Saxonite 1.2.11.12

This commit is contained in:
Andy Howard
2024-08-20 17:51:51 +01:00
parent 12aa285f32
commit 2eb778ac17
36 changed files with 149 additions and 121 deletions
@@ -319,6 +319,18 @@ namespace Sacs.Web.Components
public String Code { get; set; } public String Code { get; set; }
public String Desc { get; set; } public String Desc { get; set; }
} }
/// <summary>Statistics Caption/Value pair.</summary>
public class StatData : AjaxResponse_Base
{
public String Caption { get; set; }
public String Value { get; set; }
}
/// <summary>Statistics Group.</summary>
public class StatsGroupData : AjaxResponse_Base
{
public String Caption { get; set; }
public List<StatData> Stats { get; } = new List<StatData>();
}
//--------------------------------------------------------------- //---------------------------------------------------------------
// Form data. // Form data.
@@ -439,15 +439,14 @@ namespace Sarand.Net.Standard.Base.Bus
// Populate data item - only once on construction. // Populate data item - only once on construction.
protected void SetData(Data data) protected void SetData(Data data)
{ {
String fn = GetType().Name + ".SetData";
// Can only be replaced if currently internal class. // Can only be replaced if currently internal class.
if (this.data.GetType() != typeof(Data)) 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 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; if (ItemHasId && SysId.IsValid(Id) && !SysId.IsValid(data.Id)) data.Id = Id;
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (ItemHasId && SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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.PopulateTo(data);
this.data = data; this.data = data;
} }
+2 -2
View File
@@ -209,10 +209,10 @@ namespace Sarand.Net.Standard.Base.Bus
/// <param name="delimiter"></param> /// <param name="delimiter"></param>
/// <param name="ignoreInvalid"></param> /// <param name="ignoreInvalid"></param>
/// <returns></returns> /// <returns></returns>
public static String Concat(this List<SysId> values, String delimiter, bool ignoreInvalid = true) public static String Concat(this ICollection<SysId> values, String delimiter, bool ignoreInvalid = true)
{ {
List<String> ids = new List<string>(); List<String> ids = new List<string>();
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()); ids.Add(id.ToString());
return ids.Concat(delimiter); return ids.Concat(delimiter);
} }
+2 -3
View File
@@ -162,12 +162,11 @@ namespace Sarand.Net.Standard.Base.CodeTypes
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
string fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -154,12 +154,11 @@ namespace Sarand.Net.Standard.Base.CodeTypes
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
+1
View File
@@ -149,6 +149,7 @@ namespace Sarand.Net.Standard.Base.Core
Bmp, Bmp,
Gif, Gif,
Tif, Tif,
Svg,
// Documents. // Documents.
Pdf, Pdf,
// Text documents. // Text documents.
@@ -26,12 +26,10 @@ namespace Sarand.Net.Standard.Base.Email
//------------------------------------------------------------------- //-------------------------------------------------------------------
public bool SendEmail(SaEmailData emailData) public bool SendEmail(SaEmailData emailData)
{ {
String fn = GetType().Name + ".SendEmail";
// Validate email data. // Validate email data.
if (emailData.AddressesTo.IsEmpty()) 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; return false;
} }
@@ -54,10 +52,10 @@ namespace Sarand.Net.Standard.Base.Email
} }
catch (Exception exc) catch (Exception exc)
{ {
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc)); SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}");
return false; 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; return true;
} }
@@ -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("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("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("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. // Documents.
new ContentTypeData_Internal("pdf", "Adobe Portable Document Format (PDF)", "application/pdf", Sacs.MimeType.Pdf), new ContentTypeData_Internal("pdf", "Adobe Portable Document Format (PDF)", "application/pdf", Sacs.MimeType.Pdf),
// Text documents. // Text documents.
@@ -140,7 +141,6 @@ namespace Sarand.Net.Standard.Base.Helpers
new ContentTypeData_Internal("rar", "RAR archive", "application/vnd.rar"), new ContentTypeData_Internal("rar", "RAR archive", "application/vnd.rar"),
new ContentTypeData_Internal("rtf", "Rich Text Format (RTF)", "application/rtf"), new ContentTypeData_Internal("rtf", "Rich Text Format (RTF)", "application/rtf"),
new ContentTypeData_Internal("sh", "Bourne shell script", "application/x-sh"), 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("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("tar", "Tape Archive (TAR)", "application/x-tar"),
new ContentTypeData_Internal("ts", "MPEG transport stream", "video/vnd.dlna.mpeg-tts"), new ContentTypeData_Internal("ts", "MPEG transport stream", "video/vnd.dlna.mpeg-tts"),
@@ -166,16 +166,15 @@ namespace Sarand.Net.Standard.Base.Interfaces
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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) 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) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -253,20 +253,19 @@ namespace Sarand.Net.Standard.Base.Interfaces
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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) 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) 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)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -203,18 +203,17 @@ namespace Sarand.Net.Standard.Base.Interfaces
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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) 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)) 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) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
namespace Sarand.Net.Standard.Base.Interfaces namespace Sarand.Net.Standard.Base.Interfaces
{ {
@@ -137,16 +138,15 @@ namespace Sarand.Net.Standard.Base.Interfaces
public Data GetData() { return data.Clone(); } public Data GetData() { return data.Clone(); }
public void SetData(Data data) public void SetData(Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -1,5 +1,6 @@
using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -163,12 +164,11 @@ namespace Sarand.Net.Standard.Base.Interfaces
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
+2 -3
View File
@@ -132,12 +132,11 @@ namespace Sarand.Net.Standard.Base.ItemData
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
+3 -4
View File
@@ -180,17 +180,16 @@ namespace Sarand.Net.Standard.Base.ItemDocs
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) 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)) 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. // Category.
if ((int)data.Category < 1) if ((int)data.Category < 1)
data.Category = Category; data.Category = Category;
if ((int)Category != 0 && Category != data.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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -153,16 +153,15 @@ namespace Sarand.Net.Standard.Base.ItemOptions
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) 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)) 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)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -294,7 +294,6 @@ namespace Sarand.Net.Standard.Base.Procs
// Run process inline. // Run process inline.
public bool RunProcess() public bool RunProcess()
{ {
String fn = GetType().Name + ".RunProcess";
// Prepare process. // Prepare process.
bool runProcess = false; bool runProcess = false;
Reset(); Reset();
@@ -313,7 +312,7 @@ namespace Sarand.Net.Standard.Base.Procs
{ {
String msg = exc.GetType().Name + ": " + exc.Message; String msg = exc.GetType().Name + ": " + exc.Message;
AddErrorMessage(msg); 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. // Process running.
@@ -326,7 +325,7 @@ namespace Sarand.Net.Standard.Base.Procs
{ {
String msg = exc.GetType().Name + ": " + exc.Message; String msg = exc.GetType().Name + ": " + exc.Message;
AddErrorMessage(msg); 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 finally
{ {
@@ -347,7 +346,7 @@ namespace Sarand.Net.Standard.Base.Procs
{ {
String msg = exc.GetType().Name + ": " + exc.Message; String msg = exc.GetType().Name + ": " + exc.Message;
AddErrorMessage(msg); 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; return runProcess;
} }
@@ -186,10 +186,9 @@ namespace Sarand.Net.Standard.Base.ReferenceData
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Utils;
namespace Sarand.Net.Standard.Base.ReferenceData namespace Sarand.Net.Standard.Base.ReferenceData
{ {
@@ -130,10 +131,9 @@ namespace Sarand.Net.Standard.Base.ReferenceData
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Utils;
namespace Sarand.Net.Standard.Base.ReferenceData namespace Sarand.Net.Standard.Base.ReferenceData
{ {
@@ -131,10 +132,9 @@ namespace Sarand.Net.Standard.Base.ReferenceData
public Data GetData() { return data.Clone(); } public Data GetData() { return data.Clone(); }
public void SetData(Data data) public void SetData(Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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); this.data.PopulateFrom(data);
} }
@@ -197,12 +197,11 @@ namespace Sarand.Net.Standard.Base.ReferenceData
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -214,12 +214,11 @@ namespace Sarand.Net.Standard.Base.ReferenceData
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -257,12 +257,11 @@ namespace Sarand.Net.Standard.Base.Security
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) 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) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -371,8 +370,6 @@ namespace Sarand.Net.Standard.Base.Security
} }
public static String EncryptPassword (String password) public static String EncryptPassword (String password)
{ {
//String fn = "SaSecurityItem.EncryptPassword";
// We know this is not very water-tight, but it at least // We know this is not very water-tight, but it at least
// hides the contents of the password from prying eyes. // hides the contents of the password from prying eyes.
String toBeEncrypted = password; String toBeEncrypted = password;
@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Utils;
namespace Sarand.Net.Standard.Base.Security namespace Sarand.Net.Standard.Base.Security
{ {
@@ -165,14 +166,13 @@ namespace Sarand.Net.Standard.Base.Security
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (SysId.IsValid(data.Id)) 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)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -159,16 +159,15 @@ namespace Sarand.Net.Standard.Base.UpdateLog
public Data GetData () { return data.Clone(); } public Data GetData () { return data.Clone(); }
public void SetData (Data data) public void SetData (Data data)
{ {
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified. // Properties that cannot be changed if previously specified.
if (ItemId.Type >= 0 && ItemId.Type != data.ItemId.Type) 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)) 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)) 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)) 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. // Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data); this.data.PopulateFrom(data);
} }
@@ -79,7 +79,7 @@ namespace Sarand.Net.Standard.Base.Utils
/// <summary>Add entries from another dictionary.</summary> /// <summary>Add entries from another dictionary.</summary>
public static void AddRange<TKey, TValue>(this Dictionary<TKey, TValue> dict, Dictionary<TKey, TValue> dictToAdd) public static void AddRange<TKey, TValue>(this Dictionary<TKey, TValue> dict, Dictionary<TKey, TValue> dictToAdd)
{ {
dictToAdd.ForEach(x => dict.Add(x.Key, x.Value)); dictToAdd.ForEach(x => dict[x.Key] = x.Value);
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
+38 -4
View File
@@ -9,6 +9,7 @@ using SixLabors.ImageSharp.Processing;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
namespace Sarand.Net.Standard.Base.Utils namespace Sarand.Net.Standard.Base.Utils
@@ -33,6 +34,21 @@ namespace Sarand.Net.Standard.Base.Utils
public int Height { get; set; } 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("<svg")) return false;
if (!imageText.ContainsCI(" xmlns=\"http://www.w3.org/2000/svg\"")) return false;
return true;
}
catch (Exception) { }
return false;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
/// <summary> /// <summary>
/// Convert the data stream to an image and extract width and height. /// Convert the data stream to an image and extract width and height.
@@ -41,7 +57,6 @@ namespace Sarand.Net.Standard.Base.Utils
/// <returns>Flag to indicate whether interpretation of image data succeeded.</returns> /// <returns>Flag to indicate whether interpretation of image data succeeded.</returns>
public static ImageConfig VerifyImageData(byte[] imageData) public static ImageConfig VerifyImageData(byte[] imageData)
{ {
String fn = className + ".VerifyImageData";
ImageConfig imageConfig = new ImageConfig(); ImageConfig imageConfig = new ImageConfig();
imageConfig.ImageData = imageData; imageConfig.ImageData = imageData;
try try
@@ -60,11 +75,30 @@ namespace Sarand.Net.Standard.Base.Utils
} }
catch (Exception exc) catch (Exception exc)
{ {
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}");
} }
return imageConfig; return imageConfig;
} }
//-------------------------------------------------------------------
/// <summary>
/// Convert the SVG data stream to an image and extract width and height.
/// </summary>
/// <param name="imageData"></param>
/// <returns>Flag to indicate whether interpretation of image data succeeded.</returns>
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. // Load from byte array.
/// <summary>Convert the data stream to an image.</summary> /// <summary>Convert the data stream to an image.</summary>
@@ -107,7 +141,7 @@ namespace Sarand.Net.Standard.Base.Utils
/// <returns>Flag to indicate whether operation was successful.</returns> /// <returns>Flag to indicate whether operation was successful.</returns>
public static bool ConstrainImage(ImageConfig config, ushort widthMax, ushort heightMax) 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 (widthMax < 1 || heightMax < 1) return false;
if (config.Width <= widthMax && config.Height <= heightMax) return true; if (config.Width <= widthMax && config.Height <= heightMax) return true;
config.ValidImage = false; config.ValidImage = false;
@@ -128,7 +162,7 @@ namespace Sarand.Net.Standard.Base.Utils
} }
catch (Exception exc) catch (Exception exc)
{ {
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}");
} }
return config.ValidImage; return config.ValidImage;
@@ -1,4 +1,5 @@
using System; using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -14,6 +15,11 @@ namespace Sarand.Net.Standard.Base.Utils
// Extracting. // Extracting.
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static String SerializeObject (Object data, JsonSerializerSettings settings = null)
{
return JsonConvert.SerializeObject (data, settings);
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Parsing. // Parsing.
//------------------------------------------------------------------- //-------------------------------------------------------------------
+1 -1
View File
@@ -7,7 +7,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CsvHelper" Version="19.0.0" /> <PackageReference Include="CsvHelper" Version="19.0.0" />
<PackageReference Include="MailKit" Version="4.6.0" /> <PackageReference Include="MailKit" Version="4.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" /> <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
@@ -46,12 +46,12 @@ namespace Sarand.Net.Standard.Dbas.Base
public class SchemaData public class SchemaData
{ {
// Tables to be included (all others excluded) or those to be excluded. // Tables to be included (all others excluded) or those to be excluded.
public HashSet<String> Tables_Included { get; } = new HashSet<String>(StringComparer.InvariantCultureIgnoreCase); public HashSet<String> Tables_Included { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
public HashSet<String> Tables_Excluded { get; } = new HashSet<String>(StringComparer.InvariantCultureIgnoreCase); public HashSet<String> Tables_Excluded { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
// Schema capitalisation - for class name prefix etc - where capitalising first letter is insufficient. // Schema capitalisation - for class name prefix etc - where capitalising first letter is insufficient.
public Dictionary<String, String> SchemaNameCapitalisation { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); public Dictionary<String, String> SchemaNameCapitalisation { get; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
// Alternative table names. // Alternative table names.
public Dictionary<String, List<String>> AlternativeTableNames { get; } = new Dictionary<string, List<string>>(StringComparer.InvariantCultureIgnoreCase); public Dictionary<String, List<String>> AlternativeTableNames { get; } = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
public void AddAlternativeTableName(String tableName, String tableNameAlternative) public void AddAlternativeTableName(String tableName, String tableNameAlternative)
{ {
if (!AlternativeTableNames.ContainsKey(tableName)) AlternativeTableNames[tableName] = new List<string>(); if (!AlternativeTableNames.ContainsKey(tableName)) AlternativeTableNames[tableName] = new List<string>();
@@ -22,8 +22,6 @@ namespace Sarand.Net.Standard.Dbas.CodeType
/// </summary> /// </summary>
public static bool Generate(String connectionString) public static bool Generate(String connectionString)
{ {
String fn = className + ".Generate";
// Locate output folder: // Locate output folder:
String directory = GetOutputFolder(); String directory = GetOutputFolder();
if (String.IsNullOrEmpty(directory) || !FileUtil.IsDirectory(directory)) return false; if (String.IsNullOrEmpty(directory) || !FileUtil.IsDirectory(directory)) return false;
@@ -41,7 +39,7 @@ namespace Sarand.Net.Standard.Dbas.CodeType
} }
catch (Exception exc) catch (Exception exc)
{ {
SaLogger.Error($"{fn} {ExceptionUtil.GetLogMessage(exc, "generating database definition")}"); SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc, "generating database definition")}");
} }
return false; return false;
} }
@@ -81,10 +79,9 @@ namespace Sarand.Net.Standard.Dbas.CodeType
//------------------------------------------------------------------- //-------------------------------------------------------------------
private static String GetOutputFolder() private static String GetOutputFolder()
{ {
String fn = className + ".GetOutputFolder";
String assemblyDirectory = FileUtil.GetParentDirectory((Assembly.GetAssembly(typeof(DatabaseDefinitionGenerator)).Location)); String assemblyDirectory = FileUtil.GetParentDirectory((Assembly.GetAssembly(typeof(DatabaseDefinitionGenerator)).Location));
String directory = assemblyDirectory; 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. // Locate the parent of the 'Workspace' solution root folder.
String projectFolder = "Workspace"; String projectFolder = "Workspace";
while (!String.IsNullOrEmpty(directory)) while (!String.IsNullOrEmpty(directory))
@@ -95,15 +92,15 @@ namespace Sarand.Net.Standard.Dbas.CodeType
} }
if (String.IsNullOrEmpty(directory)) 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; return String.Empty;
} }
// Code files are generated to '..\Database\Generated\CodeTypes\' folder. // Code files are generated to '..\Database\Generated\CodeTypes\' folder.
directory = Path.Combine(directory, "Database", "Generated", "CodeTypes"); 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)) 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 String.Empty;
} }
return directory; return directory;
+3 -4
View File
@@ -258,7 +258,6 @@ namespace Sarand.Net.Standard.Dbas.Data
/// </summary> /// </summary>
protected int GetColumnOrdinal(DbDataReader dbDataReader, String columnName) 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. // 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. // 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 // 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. // Invalid column name for result set.
if (DbInfo != null && !ColumnExists(columnName)) if (DbInfo != null && !ColumnExists(columnName))
LogMissingColumn(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; return -1;
/* /*
@@ -290,10 +289,10 @@ namespace Sarand.Net.Standard.Dbas.Data
{ {
missingColumns.Add(columnIdentifier); missingColumns.Add(columnIdentifier);
// Message is only logged on first occurence. // 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; return -1;
} }
} }
@@ -78,17 +78,16 @@ namespace Sarand.Net.Standard.Dbas.Data
public static DbResultSet_DataReader ExecuteQuery (ISacsDatabase database, String query) public static DbResultSet_DataReader ExecuteQuery (ISacsDatabase database, String query)
{ {
DataMembers data = new DataMembers(database, query); DataMembers data = new DataMembers(database, query);
String fn = typeof(DbResultSet_DataReader).Name + ".ExecuteQuery";
String errorState = ""; String errorState = "";
try try
{ {
ExecuteQuery_Internal(data); 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) catch (Exception exc)
{ {
errorState = ExceptionUtil.GetErrorStateMessage(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); DbResultSet_DataReader resultSet = new DbResultSet_DataReader (data);
resultSet.SetErrorState(errorState); resultSet.SetErrorState(errorState);
@@ -97,7 +96,6 @@ namespace Sarand.Net.Standard.Dbas.Data
public static async Task<DbResultSet_DataReader> ExecuteQueryAsync (ISacsDatabase database, String query) public static async Task<DbResultSet_DataReader> ExecuteQueryAsync (ISacsDatabase database, String query)
{ {
DataMembers data = new DataMembers(database, query); DataMembers data = new DataMembers(database, query);
String fn = typeof(DbResultSet_DataReader).Name + ".ExecuteQueryAsync";
String errorState = ""; String errorState = "";
try try
{ {
@@ -107,12 +105,12 @@ namespace Sarand.Net.Standard.Dbas.Data
data.DbCommand.CommandText = data.Database.GetSelectQueryPrefix() + data.Query; data.DbCommand.CommandText = data.Database.GetSelectQueryPrefix() + data.Query;
data.DbDataReader = await data.DbCommand.ExecuteReaderAsync(); data.DbDataReader = await data.DbCommand.ExecuteReaderAsync();
data.PopulateColumns(); 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) catch (Exception exc)
{ {
errorState = ExceptionUtil.GetErrorStateMessage(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); DbResultSet_DataReader resultSet = new DbResultSet_DataReader (data);
resultSet.SetErrorState(errorState); resultSet.SetErrorState(errorState);
@@ -4,6 +4,7 @@ using System.Data.Common;
using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Base; using Sarand.Net.Standard.Dbas.Base;
namespace Sarand.Net.Standard.Dbas.Data namespace Sarand.Net.Standard.Dbas.Data
@@ -32,7 +33,6 @@ namespace Sarand.Net.Standard.Dbas.Data
private void ExecuteQuery () private void ExecuteQuery ()
{ {
ClearErrorState(); ClearErrorState();
String fn = GetType().Name + ".ExecuteQuery";
Close(); Close();
try try
{ {
@@ -44,12 +44,12 @@ namespace Sarand.Net.Standard.Dbas.Data
DataTable dataTable = new DataTable(); DataTable dataTable = new DataTable();
dbDataAdapter.Fill(dataTable); dbDataAdapter.Fill(dataTable);
dataTableReader = new DataTableReader(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) catch (Exception exc)
{ {
SetErrorState(exc.GetType().Name + ": " + exc.Message); 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);
} }
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
@@ -484,13 +484,13 @@ namespace Sarand.Net.Standard.Dbas.Data
else if (colName.EqualsCI("REMARKS")) else if (colName.EqualsCI("REMARKS"))
remarks = value; remarks = value;
else else
SaLogger.Warn(SysUtil.Fn + " Unrecognised column name: '" + colName + "'"); SaLogger.Warn($"{SysUtil.Fn} Unrecognised column name: '{colName}'");
} }
// TODO Why is Type sometimes "BASE TABLE"? // 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 (!StringUtil.IsEmpty(tableName) && (type.EqualsCI("Table") || type.EqualsCI("Base Table")) && (!schema.EqualsCI("sys") || !tableName.Left(9).EqualsCI("trace_xe_")))
{ {
#if DEBUG #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 #endif
tables.Add(new DbDfnTable(schema, tableName, remarks)); tables.Add(new DbDfnTable(schema, tableName, remarks));
} }
@@ -507,7 +507,7 @@ namespace Sarand.Net.Standard.Dbas.Data
//------------------------------------------------------------------- //-------------------------------------------------------------------
private void PopulateTableColumns(DbConnection dbConnection, DbDfnTable table) 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; short columnPos = 0;
String[] restrictions = new String[] { null, table.Schema, table.Name, null }; // database, owner, table name, column name String[] restrictions = new String[] { null, table.Schema, table.Name, null }; // database, owner, table name, column name
using (DataTable columnSchema = dbConnection.GetSchema(OdbcMetaDataCollectionNames.Columns, restrictions)) using (DataTable columnSchema = dbConnection.GetSchema(OdbcMetaDataCollectionNames.Columns, restrictions))
+1 -1
View File
@@ -10,7 +10,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" /> <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" /> <PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="System.Data.Odbc" Version="8.0.0" /> <PackageReference Include="System.Data.Odbc" Version="8.0.0" />
</ItemGroup> </ItemGroup>