BusinessMgr 3.0.0.1

This commit is contained in:
Andy Howard
2025-02-08 16:41:25 +00:00
parent 1692179120
commit c84980672b
101 changed files with 1397 additions and 907 deletions
@@ -24,16 +24,16 @@ namespace Sarand.Net.Standard.Base.Bus
//-------------------------------------------------------------------
// Static initialisation.
static SaErrorStateItem ()
static SaErrorStateItem()
{
}
//-------------------------------------------------------------------
// Construction.
protected SaErrorStateItem ()
protected SaErrorStateItem()
{
}
protected override void Dispose (bool disposing)
protected override void Dispose(bool disposing)
{
if (disposing)
{
@@ -69,21 +69,21 @@ namespace Sarand.Net.Standard.Base.Bus
/// <para>Blank message does not set the error state - leaves previous state intact.</para>
/// <para>Return value is fale unless the message is blank.</para>
/// </summary>
public bool SetErrorState (String message)
public bool SetErrorState(String message)
{
if (StringUtil.IsEmpty(message)) return true;
this.errorState = new SacsErrorState(message);
return false;
}
/// <summary>Clear the error state.</summary>
public void ClearErrorState ()
public void ClearErrorState()
{
errorState = null;
}
//-------------------------------------------------------------------
// Error state population.
protected bool SetErrorState (ErrorMessage errorMessage)
protected bool SetErrorState(ErrorMessage errorMessage)
{
String message = errorMessage.ToString();
switch (errorMessage)
@@ -274,6 +274,17 @@ namespace Sarand.Net.Standard.Base.Bus
}
}
}
protected void CheckChanged(Guid oldValue, Guid newValue)
{
CheckChangedNullable(oldValue, newValue);
}
protected void CheckChangedNullable(Guid? oldValue, Guid? newValue)
{
if (Changed) return;
if ((oldValue == null) != (newValue == null)) Changed = true;
else if (oldValue != null && newValue != null)
Changed = !oldValue.Equals(newValue);
}
protected void CheckChanged(byte[] oldValue, byte[] newValue)
{
if (Changed) return;
+6 -1
View File
@@ -16,8 +16,13 @@ namespace Sarand.Net.Standard.Base.Bus
//-------------------------------------------------------------------
// Data members.
public const String Msg_DatabaseNotAvailable = "database is not available";
public const String Msg_DatabaseNotAvailable = "Database is not available";
public const String Msg_DatabaseQueryException = "Database query exception";
public const String Msg_ItemNotSpecified = "Item not specified";
public const String Msg_ItemIdNotSpecified = "Item Id must be specified";
public const String Msg_ItemTypeNotSpecified = "Item type must be specified";
public const String Msg_InvalidItemSpecified = "Invalid item specified";
public const String Msg_MultipleItemsFound = "Multiple items found";
//-------------------------------------------------------------------
// Static initialisation.
+10
View File
@@ -180,12 +180,22 @@ namespace Sarand.Net.Standard.Base.Bus
//-------------------------------------------------------------------
// Populate list.
/// <summary>
/// Add the Id to the list.
/// <para>- Option to ignore invalid Id. [default: true]</para>
/// <para>- Option to ignore duplicate Id. [default: true]</para>
/// </summary>
public static void AddId(this ICollection<SysId> values, SysId sysId, bool ignoreInvalid = true, bool ignoreDuplicates = true)
{
if (ignoreInvalid && !SysId.IsValid(sysId)) return;
if (ignoreDuplicates && values.Contains(sysId)) return;
values.Add(sysId);
}
/// <summary>
/// Add the Ids to the list.
/// <para>- Option to ignore invalid Ids. [default: true]</para>
/// <para>- Option to ignore duplicate Ids. [default: true]</para>
/// </summary>
public static void AddIds(this ICollection<SysId> values, IEnumerable<SysId> sysIds, bool ignoreInvalid = true, bool ignoreDuplicates = true)
{
foreach (SysId id in sysIds)
@@ -1,3 +1,4 @@
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using System;
@@ -5,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:33
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:21
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Base.CodeTypes
{
@@ -61,7 +62,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
// Data members.
private static readonly int tableCount = 2;
private static readonly int columnCount = 30;
private static ulong maxTextLen = 0;
public static ulong MaxTextLen { get; private set; }
//-------------------------------------------------------------------
// Retrieve Table details (eg. name: 'Company').
@@ -69,14 +70,31 @@ namespace Sarand.Net.Standard.Base.CodeTypes
{
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];
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;
}
//-------------------------------------------------------------------
// Identify the table that corresponds with the specified column.
@@ -126,8 +144,15 @@ namespace Sarand.Net.Standard.Base.CodeTypes
}
public static String DelimitReservedWord (String word)
{
if (!IsReservedWord(word)) return word;
switch (reservedWordDelim)
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;
@@ -158,7 +183,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
}
public static void SetMaxTextLen (ulong maxTextLen)
{
SaCodeTypeDbDfn.maxTextLen = maxTextLen;
SaCodeTypeDbDfn.MaxTextLen = maxTextLen;
}
public static bool IsColFmtText (ColumnIdx column)
{
@@ -173,7 +198,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
if (columns[columnIdx].DataType == DbColumnDataType.VarChar)
{
ulong textLen = columns[columnIdx].DataLen;
if (maxTextLen > 0 && textLen > maxTextLen) textLen = maxTextLen;
if (MaxTextLen > 0 && textLen > MaxTextLen) textLen = MaxTextLen;
return textLen;
}
return 0;
@@ -204,15 +229,25 @@ namespace Sarand.Net.Standard.Base.CodeTypes
//-------------------------------------------------------------------
// Table definitions.
private static readonly String[] tables =
private class TableDfn
{
"SaCode",
"SaCodeType",
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 =
{
new TableDfn("dbo","SaCode"),
new TableDfn("dbo","SaCodeType"),
};
//-------------------------------------------------------------------
// Table column definitions.
internal class ColumnDfn
private class ColumnDfn
{
internal TableIdx TableIdx { get; set; }
internal String Name { get; set; }
@@ -230,8 +265,6 @@ namespace Sarand.Net.Standard.Base.CodeTypes
this.DataLen = dataLen;
}
}
//-------------------------------------------------------------------
private static readonly ColumnDfn[] columns =
{
new ColumnDfn(1,"Id",4,4,false,10),
@@ -268,7 +301,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
//-------------------------------------------------------------------
// Reserved words.
private static readonly List<String> reservedWords = new List<String>()
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
"ADD",
"ALL",
+18 -1
View File
@@ -10,7 +10,7 @@ namespace Sarand.Net.Standard.Base.Core
{
//-------------------------------------------------------------------
// Definitions.
public enum DataType { Unknown = 0, Bool, TriState, Long, Double, Decimal, String, Date, Time, DateTime, Blob };
public enum DataType { Unknown = 0, Bool, TriState, Long, Double, Decimal, String, Date, Time, DateTime, Guid, Blob };
public enum TriStateType { Unknown = 0, Red, Amber, Green, Blue, Purple, Yellow };
//-------------------------------------------------------------------
@@ -74,6 +74,11 @@ namespace Sarand.Net.Standard.Base.Core
break;
}
}
public DataValue(Guid value)
{
this.value = value;
this.dataType = DataType.Guid;
}
public DataValue(Byte[] value)
{
this.value = value;
@@ -101,6 +106,7 @@ namespace Sarand.Net.Standard.Base.Core
case DataType.Date: return "Date";
case DataType.Time: return "Time";
case DataType.DateTime: return "DateTime";
case DataType.Guid: return "Guid";
case DataType.Blob: return "Blob";
}
return "<Unknown>";
@@ -129,6 +135,10 @@ namespace Sarand.Net.Standard.Base.Core
{
return (dataType == DataType.Date || dataType == DataType.Time || dataType == DataType.DateTime);
}
public bool IsGuid()
{
return (dataType == DataType.Guid);
}
public bool IsBlob()
{
return (dataType == DataType.Blob);
@@ -281,6 +291,13 @@ namespace Sarand.Net.Standard.Base.Core
if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Incorrect data type: {dataType.ToString()}.");
return DateTime.MinValue;
}
public Guid AsGuid()
{
if (dataType == DataType.Guid) return (Guid)value;
if (dataType == DataType.Unknown) return default(Guid);
if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Incorrect data type: {dataType.ToString()}.");
return default(Guid);
}
public Byte[] AsBlob()
{
if (dataType == DataType.Blob) return (Byte[])value;
+12 -7
View File
@@ -7,11 +7,11 @@ namespace Sarand.Net.Standard.Base.Core
/// <summary>State Item interface.</summary>
public interface ISacsStateItem
{
bool HasErrorState ();
bool HasErrorState();
SacsErrorState ErrorState { get; }
String ErrorStateMessage { get; }
bool SetErrorState (String message);
void ClearErrorState ();
bool SetErrorState(String message);
void ClearErrorState();
}
//=======================================================================
@@ -25,12 +25,17 @@ namespace Sarand.Net.Standard.Base.Core
//-------------------------------------------------------------------
// Protected construction - use derived classes.
protected SacsStateItem () { }
protected SacsStateItem() { }
//-------------------------------------------------------------------
// Poperties.
/// <summary>OK - No error state message.</summary>
public bool OK { get { return !HasErrorState(); } }
// Error state.
public SacsErrorState ErrorState { get; private set; }
public bool HasErrorState ()
public bool HasErrorState()
{
return ErrorState != null;
}
@@ -39,14 +44,14 @@ namespace Sarand.Net.Standard.Base.Core
get { return (ErrorState != null ? ErrorState.Message : String.Empty); }
}
// Update properties.
public virtual bool SetErrorState (String message)
public virtual bool SetErrorState(String message)
{
if (StringUtil.IsEmpty(StringUtil.EmptyOnNull(message).Trim()))
throw new NotSupportedException($"{SysUtil.Fn} Blank error message.");
this.ErrorState = new SacsErrorState(message);
return false;
}
public void ClearErrorState ()
public void ClearErrorState()
{
ErrorState = null;
}
+10 -10
View File
@@ -17,14 +17,14 @@ namespace Sarand.Net.Standard.Base.Core
//-------------------------------------------------------------------
// Construction.
public StringPair (String value1, String value2) :
public StringPair(String value1, String value2) :
base(StringUtil.EmptyOnNull(value1), StringUtil.EmptyOnNull(value2))
{
}
//-------------------------------------------------------------------
// Concatenation.
public String Concat (String delimiter, bool delimBlanks = true)
public String Concat(String delimiter, bool delimBlanks = true)
{
String value = StringUtil.EmptyOnNull(Item1);
if (!String.IsNullOrEmpty(Item2) || delimBlanks)
@@ -35,7 +35,7 @@ namespace Sarand.Net.Standard.Base.Core
//-------------------------------------------------------------------
// Operators.
public static implicit operator StringPair (String value1)
public static implicit operator StringPair(String value1)
{
return new StringPair(value1, String.Empty);
}
@@ -46,17 +46,17 @@ namespace Sarand.Net.Standard.Base.Core
public static class StringPairList
{
//-------------------------------------------------------------------
public static List<StringPair> CreateFrom (List<String> valuesToAdd, bool duplicateAsS2 = false)
public static List<StringPair> CreateFrom(IEnumerable<String> valuesToAdd, bool duplicateAsS2 = false)
{
List<StringPair> values = new List<StringPair>();
foreach (String valueToAdd in valuesToAdd)
values.Add(new StringPair(valueToAdd, (duplicateAsS2 ? valueToAdd : "")));
return values;
}
public static List<StringPair> CreateFrom (List<String> s1Values, List<String> s2Values)
public static List<StringPair> CreateFrom(List<String> s1Values, List<String> s2Values)
{
List<StringPair> values = new List<StringPair>();
for (int valueIdx = 0; valueIdx < (Math.Min(s1Values.Count,s2Values.Count)); valueIdx++)
for (int valueIdx = 0; valueIdx < (Math.Min(s1Values.Count, s2Values.Count)); valueIdx++)
{
values.Add(new StringPair(s1Values[valueIdx], s2Values[valueIdx]));
}
@@ -64,17 +64,17 @@ namespace Sarand.Net.Standard.Base.Core
}
//-------------------------------------------------------------------
public static void Add (this List<StringPair> values, String s1, String s2 = "")
public static void Add(this List<StringPair> values, String s1, String s2 = "")
{
values.Add(new StringPair(s1, s2));
}
public static void AddRange (this List<StringPair> values, List<String> valuesToAdd, bool duplicateAsS2 = false)
public static void AddRange(this List<StringPair> values, IEnumerable<String> valuesToAdd, bool duplicateAsS2 = false)
{
values.AddRange(CreateFrom(valuesToAdd, duplicateAsS2));
}
//-------------------------------------------------------------------
public static List<String> Concat (this List<StringPair> values, String delimiter, bool delimitBlanks = true)
public static List<String> Concat(this List<StringPair> values, String delimiter, bool delimitBlanks = true)
{
List<String> data = new List<string>();
foreach (var pair in values)
@@ -89,7 +89,7 @@ namespace Sarand.Net.Standard.Base.Core
}
//-------------------------------------------------------------------
public static List<String> GetValues (this List<StringPair> values, StringPair.Value valueType = StringPair.Value.Value1)
public static List<String> GetValues(this List<StringPair> values, StringPair.Value valueType = StringPair.Value.Value1)
{
List<String> data = new List<string>();
foreach (var pair in values)
+11 -5
View File
@@ -21,6 +21,7 @@ namespace Sarand.Net.Standard.Base.Dbas
Double, // SQL_C_DOUBLE,
Decimal, // SQL_DECIMAL?,
DateTime, // SQL_C_TYPE_TIMESTAMP
Guid,
Binary,
};
//[Serializable()]
@@ -126,6 +127,8 @@ namespace Sarand.Net.Standard.Base.Dbas
return "Decimal";
case DbColumnDataType.DateTime:
return "DateTime";
case DbColumnDataType.Guid:
return "Guid";
case DbColumnDataType.Binary:
return "Byte[]";
}
@@ -159,6 +162,8 @@ namespace Sarand.Net.Standard.Base.Dbas
return "0.0m";
case DbColumnDataType.DateTime:
return "DateTime.MinValue";
case DbColumnDataType.Guid:
return "default(Guid)";
case DbColumnDataType.Binary:
return "null";
}
@@ -183,6 +188,7 @@ namespace Sarand.Net.Standard.Base.Dbas
case DbColumnDataType.Double:
case DbColumnDataType.Decimal:
case DbColumnDataType.DateTime:
case DbColumnDataType.Guid:
return GetVariableType();
case DbColumnDataType.Binary:
return "ByteArray";
@@ -196,7 +202,7 @@ namespace Sarand.Net.Standard.Base.Dbas
public static class DbDfnColumnList
{
// List of column names.
public static List<String> GetNames(this List<DbDfnColumn> columns)
public static List<String> GetNames(this IEnumerable<DbDfnColumn> columns)
{
List<String> names = new List<String>();
foreach (var column in columns)
@@ -206,7 +212,7 @@ namespace Sarand.Net.Standard.Base.Dbas
return names;
}
// Identity column.
public static String GetIdentityColumnName(this List<DbDfnColumn> columns)
public static String GetIdentityColumnName(this IEnumerable<DbDfnColumn> columns)
{
List<String> names = new List<String>();
foreach (var column in columns)
@@ -216,7 +222,7 @@ namespace Sarand.Net.Standard.Base.Dbas
}
return String.Empty;
}
public static String GetIdentityColumnVariableTypeName(this List<DbDfnColumn> columns)
public static String GetIdentityColumnVariableTypeName(this IEnumerable<DbDfnColumn> columns)
{
List<String> names = new List<String>();
foreach (var column in columns)
@@ -228,7 +234,7 @@ namespace Sarand.Net.Standard.Base.Dbas
}
// Locate the column in the list:
public static DbDfnColumn GetColumnByPos(this List<DbDfnColumn> columns, short pos)
public static DbDfnColumn GetColumnByPos(this IEnumerable<DbDfnColumn> columns, short pos)
{
foreach (var column in columns)
{
@@ -237,7 +243,7 @@ namespace Sarand.Net.Standard.Base.Dbas
}
return null;
}
public static DbDfnColumn GetColumnByName(this List<DbDfnColumn> columns, String name)
public static DbDfnColumn GetColumnByName(this IEnumerable<DbDfnColumn> columns, String name)
{
foreach (var column in columns)
{
+15 -15
View File
@@ -12,10 +12,10 @@ namespace Sarand.Net.Standard.Base.Dbas
{
//-------------------------------------------------------------------
// Definitions.
public static readonly int SQL_TABLE_STAT = 0;
public static readonly int SQL_TABLE_STAT = 0;
public static readonly int SQL_INDEX_CLUSTERED = 1;
public static readonly int SQL_INDEX_HASHED = 2;
public static readonly int SQL_INDEX_OTHER = 3;
public static readonly int SQL_INDEX_HASHED = 2;
public static readonly int SQL_INDEX_OTHER = 3;
// SQL_INDEX_BTREE = ???;
// SQL_INDEX_CONTENT = ???;
@@ -25,8 +25,8 @@ namespace Sarand.Net.Standard.Base.Dbas
//-------------------------------------------------------------------
// Construction.
public DbDfnIndex () { }
public DbDfnIndex (String schema, String table, String name, bool unique)
public DbDfnIndex() { }
public DbDfnIndex(String schema, String table, String name, bool unique)
{
Schema = schema;
Table = table;
@@ -71,12 +71,12 @@ namespace Sarand.Net.Standard.Base.Dbas
columns.Clear(); columns.AddRange(value);
}
}
public void CearColumns ()
public void CearColumns()
{
lock (columns)
columns.Clear();
}
public void AddColumn (DbDfnIndexColumn column)
public void AddColumn(DbDfnIndexColumn column)
{
lock (columns)
columns.Add(column);
@@ -90,7 +90,7 @@ namespace Sarand.Net.Standard.Base.Dbas
public static class DbDfnIndexList
{
// List of index names.
public static List<String> GetNames (this List<DbDfnIndex> indices)
public static List<String> GetNames(this IEnumerable<DbDfnIndex> indices)
{
List<String> names = new List<String>();
foreach (var index in indices)
@@ -98,21 +98,21 @@ namespace Sarand.Net.Standard.Base.Dbas
return names;
}
// Locate the index in the list.
public static DbDfnIndex GetIndexByName (this List<DbDfnIndex> indices, String name)
public static DbDfnIndex GetIndexByName(this IEnumerable<DbDfnIndex> indices, String name)
{
return indices.Find(idx => idx.Name.EqualsCI(name));
return indices.FirstOrDefault(idx => idx.Name.EqualsCI(name));
}
// Retrieve primary index.
public static DbDfnIndex GetPrimaryIndex (this List<DbDfnIndex> indices)
public static DbDfnIndex GetPrimaryIndex(this IEnumerable<DbDfnIndex> indices)
{
return indices.Find(idx => idx.Primary);
return indices.FirstOrDefault(idx => idx.Primary);
}
// Retrieve clustered index.
public static DbDfnIndex GetClusteredIndex (this List<DbDfnIndex> indices)
public static DbDfnIndex GetClusteredIndex(this IEnumerable<DbDfnIndex> indices)
{
DbDfnIndex index = indices.Find(idx => idx.Clustered);
DbDfnIndex index = indices.FirstOrDefault(idx => idx.Clustered);
if (index == null)
index = indices.Find(idx => idx.IndexType == DbDfnIndex.SQL_INDEX_CLUSTERED);
index = indices.FirstOrDefault(idx => idx.IndexType == DbDfnIndex.SQL_INDEX_CLUSTERED);
return index;
}
}
+12 -6
View File
@@ -35,6 +35,10 @@ namespace Sarand.Net.Standard.Base.Dbas
//-------------------------------------------------------------------
// Comparison.
public bool Matches(DbDfnTable table)
{
return (this.Schema.EqualsCI(table.Schema) && this.Name.EqualsCI(table.Name));
}
public bool MatchesSchemaName(String schema, String name)
{
return (this.Schema.EqualsCI(schema) && this.Name.EqualsCI(name));
@@ -53,7 +57,8 @@ namespace Sarand.Net.Standard.Base.Dbas
}
public bool HasColumns()
{
return ColumnCount > 0;
lock (columns)
return columns.Any();
}
public int ColumnCount
{
@@ -110,7 +115,8 @@ namespace Sarand.Net.Standard.Base.Dbas
}
public bool HasIndices()
{
return IndexCount > 0;
lock (indices)
return indices.Any();
}
public int IndexCount
{
@@ -157,7 +163,7 @@ namespace Sarand.Net.Standard.Base.Dbas
{
//-------------------------------------------------------------------
/// <summary>List of table names.</summary>
public static List<String> GetNames(this List<DbDfnTable> tables)
public static List<String> GetNames(this IEnumerable<DbDfnTable> tables)
{
List<String> names = new List<String>();
foreach (DbDfnTable table in tables)
@@ -169,7 +175,7 @@ namespace Sarand.Net.Standard.Base.Dbas
//-------------------------------------------------------------------
/// <summary>Extract the table definition by schema and table name.</summary>
public static DbDfnTable GetTableBySchemaName(this List<DbDfnTable> tables, String schema, String name)
public static DbDfnTable GetTableBySchemaName(this IEnumerable<DbDfnTable> tables, String schema, String name)
{
foreach (DbDfnTable table in tables)
{
@@ -179,7 +185,7 @@ namespace Sarand.Net.Standard.Base.Dbas
return null;
}
/// <summary>Extract the table definition by table name.</summary>
public static DbDfnTable GetTableByName(this List<DbDfnTable> tables, String name)
public static DbDfnTable GetTableByName(this IEnumerable<DbDfnTable> tables, String name)
{
foreach (DbDfnTable table in tables)
{
@@ -191,7 +197,7 @@ namespace Sarand.Net.Standard.Base.Dbas
//-------------------------------------------------------------------
/// <summary>Get total number of columns for all tables.</summary>
public static int GetColumnCount(this List<DbDfnTable> tables)
public static int GetColumnCount(this IEnumerable<DbDfnTable> tables)
{
int columnCount = 0;
foreach (DbDfnTable table in tables)
+31 -27
View File
@@ -13,19 +13,19 @@ namespace Sarand.Net.Standard.Base.Dbas
//-------------------------------------------------------------------
// Construction.
protected DbResultSet ()
protected DbResultSet()
{
}
//-------------------------------------------------------------------
// Navigation.
public abstract bool NextRecord ();
public abstract void Close ();
public abstract bool NextRecord();
public abstract void Close();
//-------------------------------------------------------------------
// Properties.
public abstract int FieldCount { get; }
public bool IsValidColumn (int columnIdx)
public bool IsValidColumn(int columnIdx)
{
return (columnIdx >= 0 && columnIdx < FieldCount);
}
@@ -33,27 +33,28 @@ namespace Sarand.Net.Standard.Base.Dbas
//-------------------------------------------------------------------
// Field Values.
public abstract int GetOrdinal (String columnName);
public abstract String GetDataTypeName (int columnIdx);
public abstract String GetName (int columnIdx);
public abstract bool IsDbNull (int columnIdx);
public abstract Object GetValue (int columnIdx);
public abstract bool GetBoolean (int columnIdx);
public abstract byte GetByte (int columnIdx);
public abstract short GetInt16 (int columnIdx);
public abstract int GetInt32 (int columnIdx);
public abstract long GetInt64 (int columnIdx);
public abstract float GetFloat (int columnIdx);
public abstract double GetDouble (int columnIdx);
public abstract decimal GetDecimal (int columnIdx);
public abstract String GetString (int columnIdx);
public abstract DateTime GetDateTime (int columnIdx);
public abstract int GetOrdinal(String columnName);
public abstract String GetDataTypeName(int columnIdx);
public abstract String GetName(int columnIdx);
public abstract bool IsDbNull(int columnIdx);
public abstract Object GetValue(int columnIdx);
public abstract bool GetBoolean(int columnIdx);
public abstract byte GetByte(int columnIdx);
public abstract short GetInt16(int columnIdx);
public abstract int GetInt32(int columnIdx);
public abstract long GetInt64(int columnIdx);
public abstract float GetFloat(int columnIdx);
public abstract double GetDouble(int columnIdx);
public abstract decimal GetDecimal(int columnIdx);
public abstract String GetString(int columnIdx);
public abstract DateTime GetDateTime(int columnIdx);
public abstract Guid GetGuid(int columnIdx);
//-------------------------------------------------------------------
// Get Field Value.
public DataValue GetFieldValue (String columnName)
public DataValue GetFieldValue(String columnName)
{
String fn = GetType().Name+".GetFieldValue('" + columnName + "')";
String fn = GetType().Name + ".GetFieldValue('" + columnName + "')";
DataValue dataValue = null;
try
{
@@ -68,9 +69,9 @@ namespace Sarand.Net.Standard.Base.Dbas
#if DEBUG
private static bool handlingGetFieldValueException = false;
#endif
public DataValue GetFieldValue (int columnIdx)
public DataValue GetFieldValue(int columnIdx)
{
String fn = GetType().Name+".GetFieldValue(" + columnIdx + ")";
String fn = GetType().Name + ".GetFieldValue(" + columnIdx + ")";
if (IsDbNull(columnIdx)) return null;
String columnDataType = "";
DataValue dataValue = null;
@@ -125,6 +126,9 @@ namespace Sarand.Net.Standard.Base.Dbas
case "SmallDateTime":
dataValue = new DataValue(GetDateTime(columnIdx));
break;
case "UniqueIdentifier":
dataValue = new DataValue(GetGuid(columnIdx));
break;
default:
SaLogger.Warn(fn + " Unrecognised data type '" + columnDataType + "' for column '" + GetName(columnIdx) + "'");
break;
@@ -132,7 +136,7 @@ namespace Sarand.Net.Standard.Base.Dbas
}
catch (Exception exc)
{
SaLogger.Warn(fn + " Data type: "+ columnDataType + ". Exception: " + exc.Message /*+ "\n" + exc.ToString()*/);
SaLogger.Warn(fn + " Data type: " + columnDataType + ". Exception: " + exc.Message /*+ "\n" + exc.ToString()*/);
#if DEBUG
if (!handlingGetFieldValueException)
{
@@ -146,7 +150,7 @@ namespace Sarand.Net.Standard.Base.Dbas
return dataValue;
}
// Get Record Values.
public NamedValue.Map GetRecordValues ()
public NamedValue.Map GetRecordValues()
{
NamedValue.Map values = null;
values = new NamedValue.Map();
@@ -164,10 +168,10 @@ namespace Sarand.Net.Standard.Base.Dbas
// 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);
SaLogger.Log((fn + "\n\t" + message).Trim(), level);
}
//-------------------------------------------------------------------
+1 -1
View File
@@ -68,7 +68,7 @@ namespace Sarand.Net.Standard.Base.Dbas
//-------------------------------------------------------------------
// Database schema.
List<String> GetTableNames(bool refresh = false);
HashSet<String> GetTableNames(bool refresh = false);
List<DbDfnTable> GetTableDfns(bool refresh = false);
DbDfnTable GetTableDfn(String name, bool refresh = false);
bool TableExists(String tableName);
+48 -43
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Runtime.InteropServices;
using Sarand.Net.Standard.Base.App;
@@ -14,12 +15,12 @@ namespace Sarand.Net.Standard.Base.Dbas
// 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.
/// </summary>
/// <returns>a string array containing the ODBC driver names, if the call to SQLGetInstalledDrivers was successfull; null, otherwise.</returns>
public static string[] GetOdbcDriverNames ()
public static string[] GetOdbcDriverNames()
{
string[] odbcDriverNames = null;
char[] driverNamesBuffer = new char[ushort.MaxValue];
@@ -37,9 +38,9 @@ namespace Sarand.Net.Standard.Base.Dbas
/// Gets the name of an ODBC driver for Microsoft SQL Server giving preference to the most recent one.
/// </summary>
/// <returns>the name of an ODBC driver for Microsoft SQL Server, if one is present; null, otherwise.</returns>
public static string GetOdbcSqlDriverName ()
public static string GetOdbcSqlDriverName()
{
List<string> driverPrecedence = new List<string>() { "ODBC Driver 17 for SQL Server", "ODBC Driver 13 for SQL Server", "ODBC Driver 11 for SQL Server", "SQL Server Native Client 11.0", "SQL Server Native Client 10.0", "SQL Server Native Client 9.0", "SQL Server" };
List<string> driverPrecedence = new List<string>() { "ODBC Driver 18 for SQL Server", "ODBC Driver 17 for SQL Server", "ODBC Driver 13 for SQL Server", "ODBC Driver 11 for SQL Server", "SQL Server Native Client 11.0", "SQL Server Native Client 10.0", "SQL Server Native Client 9.0", "SQL Server" };
string[] availableOdbcDrivers = GetOdbcDriverNames();
string driverName = null;
if (availableOdbcDrivers != null)
@@ -51,26 +52,27 @@ namespace Sarand.Net.Standard.Base.Dbas
//-------------------------------------------------------------------
// SQL Data Type to Native Data Type
//-------------------------------------------------------------------
public static short GetSqlNativeDataType (String dataTypeName)
public static short GetSqlNativeDataType(String dataTypeName)
{
switch (dataTypeName)
{
case "varchar": return 12; // SQL_VARCHAR
case "nvarchar": return -9; // SQL_WVARCHAR
case "bit": return -7; // SQL_BIT
case "tinyint": return -6; // SQL_TINYINT
case "smallint": return 5; // SQL_SMALLINT
case "int": return 4; // SQL_INTEGER
case "bigint": return -5; // SQL_BIGINT
case "real": return 7; // SQL_REAL
case "float": return 6; // SQL_FLOAT
case "decimal": return 3; // SQL_DECIMAL
case "numeric": return 2; // SQL_NUMERIC
case "datetime": return 93; // SQL_TYPE_TIMESTAMP
case "smalldatetime": return 93; // SQL_TYPE_TIMESTAMP
case "varbinary": return 93; // SQL_TYPE_TIMESTAMP
case "varchar": return 12; // SQL_VARCHAR
case "nvarchar": return -9; // SQL_WVARCHAR
case "bit": return -7; // SQL_BIT
case "tinyint": return -6; // SQL_TINYINT
case "smallint": return 5; // SQL_SMALLINT
case "int": return 4; // SQL_INTEGER
case "bigint": return -5; // SQL_BIGINT
case "real": return 7; // SQL_REAL
case "float": return 6; // SQL_FLOAT
case "decimal": return 3; // SQL_DECIMAL
case "numeric": return 2; // SQL_NUMERIC
case "datetime": return 93; // SQL_TYPE_TIMESTAMP
case "smalldatetime": return 93; // SQL_TYPE_TIMESTAMP
case "varbinary": return 93; // SQL_TYPE_TIMESTAMP
case "uniqueidentifier": return -11; // SQL_GUID
default:
SaLogger.Warn("OdbcUtil.GetSqlNativeDataType Unrecognised SQL data type: '" + dataTypeName + "'");
SaLogger.Warn($"OdbcUtil.GetSqlNativeDataType Unrecognised SQL data type: '{dataTypeName}'.");
break;
}
return 0;
@@ -105,7 +107,7 @@ namespace Sarand.Net.Standard.Base.Dbas
// 3. Binary data beyond 255 characters is truncated by default when mapped to CByteArray.
// You can extend the truncation length by explicitly setting the nMaxLength argument of RFX_Binary.
//-------------------------------------------------------------------
public static DbColumnDataType OdbcToDataType (short dataType)
public static DbColumnDataType OdbcToDataType(short dataType)
{
// Data types:
// 2 DECIMAL, CURRENCY
@@ -179,6 +181,10 @@ namespace Sarand.Net.Standard.Base.Dbas
type = DbColumnDataType.Binary;
break;
//---------------------------------------------------------------
case -11: // SQL_GUID: // -11 GUID Fixed length Globally Unique Identifier.
type = DbColumnDataType.Guid;
break;
//---------------------------------------------------------------
case 102: // SQL_INTERVAL_MONTH: // 102 INTERVAL MONTH(p) Number of months between two dates; p is the interval leading precision.
case 101: // SQL_INTERVAL_YEAR: // 101 INTERVAL YEAR(p) Number of years between two dates; p is the interval leading precision.
case 107: // SQL_INTERVAL_YEAR_TO_MONTH: // 107 INTERVAL YEAR(p) TO MONTH Number of years and months between two dates; p is the interval leading precision.
@@ -192,18 +198,17 @@ namespace Sarand.Net.Standard.Base.Dbas
case 111: // SQL_INTERVAL_HOUR_TO_MINUTE: // 111 INTERVAL HOUR(p) TO MINUTE Number of hours/minutes between two date/times; p is the interval leading precision.
case 112: // SQL_INTERVAL_HOUR_TO_SECOND: // 112 INTERVAL HOUR(p) TO SECOND(q) Number of hours/minutes/seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case 113: // SQL_INTERVAL_MINUTE_TO_SECOND: // 113 INTERVAL MINUTE(p) TO SECOND(q) Number of minutes/seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case -11: // SQL_GUID: // -11 GUID Fixed length Globally Unique Identifier.
// break;
//---------------------------------------------------------------
// break;
//---------------------------------------------------------------
default:
SaLogger.Debug("OdbcUtil.OdbcToDataType Unrecognised native data type: " + dataType);
SaLogger.Debug($"OdbcUtil.OdbcToDataType Unrecognised native data type: {dataType}.");
break;
//---------------------------------------------------------------
}
return type;
}
//-------------------------------------------------------------------
public static String GetOdbcDataTypeCaption (short dataType)
public static String GetOdbcDataTypeCaption(short dataType)
{
switch (dataType)
{
@@ -230,24 +235,24 @@ namespace Sarand.Net.Standard.Base.Dbas
case -7: return "Bit"; // SQL_BIT
case -5: return "BigInt"; // SQL_BIGINT
case -2: return "Binary"; // SQL_BINARY
case -11: return "UniqueIdentifier"; // SQL_GUID
case -3: return "VarBinary"; // SQL_VARBINARY
/*
case SQL_LONGVARBINARY: // -4 LONG VARBINARY Variable length binary data. Maximum length is data source–dependent.[9]
case SQL_INTERVAL_MONTH: // 102 INTERVAL MONTH(p) Number of months between two dates; p is the interval leading precision.
case SQL_INTERVAL_YEAR: // 101 INTERVAL YEAR(p) Number of years between two dates; p is the interval leading precision.
case SQL_INTERVAL_YEAR_TO_MONTH: // 107 INTERVAL YEAR(p) TO MONTH Number of years and months between two dates; p is the interval leading precision.
case SQL_INTERVAL_DAY: // 103 INTERVAL DAY(p) Number of days between two dates; p is the interval leading precision.
case SQL_INTERVAL_HOUR: // 104 INTERVAL HOUR(p) Number of hours between two date/times; p is the interval leading precision.
case SQL_INTERVAL_MINUTE: // 105 INTERVAL MINUTE(p) Number of minutes between two date/times; p is the interval leading precision.
case SQL_INTERVAL_SECOND: // 106 INTERVAL SECOND(p,q) Number of seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case SQL_INTERVAL_DAY_TO_HOUR: // 108 INTERVAL DAY(p) TO HOUR Number of days/hours between two date/times; p is the interval leading precision.
case SQL_INTERVAL_DAY_TO_MINUTE: // 109 INTERVAL DAY(p) TO MINUTE Number of days/hours/minutes between two date/times; p is the interval leading precision.
case SQL_INTERVAL_DAY_TO_SECOND: // 110 INTERVAL DAY(p) TO SECOND(q) Number of days/hours/minutes/seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case SQL_INTERVAL_HOUR_TO_MINUTE: // 111 INTERVAL HOUR(p) TO MINUTE Number of hours/minutes between two date/times; p is the interval leading precision.
case SQL_INTERVAL_HOUR_TO_SECOND: // 112 INTERVAL HOUR(p) TO SECOND(q) Number of hours/minutes/seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case SQL_INTERVAL_MINUTE_TO_SECOND: // 113 INTERVAL MINUTE(p) TO SECOND(q) Number of minutes/seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case SQL_GUID: // -11 GUID Fixed length Globally Unique Identifier.
*/
/*
case SQL_LONGVARBINARY: // -4 LONG VARBINARY Variable length binary data. Maximum length is data source–dependent.[9]
case SQL_INTERVAL_MONTH: // 102 INTERVAL MONTH(p) Number of months between two dates; p is the interval leading precision.
case SQL_INTERVAL_YEAR: // 101 INTERVAL YEAR(p) Number of years between two dates; p is the interval leading precision.
case SQL_INTERVAL_YEAR_TO_MONTH: // 107 INTERVAL YEAR(p) TO MONTH Number of years and months between two dates; p is the interval leading precision.
case SQL_INTERVAL_DAY: // 103 INTERVAL DAY(p) Number of days between two dates; p is the interval leading precision.
case SQL_INTERVAL_HOUR: // 104 INTERVAL HOUR(p) Number of hours between two date/times; p is the interval leading precision.
case SQL_INTERVAL_MINUTE: // 105 INTERVAL MINUTE(p) Number of minutes between two date/times; p is the interval leading precision.
case SQL_INTERVAL_SECOND: // 106 INTERVAL SECOND(p,q) Number of seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case SQL_INTERVAL_DAY_TO_HOUR: // 108 INTERVAL DAY(p) TO HOUR Number of days/hours between two date/times; p is the interval leading precision.
case SQL_INTERVAL_DAY_TO_MINUTE: // 109 INTERVAL DAY(p) TO MINUTE Number of days/hours/minutes between two date/times; p is the interval leading precision.
case SQL_INTERVAL_DAY_TO_SECOND: // 110 INTERVAL DAY(p) TO SECOND(q) Number of days/hours/minutes/seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case SQL_INTERVAL_HOUR_TO_MINUTE: // 111 INTERVAL HOUR(p) TO MINUTE Number of hours/minutes between two date/times; p is the interval leading precision.
case SQL_INTERVAL_HOUR_TO_SECOND: // 112 INTERVAL HOUR(p) TO SECOND(q) Number of hours/minutes/seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
case SQL_INTERVAL_MINUTE_TO_SECOND: // 113 INTERVAL MINUTE(p) TO SECOND(q) Number of minutes/seconds between two date/times; p is the interval leading precision and q is the interval seconds precision.
*/
default:
break;
//---------------------------------------------------------------
@@ -215,7 +215,7 @@ namespace Sarand.Net.Standard.Base.Helpers
}
}
}
SaLogger.Warn(SysUtil.Fn + " Failed to locate text resource: " + resourceNameEndsWith);
SaLogger.Warn($"{SysUtil.Fn} Failed to locate text resource: {resourceNameEndsWith}");
return null;
}
@@ -231,20 +231,20 @@ namespace Sarand.Net.Standard.Base.Helpers
/// <summary>Retrieve resource as stream based on assembly and partial resource name.</summary>
public static Stream GetManifestResourceStream(Assembly assembly, String partialPath, String resourceNameEndsWith)
{
//Logger.Debug(SysUtil.Fn + " Manifest resource names: " + new List<String>(assembly.GetManifestResourceNames()).Concat("","\n\t"));
//SaLogger.Debug($"{SysUtil.Fn} Manifest resource names: {assembly.GetManifestResourceNames().Concat("","\n\t")}");
foreach (String resourceName in assembly.GetManifestResourceNames())
{
//SaLogger.Debug(SysUtil.Fn + " Resource: " + resourceName);
//SaLogger.Debug($"{SysUtil.Fn} Resource: '{resourceName}'.");
// Match the partial path.
if (!StringUtil.IsBlank(partialPath) && !resourceName.ContainsCI(partialPath)) continue;
// Match the resource filename to the end of the resource name - resource names start with default namespace (eg. 'Sarand').
if (!resourceName.EndsWithCI(resourceNameEndsWith)) continue;
//SaLogger.Debug(SysUtil.Fn + " Resource filename: " + resourceNameEndsWith + ". Matched to resource: " + resourceName);
//SaLogger.Debug($"{SysUtil.Fn} Resource filename: '{resourceNameEndsWith}'. Matched to resource: {resourceName}");
return assembly.GetManifestResourceStream(resourceName);
}
SaLogger.Warn(SysUtil.Fn + " Resource filename not found: " + resourceNameEndsWith);
SaLogger.Warn($"{SysUtil.Fn} Resource filename not found: {resourceNameEndsWith}.");
return null;
}
@@ -372,7 +372,7 @@ namespace Sarand.Net.Standard.Base.Interfaces
//-------------------------------------------------------------------
// Reserved words.
private static readonly List<String> reservedWords = new List<String>()
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
"ADD",
"ALL",
@@ -234,7 +234,7 @@ namespace Sarand.Net.Standard.Base.ItemData
//-------------------------------------------------------------------
// Reserved words.
private static readonly List<String> reservedWords = new List<String>()
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
"ADD",
"ALL",
@@ -66,12 +66,12 @@ namespace Sarand.Net.Standard.Base.ItemData
if ((int)itemDataData.ItemId.Type < 1)
{
errField.ItemType = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item type must be supplied");
return SetErrorState(Msg_ItemTypeNotSpecified);
}
if (!SysId.IsValid(itemDataData.ItemId.Id))
{
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item Id must be supplied");
return SetErrorState(Msg_ItemIdNotSpecified);
}
if (!IsValidValue(itemDataData.DataType, "Data type", (long)SaItemDataDbDfn.GetColTextLen(SaItemDataDbDfn.ColumnIdx.SaItemData_DataType), true))
{
@@ -64,12 +64,12 @@ namespace Sarand.Net.Standard.Base.ItemDocs
if ((int)itemDocData.ItemId.Type < 1)
{
errField.ItemType = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item type must be supplied");
return SetErrorState(Msg_ItemTypeNotSpecified);
}
if (!SysId.IsValid(itemDocData.ItemId.Id))
{
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item Id must be supplied");
return SetErrorState(Msg_ItemIdNotSpecified);
}
if ((int)itemDocData.Category < 1)
{
@@ -244,7 +244,7 @@ namespace Sarand.Net.Standard.Base.ItemDocs
//-------------------------------------------------------------------
// Reserved words.
private static readonly List<String> reservedWords = new List<String>()
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
"ADD",
"ALL",
@@ -1,3 +1,4 @@
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using System;
@@ -5,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:46
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:21
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Base.ItemOptions
{
@@ -44,7 +45,7 @@ namespace Sarand.Net.Standard.Base.ItemOptions
// Data members.
private static readonly int tableCount = 1;
private static readonly int columnCount = 14;
private static ulong maxTextLen = 0;
public static ulong MaxTextLen { get; private set; }
//-------------------------------------------------------------------
// Retrieve Table details (eg. name: 'Company').
@@ -52,14 +53,31 @@ namespace Sarand.Net.Standard.Base.ItemOptions
{
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];
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;
}
//-------------------------------------------------------------------
// Identify the table that corresponds with the specified column.
@@ -109,8 +127,15 @@ namespace Sarand.Net.Standard.Base.ItemOptions
}
public static String DelimitReservedWord (String word)
{
if (!IsReservedWord(word)) return word;
switch (reservedWordDelim)
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;
@@ -141,7 +166,7 @@ namespace Sarand.Net.Standard.Base.ItemOptions
}
public static void SetMaxTextLen (ulong maxTextLen)
{
SaItemOptionDbDfn.maxTextLen = maxTextLen;
SaItemOptionDbDfn.MaxTextLen = maxTextLen;
}
public static bool IsColFmtText (ColumnIdx column)
{
@@ -156,7 +181,7 @@ namespace Sarand.Net.Standard.Base.ItemOptions
if (columns[columnIdx].DataType == DbColumnDataType.VarChar)
{
ulong textLen = columns[columnIdx].DataLen;
if (maxTextLen > 0 && textLen > maxTextLen) textLen = maxTextLen;
if (MaxTextLen > 0 && textLen > MaxTextLen) textLen = MaxTextLen;
return textLen;
}
return 0;
@@ -187,14 +212,24 @@ namespace Sarand.Net.Standard.Base.ItemOptions
//-------------------------------------------------------------------
// Table definitions.
private static readonly String[] tables =
private class TableDfn
{
"SaItemOption",
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 =
{
new TableDfn("dbo","SaItemOption"),
};
//-------------------------------------------------------------------
// Table column definitions.
internal class ColumnDfn
private class ColumnDfn
{
internal TableIdx TableIdx { get; set; }
internal String Name { get; set; }
@@ -212,8 +247,6 @@ namespace Sarand.Net.Standard.Base.ItemOptions
this.DataLen = dataLen;
}
}
//-------------------------------------------------------------------
private static readonly ColumnDfn[] columns =
{
new ColumnDfn(1,"ItemType",3,5,false,5),
@@ -234,7 +267,7 @@ namespace Sarand.Net.Standard.Base.ItemOptions
//-------------------------------------------------------------------
// Reserved words.
private static readonly List<String> reservedWords = new List<String>()
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
"ADD",
"ALL",
@@ -68,12 +68,12 @@ namespace Sarand.Net.Standard.Base.ItemOptions
if ((int)itemOptionData.ItemId.Type < 1)
{
errField.ItemType = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item type must be supplied");
return SetErrorState(Msg_ItemTypeNotSpecified);
}
if (!SysId.IsValid(itemOptionData.ItemId.Id))
{
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item Id must be supplied");
return SetErrorState(Msg_ItemIdNotSpecified);
}
if (!IsValidValue(itemOptionData.Name, "name", (long)SaItemOptionDbDfn.GetColTextLen(SaItemOptionDbDfn.ColumnIdx.SaItemOption_Name), true))
{
@@ -383,7 +383,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
//-------------------------------------------------------------------
// Reserved words.
private static readonly List<String> reservedWords = new List<String>()
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
"ADD",
"ALL",
@@ -86,7 +86,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
public virtual bool CurrencyCanBeDeleted (SaCurrency currency)
{
ClearErrorState();
if (currency == null) return SetErrorState("Item not specified");
if (currency == null) return SetErrorState(Msg_ItemNotSpecified);
if (currency.HasDependentCurrencies()) return SetErrorState("Has dependent currencies");
return true;
}
@@ -75,7 +75,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
public virtual bool LanguageCanBeDeleted (SaLanguage language)
{
ClearErrorState();
if (language == null) return SetErrorState("Item not specified");
if (language == null) return SetErrorState(Msg_ItemNotSpecified);
if (language.HasDependentLanguages()) return SetErrorState("Has dependent languages");
return true;
}
@@ -97,7 +97,7 @@ namespace Sarand.Net.Standard.Base.ReferenceData
public virtual bool RegionCanBeDeleted (SaRegion region)
{
ClearErrorState();
if (region == null) return SetErrorState("Item not specified");
if (region == null) return SetErrorState(Msg_ItemNotSpecified);
if (region.HasDependentRegions()) return SetErrorState("Has dependent regions");
if (region.HasDependentCurrencies()) return SetErrorState("Has dependent currencies");
if (region.HasDependentTaxCodes()) return SetErrorState("Has dependent tax codes");
@@ -312,7 +312,9 @@ namespace Sarand.Net.Standard.Base.Security
//-------------------------------------------------------------------
// Security item updates.
public abstract bool CreateUser(String code, String name, DbUpdateInfo dbUpdateInfo);
public abstract bool CreateGroup(String code, String name, DbUpdateInfo dbUpdateInfo);
public abstract bool AssignUserToGroup(String userCode, String groupCode, DbUpdateInfo dbUpdateInfo);
public abstract bool AssignRightToGroup(String rightCode, String groupCode, DbUpdateInfo dbUpdateInfo);
public abstract bool UpdateSecurityItem(SaSecurityItem securityItem, DbUpdateInfo dbUpdateInfo);
//-------------------------------------------------------------------
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 3-Oct-2019 15:10:38
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
//---------------------------------------------------------------------------
namespace Sarand.Net.Standard.Base.Security
{
@@ -32,11 +32,16 @@ namespace Sarand.Net.Standard.Base.Security
SaSecItem_Type,
SaSecItem_EmailAddress,
SaSecItem_Location,
SaSecItem_DataItemType,
SaSecItem_EncPword,
SaSecItem_PwordSalt,
SaSecItem_PwordHash,
SaSecItem_PasswordToken,
SaSecItem_PasswordHistory,
SaSecItem_PasswordChangedAt,
SaSecItem_LastLogin,
SaSecItem_DataItemType,
SaSecItem_LastInvalidLoginAt,
SaSecItem_InvalidLoginCount,
SaSecItem_Notes,
SaSecItem_Flags,
SaSecItem_Status,
@@ -65,8 +70,8 @@ namespace Sarand.Net.Standard.Base.Security
//-------------------------------------------------------------------
// Data members.
private static readonly int tableCount = 2;
private static readonly int columnCount = 34;
private static ulong maxTextLen = 0;
private static readonly int columnCount = 39;
public static ulong MaxTextLen { get; private set; }
//-------------------------------------------------------------------
// Retrieve Table details (eg. name: 'Company').
@@ -74,14 +79,31 @@ namespace Sarand.Net.Standard.Base.Security
{
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];
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;
}
//-------------------------------------------------------------------
// Identify the table that corresponds with the specified column.
@@ -131,8 +153,15 @@ namespace Sarand.Net.Standard.Base.Security
}
public static String DelimitReservedWord (String word)
{
if (!IsReservedWord(word)) return word;
switch (reservedWordDelim)
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;
@@ -163,7 +192,7 @@ namespace Sarand.Net.Standard.Base.Security
}
public static void SetMaxTextLen (ulong maxTextLen)
{
SaSecurityDbDfn.maxTextLen = maxTextLen;
SaSecurityDbDfn.MaxTextLen = maxTextLen;
}
public static bool IsColFmtText (ColumnIdx column)
{
@@ -178,7 +207,7 @@ namespace Sarand.Net.Standard.Base.Security
if (columns[columnIdx].DataType == DbColumnDataType.VarChar)
{
ulong textLen = columns[columnIdx].DataLen;
if (maxTextLen > 0 && textLen > maxTextLen) textLen = maxTextLen;
if (MaxTextLen > 0 && textLen > MaxTextLen) textLen = MaxTextLen;
return textLen;
}
return 0;
@@ -209,15 +238,25 @@ namespace Sarand.Net.Standard.Base.Security
//-------------------------------------------------------------------
// Table definitions.
private static readonly String[] tables =
private class TableDfn
{
"SaSecItem",
"SaSecLink",
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 =
{
new TableDfn("dbo","SaSecItem"),
new TableDfn("dbo","SaSecLink"),
};
//-------------------------------------------------------------------
// Table column definitions.
internal class ColumnDfn
private class ColumnDfn
{
internal TableIdx TableIdx { get; set; }
internal String Name { get; set; }
@@ -235,21 +274,24 @@ namespace Sarand.Net.Standard.Base.Security
this.DataLen = dataLen;
}
}
//-------------------------------------------------------------------
private static readonly ColumnDfn[] columns =
{
new ColumnDfn(1,"Id",4,4,false,10),
new ColumnDfn(1,"Code",0,-9,false,20),
new ColumnDfn(1,"Description",0,-9,false,50),
new ColumnDfn(1,"Code",0,-9,false,128),
new ColumnDfn(1,"Description",0,-9,false,100),
new ColumnDfn(1,"Type",2,-6,false,3),
new ColumnDfn(1,"EmailAddress",0,12,false,128),
new ColumnDfn(1,"EmailAddress",0,-9,false,128),
new ColumnDfn(1,"Location",0,-9,false,50),
new ColumnDfn(1,"DataItemType",3,5,false,5),
new ColumnDfn(1,"EncPword",0,-9,false,128),
new ColumnDfn(1,"PwordSalt",0,-9,false,16),
new ColumnDfn(1,"PwordHash",0,-9,false,64),
new ColumnDfn(1,"PwordHash",0,-9,false,200),
new ColumnDfn(1,"PasswordToken",0,12,false,32),
new ColumnDfn(1,"PasswordHistory",0,-9,false,0),
new ColumnDfn(1,"PasswordChangedAt",9,93,false,16),
new ColumnDfn(1,"LastLogin",9,93,false,23),
new ColumnDfn(1,"DataItemType",3,5,false,5),
new ColumnDfn(1,"LastInvalidLoginAt",9,93,false,16),
new ColumnDfn(1,"InvalidLoginCount",3,5,false,5),
new ColumnDfn(1,"Notes",0,-9,false,255),
new ColumnDfn(1,"Flags",3,5,false,5),
new ColumnDfn(1,"Status",0,12,false,3),
@@ -277,7 +319,7 @@ namespace Sarand.Net.Standard.Base.Security
//-------------------------------------------------------------------
// Reserved words.
private static readonly List<String> reservedWords = new List<String>()
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
"ADD",
"ALL",
@@ -58,10 +58,10 @@ namespace Sarand.Net.Standard.Base.Security
public String PasswordHash { get; set; } = String.Empty;
public List<String> PasswordHistory { get; } = new List<string>();
public String PasswordToken { get; set; } = String.Empty;
public DateTime PasswordChangedAt { get; set; } = DateTime.MinValue;
public DateTime? PasswordChangedAt { get; set; } = DateTime.MinValue;
// Login.
public DateTime LastLogin { get; set; } = DateTime.MinValue;
public DateTime LastInvalidLoginAt { get; set; } = DateTime.MinValue;
public DateTime? LastLogin { get; set; } = DateTime.MinValue;
public DateTime? LastInvalidLoginAt { get; set; } = DateTime.MinValue;
public short InvalidLoginCount { get; set; }
}
@@ -138,21 +138,21 @@ namespace Sarand.Net.Standard.Base.Security
get { return data.PasswordToken; }
set { CheckChanged(data.PasswordToken, value); data.PasswordToken = value; }
}
public DateTime PasswordChangedAt
public DateTime? PasswordChangedAt
{
get { return data.PasswordChangedAt; }
set { CheckChanged(data.PasswordChangedAt, value); data.PasswordChangedAt = value; }
set { CheckChangedNullable(data.PasswordChangedAt, value); data.PasswordChangedAt = value; }
}
// Login.
public DateTime LastLogin
public DateTime? LastLogin
{
get { return data.LastLogin; }
set { CheckChanged(data.LastLogin, value); data.LastLogin = value; }
set { CheckChangedNullable(data.LastLogin, value); data.LastLogin = value; }
}
public DateTime LastInvalidLoginAt
public DateTime? LastInvalidLoginAt
{
get { return data.LastInvalidLoginAt; }
set { CheckChanged(data.LastInvalidLoginAt, value); data.LastInvalidLoginAt = value; }
set { CheckChangedNullable(data.LastInvalidLoginAt, value); data.LastInvalidLoginAt = value; }
}
public short InvalidLoginCount
{
@@ -331,19 +331,19 @@ namespace Sarand.Net.Standard.Base.Security
get { return data.PasswordHistory; }
set { data.PasswordHistory = value; }
}
public DateTime PasswordChangedAt
public DateTime? PasswordChangedAt
{
get { return data.PasswordChangedAt; }
set { data.PasswordChangedAt = value; }
}
// Login.
public DateTime LastLogin
public DateTime? LastLogin
{
get { return data.LastLogin; }
set { data.LastLogin = value; }
}
public DateTime LastInvalidLoginAt
public DateTime? LastInvalidLoginAt
{
get { return data.LastInvalidLoginAt; }
set { data.LastInvalidLoginAt = value; }
@@ -42,8 +42,8 @@ namespace Sarand.Net.Standard.Base.Security
public SysId ItemIdTarget { get; set; } = new SysId();
public SysId ItemIdContext { get; set; } = new SysId();
public String DayApplicability { get; set; } = String.Empty;
public DateTime ApplicableFrom { get; set; } = DateTime.MinValue;
public DateTime ApplicableTo { get; set; } = DateTime.MinValue;
public DateTime? ApplicableFrom { get; set; } = DateTime.MinValue;
public DateTime? ApplicableTo { get; set; } = DateTime.MinValue;
}
//-------------------------------------------------------------------
@@ -78,15 +78,15 @@ namespace Sarand.Net.Standard.Base.Security
get { return data.DayApplicability; }
set { CheckChanged(data.DayApplicability, value); data.DayApplicability = value; }
}
public DateTime ApplicableFrom
public DateTime? ApplicableFrom
{
get { return data.ApplicableFrom; }
set { CheckChanged(data.ApplicableFrom, value); data.ApplicableFrom = value; }
set { CheckChangedNullable(data.ApplicableFrom, value); data.ApplicableFrom = value; }
}
public DateTime ApplicableTo
public DateTime? ApplicableTo
{
get { return data.ApplicableTo; }
set { CheckChanged(data.ApplicableTo, value); data.ApplicableTo = value; }
set { CheckChangedNullable(data.ApplicableTo, value); data.ApplicableTo = value; }
}
// Population.
internal void PopulateFrom(Data data)
@@ -200,12 +200,12 @@ namespace Sarand.Net.Standard.Base.Security
get { return data.DayApplicability; }
set { data.DayApplicability = value; }
}
public DateTime ApplicableFrom
public DateTime? ApplicableFrom
{
get { return data.ApplicableFrom; }
set { data.ApplicableFrom = value; }
}
public DateTime ApplicableTo
public DateTime? ApplicableTo
{
get { return data.ApplicableTo; }
set { data.ApplicableTo = value; }
@@ -15,36 +15,36 @@ namespace Sarand.Net.Standard.Base.Security
// S e c u r i t y I t e m s
//*******************************************************************
// Associated data.
public bool SecurityItemHasLinks (SysId securityItemId)
public bool SecurityItemHasLinks(SysId securityItemId)
{
return (SecurityItemIsSourceOfLinks(securityItemId) || SecurityItemIsTargetOfLinks(securityItemId));
}
public abstract bool SecurityItemIsSourceOfLinks (SysId securityItemId);
public abstract bool SecurityItemIsTargetOfLinks (SysId securityItemId);
public abstract bool SecurityItemHasLinksWith (SysId securityItemIdOwner, SysId securityItemIdTarget);
public abstract bool SecurityItemIsSourceOfLinks(SysId securityItemId);
public abstract bool SecurityItemIsTargetOfLinks(SysId securityItemId);
public abstract bool SecurityItemHasLinksWith(SysId securityItemIdOwner, SysId securityItemIdTarget);
//-------------------------------------------------------------------
// Retrieve individual security items.
public abstract bool SecurityItemExistsById (SysId id);
public abstract bool SecurityItemExistsByTypeCode (SaSecurity.ItemType securityItemType, String code);
public abstract SaSecurityItem GetSecurityItemById (SysId id);
public abstract bool SecurityItemExistsById(SysId id);
public abstract bool SecurityItemExistsByTypeCode(SaSecurity.ItemType securityItemType, String code);
public abstract SaSecurityItem GetSecurityItemById(SysId id);
public abstract SaSecurityItem GetSecurityItemByTypeId(SaSecurity.ItemType securityItemType, SysId id);
public abstract SaSecurityItem GetSecurityItemByTypeEmail(SaSecurity.ItemType securityItemType, String emailAddress);
public abstract SaSecurityItem GetSecurityItemByTypeCode(SaSecurity.ItemType securityItemType, String code);
public abstract SaSecurityItem GetSecurityItem (SaSecurityItem.Params prmSecItem);
public abstract SaSecurityItem GetSecurityItem(SaSecurityItem.Params prmSecItem);
// Create Security Item.
public abstract SaSecurityItem CreateSecurityItem (SaSecurity.ItemType securityItemType);
public abstract SaSecurityItem CreateSecurityItem(SaSecurity.ItemType securityItemType);
//-------------------------------------------------------------------
// Validate Security Item.
public bool IsValidSecurityItem (SaSecurityItem securityItem)
public bool IsValidSecurityItem(SaSecurityItem securityItem)
{
ClearErrorState();
if (securityItem == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
return IsValidSecurityItemData(securityItem.GetData(), new SaSecurityItem.ErrField());
}
public virtual bool IsValidSecurityItemData (SaSecurityItem.Data data, SaSecurityItem.ErrField errField)
public virtual bool IsValidSecurityItemData(SaSecurityItem.Data data, SaSecurityItem.ErrField errField)
{
ClearErrorState();
if (errField.ItemType != SacsHierarchyItem.ValidValue.Ignore && (int)data.ItemType < 1)
@@ -102,30 +102,30 @@ namespace Sarand.Net.Standard.Base.Security
//-------------------------------------------------------------------
// SecurityItem database interface.
public abstract bool InsertSecurityItem (SaSecurityItem securityItem, DbUpdateInfo dbUpdateInfo);
public abstract bool UpdateSecurityItem (SaSecurityItem securityItem, DbUpdateInfo dbUpdateInfo);
public virtual bool SecurityItemCanBeDeleted (SaSecurityItem securityItem)
public abstract bool InsertSecurityItem(SaSecurityItem securityItem, DbUpdateInfo dbUpdateInfo);
public abstract bool UpdateSecurityItem(SaSecurityItem securityItem, DbUpdateInfo dbUpdateInfo);
public virtual bool SecurityItemCanBeDeleted(SaSecurityItem securityItem)
{
ClearErrorState();
if (SecurityItemHasLinks(securityItem.Id)) return SetErrorState("security item has links");
return true;
}
public abstract bool DeleteSecurityItem (SaSecurityItem securityItem, DbUpdateInfo dbUpdateInfo);
public abstract bool DeleteSecurityItem(SaSecurityItem securityItem, DbUpdateInfo dbUpdateInfo);
//-------------------------------------------------------------------
// Item list.
public abstract ColumnDfn GetSecurityItemColumnDfn (SaSecurityItem.Column columnId, String caption = "", int width = 0);
public abstract List<String> GetSecurityItemQueryFilter (SaSecurityItem.Params prm);
public abstract long GetSecurityItemCount (SaSecurityItem.Params prm);
public abstract List<SaSecurityItem> GetSecurityItemList (SaSecurityItem.Params prm);
public abstract DbResultSet ExecuteSecurityItemQuery (List<ColumnDfn> columns, SaSecurityItem.Params prm);
public abstract ColumnDfn GetSecurityItemColumnDfn(SaSecurityItem.Column columnId, String caption = "", int width = 0);
public abstract List<String> GetSecurityItemQueryFilter(SaSecurityItem.Params prm);
public abstract long GetSecurityItemCount(SaSecurityItem.Params prm);
public abstract List<SaSecurityItem> GetSecurityItemList(SaSecurityItem.Params prm);
public abstract DbResultSet ExecuteSecurityItemQuery(List<ColumnDfn> columns, SaSecurityItem.Params prm);
//-------------------------------------------------------------------
/// <summary>
/// Extract and format result set data value where specific handling is required.
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
/// </summary>
public DataValue GetSecurityItemDataValue (ColumnDfn column, NamedValue.Map values)
public DataValue GetSecurityItemDataValue(ColumnDfn column, NamedValue.Map values)
{
DataValue value = new DataValue();
switch ((SaSecurityItem.Column)column.Id)
@@ -147,17 +147,17 @@ namespace Sarand.Net.Standard.Base.Security
// Status.
case SaSecurityItem.Column.Status_Desc:
case SaSecurityItem.Column.Status_Ind:
{
String statusCode = values.GetValue(column.DataName).ToString();
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
if (column.Id == (int)SaSecurityItem.Column.Status_Desc)
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
else if (column.Id == (int)SaSecurityItem.Column.Status_Ind)
value = new DataValue(SaSecurityItem.GetStatusTriState(status));
}
break;
{
String statusCode = values.GetValue(column.DataName).ToString();
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
if (column.Id == (int)SaSecurityItem.Column.Status_Desc)
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
else if (column.Id == (int)SaSecurityItem.Column.Status_Ind)
value = new DataValue(SaSecurityItem.GetStatusTriState(status));
}
break;
//-----------------------------------------------------------
//-----------------------------------------------------------
}
return value;
}
@@ -77,7 +77,7 @@ namespace Sarand.Net.Standard.Base.Security
EmailAddress = secItem.EmailAddress;
Description = secItem.Description;
Location = secItem.Location;
LastLogin = secItem.LastLogin;
LastLogin = secItem.LastLogin ?? DateTime.MinValue;
}
if (profileGroups != null)
securityGroups.AddRange(profileGroups);
@@ -237,7 +237,7 @@ namespace Sarand.Net.Standard.Base.UpdateLog
//-------------------------------------------------------------------
// Reserved words.
private static readonly List<String> reservedWords = new List<String>()
private static readonly HashSet<String> reservedWords = new HashSet<String>()
{
"ADD",
"ALL",
@@ -86,7 +86,7 @@ namespace Sarand.Net.Standard.Base.UpdateLog
ClearErrorState();
if (!config.UpdateLogConsole.LogUpdates(this))
SetErrorState(config.UpdateLogConsole.ErrorStateMessage);
return !HasErrorState();
return OK;
}
protected virtual bool IsColumnChangeLogged (String attrName)
{
@@ -121,7 +121,7 @@ namespace Sarand.Net.Standard.Base.UpdateLog
SetAttrValueAfter(attrName, value);
else
SetAttrValueBefore(attrName, value);
return !HasErrorState();
return OK;
}
public void SetAttrValueBefore (String attrName, DataValue value)
{
@@ -59,12 +59,12 @@ namespace Sarand.Net.Standard.Base.UpdateLog
if ((int)logEntryData.ItemId.Type < 1)
{
errField.ItemType = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item type must be supplied");
return SetErrorState(Msg_ItemTypeNotSpecified);
}
if (!SysId.IsValid(logEntryData.ItemId.Id))
{
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item Id must be supplied");
return SetErrorState(Msg_ItemIdNotSpecified);
}
if (!IsValidValue(logEntryData.Attribute, "attribute", (long)SaUpdateLogDbDfn.GetColTextLen(SaUpdateLogDbDfn.ColumnIdx.SaAttrUpdate_Attribute), true))
{
+1 -1
View File
@@ -51,7 +51,7 @@ namespace Sarand.Net.Standard.Base.Utils
/// </summary>
public static String GetLogMessage(this Exception exc, String message, int entries = 8, String stackEntryDelim = "\n\t")
{
return (exc.GetType().Name + " " + message + ": " + GetMessage(exc) + exc.GetStackEntries(entries).Concat("", stackEntryDelim)).TrimAll();
return ($"{exc.GetType().Name} {message}: {GetMessage(exc).TrimEnd('.')}.{exc.GetStackEntries(entries).Concat("", stackEntryDelim)}").TrimAll();
}
//-------------------------------------------------------------------
+13 -13
View File
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Sarand.Net.Standard</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Sarand.Net.Standard</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CsvHelper" Version="19.0.0" />
<PackageReference Include="MailKit" Version="4.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
<PackageReference Include="ZstdNet" Version="1.4.5" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CsvHelper" Version="19.0.0" />
<PackageReference Include="MailKit" Version="4.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
<PackageReference Include="ZstdNet" Version="1.4.5" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\**\*.*" />