BusinessMgr 3.0.1.9 Interfaces data model

This commit is contained in:
Andy Howard
2025-10-30 12:58:43 +00:00
parent 86b22db88b
commit e3cb2b26fe
35 changed files with 1355 additions and 1128 deletions
@@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.IO;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace Sarand.Net.Standard.Dbas.Base
{
@@ -101,7 +101,8 @@ namespace Sarand.Net.Standard.Dbas.Base
// Data members.
private Config config = null;
private const String DefaultSchema_MSSQL = "dbo";
private static String /*lf = "\n",*/ crlf = "\r\n", tab1 = "\t", tab2 = "\t\t", tab3 = "\t\t\t", tab4 = "\t\t\t\t", tab5 = "\t\t\t\t\t";
private static String /*lf = "\n",*/ crlf = "\r\n", tab1 = "\t", tab2 = "\t\t", tab3 = "\t\t\t", tab4 = "\t\t\t\t"; /*, tab5 = "\t\t\t\t\t";*/
// Reserved words.
private static readonly String[] reservedWords =
{
@@ -118,7 +119,7 @@ namespace Sarand.Net.Standard.Dbas.Base
// Validate configuration.
this.config = config;
if (!FileUtil.IsDirectory(config.OutputDirectory))
throw new Exception("Invalid directory specified [" + config.OutputDirectory + "]");
throw new Exception($"Invalid directory specified [{config.OutputDirectory}]");
// Validate and cleanse configuration parameters.
if (StringUtil.IsEmpty(StringUtil.TrimAll(config.TableClass.BaseClass)))
@@ -136,6 +137,24 @@ namespace Sarand.Net.Standard.Dbas.Base
// Table definitions.
List<DbDfnTable> tableDfns = new List<DbDfnTable>(config.Database.GetTableDfns());
// Convert 'Alternative' table names found in database to standard table names.
Dictionary<String, DbDfnTable> tablesByName = tableDfns.ToDictionary(tbl => tbl.Name, tbl => tbl);
foreach (DbDfnTable tableDfn in tableDfns)
{
// Check whether tabl name is in 'Alternative' list.
String standardTableName = config.Schema.AlternativeTableNames.Where(kv => kv.Value.ContainsCI(tableDfn.Name)).Select(kv => kv.Key).FirstOrDefault();
if (StringUtil.IsBlank(standardTableName)) continue;
// Check that 'Standard' table name isn't already used.
if (tablesByName.ContainsKey(standardTableName))
throw new Exception($"Cannot map alternative table name '{tableDfn.Name}' to standard table name '{standardTableName}' as standard table name already exists in database.");
// Rename table.
tablesByName.Remove(tableDfn.Name);
tableDfn.ChangeTableName(standardTableName);
tablesByName[tableDfn.Name] = tableDfn;
}
// Database schema XML.
GenerateDatabaseSchemaXml(tableDfns.Where(item => IsValidTable(item.Name, DefinitionOutput.DatabaseSchema)));
@@ -152,8 +171,9 @@ namespace Sarand.Net.Standard.Dbas.Base
private bool IsValidTable(String table, DefinitionOutput output)
{
if (String.IsNullOrEmpty(table)) return false;
if (config.Schema.Tables_Included.Count > 0 && !config.Schema.Tables_Included.ContainsCI(table)) return false;
if (config.Schema.Tables_Excluded.Count > 0 && config.Schema.Tables_Excluded.ContainsCI(table)) return false;
if (config.Schema.Tables_Included.Any() && !config.Schema.Tables_Included.ContainsCI(table) && !config.Schema.Tables_Included.Any(tbl => config.Schema.AlternativeTableNames.GetValueOrDefault(tbl)?.ContainsCI(table) ?? false))
return false;
if (config.Schema.Tables_Excluded.ContainsCI(table)) return false;
// Tables excluded from specific output.
if (output == DefinitionOutput.DatabaseSchema && config.Schema.Tables_ExcludedFromDatabaseSchema.Contains(table)) return false;
if (output == DefinitionOutput.DatabaseDefinitionClass && config.Schema.Tables_ExcludedFromDatabaseDefinitionClass.Contains(table)) return false;
@@ -267,23 +287,23 @@ namespace Sarand.Net.Standard.Dbas.Base
{
// Database definition file:
foreach (String namespace_Base in config.DefinitionClass.Usings.OrderBy(s => s))
file.WriteLine("using " + namespace_Base + ";");
file.WriteLine($"using {namespace_Base};");
file.WriteLine("using System;");
file.WriteLine("using System.Collections.Generic;");
file.WriteLine("using System.Linq;");
file.WriteLine("");
file.WriteLine("//---------------------------------------------------------------------------");
file.WriteLine("// Code generated by Sarand Database Utilities " + DateTime.Now.Format("ddd d-MMM-yyyy HH:mm:ss"));
file.WriteLine($"// Code generated by Sarand Database Utilities {DateTime.Now.Format("ddd d-MMM-yyyy HH:mm:ss")}");
file.WriteLine("//---------------------------------------------------------------------------");
file.WriteLine("namespace " + config.DefinitionClass.Namespace);
file.WriteLine($"namespace {config.DefinitionClass.Namespace}");
file.WriteLine("{");
file.WriteLine(tab1 + "public class " + config.DefinitionClass.Classname);
file.WriteLine(tab1 + "{");
file.WriteLine(tab2 + "//-------------------------------------------------------------------");
file.WriteLine($"{tab1}public class {config.DefinitionClass.Classname}");
file.WriteLine($"{tab1}{{");
GenerateDatabaseDefinitionTablesEnum(tableDfns, file);
GenerateDatabaseDefinitionColumnsEnum(tableDfns, file);
GenerateDatabaseDefinitionClass(tableDfns, config.DefinitionClass.Classname, file);
file.WriteLine(tab1 + "}");
file.WriteLine($"{crlf}{tab2}//-------------------------------------------------------------------");
file.WriteLine($"{tab1}}}");
file.WriteLine("}");
//file.Close(); - Unecessary as the object will be disposed at the end of the 'using' block which is the same as Close.
}
@@ -294,270 +314,279 @@ namespace Sarand.Net.Standard.Dbas.Base
//-------------------------------------------------------------------
public static void GenerateDatabaseDefinitionTablesEnum(IEnumerable<DbDfnTable> tableDfns, StreamWriter file)
{
file.WriteLine(tab2 + "// Table identifiers.");
file.WriteLine(tab2 + "public enum TableIdx");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "Unknown = 0,");
// No need or CR before opening comment line as at top of class.
file.WriteLine(@" //-------------------------------------------------------------------
// Table identifiers.
public enum TableIdx
{
Unknown = 0,");
foreach (DbDfnTable tableDfn in tableDfns)
{
file.WriteLine(tab3 + tableDfn.Name + ",");
}
file.WriteLine(tab2 + "}");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine($"{tab3}{tableDfn.Name},");
file.WriteLine($"{tab2}}}");
}
//-------------------------------------------------------------------
public static void GenerateDatabaseDefinitionColumnsEnum(IEnumerable<DbDfnTable> tableDfns, StreamWriter file)
{
file.WriteLine(tab2 + "// Column identifiers.");
file.WriteLine(tab2 + "public enum ColumnIdx");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "Unknown = 0,");
file.WriteLine(@"
//-------------------------------------------------------------------
// Column identifiers.
public enum ColumnIdx
{
Unknown = 0,");
foreach (DbDfnTable tableDfn in tableDfns)
{
foreach (var columnDfn in tableDfn.Columns)
file.WriteLine(tab3 + tableDfn.Name + "_" + columnDfn.Name + ",");
file.WriteLine($"{tab3}{tableDfn.Name}_{columnDfn.Name},");
}
file.WriteLine(tab2 + "}");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine($"{tab2}}}");
}
//-------------------------------------------------------------------
public static void GenerateDatabaseDefinitionClass(IEnumerable<DbDfnTable> tableDfns, String classnameDefinition, StreamWriter file)
{
file.WriteLine(tab2 + "// Data members.");
file.WriteLine(tab2 + "private static readonly int tableCount = " + tableDfns.Count() + ";");
file.WriteLine(tab2 + "private static readonly int columnCount = " + tableDfns.GetColumnCount() + ";");
file.WriteLine(tab2 + "public static ulong MaxTextLen { get; private set; }");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
// Data members.
file.WriteLine(@$"
//-------------------------------------------------------------------
// Data members.
private static readonly int tableCount = {tableDfns.Count()};
private static readonly int columnCount = {tableDfns.GetColumnCount()};
public static ulong MaxTextLen {{ get; private set; }}");
// Table methods.
file.WriteLine(tab2 + "// Retrieve Table details (eg. name: 'Company').");
file.WriteLine(tab2 + "public static int GetTableCount ()");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "return tableCount;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static String GetSchemaName (TableIdx table, bool delimitReservedWords = true)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int tableIdx = (int)table - 1;");
file.WriteLine(tab3 + "if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;");
file.WriteLine(tab3 + "String schemaName = tables[(int)tableIdx].Schema;");
file.WriteLine(tab3 + "if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); }");
file.WriteLine(tab3 + "return schemaName;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static String GetTableName (TableIdx table, bool delimitReservedWords = true)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int tableIdx = (int)table - 1;");
file.WriteLine(tab3 + "if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;");
file.WriteLine(tab3 + "String tableName = tables[(int)tableIdx].Name;");
file.WriteLine(tab3 + "if (delimitReservedWords) tableName = DelimitReservedWord(tableName);");
file.WriteLine(tab3 + "return tableName;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static String GetTableNameQual (TableIdx table, bool delimitReservedWords = true)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int tableIdx = (int)table - 1;");
file.WriteLine(tab3 + "if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;");
file.WriteLine(tab3 + "String schemaName = tables[(int)tableIdx].Schema;");
file.WriteLine(tab3 + "String tableName = tables[(int)tableIdx].Name;");
file.WriteLine(tab3 + "if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); tableName = DelimitReservedWord(tableName); }");
file.WriteLine(tab3 + "return (StringUtil.IsBlank(schemaName) ? \"\" : schemaName + \".\") + tableName;");
file.WriteLine(tab2 + "}");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine(@"
//-------------------------------------------------------------------
// Retrieve Table details.
public static int GetTableCount ()
{
return tableCount;
}
public static String GetSchemaName (TableIdx table, bool delimitReservedWords = true)
{
int tableIdx = (int)table - 1;
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
String schemaName = tables[(int)tableIdx].Schema;
if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); }
return schemaName;
}
public static String GetTableName (TableIdx table, bool delimitReservedWords = true)
{
int tableIdx = (int)table - 1;
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
String tableName = tables[(int)tableIdx].Name;
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
return tableName;
}
public static String GetTableNameQual (TableIdx table, bool delimitReservedWords = true)
{
int tableIdx = (int)table - 1;
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
String schemaName = tables[(int)tableIdx].Schema;
String tableName = tables[(int)tableIdx].Name;
if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); tableName = DelimitReservedWord(tableName); }
return (StringUtil.IsBlank(schemaName) ? """" : schemaName + ""."") + tableName;
}");
// Table for Column method.
file.WriteLine(tab2 + "// Identify the table that corresponds with the specified column.");
file.WriteLine(tab2 + "public static TableIdx GetTableForColumn (ColumnIdx column)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int columnIdx = (int)column - 1;");
file.WriteLine(tab3 + "if (columnIdx < 0 || columnIdx >= columnCount) return TableIdx.Unknown;");
file.WriteLine(tab3 + "return columns[columnIdx].TableIdx;");
file.WriteLine(tab2 + "}");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine(@"
//-------------------------------------------------------------------
// Identify the table that corresponds with the specified column.
public static TableIdx GetTableForColumn (ColumnIdx column)
{
int columnIdx = (int)column - 1;
if (columnIdx < 0 || columnIdx >= columnCount) return TableIdx.Unknown;
return columns[columnIdx].TableIdx;
}");
// Column methods.
file.WriteLine(tab2 + "// Retrieve the specified Column's name (Qualified include table name: '(<Table>.Column>)').");
file.WriteLine(tab2 + "public static String GetColumnName (ColumnIdx column, bool delimitReservedWords = true)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int columnIdx = (int)column - 1;");
file.WriteLine(tab3 + "if (columnIdx < 0 || columnIdx >= columnCount) return String.Empty;");
file.WriteLine(tab3 + "String columnName = columns[columnIdx].Name;");
file.WriteLine(tab3 + "if (delimitReservedWords) columnName = DelimitReservedWord(columnName);");
file.WriteLine(tab3 + "return columnName;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static String GetColumnNameQual (ColumnIdx column, String tableAlias = \"\", bool braces = false)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "String columnName = GetColumnName(column);");
file.WriteLine(tab3 + "if (!String.IsNullOrEmpty(columnName))");
file.WriteLine(tab3 + "{");
file.WriteLine(tab4 + "String tableName = StringUtil.EmptyOnNull(tableAlias);");
file.WriteLine(tab4 + "if (tableName.IsEmpty()) tableName = GetTableName(GetTableForColumn(column));");
file.WriteLine(tab4 + "columnName = tableName + (tableName.Length > 0 ? \".\" : \"\") + columnName;");
file.WriteLine(tab4 + "if (braces)");
file.WriteLine(tab5 + "columnName = \"(\" + columnName + \")\";");
file.WriteLine(tab3 + "}");
file.WriteLine(tab3 + "return columnName;");
file.WriteLine(tab2 + "}");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine(@"
//-------------------------------------------------------------------
// Retrieve the specified Column's name (Qualified include table name: '(<Table>.Column>)').
public static String GetColumnName (ColumnIdx column, bool delimitReservedWords = true)
{
int columnIdx = (int)column - 1;
if (columnIdx < 0 || columnIdx >= columnCount) return String.Empty;
String columnName = columns[columnIdx].Name;
if (delimitReservedWords) columnName = DelimitReservedWord(columnName);
return columnName;
}
public static String GetColumnNameQual (ColumnIdx column, String tableAlias = """", bool braces = false)
{
String columnName = GetColumnName(column);
if (!String.IsNullOrEmpty(columnName))
{
String tableName = StringUtil.EmptyOnNull(tableAlias);
if (tableName.IsEmpty()) tableName = GetTableName(GetTableForColumn(column));
columnName = tableName + (tableName.Length > 0 ? ""."" : """") + columnName;
if (braces) columnName = $""({columnName})"";
}
return columnName;
}");
// Reserved word methods.
file.WriteLine(tab2 + "// Reserved words.");
file.WriteLine(tab2 + "private static DbReservedWordDelim reservedWordDelim = DbReservedWordDelim.SquareBrackets;");
file.WriteLine(tab2 + "public static void SetReservedWordDelim (DbReservedWordDelim reservedWordDelim)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + classnameDefinition + ".reservedWordDelim = reservedWordDelim;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static bool IsReservedWord (String word)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "if (String.IsNullOrEmpty(word)) return false;");
file.WriteLine(tab3 + "if (reservedWords.Contains(word, StringComparer.OrdinalIgnoreCase)) return true;");
file.WriteLine(tab3 + "return false;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static String DelimitReservedWord (String word)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "return IsReservedWord(word) ? DelimitWord(word) : word;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static String DelimitWord (String word)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "return DelimitWord(word, reservedWordDelim);");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static String DelimitWord (String word, DbReservedWordDelim wordDelim)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "switch (wordDelim)");
file.WriteLine(tab3 + "{");
file.WriteLine(tab4 + "case DbReservedWordDelim.None:");
file.WriteLine(tab5 + "break;");
file.WriteLine(tab4 + "case DbReservedWordDelim.DoubleQuotes:");
file.WriteLine(tab5 + "word = \"\\\"\" + word + \"\\\"\"; ");
file.WriteLine(tab5 + "break;");
file.WriteLine(tab4 + "case DbReservedWordDelim.SquareBrackets:");
file.WriteLine(tab4 + "default:");
file.WriteLine(tab5 + "word = \"[\" + word + \"]\"; ");
file.WriteLine(tab5 + "break;");
file.WriteLine(tab3 + "}");
file.WriteLine(tab3 + "return word;");
file.WriteLine(tab2 + "}");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine(@"
//-------------------------------------------------------------------
// Reserved words.
private static DbReservedWordDelim reservedWordDelim = DbReservedWordDelim.SquareBrackets;
public static void SetReservedWordDelim (DbReservedWordDelim reservedWordDelim)
{
" + classnameDefinition + @".reservedWordDelim = reservedWordDelim;
}
public static bool IsReservedWord (String word)
{
if (String.IsNullOrEmpty(word)) return false;
if (reservedWords.Contains(word, StringComparer.OrdinalIgnoreCase)) return true;
return false;
}
public static String DelimitReservedWord (String word)
{
return IsReservedWord(word) ? DelimitWord(word) : word;
}
public static String DelimitWord (String word)
{
return DelimitWord(word, reservedWordDelim);
}
public static String DelimitWord (String word, DbReservedWordDelim wordDelim)
{
switch (wordDelim)
{
case DbReservedWordDelim.None:
break;
case DbReservedWordDelim.DoubleQuotes:
word = $""\""{word}\"""";
break;
case DbReservedWordDelim.SquareBrackets:
default:
word = $""[{word}]"";
break;
}
return word;
}");
// Column information methods.
file.WriteLine(tab2 + "// Retrieve information about the specified Column.");
file.WriteLine(tab2 + "public static DbColumnDataType GetColDataType (ColumnIdx column)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int columnIdx = (int)column - 1;");
file.WriteLine(tab3 + "if (columnIdx < 0 || columnIdx >= columnCount) return DbColumnDataType.Unknown;");
file.WriteLine(tab3 + "return columns[columnIdx].DataType;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static short GetColNativeDataType (ColumnIdx column)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int columnIdx = (int)column - 1;");
file.WriteLine(tab3 + "if (columnIdx < 0 || columnIdx >= columnCount) return 0;");
file.WriteLine(tab3 + "return columns[columnIdx].NativeDataType;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static void SetMaxTextLen (ulong maxTextLen)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + classnameDefinition + ".MaxTextLen = maxTextLen;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static bool IsColFmtText (ColumnIdx column)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int columnIdx = (int)column - 1;");
file.WriteLine(tab3 + "if (columnIdx < 0 || columnIdx >= columnCount) return false;");
file.WriteLine(tab3 + "return (columns[columnIdx].DataType == DbColumnDataType.VarChar);");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static ulong GetColTextLen (ColumnIdx column)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int columnIdx = (int)column - 1;");
file.WriteLine(tab3 + "if (columnIdx < 0 || columnIdx >= columnCount) return 0;");
file.WriteLine(tab3 + "if (columns[columnIdx].DataType == DbColumnDataType.VarChar)");
file.WriteLine(tab3 + "{");
file.WriteLine(tab4 + "ulong textLen = columns[columnIdx].DataLen;");
file.WriteLine(tab4 + "if (MaxTextLen > 0 && textLen > MaxTextLen) textLen = MaxTextLen;");
file.WriteLine(tab4 + "return textLen;");
file.WriteLine(tab3 + "}");
file.WriteLine(tab3 + "return 0;");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static bool IsColFmtBool (ColumnIdx column)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int columnIdx = (int)column - 1;");
file.WriteLine(tab3 + "if (columnIdx < 0 || columnIdx >= columnCount) return false;");
file.WriteLine(tab3 + "return (columns[columnIdx].DataType == DbColumnDataType.Bit);");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "public static bool IsColFmtNumeric (ColumnIdx column)");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "int columnIdx = (int)column - 1;");
file.WriteLine(tab3 + "if (columnIdx < 0 || columnIdx >= columnCount) return false;");
file.WriteLine(tab3 + "switch (columns[columnIdx].DataType)");
file.WriteLine(tab3 + "{");
file.WriteLine(tab4 + "case DbColumnDataType.TinyInt:");
file.WriteLine(tab4 + "case DbColumnDataType.SmallInt:");
file.WriteLine(tab4 + "case DbColumnDataType.Int:");
file.WriteLine(tab4 + "case DbColumnDataType.BigInt:");
file.WriteLine(tab4 + "case DbColumnDataType.Single:");
file.WriteLine(tab4 + "case DbColumnDataType.Double:");
file.WriteLine(tab4 + "case DbColumnDataType.Decimal:");
file.WriteLine(tab5 + "return true;");
file.WriteLine(tab3 + "}");
file.WriteLine(tab3 + "return false;");
file.WriteLine(tab2 + "}");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine(@"
//-------------------------------------------------------------------
// Retrieve information about the specified Column.
public static DbColumnDataType GetColDataType (ColumnIdx column)
{
int columnIdx = (int)column - 1;
if (columnIdx < 0 || columnIdx >= columnCount) return DbColumnDataType.Unknown;
return columns[columnIdx].DataType;
}
public static short GetColNativeDataType (ColumnIdx column)
{
int columnIdx = (int)column - 1;
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
return columns[columnIdx].NativeDataType;
}
public static void SetMaxTextLen (ulong maxTextLen)
{
" + classnameDefinition + @".MaxTextLen = maxTextLen;
}
public static bool IsColFmtText (ColumnIdx column)
{
int columnIdx = (int)column - 1;
if (columnIdx < 0 || columnIdx >= columnCount) return false;
return (columns[columnIdx].DataType == DbColumnDataType.VarChar);
}
public static ulong GetColTextLen (ColumnIdx column)
{
int columnIdx = (int)column - 1;
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
if (columns[columnIdx].DataType == DbColumnDataType.VarChar)
{
ulong textLen = columns[columnIdx].DataLen;
if (MaxTextLen > 0 && textLen > MaxTextLen) textLen = MaxTextLen;
return textLen;
}
return 0;
}
public static bool IsColFmtBool (ColumnIdx column)
{
int columnIdx = (int)column - 1;
if (columnIdx < 0 || columnIdx >= columnCount) return false;
return (columns[columnIdx].DataType == DbColumnDataType.Bit);
}
public static bool IsColFmtNumeric (ColumnIdx column)
{
int columnIdx = (int)column - 1;
if (columnIdx < 0 || columnIdx >= columnCount) return false;
switch (columns[columnIdx].DataType)
{
case DbColumnDataType.TinyInt:
case DbColumnDataType.SmallInt:
case DbColumnDataType.Int:
case DbColumnDataType.BigInt:
case DbColumnDataType.Single:
case DbColumnDataType.Double:
case DbColumnDataType.Decimal:
return true;
}
return false;
}");
// Table names.
file.WriteLine(tab2 + "// Table definitions.");
file.WriteLine(tab2 + "private class TableDfn");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "internal String Schema { get; set; }");
file.WriteLine(tab3 + "internal String Name { get; set; }");
file.WriteLine(tab3 + "internal TableDfn (String schema, String name)");
file.WriteLine(tab3 + "{");
file.WriteLine(tab4 + "this.Schema= schema;");
file.WriteLine(tab4 + "this.Name = name;");
file.WriteLine(tab3 + "}");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "private static readonly TableDfn[] tables =");
file.WriteLine(tab2 + "{");
file.WriteLine(@"
//-------------------------------------------------------------------
// Table definitions.
private class TableDfn
{
internal String Schema { get; set; }
internal String Name { get; set; }
internal TableDfn (String schema, String name)
{
this.Schema= schema;
this.Name = name;
}
}
private static readonly TableDfn[] tables =
{");
foreach (DbDfnTable tableDfn in tableDfns)
file.WriteLine(tab3 + "new TableDfn(\"" + tableDfn.Schema + "\",\"" + tableDfn.Name + "\"),");
file.WriteLine(tab2 + "};");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine($"{tab2}}};");
// Table Column definitions.
file.WriteLine(tab2 + "// Table column definitions.");
file.WriteLine(tab2 + "private class ColumnDfn");
file.WriteLine(tab2 + "{");
file.WriteLine(tab3 + "internal TableIdx TableIdx { get; set; }");
file.WriteLine(tab3 + "internal String Name { get; set; }");
file.WriteLine(tab3 + "internal DbColumnDataType DataType { get; set; }");
file.WriteLine(tab3 + "internal short NativeDataType { get; set; }");
file.WriteLine(tab3 + "internal bool IsIdentity { get; set; }");
file.WriteLine(tab3 + "internal ulong DataLen { get; set; }");
file.WriteLine(tab3 + "internal ColumnDfn (int tableIdx, String name, int dataType, short nativeDataType, bool isIdentity, ulong dataLen)");
file.WriteLine(tab3 + "{");
file.WriteLine(tab4 + "this.TableIdx = (TableIdx)tableIdx;");
file.WriteLine(tab4 + "this.Name = name;");
file.WriteLine(tab4 + "this.DataType = (DbColumnDataType)dataType;");
file.WriteLine(tab4 + "this.NativeDataType = nativeDataType;");
file.WriteLine(tab4 + "this.IsIdentity = isIdentity;");
file.WriteLine(tab4 + "this.DataLen = dataLen;");
file.WriteLine(tab3 + "}");
file.WriteLine(tab2 + "}");
file.WriteLine(tab2 + "private static readonly ColumnDfn[] columns =");
file.WriteLine(tab2 + "{");
file.WriteLine(@"
//-------------------------------------------------------------------
// Table column definitions.
private class ColumnDfn
{
internal TableIdx TableIdx { get; set; }
internal String Name { get; set; }
internal DbColumnDataType DataType { get; set; }
internal short NativeDataType { get; set; }
internal bool IsIdentity { get; set; }
internal ulong DataLen { get; set; }
internal ColumnDfn (int tableIdx, String name, int dataType, short nativeDataType, bool isIdentity, ulong dataLen)
{
this.TableIdx = (TableIdx)tableIdx;
this.Name = name;
this.DataType = (DbColumnDataType)dataType;
this.NativeDataType = nativeDataType;
this.IsIdentity = isIdentity;
this.DataLen = dataLen;
}
}
private static readonly ColumnDfn[] columns =
{");
uint tableIdx = 0;
foreach (DbDfnTable tableDfn in tableDfns)
{
tableIdx++;
foreach (var columnDfn in tableDfn.Columns)
file.WriteLine(tab3 + "new ColumnDfn(" + tableIdx.ToString() + ",\"" + columnDfn.Name + "\"," + ((int)columnDfn.DataType).ToString() + "," + columnDfn.DataTypeNative.ToString() + "," + (columnDfn.IsIdentity ? "true" : "false") + "," + columnDfn.Size.ToString() + "),");
file.WriteLine($"{tab3}new ColumnDfn({tableIdx},\"{columnDfn.Name}\",{(int)columnDfn.DataType},{columnDfn.DataTypeNative},{(columnDfn.IsIdentity ? "true" : "false")},{columnDfn.Size}),");
}
file.WriteLine(tab2 + "};");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine($"{tab2}}};");
// Reserved words.
file.WriteLine(tab2 + "// Reserved words.");
file.WriteLine(tab2 + "private static readonly HashSet<String> reservedWords = new HashSet<String>()");
file.WriteLine(tab2 + "{");
foreach (String reservedword in reservedWords)
file.WriteLine(tab3 + "\"" + reservedword + "\", ");
file.WriteLine(tab2 + "};");
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine(@"
//-------------------------------------------------------------------
// Reserved words.
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
" + reservedWords.Concat($",{crlf}{tab3}", "\"", "\"") + @"
};");
}
//-------------------------------------------------------------------
@@ -631,23 +660,23 @@ namespace Sarand.Net.Standard.Dbas.Base
file.WriteLine(tab2 + "// Data members.");
file.WriteLine(tab2 + "protected static List<String> fields { get; } = new List<String>()");
file.WriteLine(tab2 + "{");
foreach (var columnDfn in tableDfn.Columns) file.WriteLine(tab3 + "\"" + columnDfn.Name + "\",");
foreach (var columnDfn in tableDfn.Columns) file.WriteLine($"{tab3}\"{columnDfn.Name}\",");
file.WriteLine(tab2 + "};");
file.WriteLine(tab2 + "protected static List<String> fieldsId { get; } = new List<String>()");
file.WriteLine(tab2 + "{");
foreach (var columnDfn in tableDfn.Columns.FindAll(item => item.IsIdentity)) file.WriteLine(tab3 + "\"" + columnDfn.Name + "\",");
foreach (var columnDfn in tableDfn.Columns.FindAll(item => item.IsIdentity)) file.WriteLine($"{tab3}\"{columnDfn.Name}\",");
file.WriteLine(tab2 + "};");
file.WriteLine(tab2 + "protected static List<String> fieldsPrimary { get; } = new List<String>()");
file.WriteLine(tab2 + "{");
foreach (String columnName in primaryColumnNames) file.WriteLine(tab3 + "\"" + columnName + "\",");
foreach (String columnName in primaryColumnNames) file.WriteLine($"{tab3}\"{columnName}\",");
file.WriteLine(tab2 + "};");
file.WriteLine(tab2 + "protected static List<String> fieldsNullable { get; } = new List<String>()");
file.WriteLine(tab2 + "{");
foreach (var columnDfn in tableDfn.Columns.FindAll(item => item.IsNullable)) file.WriteLine(tab3 + "\"" + columnDfn.Name + "\",");
foreach (var columnDfn in tableDfn.Columns.FindAll(item => item.IsNullable)) file.WriteLine($"{tab3}\"{columnDfn.Name}\",");
file.WriteLine(tab2 + "};");
file.WriteLine(tab2 + "protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()");
file.WriteLine(tab2 + "{");
foreach (String columnName in columnsIgnoredOnUpdate) file.WriteLine(tab3 + "\"" + columnName + "\",");
foreach (String columnName in columnsIgnoredOnUpdate) file.WriteLine($"{tab3}\"{columnName}\",");
file.WriteLine(tab2 + "};");
/*
file.WriteLine(tab2 + "protected static List<String> fieldsNonId { get; } = new List<String>()");
@@ -668,14 +697,14 @@ namespace Sarand.Net.Standard.Dbas.Base
// Properties.
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
file.WriteLine(tab2 + "// Properties.");
file.WriteLine(tab2 + "public override String SchemaName { get; } = \"" + tableDfn.Schema + "\";");
file.WriteLine(tab2 + $"public override String SchemaName {{ get; }} = \"{tableDfn.Schema}\";");
if (alternativeTableNames.Count == 0)
file.WriteLine(tab2 + "public override String TableName { get; } = \"" + tableDfn.Name + "\";");
file.WriteLine(tab2 + $"public override String TableName {{ get; }} = \"{tableDfn.Name}\";");
else
{
// Logic to handle alternative table names.
file.WriteLine(tab2 + "public override String TableName { get { return GetActualTableName(\"" + tableDfn.Name + "\"); } }");
file.WriteLine(tab2 + "public override List<String> AlternativeTableNames { get; } = new List<string>() { " + alternativeTableNames.Concat(", ", "\"", "\"") + " };");
file.WriteLine(tab2 + $"public override String TableName {{ get {{ return GetActualTableName(\"{tableDfn.Name}\"); }} }}");
file.WriteLine(tab2 + $"public override List<String> AlternativeTableNames {{ get; }} = new List<string>() {{ {alternativeTableNames.Concat(", ", "\"", "\"")} }};");
}
file.WriteLine(tab2 + "public String TableNameFmt { get { return (!String.IsNullOrEmpty(SchemaName) ? \"[\" + SchemaName + \"].\" : \"\") + \"[\" + TableName + \"]\"; } }");
file.WriteLine(tab2 + "public static List<String> Fields { get { return new List<String>(fields); } }");
@@ -684,7 +713,7 @@ namespace Sarand.Net.Standard.Dbas.Base
file.WriteLine(tab2 + "// Columns.");
file.WriteLine(tab2 + "public ColumnsData Cols { get; } = new ColumnsData();");
foreach (var columnDfn in tableDfn.Columns)
file.WriteLine(tab2 + "public " + GetColumnVariableType(columnDfn) + (TreatColumnAsNullable(columnDfn) ? "?" : "") + " _" + columnDfn.Name + " { get { return Cols._" + columnDfn.Name + ".Value; } set { Cols._" + columnDfn.Name + ".Value = value; } }");
file.WriteLine(tab2 + $"public {GetColumnVariableType(columnDfn)}{(TreatColumnAsNullable(columnDfn) ? "?" : "")} _{columnDfn.Name} {{ get {{ return Cols._{columnDfn.Name}.Value; }} set {{ Cols._{columnDfn.Name}.Value = value; }} }}");
file.WriteLine(tab2 + "// Existing columns - confirmed on database if table exists.");
file.WriteLine(tab2 + "public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }");
file.WriteLine(tab2 + "public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }");
+19 -14
View File
@@ -1,16 +1,16 @@
using System;
using Microsoft.Win32;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Dbas.Data;
namespace Sarand.Net.Standard.Dbas.Base
{
@@ -209,19 +209,24 @@ namespace Sarand.Net.Standard.Dbas.Base
columnNameValues.Add(columnName, SysId.ToInt(value).ToString());
}
/// <summary>Add numeric value pair - used to build value lists for insert and update.</summary>
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, long value)
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, Int32? value)
{
columnNameValues.Add(columnName, value.ToString());
columnNameValues.Add(columnName, value is null ? "NULL" : $"{value}");
}
/// <summary>Add numeric value pair - used to build value lists for insert and update.</summary>
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, Int64? value)
{
columnNameValues.Add(columnName, value is null ? "NULL" : $"{value}");
}
/// <summary>Add decimal value pair - used to build value lists for insert and update.</summary>
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, decimal value)
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, decimal? value)
{
columnNameValues.Add(columnName, value.ToString());
columnNameValues.Add(columnName, value is null ? "NULL" : $"{value}");
}
/// <summary>Add date/time value pair - used to build value lists for insert and update.</summary>
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, DateTime value)
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, DateTime? value)
{
AddValuePair(columnNameValues, columnName, DateUtil.Format(value, "yyyy/MM/dd HH:mm:ss"), true);
AddValuePair(columnNameValues, columnName, value is null ? "NULL" : DateUtil.Format(value, "yyyy/MM/dd HH:mm:ss"), true);
}
// Specific queries.
public abstract long GetRowCount(String tableName, String filter);
@@ -10,7 +10,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:21
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:12
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.CodeTypes.Internal
{
@@ -10,7 +10,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:21
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:12
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.CodeTypes.Internal
{
@@ -22,7 +22,7 @@ namespace Sarand.Net.Standard.Dbas.CodeType
/// </summary>
public static bool Generate(String connectionString)
{
String fn = className + ".Generate";
String fn = $"{className}.Generate";
// Locate output folder:
String directory = GetOutputFolder();
@@ -87,7 +87,7 @@ namespace Sarand.Net.Standard.Dbas.CodeType
//-------------------------------------------------------------------
private static String GetOutputFolder()
{
String fn = className + ".GetOutputFolder";
String fn = $"{className}.GetOutputFolder";
String assemblyDirectory = FileUtil.GetParentDirectory((Assembly.GetAssembly(typeof(DatabaseDefinitionGenerator)).Location));
String directory = assemblyDirectory;
SaLogger.Debug($"{fn} Assembly folder: {directory}");
@@ -1,15 +1,16 @@
using Microsoft.Data.SqlClient;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Data.Common;
using Microsoft.Data.SqlClient;
using System.Linq;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:58
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:13
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
{
@@ -26,24 +27,24 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public ColumnDataInt16 _ItemType { get; } = new ColumnDataInt16("ItemType");
public ColumnDataInt32 _ItemId { get; } = new ColumnDataInt32("ItemId");
public ColumnDataString _ProcessStatus { get; } = new ColumnDataString("ProcessStatus");
public ColumnDataInt32 _ProcessStatusBy { get; } = new ColumnDataInt32("ProcessStatusBy");
public ColumnDataDateTime _ProcessStatusAt { get; } = new ColumnDataDateTime("ProcessStatusAt");
public ColumnDataInt32Nullable _ProcessStatusBy { get; } = new ColumnDataInt32Nullable("ProcessStatusBy");
public ColumnDataDateTimeNullable _ProcessStatusAt { get; } = new ColumnDataDateTimeNullable("ProcessStatusAt");
public ColumnDataString _ItemStatus { get; } = new ColumnDataString("ItemStatus");
public ColumnDataInt32 _ItemStatusBy { get; } = new ColumnDataInt32("ItemStatusBy");
public ColumnDataDateTime _ItemStatusAt { get; } = new ColumnDataDateTime("ItemStatusAt");
public ColumnDataInt32Nullable _ItemStatusBy { get; } = new ColumnDataInt32Nullable("ItemStatusBy");
public ColumnDataDateTimeNullable _ItemStatusAt { get; } = new ColumnDataDateTimeNullable("ItemStatusAt");
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy");
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy");
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
}
//-------------------------------------------------------------------
// Data members.
private static List<String> fields { get; } = new List<String>()
protected static List<String> fields { get; } = new List<String>()
{
"Id",
"InterfaceId",
@@ -66,14 +67,32 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
"UpdateBy",
"UpdateHost",
};
private static List<String> fieldsId { get; } = new List<String>()
protected static List<String> fieldsId { get; } = new List<String>()
{
};
private static List<String> fieldsPrimary { get; } = new List<String>()
protected static List<String> fieldsPrimary { get; } = new List<String>()
{
"Id",
};
private static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
protected static List<String> fieldsNullable { get; } = new List<String>()
{
"ExternalRef",
"ProcessStatus",
"ProcessStatusBy",
"ProcessStatusAt",
"ItemStatus",
"ItemStatusBy",
"ItemStatusAt",
"Notes",
"Flags",
"CreateOn",
"CreateBy",
"CreateHost",
"UpdateOn",
"UpdateBy",
"UpdateHost",
};
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
{
"CreateOn",
"CreateBy",
@@ -108,22 +127,23 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public Int16 _ItemType { get { return Cols._ItemType.Value; } set { Cols._ItemType.Value = value; } }
public Int32 _ItemId { get { return Cols._ItemId.Value; } set { Cols._ItemId.Value = value; } }
public String _ProcessStatus { get { return Cols._ProcessStatus.Value; } set { Cols._ProcessStatus.Value = value; } }
public Int32 _ProcessStatusBy { get { return Cols._ProcessStatusBy.Value; } set { Cols._ProcessStatusBy.Value = value; } }
public DateTime _ProcessStatusAt { get { return Cols._ProcessStatusAt.Value; } set { Cols._ProcessStatusAt.Value = value; } }
public Int32? _ProcessStatusBy { get { return Cols._ProcessStatusBy.Value; } set { Cols._ProcessStatusBy.Value = value; } }
public DateTime? _ProcessStatusAt { get { return Cols._ProcessStatusAt.Value; } set { Cols._ProcessStatusAt.Value = value; } }
public String _ItemStatus { get { return Cols._ItemStatus.Value; } set { Cols._ItemStatus.Value = value; } }
public Int32 _ItemStatusBy { get { return Cols._ItemStatusBy.Value; } set { Cols._ItemStatusBy.Value = value; } }
public DateTime _ItemStatusAt { get { return Cols._ItemStatusAt.Value; } set { Cols._ItemStatusAt.Value = value; } }
public Int32? _ItemStatusBy { get { return Cols._ItemStatusBy.Value; } set { Cols._ItemStatusBy.Value = value; } }
public DateTime? _ItemStatusAt { get { return Cols._ItemStatusAt.Value; } set { Cols._ItemStatusAt.Value = value; } }
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
// Existing columns - confirmed on database if table exists.
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
//-------------------------------------------------------------------
// Population.
@@ -149,18 +169,18 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
_ItemType = GetFieldInt16(dbDataReader, "ItemType", _ItemType);
_ItemId = GetFieldInt32(dbDataReader, "ItemId", _ItemId);
_ProcessStatus = GetFieldString(dbDataReader, "ProcessStatus", _ProcessStatus);
_ProcessStatusBy = GetFieldInt32(dbDataReader, "ProcessStatusBy", _ProcessStatusBy);
_ProcessStatusAt = GetFieldDateTime(dbDataReader, "ProcessStatusAt", _ProcessStatusAt);
_ProcessStatusBy = GetFieldInt32Nullable(dbDataReader, "ProcessStatusBy", _ProcessStatusBy);
_ProcessStatusAt = GetFieldDateTimeNullable(dbDataReader, "ProcessStatusAt", _ProcessStatusAt);
_ItemStatus = GetFieldString(dbDataReader, "ItemStatus", _ItemStatus);
_ItemStatusBy = GetFieldInt32(dbDataReader, "ItemStatusBy", _ItemStatusBy);
_ItemStatusAt = GetFieldDateTime(dbDataReader, "ItemStatusAt", _ItemStatusAt);
_ItemStatusBy = GetFieldInt32Nullable(dbDataReader, "ItemStatusBy", _ItemStatusBy);
_ItemStatusAt = GetFieldDateTimeNullable(dbDataReader, "ItemStatusAt", _ItemStatusAt);
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy);
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
}
@@ -212,10 +232,15 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
//-------------------------------------------------------------------
// Update command.
public override bool ExecuteUpdateCommand (DbCommand dbCommand)
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
{
// Columns to update.
List<String> columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList();
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
if (!columnNames.Any())
{
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
return false;
}
// Construct query.
String query = "UPDATE " + TableNameFmt + " SET ";
if (dbCommand is SqlCommand)
@@ -1,15 +1,16 @@
using Microsoft.Data.SqlClient;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Data.Common;
using Microsoft.Data.SqlClient;
using System.Linq;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:58
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:13
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
{
@@ -22,19 +23,19 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public ColumnDataInt32 _ProcessId { get; } = new ColumnDataInt32("ProcessId");
public ColumnDataInt32 _InterfaceDataItemId { get; } = new ColumnDataInt32("InterfaceDataItemId");
public ColumnDataString _ItemData { get; } = new ColumnDataString("ItemData");
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy");
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy");
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
}
//-------------------------------------------------------------------
// Data members.
private static List<String> fields { get; } = new List<String>()
protected static List<String> fields { get; } = new List<String>()
{
"ProcessId",
"InterfaceDataItemId",
@@ -48,15 +49,27 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
"UpdateBy",
"UpdateHost",
};
private static List<String> fieldsId { get; } = new List<String>()
protected static List<String> fieldsId { get; } = new List<String>()
{
};
private static List<String> fieldsPrimary { get; } = new List<String>()
protected static List<String> fieldsPrimary { get; } = new List<String>()
{
"ProcessId",
"InterfaceDataItemId",
};
private static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
protected static List<String> fieldsNullable { get; } = new List<String>()
{
"ItemData",
"Flags",
"Status",
"CreateOn",
"CreateBy",
"CreateHost",
"UpdateOn",
"UpdateBy",
"UpdateHost",
};
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
{
"CreateOn",
"CreateBy",
@@ -92,17 +105,18 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public Int32 _ProcessId { get { return Cols._ProcessId.Value; } set { Cols._ProcessId.Value = value; } }
public Int32 _InterfaceDataItemId { get { return Cols._InterfaceDataItemId.Value; } set { Cols._InterfaceDataItemId.Value = value; } }
public String _ItemData { get { return Cols._ItemData.Value; } set { Cols._ItemData.Value = value; } }
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
// Existing columns - confirmed on database if table exists.
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
//-------------------------------------------------------------------
// Population.
@@ -124,13 +138,13 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
_ProcessId = GetFieldInt32(dbDataReader, "ProcessId", _ProcessId);
_InterfaceDataItemId = GetFieldInt32(dbDataReader, "InterfaceDataItemId", _InterfaceDataItemId);
_ItemData = GetFieldString(dbDataReader, "ItemData", _ItemData);
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
_Status = GetFieldString(dbDataReader, "Status", _Status);
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy);
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
}
@@ -173,10 +187,15 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
//-------------------------------------------------------------------
// Update command.
public override bool ExecuteUpdateCommand (DbCommand dbCommand)
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
{
// Columns to update.
List<String> columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList();
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
if (!columnNames.Any())
{
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
return false;
}
// Construct query.
String query = "UPDATE " + TableNameFmt + " SET ";
if (dbCommand is SqlCommand)
@@ -1,15 +1,16 @@
using Microsoft.Data.SqlClient;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Data.Common;
using Microsoft.Data.SqlClient;
using System.Linq;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:58
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:13
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
{
@@ -24,22 +25,22 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public ColumnDataString _MsgType { get; } = new ColumnDataString("MsgType");
public ColumnDataString _Msg { get; } = new ColumnDataString("Msg");
public ColumnDataString _FileName { get; } = new ColumnDataString("FileName");
public ColumnDataInt32 _LineNumber { get; } = new ColumnDataInt32("LineNumber");
public ColumnDataInt16 _ItemType { get; } = new ColumnDataInt16("ItemType");
public ColumnDataInt32 _ItemId { get; } = new ColumnDataInt32("ItemId");
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
public ColumnDataInt32Nullable _LineNumber { get; } = new ColumnDataInt32Nullable("LineNumber");
public ColumnDataInt16Nullable _ItemType { get; } = new ColumnDataInt16Nullable("ItemType");
public ColumnDataInt32Nullable _ItemId { get; } = new ColumnDataInt32Nullable("ItemId");
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy");
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy");
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
}
//-------------------------------------------------------------------
// Data members.
private static List<String> fields { get; } = new List<String>()
protected static List<String> fields { get; } = new List<String>()
{
"Id",
"ProcessId",
@@ -58,14 +59,31 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
"UpdateBy",
"UpdateHost",
};
private static List<String> fieldsId { get; } = new List<String>()
protected static List<String> fieldsId { get; } = new List<String>()
{
};
private static List<String> fieldsPrimary { get; } = new List<String>()
protected static List<String> fieldsPrimary { get; } = new List<String>()
{
"Id",
};
private static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
protected static List<String> fieldsNullable { get; } = new List<String>()
{
"MsgType",
"Msg",
"FileName",
"LineNumber",
"ItemType",
"ItemId",
"Flags",
"Status",
"CreateOn",
"CreateBy",
"CreateHost",
"UpdateOn",
"UpdateBy",
"UpdateHost",
};
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
{
"CreateOn",
"CreateBy",
@@ -102,20 +120,21 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public String _MsgType { get { return Cols._MsgType.Value; } set { Cols._MsgType.Value = value; } }
public String _Msg { get { return Cols._Msg.Value; } set { Cols._Msg.Value = value; } }
public String _FileName { get { return Cols._FileName.Value; } set { Cols._FileName.Value = value; } }
public Int32 _LineNumber { get { return Cols._LineNumber.Value; } set { Cols._LineNumber.Value = value; } }
public Int16 _ItemType { get { return Cols._ItemType.Value; } set { Cols._ItemType.Value = value; } }
public Int32 _ItemId { get { return Cols._ItemId.Value; } set { Cols._ItemId.Value = value; } }
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public Int32? _LineNumber { get { return Cols._LineNumber.Value; } set { Cols._LineNumber.Value = value; } }
public Int16? _ItemType { get { return Cols._ItemType.Value; } set { Cols._ItemType.Value = value; } }
public Int32? _ItemId { get { return Cols._ItemId.Value; } set { Cols._ItemId.Value = value; } }
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
// Existing columns - confirmed on database if table exists.
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
//-------------------------------------------------------------------
// Population.
@@ -139,16 +158,16 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
_MsgType = GetFieldString(dbDataReader, "MsgType", _MsgType);
_Msg = GetFieldString(dbDataReader, "Msg", _Msg);
_FileName = GetFieldString(dbDataReader, "FileName", _FileName);
_LineNumber = GetFieldInt32(dbDataReader, "LineNumber", _LineNumber);
_ItemType = GetFieldInt16(dbDataReader, "ItemType", _ItemType);
_ItemId = GetFieldInt32(dbDataReader, "ItemId", _ItemId);
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
_LineNumber = GetFieldInt32Nullable(dbDataReader, "LineNumber", _LineNumber);
_ItemType = GetFieldInt16Nullable(dbDataReader, "ItemType", _ItemType);
_ItemId = GetFieldInt32Nullable(dbDataReader, "ItemId", _ItemId);
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
_Status = GetFieldString(dbDataReader, "Status", _Status);
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy);
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
}
@@ -196,10 +215,15 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
//-------------------------------------------------------------------
// Update command.
public override bool ExecuteUpdateCommand (DbCommand dbCommand)
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
{
// Columns to update.
List<String> columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList();
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
if (!columnNames.Any())
{
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
return false;
}
// Construct query.
String query = "UPDATE " + TableNameFmt + " SET ";
if (dbCommand is SqlCommand)
@@ -1,15 +1,16 @@
using Microsoft.Data.SqlClient;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Data.Common;
using Microsoft.Data.SqlClient;
using System.Linq;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:58
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:13
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
{
@@ -23,18 +24,18 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public ColumnDataInt32 _InterfaceId { get; } = new ColumnDataInt32("InterfaceId");
public ColumnDataInt16 _Direction { get; } = new ColumnDataInt16("Direction");
public ColumnDataString _ProcRef { get; } = new ColumnDataString("ProcRef");
public ColumnDataInt32 _ProcSeq { get; } = new ColumnDataInt32("ProcSeq");
public ColumnDataDateTime _ProcessAt { get; } = new ColumnDataDateTime("ProcessAt");
public ColumnDataDateTime _BatchAt { get; } = new ColumnDataDateTime("BatchAt");
public ColumnDataInt32 _ElapseSecs { get; } = new ColumnDataInt32("ElapseSecs");
public ColumnDataInt32 _ItemCount { get; } = new ColumnDataInt32("ItemCount");
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
public ColumnDataInt32Nullable _ProcSeq { get; } = new ColumnDataInt32Nullable("ProcSeq");
public ColumnDataDateTimeNullable _ProcessAt { get; } = new ColumnDataDateTimeNullable("ProcessAt");
public ColumnDataDateTimeNullable _BatchAt { get; } = new ColumnDataDateTimeNullable("BatchAt");
public ColumnDataInt32Nullable _ElapseSecs { get; } = new ColumnDataInt32Nullable("ElapseSecs");
public ColumnDataInt32Nullable _ItemCount { get; } = new ColumnDataInt32Nullable("ItemCount");
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy");
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy");
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
}
@@ -67,6 +68,23 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
{
"Id",
};
protected static List<String> fieldsNullable { get; } = new List<String>()
{
"ProcRef",
"ProcSeq",
"ProcessAt",
"BatchAt",
"ElapseSecs",
"ItemCount",
"Flags",
"Status",
"CreateOn",
"CreateBy",
"CreateHost",
"UpdateOn",
"UpdateBy",
"UpdateHost",
};
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
{
"CreateOn",
@@ -102,22 +120,23 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public Int32 _InterfaceId { get { return Cols._InterfaceId.Value; } set { Cols._InterfaceId.Value = value; } }
public Int16 _Direction { get { return Cols._Direction.Value; } set { Cols._Direction.Value = value; } }
public String _ProcRef { get { return Cols._ProcRef.Value; } set { Cols._ProcRef.Value = value; } }
public Int32 _ProcSeq { get { return Cols._ProcSeq.Value; } set { Cols._ProcSeq.Value = value; } }
public DateTime _ProcessAt { get { return Cols._ProcessAt.Value; } set { Cols._ProcessAt.Value = value; } }
public DateTime _BatchAt { get { return Cols._BatchAt.Value; } set { Cols._BatchAt.Value = value; } }
public Int32 _ElapseSecs { get { return Cols._ElapseSecs.Value; } set { Cols._ElapseSecs.Value = value; } }
public Int32 _ItemCount { get { return Cols._ItemCount.Value; } set { Cols._ItemCount.Value = value; } }
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public Int32? _ProcSeq { get { return Cols._ProcSeq.Value; } set { Cols._ProcSeq.Value = value; } }
public DateTime? _ProcessAt { get { return Cols._ProcessAt.Value; } set { Cols._ProcessAt.Value = value; } }
public DateTime? _BatchAt { get { return Cols._BatchAt.Value; } set { Cols._BatchAt.Value = value; } }
public Int32? _ElapseSecs { get { return Cols._ElapseSecs.Value; } set { Cols._ElapseSecs.Value = value; } }
public Int32? _ItemCount { get { return Cols._ItemCount.Value; } set { Cols._ItemCount.Value = value; } }
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
// Existing columns - confirmed on database if table exists.
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
//-------------------------------------------------------------------
// Population.
@@ -140,18 +159,18 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
_InterfaceId = GetFieldInt32(dbDataReader, "InterfaceId", _InterfaceId);
_Direction = GetFieldInt16(dbDataReader, "Direction", _Direction);
_ProcRef = GetFieldString(dbDataReader, "ProcRef", _ProcRef);
_ProcSeq = GetFieldInt32(dbDataReader, "ProcSeq", _ProcSeq);
_ProcessAt = GetFieldDateTime(dbDataReader, "ProcessAt", _ProcessAt);
_BatchAt = GetFieldDateTime(dbDataReader, "BatchAt", _BatchAt);
_ElapseSecs = GetFieldInt32(dbDataReader, "ElapseSecs", _ElapseSecs);
_ItemCount = GetFieldInt32(dbDataReader, "ItemCount", _ItemCount);
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
_ProcSeq = GetFieldInt32Nullable(dbDataReader, "ProcSeq", _ProcSeq);
_ProcessAt = GetFieldDateTimeNullable(dbDataReader, "ProcessAt", _ProcessAt);
_BatchAt = GetFieldDateTimeNullable(dbDataReader, "BatchAt", _BatchAt);
_ElapseSecs = GetFieldInt32Nullable(dbDataReader, "ElapseSecs", _ElapseSecs);
_ItemCount = GetFieldInt32Nullable(dbDataReader, "ItemCount", _ItemCount);
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
_Status = GetFieldString(dbDataReader, "Status", _Status);
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy);
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
}
@@ -200,10 +219,15 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
//-------------------------------------------------------------------
// Update command.
public override bool ExecuteUpdateCommand (DbCommand dbCommand)
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
{
// Columns to update.
List<String> columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList();
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
if (!columnNames.Any())
{
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
return false;
}
// Construct query.
String query = "UPDATE " + TableNameFmt + " SET ";
if (dbCommand is SqlCommand)
@@ -1,15 +1,16 @@
using Microsoft.Data.SqlClient;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Data.Common;
using Microsoft.Data.SqlClient;
using System.Linq;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:58
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:13
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
{
@@ -22,23 +23,23 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
public ColumnDataString _Context { get; } = new ColumnDataString("Context");
public ColumnDataString _Code { get; } = new ColumnDataString("Code");
public ColumnDataInt16 _Category { get; } = new ColumnDataInt16("Category");
public ColumnDataInt16 _Type { get; } = new ColumnDataInt16("Type");
public ColumnDataInt16Nullable _Category { get; } = new ColumnDataInt16Nullable("Category");
public ColumnDataInt16Nullable _Type { get; } = new ColumnDataInt16Nullable("Type");
public ColumnDataString _Caption { get; } = new ColumnDataString("Caption");
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy");
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy");
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
}
//-------------------------------------------------------------------
// Data members.
private static List<String> fields { get; } = new List<String>()
protected static List<String> fields { get; } = new List<String>()
{
"Id",
"Context",
@@ -56,14 +57,29 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
"UpdateBy",
"UpdateHost",
};
private static List<String> fieldsId { get; } = new List<String>()
protected static List<String> fieldsId { get; } = new List<String>()
{
};
private static List<String> fieldsPrimary { get; } = new List<String>()
protected static List<String> fieldsPrimary { get; } = new List<String>()
{
"Id",
};
private static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
protected static List<String> fieldsNullable { get; } = new List<String>()
{
"Context",
"Category",
"Type",
"Notes",
"Flags",
"Status",
"CreateOn",
"CreateBy",
"CreateHost",
"UpdateOn",
"UpdateBy",
"UpdateHost",
};
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
{
"CreateOn",
"CreateBy",
@@ -93,21 +109,22 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
public Int32 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
public String _Context { get { return Cols._Context.Value; } set { Cols._Context.Value = value; } }
public String _Code { get { return Cols._Code.Value; } set { Cols._Code.Value = value; } }
public Int16 _Category { get { return Cols._Category.Value; } set { Cols._Category.Value = value; } }
public Int16 _Type { get { return Cols._Type.Value; } set { Cols._Type.Value = value; } }
public Int16? _Category { get { return Cols._Category.Value; } set { Cols._Category.Value = value; } }
public Int16? _Type { get { return Cols._Type.Value; } set { Cols._Type.Value = value; } }
public String _Caption { get { return Cols._Caption.Value; } set { Cols._Caption.Value = value; } }
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
// Existing columns - confirmed on database if table exists.
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
//-------------------------------------------------------------------
// Population.
@@ -129,17 +146,17 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
_Context = GetFieldString(dbDataReader, "Context", _Context);
_Code = GetFieldString(dbDataReader, "Code", _Code);
_Category = GetFieldInt16(dbDataReader, "Category", _Category);
_Type = GetFieldInt16(dbDataReader, "Type", _Type);
_Category = GetFieldInt16Nullable(dbDataReader, "Category", _Category);
_Type = GetFieldInt16Nullable(dbDataReader, "Type", _Type);
_Caption = GetFieldString(dbDataReader, "Caption", _Caption);
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
_Status = GetFieldString(dbDataReader, "Status", _Status);
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy);
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
}
@@ -186,10 +203,15 @@ namespace Sarand.Net.Standard.Dbas.Interfaces.Internal
//-------------------------------------------------------------------
// Update command.
public override bool ExecuteUpdateCommand (DbCommand dbCommand)
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
{
// Columns to update.
List<String> columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList();
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
if (!columnNames.Any())
{
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
return false;
}
// Construct query.
String query = "UPDATE " + TableNameFmt + " SET ";
if (dbCommand is SqlCommand)
@@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Dbas.Base;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
namespace Sarand.Net.Standard.Dbas.Interfaces
{
@@ -18,13 +17,13 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Static initialisation.
static SaInterfaceConsole_Dbas ()
static SaInterfaceConsole_Dbas()
{
}
//-------------------------------------------------------------------
// Construction.
protected SaInterfaceConsole_Dbas (ISacsDatabase database)
protected SaInterfaceConsole_Dbas(ISacsDatabase database)
{
Database = database;
interfaceMgr = new SaInterfaceMgr_Dbas(this);
@@ -48,35 +47,43 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
// M a n a g e I n t e r f a c e s
//-------------------------------------------------------------------
// Manage interfaces - returns true if changes made.
public override bool ManageInterfaces (String interfaceContext, bool userCanManageInterfaces, bool userCanProcessInterfaces, DbUpdateInfo dbUpdateInfo)
public override bool ManageInterfaces(String interfaceContext, bool userCanManageInterfaces, bool userCanProcessInterfaces, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
MaintainInterfacesFn?.Invoke(this, interfaceContext, userCanManageInterfaces, userCanProcessInterfaces, dbUpdateInfo);
return false;
}
// Method to display Interface management dialog.
protected delegate bool MaintainInterfacesFunction (SaInterfaceConsole codeTypeConsole, String interfaceContext, bool userCanManageInterfaces, bool userCanProcessInterfaces, DbUpdateInfo dbUpdateInfo);
protected delegate bool MaintainInterfacesFunction(SaInterfaceConsole codeTypeConsole, String interfaceContext, bool userCanManageInterfaces, bool userCanProcessInterfaces, DbUpdateInfo dbUpdateInfo);
protected abstract MaintainInterfacesFunction MaintainInterfacesFn { get; }
//-------------------------------------------------------------------
// I n t e r f a c e M a n a g e m e n t
//-------------------------------------------------------------------
// Interface management.
public override SysId CreateInterface (String context, SaInterfaceCategory interfaceCategory, short interfaceType, String code, String caption, DbUpdateInfo dbUpdateInfo)
public override SysId CreateInterface(String context, SaInterfaceCategory interfaceCategory, short interfaceType, String code, String caption, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
SaInterface interfaceObj = interfaceMgr.CreateInterface(context,interfaceCategory,interfaceType);
SaInterface interfaceObj = interfaceMgr.CreateInterface(context, interfaceCategory, interfaceType);
interfaceObj.Code = code;
interfaceObj.Caption = caption;
if (!interfaceMgr.InsertInterface(interfaceObj,dbUpdateInfo))
if (!interfaceMgr.InsertInterface(interfaceObj, dbUpdateInfo))
{
SetErrorState(interfaceMgr.ErrorStateMessage);
return null;
}
return interfaceObj.Id;
}
public override bool UpdateInterface(SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!interfaceMgr.UpdateInterface(interfaceObj, dbUpdateInfo))
return SetErrorState(interfaceMgr.ErrorStateMessage);
return true;
}
// Clear configuration options, data items, processes etc.
public override bool ClearDependentData (SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
public override bool ClearDependentData(SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
throw new NotImplementedException();
@@ -85,22 +92,38 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//---------------------------------------------------------------
// Retrieve interfaces.
public override SaInterface GetInterface (SaInterface.Params prmInterface)
public override SaInterface GetInterface(SaInterface.Params prmInterface)
{
return interfaceMgr.GetInterface(prmInterface);
}
public override SaInterface GetInterfaceById (SysId interfaceId)
public override SaInterface GetInterfaceById(SysId interfaceId)
{
return interfaceMgr.GetInterfaceById(interfaceId);
}
public override List<SaInterface> GetInterfaceList (SaInterface.Params prmInterface)
public override ColumnDfn GetInterfaceColumnDfn(SaInterface.Column columnId, string caption = "", int width = 0)
{
return interfaceMgr.GetInterfaceColumnDfn(columnId, caption, width);
}
public override long GetInterfaceCount(SaInterface.Params prmInterface)
{
return interfaceMgr.GetInterfaceCount(prmInterface);
}
public override List<SaInterface> GetInterfaceList(SaInterface.Params prmInterface)
{
return interfaceMgr.GetInterfaceList(prmInterface);
}
public override DbResultSet ExecuteInterfaceQuery(List<ColumnDfn> columns, SaInterface.Params prm)
{
return interfaceMgr.ExecuteInterfaceQuery(columns, prm);
}
public override DataValue GetInterfaceDataValue(ColumnDfn column, NamedValue.Map values)
{
return interfaceMgr.GetInterfaceDataValue(column, values);
}
//---------------------------------------------------------------
// Conversion between Interface Category & Type and the equivalent database Id (if only one exists).
public override SysId GetInterfaceIdForContextCategoryType (String context, SaInterfaceCategory interfaceCategory, short interfaceType)
public override SysId GetInterfaceIdForContextCategoryType(String context, SaInterfaceCategory interfaceCategory, short interfaceType)
{
ClearErrorState();
SaInterface.Params prmInterface = new SaInterface.Params();
@@ -115,7 +138,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
return null;
}
// Conversion between Interface Category & Code and the equivalent database Id (if only one exists).
public override SysId GetInterfaceIdForContextCategoryCode (String context, SaInterfaceCategory interfaceCategory, String code)
public override SysId GetInterfaceIdForContextCategoryCode(String context, SaInterfaceCategory interfaceCategory, String code)
{
ClearErrorState();
SaInterface.Params prmInterface = new SaInterface.Params();
@@ -129,14 +152,14 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
return interfaceObj.Id;
return null;
}
public override SaInterfaceCategory GetCategoryForInterfaceId (SysId interfaceId)
public override SaInterfaceCategory GetCategoryForInterfaceId(SysId interfaceId)
{
SaInterface interfaceObj = interfaceMgr.GetInterfaceById(interfaceId);
if (interfaceObj != null)
return interfaceObj.Category;
return SaInterfaceCategory.Unknown;
}
public override String GetCodeForInterfaceId (SysId interfaceId)
public override String GetCodeForInterfaceId(SysId interfaceId)
{
SaInterface interfaceObj = interfaceMgr.GetInterfaceById(interfaceId);
if (interfaceObj != null)
@@ -148,7 +171,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
// I n t e r f a c e P r o c e s s e s
//---------------------------------------------------------------
// Identify the highest sequence currently in use for an interface.
public override int GetMaxProcessSequence (SysId interfaceId, SaInterfaceProcessDirection processDirection, bool completedOnly = true)
public override int GetMaxProcessSequence(SysId interfaceId, SaInterfaceProcessDirection processDirection, bool completedOnly = true)
{
ClearErrorState();
int sequence = interfaceMgr.GetMaxProcessSequenceForInterface(interfaceId, processDirection);
@@ -159,7 +182,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//---------------------------------------------------------------
// Create new process and imediately store details on database (status set to 'In Progress').
public override SaInterfaceProcess StartInterfaceProcess (SysId interfaceId, SaInterfaceProcessDirection eDirection, String batchRef, DateTime batchAt, int sequence, DbUpdateInfo dbUpdateInfo)
public override SaInterfaceProcess StartInterfaceProcess(SysId interfaceId, SaInterfaceProcessDirection eDirection, String batchRef, DateTime batchAt, int sequence, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!interfaceMgr.InterfaceExistsById(interfaceId))
@@ -171,7 +194,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
interfaceProcess.ProcessAt = DateTime.Now;
interfaceProcess.BatchAt = batchAt;
interfaceProcess.Status = SaStatus.InProgress;
if (!interfaceMgr.InsertInterfaceProcess(interfaceProcess,dbUpdateInfo))
if (!interfaceMgr.InsertInterfaceProcess(interfaceProcess, dbUpdateInfo))
{
interfaceProcess = null;
SetErrorState(interfaceMgr.ErrorStateMessage);
@@ -181,7 +204,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//---------------------------------------------------------------
// Retrieve a process using its identity (restricted by interface).
public override SaInterfaceProcess GetInterfaceProcess (SysId interfaceId, SysId interfaceProcessId)
public override SaInterfaceProcess GetInterfaceProcess(SysId interfaceId, SysId interfaceProcessId)
{
ClearErrorState();
SaInterfaceProcess interfaceProcess = interfaceMgr.GetInterfaceProcessById(interfaceProcessId);
@@ -200,14 +223,14 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//---------------------------------------------------------------
// Update the details for a process.
public override bool StoreInterfaceProcess (SaInterfaceProcess interfaceProcess, DbUpdateInfo dbUpdateInfo)
public override bool StoreInterfaceProcess(SaInterfaceProcess interfaceProcess, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!SysId.IsValid(interfaceProcess.Id))
{
// Insert interface process.
if (!interfaceMgr.InsertInterfaceProcess(interfaceProcess, dbUpdateInfo))
return SetErrorState("Failed to insert process - "+interfaceMgr.ErrorStateMessage);
return SetErrorState("Failed to insert process - " + interfaceMgr.ErrorStateMessage);
}
else
{
@@ -221,7 +244,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//---------------------------------------------------------------
// I n t e r f a c e P r o c e s s M e s s a g e s
//---------------------------------------------------------------
public override bool LogInterfaceProcessMessage (SysId interfaceProcessId, DbUpdateInfo dbUpdateInfo, String message, SaMessageLevel messageLevel = SaMessageLevel.Info, String filename = "", int lineNumber = 0, ItemId itemId = null)
public override bool LogInterfaceProcessMessage(SysId interfaceProcessId, DbUpdateInfo dbUpdateInfo, String message, SaMessageLevel messageLevel = SaMessageLevel.Info, String filename = "", int lineNumber = 0, ItemId itemId = null)
{
ClearErrorState();
if (!interfaceMgr.InterfaceProcessExistsById(interfaceProcessId)) return SetErrorState("Invalid interface process id supplied");
@@ -243,14 +266,14 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//---------------------------------------------------------------
// I n t e r f a c e D a t a I t e m s
//---------------------------------------------------------------
public override bool ItemHasDataItems (ItemId itemId)
public override bool ItemHasDataItems(ItemId itemId)
{
ClearErrorState();
SaInterfaceDataItem.Params prmInterfaceDataItem = new SaInterfaceDataItem.Params();
prmInterfaceDataItem.ItemIdsIncluded.Add(itemId);
return (interfaceMgr.GetInterfaceDataItemCount(prmInterfaceDataItem) > 0);
}
public override bool InterfaceDataItemExistsByRef (SysId interfaceId, SaInterfaceProcessDirection processDirection, short itemType, String externalReference)
public override bool InterfaceDataItemExistsByRef(SysId interfaceId, SaInterfaceProcessDirection processDirection, short itemType, String externalReference)
{
ClearErrorState();
SaInterfaceDataItem.Params prmInterfaceDataItem = new SaInterfaceDataItem.Params();
@@ -260,17 +283,17 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
prmInterfaceDataItem.ExternalReference = externalReference;
return (interfaceMgr.GetInterfaceDataItemCount(prmInterfaceDataItem) > 0);
}
public override SaInterfaceDataItem CreateInterfaceDataItem (SysId interfaceId, SaInterfaceProcessDirection processDirection, ItemId itemId, String externalReference)
public override SaInterfaceDataItem CreateInterfaceDataItem(SysId interfaceId, SaInterfaceProcessDirection processDirection, ItemId itemId, String externalReference)
{
ClearErrorState();
return interfaceMgr.CreateInterfaceDataItem(interfaceId, processDirection, itemId, externalReference);
}
public override SaInterfaceDataItem GetInterfaceDataItem (SysId interfaceDataItemId)
public override SaInterfaceDataItem GetInterfaceDataItem(SysId interfaceDataItemId)
{
ClearErrorState();
return interfaceMgr.GetInterfaceDataItemById(interfaceDataItemId);
}
public override SaInterfaceDataItem GetInterfaceDataItemByItemRef (SysId interfaceId, SaInterfaceProcessDirection processDirection, ItemId itemId, String externalReference)
public override SaInterfaceDataItem GetInterfaceDataItemByItemRef(SysId interfaceId, SaInterfaceProcessDirection processDirection, ItemId itemId, String externalReference)
{
ClearErrorState();
SaInterfaceDataItem.Params prmInterfaceDataItem = new SaInterfaceDataItem.Params();
@@ -280,7 +303,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
prmInterfaceDataItem.ExternalReference = externalReference;
return interfaceMgr.GetInterfaceDataItem(prmInterfaceDataItem);
}
public override SaInterfaceDataItem GetInterfaceDataItemByRef (SysId interfaceId, SaInterfaceProcessDirection processDirection, short itemType, String externalReference)
public override SaInterfaceDataItem GetInterfaceDataItemByRef(SysId interfaceId, SaInterfaceProcessDirection processDirection, short itemType, String externalReference)
{
// Fails if more than 1 matching data item.
ClearErrorState();
@@ -291,7 +314,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
prmInterfaceDataItem.ExternalReference = externalReference;
return interfaceMgr.GetInterfaceDataItem(prmInterfaceDataItem);
}
public override SaInterfaceDataItem GetInterfaceDataItemByItem (SysId interfaceId, SaInterfaceProcessDirection processDirection, ItemId itemId)
public override SaInterfaceDataItem GetInterfaceDataItemByItem(SysId interfaceId, SaInterfaceProcessDirection processDirection, ItemId itemId)
{
// Fails if more than 1 matching data item.
ClearErrorState();
@@ -301,7 +324,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
prmInterfaceDataItem.ItemIdsIncluded.Add(itemId);
return interfaceMgr.GetInterfaceDataItem(prmInterfaceDataItem);
}
public override List<SaInterfaceDataItem> GetInterfaceDataItemsByItem (SysId interfaceId, SaInterfaceProcessDirection processDirection, ItemId itemId)
public override List<SaInterfaceDataItem> GetInterfaceDataItemsByItem(SysId interfaceId, SaInterfaceProcessDirection processDirection, ItemId itemId)
{
ClearErrorState();
SaInterfaceDataItem.Params prmInterfaceDataItem = new SaInterfaceDataItem.Params();
@@ -310,7 +333,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
prmInterfaceDataItem.ItemIdsIncluded.Add(itemId);
return interfaceMgr.GetInterfaceDataItemList(prmInterfaceDataItem);
}
public override List<SaInterfaceDataItem> GetInterfaceDataItemsByRef (SysId interfaceId, SaInterfaceProcessDirection processDirection, short itemType, String externalReference)
public override List<SaInterfaceDataItem> GetInterfaceDataItemsByRef(SysId interfaceId, SaInterfaceProcessDirection processDirection, short itemType, String externalReference)
{
ClearErrorState();
SaInterfaceDataItem.Params prmInterfaceDataItem = new SaInterfaceDataItem.Params();
@@ -320,7 +343,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
prmInterfaceDataItem.ExternalReference = externalReference;
return interfaceMgr.GetInterfaceDataItemList(prmInterfaceDataItem);
}
public override bool StoreInterfaceDataItem (SaInterfaceDataItem interfaceDataItem, DbUpdateInfo dbUpdateInfo)
public override bool StoreInterfaceDataItem(SaInterfaceDataItem interfaceDataItem, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (interfaceDataItem == null) return SetErrorState("data item must be supplied");
@@ -336,7 +359,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
}
return true;
}
public override bool StoreInterfaceDataItems (List<SaInterfaceDataItem> interfaceDataItems, DbUpdateInfo dbUpdateInfo)
public override bool StoreInterfaceDataItems(List<SaInterfaceDataItem> interfaceDataItems, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
foreach (SaInterfaceDataItem interfaceDataItem in interfaceDataItems)
@@ -346,14 +369,14 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
}
return true;
}
public override bool ClearInterfaceDataItem (SaInterfaceDataItem interfaceDataItem, DbUpdateInfo dbUpdateInfo)
public override bool ClearInterfaceDataItem(SaInterfaceDataItem interfaceDataItem, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!interfaceMgr.DeleteInterfaceDataItem(interfaceDataItem, dbUpdateInfo))
return SetErrorState(interfaceMgr.ErrorStateMessage);
return true;
}
public override bool ClearInterfaceDataItems (ItemId itemId, DbUpdateInfo dbUpdateInfo)
public override bool ClearInterfaceDataItems(ItemId itemId, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
SaInterfaceDataItem.Params prmInterfaceDataItem = new SaInterfaceDataItem.Params();
@@ -1,11 +1,11 @@
using System;
using System.IO;
using System.Reflection;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.IO;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Base;
using System;
using System.IO;
using System.Reflection;
namespace Sarand.Net.Standard.Dbas.Interface
{
@@ -14,16 +14,15 @@ namespace Sarand.Net.Standard.Dbas.Interface
{
//-------------------------------------------------------------------
// Data members.
//private static string messageBoxTitle = "Sarand Interface Module database definition generator";
//private static String dbConnectionString = "Driver={SQL Server Native Client 11.0};Server=Sarand106\\SQL2014;Database=SaStockTracker_Solent_STN;Trusted_Connection=Yes;MARS_Connection=yes;";
private static String className = nameof(SaInterfaceDbDfnGenerator);
//-------------------------------------------------------------------
/// <summary>
/// Generate database definitions.
/// </summary>
public static bool Generate (String connectionString)
public static bool Generate(String connectionString)
{
String fn = nameof(SaInterfaceDbDfnGenerator) + ".Generate";
String fn = $"{className}.Generate";
// Locate output folder:
String directory = GetOutputFolder();
@@ -42,13 +41,13 @@ namespace Sarand.Net.Standard.Dbas.Interface
}
catch (Exception exc)
{
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc));
SaLogger.Error($"{fn} {ExceptionUtil.GetLogMessage(exc, "generating Interface database definition")}");
}
return false;
}
//-------------------------------------------------------------------
private static bool GenerateDatabaseDefinition (SacsDatabase database, String directory)
private static bool GenerateDatabaseDefinition(SacsDatabase database, String directory)
{
DatabaseDefinitionGenerator.Config config = new DatabaseDefinitionGenerator.Config()
{
@@ -73,10 +72,19 @@ namespace Sarand.Net.Standard.Dbas.Interface
config.Schema.InsertOnlyColumns.Add("SaInterfaceDataItem", "InterfaceId");
config.Schema.InsertOnlyColumns.Add("SaInterfaceProcessDataItem", "ProcessId,InterfaceDataItemId");
// Database Definition class.
config.DefinitionClass.Namespace = "Sarand.Net.Standard.Base.Interfaces";
config.DefinitionClass.Classname = "SaInterfaceDbDfn";
config.DefinitionClass.Usings.Clear();
config.DefinitionClass.Usings.Add("Sarand.Net.Standard.Base.Core");
config.DefinitionClass.Usings.Add("Sarand.Net.Standard.Base.Utils");
config.DefinitionClass.Usings.Add("Sarand.Net.Standard.Base.Dbas");
config.DefinitionClass.Namespace = "Sarand.Net.Standard.Base.Interfaces";
config.DefinitionClass.Classname = "SaInterfaceDbDfn";
// Table class.
config.TableClass.Usings.Add("Sarand.Net.Standard.Base.App");
config.TableClass.Usings.Add("Sarand.Net.Standard.Base.Core");
config.TableClass.Usings.Add("Sarand.Net.Standard.Base.Utils");
config.TableClass.Usings.Add("Sarand.Net.Standard.Base.Dbas");
config.TableClass.Namespace = "Sarand.Net.Standard.Dbas.Interfaces.Internal";
config.TableClass.ClassName_DatabaseInfo = "IDatabaseInfo";
config.TableClass.MandatoryConstructorDbInfo = true;
// Generate database definition.
@@ -84,10 +92,10 @@ namespace Sarand.Net.Standard.Dbas.Interface
return generator.Generate(config);
}
//-------------------------------------------------------------------
private static String GetOutputFolder ()
private static String GetOutputFolder()
{
String fn = nameof(SaInterfaceDbDfnGenerator) + ".GetOutputFolder";
String assemblyDirectory = FileUtil.GetParentDirectory((Assembly.GetAssembly(typeof (DatabaseDefinitionGenerator)).Location));
String fn = $"{className}.GetOutputFolder";
String assemblyDirectory = FileUtil.GetParentDirectory((Assembly.GetAssembly(typeof(DatabaseDefinitionGenerator)).Location));
String directory = assemblyDirectory;
SaLogger.Debug(fn + " Assembly folder: " + directory);
// Locate the parent of the 'Workspace' solution root folder.
@@ -106,11 +114,11 @@ namespace Sarand.Net.Standard.Dbas.Interface
return String.Empty;
}
// Code files are generated to '..\Dbas\Generated\Interfaces\' folder.
directory += Path.DirectorySeparatorChar + "Database" + Path.DirectorySeparatorChar + "Generated" + Path.DirectorySeparatorChar + "Interfaces";
SaLogger.Debug(fn + " Output folder: " + directory);
directory = Path.Combine(directory, "Database", "Generated", "Interfaces");
SaLogger.Debug($"{fn} Output folder: {directory}");
if (!FileUtil.ValidateDirectory(directory, true))
{
SaLogger.Error(fn + " Output folder not found:\n\n" + directory);
SaLogger.Error($"{fn} Output folder not found: {directory}");
return String.Empty;
}
return directory;
@@ -1,15 +1,15 @@
using System;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using Sarand.Net.Standard.Dbas.Interfaces.Internal;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Dbas.Data;
using Sarand.Net.Standard.Dbas.Interfaces.Internal;
using Sarand.Net.Standard.Base.Utils;
namespace Sarand.Net.Standard.Dbas.Interfaces
{
@@ -212,7 +212,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
interfaceProcessMessage.Level = SaMessageLevel.Warning;
interfaceProcessMessage.Message = dbInterfaceProcessMessage._Msg;
interfaceProcessMessage.Filename = dbInterfaceProcessMessage._FileName;
interfaceProcessMessage.LineNumber = dbInterfaceProcessMessage._LineNumber;
interfaceProcessMessage.LineNumber = dbInterfaceProcessMessage._LineNumber ?? 0;
interfaceProcessMessage.ItemId = new ItemId(dbInterfaceProcessMessage._ItemType, new SysId(dbInterfaceProcessMessage._ItemId));
interfaceProcessMessage.Status = SacsSystem.GetStatusForCode(dbInterfaceProcessMessage._Status);
interfaceProcessMessage.SetCreateStamp(dbInterfaceProcessMessage._CreateOn, new SysId(dbInterfaceProcessMessage._CreateBy), dbInterfaceProcessMessage._CreateHost);
@@ -1,15 +1,15 @@
using System;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using Sarand.Net.Standard.Dbas.Interfaces.Internal;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Dbas.Data;
using Sarand.Net.Standard.Dbas.Interfaces.Internal;
using Sarand.Net.Standard.Base.Utils;
namespace Sarand.Net.Standard.Dbas.Interfaces
{
@@ -49,7 +49,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
private SaInterfaceProcess CreateInterfaceProcess(SaInterfaceProcess_Db dbInterfaceProcess)
{
ClearErrorState();
SaInterfaceProcess interfaceProcess = new SaInterfaceProcess_Dbas(new SysId(dbInterfaceProcess._Id), new SysId(dbInterfaceProcess._InterfaceId), (SaInterfaceProcessDirection)dbInterfaceProcess._Direction, dbInterfaceProcess._ProcRef, dbInterfaceProcess._ProcSeq, (ushort)dbInterfaceProcess._Flags);
SaInterfaceProcess interfaceProcess = new SaInterfaceProcess_Dbas(new SysId(dbInterfaceProcess._Id), new SysId(dbInterfaceProcess._InterfaceId), (SaInterfaceProcessDirection)dbInterfaceProcess._Direction, dbInterfaceProcess._ProcRef, dbInterfaceProcess._ProcSeq ?? 0, (ushort)dbInterfaceProcess._Flags);
PopulateFrom(dbInterfaceProcess, interfaceProcess);
return interfaceProcess;
}
@@ -284,7 +284,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//interfaceProcess.Sequence = dbInterfaceProcess._ProcSeq;
interfaceProcess.ProcessAt = dbInterfaceProcess._ProcessAt;
interfaceProcess.BatchAt = dbInterfaceProcess._BatchAt;
interfaceProcess.ElapseSecs = dbInterfaceProcess._ElapseSecs;
interfaceProcess.ElapseSecs = dbInterfaceProcess._ElapseSecs ?? 0;
interfaceProcess.Status = SacsSystem.GetStatusForCode(dbInterfaceProcess._Status);
interfaceProcess.SetCreateStamp(dbInterfaceProcess._CreateOn, new SysId(dbInterfaceProcess._CreateBy), dbInterfaceProcess._CreateHost);
interfaceProcess.SetUpdateStamp(dbInterfaceProcess._UpdateOn, new SysId(dbInterfaceProcess._UpdateBy), dbInterfaceProcess._UpdateHost);
@@ -1,15 +1,16 @@
using System;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using Sarand.Net.Standard.Dbas.Interfaces.Internal;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Dbas.Data;
using Sarand.Net.Standard.Dbas.Interfaces.Internal;
using Sarand.Net.Standard.Base.Utils;
using System.Text.RegularExpressions;
namespace Sarand.Net.Standard.Dbas.Interfaces
{
@@ -20,20 +21,20 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
// I n t e r f a c e s
//*******************************************************************
// Associated data.
public override bool InterfaceHasProcesses (SysId id)
public override bool InterfaceHasProcesses(SysId id)
{
ClearErrorState();
String filter = SaInterfaceDbDfn.GetColumnName(SaInterfaceDbDfn.ColumnIdx.SaInterfaceProcess_InterfaceId) + "=" + SysId.ToString(id);
return (Database.GetRowCount(TableName_InterfaceProcess, filter) > 0);
}
public override bool InterfaceHasDataItems (SysId id)
public override bool InterfaceHasDataItems(SysId id)
{
ClearErrorState();
String filter = SaInterfaceDbDfn.GetColumnName(SaInterfaceDbDfn.ColumnIdx.SaInterfaceDataItem_InterfaceId) + "=" + SysId.ToString(id);
return (Database.GetRowCount(TableName_InterfaceDataItem, filter) > 0);
}
// Process sequence.
public override int GetMaxProcessSequenceForInterface (SysId interfaceId, SaInterfaceProcessDirection processDirection)
public override int GetMaxProcessSequenceForInterface(SysId interfaceId, SaInterfaceProcessDirection processDirection)
{
ClearErrorState();
if (!SysId.IsValid(interfaceId)) return 0;
@@ -46,19 +47,19 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Create Item.
public override SaInterface CreateInterface (String context, SaInterfaceCategory category, short type)
public override SaInterface CreateInterface(String context, SaInterfaceCategory category, short type)
{
ClearErrorState();
return new SaInterface_Dbas(null, context, category, type, 0);
}
private SaInterface CreateInterface (SaInterface_Db dbInterface)
private SaInterface CreateInterface(SaInterface_Db dbInterface)
{
ClearErrorState();
SaInterface saInterface = new SaInterface_Dbas(new SysId(dbInterface._Id), dbInterface._Context, (SaInterfaceCategory)dbInterface._Category, dbInterface._Type, (ushort)dbInterface._Flags);
SaInterface saInterface = new SaInterface_Dbas(new SysId(dbInterface._Id), dbInterface._Context, (SaInterfaceCategory)dbInterface._Category, dbInterface._Type ?? 0, (ushort)dbInterface._Flags);
PopulateFrom(dbInterface, saInterface);
return saInterface;
}
private SaInterface CreateInterface (DbDataReader dataReader)
private SaInterface CreateInterface(DbDataReader dataReader)
{
SaInterface_Db dbInterface = new SaInterface_Db(DbInfo);
dbInterface.PopulateFrom(dataReader);
@@ -67,13 +68,13 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Item exists.
public override bool InterfaceExistsById (SysId id)
public override bool InterfaceExistsById(SysId id)
{
ClearErrorState();
if (!SysId.IsValid(id)) return false;
return GetInterfaceCount(SaInterfaceDbDfn.GetColumnNameQual(SaInterfaceDbDfn.ColumnIdx.SaInterface_Id, aliasInterface) + "=" + SysId.ToString(id)) == 1;
}
public override bool InterfaceExistsByCode (String code)
public override bool InterfaceExistsByCode(String code)
{
ClearErrorState();
if (StringUtil.IsEmpty(code)) return false;
@@ -82,11 +83,11 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Get Item.
public override SaInterface GetInterface (SaInterface.Params prm)
public override SaInterface GetInterface(SaInterface.Params prm)
{
return GetInterface(GetInterfaceQueryFilter(prm).Concat(" AND ", "(", ")"));
}
private SaInterface GetInterface (String filter)
private SaInterface GetInterface(String filter)
{
ClearErrorState();
if (GetInterfaceCount(filter) != 1) return null;
@@ -110,13 +111,13 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
}
return interfaceObj;
}
public override SaInterface GetInterfaceById (SysId id)
public override SaInterface GetInterfaceById(SysId id)
{
ClearErrorState();
if (!SysId.IsValid(id)) return null;
return GetInterface("Id=" + SysId.ToString(id));
}
public override SaInterface GetInterfaceByContextCode (String context, String code)
public override SaInterface GetInterfaceByContextCode(String context, String code)
{
ClearErrorState();
if (StringUtil.IsEmpty(code)) return null;
@@ -125,7 +126,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Validate Item properties.
public override bool IsValidInterfaceData (SaInterface.Data interfaceData, SaInterface.ErrField errField)
public override bool IsValidInterfaceData(SaInterface.Data interfaceData, SaInterface.ErrField errField)
{
ClearErrorState();
if (!base.IsValidInterfaceData(interfaceData, errField)) return false;
@@ -134,7 +135,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Insert Item.
public override bool InsertInterface (SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
public override bool InsertInterface(SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!IsValidInterface(interfaceObj)) return false;
@@ -162,7 +163,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Update Item.
public override bool UpdateInterface (SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
public override bool UpdateInterface(SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!IsValidInterface(interfaceObj)) return false;
@@ -187,13 +188,13 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Delete Item.
public override bool InterfaceCanBeDeleted (SaInterface interfaceObj)
public override bool InterfaceCanBeDeleted(SaInterface interfaceObj)
{
ClearErrorState();
if (!base.InterfaceCanBeDeleted(interfaceObj)) return false;
return true;
}
public override bool DeleteInterface (SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
public override bool DeleteInterface(SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!InterfaceCanBeDeleted(interfaceObj)) return false;
@@ -218,7 +219,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Copy data properties to and from database.
private void PopulateTo (SaInterface_Db dbInterface, SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
private void PopulateTo(SaInterface_Db dbInterface, SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
{
dbInterface._Id = interfaceObj.Id.ToInt();
dbInterface._Context = interfaceObj.Context;
@@ -240,7 +241,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
dbInterface._UpdateBy = dbUpdateInfo.UserId.ToInt();
dbInterface._UpdateHost = dbUpdateInfo.Host;
}
private void PopulateFrom (SaInterface_Db dbInterface, SaInterface interfaceObj)
private void PopulateFrom(SaInterface_Db dbInterface, SaInterface interfaceObj)
{
//interface.Id = new SysId(dbInterface._Id);
//interfaceObj.Context = dbInterface._Context;
@@ -270,7 +271,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
alias = aliasInterface;
col.Set(caption, width, (int)dbCol, prefix + SaInterfaceDbDfn.GetColumnName(dbCol, false), SaInterfaceDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
}
public override ColumnDfn GetInterfaceColumnDfn (SaInterface.Column columnId, string caption = "", int width = 0)
public override ColumnDfn GetInterfaceColumnDfn(SaInterface.Column columnId, string caption = "", int width = 0)
{
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
switch (columnId)
@@ -359,7 +360,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Query filter.
public override List<string> GetInterfaceQueryFilter (SaInterface.Params prm)
public override List<string> GetInterfaceQueryFilter(SaInterface.Params prm)
{
List<String> filter = new List<String>();
@@ -372,8 +373,28 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
if (!excludedIds.IsEmpty())
filter.Add(colId + " NOT IN (" + excludedIds + ")");
// Context.
String colContext = SaInterfaceDbDfn.GetColumnNameQual(SaInterfaceDbDfn.ColumnIdx.SaInterface_Context, aliasInterface);
String colCode = SaInterfaceDbDfn.GetColumnNameQual(SaInterfaceDbDfn.ColumnIdx.SaInterface_Code, aliasInterface);
String colCaption = SaInterfaceDbDfn.GetColumnNameQual(SaInterfaceDbDfn.ColumnIdx.SaInterface_Caption, aliasInterface);
String colNotes = SaInterfaceDbDfn.GetColumnNameQual(SaInterfaceDbDfn.ColumnIdx.SaInterface_Notes, aliasInterface);
// Generic search.
if (!StringUtil.IsBlank(prm.Search))
{
foreach (String search in Regex.Split(prm.Search, "[\\s,;\\-+]+"))
{
if (StringUtil.IsBlank(search)) continue;
String searchForLike = DbQuery.FormatForLike(search, true);
List<String> searchFilter = new List<string>();
searchFilter.Add($"{colContext} LIKE '%{searchForLike}%'");
searchFilter.Add($"{colCode} LIKE '%{searchForLike}%'");
searchFilter.Add($"{colCaption} LIKE '%{searchForLike}%'");
searchFilter.Add($"{colNotes} LIKE '%{searchForLike}%'");
filter.Add(searchFilter.Concat(" OR ", "(", ")"));
}
}
// Context.
if (!StringUtil.IsEmpty(prm.Context))
filter.Add(colContext + "='" + DbQuery.FormatForCondition(prm.Context) + "'");
@@ -388,18 +409,16 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
filter.Add(colType + " In (" + String.Join(",", prm.InterfaceTypesIncluded) + ")");
// Code.
String colCode = SaInterfaceDbDfn.GetColumnNameQual(SaInterfaceDbDfn.ColumnIdx.SaInterface_Code, aliasInterface);
if (!StringUtil.IsEmpty(prm.Code))
filter.Add(colCode + "='" + DbQuery.FormatForCondition(prm.Code) + "'");
// Caption.
String colCaption = SaInterfaceDbDfn.GetColumnNameQual(SaInterfaceDbDfn.ColumnIdx.SaInterface_Caption, aliasInterface);
if (!StringUtil.IsEmpty(prm.CaptionPartial))
filter.Add(colCaption + " Like '%" + DbQuery.FormatForLike(prm.CaptionPartial) + "%'");
// Interface text - code or caption.
if (!StringUtil.IsEmpty(prm.InterfaceText))
filter.Add(colCode + " Like '%" + DbQuery.FormatForLike(prm.InterfaceText) + "%' Or "+ colCaption + " Like '%" + DbQuery.FormatForLike(prm.InterfaceText) + "%'");
filter.Add(colCode + " Like '%" + DbQuery.FormatForLike(prm.InterfaceText) + "%' Or " + colCaption + " Like '%" + DbQuery.FormatForLike(prm.InterfaceText) + "%'");
// Active flag.
String colFlags = SaInterfaceDbDfn.GetColumnNameQual(SaInterfaceDbDfn.ColumnIdx.SaInterface_Flags, aliasInterface);
@@ -415,7 +434,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
return filter;
}
// Sort columns.
public List<String> GetInterfaceSortColumns (SaInterface.Params prm)
public List<String> GetInterfaceSortColumns(SaInterface.Params prm)
{
// Sort sequence:
List<String> sortColumnNames = new List<String>();
@@ -453,12 +472,12 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Item count.
private long GetInterfaceCount (String filter)
private long GetInterfaceCount(String filter)
{
ClearErrorState();
return Database.GetRowCount($"{TableName_Interface} As {aliasInterface}", filter);
}
public override long GetInterfaceCount (SaInterface.Params prm)
public override long GetInterfaceCount(SaInterface.Params prm)
{
ClearErrorState();
return GetInterfaceCount(GetInterfaceQueryFilter(prm).Concat(" AND ", "(", ")"));
@@ -466,7 +485,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Item list.
public override List<SaInterface> GetInterfaceList (SaInterface.Params prm)
public override List<SaInterface> GetInterfaceList(SaInterface.Params prm)
{
ClearErrorState();
List<SaInterface> interfaces = new List<SaInterface>();
@@ -501,7 +520,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Item query.
public override DbResultSet ExecuteInterfaceQuery (List<ColumnDfn> columns, SaInterface.Params prm)
public override DbResultSet ExecuteInterfaceQuery(List<ColumnDfn> columns, SaInterface.Params prm)
{
ClearErrorState();
@@ -1,4 +1,6 @@
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Base;
@@ -6,10 +8,7 @@ using Sarand.Net.Standard.Dbas.Interfaces.Internal;
using System;
using System.Collections.Generic;
using System.Data.Common;
using Microsoft.Data.SqlClient;
using System.Linq;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.App;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:58
@@ -25,9 +24,9 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Data members.
private String colNameProcDate = "ProcDate";
private String colNameProcTime= "ProcTime";
private String colNameProcTime = "ProcTime";
private String colNameBatchDate = "BatchDate";
private String colNameBatchTime= "BatchTime";
private String colNameBatchTime = "BatchTime";
private bool colExists_ProcessAt = false;
private bool colExists_ProcDate = false;
private bool colExists_ProcTime = false;
@@ -37,7 +36,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Construction.
internal SaInterfaceProcess_Db_Local (IDatabaseInfo dbInfo) : base(dbInfo)
internal SaInterfaceProcess_Db_Local(IDatabaseInfo dbInfo) : base(dbInfo)
{
colExists_ProcessAt = ColumnExists(SaInterfaceDbDfn.GetColumnName(SaInterfaceDbDfn.ColumnIdx.SaInterfaceProcess_ProcessAt, false));
colExists_ProcDate = ColumnExists(colNameProcDate);
@@ -52,7 +51,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Population.
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
public override void PopulateFrom(DbCommand dbCommand, String tableAlias, String filter)
{
if (colExists_ProcessAt)
{
@@ -68,7 +67,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
PopulateFrom(dbDataReader);
}
}
public override void PopulateFrom (DbDataReader dbDataReader)
public override void PopulateFrom(DbDataReader dbDataReader)
{
base.PopulateFrom(dbDataReader);
// 'Process At' legacy fields: ProcDate (Int32) & ProcTime (Int32).
@@ -95,7 +94,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Insert command.
public override bool ExecuteInsertCommand (DbCommand dbCommand)
public override bool ExecuteInsertCommand(DbCommand dbCommand)
{
if (colExists_ProcessAt)
return ExecuteInsertCommand(dbCommand);
@@ -109,13 +108,13 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
SacsDatabase.AddValuePair(columnValues, "ProcSeq", _ProcSeq);
if (colExists_ProcDate && colExists_ProcTime)
{
SacsDatabase.AddValuePair(columnValues, colNameProcDate, DateUtil.DateToInt32(_ProcessAt));
SacsDatabase.AddValuePair(columnValues, colNameProcTime, DateUtil.TimeToInt32(_ProcessAt));
SacsDatabase.AddValuePair(columnValues, colNameProcDate, DateUtil.DateToInt32(_ProcessAt ?? DateTime.MinValue));
SacsDatabase.AddValuePair(columnValues, colNameProcTime, DateUtil.TimeToInt32(_ProcessAt ?? DateTime.MinValue));
}
if (colExists_BatchDate && colExists_BatchTime)
{
SacsDatabase.AddValuePair(columnValues, colNameBatchDate, DateUtil.DateToInt32(_BatchAt));
SacsDatabase.AddValuePair(columnValues, colNameBatchTime, DateUtil.TimeToInt32(_BatchAt));
SacsDatabase.AddValuePair(columnValues, colNameBatchDate, DateUtil.DateToInt32(_BatchAt ?? DateTime.MinValue));
SacsDatabase.AddValuePair(columnValues, colNameBatchTime, DateUtil.TimeToInt32(_BatchAt ?? DateTime.MinValue));
}
SacsDatabase.AddValuePair(columnValues, "ElapseSecs", _ElapseSecs);
SacsDatabase.AddValuePair(columnValues, "ItemCount", _ItemCount);
@@ -145,7 +144,7 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
//-------------------------------------------------------------------
// Update command.
public override bool ExecuteUpdateCommand (DbCommand dbCommand)
public override bool ExecuteUpdateCommand(DbCommand dbCommand)
{
if (colExists_ProcessAt)
return ExecuteUpdateCommand(dbCommand);
@@ -156,13 +155,13 @@ namespace Sarand.Net.Standard.Dbas.Interfaces
SacsDatabase.AddValuePair(columnValues, "ProcSeq", _ProcSeq);
if (colExists_ProcDate && colExists_ProcTime)
{
SacsDatabase.AddValuePair(columnValues, colNameProcDate, DateUtil.DateToInt32(_ProcessAt));
SacsDatabase.AddValuePair(columnValues, colNameProcTime, DateUtil.TimeToInt32(_ProcessAt));
SacsDatabase.AddValuePair(columnValues, colNameProcDate, DateUtil.DateToInt32(_ProcessAt ?? DateTime.MinValue));
SacsDatabase.AddValuePair(columnValues, colNameProcTime, DateUtil.TimeToInt32(_ProcessAt ?? DateTime.MinValue));
}
if (colExists_BatchDate && colExists_BatchTime)
{
SacsDatabase.AddValuePair(columnValues, colNameBatchDate, DateUtil.DateToInt32(_BatchAt));
SacsDatabase.AddValuePair(columnValues, colNameBatchTime, DateUtil.TimeToInt32(_BatchAt));
SacsDatabase.AddValuePair(columnValues, colNameBatchDate, DateUtil.DateToInt32(_BatchAt ?? DateTime.MinValue));
SacsDatabase.AddValuePair(columnValues, colNameBatchTime, DateUtil.TimeToInt32(_BatchAt ?? DateTime.MinValue));
}
SacsDatabase.AddValuePair(columnValues, "ElapseSecs", _ElapseSecs);
SacsDatabase.AddValuePair(columnValues, "ItemCount", _ItemCount);
@@ -10,7 +10,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:21
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:12
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.ItemOptions.Internal
{
@@ -10,7 +10,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:12
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.Security.Internal
{
@@ -10,7 +10,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
// Code generated by Sarand Database Utilities Thu 30-Oct-2025 11:28:12
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Dbas.Security.Internal
{
@@ -1,15 +1,14 @@
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Security;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using Sarand.Net.Standard.Dbas.Security.Internal;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using Sarand.Net.Standard.Base.Utils;
namespace Sarand.Net.Standard.Dbas.Security
{
@@ -203,8 +202,8 @@ namespace Sarand.Net.Standard.Dbas.Security
securityLink.ApplicableFrom = DateUtil.Int32ToDate(dbSecurityLink._DateApplicFrom ?? 0);
securityLink.ApplicableTo = DateUtil.Int32ToDate(dbSecurityLink._DateApplicTo ?? 0);
securityLink.Status = SacsSystem.GetStatusForCode(dbSecurityLink._Status);
securityLink.SetCreateStamp(dbSecurityLink._CreateOn ?? DateTime.MinValue, new SysId(dbSecurityLink._CreateBy ?? 0), dbSecurityLink._CreateHost);
securityLink.SetUpdateStamp(dbSecurityLink._UpdateOn ?? DateTime.MinValue, new SysId(dbSecurityLink._UpdateBy ?? 0), dbSecurityLink._UpdateHost);
securityLink.SetCreateStamp(dbSecurityLink._CreateOn, new SysId(dbSecurityLink._CreateBy), dbSecurityLink._CreateHost);
securityLink.SetUpdateStamp(dbSecurityLink._UpdateOn, new SysId(dbSecurityLink._UpdateBy), dbSecurityLink._UpdateHost);
securityLink.AcceptChanges();
}
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<DbDfnDatabase xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?xml version="1.0" encoding="utf-8"?>
<DbDfnDatabase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Tables>
<DbDfnTable>
<Schema>dbo</Schema>
@@ -101,8 +101,8 @@
<DataTypeNative>-9</DataTypeNative>
<DataTypeNameNative>nvarchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>50</Size>
<BufferLen>100</BufferLen>
<Size>100</Size>
<BufferLen>200</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
@@ -266,14 +266,14 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterface</Table>
<Name>PK_SaInterface</Name>
<Name>PK_Interface</Name>
<IndexType>1</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>1</UniqueValues>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -286,7 +286,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterface</Table>
<Name>IDX_SaInterface_ContextCode</Name>
<Name>IDX_Interface_ContextCode</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
@@ -311,7 +311,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterface</Table>
<Name>IDX_SaInterface_ContextCategoryType</Name>
<Name>IDX_Interface_ContextCategoryType</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -690,7 +690,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceDataItem</Table>
<Name>PK_SaInterfaceDataItem</Name>
<Name>PK_InterfaceDataItem</Name>
<IndexType>1</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
@@ -710,7 +710,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceDataItem</Table>
<Name>IDX_SaInterfaceDataItem_InterfaceItemRef</Name>
<Name>IDX_InterfaceDataItem_InterfaceItemRef</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
@@ -750,7 +750,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceDataItem</Table>
<Name>IDX_SaInterfaceDataItem_InterfaceStatusItemRef</Name>
<Name>IDX_InterfaceDataItem_InterfaceStatusItemRef</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
@@ -795,7 +795,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceDataItem</Table>
<Name>IDX_SaInterfaceDataItem_InterfaceDirectionItemRef</Name>
<Name>IDX_InterfaceDataItem_InterfaceDirectionItemRef</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -830,7 +830,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceDataItem</Table>
<Name>IDX_SaInterfaceDataItem_Item</Name>
<Name>IDX_InterfaceDataItem_Item</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -855,7 +855,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceDataItem</Table>
<Name>IDX_SaInterfaceDataItem_ItemExternal</Name>
<Name>IDX_InterfaceDataItem_ItemExternal</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -1178,14 +1178,14 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcess</Table>
<Name>PK_SaInterfaceProcess</Name>
<Name>PK_InterfaceProcess</Name>
<IndexType>1</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>22</UniqueValues>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -1198,7 +1198,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcess</Table>
<Name>IDX_SaInterfaceProcess_IntDirSeq</Name>
<Name>IDX_InterfaceProcess_IntDirSeq</Name>
<IndexType>3</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
@@ -1228,32 +1228,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcess</Table>
<Name>IDX_SaInterfaceProcess_IntProcAt</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>InterfaceId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
<DbDfnIndexColumn>
<Seq>2</Seq>
<Name>ProcessAt</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcess</Table>
<Name>IDX_SaInterfaceProcess_IntProcRef</Name>
<Name>IDX_InterfaceProcess_IntProc</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -1474,7 +1449,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcessDataItem</Table>
<Name>PK_SaInterfaceProcessDataItem</Name>
<Name>PK_InterfaceProcessDataItem</Name>
<IndexType>1</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
@@ -1499,7 +1474,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcessDataItem</Table>
<Name>IDX_SaInterfaceProcessDataItem_Item</Name>
<Name>IDX_InterfaceProcessDataItem_Item</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -1519,7 +1494,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcessDataItem</Table>
<Name>IDX_SaInterfaceProcessDataItem_ProcessItemData</Name>
<Name>IDX_InterfaceProcessDataItem_ProcItemData</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -1589,11 +1564,11 @@
<Name>MsgType</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>12</DataTypeNative>
<DataTypeNameNative>varchar</DataTypeNameNative>
<DataTypeNative>-9</DataTypeNative>
<DataTypeNameNative>nvarchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>3</Size>
<BufferLen>3</BufferLen>
<BufferLen>6</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>Nullable</Nullable>
<IsNullable>true</IsNullable>
@@ -1609,8 +1584,8 @@
<DataTypeNative>-9</DataTypeNative>
<DataTypeNameNative>nvarchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>1024</Size>
<BufferLen>2048</BufferLen>
<Size>4000</Size>
<BufferLen>8000</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>Nullable</Nullable>
<IsNullable>true</IsNullable>
@@ -1759,11 +1734,11 @@
<Name>CreateHost</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>-9</DataTypeNative>
<DataTypeNameNative>nvarchar</DataTypeNameNative>
<DataTypeNative>12</DataTypeNative>
<DataTypeNameNative>varchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>64</Size>
<BufferLen>128</BufferLen>
<BufferLen>64</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>Nullable</Nullable>
<IsNullable>true</IsNullable>
@@ -1810,11 +1785,11 @@
<Name>UpdateHost</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>-9</DataTypeNative>
<DataTypeNameNative>nvarchar</DataTypeNameNative>
<DataTypeNative>12</DataTypeNative>
<DataTypeNameNative>varchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>64</Size>
<BufferLen>128</BufferLen>
<BufferLen>64</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>Nullable</Nullable>
<IsNullable>true</IsNullable>
@@ -1825,14 +1800,14 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcessMessage</Table>
<Name>PK_SaInterfaceProcessMessage</Name>
<Name>PK_InterfaceProcessMessage</Name>
<IndexType>1</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>12</Pages>
<UniqueValues>342</UniqueValues>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -1845,7 +1820,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcessMessage</Table>
<Name>IDX_SaInterfaceProcessMessage_Process</Name>
<Name>IDX_InterfaceProcessMessage_Process</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -1865,7 +1840,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>SaInterfaceProcessMessage</Table>
<Name>IDX_SaInterfaceProcessMessage_ProcessMsgType</Name>
<Name>IDX_InterfaceProcessMessage_ProcMsgType</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>