General tidy.

This commit is contained in:
Andy Howard
2024-06-13 14:32:44 +01:00
parent 0c44e9ddd3
commit bf6bb966bc
159 changed files with 1166 additions and 972 deletions
@@ -364,7 +364,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
private bool ExportCommodityData_Csv()
{
String fn = this.GetFn("ExportCommodityData_Csv");
if (!OK) return false;
String progressPrefix = "Exporting data to CSV file";
@@ -415,7 +414,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc));
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
return AddErrorMessage(ExceptionUtil.GetErrorStateMessage(exc));
}
return OK;
@@ -426,7 +425,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
private bool ExportCommodityData_Excel()
{
String fn = this.GetFn("ExportCommodityData_Excel");
if (!OK) return false;
String progressPrefix = "Exporting data to Excel";
@@ -488,7 +486,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc));
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
return AddErrorMessage(ExceptionUtil.GetErrorStateMessage(exc));
}
@@ -62,7 +62,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
// Test connection.
protected bool TestFtpConnection (FtpConfig ftpConfig)
{
String fn = GetType().Name + ".TestFtpConnection";
WebResponse response = null;
try
{
@@ -75,12 +74,12 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
using (StreamReader reader = new StreamReader(responseStream))
{
String responseData = reader.ReadToEnd();
SaLogger.Debug(fn + ": Items in root: " + responseData.ReplaceAll("\r\n", ", "));
SaLogger.Debug($"{SysUtil.Fn} Items in root: " + responseData.ReplaceAll("\r\n", ", "));
}
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + exc.GetType().Name + ": " + exc.Message, true);
SaLogger.Warn($"{SysUtil.Fn} " + exc.GetType().Name + ": " + exc.Message, true);
return AddErrorMessage("Unable to connect to FTP host");
}
finally
@@ -110,7 +109,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
//-------------------------------------------------------------------
protected bool FtpFolderExists (FtpConfig ftpConfig, String folder)
{
String fn = GetType().Name + ".FtpFolderExists";
WebResponse response = null;
try
{
@@ -137,7 +135,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + exc.GetType().Name + ": " + exc.Message, true);
SaLogger.Warn($"{SysUtil.Fn} " + exc.GetType().Name + ": " + exc.Message, true);
return false;
}
finally
@@ -156,7 +154,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
/// <summary>Get list of items in remote FTP folder.</summary>
protected List<FtpUtil.FtpDirectoryItem> GetFtpItems (FtpConfig ftpConfig, String folder)
{
String fn = this.GetType().Name + ".GetFtpItems";
List<FtpUtil.FtpDirectoryItem> files = new List<FtpUtil.FtpDirectoryItem>();
WebResponse response = null;
try
@@ -183,7 +180,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + exc.GetType().Name + ": " + exc.Message, true);
SaLogger.Warn($"{SysUtil.Fn} " + exc.GetType().Name + ": " + exc.Message, true);
}
finally
{
@@ -195,7 +192,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
//-------------------------------------------------------------------
protected String GetFtpFileData (FtpConfig ftpConfig, String folder, String filename)
{
String fn = GetType() + ".GetFtpFileData";
WebClient ftpClient = null;
try
{
@@ -206,7 +202,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + exc.GetType().Name + ": " + exc.Message, true);
SaLogger.Warn($"{SysUtil.Fn} " + exc.GetType().Name + ": " + exc.Message, true);
}
finally
{
@@ -218,7 +214,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
//-------------------------------------------------------------------
protected bool WriteDataToFtpFile (FtpConfig ftpConfig, String folder, String filename, String data)
{
String fn = GetType() + ".WriteDataToFtpFile";
bool dataWrittenToFile = false;
FtpWebResponse response = null;
try
@@ -235,7 +230,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + exc.GetType().Name + ": " + exc.Message, true);
SaLogger.Warn($"{SysUtil.Fn} " + exc.GetType().Name + ": " + exc.Message, true);
}
finally
{
@@ -247,7 +242,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
//-------------------------------------------------------------------
protected bool DeleteFtpFile (FtpConfig ftpConfig, String folder, String filename)
{
String fn = GetType() + ".DeleteFtpData";
bool fileDeleted = false;
FtpWebResponse response = null;
try
@@ -261,7 +255,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + exc.GetType().Name + ": " + exc.Message, true);
SaLogger.Warn($"{SysUtil.Fn} " + exc.GetType().Name + ": " + exc.Message, true);
}
finally
{
@@ -272,7 +272,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
private bool ExportData()
{
if (!OK) return false;
String fn = this.GetFn("ExportData");
String progressPrefix = "Preparing worksheet";
//String saveFolder = ""; //GetOption_SaveFolder();
@@ -314,7 +313,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
}
catch (Exception exc)
{
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc));
SaLogger.Error($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
return AddErrorMessage(exc.GetType().Name + " exporting data to Excel.");
}
@@ -587,7 +586,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
private bool ExportCommoditiesToExcel(SaMsSpreadsheet spreadsheet)
{
if (!OK) return false;
String fn = this.GetFn("ExportCommoditiesToExcel");
String progressPrefix = "Exporting commodities";
SetProgressInfo(progressPrefix + " - Preparing data");
+2 -4
View File
@@ -233,8 +233,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Reports
//-------------------------------------------------------------------
public virtual void BeginPrint(PrintAction printAction, int pageNumberFrom = 0, int pageNumberTo = 0)
{
String fn = GetType().Name + ".BeginPrint";
if (DebugMode) SaLogger.Debug(fn + " PrintAction: " + printAction + ". Page range: " + pageNumberFrom + "-" + pageNumberTo + ". Page count: " + PageCount);
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} PrintAction: " + printAction + ". Page range: " + pageNumberFrom + "-" + pageNumberTo + ". Page count: " + PageCount);
PageNumberFrom = PageNumberFrom;
PageNumberTo = pageNumberTo;
PageNumber = Math.Max(1, pageNumberFrom) - 1;
@@ -246,7 +245,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Reports
public virtual void QueryPageSettings(PageSettings pageSettings, PrintAction printAction) { }
public PrintPageResult PrintPage(Graphics graphics, PageSettings pageSettings, Rectangle pageBounds, Rectangle marginBounds)
{
String fn = GetType().Name + ".PrintPage";
PageNumber++;
// Configure graphics for printing document.
@@ -266,7 +264,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Reports
cfg.PosY = marginBounds.Top;
cfg.PosYBodyTop = marginBounds.Top;
cfg.PosYBodyBottom = marginBounds.Bottom;
if (DebugMode) SaLogger.Debug(fn + " Page: " + PageNumber);
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Page: " + PageNumber);
SwitchPrintMode(PrintMode.Physical, cfg);
// Log print configuration.
+1 -1
View File
@@ -50,7 +50,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
LocalizedString text = MainProperties.GetString(key, parameters);
if (text.ResourceNotFound)
{
SaLogger.Debug(GetType().Name + ".GetText Key not found: " + key);
SaLogger.Debug($"{SysUtil.Fn} Key not found: {key}");
// Look up key in alternative property files.
foreach (IStringLocalizer properties in AlternativeProperties ?? new List<IStringLocalizer>())
{
+3 -2
View File
@@ -110,8 +110,9 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
LanguageViewLocationExpanderFormat.Suffix,
opts => { opts.ResourcesPath = resourcesPath; })
.AddDataAnnotationsLocalization()
// Ignore null values during object serisliation.
.AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
// Ignore null values during object serialiation.
.AddJsonOptions(options => { options.JsonSerializerOptions.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull; });
// Jun24 Was: .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
// Configure localisation middleware.
config.services.Configure<RequestLocalizationOptions>
@@ -1,4 +1,7 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Security;
using System;
using System.Collections.Generic;
using System.Text;
@@ -20,6 +23,13 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
//-------------------------------------------------------------------
// Properties.
//-------------------------------------------------------------------
// Modify properties - internal only.
public void RefreshUser(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners)
{
base.SetUserData(securityItemUser, affiliateUser, supervisedOwners);
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -1,14 +1,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging.Abstractions;
using Sacs.Web.Components;
using Sarand.BusinessMgr.Net.Core.Web.App;
using Sarand.BusinessMgr.Net.Core.Web.Models;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
@@ -17,10 +10,8 @@ using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.CodeTypes;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Diary;
using Sarand.Net.Standard.Base.Email;
using Sarand.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.ItemData;
using Sarand.Net.Standard.Base.ItemDocs;
@@ -31,12 +22,9 @@ using Sarand.Net.Standard.Base.UpdateLog;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
{
@@ -46,6 +34,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
//-------------------------------------------------------------------
// Data members.
private SbmInternals internals;
private SbmSysParamCache sysParamCache = null;
//-------------------------------------------------------------------
// Protected construction.
@@ -56,25 +45,30 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
// Initialise console (debug) logging listener.
//if (Directory.Exists(App.LoggingRootFolder) && SbmSystem.DebugMode)
// SbmConsoleListener.ConfigureDebugListener(App.LoggingRootFolder);
if (DebugMode) SaLogger.Trace(GetType().Name + ".CTR");
if (DebugMode) SaLogger.Trace($"{GetType().Name}.CTR");
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (sysParamCache != null) sysParamCache.Dispose();
sysParamCache = null;
if (internals != null) internals.Dispose();
internals = null;
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
protected SbmLocaliser Localiser { get; }
protected SbmApplication_Web App { get { return SbmGlobals_Web.Application; } }
public SbmAppConfig AppConfig { get { return App.AppConfig; } }
public SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } }
public ISbmUserContext UserContext { get { return SessionData; } }
protected SbmLocaliser Localiser { get; }
public abstract SbmSessionContext SessionContext { get; }
public abstract ISbmUserContext UserContext { get; }
// Business components.
public SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } }
protected SbmSysParamCache SysParamCache { get { if (sysParamCache == null) sysParamCache = new SbmSysParamCache(UserContext); return sysParamCache; } }
// Managers.
public SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
public SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } }
@@ -109,152 +103,27 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
//-------------------------------------------------------------------
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (DebugMode) SaLogger.Debug(GetType().Name + ".OnActionExecuting" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
// Refreh model properties.
SbmModel_Base baseModel = ViewData.Model as SbmModel_Base;
RefreshModel(baseModel);
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
base.OnActionExecuting(filterContext);
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (DebugMode) SaLogger.Debug(GetType().Name + ".OnActionExecuted" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
// Refreh model properties.
SbmModel_Base baseModel = ViewData.Model as SbmModel_Base;
RefreshModel(baseModel);
// Store session data if present - as potentially modfied.
if (SessionData != null)
// ToDo Store system params.
if (sysParamCache != null)
{
// Most actions will store the session data in case it's been modified.
// Some actions (eg. score password) don't need to.
if (StoreSessionData)
if (sysParamCache.Modified)
{
String sessionDataJson = JsonConvert.SerializeObject(SessionData);
HttpContext.Session.Set(SessionStorage.SessionKey_SessionData, SessionStorage.sessionDataEncoding.GetBytes(sessionDataJson));
sysParamCache.Store();
SaLogger.Info($"{SysUtil.Fn} User params stored.");
}
}
else HttpContext.Session.Remove(SessionStorage.SessionKey_SessionData);
// Response headers.
if (baseModel != null && baseModel.ProhibitCache)
{
if (Response.Headers.ContainsKey(HeaderNames.CacheControl))
Response.Headers.Remove(HeaderNames.CacheControl);
Response.Headers.Add(HeaderNames.CacheControl, "no-cache, no-store, must-revalidate");
Response.Headers.Add(HeaderNames.Pragma, "no-cache");
Response.Headers.Add(HeaderNames.Expires, "0");
}
base.OnActionExecuted(filterContext);
}
//-------------------------------------------------------------------
// Model.
//-------------------------------------------------------------------
protected void RefreshModel(SbmModel_Base model)
{
if (model == null) return;
// Session data.
model.Controller = this;
model.SessionData_Web = SessionData;
// Redirect locations.
model.RedirectLocation.Base = GetRedirectLocation(RedirectLocation.WebAppBase);
model.RedirectLocation.Home = GetRedirectLocation(RedirectLocation.WebAppHome);
model.RedirectLocation.Home_SessionExpired = GetRedirectLocation(RedirectLocation.WebAppHome_SessionExpired);
}
//-------------------------------------------------------------------
// Session.
//-------------------------------------------------------------------
public bool ValidUserSession { get { return SessionData?.ValidUserSession ?? false; } }
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } }
// Referrer.
public String Referer { get { return Request.Headers["Referer"].ToString(); } }
public bool ValidReferer { get { return !StringUtil.IsEmpty(Referer); } }
/// <summary>Store session data, eg. to start a new user session on sign-in.</summary>
protected bool SetSessionData(SbmSessionData_Web sessionData)
{
if (sessionStorage.SessionData != null) return false;
sessionStorage.SessionData = sessionData;
return true;
}
protected void ClearSessionData()
{
if (HttpContext.Session.IsAvailable)
HttpContext.Session.Clear();
sessionStorage.SessionData = null;
}
//-------------------------------------------------------------------
// Session storage.
public class SessionStorage
{
public SbmSessionData_Web SessionData { get; set; }
public static String SessionKey_SessionData { get; } = "SbmSessionData";
public static Encoding sessionDataEncoding { get; } = Encoding.UTF8;
//JSON Serialisation.
public class SbmSessionDataContractResolver : DefaultContractResolver
{
// To allow private properties to be deserialised.
// NB Only applies to top level properties in the serialised object.
protected override List<MemberInfo> GetSerializableMembers(Type objectType)
{
var flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
MemberInfo[] fields = objectType.GetFields(flags);
return fields
.Concat(objectType.GetProperties(flags).Where(propInfo => propInfo.CanWrite))
.ToList();
}
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
return base.CreateProperties(type, MemberSerialization.Fields);
}
};
public static JsonSerializerSettings JsonDeserialisationSettings = new JsonSerializerSettings
{
ContractResolver = new SbmSessionDataContractResolver(),
// Force all deserialised objects to be replaced - to avoid proxy lists not populating.
ObjectCreationHandling = ObjectCreationHandling.Replace
};
}
private readonly SessionStorage sessionStorage = new SessionStorage();
public static JsonSerializerSettings SbmSessionDataJsonSerializerSettings { get { return SessionStorage.JsonDeserialisationSettings; } }
//-------------------------------------------------------------------
public SbmSessionData_Web SessionData
{
get
{
try
{
// Retrieve session data if not already in controller.
if (sessionStorage.SessionData == null)
{
byte[] sessionDataBytes = null;
HttpContext.Session.TryGetValue(SessionStorage.SessionKey_SessionData, out sessionDataBytes);
if (sessionDataBytes != null)
{
String sessionDataJson = SessionStorage.sessionDataEncoding.GetString(sessionDataBytes);
sessionStorage.SessionData = DeserializeSessionData(sessionDataJson);
}
}
return sessionStorage.SessionData;
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".SessionData " + exc.GetType().Name + " - " + exc.Message + exc.GetStackEntries().Concat("", "\n\t"));
}
return null;
}
}
protected abstract SbmSessionData_Web DeserializeSessionData(String sessionDataJson);
//-------------------------------------------------------------------
}
//=======================================================================
@@ -0,0 +1,225 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Sacs.Web.Components;
using Sarand.BusinessMgr.Net.Core.Web.App;
using Sarand.BusinessMgr.Net.Core.Web.Models;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.CodeTypes;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Diary;
using Sarand.Net.Standard.Base.Email;
using Sarand.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.ItemData;
using Sarand.Net.Standard.Base.ItemDocs;
using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.ReferenceData;
using Sarand.Net.Standard.Base.Security;
using Sarand.Net.Standard.Base.UpdateLog;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
{
//=======================================================================
public abstract class SbmController_Web : SbmController_Base
{
//-------------------------------------------------------------------
// Data members.
//-------------------------------------------------------------------
// Protected construction.
protected SbmController_Web(SbmLocaliser localiser) : base(localiser)
{
// Initialise console (debug) logging listener.
//if (Directory.Exists(App.LoggingRootFolder) && SbmSystem.DebugMode)
// SbmConsoleListener.ConfigureDebugListener(App.LoggingRootFolder);
if (DebugMode) SaLogger.Trace($"{GetType().Name}.CTR");
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
public override SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } }
public override ISbmUserContext UserContext { get { return SessionData; } }
//-------------------------------------------------------------------
// Action execution events.
//-------------------------------------------------------------------
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
// Refreh model properties.
SbmModel_Base baseModel = ViewData.Model as SbmModel_Base;
RefreshModel(baseModel);
base.OnActionExecuting(filterContext);
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
// Refreh model properties.
SbmModel_Base baseModel = ViewData.Model as SbmModel_Base;
RefreshModel(baseModel);
// Store session data if present - as potentially modfied.
if (SessionData != null)
{
// Most actions will store the session data in case it's been modified.
// Some actions (eg. score password) don't need to.
if (StoreSessionData)
{
String sessionDataJson = JsonConvert.SerializeObject(SessionData);
HttpContext.Session.Set(SessionStorage.SessionKey_SessionData, SessionStorage.sessionDataEncoding.GetBytes(sessionDataJson));
}
}
else HttpContext.Session.Remove(SessionStorage.SessionKey_SessionData);
// Response headers.
if (baseModel != null && baseModel.ProhibitCache)
{
if (Response.Headers.ContainsKey(HeaderNames.CacheControl))
Response.Headers.Remove(HeaderNames.CacheControl);
Response.Headers.Add(HeaderNames.CacheControl, "no-cache, no-store, must-revalidate");
Response.Headers.Add(HeaderNames.Pragma, "no-cache");
Response.Headers.Add(HeaderNames.Expires, "0");
}
base.OnActionExecuted(filterContext);
}
//-------------------------------------------------------------------
// Model.
//-------------------------------------------------------------------
protected void RefreshModel(SbmModel_Base model)
{
if (model == null) return;
// Session data.
model.Controller = this;
model.SessionData_Web = SessionData;
// Redirect locations.
model.RedirectLocation.Base = GetRedirectLocation(RedirectLocation.WebAppBase);
model.RedirectLocation.Home = GetRedirectLocation(RedirectLocation.WebAppHome);
model.RedirectLocation.Home_SessionExpired = GetRedirectLocation(RedirectLocation.WebAppHome_SessionExpired);
}
//-------------------------------------------------------------------
// Session.
//-------------------------------------------------------------------
public bool ValidUserSession { get { return SessionData?.ValidUserSession ?? false; } }
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } }
// Referrer.
public String Referer { get { return Request.Headers["Referer"].ToString(); } }
public bool ValidReferer { get { return !StringUtil.IsEmpty(Referer); } }
/// <summary>Store session data, eg. to start a new user session on sign-in.</summary>
protected bool SetSessionData(SbmSessionData_Web sessionData)
{
if (sessionStorage.SessionData != null) return false;
sessionStorage.SessionData = sessionData;
return true;
}
protected void ClearSessionData()
{
if (HttpContext.Session.IsAvailable)
HttpContext.Session.Clear();
sessionStorage.SessionData = null;
}
//-------------------------------------------------------------------
// Session storage.
public class SessionStorage
{
public SbmSessionData_Web SessionData { get; set; }
public static String SessionKey_SessionData { get; } = "SbmSessionData";
public static Encoding sessionDataEncoding { get; } = Encoding.UTF8;
//JSON Serialisation.
public class SbmSessionDataContractResolver : DefaultContractResolver
{
// To allow private properties to be deserialised.
// NB Only applies to top level properties in the serialised object.
protected override List<MemberInfo> GetSerializableMembers(Type objectType)
{
var flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
MemberInfo[] fields = objectType.GetFields(flags);
return fields
.Concat(objectType.GetProperties(flags).Where(propInfo => propInfo.CanWrite))
.ToList();
}
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
return base.CreateProperties(type, MemberSerialization.Fields);
}
};
public static JsonSerializerSettings JsonDeserialisationSettings = new JsonSerializerSettings
{
ContractResolver = new SbmSessionDataContractResolver(),
// Force all deserialised objects to be replaced - to avoid proxy lists not populating.
ObjectCreationHandling = ObjectCreationHandling.Replace
};
}
private readonly SessionStorage sessionStorage = new SessionStorage();
public static JsonSerializerSettings SbmSessionDataJsonSerializerSettings { get { return SessionStorage.JsonDeserialisationSettings; } }
//-------------------------------------------------------------------
public SbmSessionData_Web SessionData
{
get
{
try
{
// Retrieve session data if not already in controller.
if (sessionStorage.SessionData == null)
{
byte[] sessionDataBytes = null;
HttpContext.Session.TryGetValue(SessionStorage.SessionKey_SessionData, out sessionDataBytes);
if (sessionDataBytes != null)
{
String sessionDataJson = SessionStorage.sessionDataEncoding.GetString(sessionDataBytes);
sessionStorage.SessionData = DeserializeSessionData(sessionDataJson);
}
}
return sessionStorage.SessionData;
}
catch (Exception exc)
{
SaLogger.Warn($"{SysUtil.Fn} {exc.GetType().Name} - {exc.Message}{exc.GetStackEntries().Concat("", "\n\t")}");
}
return null;
}
}
protected abstract SbmSessionData_Web DeserializeSessionData(String sessionDataJson);
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -10,12 +10,15 @@ using System.Reflection.PortableExecutable;
using System.Text;
using System.Text.RegularExpressions;
// Ignore obsolete warning on ComplexTypeModelBinder.
#pragma warning disable 0618
namespace Sarand.BusinessMgr.Net.Core.Web.Middleware
{
//=======================================================================
/// <summary>
/// Maps a browser request to a data object. Default class provides a base implementation of a model binder.
/// <para>Overridden to trim whitespace from input values.</para>
/// <para>- Overridden to trim whitespace from input values.</para>
/// </summary>
public class SbmModelBinder : ComplexTypeModelBinder
{
@@ -54,13 +57,12 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Middleware
/// </summary>
protected override void SetProperty(ModelBindingContext bindingContext, string modelName, ModelMetadata propertyMetadata, ModelBindingResult result)
{
string fn = GetType().Name + ".SetProperty";
//if (SbmSystem.DebugMode) Logger.Debug(fn + " Form property " + modelName + ": '" + result.Model.ToString() + ".");
//if (SbmSystem.DebugMode) Logger.Debug($"{SysUtil.Fn} Form property " + modelName + ": '" + result.Model.ToString() + ".");
object originalValue = result.Model;
// Anything that looks like a password will be left as is.
bool password = modelName.ContainsCI("Password");
// Exclude properties that retain leading/trailing whitespace.
if (result.Model is string)
// Exclude properties that retain leading/trailing whitespace.
if (result.Model is string)
{
if (!password)
{
@@ -92,16 +94,16 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Middleware
result = ModelBindingResult.Success(value);
}
}
// Log property details.
if (result.Model != null && SbmSystem.DebugMode &&
// Log property details.
if (result.Model != null && SbmSystem.DebugMode &&
// Ignore passwords.
!password &&
// Ignore items that correspond with objects in the model rather than values.
!result.Model.ToString().Equals(result.Model.GetType().FullName) &&
// Ignore form files.
!result.Model.ToString().ContainsCI("Microsoft.AspNetCore.Http.IFormFile"))
SaLogger.Debug(SysUtil.Fn + " Form property " + modelName + ": '" + result.Model.ToString() + "'." + (originalValue != null && !originalValue.Equals(result.Model) ? " Original value: '" + originalValue.ToString() + "'" : ""));
base.SetProperty(bindingContext, modelName, propertyMetadata, result);
// Ignore items that correspond with objects in the model rather than values.
!result.Model.ToString().Equals(result.Model.GetType().FullName) &&
// Ignore form files.
!result.Model.ToString().ContainsCI("Microsoft.AspNetCore.Http.IFormFile"))
SaLogger.Debug(SysUtil.Fn + " Form property " + modelName + ": '" + result.Model.ToString() + "'." + (originalValue != null && !originalValue.Equals(result.Model) ? " Original value: '" + originalValue.ToString() + "'" : ""));
base.SetProperty(bindingContext, modelName, propertyMetadata, result);
}
//-------------------------------------------------------------------
@@ -41,11 +41,9 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Middleware
public async Task Invoke(HttpContext context)
{
String fn = GetType().Name + ".Invoke";
// Log action.
//String rawTarget = context.Features.Get<IHttpRequestFeature>().RawTarget;
if (SbmSystem.DebugMode) SaLogger.Debug(fn + " Action: '" + Regex.Replace(context.Request.Path.ToString(), "^/", "") + "'. Method: " + context.Request.Method);
if (SbmSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Action: '" + Regex.Replace(context.Request.Path.ToString(), "^/", "") + "'. Method: " + context.Request.Method);
// Intercept POST requests and apply anti-forgery test.
if (HttpMethods.IsPost(context.Request.Method))
@@ -59,7 +57,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Middleware
}
catch (Exception exc)
{
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc));
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
throw;
}
}
+1 -1
View File
@@ -51,7 +51,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } }
public SbmLocaliser Localiser { get; }
// Request properties.
public SbmController_Base Controller { get; set; }
public SbmController_Web Controller { get; set; }
public CultureInfo SessionCulture { get { return Controller?.SessionCulture ?? CultureInfo.InvariantCulture; } }
//-------------------------------------------------------------------
@@ -2,6 +2,7 @@
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.Utils;
using System;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
@@ -265,7 +266,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
public static bool IsMenuOptionApplicable(ISbmUserContext userContext, SbmConfigConsole configConsole, Sbm.MenuOption menuOption)
{
String fn = ClassName + ".IsMenuOptionApplicable";
if (!userContext.ValidUser)
{
// ToDo Only Login menu option available.
@@ -295,7 +295,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
return configConsole.AllowOption(userContext, Sbm.ConfigOption.TimeRecording);
//-----------------------------------------------------------
}
SaLogger.Warn(fn + " Unsupport menu option - " + menuOption.ToString());
SaLogger.Warn($"{SysUtil.Fn} Unsupport menu option - {menuOption.ToString()}");
return false;
}
@@ -101,8 +101,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
public static SbmConfigConsole CreateConsole(SbmSessionContext sessionContext)
{
String fn = "SbmConfigConsole.CreateConsole";
SaLogger.Warn(fn + ".CreateConsole Creating default configuration console.");
SaLogger.Warn($"{SysUtil.Fn} Creating default configuration console.");
// Default console.
SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SbmSystem.AssemblyBuildAt);
return new SbmConfigConsole(Sbm.ConfigConsole.Generic, consoleVersion, sessionContext);
@@ -186,8 +185,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// Application events.
public virtual void OnOpenDatabase()
{
String fn = GetType().Name + ".OnOpenDatabase";
SaLogger.Trace(fn);
SaLogger.Trace($"{SysUtil.Fn}");
}
//-------------------------------------------------------------------
+75 -51
View File
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
@@ -1159,10 +1159,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
int tableIdx = (int)table - 1;
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
String tableName = tables[(int)tableIdx];
String tableName = tables[(int)tableIdx].Name;
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
return tableName;
}
public static String GetTableNameQual (TableIdx table, bool delimitReservedWords = true)
{
int tableIdx = (int)table - 1;
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
String schemaName = tables[(int)tableIdx].Schema;
String tableName = tables[(int)tableIdx].Name;
if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); tableName = DelimitReservedWord(tableName); }
return (StringUtil.IsBlank(schemaName) ? "" : schemaName + ".") + tableName;
}
//-------------------------------------------------------------------
// Identify the table that corresponds with the specified column.
@@ -1212,8 +1221,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
}
public static String DelimitReservedWord (String word)
{
if (!IsReservedWord(word)) return word;
switch (reservedWordDelim)
return IsReservedWord(word) ? DelimitWord(word) : word;
}
public static String DelimitWord (String word)
{
return DelimitWord(word, reservedWordDelim);
}
public static String DelimitWord (String word, DbReservedWordDelim wordDelim)
{
switch (wordDelim)
{
case DbReservedWordDelim.None:
break;
@@ -1290,52 +1306,62 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// Table definitions.
private static readonly String[] tables =
private class TableDfn
{
"Address",
"Affiliate",
"Association",
"Commodity",
"CommodityCustomer",
"CommoditySupplier",
"Constituent",
"Container",
"ContainerItem",
"Currency",
"IndexDefragLog",
"Interface",
"InterfaceDataItem",
"InterfaceProcess",
"InterfaceProcessDataItem",
"InterfaceProcessMessage",
"ItemBatch",
"ItemLink",
"Language",
"Location",
"Movement",
"PortfolioItem",
"Process",
"Region",
"Requirement",
"SaAsset",
"SaAssetCategory",
"SaAssetProcess",
"SaDiaryEntry",
"SaDiaryLink",
"SaPrice",
"SaPriceSet",
"SaVehicle",
"SaVehicleClass",
"SaVehicleEvent",
"SaVehicleFeature",
"StockLevel",
"SysParam",
"SystemAccount",
"SystemAccountUser",
"SystemUser",
"TaxCode",
"Transaction",
"UnitMeasure",
internal String Schema { get; set; }
internal String Name { get; set; }
internal TableDfn (String schema, String name)
{
this.Schema= schema;
this.Name = name;
}
}
private static readonly TableDfn[] tables =
{
new TableDfn("dbo","Address"),
new TableDfn("dbo","Affiliate"),
new TableDfn("dbo","Association"),
new TableDfn("dbo","Commodity"),
new TableDfn("dbo","CommodityCustomer"),
new TableDfn("dbo","CommoditySupplier"),
new TableDfn("dbo","Constituent"),
new TableDfn("dbo","Container"),
new TableDfn("dbo","ContainerItem"),
new TableDfn("dbo","Currency"),
new TableDfn("dbo","IndexDefragLog"),
new TableDfn("dbo","Interface"),
new TableDfn("dbo","InterfaceDataItem"),
new TableDfn("dbo","InterfaceProcess"),
new TableDfn("dbo","InterfaceProcessDataItem"),
new TableDfn("dbo","InterfaceProcessMessage"),
new TableDfn("dbo","ItemBatch"),
new TableDfn("dbo","ItemLink"),
new TableDfn("dbo","Language"),
new TableDfn("dbo","Location"),
new TableDfn("dbo","Movement"),
new TableDfn("dbo","PortfolioItem"),
new TableDfn("dbo","Process"),
new TableDfn("dbo","Region"),
new TableDfn("dbo","Requirement"),
new TableDfn("dbo","SaAsset"),
new TableDfn("dbo","SaAssetCategory"),
new TableDfn("dbo","SaAssetProcess"),
new TableDfn("dbo","SaDiaryEntry"),
new TableDfn("dbo","SaDiaryLink"),
new TableDfn("dbo","SaPrice"),
new TableDfn("dbo","SaPriceSet"),
new TableDfn("dbo","SaVehicle"),
new TableDfn("dbo","SaVehicleClass"),
new TableDfn("dbo","SaVehicleEvent"),
new TableDfn("dbo","SaVehicleFeature"),
new TableDfn("dbo","StockLevel"),
new TableDfn("dbo","SysParam"),
new TableDfn("dbo","SystemAccount"),
new TableDfn("dbo","SystemAccountUser"),
new TableDfn("dbo","SystemUser"),
new TableDfn("dbo","TaxCode"),
new TableDfn("dbo","Transaction"),
new TableDfn("dbo","UnitMeasure"),
};
//-------------------------------------------------------------------
@@ -1358,8 +1384,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
this.DataLen = dataLen;
}
}
//-------------------------------------------------------------------
private static readonly ColumnDfn[] columns =
{
new ColumnDfn(1,"Id",4,4,false,10),
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:28
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
@@ -98,10 +98,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
int tableIdx = (int)table - 1;
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
String tableName = tables[(int)tableIdx];
String tableName = tables[(int)tableIdx].Name;
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
return tableName;
}
public static String GetTableNameQual (TableIdx table, bool delimitReservedWords = true)
{
int tableIdx = (int)table - 1;
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
String schemaName = tables[(int)tableIdx].Schema;
String tableName = tables[(int)tableIdx].Name;
if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); tableName = DelimitReservedWord(tableName); }
return (StringUtil.IsBlank(schemaName) ? "" : schemaName + ".") + tableName;
}
//-------------------------------------------------------------------
// Identify the table that corresponds with the specified column.
@@ -151,8 +160,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
}
public static String DelimitReservedWord (String word)
{
if (!IsReservedWord(word)) return word;
switch (reservedWordDelim)
return IsReservedWord(word) ? DelimitWord(word) : word;
}
public static String DelimitWord (String word)
{
return DelimitWord(word, reservedWordDelim);
}
public static String DelimitWord (String word, DbReservedWordDelim wordDelim)
{
switch (wordDelim)
{
case DbReservedWordDelim.None:
break;
@@ -229,11 +245,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// Table definitions.
private static readonly String[] tables =
private class TableDfn
{
"Database",
"DatabaseAccount",
"UserAccount",
internal String Schema { get; set; }
internal String Name { get; set; }
internal TableDfn (String schema, String name)
{
this.Schema= schema;
this.Name = name;
}
}
private static readonly TableDfn[] tables =
{
new TableDfn("dbo","Database"),
new TableDfn("dbo","DatabaseAccount"),
new TableDfn("dbo","UserAccount"),
};
//-------------------------------------------------------------------
@@ -256,8 +282,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
this.DataLen = dataLen;
}
}
//-------------------------------------------------------------------
private static readonly ColumnDfn[] columns =
{
new ColumnDfn(1,"Id",4,4,true,10),
@@ -1,116 +0,0 @@
using Sarand.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Reflection;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
public static class SbmResourceConsole
{
//----------------------------------------------------------------------
// Definitions.
public enum TextResource
{
SaBaseCss,
SaBaseJs,
SbmBaseCss,
SbmBaseJs,
JQueryJs,
JQueryUiCss,
JQueryUiJs,
}
public enum ImageResource
{
// Sapphire icons.
sapphire01_side_32_png,
sapphire01_side_40_png,
sapphire01_side_64_png,
// Menu icons.
arrow_down_black_16_png,
arrow_down_black_24_png,
arrow_up_black_16_png,
arrow_up_black_24_png,
star_amber_16_png,
}
//-------------------------------------------------------------------
// Properties.
public static Assembly Assembly { get { return typeof(SacsResourceHelper).GetTypeInfo().Assembly; } }
//-------------------------------------------------------------------
public static String GetTextResource(TextResource textResource)
{
switch (textResource)
{
case TextResource.SaBaseCss:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.SaBaseCss);
case TextResource.SaBaseJs:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.SaBaseJs);
case TextResource.SbmBaseCss:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.SaBaseCss) + SacsResourceHelper.GetManifestResourceAsText(Assembly, "", "sbm_base.css");
case TextResource.SbmBaseJs:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.SaBaseJs) + SacsResourceHelper.GetManifestResourceAsText(Assembly, "", "sbm_base.js");
case TextResource.JQueryJs:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.JQueryJs);
case TextResource.JQueryUiCss:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.JQueryUiCss);
case TextResource.JQueryUiJs:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.JQueryUiJs);
}
return "";
}
//-------------------------------------------------------------------
public static byte[] GetImageResource(ImageResource imageResource)
{
String partialPath = "";
String resourceFilename = "";
switch (imageResource)
{
// Sapphire icons.
case ImageResource.sapphire01_side_32_png:
partialPath = "sapphire";
resourceFilename = "sapphire01-side-32.png";
break;
case ImageResource.sapphire01_side_40_png:
partialPath = "sapphire";
resourceFilename = "sapphire01-side-40.png";
break;
case ImageResource.sapphire01_side_64_png:
partialPath = "sapphire";
resourceFilename = "sapphire01-side-64.png";
break;
// Menu icons.
case ImageResource.arrow_down_black_16_png:
resourceFilename = "arrow-down-black-16.png";
break;
case ImageResource.arrow_down_black_24_png:
resourceFilename = "arrow-down-black-24.png";
break;
case ImageResource.arrow_up_black_16_png:
resourceFilename = "arrow-up-black-16.png";
break;
case ImageResource.arrow_up_black_24_png:
resourceFilename = "arrow-up-black-24.png";
break;
case ImageResource.star_amber_16_png:
resourceFilename = "star-amber-16.png";
break;
}
if (!StringUtil.IsEmpty(resourceFilename))
{
var assembly = typeof(SbmResourceConsole).GetTypeInfo().Assembly;
byte[] resourceData = SacsResourceHelper.GetManifestResourceAsBinary(assembly, partialPath, resourceFilename);
if (resourceData != null)
return resourceData;
}
return new byte[0];
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -44,7 +44,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// Refresh profile.
public void RefreshProfile(SbmConfigConsole configConsole, SaSecurityConsole securityConsole, SysId userId, List<TypeCodeDesc> securityRights)
{
String fn = GetType().Name + ".RefreshProfile";
ClearErrorState();
// Make a note of the security right.
@@ -63,7 +62,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
if (hostSecurityProfile == null && includeHostSecurityProfile)
hostSecurityProfile = securityConsole.GetHostSecurityProfile();
}
SaLogger.Debug(fn + " User: '" + UserDisplayName + "' [Id: " + UserId + "]" + (SysId.IsValid(previousUserId) ? ". Previous UserId: " + SysId.ToString(previousUserId) : ""));
SaLogger.Debug($"{SysUtil.Fn} User: '{UserDisplayName}' [Id: {UserId}]" + (SysId.IsValid(previousUserId) ? ". Previous UserId: " + SysId.ToString(previousUserId) : ""));
RefreshProfileSettings(configConsole);
@@ -7,6 +7,7 @@ using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.Security;
using Sarand.Net.Standard.Base.Utils;
using System.Collections.Generic;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
@@ -96,7 +97,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
SbmAffiliate affiliateUser = accountMgr.GetAffiliateByUserId(userId);
if (affiliateUser == null)
{
SaLogger.Warn(GetType().Name + ".StartUserSession Unable to retrieve affiliate for UserId: " + SysId.ToString(userId));
SaLogger.Warn($"{SysUtil.Fn} Unable to retrieve affiliate for UserId: {SysId.ToString(userId)}");
return false;
}
List<SysIdString> userSupervisedOwners = accountMgr.GetAffiliatesSupervisedBy(affiliateUser.Id);
@@ -1,52 +1,139 @@
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Org.BouncyCastle.Asn1.IsisMtt;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
public class SbmSysParamCache
public class SbmSysParamCache : SacsDisposable
{
//-------------------------------------------------------------------
// Definitions.
public enum ParamName
{
/// <summary>User's selected organisation.</summary>
SelectedCompany,
SelectedOwner = SelectedCompany,
DefaultView,
ApplicationSize,
LeftPanelWidth,
SelectedAssociation,
SelectedTransaction,
SelectedPortfolio,
SelectedPortfolioItem,
SelectedCommodity,
AssocMaintTab,
}
public static String ParamName_SelectedCompany = "SelectedCompany";
public static String ParamName_DefaultView = "DefaultView";
public static String ParamName_ApplicationSize = "AppSize";
public static String ParamName_LeftPanelWidth = "LeftPanelWidth";
public static String ParamName_SelectedAssociation = "SelectedAssociation";
public static String ParamName_SelectedTransaction = "SelectedTransaction";
public static String ParamName_SelectedPortfolio = "SelectedPortfolio";
public static String ParamName_SelectedPortfolioItem = "SelectedPortfolioItem";
public static String ParamName_SelectedCommodity = "SelectedCommodity";
public static String ParamName_AssocMaintTab = "AssocMaintTab";
//-------------------------------------------------------------------
// Data members.
protected readonly List<SbmSysParam> userSysParams = new List<SbmSysParam>();
//-------------------------------------------------------------------
// Protected Construction - use derived objects.
// Construction.
public SbmSysParamCache(ISbmUserContext userContext)
{
this.UserContext = userContext;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
}
}
//-------------------------------------------------------------------
// Properties.
public ISbmUserContext UserContext { get; }
public SysId AffiliateIdUser { get; private set; }
public SysId AffiliateIdUser { get { return UserContext.User.AffiliateId; } }
public bool Modified { get; private set; }
//-------------------------------------------------------------------
// Utilities.
public static String GetParamName(ParamName paramName)
{
switch (paramName)
{
case ParamName.SelectedCompany:
return ParamName_SelectedCompany;
case ParamName.DefaultView:
return ParamName_DefaultView;
case ParamName.ApplicationSize:
return ParamName_ApplicationSize;
case ParamName.LeftPanelWidth:
return ParamName_LeftPanelWidth;
case ParamName.SelectedAssociation:
return ParamName_SelectedAssociation;
case ParamName.SelectedTransaction:
return ParamName_SelectedTransaction;
case ParamName.SelectedPortfolio:
return ParamName_SelectedPortfolio;
case ParamName.SelectedPortfolioItem:
return ParamName_SelectedPortfolioItem;
case ParamName.SelectedCommodity:
return ParamName_SelectedCommodity;
case ParamName.AssocMaintTab:
return ParamName_AssocMaintTab;
}
return "";
}
//-------------------------------------------------------------------
/// <summary>Retrieve the value for the user parameter.</summary>
public String GetParamValue(String name, SysId affiliateIdTarget = null, SysId associationId = null)
public String GetUserParamValue(ParamName paramName, SysId affiliateIdTarget = null, SysId associationId = null)
{
return GetUserParamValue(GetParamName(paramName), affiliateIdTarget, associationId);
}
/// <summary>Retrieve the value for the user parameter.</summary>
public String GetUserParamValue(String name, SysId affiliateIdTarget = null, SysId associationId = null)
{
if (!SysId.IsValid(UserContext.User.AffiliateId)) return "";
return GetParam(name, affiliateIdTarget, associationId)?.Value ?? "";
}
//-------------------------------------------------------------------
/// <summary>Store value against user parameter.</summary>
public bool SetSessionParam(String name, String value, SysId affiliateIdTarget = null, SysId associationId = null)
public bool SetUserParamValue(ParamName paramName, String value, SysId affiliateIdTarget = null, SysId associationId = null)
{
return SetUserParamValue(GetParamName(paramName), value, affiliateIdTarget, associationId);
}
/// <summary>Store value against user parameter.</summary>
public bool SetUserParamValue(String name, String value, SysId affiliateIdTarget = null, SysId associationId = null)
{
bool success = false;
if (!SysId.IsValid(UserContext.User.AffiliateId)) return false;
SbmSysParam sysParam = GetParam(name, affiliateIdTarget, associationId);
if (sysParam != null)
{
// Update the value.
sysParam.Value = value;
if (!sysParam.Value.Equals(value))
{
// Update the value.
sysParam.Value = value;
Modified = true;
}
success = true;
}
return success;
@@ -98,7 +185,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
/// <summary>Store the params cached for the current user.</summary>
public bool Store()
{
String fn = GetType().Name + ".Store";
bool success = true;
using (SbmAccountMgr accountMgr = CreateAccountMgr())
{
@@ -110,7 +196,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
if (!accountMgr.InsertSysParam(sysParam, UserContext.DbUpdateInfo))
{
success = false;
SaLogger.Warn(fn + " Failed to add parameter - " + accountMgr.ErrorStateMessage);
SaLogger.Warn($"{SysUtil.Fn} Failed to add parameter - {accountMgr.ErrorStateMessage}");
}
}
else
@@ -119,11 +205,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
if (!accountMgr.UpdateSysParam(sysParam, UserContext.DbUpdateInfo))
{
success = false;
SaLogger.Warn(fn + " Failed to update parameter - " + accountMgr.ErrorStateMessage);
SaLogger.Warn($"{SysUtil.Fn} Failed to update parameter - {accountMgr.ErrorStateMessage}");
}
}
}
}
if (success) Modified = false;
return success;
}
@@ -131,8 +218,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
/// <summary>Clear the params cached for the current user.</summary>
public void Clear()
{
AffiliateIdUser = null;
ListUtil.ClearAndDispose(userSysParams);
Modified = false;
}
//-------------------------------------------------------------------
@@ -130,7 +130,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
SessionContext = sessionContext;
organisationData = new OrganisationData_Internal();
securityProfile = new SbmSecurityProfile(this, true);
DbUpdateInfo = new DbUpdateInfo(User.AffiliateId, User.DisplayName, SacsSystem.ComputerName);
}
//-------------------------------------------------------------------
@@ -139,7 +138,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public ISbmUserContext.IUserData User { get { return userData; } }
public bool ValidUser { get { return SysId.IsValid(userData.SecurityItemId) && SysId.IsValid(userData.AffiliateId); } }
public ISbmUserContext.IOrganisationData Organisation { get { return organisationData; } }
public DbUpdateInfo DbUpdateInfo { get; private set; }
public DbUpdateInfo DbUpdateInfo { get { return new DbUpdateInfo(User?.AffiliateId, User?.DisplayName ?? "", SacsSystem.ComputerName); } }
//-------------------------------------------------------------------
// Security profile.
@@ -283,19 +282,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
protected void SetUserData(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners)
{
userData.Refresh(securityItemUser, affiliateUser, supervisedOwners);
DbUpdateInfo = new DbUpdateInfo(User.AffiliateId, User.DisplayName, SacsSystem.ComputerName);
}
protected void ClearUserData()
{
userData.Clear();
organisationData.Clear();
SetSecurityProfile(new SbmSecurityProfile(this, true));
DbUpdateInfo = new DbUpdateInfo(User.AffiliateId, User.DisplayName, SacsSystem.ComputerName);
}
protected void SetOrganisationData(SysId affiliateIdOrganisation)
{
String fn = GetType().Name + ".SetOrganisationData";
// Interface context for selected organisation.
String interfaceContext = SbmAccountMgr.GetInterfaceContext(affiliateIdOrganisation);
@@ -329,7 +324,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// Retrieve the options for this association.
organisationData.configOptionsCache.Reset(associationItemId_Owner, affiliateItemId_Owner);
organisationData.configOptionsCache.ItemOptions.AddRange(itemOptionConsole.GetItemOptionsForItem(associationItemId_Owner));
SaLogger.Debug(fn + " Populated organisation options: " + organisationData.configOptionsCache.ItemOptions.Count);
SaLogger.Debug($"{SysUtil.Fn} Populated organisation options: {organisationData.configOptionsCache.ItemOptions.Count}.");
}
}
}
+3 -4
View File
@@ -444,17 +444,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public Data GetData() { return data.Clone(); }
public void SetData(Data data)
{
String fn = GetType().Name + ".SetData";
// Properties that cannot be changed if previously specified.
// 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");
// Item type.
if ((int)ItemType > 1 && ItemType != data.ItemType)
throw new NotSupportedException(fn + " Item Type cannot be changed");
throw new NotSupportedException($"{SysUtil.Fn} Item Type cannot be changed");
// Item Id.
if (SysId.IsValid(ItemId) && SysId.ToInt(ItemId) != SysId.ToInt(data.ItemId))
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);
}
@@ -471,10 +471,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 -2
View File
@@ -416,10 +416,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -256,10 +256,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -164,10 +165,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -587,10 +587,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -1130,10 +1130,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -169,10 +169,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -162,10 +163,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -441,10 +442,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -202,10 +203,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -203,10 +204,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -291,10 +291,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -165,10 +166,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 -2
View File
@@ -202,10 +202,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -164,10 +164,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -3,6 +3,7 @@ using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -232,10 +233,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 -2
View File
@@ -2,6 +2,7 @@
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -153,10 +154,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 -2
View File
@@ -215,10 +215,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -226,10 +227,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
+3 -3
View File
@@ -2,6 +2,7 @@
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -203,12 +204,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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(PriceSetId) && SysId.ToInt(PriceSetId) != SysId.ToInt(data.PriceSetId))
throw new NotSupportedException(fn + "Price set Id cannot be changed");
throw new NotSupportedException($"{SysUtil.Fn} Price set Id cannot be changed");
if (SysId.IsValid(CommodityId) && SysId.ToInt(CommodityId) != SysId.ToInt(data.CommodityId))
throw new NotSupportedException(fn + "Commodity Id cannot be changed");
throw new NotSupportedException($"{SysUtil.Fn} Commodity Id cannot be changed");
// Populate individual properties to ensure that 'Changed' indicator is kept up to date.
this.data.PopulateFrom(data);
}
+2 -2
View File
@@ -2,6 +2,7 @@
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -164,10 +165,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 -2
View File
@@ -2,6 +2,7 @@
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -171,10 +172,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -768,10 +768,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -203,10 +204,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 -2
View File
@@ -2,6 +2,7 @@
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -169,10 +170,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -179,10 +180,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
@@ -133,10 +134,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
@@ -160,10 +161,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -1060,10 +1060,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -162,10 +162,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 -2
View File
@@ -2,6 +2,7 @@
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -374,10 +375,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -296,10 +297,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -227,10 +228,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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 Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
@@ -234,10 +235,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
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);
}
@@ -45,8 +45,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
/// </summary>
public static int GetPasswordStrength(String password)
{
String fn = "PasswordHelper.GetPasswordStrength";
// 0 - Blank.
if (StringUtil.IsEmpty(password)) return 0;
@@ -61,7 +59,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
}
catch (Exception exc)
{
SaLogger.Debug(fn + " " + ExceptionUtil.GetLogMessage(exc));
SaLogger.Debug($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}");
}
int passwordLength = StringUtil.GetLength(password);
@@ -14,6 +14,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
// Definitions.
public enum TextResource
{
// Base text resources.
SaBaseCss,
SaBaseJs,
SbmBaseCss,
SbmBaseJs,
JQueryJs,
JQueryUiCss,
JQueryUiJs,
// Email stylesheets.
Email_Main_Css,
// Email partial content.
@@ -26,8 +34,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
public enum ImageResource
{
BusinessMgr_logo_h75_png,
// Sapphire icons.
sapphire01_side_32_png,
sapphire01_side_40_png,
sapphire01_side_64_png,
// Menu icons.
arrow_down_black_16_png,
arrow_down_black_24_png,
arrow_up_black_16_png,
arrow_up_black_24_png,
star_amber_16_png,
}
//-------------------------------------------------------------------
// Properties.
public static Assembly Assembly { get { return typeof(SacsResourceHelper).GetTypeInfo().Assembly; } }
//-------------------------------------------------------------------
// Text resources.
public static String GetTextResource(TextResource textResource)
@@ -36,6 +58,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
String resourceFilename = "";
switch (textResource)
{
// Base text resources.
case TextResource.SaBaseCss:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.SaBaseCss);
case TextResource.SaBaseJs:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.SaBaseJs);
case TextResource.SbmBaseCss:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.SaBaseCss) + SacsResourceHelper.GetManifestResourceAsText(Assembly, "", "sbm_base.css");
case TextResource.SbmBaseJs:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.SaBaseJs) + SacsResourceHelper.GetManifestResourceAsText(Assembly, "", "sbm_base.js");
case TextResource.JQueryJs:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.JQueryJs);
case TextResource.JQueryUiCss:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.JQueryUiCss);
case TextResource.JQueryUiJs:
return SacsResourceHelper.GetResourceText(SacsResourceHelper.TextResource.JQueryUiJs);
// Email stylesheet.
case TextResource.Email_Main_Css:
resourceFilename = "sbm-email-main.css";
@@ -55,8 +93,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
}
if (!StringUtil.IsEmpty(resourceFilename))
{
var assembly = typeof(SbmResourceHelper).GetTypeInfo().Assembly;
String resourceText = SacsResourceHelper.GetManifestResourceAsText(assembly, partialPath, resourceFilename);
String resourceText = SacsResourceHelper.GetManifestResourceAsText(Assembly, partialPath, resourceFilename);
if (!StringUtil.IsEmpty(resourceText))
return resourceText;
}
@@ -74,11 +111,41 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
case ImageResource.BusinessMgr_logo_h75_png:
resourceFilename = "BusinessMgr-logo-h75.png";
break;
// Sapphire icons.
case ImageResource.sapphire01_side_32_png:
partialPath = "sapphire";
resourceFilename = "sapphire01-side-32.png";
break;
case ImageResource.sapphire01_side_40_png:
partialPath = "sapphire";
resourceFilename = "sapphire01-side-40.png";
break;
case ImageResource.sapphire01_side_64_png:
partialPath = "sapphire";
resourceFilename = "sapphire01-side-64.png";
break;
// Menu icons.
case ImageResource.arrow_down_black_16_png:
resourceFilename = "arrow-down-black-16.png";
break;
case ImageResource.arrow_down_black_24_png:
resourceFilename = "arrow-down-black-24.png";
break;
case ImageResource.arrow_up_black_16_png:
resourceFilename = "arrow-up-black-16.png";
break;
case ImageResource.arrow_up_black_24_png:
resourceFilename = "arrow-up-black-24.png";
break;
case ImageResource.star_amber_16_png:
resourceFilename = "star-amber-16.png";
break;
}
if (!StringUtil.IsEmpty(resourceFilename))
{
var assembly = typeof(SbmResourceHelper).GetTypeInfo().Assembly;
byte[] resourceData = SacsResourceHelper.GetManifestResourceAsBinary(assembly, partialPath, resourceFilename);
byte[] resourceData = SacsResourceHelper.GetManifestResourceAsBinary(Assembly, partialPath, resourceFilename);
if (resourceData != null)
return resourceData;
}
+4 -4
View File
@@ -280,13 +280,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
private CodeTypeCache codeTypeCache;
public bool CodeTypeHasCodes(Sbm.ApplCodeType codeType)
{
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException(GetType().Name + ".CodeTypeHasCodes Unsupported code type: " + codeType);
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException($"{SysUtil.Fn} Unsupported code type: {codeType}");
PopulateCodeTypes();
return codeTypeCache.CodeTypeHasCodes(codeType);
}
public String GetCodeTypeCodeDesc(Sbm.ApplCodeType codeType, String code, bool defaultToCode = true)
{
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException(GetType().Name + ".GetCodeTypeCodeDesc Unsupported code type: " + codeType);
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException($"{SysUtil.Fn} Unsupported code type: {codeType}");
PopulateCodeTypes();
List<SaCode> codes = codeTypeCache.GetCodesForCodeType(codeType, false);
if (codes != null)
@@ -295,13 +295,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
}
public List<SaCode> GetCodesForCodeType(Sbm.ApplCodeType codeType, bool activeOnly = true)
{
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException(GetType().Name + ".GetCodesForCodeType Unsupported code type: " + codeType);
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException($"{SysUtil.Fn} Unsupported code type: {codeType}");
PopulateCodeTypes();
return codeTypeCache.GetCodesForCodeType(codeType, activeOnly);
}
public List<CodeDesc> GetCodeDescsForCodeType(Sbm.ApplCodeType codeType, bool activeOnly = true)
{
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException(GetType().Name + ".GetCodeDescsForCodeType Unsupported code type: " + codeType);
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException($"{SysUtil.Fn} Unsupported code type: {codeType}");
PopulateCodeTypes();
return codeTypeCache.GetCodeDescsForCodeType(codeType, activeOnly);
}
@@ -57,7 +57,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
//-------------------------------------------------------------------
public async Task<bool> RequestIsAlive(SbmWebServiceInstanceDefinition instanceDefinition)
{
String fn = GetType().Name + ".IsAlive";
try
{
RequestData requestData = new RequestData(instanceDefinition);
@@ -65,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
if (serviceResponse.ResponseData.EqualsCI(SbmWebServiceDfn.IsAliveResponse))
return true;
}
catch (Exception exc) { SaLogger.Warn(fn + " " + exc.GetLogMessage()); }
catch (Exception exc) { SaLogger.Warn($"{SysUtil.Fn} " + exc.GetLogMessage()); }
return false;
}
@@ -79,7 +78,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
}
public async Task<ItemCountResponseData> RequestItemCount(SbmWebServiceRequest.Config configRequest, Dictionary<String, String> filters, SacsTaskData taskData)
{
String fn = GetType().Name + ".GetItemCount";
if (SacsSystem.DebugMode && configRequest.RequestType != SbmWebServiceRequest.RequestType.Count) Debugger.Break();
// Service Request.
@@ -133,7 +131,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
}
public async Task<QueryListResponseData> RequestQueryList(SbmWebServiceRequest.Config configRequest, Dictionary<String, String> filters, List<string> columns, List<String> sortColumns, SacsTaskData taskData)
{
String fn = GetType().Name + ".GetItemList";
if (SacsSystem.DebugMode && configRequest.RequestType != SbmWebServiceRequest.RequestType.QueryList) Debugger.Break();
// Service Request.
@@ -147,7 +144,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
requestData.Data = serviceRequestData.GenerateRequestData();
SbmWebServiceResponse serviceResponse = await DoWebServiceRequest(requestData);
QueryListResponseData responseData = new QueryListResponseData(serviceResponse);
//if (SacsSystem.DebugMode && responseData.ResponseElement != null) SaLogger.Debug(fn + " Response:\n\n" + responseData.ResponseElement.FormatXml() + "\n");
//if (SacsSystem.DebugMode && responseData.ResponseElement != null) SaLogger.Debug($"{SysUtil.Fn} Response:\n\n" + responseData.ResponseElement.FormatXml() + "\n");
// Interpret response.
if (serviceResponse.ResponseElement != null && !taskData.IsCancellationRequested)
@@ -209,7 +206,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
}
public async Task<ItemListResponseData> RequestItemList(SbmWebServiceRequest.Config configRequest, Dictionary<String, String> filters, List<String> sortColumns, SacsTaskData taskData)
{
String fn = GetType().Name + ".GetItemList";
if (SacsSystem.DebugMode && configRequest.RequestType != SbmWebServiceRequest.RequestType.ItemList) Debugger.Break();
// Service Request.
@@ -222,7 +218,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
requestData.Data = serviceRequestData.GenerateRequestData();
SbmWebServiceResponse serviceResponse = await DoWebServiceRequest(requestData);
ItemListResponseData responseData = new ItemListResponseData(serviceResponse);
//if (SacsSystem.DebugMode && responseData.ResponseElement != null) SaLogger.Debug(fn + " Response:\n\n" + responseData.ResponseElement.FormatXml() + "\n");
//if (SacsSystem.DebugMode && responseData.ResponseElement != null) SaLogger.Debug($"{SysUtil.Fn} Response:\n\n" + responseData.ResponseElement.FormatXml() + "\n");
// Interpret response.
if (serviceResponse.ResponseElement != null && !taskData.IsCancellationRequested)
@@ -272,7 +268,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
}
public async Task<ItemDataResponseData> RequestItemData(SbmWebServiceRequest.Config configRequest, Dictionary<String, String> filters, SacsTaskData taskData)
{
String fn = GetType().Name + ".GetItemData";
if (SacsSystem.DebugMode && configRequest.RequestType != SbmWebServiceRequest.RequestType.Item) Debugger.Break();
// Service Request.
@@ -349,7 +344,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
}
public async Task<StoreItemResponseData> StoreItem(SbmWebServiceRequest.Config configRequest, XElement itemElement, SacsTaskData taskData)
{
String fn = GetType().Name + ".StoreItem";
if (SacsSystem.DebugMode && configRequest.RequestType != SbmWebServiceRequest.RequestType.Store) Debugger.Break();
// Service Request.
@@ -374,18 +368,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
/// </summary>
public async Task<SbmWebServiceResponse> DoWebServiceRequest(RequestData requestData)
{
String fn = GetType().Name + ".DoWebServiceRequest";
SbmWebServiceResponse serviceResponse = null;
// Throw canceled exception if task has been cancelled - invoke at regular intervals.
requestData.ThrowIfCancellationRequested();
// Log request.
//if (SacsSystem.DebugMode) SaLogger.Debug(fn + " Request URL:" + requestData.InstanceDefinition.URL);
//if (SacsSystem.DebugMode) SaLogger.Debug($"{SysUtil.Fn} Request URL:" + requestData.InstanceDefinition.URL);
if (requestData.Debug)
{
if (requestData.Data.Length < 512)
SaLogger.Debug(fn + " Request:\n\t" + requestData.Data);
else SaLogger.Debug(fn + " Request length:" + requestData.Data.Length);
SaLogger.Debug($"{SysUtil.Fn} Request:\n\t" + requestData.Data);
else SaLogger.Debug($"{SysUtil.Fn} Request length:" + requestData.Data.Length);
}
// Configure the request.
@@ -418,8 +411,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
if (requestData.Debug)
{
if (serviceResponse.ResponseData.Length < 1024)
SaLogger.Debug(fn + " Response: " + serviceResponse.ResponseData);
else SaLogger.Debug(fn + " Response size: " + serviceResponse.ResponseData.Length);
SaLogger.Debug($"{SysUtil.Fn} Response: " + serviceResponse.ResponseData);
else SaLogger.Debug($"{SysUtil.Fn} Response size: " + serviceResponse.ResponseData.Length);
}
return serviceResponse;
}
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:28
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:28
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:28
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{

Some files were not shown because too many files have changed in this diff Show More