BusinessMgr 3.0.0.4
This commit is contained in:
@@ -7,6 +7,7 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.Base
|
||||
{
|
||||
@@ -32,9 +33,9 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
private void LogSql(String sql)
|
||||
protected void LogSql(String fn, String sql)
|
||||
{
|
||||
SaLogger.Debug(GetType().Name + " SQL: " + sql);
|
||||
SaLogger.Debug($"{fn} SQL: {sql}");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -174,9 +175,9 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
// Database Index stats.
|
||||
public class IndexStats
|
||||
{
|
||||
public int PrimaryIndicesCreated { get; set; } = 0;
|
||||
public int IndicesCreated { get; set; } = 0;
|
||||
public int IndicesDropped { get; set; } = 0;
|
||||
public int PrimaryIndicesCreated { get; set; }
|
||||
public int IndicesCreated { get; set; }
|
||||
public int IndicesDropped { get; set; }
|
||||
public List<String> Stats
|
||||
{
|
||||
get
|
||||
@@ -194,59 +195,20 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Drop index.
|
||||
protected bool DropDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String indexName)
|
||||
protected bool ColumnsExist(String fn, DbDfnTable dfnTable, HashSet<String> columnNames)
|
||||
{
|
||||
if (database == null || HasErrorState()) return false;
|
||||
if (!database.TableExists(tableName)) return true;
|
||||
DbDfnTable dfnTbl = database.GetTableDfn(tableName, true);
|
||||
if (!dfnTbl.HasIndexByName(indexName)) // Should also check the columns and their sequence in the index.
|
||||
HashSet<String> missingColumnNames = new HashSet<string>();
|
||||
foreach (String columnName in columnNames)
|
||||
{
|
||||
// Drop index:
|
||||
// MS Access: DROP INDEX index_name ON table_name
|
||||
// MS SQL Server: DROP INDEX table_name.index_name
|
||||
// DB2/Oracle: DROP INDEX index_name
|
||||
// MySQL: ALTER TABLE table_name DROP INDEX index_name
|
||||
String query = "DROP INDEX [" + indexName + "] ON [" + tableName + "]";
|
||||
LogSql(query);
|
||||
if (database.DbmsType == DbmsType.MsSql)
|
||||
query = "DROP INDEX [" + tableName + "].[" + indexName + "]";
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
if (!database.HasErrorState())
|
||||
indexStats.IndicesDropped++;
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: " + tableName + "; Index: " + indexName + "; Exception: " + database.ErrorStateMessage);
|
||||
#endif
|
||||
SetErrorState("Failed to drop index " + indexName + " on " + tableName + " - " + database.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
if (!dfnTable.HasColumnByName(columnName))
|
||||
missingColumnNames.Add(columnName);
|
||||
}
|
||||
else
|
||||
if (missingColumnNames.Any())
|
||||
{
|
||||
// Assume this is the Primary Key:
|
||||
String query = "ALTER TABLE [" + tableName + "] DROP CONSTRAINT [" + indexName + "]";
|
||||
LogSql(query);
|
||||
//if (database.DbmsType() == eSaDbmsMsSql)
|
||||
// sQry = "DROP INDEX ["+tableName+"].["+indexName+"]";
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
if (!database.HasErrorState())
|
||||
indexStats.IndicesDropped++;
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: " + tableName + "; Index: " + indexName + "; Exception: " + database.ErrorStateMessage);
|
||||
#endif
|
||||
SetErrorState("Failed to drop primary key " + indexName + " on " + tableName + " - " + database.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
SaLogger.Warn($"{fn} {dfnTable.Name} Table is missing columns for index creation: {missingColumnNames.Concat(", ")}.");
|
||||
return false;
|
||||
}
|
||||
return OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -254,18 +216,19 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
protected bool CreatePrimaryDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String columnsCsv, bool dropIndicesIfNotExist = true)
|
||||
{
|
||||
if (database == null || HasErrorState()) return false;
|
||||
if (!database.TableExists(tableName)) return true;
|
||||
List<String> lColumn = StringListUtil.Split(columnsCsv, ",");
|
||||
DbDfnTable dfnTbl = database.GetTableDfn(tableName, true);
|
||||
DbDfnTable dfnTable = database.GetTableDfn(tableName, true);
|
||||
if (dfnTable == null) return true;
|
||||
HashSet<String> columnNames = new HashSet<String>(Regex.Split(columnsCsv, "[\\s,;\\-+]+").Where(s => !StringUtil.IsEmpty(s)));
|
||||
if (!ColumnsExist(SysUtil.Fn, dfnTable, columnNames)) return false;
|
||||
|
||||
String indexName = "PK_" + tableName;
|
||||
if (!dfnTbl.HasIndexByName(indexName))
|
||||
if (!dfnTable.HasIndexByName(indexName))
|
||||
{
|
||||
if (dropIndicesIfNotExist)
|
||||
{
|
||||
foreach (DbDfnIndex indexDfn in dfnTbl.Indices)
|
||||
{
|
||||
// All existing indices are dropped
|
||||
foreach (DbDfnIndex indexDfn in dfnTable.Indices)
|
||||
DropDbIndex(database, indexStats, tableName, indexDfn.Name);
|
||||
}
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
@@ -276,10 +239,10 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
// ADD CONSTRAINT [PK_Individual_CustomerID]
|
||||
// PRIMARY KEY CLUSTERED
|
||||
// ([CustomerID] ASC)
|
||||
String query = "ALTER TABLE [" + tableName + "] ADD CONSTRAINT [" + indexName + "] PRIMARY KEY (" + lColumn.Concat(",", "[", "]") + ")";
|
||||
String query = $"ALTER TABLE [{tableName}] ADD CONSTRAINT [{indexName}] PRIMARY KEY ({columnNames.Concat(",", "[", "]")})";
|
||||
if (database.DbmsType == DbmsType.MsSql)
|
||||
query = "ALTER TABLE [" + tableName + "] ADD CONSTRAINT [" + indexName + "] PRIMARY KEY CLUSTERED (" + lColumn.Concat(",", "[", "]") + ")";
|
||||
LogSql(query);
|
||||
query = $"ALTER TABLE [{tableName}] ADD CONSTRAINT [{indexName}] PRIMARY KEY CLUSTERED ({columnNames.Concat(",", "[", "]")})";
|
||||
LogSql(SysUtil.Fn, query);
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
@@ -287,10 +250,8 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
indexStats.PrimaryIndicesCreated++;
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: %" + tableName + "; Index: " + indexName + "; Exception: " + database.ErrorStateMessage);
|
||||
#endif
|
||||
SetErrorState("Failed to create primary index " + indexName + " on " + tableName + " - " + database.ErrorStateMessage);
|
||||
SetErrorState($"Failed to create primary index {indexName} on {tableName} - {database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,20 +261,27 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create database index.
|
||||
protected bool CreateDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String indexName, String columnsCsv, bool unique = false)
|
||||
protected bool CreateDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String indexName, String columnsCsv, String includeColumnsCsv = "", bool unique = false)
|
||||
{
|
||||
if (database == null || HasErrorState()) return false;
|
||||
if (!database.TableExists(tableName)) return true;
|
||||
List<String> columns = StringListUtil.Split(columnsCsv, ",");
|
||||
DbDfnTable dfnTbl = database.GetTableDfn(tableName, true);
|
||||
// Construct the index name:
|
||||
DbDfnTable dfnTable = database.GetTableDfn(tableName, true);
|
||||
if (dfnTable == null) return true;
|
||||
HashSet<String> columnNames = new HashSet<String>(Regex.Split(columnsCsv, "[\\s,;\\-+]+").Where(s => !StringUtil.IsEmpty(s)));
|
||||
if (!ColumnsExist(SysUtil.Fn, dfnTable, columnNames)) return false;
|
||||
HashSet<String> includeColumnNames = new HashSet<String>(Regex.Split(includeColumnsCsv, "[\\s,;\\-+]+").Where(s => !StringUtil.IsEmpty(s)));
|
||||
if (!ColumnsExist(SysUtil.Fn, dfnTable, includeColumnNames)) return false;
|
||||
|
||||
// Construct the index name.
|
||||
String indexNamePrefix = "IDX_" + tableName + "_";
|
||||
if (!indexName.StartsWith(indexNamePrefix)) indexName = indexNamePrefix + indexName;
|
||||
if (!dfnTbl.HasIndexByName(indexName)) // Should also check the columns and their sequence in the index.
|
||||
|
||||
// Should also check the columns and their sequence in the index.
|
||||
if (!dfnTable.HasIndexByName(indexName))
|
||||
{
|
||||
String query = "CREATE " + (unique ? "UNIQUE " : "") + "INDEX ";
|
||||
query += "[" + indexName + "] ON [" + tableName + "] (" + columns.Concat(",", "[", "]") + ")";
|
||||
LogSql(query);
|
||||
String query = $"CREATE " + (unique ? "UNIQUE " : "") + $"INDEX [{indexName}] ON [{tableName}] ({columnNames.Concat(",", "[", "]")})";
|
||||
if (!includeColumnNames.IsEmpty())
|
||||
query += $" INCLUDE ({includeColumnNames.Concat(",", "[", "]")})";
|
||||
LogSql(SysUtil.Fn, query);
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
@@ -321,10 +289,66 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
indexStats.IndicesCreated++;
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: " + tableName + "; Index: " + indexName + "; Exception: " + database.ErrorStateMessage);
|
||||
#endif
|
||||
SetErrorState("Failed to create index " + indexName + " on " + tableName + " - " + database.ErrorStateMessage);
|
||||
SetErrorState($"Failed to create index {indexName} on {tableName} - {database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Drop index.
|
||||
protected bool DropDbIndex(ISacsDatabase database, IndexStats indexStats, String tableName, String indexName)
|
||||
{
|
||||
if (database == null || HasErrorState()) return false;
|
||||
DbDfnTable dfnTable = database.GetTableDfn(tableName, true);
|
||||
if (dfnTable == null) return true;
|
||||
DbDfnIndex dfnIndex = dfnTable.GetIndexByName(indexName);
|
||||
if (dfnIndex == null)
|
||||
{
|
||||
SaLogger.Info($"{SysUtil.Fn} Index '{indexName}' does not exist on table {tableName}.");
|
||||
return true;
|
||||
}
|
||||
if (!dfnIndex.Primary)
|
||||
{
|
||||
// Drop index:
|
||||
// MS Access: DROP INDEX index_name ON table_name
|
||||
// MS SQL Server: DROP INDEX table_name.index_name
|
||||
// DB2/Oracle: DROP INDEX index_name
|
||||
// MySQL: ALTER TABLE table_name DROP INDEX index_name
|
||||
String query = $"DROP INDEX [{indexName}] ON [{tableName}]";
|
||||
LogSql(SysUtil.Fn, query);
|
||||
if (database.DbmsType == DbmsType.MsSql)
|
||||
query = $"DROP INDEX [{tableName}].[{indexName}]";
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
if (!database.HasErrorState())
|
||||
indexStats.IndicesDropped++;
|
||||
else
|
||||
{
|
||||
SetErrorState($"Failed to drop index {indexName} on {tableName} - {database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Drop Primary Key.
|
||||
String query = $"ALTER TABLE [{tableName}] DROP CONSTRAINT [{indexName}]";
|
||||
LogSql(SysUtil.Fn, query);
|
||||
//if (database.DbmsType() == eSaDbmsMsSql)
|
||||
// sQry = "DROP INDEX ["+tableName+"].["+indexName+"]";
|
||||
if (!StringUtil.IsEmpty(query))
|
||||
{
|
||||
database.ExecuteNonQuery(query);
|
||||
if (!database.HasErrorState())
|
||||
indexStats.IndicesDropped++;
|
||||
else
|
||||
{
|
||||
SetErrorState($"Failed to drop primary key {indexName} on {tableName} - {database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
private static List<DbDfnTable> GetTableDefinitions(DbConnection dbConnection, String tableNameRestriction = null)
|
||||
{
|
||||
List<DbDfnTable> tables = new List<DbDfnTable>();
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug(SysUtil.Fn + (!StringUtil.IsEmpty(tableNameRestriction) ? " Table: " + tableNameRestriction : " "));
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Database: {dbConnection.Database}." + (!StringUtil.IsEmpty(tableNameRestriction) ? $" Table: {tableNameRestriction}." : ""));
|
||||
String[] restrictions = new String[] { null, null, tableNameRestriction }; // database, owner, table name, type
|
||||
using (DataTable tableSchema = dbConnection.GetSchema(OdbcMetaDataCollectionNames.Tables, restrictions))
|
||||
{
|
||||
@@ -502,7 +502,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
//-------------------------------------------------------------------
|
||||
private void PopulateTableColumns(DbConnection dbConnection, DbDfnTable table)
|
||||
{
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Table: {table.Name}");
|
||||
//if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Table: {table.Name}");
|
||||
short columnPos = 0;
|
||||
String[] restrictions = new String[] { null, table.Schema, table.Name, null }; // database, owner, table name, column name
|
||||
using (DataTable columnSchema = dbConnection.GetSchema(OdbcMetaDataCollectionNames.Columns, restrictions))
|
||||
|
||||
@@ -125,8 +125,10 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
private void CompareTables()
|
||||
{
|
||||
// Database schemas.
|
||||
HashSet<String> sourceTables = (config.SourceDatabase?.GetTableNames(true) ?? config.SourceTables.Select(item => item.Name)).OrderBy(item => item).ToHashSet();
|
||||
HashSet<String> targetTables = config.TargetDatabase.GetTableNames(true).OrderBy(item => item).ToHashSet();
|
||||
List<DbDfnTable> sourceTableDfns = config.SourceDatabase?.GetTableDfns(true) ?? config.SourceTables;
|
||||
List<DbDfnTable> targetTableDfns = config.TargetDatabase.GetTableDfns(true) ?? new List<DbDfnTable>();
|
||||
HashSet<String> sourceTables = sourceTableDfns.Select(item => item.Name).OrderBy(item => item).ToHashSet();
|
||||
HashSet<String> targetTables = targetTableDfns.Select(item => item.Name).OrderBy(item => item).ToHashSet();
|
||||
|
||||
for (int sourceTableIdx = 0, targetTableIdx = 0; sourceTableIdx < sourceTables.Count || targetTableIdx < targetTables.Count;)
|
||||
{
|
||||
@@ -135,8 +137,8 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
String targetTableName = (targetTableIdx < targetTables.Count ? targetTables.ElementAt(targetTableIdx) : "");
|
||||
|
||||
// Retrieve table definition from each database.
|
||||
DbDfnTable sourceTableDfn = !StringUtil.IsBlank(sourceTableName) ? config.SourceDatabase?.GetTableDfn(sourceTableName, true) ?? config.SourceTables.GetTableByName(sourceTableName) : null;
|
||||
DbDfnTable targetTableDfn = !StringUtil.IsBlank(targetTableName) ? config.TargetDatabase.GetTableDfn(targetTableName, true) : null;
|
||||
DbDfnTable sourceTableDfn = sourceTableDfns.GetTableByName(sourceTableName);
|
||||
DbDfnTable targetTableDfn = targetTableDfns.GetTableByName(sourceTableName);
|
||||
|
||||
if (!StringUtil.IsEmpty(sourceTableName) && (StringUtil.IsEmpty(targetTableName) || targetTableName.CompareTo(sourceTableName) > 0))
|
||||
{
|
||||
|
||||
@@ -10,44 +10,44 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Currencies.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// C u r r e n c i e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_Currency { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.Currency, false); } }
|
||||
public override bool DatabaseIsValid_Currency { get { return Database.TableExists(TableName_Currency); } }
|
||||
|
||||
// Retrieve Currency.
|
||||
public override SaCurrency GetCurrency (SaCurrency.Params prmCurrency)
|
||||
// Retrieve Item.
|
||||
public override SaCurrency GetCurrency(SaCurrency.Params prmCurrency)
|
||||
{
|
||||
return referenceDataMgr.GetCurrency(prmCurrency);
|
||||
}
|
||||
|
||||
// Currency list.
|
||||
public override ColumnDfn GetCurrencyColumnDfn (SaCurrency.Column columnId, String caption = "", int width = 0)
|
||||
// Item list.
|
||||
public override ColumnDfn GetCurrencyColumnDfn(SaCurrency.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyColumnDfn(columnId, caption, width);
|
||||
}
|
||||
public override List<String> GetCurrencyQueryFilter (SaCurrency.Params prm)
|
||||
public override List<String> GetCurrencyQueryFilter(SaCurrency.Params prm)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyQueryFilter(prm);
|
||||
}
|
||||
public override long GetCurrencyCount (SaCurrency.Params prmCurrency)
|
||||
public override long GetCurrencyCount(SaCurrency.Params prmCurrency)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyCount(prmCurrency);
|
||||
}
|
||||
public override List<SaCurrency> GetCurrencyList (SaCurrency.Params prmCurrency)
|
||||
public override List<SaCurrency> GetCurrencyList(SaCurrency.Params prmCurrency)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyList(prmCurrency);
|
||||
}
|
||||
public override DbResultSet ExecuteCurrencyQuery (List<ColumnDfn> columns, SaCurrency.Params prm)
|
||||
public override DbResultSet ExecuteCurrencyQuery(List<ColumnDfn> columns, SaCurrency.Params prm)
|
||||
{
|
||||
return referenceDataMgr.ExecuteCurrencyQuery(columns, prm);
|
||||
}
|
||||
public override DataValue GetCurrencyDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public override DataValue GetCurrencyDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
return referenceDataMgr.GetCurrencyDataValue(column, values);
|
||||
}
|
||||
|
||||
@@ -10,44 +10,44 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Languages.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// L a n g u a g e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_Language { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.Language, false); } }
|
||||
public override bool DatabaseIsValid_Language { get { return Database.TableExists(TableName_Language); } }
|
||||
|
||||
// Retrieve Language.
|
||||
public override SaLanguage GetLanguage (SaLanguage.Params prmLanguage)
|
||||
// Retrieve Item.
|
||||
public override SaLanguage GetLanguage(SaLanguage.Params prmLanguage)
|
||||
{
|
||||
return referenceDataMgr.GetLanguage(prmLanguage);
|
||||
}
|
||||
|
||||
// Language list.
|
||||
public override ColumnDfn GetLanguageColumnDfn (SaLanguage.Column columnId, String caption = "", int width = 0)
|
||||
// Item list.
|
||||
public override ColumnDfn GetLanguageColumnDfn(SaLanguage.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageColumnDfn(columnId, caption, width);
|
||||
}
|
||||
public override List<String> GetLanguageQueryFilter (SaLanguage.Params prm)
|
||||
public override List<String> GetLanguageQueryFilter(SaLanguage.Params prm)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageQueryFilter(prm);
|
||||
}
|
||||
public override long GetLanguageCount (SaLanguage.Params prmLanguage)
|
||||
public override long GetLanguageCount(SaLanguage.Params prmLanguage)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageCount(prmLanguage);
|
||||
}
|
||||
public override List<SaLanguage> GetLanguageList (SaLanguage.Params prmLanguage)
|
||||
public override List<SaLanguage> GetLanguageList(SaLanguage.Params prmLanguage)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageList(prmLanguage);
|
||||
}
|
||||
public override DbResultSet ExecuteLanguageQuery (List<ColumnDfn> columns, SaLanguage.Params prm)
|
||||
public override DbResultSet ExecuteLanguageQuery(List<ColumnDfn> columns, SaLanguage.Params prm)
|
||||
{
|
||||
return referenceDataMgr.ExecuteLanguageQuery(columns, prm);
|
||||
}
|
||||
public override DataValue GetLanguageDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public override DataValue GetLanguageDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
return referenceDataMgr.GetLanguageDataValue(column, values);
|
||||
}
|
||||
|
||||
@@ -10,44 +10,44 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Regions.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// R e g i o n s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_Region { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.Region, false); } }
|
||||
public override bool DatabaseIsValid_Region { get { return Database.TableExists(TableName_Region); } }
|
||||
|
||||
// Retrieve Region.
|
||||
public override SaRegion GetRegion (SaRegion.Params prmRegion)
|
||||
// Retrieve Item.
|
||||
public override SaRegion GetRegion(SaRegion.Params prmRegion)
|
||||
{
|
||||
return referenceDataMgr.GetRegion(prmRegion);
|
||||
}
|
||||
|
||||
// Region list.
|
||||
public override ColumnDfn GetRegionColumnDfn (SaRegion.Column columnId, String caption = "", int width = 0)
|
||||
// Item list.
|
||||
public override ColumnDfn GetRegionColumnDfn(SaRegion.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetRegionColumnDfn(columnId, caption, width);
|
||||
}
|
||||
public override List<String> GetRegionQueryFilter (SaRegion.Params prm)
|
||||
public override List<String> GetRegionQueryFilter(SaRegion.Params prm)
|
||||
{
|
||||
return referenceDataMgr.GetRegionQueryFilter(prm);
|
||||
}
|
||||
public override long GetRegionCount (SaRegion.Params prmRegion)
|
||||
public override long GetRegionCount(SaRegion.Params prmRegion)
|
||||
{
|
||||
return referenceDataMgr.GetRegionCount(prmRegion);
|
||||
}
|
||||
public override List<SaRegion> GetRegionList (SaRegion.Params prmRegion)
|
||||
public override List<SaRegion> GetRegionList(SaRegion.Params prmRegion)
|
||||
{
|
||||
return referenceDataMgr.GetRegionList(prmRegion);
|
||||
}
|
||||
public override DbResultSet ExecuteRegionQuery (List<ColumnDfn> columns, SaRegion.Params prm)
|
||||
public override DbResultSet ExecuteRegionQuery(List<ColumnDfn> columns, SaRegion.Params prm)
|
||||
{
|
||||
return referenceDataMgr.ExecuteRegionQuery(columns, prm);
|
||||
}
|
||||
public override DataValue GetRegionDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public override DataValue GetRegionDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
return referenceDataMgr.GetRegionDataValue(column, values);
|
||||
}
|
||||
|
||||
@@ -10,23 +10,23 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Tax Codes.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// T a x C o d e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_TaxCode { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.TaxCode, false); } }
|
||||
public override bool DatabaseIsValid_TaxCode { get { return Database.TableExists(TableName_TaxCode); } }
|
||||
|
||||
// Retrieve TaxCode.
|
||||
// Retrieve Item.
|
||||
public override SaTaxCode GetTaxCode (SaTaxCode.Params prmTaxCode)
|
||||
{
|
||||
return referenceDataMgr.GetTaxCode(prmTaxCode);
|
||||
}
|
||||
|
||||
// TaxCode list.
|
||||
// Item list.
|
||||
public override ColumnDfn GetTaxCodeColumnDfn (SaTaxCode.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetTaxCodeColumnDfn(columnId, caption, width);
|
||||
|
||||
@@ -10,44 +10,44 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console - Units of Measure.
|
||||
//=======================================================================
|
||||
partial class SaReferenceDataConsole_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// U n i t s M e a s u r e
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String TableName_UnitMeasure { get { return SaReferenceDataDbDfn.GetTableName(SaReferenceDataDbDfn.TableIdx.UnitMeasure, false); } }
|
||||
public override bool DatabaseIsValid_UnitMeasure { get { return Database.TableExists(TableName_UnitMeasure); } }
|
||||
|
||||
// Retrieve Unit of Measure.
|
||||
public override SaUnitMeasure GetUnitMeasure (SaUnitMeasure.Params prmUnitMeasure)
|
||||
// Retrieve Item.
|
||||
public override SaUnitMeasure GetUnitMeasure(SaUnitMeasure.Params prmUnitMeasure)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasure(prmUnitMeasure);
|
||||
}
|
||||
|
||||
// Unit of Measure list.
|
||||
public override ColumnDfn GetUnitMeasureColumnDfn (SaUnitMeasure.Column columnId, String caption = "", int width = 0)
|
||||
// Item list.
|
||||
public override ColumnDfn GetUnitMeasureColumnDfn(SaUnitMeasure.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureColumnDfn(columnId, caption, width);
|
||||
}
|
||||
public override List<String> GetUnitMeasureQueryFilter (SaUnitMeasure.Params prm)
|
||||
public override List<String> GetUnitMeasureQueryFilter(SaUnitMeasure.Params prm)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureQueryFilter(prm);
|
||||
}
|
||||
public override long GetUnitMeasureCount (SaUnitMeasure.Params prmUnitMeasure)
|
||||
public override long GetUnitMeasureCount(SaUnitMeasure.Params prmUnitMeasure)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureCount(prmUnitMeasure);
|
||||
}
|
||||
public override List<SaUnitMeasure> GetUnitMeasureList (SaUnitMeasure.Params prmUnitMeasure)
|
||||
public override List<SaUnitMeasure> GetUnitMeasureList(SaUnitMeasure.Params prmUnitMeasure)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureList(prmUnitMeasure);
|
||||
}
|
||||
public override DbResultSet ExecuteUnitMeasureQuery (List<ColumnDfn> columns, SaUnitMeasure.Params prm)
|
||||
public override DbResultSet ExecuteUnitMeasureQuery(List<ColumnDfn> columns, SaUnitMeasure.Params prm)
|
||||
{
|
||||
return referenceDataMgr.ExecuteUnitMeasureQuery(columns, prm);
|
||||
}
|
||||
public override DataValue GetUnitMeasureDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public override DataValue GetUnitMeasureDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
return referenceDataMgr.GetUnitMeasureDataValue(column, values);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ using Sarand.Net.Standard.Dbas.Base;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data console.
|
||||
//=======================================================================
|
||||
public abstract partial class SaReferenceDataConsole_Dbas : SaReferenceDataConsole
|
||||
{
|
||||
|
||||
@@ -14,12 +14,12 @@ using Sarand.Net.Standard.Base.App;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Currencies.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// C u r r e n c i e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create Currency.
|
||||
public override SaCurrency CreateCurrency()
|
||||
{
|
||||
|
||||
@@ -14,12 +14,12 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Languages.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// L a n g u a g e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create Language.
|
||||
public override SaLanguage CreateLanguage()
|
||||
{
|
||||
|
||||
@@ -14,12 +14,12 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Regions.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// R e g i o n s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create Region.
|
||||
public override SaRegion CreateRegion(SaRegionType regionType)
|
||||
{
|
||||
|
||||
@@ -14,13 +14,13 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Tax Codes.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// T a x C o d e s
|
||||
//*******************************************************************
|
||||
// Create TaxCode.
|
||||
//-------------------------------------------------------------------
|
||||
// Create Item.
|
||||
public override SaTaxCode CreateTaxCode()
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -41,7 +41,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode exists.
|
||||
// Item exists.
|
||||
public override bool TaxCodeExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -56,7 +56,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get TaxCode.
|
||||
// Get Item.
|
||||
public override SaTaxCode GetTaxCode(SaTaxCode.Params prm)
|
||||
{
|
||||
return GetTaxCode(GetTaxCodeQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
@@ -105,7 +105,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item.
|
||||
// Validate Item.
|
||||
public override bool IsValidTaxCodeData(SaTaxCode.Data data, SaTaxCode.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -114,7 +114,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert item.
|
||||
// Insert Item.
|
||||
public override bool InsertTaxCode(SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -142,7 +142,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update item.
|
||||
// Update Item.
|
||||
public override bool UpdateTaxCode(SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -171,7 +171,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Delete item.
|
||||
// Delete Item.
|
||||
public override bool TaxCodeCanBeDeleted(SaTaxCode taxCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -202,7 +202,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copy data properties to and from database.
|
||||
// Copy Item properties to and from database.
|
||||
private void PopulateTo(TaxCode_Db dbTaxCode, SaTaxCode taxCode, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
dbTaxCode._Id = taxCode.Id.ToInt();
|
||||
@@ -233,7 +233,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
private void PopulateFrom(TaxCode_Db dbTaxCode, SaTaxCode taxCode)
|
||||
{
|
||||
//taxCode.Id = new SysId(dbTaxCode._Id);
|
||||
//taxCode.Code = dbTaxCode._Code;
|
||||
taxCode.Code = dbTaxCode._Code;
|
||||
taxCode.CodeAlt1 = dbTaxCode._CodeAlt1;
|
||||
taxCode.CodeAlt2 = dbTaxCode._CodeAlt2;
|
||||
taxCode.Description = dbTaxCode._Description;
|
||||
@@ -252,7 +252,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode column definitions.
|
||||
// Item column definitions.
|
||||
private static readonly String aliasTaxCode = "aTax";
|
||||
private void SetTaxCodeColDfn
|
||||
(ColumnDfn col, String caption, int width, SaReferenceDataDbDfn.ColumnIdx dbCol,
|
||||
@@ -265,9 +265,9 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
if (dataType == DataValue.DataType.String && dbCol != SaReferenceDataDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SaReferenceDataDbDfn.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting taxcode column definition.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item column definition.
|
||||
public override ColumnDfn GetTaxCodeColumnDfn(SaTaxCode.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
|
||||
@@ -354,7 +354,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode query filter.
|
||||
// Item query filter.
|
||||
public override List<string> GetTaxCodeQueryFilter(SaTaxCode.Params prm)
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
@@ -403,7 +403,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
}
|
||||
// TaxCode sort columns.
|
||||
// Item sort columns.
|
||||
public List<String> GetTaxCodeSortColumns(SaTaxCode.Params prm)
|
||||
{
|
||||
// Sort sequence:
|
||||
@@ -438,7 +438,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode count.
|
||||
// Item count.
|
||||
private long GetTaxCodeCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -451,7 +451,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode list.
|
||||
// Item list.
|
||||
public override List<SaTaxCode> GetTaxCodeList(SaTaxCode.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -486,7 +486,6 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// TaxCode query execution.
|
||||
public override DbResultSet ExecuteTaxCodeQuery(List<ColumnDfn> columns, SaTaxCode.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
@@ -14,12 +14,12 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager - Units of Measure.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// U n i t s o f M e a s u r e
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Create UnitMeasure.
|
||||
public override SaUnitMeasure CreateUnitMeasure()
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
{
|
||||
//=======================================================================
|
||||
// Reference Data manager.
|
||||
//=======================================================================
|
||||
internal partial class SaReferenceDataMgr_Dbas : SaReferenceDataMgr
|
||||
{
|
||||
@@ -18,7 +20,7 @@ namespace Sarand.Net.Standard.Dbas.ReferenceData
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaReferenceDataMgr_Dbas (SaReferenceDataConsole_Dbas referenceDataConsole) :
|
||||
public SaReferenceDataMgr_Dbas(SaReferenceDataConsole_Dbas referenceDataConsole) :
|
||||
base()
|
||||
{
|
||||
ReferenceDataConsole = referenceDataConsole;
|
||||
|
||||
Reference in New Issue
Block a user