Saxonite 1.2.11.2
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaDbDfnOdbcDriver (String name)
|
||||
public SaDbDfnOdbcDriver(String name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
@@ -25,28 +25,30 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public String Name { get; }
|
||||
public Dictionary<String,String> Attributes { get; } = new Dictionary<String, String>();
|
||||
public Dictionary<String, String> Attributes { get; } = new Dictionary<String, String>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
/// <summary>Add 'Driver' attribute from registry. Fails if driver name not found.</summary>
|
||||
public bool AddDriverConfig ()
|
||||
public bool AddDriverConfig()
|
||||
{
|
||||
if (StringUtil.IsEmpty(Name)) return false;
|
||||
try
|
||||
{
|
||||
#pragma warning disable CA1416
|
||||
// Retrieve 'Driver' (location of DLL) parameter for this driver:
|
||||
using (RegistryKey localMachineHive = Registry.LocalMachine)
|
||||
using (RegistryKey odbcDriverKey = localMachineHive.OpenSubKey(@"SOFTWARE\ODBC\ODBCINST.INI\" + Name))
|
||||
{
|
||||
if (odbcDriverKey != null)
|
||||
{
|
||||
object driverName = odbcDriverKey.GetValue("Driver");
|
||||
object driverName = odbcDriverKey.GetValue("Driver");
|
||||
if (driverName != null && driverName is String)
|
||||
Attributes["Driver"] = driverName.ToString();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#pragma warning restore CA1416
|
||||
}
|
||||
catch (Exception) { }
|
||||
return true;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SacsDatabase (DbmsType dbms, String databaseName, String connectionString)
|
||||
protected SacsDatabase(DbmsType dbms, String databaseName, String connectionString)
|
||||
{
|
||||
DbmsType = dbms;
|
||||
DatabaseName = databaseName;
|
||||
@@ -36,9 +36,9 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
public String DatabaseName { get; }
|
||||
public SelectLockMode SelectLockMode { get; set; } = SelectLockMode.Default;
|
||||
public bool DisplayErrors { get; set; } = true;
|
||||
public abstract void OnConnectionChanged ();
|
||||
public abstract DbConnection CreateConnection (bool forceOdbc = false);
|
||||
public abstract DbDataAdapter CreateDataAdapter ();
|
||||
public abstract void OnConnectionChanged();
|
||||
public abstract DbConnection CreateConnection(bool forceOdbc = false);
|
||||
public abstract DbDataAdapter CreateDataAdapter();
|
||||
// Profile properties.
|
||||
public static String ProfileSection_DbUtilities { get; } = "DbUtilities";
|
||||
public static String ProfileValue_DbExportFile { get; } = "DbExportFile";
|
||||
@@ -57,21 +57,21 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
protected String NextIdTable { get; set; } = "NextId";
|
||||
protected String NextIdColumn_Object { get; set; } = "Object";
|
||||
protected String NextIdColumn_NextId { get; set; } = "NextId";
|
||||
public abstract SysId GetNextId (String objectName, DbUpdateInfo dbUpdateInfo, bool databaseTable = true, String idColumn = "Id");
|
||||
public abstract SysId GetNextId(String objectName, DbUpdateInfo dbUpdateInfo, bool databaseTable = true, String idColumn = "Id");
|
||||
public abstract int GetNextIdFromTable(string objectName, string idColumn = "Id");
|
||||
public abstract bool SetMinNextId (String objectName, SysId id, DbUpdateInfo dbUpdateInfo, bool databaseTable = true, String idColumn = "Id", bool force = false);
|
||||
public abstract bool SetMinNextId(String objectName, SysId id, DbUpdateInfo dbUpdateInfo, bool databaseTable = true, String idColumn = "Id", bool force = false);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// O D B C D r i v e r s
|
||||
//-------------------------------------------------------------------
|
||||
[DllImport("odbccp32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
private static extern bool SQLGetInstalledDriversW (char[] lpszBuf, ushort cbufMax, out ushort pcbBufOut);
|
||||
private static extern bool SQLGetInstalledDriversW(char[] lpszBuf, ushort cbufMax, out ushort pcbBufOut);
|
||||
/// <summary>
|
||||
/// Gets the ODBC driver names from the SQLGetInstalledDrivers function.
|
||||
/// <para>Ref. https://stackoverflow.com/questions/6457973/odbc-driver-list-from-net</para>
|
||||
/// </summary>
|
||||
/// <returns>List of ODBC driver names, if successfull.</returns>
|
||||
public static List<String> GetOdbcDriverNames ()
|
||||
public static List<String> GetOdbcDriverNames()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -93,13 +93,16 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
catch (Exception) { }
|
||||
try
|
||||
{
|
||||
#pragma warning disable CA1416
|
||||
// Alternatively, use the registry.
|
||||
// Validate platform compatibility
|
||||
using (RegistryKey localMachineHive = Registry.LocalMachine)
|
||||
using (RegistryKey odbcDriversKey = localMachineHive.OpenSubKey(@"SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"))
|
||||
{
|
||||
if (odbcDriversKey != null)
|
||||
return new List<String>(odbcDriversKey.GetValueNames()).OrderBy(item => item).ToList();
|
||||
}
|
||||
// Validate platform compatibility
|
||||
// 64-BitConverter machines.
|
||||
using (RegistryKey localMachineHive = Registry.LocalMachine)
|
||||
using (RegistryKey odbcDriversKey = localMachineHive.OpenSubKey(@"SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers"))
|
||||
@@ -107,6 +110,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
if (odbcDriversKey != null)
|
||||
return new List<String>(odbcDriversKey.GetValueNames()).OrderBy(item => item).ToList();
|
||||
}
|
||||
#pragma warning restore CA1416
|
||||
}
|
||||
catch (Exception) { }
|
||||
return new List<String>();
|
||||
@@ -116,13 +120,13 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
// O D B C D a t a S o u r c e s
|
||||
//-------------------------------------------------------------------
|
||||
[DllImport("odbc32.dll")]
|
||||
public static extern int SQLDataSources (int EnvHandle, int Direction, StringBuilder ServerName, int ServerNameBufferLenIn, ref int ServerNameBufferLenOut, StringBuilder Driver, int DriverBufferLenIn, ref int DriverBufferLenOut);
|
||||
public static extern int SQLDataSources(int EnvHandle, int Direction, StringBuilder ServerName, int ServerNameBufferLenIn, ref int ServerNameBufferLenOut, StringBuilder Driver, int DriverBufferLenIn, ref int DriverBufferLenOut);
|
||||
[DllImport("odbc32.dll")]
|
||||
public static extern int SQLAllocEnv (ref int EnvHandle);
|
||||
public static List<SaDbDfnOdbcDataSource> GetOdbcDatasources ()
|
||||
public static extern int SQLAllocEnv(ref int EnvHandle);
|
||||
public static List<SaDbDfnOdbcDataSource> GetOdbcDatasources()
|
||||
{
|
||||
List<SaDbDfnOdbcDataSource> dataSources = new List<SaDbDfnOdbcDataSource>();
|
||||
int envHandle=0;
|
||||
int envHandle = 0;
|
||||
const int SQL_FETCH_NEXT = 1;
|
||||
const int SQL_FETCH_FIRST_SYSTEM = 32;
|
||||
|
||||
@@ -147,7 +151,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
//-------------------------------------------------------------------
|
||||
// Q u e r y D a t a b a s e
|
||||
//-------------------------------------------------------------------
|
||||
public String GetSelectQueryPrefix ()
|
||||
public String GetSelectQueryPrefix()
|
||||
{
|
||||
// Query prefix.
|
||||
switch (SelectLockMode)
|
||||
@@ -180,16 +184,16 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public abstract IDbDataTable ExecuteQuery (String query);
|
||||
public abstract int ExecuteNonQuery (String query);
|
||||
public abstract int ExecuteInsert (String tableName, List<StringPair> columnNameValues);
|
||||
public abstract int ExecuteUpdate (String tableName, List<StringPair> columnNameValues, String filter);
|
||||
public abstract int ExecuteDelete (String tableName, String filter);
|
||||
public abstract IDbDataTable ExecuteQuery(String query);
|
||||
public abstract int ExecuteNonQuery(String query);
|
||||
public abstract int ExecuteInsert(String tableName, List<StringPair> columnNameValues);
|
||||
public abstract int ExecuteUpdate(String tableName, List<StringPair> columnNameValues, String filter);
|
||||
public abstract int ExecuteDelete(String tableName, String filter);
|
||||
/// <summary>
|
||||
/// Add value pair - used to build value lists for insert and update.
|
||||
/// <para>Caters for delimiting text values and uses 'NULL' for empty text values.</para>
|
||||
/// </summary>
|
||||
public static void AddValuePair (List<StringPair> columnNameValues, String columnName, String value, bool delimitString = false)
|
||||
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, String value, bool delimitString = false)
|
||||
{
|
||||
if (delimitString)
|
||||
{
|
||||
@@ -200,42 +204,42 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
columnNameValues.Add(columnName, value);
|
||||
}
|
||||
/// <summary>Add SysId value pair - used to build value lists for insert and update.</summary>
|
||||
public static void AddValuePair (List<StringPair> columnNameValues, String columnName, SysId value)
|
||||
public static void AddValuePair(List<StringPair> columnNameValues, String columnName, SysId value)
|
||||
{
|
||||
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, long value)
|
||||
{
|
||||
columnNameValues.Add(columnName, value.ToString());
|
||||
}
|
||||
/// <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());
|
||||
}
|
||||
/// <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);
|
||||
}
|
||||
// Specific queries.
|
||||
public abstract long GetRowCount (String tableName, String filter);
|
||||
public abstract DataValue GetRowValue (String tableName, String columnName, String filter);
|
||||
public abstract DataValue GetRowValue (String tableName, String columnName, String filter, DbGetValueType getValueType);
|
||||
public abstract long GetRowCount(String tableName, String filter);
|
||||
public abstract DataValue GetRowValue(String tableName, String columnName, String filter);
|
||||
public abstract DataValue GetRowValue(String tableName, String columnName, String filter, DbGetValueType getValueType);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D a t a b a s e S c h e m a
|
||||
//-------------------------------------------------------------------
|
||||
public abstract List<String> GetTableNames (bool refresh = false);
|
||||
public abstract List<DbDfnTable> GetTableDfns (bool refresh = false);
|
||||
public abstract DbDfnTable GetTableDfn (String name, bool refresh = false);
|
||||
public bool TableExists (String tableName)
|
||||
public abstract List<String> GetTableNames(bool refresh = false);
|
||||
public abstract List<DbDfnTable> GetTableDfns(bool refresh = false);
|
||||
public abstract DbDfnTable GetTableDfn(String name, bool refresh = false);
|
||||
public bool TableExists(String tableName)
|
||||
{
|
||||
if (StringUtil.IsEmpty(tableName)) return false;
|
||||
return GetTableNames().Exists(table => table.EqualsCI(tableName));
|
||||
}
|
||||
public bool ColumnExists (String tableName, String columnName)
|
||||
public bool ColumnExists(String tableName, String columnName)
|
||||
{
|
||||
if (StringUtil.IsEmpty(tableName) || StringUtil.IsEmpty(columnName)) return false;
|
||||
DbDfnTable table = GetTableDfn(tableName);
|
||||
@@ -243,7 +247,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
return table.HasColumnByName(columnName);
|
||||
return false;
|
||||
}
|
||||
public bool IndexExists (String tableName, String indexName)
|
||||
public bool IndexExists(String tableName, String indexName)
|
||||
{
|
||||
if (StringUtil.IsEmpty(tableName) || StringUtil.IsEmpty(indexName)) return false;
|
||||
DbDfnTable table = GetTableDfn(tableName);
|
||||
@@ -263,7 +267,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
// Logging.
|
||||
public static SaMessageLevel LoggingLevel { get; set; } = SaMessageLevel.None;
|
||||
public static String LoggingPrefix { get; set; } = " ~~~ ";
|
||||
protected static void Log (String fn, String message, SaMessageLevel level = SaMessageLevel.Debug)
|
||||
protected static void Log(String fn, String message, SaMessageLevel level = SaMessageLevel.Debug)
|
||||
{
|
||||
if ((int)level > (int)LoggingLevel) return;
|
||||
SaLogger.Log((fn + "\n\t" + message).Trim(), level);
|
||||
|
||||
@@ -5,7 +5,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -173,10 +173,9 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
// Query records.
|
||||
public override IDbDataTable ExecuteQuery(String query)
|
||||
{
|
||||
String fn = GetType().Name + ".ExecuteQuery";
|
||||
ClearErrorState();
|
||||
DataTable dataTable = null;
|
||||
Log(fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
Log(SysUtil.Fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
try
|
||||
{
|
||||
using (DbConnection dbConnection = CreateConnection())
|
||||
@@ -191,7 +190,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
return new DbDataTable(dataTable);
|
||||
@@ -200,9 +199,8 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
/// <summary>Execute a non-query statement and return the row count.</summary>
|
||||
public override int ExecuteNonQuery(string query)
|
||||
{
|
||||
String fn = GetType().Name + ".ExecuteNonQuery";
|
||||
ClearErrorState();
|
||||
Log(fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
Log(SysUtil.Fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
using (var dbConnection = CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
@@ -215,7 +213,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
}
|
||||
@@ -225,13 +223,12 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
/// <summary>Compile and execute an insert statement and return the row count.</summary>
|
||||
public override int ExecuteInsert(String tableName, List<StringPair> columnNameValues)
|
||||
{
|
||||
String fn = GetType().Name + ".ExecuteInsert";
|
||||
ClearErrorState();
|
||||
String query =
|
||||
"INSERT INTO " + tableName + " " +
|
||||
"(" + columnNameValues.GetValues(StringPair.Value.Value1).Concat(", ") + ") " +
|
||||
"VALUES (" + columnNameValues.GetValues(StringPair.Value.Value2).Concat(", ") + ")";
|
||||
Log(fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
Log(SysUtil.Fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
using (var dbConnection = CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
@@ -244,7 +241,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
}
|
||||
@@ -254,14 +251,13 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
/// <summary>Compile and execute an update statement and return the row count.</summary>
|
||||
public override int ExecuteUpdate(String tableName, List<StringPair> columnNameValues, String filter)
|
||||
{
|
||||
String fn = GetType().Name + ".ExecuteUpdate";
|
||||
ClearErrorState();
|
||||
String query =
|
||||
"UPDATE " + tableName + " " +
|
||||
"SET " + columnNameValues.Concat("=").Concat(", ");
|
||||
if (!StringUtil.IsEmpty(filter))
|
||||
query += (String)" WHERE " + filter;
|
||||
Log(fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
Log(SysUtil.Fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
using (var dbConnection = CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
@@ -274,7 +270,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
}
|
||||
@@ -284,12 +280,11 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
/// <summary>Compile and execute a delete statement and return the row count.</summary>
|
||||
public override int ExecuteDelete(String tableName, String filter)
|
||||
{
|
||||
String fn = GetType().Name + ".ExecuteDelete";
|
||||
ClearErrorState();
|
||||
String query = "DELETE FROM " + tableName;
|
||||
if (!StringUtil.IsEmpty(filter))
|
||||
query += " WHERE " + filter;
|
||||
Log(fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
Log(SysUtil.Fn, "Query: " + query, SaMessageLevel.Debug);
|
||||
using (var dbConnection = CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
@@ -302,7 +297,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
}
|
||||
@@ -449,8 +444,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
{
|
||||
if (StringUtil.IsEmpty(tableNameRestriction) && tables.Count > 0) return;
|
||||
if (!StringUtil.IsEmpty(tableNameRestriction) && tables.Exists(item => item.Name.Equals(tableNameRestriction))) return;
|
||||
String fn = GetType().Name + ".PopulateTableNames";
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug(fn + (!StringUtil.IsEmpty(tableNameRestriction) ? " Table: " + tableNameRestriction : " "));
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug(SysUtil.Fn + (!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))
|
||||
{
|
||||
@@ -490,7 +484,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
else if (colName.EqualsCI("REMARKS"))
|
||||
remarks = value;
|
||||
else
|
||||
SaLogger.Warn(fn + " Unrecognised column name: '" + colName + "'");
|
||||
SaLogger.Warn(SysUtil.Fn + " Unrecognised column name: '" + colName + "'");
|
||||
}
|
||||
// TODO Why is Type sometimes "BASE TABLE"?
|
||||
if (!StringUtil.IsEmpty(tableName) && (type.EqualsCI("Table") || type.EqualsCI("Base Table")) && (!schema.EqualsCI("sys") || !tableName.Left(9).EqualsCI("trace_xe_")))
|
||||
@@ -513,8 +507,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
//-------------------------------------------------------------------
|
||||
private void PopulateTableColumns(DbConnection dbConnection, DbDfnTable table)
|
||||
{
|
||||
String fn = GetType().Name + ".PopulateTableColumns";
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug(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))
|
||||
@@ -718,7 +711,6 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
//-------------------------------------------------------------------
|
||||
private void PopulateTableIndices(DbConnection dbConnection, DbDfnTable table)
|
||||
{
|
||||
String fn = GetType().Name + ".PopulateTableIndices";
|
||||
String[] restrictions = new String[] { null, table.Schema, table.Name }; // database, owner, table name
|
||||
using (DataTable columnSchema = dbConnection.GetSchema(OdbcMetaDataCollectionNames.Indexes, restrictions))
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -41,10 +41,6 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public interface IProcessNotifier : ISacsProcessNotifier
|
||||
{
|
||||
void OnSchemaComparisonItemAdded(SaDbProcess_CompareDatabaseSchemas proc);
|
||||
}
|
||||
public class SchemaComparisonItem
|
||||
{
|
||||
internal SchemaComparisonItem(String tableName, String columnName, int columnPosition, String indexName, String comment)
|
||||
@@ -68,7 +64,6 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config;
|
||||
private IProcessNotifier processNotifier = null;
|
||||
private readonly List<SchemaComparisonItem> schemaComparisonItems = new List<SchemaComparisonItem>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -88,13 +83,19 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override string ProcessDescription { get; } = "Database Schema Comparison";
|
||||
public new IProcessNotifier ProcessNotifier
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Events.
|
||||
|
||||
// Processing Completed.
|
||||
public class SchemaComparisonItemAddedEventArgs : EventArgs { }
|
||||
public event EventHandler<SchemaComparisonItemAddedEventArgs> OnSchemaComparisonItemAdded;
|
||||
protected virtual void InvokeSchemaComparisonItemAdded()
|
||||
{
|
||||
get { return processNotifier; }
|
||||
set
|
||||
if (OnSchemaComparisonItemAdded != null)
|
||||
{
|
||||
processNotifier = value;
|
||||
base.ProcessNotifier = value;
|
||||
SchemaComparisonItemAddedEventArgs args = new SchemaComparisonItemAddedEventArgs();
|
||||
OnSchemaComparisonItemAdded(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +113,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
protected override bool Run()
|
||||
{
|
||||
schemaComparisonItems.Clear();
|
||||
if (config.SourceDatabase == null && config.SourceTables == null) return SetProcessError("Source database must be supplied.");
|
||||
if (config.SourceDatabase == null && config.SourceTables == null) return AddErrorMessage("Source database must be supplied.");
|
||||
|
||||
CompareTables();
|
||||
return OK;
|
||||
@@ -393,7 +394,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
private void AddSchemaComparisonItem(String tableName, String columnName, int position, String indexName, String comment)
|
||||
{
|
||||
schemaComparisonItems.Add(new SchemaComparisonItem(tableName, columnName, position, indexName, comment));
|
||||
if (ProcessNotifier != null) ProcessNotifier.OnSchemaComparisonItemAdded(this);
|
||||
InvokeSchemaComparisonItemAdded();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
}
|
||||
public new class Config : SaProcess_Base.Config
|
||||
{
|
||||
public Config ()
|
||||
public Config()
|
||||
{
|
||||
}
|
||||
public SourceDefinitionType SourceDefinitionType { get; set; }
|
||||
@@ -43,9 +43,6 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public interface IProcessNotifier : ISacsProcessNotifier
|
||||
{
|
||||
}
|
||||
private class Statistics
|
||||
{
|
||||
}
|
||||
@@ -53,17 +50,16 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config;
|
||||
private IProcessNotifier processNotifier;
|
||||
private readonly List<DbDfnTable> tableDfns = new List<DbDfnTable>();
|
||||
private Statistics stats;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaDbProcess_ConvertDbDefinition (Config config) : base(config)
|
||||
public SaDbProcess_ConvertDbDefinition(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
protected override void Dispose (bool disposing)
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
@@ -74,15 +70,6 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override string ProcessDescription { get; } = "Database Definition Convertor";
|
||||
public new IProcessNotifier ProcessNotifier
|
||||
{
|
||||
get { return processNotifier; }
|
||||
set
|
||||
{
|
||||
processNotifier = value;
|
||||
base.ProcessNotifier = value;
|
||||
}
|
||||
}
|
||||
/// <summary>Processing statistics.</summary>
|
||||
public override List<StringPair> ProcessingStatistics
|
||||
{
|
||||
@@ -102,7 +89,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
//-------------------------------------------------------------------
|
||||
// P r o c e s s i n g
|
||||
//-------------------------------------------------------------------
|
||||
protected override bool Run ()
|
||||
protected override bool Run()
|
||||
{
|
||||
// Initialise process.
|
||||
tableDfns.Clear();
|
||||
@@ -115,32 +102,32 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
|
||||
return OK;
|
||||
}
|
||||
protected bool ValidateConfiguration ()
|
||||
protected bool ValidateConfiguration()
|
||||
{
|
||||
// Source file.
|
||||
if (config.SourceDefinitionType <= 0)
|
||||
return SetProcessError("Source definition type must be specified.");
|
||||
return AddErrorMessage("Source definition type must be specified.");
|
||||
if (StringUtil.IsEmpty(config.SourceDefinitionFilePath))
|
||||
return SetProcessError("Source definition file must be specified.");
|
||||
return AddErrorMessage("Source definition file must be specified.");
|
||||
if (!FileUtil.IsFile(config.SourceDefinitionFilePath))
|
||||
return SetProcessError("Source definition file not found.");
|
||||
return AddErrorMessage("Source definition file not found.");
|
||||
|
||||
// Target file.
|
||||
if (config.TargetDefinitionType <= 0)
|
||||
return SetProcessError("Target definition type must be specified.");
|
||||
return AddErrorMessage("Target definition type must be specified.");
|
||||
if (StringUtil.IsEmpty(config.TargetDefinitionFilePath))
|
||||
return SetProcessError("Target definition file must be specified.");
|
||||
return AddErrorMessage("Target definition file must be specified.");
|
||||
if (!DirectoryUtil.DirectoryExists(DirectoryUtil.GetDirectoryName(config.TargetDefinitionFilePath)))
|
||||
return SetProcessError("Target folder not found.");
|
||||
return AddErrorMessage("Target folder not found.");
|
||||
|
||||
if (config.SourceDefinitionFilePath.EqualsCI(config.TargetDefinitionFilePath))
|
||||
return SetProcessError("Target file must not be the same as the source file.");
|
||||
return AddErrorMessage("Target file must not be the same as the source file.");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private bool ConvertCppDatabaseDefinition ()
|
||||
private bool ConvertCppDatabaseDefinition()
|
||||
{
|
||||
if (!OK) return false;
|
||||
|
||||
@@ -169,7 +156,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
}
|
||||
private class SourceDefinition_Params
|
||||
{
|
||||
protected SourceDefinition_Params () { }
|
||||
protected SourceDefinition_Params() { }
|
||||
public int LineNumber { get; set; } = -1;
|
||||
public int TableIdx { get; set; } = -1;
|
||||
public int ColumnIdx { get; set; } = -1;
|
||||
@@ -186,7 +173,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
public Dictionary<StringPair, ColumnData> ColumnMap { get; } = new Dictionary<StringPair, ColumnData>();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
private bool ExtractDatabaseDefinition ()
|
||||
private bool ExtractDatabaseDefinition()
|
||||
{
|
||||
if (!OK) return false;
|
||||
|
||||
@@ -245,7 +232,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Warn(ExceptionUtil.GetLogMessage(exc)); SetProcessError(ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
catch (Exception exc) { SaLogger.Warn(ExceptionUtil.GetLogMessage(exc)); AddErrorMessage(ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -253,7 +240,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
//-------------------------------------------------------------------
|
||||
// C + + C o d e S o u r c e
|
||||
//-------------------------------------------------------------------
|
||||
private readonly Dictionary<int,String> cppColumnDataTypes = new Dictionary<int, string>()
|
||||
private readonly Dictionary<int, String> cppColumnDataTypes = new Dictionary<int, string>()
|
||||
{
|
||||
{ 1, "VarChar" },
|
||||
{ -7, "Bit" },
|
||||
@@ -265,7 +252,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
{ 8, "Double" },
|
||||
{ 93, "DateTime" }
|
||||
};
|
||||
private bool ExtractDatabaseDefinitionLine_CppCode (SourceDefinition_Params_CppCode sourceDfnParams, String line)
|
||||
private bool ExtractDatabaseDefinitionLine_CppCode(SourceDefinition_Params_CppCode sourceDfnParams, String line)
|
||||
{
|
||||
if (!OK) return false;
|
||||
|
||||
@@ -276,7 +263,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
{
|
||||
// Table enum start.
|
||||
if (sourceDfnParams.TablesEnumFound)
|
||||
return SetProcessError("Found multiple table enums at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
return AddErrorMessage("Found multiple table enums at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
sourceDfnParams.TablesEnumFound = true;
|
||||
sourceDfnParams.InTablesEnum = true;
|
||||
return OK;
|
||||
@@ -289,13 +276,13 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
else if (!line.ContainsCI("eSaDbTblUnknown"))
|
||||
{
|
||||
if (!line.ContainsCI("eSaDbTbl"))
|
||||
return SetProcessError("Invalid table definition on line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
return AddErrorMessage("Invalid table definition on line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
// Extract table name.
|
||||
String tableName = line.ReplaceAll("eSaDbTbl","").ReplaceAll(",","");
|
||||
String tableName = line.ReplaceAll("eSaDbTbl", "").ReplaceAll(",", "");
|
||||
if (StringUtil.IsEmpty(tableName))
|
||||
return SetProcessError("Blank table name on line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
return AddErrorMessage("Blank table name on line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (tableDfns.Exists(item => item.Name.EqualsCI(tableName)))
|
||||
return SetProcessError("Duplicate table name on line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
return AddErrorMessage("Duplicate table name on line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
// Add this table to the list.
|
||||
sourceDfnParams.TableIdx++;
|
||||
//SaLogger.Debug("Table #" + sourceDfnParams.TableIdx + ": " + tableName);
|
||||
@@ -310,7 +297,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
{
|
||||
// Column enum start.
|
||||
if (sourceDfnParams.ColumnsEnumFound)
|
||||
return SetProcessError("Found multiple columns enums at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
return AddErrorMessage("Found multiple columns enums at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
sourceDfnParams.ColumnsEnumFound = true;
|
||||
sourceDfnParams.InColumnsEnum = true;
|
||||
return OK;
|
||||
@@ -323,7 +310,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
else if (!line.ContainsCI("eSaDbColUnknown"))
|
||||
{
|
||||
if (!line.ContainsCI("eSaDbCol"))
|
||||
return SetProcessError("Invalid column definition on line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
return AddErrorMessage("Invalid column definition on line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
// Column definitions:
|
||||
// eSaDbColUnknown = -1,
|
||||
// #define eSaDbColVendorType_ListID (eSaDbColumn)4101
|
||||
@@ -345,7 +332,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
// Split table and column names on Underscore.
|
||||
String[] tableColumnNameParts = tableColumnName.Split('_');
|
||||
if (tableColumnNameParts.Length != 2)
|
||||
return SetProcessError("Invalid column definition on line (missing underscore?) " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
return AddErrorMessage("Invalid column definition on line (missing underscore?) " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
sourceDfnParams.ColumnIdx++;
|
||||
String tableName = tableColumnNameParts[0];
|
||||
String columnName = tableColumnNameParts[1];
|
||||
@@ -360,7 +347,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
{
|
||||
// Column definitions start.
|
||||
if (sourceDfnParams.ColumnsDfnsFound)
|
||||
return SetProcessError("Found multiple column definitions at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
return AddErrorMessage("Found multiple column definitions at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
sourceDfnParams.ColumnsDfnsFound = true;
|
||||
sourceDfnParams.InColumnsDfns = true;
|
||||
sourceDfnParams.ColumnIdx = -1;
|
||||
@@ -388,40 +375,40 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
// eTime = 93 SQL_C_TYPE_TIMESTAMP
|
||||
foreach (String columnDfnDataRaw in line.Split(new String[] { "}," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
String columnDfnData = columnDfnDataRaw.ReplaceAll("{","").TrimAll();
|
||||
String columnDfnData = columnDfnDataRaw.ReplaceAll("{", "").TrimAll();
|
||||
//SaLogger.Debug("Column dfn: " + columnDfnData);
|
||||
String[] columnDfnParts = columnDfnData.Split(',');
|
||||
if (columnDfnParts.Length != 4) return SetProcessError("Invalid column definition (expecting 4 parts) at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (columnDfnParts.Length != 4) return AddErrorMessage("Invalid column definition (expecting 4 parts) at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
String tableIdxRaw = columnDfnParts[0].TrimAll();
|
||||
int tableIdx = StringUtil.ToInt(tableIdxRaw);
|
||||
String columnName = columnDfnParts[1].TrimAll().ReplaceAll("\"","");
|
||||
String columnName = columnDfnParts[1].TrimAll().ReplaceAll("\"", "");
|
||||
String dataTypeRaw = columnDfnParts[2].TrimAll();
|
||||
int dataType = StringUtil.ToInt(dataTypeRaw);
|
||||
String columnLengthRaw = columnDfnParts[3].TrimAll();
|
||||
int columnLength = StringUtil.ToInt(columnLengthRaw);
|
||||
if (!tableIdxRaw.IsNumeric()) return SetProcessError("Invalid table index in column definition (" + tableIdxRaw + ") at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (StringUtil.IsEmpty(columnName)) return SetProcessError("Blank name in column definition at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (!dataTypeRaw.IsNumeric(true) || !cppColumnDataTypes.ContainsKey(dataType)) return SetProcessError("Invalid data type in column definition (" + dataTypeRaw + ") at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (!columnLengthRaw.IsNumeric()) return SetProcessError("Invalid column length in column definition (" + columnLengthRaw + ") at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (!tableIdxRaw.IsNumeric()) return AddErrorMessage("Invalid table index in column definition (" + tableIdxRaw + ") at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (StringUtil.IsEmpty(columnName)) return AddErrorMessage("Blank name in column definition at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (!dataTypeRaw.IsNumeric(true) || !cppColumnDataTypes.ContainsKey(dataType)) return AddErrorMessage("Invalid data type in column definition (" + dataTypeRaw + ") at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (!columnLengthRaw.IsNumeric()) return AddErrorMessage("Invalid column length in column definition (" + columnLengthRaw + ") at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
// Table definition.
|
||||
String tableName = sourceDfnParams.TableMap.Values.ToList().Find(item => item.TableIdx == tableIdx)?.TableName ?? "";
|
||||
if (StringUtil.IsEmpty(tableName)) return SetProcessError("Unable to identify table name for Table idx " + tableIdx + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (StringUtil.IsEmpty(tableName)) return AddErrorMessage("Unable to identify table name for Table idx " + tableIdx + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
DbDfnTable tableDfn = tableDfns.GetTableByName(tableName);
|
||||
if (tableDfn == null) return SetProcessError("Unable to retrieve table definition for Table name " + tableName + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (tableDfn == null) return AddErrorMessage("Unable to retrieve table definition for Table name " + tableName + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
// Column data.
|
||||
sourceDfnParams.ColumnIdx++;
|
||||
ColumnData columnData = sourceDfnParams.ColumnMap.Values.ToList().Find(item => item.TableName.EqualsCI(tableName) && item.ColumnIdx == sourceDfnParams.ColumnIdx);
|
||||
if (columnData == null) return SetProcessError("Unable to column data for table " + tableName + " and column " + columnName + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (columnData.ColumnName.EqualsCI(columnName)) return SetProcessError("Inconsistent column name for table " + tableName + " and column " + columnName + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (columnData == null) return AddErrorMessage("Unable to column data for table " + tableName + " and column " + columnName + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (columnData.ColumnName.EqualsCI(columnName)) return AddErrorMessage("Inconsistent column name for table " + tableName + " and column " + columnName + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
// Column definition.
|
||||
DbDfnColumn columnDfn = new DbDfnColumn()
|
||||
{
|
||||
Table = tableName,
|
||||
Name = columnName,
|
||||
DataType = EnumUtil.ParseEnum(cppColumnDataTypes.GetValue(dataType,""),DbColumnDataType.Unknown),
|
||||
DataType = EnumUtil.ParseEnum(cppColumnDataTypes.GetValue(dataType, ""), DbColumnDataType.Unknown),
|
||||
Size = columnLength
|
||||
};
|
||||
if (columnDfn.DataType < 0) return SetProcessError("Invalid data type for table " + tableName + " and column " + columnName + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
if (columnDfn.DataType < 0) return AddErrorMessage("Invalid data type for table " + tableName + " and column " + columnName + " at line " + sourceDfnParams.LineNumber + ": " + line + ".");
|
||||
tableDfn.AddColumn(columnDfn);
|
||||
}
|
||||
return OK;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
//-------------------------------------------------------------------
|
||||
public List<DbDfnTable> ConvertXmlToTables(String xmlSchemaData)
|
||||
{
|
||||
ClearProcessError();
|
||||
ClearProcessMessages();
|
||||
String fn = GetType().Name + ".ConvertXmlToTables";
|
||||
Dictionary<String, DbDfnTable> tables = new Dictionary<String, DbDfnTable>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace Sarand.Net.Standard.Dbas.Proc
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetProcessError(exc.GetErrorStateMessage());
|
||||
AddErrorMessage(exc.GetErrorStateMessage());
|
||||
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>Sarand.Net.Standard</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||
<PackageReference Include="System.Data.Odbc" Version="5.0.0" />
|
||||
<PackageReference Include="System.Data.Odbc" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user