Saxonite 1.2.11.12
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -209,10 +209,10 @@ namespace Sarand.Net.Standard.Base.Bus
|
||||
/// <param name="delimiter"></param>
|
||||
/// <param name="ignoreInvalid"></param>
|
||||
/// <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>();
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -149,6 +149,7 @@ namespace Sarand.Net.Standard.Base.Core
|
||||
Bmp,
|
||||
Gif,
|
||||
Tif,
|
||||
Svg,
|
||||
// Documents.
|
||||
Pdf,
|
||||
// Text documents.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
/// <summary>Add entries from another dictionary.</summary>
|
||||
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);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -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("<svg")) return false;
|
||||
if (!imageText.ContainsCI(" xmlns=\"http://www.w3.org/2000/svg\"")) return false;
|
||||
return true;
|
||||
}
|
||||
catch (Exception) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// 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>
|
||||
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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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.
|
||||
/// <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>
|
||||
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;
|
||||
|
||||
@@ -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.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user