BusinessMgr 3.0.2 .Net8
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>Sacs</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -14,12 +14,13 @@ using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Web;
|
||||
|
||||
namespace Sacs.Web.Components
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaController : Controller
|
||||
public class SaController : Controller, ISacsStateItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
@@ -246,7 +247,7 @@ namespace Sacs.Web.Components
|
||||
public AjaxResponse_Base SetSessionExpired(String title, String text)
|
||||
{
|
||||
SessionExpired = true;
|
||||
return SetMessage(title, text);
|
||||
return SetPopupMessage(title, text);
|
||||
}
|
||||
public AjaxResponse_Base SetGoHome()
|
||||
{
|
||||
@@ -256,21 +257,53 @@ namespace Sacs.Web.Components
|
||||
public AjaxResponse_Base SetGoHome(String title, String text)
|
||||
{
|
||||
GoHome = true;
|
||||
return SetMessage(title, text);
|
||||
return SetPopupMessage(title, text);
|
||||
}
|
||||
// Message - displays alert popup.
|
||||
|
||||
// Inline message - to display on view.
|
||||
public class InlineMessageData
|
||||
{
|
||||
public String Text { get; init; }
|
||||
public bool? Warning { get { return Level == SaMessageLevel.Warning ? true : null; } }
|
||||
public bool? Error { get { return Level == SaMessageLevel.Error ? true : null; } }
|
||||
[JsonIgnore]
|
||||
public SaMessageLevel Level { get; init; } = SaMessageLevel.Info;
|
||||
}
|
||||
public InlineMessageData InlineMessage { get; private set; }
|
||||
public AjaxResponse_Base SetInfoMessage(String message)
|
||||
{
|
||||
if (!StringUtil.IsBlank(message))
|
||||
InlineMessage = new() { Text = message };
|
||||
if (InlineMessage is not null) throw new NotSupportedException("Inline message already populated");
|
||||
return this;
|
||||
}
|
||||
public AjaxResponse_Base SetWarningMessage(String message)
|
||||
{
|
||||
if (!StringUtil.IsBlank(message))
|
||||
InlineMessage = new() { Text = message, Level = SaMessageLevel.Warning };
|
||||
return this;
|
||||
}
|
||||
public AjaxResponse_Base SetErrorMessage(String message)
|
||||
{
|
||||
if (!StringUtil.IsBlank(message))
|
||||
InlineMessage = new() { Text = message, Level = SaMessageLevel.Error };
|
||||
return this;
|
||||
}
|
||||
|
||||
// Popup Message - displays in modal popup.
|
||||
public class MessageData
|
||||
{
|
||||
public String Title { get; set; }
|
||||
public String Text { get; set; }
|
||||
}
|
||||
public MessageData Message { get; private set; }
|
||||
public AjaxResponse_Base SetMessage(String title, String text)
|
||||
public MessageData PopupMessage { get; private set; }
|
||||
public AjaxResponse_Base SetPopupMessage(String title, String text)
|
||||
{
|
||||
if (!StringUtil.IsBlank(text))
|
||||
Message = new MessageData() { Title = title, Text = text };
|
||||
PopupMessage = new MessageData() { Title = title, Text = text };
|
||||
return this;
|
||||
}
|
||||
|
||||
// Confirmation message - to query user.
|
||||
public class ConfirmMessageData : MessageData
|
||||
{
|
||||
@@ -284,6 +317,20 @@ namespace Sacs.Web.Components
|
||||
return this;
|
||||
}
|
||||
public bool? HasConfirmMessage { get { return ConfirmMessage != null ? true : null; } }
|
||||
|
||||
// Notify message - briefly displays after response received.
|
||||
public class NotifyMessageData
|
||||
{
|
||||
public String Title { get; set; }
|
||||
public String Message { get; set; }
|
||||
}
|
||||
public NotifyMessageData NotifyMessage { get; private set; }
|
||||
public AjaxResponse_Base SetNotifyMessage(String title, String message)
|
||||
{
|
||||
NotifyMessage = new NotifyMessageData() { Title = title, Message = message };
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -295,15 +342,15 @@ namespace Sacs.Web.Components
|
||||
{
|
||||
if (model.ErrorMessages.Any())
|
||||
{
|
||||
SetMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.error", "Error")), model.ErrorMessages.Concat("", "\n"));
|
||||
SetPopupMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.error", "Error")), model.ErrorMessages.Concat("", "\n"));
|
||||
}
|
||||
else if (model.WarningMessages.Any())
|
||||
{
|
||||
SetMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.warning", "Warning")), model.WarningMessages.Concat("", "\n"));
|
||||
SetPopupMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.warning", "Warning")), model.WarningMessages.Concat("", "\n"));
|
||||
}
|
||||
else if (model.InfoMessages.Any())
|
||||
{
|
||||
SetNotification(StringUtil.OnBlank(messageTitle, model.GetText("label.notification", "Notificaton")), model.InfoMessages.Concat("", "\n"));
|
||||
SetNotifyMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.notification", "Notificaton")), model.InfoMessages.Concat("", "\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,20 +538,6 @@ namespace Sacs.Web.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Notification - briefly displays after response received.
|
||||
public class NotificationData
|
||||
{
|
||||
public String Title { get; set; }
|
||||
public String Message { get; set; }
|
||||
}
|
||||
public NotificationData Notification { get; private set; }
|
||||
public AjaxResponse_Data SetNotification(String title, String message)
|
||||
{
|
||||
Notification = new NotificationData() { Title = title, Message = message };
|
||||
return this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Paged data.
|
||||
public class PagingData
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using Microsoft.Maui.Controls.Compatibility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Mobile.Maui.Layouts
|
||||
{
|
||||
@@ -139,7 +133,7 @@ namespace Sarand.Net.Mobile.Maui.Layouts
|
||||
|
||||
var size = child.Measure(widthConstraint, heightConstraint);
|
||||
var itemWidth = (double)columnsSize;
|
||||
var itemHeight = size.Request.Height;
|
||||
var itemHeight = size.Height;
|
||||
|
||||
if (IsSquare)
|
||||
{
|
||||
@@ -201,8 +195,8 @@ namespace Sarand.Net.Mobile.Maui.Layouts
|
||||
{
|
||||
var child = childBlock.current.child;
|
||||
var size = childBlock.current.size;
|
||||
var itemWidth = size.Request.Width;
|
||||
var itemHeight = size.Request.Height;
|
||||
var itemWidth = size.Width;
|
||||
var itemHeight = size.Height;
|
||||
|
||||
rowHeight = Math.Max(rowHeight, itemHeight + SpacingY);
|
||||
rowWidth += itemWidth + SpacingX;
|
||||
@@ -224,7 +218,7 @@ namespace Sarand.Net.Mobile.Maui.Layouts
|
||||
}
|
||||
|
||||
xPos += itemWidth + SpacingX;
|
||||
var nextWitdh = childBlock.next.size.Request.Width;
|
||||
var nextWitdh = childBlock.next.size.Width;
|
||||
|
||||
if (xPos + nextWitdh - x > widthConstraint)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst18.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
|
||||
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
|
||||
<UseMaui>true</UseMaui>
|
||||
@@ -10,9 +10,9 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.4</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.5</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">32.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
|
||||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.3</SupportedOSPlatformVersion>
|
||||
@@ -20,8 +20,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.20" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.20" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.120" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.120" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>Sarand.Net.Mobile</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>Sarand.Net.Standard</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.App
|
||||
{
|
||||
@@ -11,7 +9,7 @@ namespace Sarand.Net.Standard.Base.App
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SacsVersion (String name, String version, DateTime buildAt)
|
||||
public SacsVersion(String name, String version, DateTime buildAt)
|
||||
{
|
||||
Name = name;
|
||||
Version = version;
|
||||
@@ -27,7 +25,7 @@ namespace Sarand.Net.Standard.Base.App
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn(GetType().Name + " " + exc.GetType().Name + " on parsing version: " + exc.Message);
|
||||
SaLogger.Warn($"{GetType().Name} {exc.GetType().Name} on parsing version: {ExceptionUtil.GetMessage(exc)}");
|
||||
}
|
||||
VersionInt = Ver1 << 48 + Ver2 << 32 + Ver3 << 16 + Ver4;
|
||||
}
|
||||
@@ -45,24 +43,24 @@ namespace Sarand.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Comparison.
|
||||
public override bool Equals (object obj)
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is SacsVersion) return Equals(obj as SacsVersion);
|
||||
return base.Equals(obj);
|
||||
}
|
||||
public override int GetHashCode ()
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var hashCode = 2121240903;
|
||||
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Version);
|
||||
hashCode = hashCode * -1521134295 + VersionInt.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
public bool Equals (SacsVersion version)
|
||||
public bool Equals(SacsVersion version)
|
||||
{
|
||||
if (VersionInt == version.VersionInt) return true;
|
||||
return false;
|
||||
}
|
||||
public int CompareTo (SacsVersion version, bool includeName = false)
|
||||
public int CompareTo(SacsVersion version, bool includeName = false)
|
||||
{
|
||||
int versionCompare = VersionInt.CompareTo(version.VersionInt);
|
||||
if (!includeName || versionCompare != 0) return versionCompare;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.Data
|
||||
{
|
||||
@@ -23,11 +20,11 @@ namespace Sarand.Net.Standard.Base.Data
|
||||
// Either generate a 32 byte key or use any string and convert it into a key with CreateKey.
|
||||
// NB The salt will remain the same here for each key generated - it does not need to be randomized as with hashing.
|
||||
//-------------------------------------------------------------------
|
||||
private static byte[] CreateKey (string password, int keyBytes = 32)
|
||||
private static byte[] CreateKey(string password, int keyBytes = 32)
|
||||
{
|
||||
byte[] salt = new byte[] { 80, 70, 60, 50, 40, 30, 20, 10 };
|
||||
int iterations = 300;
|
||||
DeriveBytes keyGenerator = new Rfc2898DeriveBytes(password, salt, iterations);
|
||||
DeriveBytes keyGenerator = new Rfc2898DeriveBytes(password, salt, iterations, HashAlgorithmName.SHA256);
|
||||
return keyGenerator.GetBytes(keyBytes);
|
||||
}
|
||||
|
||||
@@ -37,7 +34,7 @@ namespace Sarand.Net.Standard.Base.Data
|
||||
// In AES, the IV is a randomizer, making sure that no two identical messages ever give the same encrypted output.
|
||||
// The IV can be public and does not need to be hidden.
|
||||
//-------------------------------------------------------------------
|
||||
public static string Encrypt (this string clearValue, string encryptionKey)
|
||||
public static string Encrypt(this string clearValue, string encryptionKey)
|
||||
{
|
||||
using (Aes aes = Aes.Create())
|
||||
{
|
||||
@@ -48,7 +45,7 @@ namespace Sarand.Net.Standard.Base.Data
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
public static byte[] Encrypt (string plainText, byte[] key, byte[] iv)
|
||||
public static byte[] Encrypt(string plainText, byte[] key, byte[] iv)
|
||||
{
|
||||
if (plainText == null || plainText.Length <= 0) throw new ArgumentNullException($"{nameof(plainText)}");
|
||||
if (key == null || key.Length <= 0) throw new ArgumentNullException($"{nameof(key)}");
|
||||
@@ -79,7 +76,7 @@ namespace Sarand.Net.Standard.Base.Data
|
||||
// assume that the IV is at the end of the string passed in.
|
||||
// To decrypt a message encrypted by another function, the IV will have to be passed explicitly.
|
||||
//-------------------------------------------------------------------
|
||||
public static string Decrypt (this string encryptedValue, string encryptionKey)
|
||||
public static string Decrypt(this string encryptedValue, string encryptionKey)
|
||||
{
|
||||
String[] valueParts = encryptedValue.Split(new String[] { AesIvDelimiter }, StringSplitOptions.None);
|
||||
if (valueParts.Length != 2)
|
||||
@@ -91,7 +88,7 @@ namespace Sarand.Net.Standard.Base.Data
|
||||
return Decrypt(Convert.FromBase64String(valueParts[0]), CreateKey(encryptionKey), Convert.FromBase64String(valueParts[1]));
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
public static string Decrypt (byte[] cipherText, byte[] key, byte[] iv)
|
||||
public static string Decrypt(byte[] cipherText, byte[] key, byte[] iv)
|
||||
{
|
||||
if (cipherText == null || cipherText.Length <= 0) throw new ArgumentNullException($"{nameof(cipherText)}");
|
||||
if (key == null || key.Length <= 0) throw new ArgumentNullException($"{nameof(key)}");
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.Dbas
|
||||
{
|
||||
@@ -54,7 +55,7 @@ namespace Sarand.Net.Standard.Base.Dbas
|
||||
// Get Field Value.
|
||||
public DataValue GetFieldValue(String columnName)
|
||||
{
|
||||
String fn = GetType().Name + ".GetFieldValue('" + columnName + "')";
|
||||
String fn = $"{GetType().Name}.GetFieldValue('{columnName}')";
|
||||
DataValue dataValue = null;
|
||||
try
|
||||
{
|
||||
@@ -62,7 +63,7 @@ namespace Sarand.Net.Standard.Base.Dbas
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn(fn + " Exception: " + exc.Message);
|
||||
SaLogger.Warn($"{fn} {ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
return dataValue;
|
||||
}
|
||||
@@ -71,7 +72,7 @@ namespace Sarand.Net.Standard.Base.Dbas
|
||||
#endif
|
||||
public DataValue GetFieldValue(int columnIdx)
|
||||
{
|
||||
String fn = GetType().Name + ".GetFieldValue(" + columnIdx + ")";
|
||||
String fn = $"{GetType().Name}.GetFieldValue('{columnIdx}')";
|
||||
if (IsDbNull(columnIdx)) return null;
|
||||
String columnDataType = "";
|
||||
DataValue dataValue = null;
|
||||
@@ -136,7 +137,7 @@ namespace Sarand.Net.Standard.Base.Dbas
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn(fn + " Data type: " + columnDataType + ". Exception: " + exc.Message /*+ "\n" + exc.ToString()*/);
|
||||
SaLogger.Warn($"{fn} Data type: {columnDataType}. {ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
#if DEBUG
|
||||
if (!handlingGetFieldValueException)
|
||||
{
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Net;
|
||||
using Sarand.Net.Standard.Base.Tasks;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -179,8 +177,8 @@ namespace Sarand.Net.Standard.Base.Helpers
|
||||
{
|
||||
exc = exc.InnerException;
|
||||
}
|
||||
String msg = exc.GetType().Name + ": " + exc.Message;
|
||||
SaLogger.Warn(SysUtil.Fn + " " + msg + ExceptionUtil.GetStackEntries(exc, 6).Concat("", "\n\t"));
|
||||
String msg = ExceptionUtil.GetErrorStateMessage(exc);
|
||||
SaLogger.Warn($"{SysUtil.Fn} {msg}{ExceptionUtil.GetStackEntries(exc, 6).Concat("", "\n\t")}");
|
||||
responseData.ErrorStateMessage = msg;
|
||||
}
|
||||
requestData.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.IO
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
//-------------------------------------------------------------------
|
||||
// D i r e c t o r y E x i s t s
|
||||
//-------------------------------------------------------------------
|
||||
public static bool DirectoryExists (String directory)
|
||||
public static bool DirectoryExists(String directory)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -32,7 +32,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
/// <param name="path">The path of a file or directory.</param>
|
||||
/// <returns>Directory information for path, or null if path denotes a root directory or is
|
||||
/// null. Returns System.String.Empty if path does not contain directory information.</returns>
|
||||
public static String GetDirectoryName (String path)
|
||||
public static String GetDirectoryName(String path)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
/// Retrieve list of sub directories in directory.
|
||||
/// <para>Avoiding Exception thrown when network path isn't valid.</para>
|
||||
/// </summary>
|
||||
public static IEnumerable<String> EnumerateDirectories (String path)
|
||||
public static IEnumerable<String> EnumerateDirectories(String path)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -62,7 +62,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error("DirectoryUtil.EnumerateDirectories " + exc.GetType().Name + ": " + exc.Message + ". Path: '" + path + "'");
|
||||
SaLogger.Error($"DirectoryUtil.EnumerateDirectories {ExceptionUtil.GetErrorStateMessage(exc)}. Path: '{path}'");
|
||||
}
|
||||
return new List<String>();
|
||||
}
|
||||
@@ -74,7 +74,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
/// Retrieve list of files in directory.
|
||||
/// <para>Avoiding Exception thrown when network path isn't valid.</para>
|
||||
/// </summary>
|
||||
public static IEnumerable<String> EnumerateFiles (String path)
|
||||
public static IEnumerable<String> EnumerateFiles(String path)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -82,7 +82,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error("DirectoryUtil.EnumerateFiles " + exc.GetType().Name + ": " + exc.Message + ". Path: '" + path + "'");
|
||||
SaLogger.Error($"DirectoryUtil.EnumerateFiles {ExceptionUtil.GetErrorStateMessage(exc)}. Path: '{path}'");
|
||||
}
|
||||
return new List<String>();
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
/// Retrieve list of files in directory.
|
||||
/// <para>Avoiding Exception thrown when network path isn't valid.</para>
|
||||
/// </summary>
|
||||
public static IEnumerable<String> EnumerateFiles (String path, String searchPattern)
|
||||
public static IEnumerable<String> EnumerateFiles(String path, String searchPattern)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -99,7 +99,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error("DirectoryUtil.EnumerateFiles " + exc.GetType().Name + ": " + exc.Message + ". Path: '" + path + "'. Pattern: " + searchPattern);
|
||||
SaLogger.Error($"DirectoryUtil.EnumerateFiles {ExceptionUtil.GetErrorStateMessage(exc)}. Path: '{path}'. Pattern: {searchPattern}");
|
||||
}
|
||||
return new List<String>();
|
||||
}
|
||||
@@ -108,7 +108,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
/// Retrieve list of files in directory.
|
||||
/// <para>Avoiding Exception thrown when network path isn't valid.</para>
|
||||
/// </summary>
|
||||
public static IEnumerable<String> EnumerateFiles (String path, String searchPattern, SearchOption searchOption)
|
||||
public static IEnumerable<String> EnumerateFiles(String path, String searchPattern, SearchOption searchOption)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -116,7 +116,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error("DirectoryUtil.EnumerateFiles " + exc.GetType().Name + ": " + exc.Message + ". Path: '" + path + "'. Pattern: " + searchPattern + ". Option: " + searchOption.ToString());
|
||||
SaLogger.Error($"DirectoryUtil.EnumerateFiles {ExceptionUtil.GetErrorStateMessage(exc)}. Path: '{path}'. Pattern: {searchPattern}. Option: {searchOption}");
|
||||
}
|
||||
return new List<String>();
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
/// Create Directory in the specified path.
|
||||
/// <para>Avoiding Exception thrown when network path isn't valid.</para>
|
||||
/// </summary>
|
||||
public static DirectoryInfo CreateDirectory (String path)
|
||||
public static DirectoryInfo CreateDirectory(String path)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -136,7 +136,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error("DirectoryUtil.CreateDirectory " + exc.GetType().Name + ": " + exc.Message + ". Path: '" + path + "'");
|
||||
SaLogger.Error($"DirectoryUtil.CreateDirectory {ExceptionUtil.GetErrorStateMessage(exc)}. Path: '{path}'");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
public static String TrimTrailingSlashes (String path)
|
||||
public static String TrimTrailingSlashes(String path)
|
||||
{
|
||||
return Regex.Replace(path, "[\\\\/]+$", "");
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.IO
|
||||
{
|
||||
@@ -57,7 +56,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
// Default method.
|
||||
return Directory.Exists(directoryPath);
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Debug("FileUtil.IsDirectory " + exc.GetType().Name + ": " + exc.Message); }
|
||||
catch (Exception exc) { SaLogger.Debug($"FileUtil.IsDirectory {ExceptionUtil.GetErrorStateMessage(exc)}"); }
|
||||
return false;
|
||||
}
|
||||
public delegate String DirectoryGetParentFn(String filepath);
|
||||
@@ -74,7 +73,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
if (parentDirectoryInfo != null)
|
||||
return parentDirectoryInfo.FullName;
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Debug("FileUtil.GetParentDirectory " + exc.GetType().Name + ": " + exc.Message); }
|
||||
catch (Exception exc) { SaLogger.Debug($"FileUtil.GetParentDirectory {ExceptionUtil.GetErrorStateMessage(exc)}"); }
|
||||
return String.Empty;
|
||||
}
|
||||
public delegate bool DirectoryCreateDirectoryFn(String filepath);
|
||||
@@ -90,7 +89,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
DirectoryInfo info = Directory.CreateDirectory(directoryPath);
|
||||
return info.Exists;
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Debug("FileUtil.CreateDirectory " + exc.GetType().Name + ": " + exc.Message); }
|
||||
catch (Exception exc) { SaLogger.Debug($"FileUtil.CreateDirectory {ExceptionUtil.GetErrorStateMessage(exc)}"); }
|
||||
return false;
|
||||
}
|
||||
public static bool ValidateDirectory(String directoryPath, bool allowCreation = false)
|
||||
@@ -116,7 +115,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn(typeof(FileUtil).Name + ".GetFileLastWriteTime " + exc.GetType().Name + ": " + exc.Message);
|
||||
SaLogger.Warn($"{typeof(FileUtil).Name}.GetFileLastWriteTime {ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
@@ -139,7 +138,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
// Default method.
|
||||
return File.Exists(filePath);
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Debug("FileUtil.IsFile " + exc.GetType().Name + ": " + exc.Message); }
|
||||
catch (Exception exc) { SaLogger.Debug($"FileUtil.IsFile {ExceptionUtil.GetErrorStateMessage(exc)}"); }
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -161,7 +160,7 @@ namespace Sarand.Net.Standard.Base.IO
|
||||
// Default method.
|
||||
return File.ReadAllLines(filePath);
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Debug("FileUtil.ReadAllFileLines " + exc.GetType().Name + ": " + exc.Message); }
|
||||
catch (Exception exc) { SaLogger.Debug($"FileUtil.ReadAllFileLines {ExceptionUtil.GetErrorStateMessage(exc)}"); }
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Helpers;
|
||||
using Sarand.Net.Standard.Base.Tasks;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
@@ -14,7 +12,6 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -262,7 +259,7 @@ namespace Sarand.Net.Standard.Base.Net
|
||||
{
|
||||
exc = exc.InnerException;
|
||||
}
|
||||
String msg = exc.GetType().Name + ": " + exc.Message;
|
||||
String msg = ExceptionUtil.GetErrorStateMessage(exc);
|
||||
SaLogger.Warn(SysUtil.Fn + " " + msg + ExceptionUtil.GetStackEntries(exc, 6).Concat("", "\n\t"));
|
||||
responseData.ErrorStateMessage = msg;
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace Sarand.Net.Standard.Base.Procs
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
String msg = exc.GetType().Name + ": " + exc.Message;
|
||||
String msg = ExceptionUtil.GetErrorStateMessage(exc);
|
||||
AddErrorMessage(msg);
|
||||
SaLogger.Error($"{SysUtil.Fn} ProcessStarting: {msg}{exc.GetStackEntries(6).Concat("", "\n\tat ")}", true);
|
||||
}
|
||||
@@ -319,7 +319,7 @@ namespace Sarand.Net.Standard.Base.Procs
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
String msg = exc.GetType().Name + ": " + exc.Message;
|
||||
String msg = ExceptionUtil.GetErrorStateMessage(exc);
|
||||
AddErrorMessage(msg);
|
||||
SaLogger.Error($"{SysUtil.Fn} " + msg + exc.GetStackEntries(6).Concat("", "\n\tat "), true);
|
||||
}
|
||||
@@ -340,7 +340,7 @@ namespace Sarand.Net.Standard.Base.Procs
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
String msg = exc.GetType().Name + ": " + exc.Message;
|
||||
String msg = ExceptionUtil.GetErrorStateMessage(exc);
|
||||
AddErrorMessage(msg);
|
||||
SaLogger.Error($"{SysUtil.Fn} ProcessCompleted: {msg}{exc.GetStackEntries(6).Concat("", "\n\tat ")}", true);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.Net.Standard.Base.Utils
|
||||
{
|
||||
@@ -27,10 +25,9 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
#pragma warning restore CS0649
|
||||
};
|
||||
|
||||
public static DateTime GetBuildDateTime (this Assembly assembly)
|
||||
public static DateTime GetBuildDateTime(this Assembly assembly)
|
||||
{
|
||||
// Not available until .Net Standard 1.5.
|
||||
var path = assembly.GetName().CodeBase;
|
||||
var path = assembly.Location;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
|
||||
|
||||
@@ -579,7 +579,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Debug("DateUtil.Format Exception: " + exc.Message);
|
||||
SaLogger.Debug($"DateUtil.Format {ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
@@ -20,9 +18,6 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
/// <returns>The copied object.</returns>
|
||||
public static T DeepCopy<T>(T source)
|
||||
{
|
||||
if (!typeof(T).IsSerializable)
|
||||
throw new ArgumentException("The type must be serializable.", "source");
|
||||
|
||||
// Don't serialize a null object, simply return the default for that object
|
||||
if (Object.ReferenceEquals(source, null))
|
||||
return default(T);
|
||||
@@ -40,7 +35,6 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
// Serialize using JSON.
|
||||
public static String ToJson<T>(T source)
|
||||
{
|
||||
if (!typeof(T).IsSerializable) throw new ArgumentException("The type must be serializable.", "source");
|
||||
// Don't serialize a null object, simply return the default for that object
|
||||
if (Object.ReferenceEquals(source, null)) return "";
|
||||
// Serialise to JSON String.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -665,7 +663,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Debug("StringUtil.FormatNumeric(double) " + exc.GetType().Name + ": " + exc.Message);
|
||||
SaLogger.Debug($"StringUtil.FormatNumeric(double) {ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -681,7 +679,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Debug("StringUtil.FormatNumeric(decimal) " + exc.GetType().Name + ": " + exc.Message);
|
||||
SaLogger.Debug($"StringUtil.FormatNumeric(decimal) {ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>Sarand.Net.Standard</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
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.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.Data
|
||||
{
|
||||
@@ -48,8 +48,8 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState(exc.GetType().Name + ": " + exc.Message);
|
||||
SaLogger.Warn(SysUtil.Fn + " " + exc.GetType().Name + ": " + exc.Message + "\n\t Query: " + query, true);
|
||||
SetErrorState(ExceptionUtil.GetErrorStateMessage(exc));
|
||||
SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetErrorStateMessage(exc)}\n\t Query: " + query, true);
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>Sarand.Net.Standard</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Sarand.Net.Standard.Proc.Excel
|
||||
workbook.MemoryStream = new MemoryStream();
|
||||
workbook.Document = SpreadsheetDocument.Create(workbook.MemoryStream, SpreadsheetDocumentType.Workbook);
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Warn(exc.GetType().Name + ".CreateWorkbook " + ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
catch (Exception exc) { SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetErrorStateMessage(exc)}"); }
|
||||
return (workbook != null);
|
||||
}
|
||||
public override bool OpenWorkbook(String filePath)
|
||||
@@ -113,7 +113,7 @@ namespace Sarand.Net.Standard.Proc.Excel
|
||||
workbook = new WorkbookData();
|
||||
workbook.Document = SpreadsheetDocument.Create(filePath, SpreadsheetDocumentType.Workbook);
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Warn(exc.GetType().Name + ".OpenWorkbook " + ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
catch (Exception exc) { SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetErrorStateMessage(exc)}"); }
|
||||
return (workbook != null);
|
||||
}
|
||||
public override bool CleanseWorkbook()
|
||||
@@ -153,7 +153,7 @@ namespace Sarand.Net.Standard.Proc.Excel
|
||||
workbook = null;
|
||||
}
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Warn(exc.GetType().Name + ".CloseWorkbook " + ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
catch (Exception exc) { SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetErrorStateMessage(exc)}"); }
|
||||
workbook = null;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>Sarand.Net.Standard</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user