From 2eb778ac17c2204951f9b841b1abf1a4aa336bc5 Mon Sep 17 00:00:00 2001 From: Andy Howard Date: Tue, 20 Aug 2024 17:51:51 +0100 Subject: [PATCH] Saxonite 1.2.11.12 --- SacsCoreWeb/Web/Components/SaController.cs | 12 ++++++ .../Base/Bus/SacsHierarchyItem.cs | 5 +-- SacsStandardBase/Base/Bus/SysId.cs | 4 +- SacsStandardBase/Base/CodeTypes/SaCode.cs | 5 +-- SacsStandardBase/Base/CodeTypes/SaCodeType.cs | 5 +-- SacsStandardBase/Base/Core/SacsDfn.cs | 1 + SacsStandardBase/Base/Email/SaEmailConsole.cs | 8 ++-- .../Base/Helpers/SacsContentTypeHelper.cs | 2 +- .../Base/Interfaces/SaInterface.cs | 9 ++-- .../Base/Interfaces/SaInterfaceDataItem.cs | 13 +++--- .../Base/Interfaces/SaInterfaceProcess.cs | 11 +++-- .../Interfaces/SaInterfaceProcessDataItem.cs | 10 ++--- .../Interfaces/SaInterfaceProcessMessage.cs | 6 +-- SacsStandardBase/Base/ItemData/SaItemData.cs | 5 +-- SacsStandardBase/Base/ItemDocs/SaItemDoc.cs | 7 ++-- .../Base/ItemOptions/SaItemOption.cs | 9 ++-- SacsStandardBase/Base/Procs/SaProcess_Base.cs | 7 ++-- .../Base/ReferenceData/SaCurrency.cs | 3 +- .../Base/ReferenceData/SaLanguage.cs | 4 +- .../Base/ReferenceData/SaRegion.cs | 4 +- .../Base/ReferenceData/SaTaxCode.cs | 5 +-- .../Base/ReferenceData/SaUnitMeasure.cs | 5 +-- .../Base/Security/SaSecurityItem.cs | 7 +--- .../Base/Security/SaSecurityLink.cs | 8 ++-- .../Base/UpdateLog/SaUpdateLogEntry.cs | 9 ++-- SacsStandardBase/Base/Utils/DictionaryUtil.cs | 2 +- SacsStandardBase/Base/Utils/ImageUtils.cs | 42 +++++++++++++++++-- .../Base/Utils/NewtonsoftJsonUtil.cs | 8 +++- SacsStandardBase/SacsStandardBase.csproj | 2 +- .../Dbas/Base/DatabaseDefinitionGenerator.cs | 8 ++-- .../CodeTypes/SaCodeTypeDbDfnGenerator.cs | 13 +++--- SacsStandardDbas/Dbas/Data/DbDataItem.cs | 7 ++-- .../Dbas/Data/DbResultSet_DataReader.cs | 10 ++--- .../Dbas/Data/DbResultSet_DataTableReader.cs | 6 +-- .../Dbas/Data/SacsDatabaseOdbc.cs | 6 +-- SacsStandardDbas/SacsStandardDbas.csproj | 2 +- 36 files changed, 149 insertions(+), 121 deletions(-) diff --git a/SacsCoreWeb/Web/Components/SaController.cs b/SacsCoreWeb/Web/Components/SaController.cs index 4448b02..68394ea 100644 --- a/SacsCoreWeb/Web/Components/SaController.cs +++ b/SacsCoreWeb/Web/Components/SaController.cs @@ -319,6 +319,18 @@ namespace Sacs.Web.Components public String Code { get; set; } public String Desc { get; set; } } + /// Statistics Caption/Value pair. + public class StatData : AjaxResponse_Base + { + public String Caption { get; set; } + public String Value { get; set; } + } + /// Statistics Group. + public class StatsGroupData : AjaxResponse_Base + { + public String Caption { get; set; } + public List Stats { get; } = new List(); + } //--------------------------------------------------------------- // Form data. diff --git a/SacsStandardBase/Base/Bus/SacsHierarchyItem.cs b/SacsStandardBase/Base/Bus/SacsHierarchyItem.cs index 0b2dc0b..c2727b1 100644 --- a/SacsStandardBase/Base/Bus/SacsHierarchyItem.cs +++ b/SacsStandardBase/Base/Bus/SacsHierarchyItem.cs @@ -439,15 +439,14 @@ namespace Sarand.Net.Standard.Base.Bus // Populate data item - only once on construction. protected void SetData(Data data) { - String fn = GetType().Name + ".SetData"; // Can only be replaced if currently internal class. if (this.data.GetType() != typeof(Data)) - throw new NotSupportedException(fn + " Data object has already been specified"); + throw new NotSupportedException($"{SysUtil.Fn} Data object has already been specified"); // If Id has already been specified (on construction) and supplied Id is not valid, set it to the existing value. if (ItemHasId && SysId.IsValid(Id) && !SysId.IsValid(data.Id)) data.Id = Id; // Properties that cannot be changed if previously specified. if (ItemHasId && SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); this.data.PopulateTo(data); this.data = data; } diff --git a/SacsStandardBase/Base/Bus/SysId.cs b/SacsStandardBase/Base/Bus/SysId.cs index 936333f..0826166 100644 --- a/SacsStandardBase/Base/Bus/SysId.cs +++ b/SacsStandardBase/Base/Bus/SysId.cs @@ -209,10 +209,10 @@ namespace Sarand.Net.Standard.Base.Bus /// /// /// - public static String Concat(this List values, String delimiter, bool ignoreInvalid = true) + public static String Concat(this ICollection values, String delimiter, bool ignoreInvalid = true) { List ids = new List(); - foreach (SysId id in values.FindAll(id => !ignoreInvalid || SysId.IsValid(id))) + foreach (SysId id in values.Where(id => !ignoreInvalid || SysId.IsValid(id))) ids.Add(id.ToString()); return ids.Concat(delimiter); } diff --git a/SacsStandardBase/Base/CodeTypes/SaCode.cs b/SacsStandardBase/Base/CodeTypes/SaCode.cs index 84cadc0..5fa9dd0 100644 --- a/SacsStandardBase/Base/CodeTypes/SaCode.cs +++ b/SacsStandardBase/Base/CodeTypes/SaCode.cs @@ -162,12 +162,11 @@ namespace Sarand.Net.Standard.Base.CodeTypes public Data GetData () { return data.Clone(); } public void SetData (Data data) { - string fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (!StringUtil.IsEmpty(Code) && !Code.Equals(data.Code)) - throw new NotSupportedException(fn + " Code cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Code cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/CodeTypes/SaCodeType.cs b/SacsStandardBase/Base/CodeTypes/SaCodeType.cs index a84c87b..9256457 100644 --- a/SacsStandardBase/Base/CodeTypes/SaCodeType.cs +++ b/SacsStandardBase/Base/CodeTypes/SaCodeType.cs @@ -154,12 +154,11 @@ namespace Sarand.Net.Standard.Base.CodeTypes public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (!StringUtil.IsEmpty(Code) && !Code.Equals(data.Code)) - throw new NotSupportedException(fn + " Code cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Code cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/Core/SacsDfn.cs b/SacsStandardBase/Base/Core/SacsDfn.cs index add4020..66a16b6 100644 --- a/SacsStandardBase/Base/Core/SacsDfn.cs +++ b/SacsStandardBase/Base/Core/SacsDfn.cs @@ -149,6 +149,7 @@ namespace Sarand.Net.Standard.Base.Core Bmp, Gif, Tif, + Svg, // Documents. Pdf, // Text documents. diff --git a/SacsStandardBase/Base/Email/SaEmailConsole.cs b/SacsStandardBase/Base/Email/SaEmailConsole.cs index 8783966..880dfc1 100644 --- a/SacsStandardBase/Base/Email/SaEmailConsole.cs +++ b/SacsStandardBase/Base/Email/SaEmailConsole.cs @@ -26,12 +26,10 @@ namespace Sarand.Net.Standard.Base.Email //------------------------------------------------------------------- public bool SendEmail(SaEmailData emailData) { - String fn = GetType().Name + ".SendEmail"; - // Validate email data. if (emailData.AddressesTo.IsEmpty()) { - SaLogger.Error(fn + " Unable to send email - To address not specified."); + SaLogger.Error($"{SysUtil.Fn} Unable to send email - To address not specified."); return false; } @@ -54,10 +52,10 @@ namespace Sarand.Net.Standard.Base.Email } catch (Exception exc) { - SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc)); + SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}"); return false; } - SaLogger.Info(fn + " Email sent to " + emailData.AddressesTo[0] + ". Subject: " + emailData.Subject); + SaLogger.Info($"{SysUtil.Fn} Email sent to {emailData.AddressesTo[0]}. Subject: {emailData.Subject}"); return true; } diff --git a/SacsStandardBase/Base/Helpers/SacsContentTypeHelper.cs b/SacsStandardBase/Base/Helpers/SacsContentTypeHelper.cs index 109d0b6..b47efa8 100644 --- a/SacsStandardBase/Base/Helpers/SacsContentTypeHelper.cs +++ b/SacsStandardBase/Base/Helpers/SacsContentTypeHelper.cs @@ -90,6 +90,7 @@ namespace Sarand.Net.Standard.Base.Helpers new ContentTypeData_Internal("bmp", "Windows OS/2 Bitmap Graphics", "image/bmp", Sacs.MimeType.Bmp), new ContentTypeData_Internal("gif", "Graphics Interchange Format (GIF)", "image/gif", Sacs.MimeType.Gif), new ContentTypeData_Internal("tif,tiff", "Tagged Image File Format (TIFF)", "image/tiff", Sacs.MimeType.Tif), + new ContentTypeData_Internal("svg", "Scalable Vector Graphics (SVG)", "image/svg+xml", Sacs.MimeType.Svg), // Documents. new ContentTypeData_Internal("pdf", "Adobe Portable Document Format (PDF)", "application/pdf", Sacs.MimeType.Pdf), // Text documents. @@ -140,7 +141,6 @@ namespace Sarand.Net.Standard.Base.Helpers new ContentTypeData_Internal("rar", "RAR archive", "application/vnd.rar"), new ContentTypeData_Internal("rtf", "Rich Text Format (RTF)", "application/rtf"), new ContentTypeData_Internal("sh", "Bourne shell script", "application/x-sh"), - new ContentTypeData_Internal("svg", "Scalable Vector Graphics (SVG)", "image/svg+xml"), new ContentTypeData_Internal("swf", "Small web format (SWF) or Adobe Flash document", "application/x-shockwave-flash"), new ContentTypeData_Internal("tar", "Tape Archive (TAR)", "application/x-tar"), new ContentTypeData_Internal("ts", "MPEG transport stream", "video/vnd.dlna.mpeg-tts"), diff --git a/SacsStandardBase/Base/Interfaces/SaInterface.cs b/SacsStandardBase/Base/Interfaces/SaInterface.cs index f8fda81..756c6b1 100644 --- a/SacsStandardBase/Base/Interfaces/SaInterface.cs +++ b/SacsStandardBase/Base/Interfaces/SaInterface.cs @@ -166,16 +166,15 @@ namespace Sarand.Net.Standard.Base.Interfaces public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (!StringUtil.IsEmpty(Context) && !Context.Equals(data.Context)) - throw new NotSupportedException(fn + " Context cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Context cannot be changed"); if ((int)Category >= 0 && (int)Category != (int)data.Category) - throw new NotSupportedException(fn + " Category cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Category cannot be changed"); if (Type >= 0 && Type != data.Type) - throw new NotSupportedException(fn + " Type cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Type cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/Interfaces/SaInterfaceDataItem.cs b/SacsStandardBase/Base/Interfaces/SaInterfaceDataItem.cs index 1752565..bed02c2 100644 --- a/SacsStandardBase/Base/Interfaces/SaInterfaceDataItem.cs +++ b/SacsStandardBase/Base/Interfaces/SaInterfaceDataItem.cs @@ -253,20 +253,19 @@ namespace Sarand.Net.Standard.Base.Interfaces public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (SysId.IsValid(InterfaceId) && SysId.ToInt(InterfaceId) != SysId.ToInt(data.InterfaceId)) - throw new NotSupportedException(fn + " Interface cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Interface cannot be changed"); if ((int)Direction > 0 && (int)Direction != (int)data.Direction) - throw new NotSupportedException(fn + " Direction cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Direction cannot be changed"); if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) - throw new NotSupportedException(fn + " Item type cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item type cannot be changed"); if (SysId.IsValid(ItemId.Id) && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id)) - throw new NotSupportedException(fn + " Item Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed"); if (!StringUtil.IsEmpty(ExternalReference) && !ExternalReference.Equals(data.ExternalReference)) - throw new NotSupportedException(fn + " External reference cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} External reference cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/Interfaces/SaInterfaceProcess.cs b/SacsStandardBase/Base/Interfaces/SaInterfaceProcess.cs index f7ec594..e79e03f 100644 --- a/SacsStandardBase/Base/Interfaces/SaInterfaceProcess.cs +++ b/SacsStandardBase/Base/Interfaces/SaInterfaceProcess.cs @@ -203,18 +203,17 @@ namespace Sarand.Net.Standard.Base.Interfaces public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (SysId.IsValid(InterfaceId) && SysId.ToInt(InterfaceId) != SysId.ToInt(data.InterfaceId)) - throw new NotSupportedException(fn + " Interface cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Interface cannot be changed"); if ((int)Direction > 0 && (int)Direction != (int)data.Direction) - throw new NotSupportedException(fn + " Direction cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Direction cannot be changed"); if (!StringUtil.IsEmpty(Reference) && !Reference.Equals(data.Reference)) - throw new NotSupportedException(fn + " Reference cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Reference cannot be changed"); if (Sequence > 0 && Sequence != data.Sequence) - throw new NotSupportedException(fn + " Sequence cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Sequence cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/Interfaces/SaInterfaceProcessDataItem.cs b/SacsStandardBase/Base/Interfaces/SaInterfaceProcessDataItem.cs index 63466b6..0b8488f 100644 --- a/SacsStandardBase/Base/Interfaces/SaInterfaceProcessDataItem.cs +++ b/SacsStandardBase/Base/Interfaces/SaInterfaceProcessDataItem.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Utils; namespace Sarand.Net.Standard.Base.Interfaces { @@ -137,16 +138,15 @@ namespace Sarand.Net.Standard.Base.Interfaces public Data GetData() { return data.Clone(); } public void SetData(Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (SysId.IsValid(InterfaceProcessId) && SysId.ToInt(InterfaceProcessId) != SysId.ToInt(data.InterfaceProcessId)) - throw new NotSupportedException(fn + " Interface Process cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Interface Process cannot be changed"); if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) - throw new NotSupportedException(fn + " Item type cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item type cannot be changed"); if (SysId.IsValid(ItemId.Id) && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id)) - throw new NotSupportedException(fn + " Item Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/Interfaces/SaInterfaceProcessMessage.cs b/SacsStandardBase/Base/Interfaces/SaInterfaceProcessMessage.cs index 5623a7f..efdc767 100644 --- a/SacsStandardBase/Base/Interfaces/SaInterfaceProcessMessage.cs +++ b/SacsStandardBase/Base/Interfaces/SaInterfaceProcessMessage.cs @@ -1,5 +1,6 @@ using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; @@ -163,12 +164,11 @@ namespace Sarand.Net.Standard.Base.Interfaces public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (SysId.IsValid(InterfaceProcessId) && SysId.ToInt(InterfaceProcessId) != SysId.ToInt(data.InterfaceProcessId)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/ItemData/SaItemData.cs b/SacsStandardBase/Base/ItemData/SaItemData.cs index 24bcec3..f667791 100644 --- a/SacsStandardBase/Base/ItemData/SaItemData.cs +++ b/SacsStandardBase/Base/ItemData/SaItemData.cs @@ -132,12 +132,11 @@ namespace Sarand.Net.Standard.Base.ItemData public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) - throw new NotSupportedException(fn + " Item type cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item type cannot be changed"); if (SysId.IsValid(ItemId.Id) && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id)) - throw new NotSupportedException(fn + " Item Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/ItemDocs/SaItemDoc.cs b/SacsStandardBase/Base/ItemDocs/SaItemDoc.cs index a621a88..eb866d2 100644 --- a/SacsStandardBase/Base/ItemDocs/SaItemDoc.cs +++ b/SacsStandardBase/Base/ItemDocs/SaItemDoc.cs @@ -180,17 +180,16 @@ namespace Sarand.Net.Standard.Base.ItemDocs public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) - throw new NotSupportedException(fn + " Item type cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item type cannot be changed"); if (SysId.IsValid(ItemId.Id) && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id)) - throw new NotSupportedException(fn + " Item Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed"); // Category. if ((int)data.Category < 1) data.Category = Category; if ((int)Category != 0 && Category != data.Category) - throw new NotSupportedException(fn + " Category cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Category cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/ItemOptions/SaItemOption.cs b/SacsStandardBase/Base/ItemOptions/SaItemOption.cs index 0647008..b427741 100644 --- a/SacsStandardBase/Base/ItemOptions/SaItemOption.cs +++ b/SacsStandardBase/Base/ItemOptions/SaItemOption.cs @@ -153,16 +153,15 @@ namespace Sarand.Net.Standard.Base.ItemOptions public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) - throw new NotSupportedException(fn + " Item type cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item type cannot be changed"); if (SysId.IsValid(ItemId.Id) && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id)) - throw new NotSupportedException(fn + " Item Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed"); if (!StringUtil.IsEmpty(Name) && !Name.Equals(data.Name)) - throw new NotSupportedException(fn + " Name cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Name cannot be changed"); if (!StringUtil.IsEmpty(Context) && !Context.Equals(data.Context)) - throw new NotSupportedException(fn + " Context cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Context cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/Procs/SaProcess_Base.cs b/SacsStandardBase/Base/Procs/SaProcess_Base.cs index 0d2f073..391d5da 100644 --- a/SacsStandardBase/Base/Procs/SaProcess_Base.cs +++ b/SacsStandardBase/Base/Procs/SaProcess_Base.cs @@ -294,7 +294,6 @@ namespace Sarand.Net.Standard.Base.Procs // Run process inline. public bool RunProcess() { - String fn = GetType().Name + ".RunProcess"; // Prepare process. bool runProcess = false; Reset(); @@ -313,7 +312,7 @@ namespace Sarand.Net.Standard.Base.Procs { String msg = exc.GetType().Name + ": " + exc.Message; AddErrorMessage(msg); - SaLogger.Error(fn + " ProcessStarting: " + msg + exc.GetStackEntries(6).Concat("", "\n\tat "), true); + SaLogger.Error($"{SysUtil.Fn} ProcessStarting: {msg}{exc.GetStackEntries(6).Concat("", "\n\tat ")}", true); } // Process running. @@ -326,7 +325,7 @@ namespace Sarand.Net.Standard.Base.Procs { String msg = exc.GetType().Name + ": " + exc.Message; AddErrorMessage(msg); - SaLogger.Error(fn + " " + msg + exc.GetStackEntries(6).Concat("", "\n\tat "), true); + SaLogger.Error($"{SysUtil.Fn} " + msg + exc.GetStackEntries(6).Concat("", "\n\tat "), true); } finally { @@ -347,7 +346,7 @@ namespace Sarand.Net.Standard.Base.Procs { String msg = exc.GetType().Name + ": " + exc.Message; AddErrorMessage(msg); - SaLogger.Error(fn + " ProcessCompleted: " + msg + exc.GetStackEntries(6).Concat("", "\n\tat "), true); + SaLogger.Error($"{SysUtil.Fn} ProcessCompleted: {msg}{exc.GetStackEntries(6).Concat("", "\n\tat ")}", true); } return runProcess; } diff --git a/SacsStandardBase/Base/ReferenceData/SaCurrency.cs b/SacsStandardBase/Base/ReferenceData/SaCurrency.cs index cd5e7ec..ab88476 100644 --- a/SacsStandardBase/Base/ReferenceData/SaCurrency.cs +++ b/SacsStandardBase/Base/ReferenceData/SaCurrency.cs @@ -186,10 +186,9 @@ namespace Sarand.Net.Standard.Base.ReferenceData public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/ReferenceData/SaLanguage.cs b/SacsStandardBase/Base/ReferenceData/SaLanguage.cs index 568ca83..bcf8dba 100644 --- a/SacsStandardBase/Base/ReferenceData/SaLanguage.cs +++ b/SacsStandardBase/Base/ReferenceData/SaLanguage.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Utils; namespace Sarand.Net.Standard.Base.ReferenceData { @@ -130,10 +131,9 @@ namespace Sarand.Net.Standard.Base.ReferenceData public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/ReferenceData/SaRegion.cs b/SacsStandardBase/Base/ReferenceData/SaRegion.cs index e93b81a..3cdd93d 100644 --- a/SacsStandardBase/Base/ReferenceData/SaRegion.cs +++ b/SacsStandardBase/Base/ReferenceData/SaRegion.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Utils; namespace Sarand.Net.Standard.Base.ReferenceData { @@ -131,10 +132,9 @@ namespace Sarand.Net.Standard.Base.ReferenceData public Data GetData() { return data.Clone(); } public void SetData(Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/ReferenceData/SaTaxCode.cs b/SacsStandardBase/Base/ReferenceData/SaTaxCode.cs index 6ce4aac..dd48cd2 100644 --- a/SacsStandardBase/Base/ReferenceData/SaTaxCode.cs +++ b/SacsStandardBase/Base/ReferenceData/SaTaxCode.cs @@ -197,12 +197,11 @@ namespace Sarand.Net.Standard.Base.ReferenceData public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (!StringUtil.IsEmpty(Code) && !Code.EqualsCI(data.Code)) - throw new NotSupportedException(fn + " Code cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Code cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/ReferenceData/SaUnitMeasure.cs b/SacsStandardBase/Base/ReferenceData/SaUnitMeasure.cs index b41e731..16156ea 100644 --- a/SacsStandardBase/Base/ReferenceData/SaUnitMeasure.cs +++ b/SacsStandardBase/Base/ReferenceData/SaUnitMeasure.cs @@ -214,12 +214,11 @@ namespace Sarand.Net.Standard.Base.ReferenceData public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if (!StringUtil.IsEmpty(Code) && !Code.EqualsCI(data.Code)) - throw new NotSupportedException(fn + " Codecannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Codecannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/Security/SaSecurityItem.cs b/SacsStandardBase/Base/Security/SaSecurityItem.cs index 86cfb9b..02da350 100644 --- a/SacsStandardBase/Base/Security/SaSecurityItem.cs +++ b/SacsStandardBase/Base/Security/SaSecurityItem.cs @@ -257,12 +257,11 @@ namespace Sarand.Net.Standard.Base.Security public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) - throw new NotSupportedException(fn + " Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed"); if ((int)data.ItemType > 0 && data.ItemType != ItemType) - throw new NotSupportedException(fn + " Item Type cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item Type cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } @@ -371,8 +370,6 @@ namespace Sarand.Net.Standard.Base.Security } public static String EncryptPassword (String password) { - //String fn = "SaSecurityItem.EncryptPassword"; - // We know this is not very water-tight, but it at least // hides the contents of the password from prying eyes. String toBeEncrypted = password; diff --git a/SacsStandardBase/Base/Security/SaSecurityLink.cs b/SacsStandardBase/Base/Security/SaSecurityLink.cs index e27fb2a..06514b9 100644 --- a/SacsStandardBase/Base/Security/SaSecurityLink.cs +++ b/SacsStandardBase/Base/Security/SaSecurityLink.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Utils; namespace Sarand.Net.Standard.Base.Security { @@ -165,14 +166,13 @@ namespace Sarand.Net.Standard.Base.Security public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(data.Id)) - throw new NotSupportedException(fn + " Id is not applicable for security links"); + throw new NotSupportedException($"{SysUtil.Fn} Id is not applicable for security links"); if (SysId.IsValid(data.ItemIdOwner) && SysId.ToInt(data.ItemIdOwner) != SysId.ToInt(ItemIdOwner)) - throw new NotSupportedException(fn + " Owner Item cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Owner Item cannot be changed"); if (SysId.IsValid(data.ItemIdTarget) && SysId.ToInt(data.ItemIdTarget) != SysId.ToInt(ItemIdTarget)) - throw new NotSupportedException(fn + " Target Item cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Target Item cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/UpdateLog/SaUpdateLogEntry.cs b/SacsStandardBase/Base/UpdateLog/SaUpdateLogEntry.cs index 6f86301..1443681 100644 --- a/SacsStandardBase/Base/UpdateLog/SaUpdateLogEntry.cs +++ b/SacsStandardBase/Base/UpdateLog/SaUpdateLogEntry.cs @@ -159,16 +159,15 @@ namespace Sarand.Net.Standard.Base.UpdateLog public Data GetData () { return data.Clone(); } public void SetData (Data data) { - String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) - throw new NotSupportedException(fn + " Item type cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item type cannot be changed"); if (SysId.IsValid(ItemId.Id) && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id)) - throw new NotSupportedException(fn + " Item Id cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed"); if (!StringUtil.IsEmpty(Attribute) && !Attribute.Equals(data.Attribute)) - throw new NotSupportedException(fn + " Attribute cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Attribute cannot be changed"); if (Logged != DateTime.MinValue && !Logged.Equals(data.Logged)) - throw new NotSupportedException(fn + " Logged date/time cannot be changed"); + throw new NotSupportedException($"{SysUtil.Fn} Logged date/time cannot be changed"); // Populate individual properties to ensure that 'Changed' indicator is kept up to date. this.data.PopulateFrom(data); } diff --git a/SacsStandardBase/Base/Utils/DictionaryUtil.cs b/SacsStandardBase/Base/Utils/DictionaryUtil.cs index fc1cf9a..83a9ac1 100644 --- a/SacsStandardBase/Base/Utils/DictionaryUtil.cs +++ b/SacsStandardBase/Base/Utils/DictionaryUtil.cs @@ -79,7 +79,7 @@ namespace Sarand.Net.Standard.Base.Utils /// Add entries from another dictionary. public static void AddRange(this Dictionary dict, Dictionary dictToAdd) { - dictToAdd.ForEach(x => dict.Add(x.Key, x.Value)); + dictToAdd.ForEach(x => dict[x.Key] = x.Value); } //------------------------------------------------------------------- diff --git a/SacsStandardBase/Base/Utils/ImageUtils.cs b/SacsStandardBase/Base/Utils/ImageUtils.cs index 8c4772d..1e51524 100644 --- a/SacsStandardBase/Base/Utils/ImageUtils.cs +++ b/SacsStandardBase/Base/Utils/ImageUtils.cs @@ -9,6 +9,7 @@ using SixLabors.ImageSharp.Processing; using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; namespace Sarand.Net.Standard.Base.Utils @@ -33,6 +34,21 @@ namespace Sarand.Net.Standard.Base.Utils public int Height { get; set; } } + //------------------------------------------------------------------- + public static bool IsSvg(byte[] imageData) + { + try + { + if (!imageData.Contains((byte)'<')) return false; + String imageText = Encoding.UTF8.GetString(imageData); + if (!imageText.ContainsCI(" /// Convert the data stream to an image and extract width and height. @@ -41,7 +57,6 @@ namespace Sarand.Net.Standard.Base.Utils /// Flag to indicate whether interpretation of image data succeeded. public static ImageConfig VerifyImageData(byte[] imageData) { - String fn = className + ".VerifyImageData"; ImageConfig imageConfig = new ImageConfig(); imageConfig.ImageData = imageData; try @@ -60,11 +75,30 @@ namespace Sarand.Net.Standard.Base.Utils } catch (Exception exc) { - SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); + SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}"); } return imageConfig; } + //------------------------------------------------------------------- + /// + /// Convert the SVG data stream to an image and extract width and height. + /// + /// + /// Flag to indicate whether interpretation of image data succeeded. + public static ImageConfig VerifySvgImageData(byte[] imageData) + { + ImageConfig imageConfig = new ImageConfig(); + imageConfig.ImageData = imageData; + imageConfig.ImageFormatName = "svg"; + imageConfig.DefaultMimeType = "svg"; + imageConfig.MimeType = EnumUtil.ParseEnum(imageConfig.ImageFormatName, Sacs.MimeType.Unknown); + imageConfig.Width = 0; + imageConfig.Height = 0; + imageConfig.ValidImage = true; + return imageConfig; + } + //------------------------------------------------------------------- // Load from byte array. /// Convert the data stream to an image. @@ -107,7 +141,7 @@ namespace Sarand.Net.Standard.Base.Utils /// Flag to indicate whether operation was successful. public static bool ConstrainImage(ImageConfig config, ushort widthMax, ushort heightMax) { - String fn = className + ".ConstrainImage"; + if (config.Width == 0 || config.Height == 0) return true; if (widthMax < 1 || heightMax < 1) return false; if (config.Width <= widthMax && config.Height <= heightMax) return true; config.ValidImage = false; @@ -128,7 +162,7 @@ namespace Sarand.Net.Standard.Base.Utils } catch (Exception exc) { - SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); + SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}"); } return config.ValidImage; diff --git a/SacsStandardBase/Base/Utils/NewtonsoftJsonUtil.cs b/SacsStandardBase/Base/Utils/NewtonsoftJsonUtil.cs index 11ba571..a376ec3 100644 --- a/SacsStandardBase/Base/Utils/NewtonsoftJsonUtil.cs +++ b/SacsStandardBase/Base/Utils/NewtonsoftJsonUtil.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,6 +15,11 @@ namespace Sarand.Net.Standard.Base.Utils // Extracting. //------------------------------------------------------------------- + public static String SerializeObject (Object data, JsonSerializerSettings settings = null) + { + return JsonConvert.SerializeObject (data, settings); + } + //------------------------------------------------------------------- // Parsing. //------------------------------------------------------------------- diff --git a/SacsStandardBase/SacsStandardBase.csproj b/SacsStandardBase/SacsStandardBase.csproj index cd7772e..8eed933 100644 --- a/SacsStandardBase/SacsStandardBase.csproj +++ b/SacsStandardBase/SacsStandardBase.csproj @@ -7,7 +7,7 @@ - + diff --git a/SacsStandardDbas/Dbas/Base/DatabaseDefinitionGenerator.cs b/SacsStandardDbas/Dbas/Base/DatabaseDefinitionGenerator.cs index 4023fa8..42da43a 100644 --- a/SacsStandardDbas/Dbas/Base/DatabaseDefinitionGenerator.cs +++ b/SacsStandardDbas/Dbas/Base/DatabaseDefinitionGenerator.cs @@ -46,12 +46,12 @@ namespace Sarand.Net.Standard.Dbas.Base public class SchemaData { // Tables to be included (all others excluded) or those to be excluded. - public HashSet Tables_Included { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); - public HashSet Tables_Excluded { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); + public HashSet Tables_Included { get; } = new HashSet(StringComparer.OrdinalIgnoreCase); + public HashSet Tables_Excluded { get; } = new HashSet(StringComparer.OrdinalIgnoreCase); // Schema capitalisation - for class name prefix etc - where capitalising first letter is insufficient. - public Dictionary SchemaNameCapitalisation { get; } = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + public Dictionary SchemaNameCapitalisation { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); // Alternative table names. - public Dictionary> AlternativeTableNames { get; } = new Dictionary>(StringComparer.InvariantCultureIgnoreCase); + public Dictionary> AlternativeTableNames { get; } = new Dictionary>(StringComparer.OrdinalIgnoreCase); public void AddAlternativeTableName(String tableName, String tableNameAlternative) { if (!AlternativeTableNames.ContainsKey(tableName)) AlternativeTableNames[tableName] = new List(); diff --git a/SacsStandardDbas/Dbas/CodeTypes/SaCodeTypeDbDfnGenerator.cs b/SacsStandardDbas/Dbas/CodeTypes/SaCodeTypeDbDfnGenerator.cs index ee21a23..c18025c 100644 --- a/SacsStandardDbas/Dbas/CodeTypes/SaCodeTypeDbDfnGenerator.cs +++ b/SacsStandardDbas/Dbas/CodeTypes/SaCodeTypeDbDfnGenerator.cs @@ -22,8 +22,6 @@ namespace Sarand.Net.Standard.Dbas.CodeType /// public static bool Generate(String connectionString) { - String fn = className + ".Generate"; - // Locate output folder: String directory = GetOutputFolder(); if (String.IsNullOrEmpty(directory) || !FileUtil.IsDirectory(directory)) return false; @@ -41,7 +39,7 @@ namespace Sarand.Net.Standard.Dbas.CodeType } catch (Exception exc) { - SaLogger.Error($"{fn} {ExceptionUtil.GetLogMessage(exc, "generating database definition")}"); + SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc, "generating database definition")}"); } return false; } @@ -81,10 +79,9 @@ namespace Sarand.Net.Standard.Dbas.CodeType //------------------------------------------------------------------- private static String GetOutputFolder() { - String fn = className + ".GetOutputFolder"; String assemblyDirectory = FileUtil.GetParentDirectory((Assembly.GetAssembly(typeof(DatabaseDefinitionGenerator)).Location)); String directory = assemblyDirectory; - SaLogger.Debug($"{fn} Assembly folder: {directory}"); + SaLogger.Debug($"{SysUtil.Fn} Assembly folder: {directory}"); // Locate the parent of the 'Workspace' solution root folder. String projectFolder = "Workspace"; while (!String.IsNullOrEmpty(directory)) @@ -95,15 +92,15 @@ namespace Sarand.Net.Standard.Dbas.CodeType } if (String.IsNullOrEmpty(directory)) { - SaLogger.Error($"{fn} Failed to find '{projectFolder}' solution root folder in assembly path: {assemblyDirectory}"); + SaLogger.Error($"{SysUtil.Fn} Failed to find '{projectFolder}' solution root folder in assembly path: {assemblyDirectory}"); return String.Empty; } // Code files are generated to '..\Database\Generated\CodeTypes\' folder. directory = Path.Combine(directory, "Database", "Generated", "CodeTypes"); - SaLogger.Debug($"{fn} Output folder: {directory}"); + SaLogger.Debug($"{SysUtil.Fn} Output folder: {directory}"); if (!FileUtil.ValidateDirectory(directory, true)) { - SaLogger.Error($"{fn} Output folder not found: {directory}"); + SaLogger.Error($"{SysUtil.Fn} Output folder not found: {directory}"); return String.Empty; } return directory; diff --git a/SacsStandardDbas/Dbas/Data/DbDataItem.cs b/SacsStandardDbas/Dbas/Data/DbDataItem.cs index afeeac2..6b1c730 100644 --- a/SacsStandardDbas/Dbas/Data/DbDataItem.cs +++ b/SacsStandardDbas/Dbas/Data/DbDataItem.cs @@ -258,7 +258,6 @@ namespace Sarand.Net.Standard.Dbas.Data /// protected int GetColumnOrdinal(DbDataReader dbDataReader, String columnName) { - String fn = GetType().Name + ".GetColumnOrdinal"; // Identify whether the specified column name is in the list of columns in the results set. // NB Efficient as doesn't load the table schema and avoids logging of exception. // Ref. https://stackoverflow.com/questions/373230/check-for-column-name-in-a-sqldatareader-object @@ -268,7 +267,7 @@ namespace Sarand.Net.Standard.Dbas.Data // Invalid column name for result set. if (DbInfo != null && !ColumnExists(columnName)) LogMissingColumn(columnName); - else SaLogger.Warn(fn + " Column not found in result set: '" + columnName + "'"); + else SaLogger.Warn($"{SysUtil.Fn} Column not found in result set: '{columnName}'"); return -1; /* @@ -290,10 +289,10 @@ namespace Sarand.Net.Standard.Dbas.Data { missingColumns.Add(columnIdentifier); // Message is only logged on first occurence. - SaLogger.Debug(fn + " Column not found on database: " + columnIdentifier); + SaLogger.Debug($"{SysUtil.Fn} Column not found on database: {columnIdentifier}"); } } - else SaLogger.Warn(fn + " Column not found in result set: '" + columnName + "'"); + else SaLogger.Warn($"{SysUtil.Fn} Column not found in result set: '{columnName}'"); return -1; } } diff --git a/SacsStandardDbas/Dbas/Data/DbResultSet_DataReader.cs b/SacsStandardDbas/Dbas/Data/DbResultSet_DataReader.cs index a6aa337..ce75840 100644 --- a/SacsStandardDbas/Dbas/Data/DbResultSet_DataReader.cs +++ b/SacsStandardDbas/Dbas/Data/DbResultSet_DataReader.cs @@ -78,17 +78,16 @@ namespace Sarand.Net.Standard.Dbas.Data public static DbResultSet_DataReader ExecuteQuery (ISacsDatabase database, String query) { DataMembers data = new DataMembers(database, query); - String fn = typeof(DbResultSet_DataReader).Name + ".ExecuteQuery"; String errorState = ""; try { ExecuteQuery_Internal(data); - Log(fn, "Query: " + data.Query + (data.DbDataReader.HasRows ? " [has rows]" : " [no rows]"), SaMessageLevel.Debug); + Log(SysUtil.Fn, "Query: " + data.Query + (data.DbDataReader.HasRows ? " [has rows]" : " [no rows]"), SaMessageLevel.Debug); } catch (Exception exc) { errorState = ExceptionUtil.GetErrorStateMessage(exc); - SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc, 6) + "\n\t Query: " + query, true); + SaLogger.Warn(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc, 6) + "\n\t Query: " + query, true); } DbResultSet_DataReader resultSet = new DbResultSet_DataReader (data); resultSet.SetErrorState(errorState); @@ -97,7 +96,6 @@ namespace Sarand.Net.Standard.Dbas.Data public static async Task ExecuteQueryAsync (ISacsDatabase database, String query) { DataMembers data = new DataMembers(database, query); - String fn = typeof(DbResultSet_DataReader).Name + ".ExecuteQueryAsync"; String errorState = ""; try { @@ -107,12 +105,12 @@ namespace Sarand.Net.Standard.Dbas.Data data.DbCommand.CommandText = data.Database.GetSelectQueryPrefix() + data.Query; data.DbDataReader = await data.DbCommand.ExecuteReaderAsync(); data.PopulateColumns(); - Log(fn, "Query: " + data.Query + (data.DbDataReader.HasRows ? " [has rows]" : " [no rows]"), SaMessageLevel.Debug); + Log(SysUtil.Fn, "Query: " + data.Query + (data.DbDataReader.HasRows ? " [has rows]" : " [no rows]"), SaMessageLevel.Debug); } catch (Exception exc) { errorState = ExceptionUtil.GetErrorStateMessage(exc); - SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc, 6) + "\n\t Query: " + query, true); + SaLogger.Warn(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc, 6) + "\n\t Query: " + query, true); } DbResultSet_DataReader resultSet = new DbResultSet_DataReader (data); resultSet.SetErrorState(errorState); diff --git a/SacsStandardDbas/Dbas/Data/DbResultSet_DataTableReader.cs b/SacsStandardDbas/Dbas/Data/DbResultSet_DataTableReader.cs index 99e3234..fbcf9b6 100644 --- a/SacsStandardDbas/Dbas/Data/DbResultSet_DataTableReader.cs +++ b/SacsStandardDbas/Dbas/Data/DbResultSet_DataTableReader.cs @@ -4,6 +4,7 @@ using System.Data.Common; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Dbas.Base; namespace Sarand.Net.Standard.Dbas.Data @@ -32,7 +33,6 @@ namespace Sarand.Net.Standard.Dbas.Data private void ExecuteQuery () { ClearErrorState(); - String fn = GetType().Name + ".ExecuteQuery"; Close(); try { @@ -44,12 +44,12 @@ namespace Sarand.Net.Standard.Dbas.Data DataTable dataTable = new DataTable(); dbDataAdapter.Fill(dataTable); dataTableReader = new DataTableReader(dataTable); - Log(fn, GetType().Name + ".ExecuteQuery Query: " + query + (HasRows ? " [has rows]" : " [no rows]"), SaMessageLevel.Debug); + Log(SysUtil.Fn, GetType().Name + ".ExecuteQuery Query: " + query + (HasRows ? " [has rows]" : " [no rows]"), SaMessageLevel.Debug); } catch (Exception exc) { SetErrorState(exc.GetType().Name + ": " + exc.Message); - SaLogger.Warn(fn + " " + exc.GetType().Name + ": " + exc.Message + "\n\t Query: " + query, true); + SaLogger.Warn(SysUtil.Fn + " " + exc.GetType().Name + ": " + exc.Message + "\n\t Query: " + query, true); } } //------------------------------------------------------------------- diff --git a/SacsStandardDbas/Dbas/Data/SacsDatabaseOdbc.cs b/SacsStandardDbas/Dbas/Data/SacsDatabaseOdbc.cs index 0c191f0..e972b3d 100644 --- a/SacsStandardDbas/Dbas/Data/SacsDatabaseOdbc.cs +++ b/SacsStandardDbas/Dbas/Data/SacsDatabaseOdbc.cs @@ -484,13 +484,13 @@ namespace Sarand.Net.Standard.Dbas.Data else if (colName.EqualsCI("REMARKS")) remarks = value; else - SaLogger.Warn(SysUtil.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_"))) { #if DEBUG - //SaLogger.Trace(fn+" Database="+database+", Schema="+schema+", Table="+tableName+", Type="+ type); + //SaLogger.Trace($"{SysUtil.Fn} Database={database}, Schema={schema}, Table={tableName}, Type={type}"); #endif tables.Add(new DbDfnTable(schema, tableName, remarks)); } @@ -507,7 +507,7 @@ namespace Sarand.Net.Standard.Dbas.Data //------------------------------------------------------------------- private void PopulateTableColumns(DbConnection dbConnection, DbDfnTable table) { - if (SacsSystem.DebugMode) SaLogger.Debug(SysUtil.Fn + " Table: " + table.Name); + if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Table: {table.Name}"); short columnPos = 0; String[] restrictions = new String[] { null, table.Schema, table.Name, null }; // database, owner, table name, column name using (DataTable columnSchema = dbConnection.GetSchema(OdbcMetaDataCollectionNames.Columns, restrictions)) diff --git a/SacsStandardDbas/SacsStandardDbas.csproj b/SacsStandardDbas/SacsStandardDbas.csproj index 831b055..d0a00d8 100644 --- a/SacsStandardDbas/SacsStandardDbas.csproj +++ b/SacsStandardDbas/SacsStandardDbas.csproj @@ -10,7 +10,7 @@ - +