BusinessMgr 3.0.1.2
This commit is contained in:
@@ -72,7 +72,7 @@ namespace Sacs.UnitTests.Net.Standard.Base.Helpers
|
||||
{
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
String value = SacsRandomHelper.getRandomLengthNumber(i);
|
||||
String value = SacsRandomHelper.GetRandomLengthNumber(i);
|
||||
//Debug.WriteLine("Value: " + value);
|
||||
Assert.IsTrue(value.Length > 0);
|
||||
Assert.IsTrue(value.Length < i + 1);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
@@ -47,32 +48,16 @@ namespace Sarand.UnitTests.Core.Base.Utils
|
||||
//-------------------------------------------------------------------
|
||||
// Regular Expression Matching.
|
||||
//-------------------------------------------------------------------
|
||||
[TestMethod]
|
||||
public void StringUtil_Match()
|
||||
{
|
||||
// Match.
|
||||
Assert.AreEqual(true, "ABCDEF".Match("CDE"));
|
||||
Assert.AreEqual(true, "ABCDEF".MatchCI("cDe"));
|
||||
Assert.AreEqual(true, "ABCDEF".Match("CDE", System.Text.RegularExpressions.RegexOptions.None));
|
||||
Assert.AreEqual(true, "ABCDEF".Match(new Regex("CDE", System.Text.RegularExpressions.RegexOptions.None)));
|
||||
Assert.AreEqual(true, "ABCDEF".Match(new Regex("cDe", System.Text.RegularExpressions.RegexOptions.IgnoreCase)));
|
||||
|
||||
// Match with escaped content.
|
||||
Assert.AreEqual(true, "ABC\\sDEF".Match("\\\\s"));
|
||||
Assert.AreEqual(true, "AB(CD)EF".Match("(..)"));
|
||||
Assert.AreEqual(true, "AB(CD)EF".Match("\\(CD\\)"));
|
||||
|
||||
// Not match.
|
||||
Assert.AreEqual(false, "ABCDEF".Match("cDe"));
|
||||
Assert.AreEqual(false, "ABCDEF".MatchCI("eFg"));
|
||||
Assert.AreEqual(false, "ABCDEF".Match("cDe", System.Text.RegularExpressions.RegexOptions.None));
|
||||
Assert.AreEqual(false, "ABCDEF".Match(new Regex("cDe", System.Text.RegularExpressions.RegexOptions.None)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void StringUtil_IsMatch()
|
||||
{
|
||||
// IsMatch.
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatch("ABCDEF"));
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatch("^ABCDEF$"));
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatchCI("AbCdEf"));
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatchCI("^AbCdEf$"));
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatch("^ABC"));
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatchCI("AbC"));
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatch("CDE"));
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatchCI("cDe"));
|
||||
Assert.AreEqual(true, "ABCDEF".IsMatch("CDE", System.Text.RegularExpressions.RegexOptions.None));
|
||||
@@ -91,12 +76,63 @@ namespace Sarand.UnitTests.Core.Base.Utils
|
||||
Assert.AreEqual(false, "ABCDEF".IsMatch(new Regex("cDe", System.Text.RegularExpressions.RegexOptions.None)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void StringUtil_Match()
|
||||
{
|
||||
// Match.
|
||||
Assert.AreEqual("CDE", "ABCDEF".GetMatch("CDE"));
|
||||
Assert.AreEqual("CDE", "ABCDEF".GetMatchCI("cDe"));
|
||||
Assert.AreEqual("CDE", "ABCDEF".Match("CDE", System.Text.RegularExpressions.RegexOptions.None).Value);
|
||||
Assert.AreEqual("CDE", "ABCDEF".Match(new Regex("CDE", System.Text.RegularExpressions.RegexOptions.None)).Value);
|
||||
Assert.AreEqual("CDE", "ABCDEF".Match(new Regex("cDe", System.Text.RegularExpressions.RegexOptions.IgnoreCase)).Value);
|
||||
|
||||
// Match with escaped content.
|
||||
Assert.AreEqual(" ", "ABC DEF".GetMatch("\\s"));
|
||||
Assert.AreEqual("\\s", "ABC\\sDEF".GetMatch("\\\\s"));
|
||||
Assert.AreEqual("AB", "AB(CD)EF".GetMatch("(..)"));
|
||||
Assert.AreEqual("(CD)", "AB(CD)EF".GetMatch("\\(..\\)"));
|
||||
Assert.AreEqual("(CD)", "AB(CD)EF".GetMatch("\\(CD\\)"));
|
||||
|
||||
// Not match.
|
||||
Assert.AreEqual(null, "ABCDEF".GetMatch("cDe"));
|
||||
Assert.AreEqual(null, "ABCDEF".GetMatch("eFg"));
|
||||
Assert.AreEqual("", "ABCDEF".Match("cDe", System.Text.RegularExpressions.RegexOptions.None).Value);
|
||||
Assert.AreEqual("", "ABCDEF".Match(new Regex("cDe", System.Text.RegularExpressions.RegexOptions.None)).Value);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void StringUtil_Matches()
|
||||
{
|
||||
// Match.
|
||||
Assert.AreEqual(1, "ABCDEF".GetMatches("CDE").Count);
|
||||
Assert.AreEqual(1, "ABCDEF".GetMatchesCI("cDe").Count);
|
||||
Assert.AreEqual(1, "ABCDEF".Matches("CDE", System.Text.RegularExpressions.RegexOptions.None).Count);
|
||||
Assert.AreEqual(1, "ABCDEF".Matches(new Regex("CDE", System.Text.RegularExpressions.RegexOptions.None)).Count);
|
||||
Assert.AreEqual(1, "ABCDEF".Matches(new Regex("cDe", System.Text.RegularExpressions.RegexOptions.IgnoreCase)).Count);
|
||||
|
||||
// Match with escaped content.
|
||||
Assert.AreEqual(1, "ABC DEF".GetMatchesCI("\\s").Count);
|
||||
Assert.AreEqual(1, "ABC\\sDEF".GetMatchesCI("\\\\s").Count);
|
||||
Assert.AreEqual(4, "AB(CD)EF".GetMatchesCI("(..)").Count);
|
||||
Assert.AreEqual("D)", "AB(CD)EF".GetMatchesCI("(..)")[2]);
|
||||
Assert.AreEqual(1, "AB(CD)EF".GetMatchesCI("\\(..\\)").Count);
|
||||
Assert.AreEqual(1, "AB(CD)EF".GetMatchesCI("\\(CD\\)").Count);
|
||||
|
||||
// Not match.
|
||||
Assert.AreEqual(0, "ABCDEF".GetMatches("cDe").Count);
|
||||
Assert.AreEqual(0, "ABCDEF".GetMatches("eFg").Count);
|
||||
Assert.AreEqual(0, "ABCDEF".Matches("cDe", System.Text.RegularExpressions.RegexOptions.None).Count);
|
||||
Assert.AreEqual(0, "ABCDEF".Matches(new Regex("cDe", System.Text.RegularExpressions.RegexOptions.None)).Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void StringUtil_MatchCount()
|
||||
{
|
||||
// Match.
|
||||
Assert.AreEqual(1, "ABCDEF".MatchCount(new Regex("CDE")));
|
||||
Assert.AreEqual(2, "ABCDEFGHICDEJKL".MatchCount(new Regex("CDE")));
|
||||
Assert.AreEqual(1, "ABCDEF".GetMatchCount("CDE"));
|
||||
Assert.AreEqual(1, "ABCDEF".MatchesCount(new Regex("CDE")));
|
||||
Assert.AreEqual(2, "ABCDEFGHICDEJKL".GetMatchCount("CDE"));
|
||||
Assert.AreEqual(2, "ABCDEFGHICDEJKL".MatchesCount(new Regex("CDE")));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -120,7 +156,7 @@ namespace Sarand.UnitTests.Core.Base.Utils
|
||||
Assert.AreEqual("00123", "123".PadLeft(5, '0'));
|
||||
}
|
||||
[TestMethod]
|
||||
public void StringUtil_PadRight ()
|
||||
public void StringUtil_PadRight()
|
||||
{
|
||||
// Leading spaces.
|
||||
Assert.AreEqual(" ", "".PadRight(3, ' '));
|
||||
@@ -142,7 +178,7 @@ namespace Sarand.UnitTests.Core.Base.Utils
|
||||
// S u b S t r i n g
|
||||
//-------------------------------------------------------------------
|
||||
[TestMethod]
|
||||
public void StringUtil_SubstringSafe ()
|
||||
public void StringUtil_SubstringSafe()
|
||||
{
|
||||
Assert.AreEqual(StringUtil.SubstringSafe(null, 0), "");
|
||||
Assert.AreEqual(StringUtil.SubstringSafe("", 0), "");
|
||||
|
||||
@@ -295,8 +295,20 @@ namespace Sacs.Web.Components
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Construction.
|
||||
protected AjaxResponse_Data(SaModel model)
|
||||
protected AjaxResponse_Data(SaModel model, String messageTitle = "")
|
||||
{
|
||||
if (model.ErrorMessages.Any())
|
||||
{
|
||||
SetMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.error", "Error")), model.ErrorMessages.Concat("", "\n"));
|
||||
}
|
||||
else if (model.WarningMessages.Any())
|
||||
{
|
||||
SetMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.warning", "Warning")), model.WarningMessages.Concat("", "\n"));
|
||||
}
|
||||
else if (model.InfoMessages.Any())
|
||||
{
|
||||
SetNotification(StringUtil.OnBlank(messageTitle, model.GetText("label.notification", "Notificaton")), model.InfoMessages.Concat("", "\n"));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -11,7 +14,7 @@ using System.Linq;
|
||||
namespace Sacs.Web.Components
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaModel : SacsDisposable
|
||||
public abstract class SaModel : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
@@ -50,13 +53,26 @@ namespace Sacs.Web.Components
|
||||
/// Views can be registered to avoid multiple inclusions in a page.
|
||||
/// <para>Only generate view content if this method returns true.</para>
|
||||
/// </summary>
|
||||
public bool RegisterView(String viewName)
|
||||
public bool RegisterView(ViewContext viewContext)
|
||||
{
|
||||
#if DEBUG
|
||||
if (registeredViews.Contains(viewName))
|
||||
SaLogger.Warn(this.GetType().Name + ".RegisterView View already registered: " + viewName);
|
||||
#endif
|
||||
return registeredViews.Add(viewName);
|
||||
// View identity.
|
||||
String viewPath = viewContext.ExecutingFilePath;
|
||||
if (StringUtil.IsBlank(viewPath)) return false;
|
||||
|
||||
// Action identity.
|
||||
Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor controllerActionDescriptor = viewContext.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor;
|
||||
String actionName = viewContext.ActionDescriptor.DisplayName;
|
||||
if (controllerActionDescriptor != null)
|
||||
actionName = $"{controllerActionDescriptor.ControllerName}.{controllerActionDescriptor.ActionName}";
|
||||
|
||||
// Check if view already registered.
|
||||
if (registeredViews.Contains(viewPath))
|
||||
{
|
||||
SaLogger.Debug($"{SysUtil.Fn} View already registered: {viewPath}. Action: {actionName}.");
|
||||
return false;
|
||||
}
|
||||
// Attempt to add this view to those registered on this page, returning false if already registered.
|
||||
return registeredViews.Add(viewPath);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -131,6 +147,10 @@ namespace Sacs.Web.Components
|
||||
return new SelectList(Enumerable.Empty<SelectListItem>());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Text & localisation.
|
||||
public abstract String GetText(String textKey, String defaultText);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Messages.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Static initialisation.
|
||||
static SaCodeTypeConsole ()
|
||||
static SaCodeTypeConsole()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaCodeTypeConsole ()
|
||||
protected SaCodeTypeConsole()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// C o d e T y p e D e f i n i t i o n s
|
||||
//-------------------------------------------------------------------
|
||||
public List<SaCodeTypeDfn> CodeTypeDefinitions { get { return new List<SaCodeTypeDfn>(codeTypeDfns); } }
|
||||
public SaCodeTypeDfn GetCodeTypeDefinition (String codeTypeCode)
|
||||
public SaCodeTypeDfn GetCodeTypeDefinition(String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
foreach (SaCodeTypeDfn codeTypeDfn in codeTypeDfns)
|
||||
@@ -44,15 +44,15 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
return codeTypeDfn;
|
||||
return null;
|
||||
}
|
||||
public abstract SaCodeTypeDfn GetCodeTypeDefinition (SysId codeTypeId);
|
||||
public virtual String GetNameForCodeType (String codeTypeCode)
|
||||
public abstract SaCodeTypeDfn GetCodeTypeDefinition(SysId codeTypeId);
|
||||
public virtual String GetNameForCodeType(String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeTypeDfn codeTypeDfn = GetCodeTypeDefinition(codeTypeCode);
|
||||
if (codeTypeDfn != null) return codeTypeDfn.Description;
|
||||
return "";
|
||||
}
|
||||
public bool IsCodeTypeSequenceAllowed (String codeTypeCode)
|
||||
public bool IsCodeTypeSequenceAllowed(String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeTypeDfn codeTypeDfn = GetCodeTypeDefinition(codeTypeCode);
|
||||
@@ -62,47 +62,72 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Code Type registration - for use in validation and population of default database.
|
||||
public bool RegisterCodeType (SaCodeTypeDfn codeTypeDfn)
|
||||
public bool RegisterCodeType(SaCodeTypeDfn codeTypeDfn)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (codeTypeDfns.GetCodeTypeDfnByCode(codeTypeDfn.Code) != null) return false;
|
||||
codeTypeDfns.Add(codeTypeDfn);
|
||||
return true;
|
||||
}
|
||||
public bool RegisterCodesOfType (String codeTypeCode, List<CodeDesc> codeDfns)
|
||||
public bool RegisterCodesOfType(String codeTypeCode, List<CodeDesc> codeDfns)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeTypeDfn codeTypeDfn = GetCodeTypeDefinition(codeTypeCode);
|
||||
if (codeTypeDfn == null) return false;
|
||||
codeTypeDfn.DefaultCodeDefinitions.Clear();
|
||||
foreach (CodeDesc codeDFn in codeDfns)
|
||||
{
|
||||
codeTypeDfn.DefaultCodeDefinitions.Add(new SaCodeDfn(codeDFn.Code,codeDFn.Desc));
|
||||
}
|
||||
codeTypeDfn.DefaultCodeDefinitions.Add(new SaCodeDfn(codeDFn.Code, codeDFn.Desc));
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Populate Code Types.
|
||||
/// <para>- Population continues even if one or more Code Types fail to populate.</para>
|
||||
/// <para>- Error message will reflect the first error encountered.</para>
|
||||
/// </summary>
|
||||
public bool Populate(DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
String errorMessage = "";
|
||||
foreach (SaCodeTypeDfn codeTypeDfn in CodeTypeDefinitions)
|
||||
{
|
||||
// Continue with Code Type population if one or more fail.
|
||||
if (PopulateCodeType(codeTypeDfn.Code, dbUpdateInfo))
|
||||
{
|
||||
//foreach (var code in codeTypeDfn.Codes)
|
||||
// Internals.CodeTypeConsole.PopulateCode(codeTypeDfn.sCode, code.Code, code.Desc);
|
||||
}
|
||||
else if (StringUtil.IsBlank(errorMessage))
|
||||
errorMessage = ErrorStateMessage;
|
||||
}
|
||||
if (StringUtil.IsBlank(errorMessage))
|
||||
SetErrorState(errorMessage);
|
||||
return OK;
|
||||
}
|
||||
|
||||
//*******************************************************************
|
||||
// C o d e T y p e s
|
||||
//*******************************************************************
|
||||
public abstract SaCodeType CreateCodeType(String code);
|
||||
public abstract bool CodeTypeExistsById(SysId codeTypeId);
|
||||
public abstract bool CodeTypeExistsByCode(String codeTypeCode);
|
||||
public abstract int GetCodeTypeCount (SaCodeType.Params prmCodeType);
|
||||
public abstract int GetCodeTypeCount(SaCodeType.Params prmCodeType);
|
||||
public abstract int GetCodeTypeCountById(SysId codeTypeId);
|
||||
public abstract int GetCodeTypeCountByCode(String codeTypeCode);
|
||||
public abstract SaCodeType GetCodeTypeById(SysId codeTypeId);
|
||||
public abstract SaCodeType GetCodeTypeByCode(String codeTypeCode);
|
||||
public abstract SaCodeType GetCodeType(SaCodeType.Params prmCodeType);
|
||||
public abstract List<SaCodeType> GetCodeTypeList (SaCodeType.Params prmCodeType);
|
||||
public abstract List<SaCodeType> GetCodeTypeList(SaCodeType.Params prmCodeType);
|
||||
// Code type list.
|
||||
public abstract ColumnDfn GetCodeTypeColumnDfn (SaCodeType.Column columnId, String caption = "", int width = 0);
|
||||
public abstract DbResultSet ExecuteCodeTypeQuery (List<ColumnDfn> columns, SaCodeType.Params prm);
|
||||
public abstract ColumnDfn GetCodeTypeColumnDfn(SaCodeType.Column columnId, String caption = "", int width = 0);
|
||||
public abstract DbResultSet ExecuteCodeTypeQuery(List<ColumnDfn> columns, SaCodeType.Params prm);
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public abstract DataValue GetCodeTypeDataValue (ColumnDfn column, NamedValue.Map values);
|
||||
public abstract DataValue GetCodeTypeDataValue(ColumnDfn column, NamedValue.Map values);
|
||||
// Population.
|
||||
public abstract bool PopulateCodeType (String codeTypeCode, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool PopulateCodeType(String codeTypeCode, DbUpdateInfo dbUpdateInfo);
|
||||
// Code Type updates.
|
||||
public abstract bool InsertCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
@@ -118,31 +143,31 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Create code.
|
||||
public abstract SaCode CreateCode(SysId codeTypeId, String code);
|
||||
// Check whether code exists.
|
||||
public abstract bool CodeExistsForCodeType (String codeTypeCode, String code, bool activeOnly = true);
|
||||
public abstract bool CodeExistsForCodeType(String codeTypeCode, String code, bool activeOnly = true);
|
||||
// Codes for code type.
|
||||
public abstract bool CodeTypeHasCodes (String codeTypeCode, bool activeOnly = true);
|
||||
public abstract int GetCodeCountForCodeType (String codeTypeCode, bool activeOnly = true);
|
||||
public abstract SaCode GetCodeById (SysId codeId);
|
||||
public abstract bool CodeTypeHasCodes(String codeTypeCode, bool activeOnly = true);
|
||||
public abstract int GetCodeCountForCodeType(String codeTypeCode, bool activeOnly = true);
|
||||
public abstract SaCode GetCodeById(SysId codeId);
|
||||
public abstract SaCode GetCodeForCodeType(String codeTypeCode, String code, bool activeOnly = true);
|
||||
public abstract List<CodeDesc> GetCodeDescsForCodeType (String codeTypeCode, bool activeOnly = true);
|
||||
public abstract List<SaCode> GetCodesForCodeType (String codeTypeCode, bool activeOnly = true);
|
||||
public abstract List<CodeDesc> GetCodeDescsForCodeType(String codeTypeCode, bool activeOnly = true);
|
||||
public abstract List<SaCode> GetCodesForCodeType(String codeTypeCode, bool activeOnly = true);
|
||||
// Code list.
|
||||
public abstract ColumnDfn GetCodeColumnDfn (SaCode.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<SaCode> GetCodeList (SaCode.Params prmCode);
|
||||
public abstract DbResultSet ExecuteCodeQuery (List<ColumnDfn> columns, SaCode.Params prm);
|
||||
public abstract ColumnDfn GetCodeColumnDfn(SaCode.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<SaCode> GetCodeList(SaCode.Params prmCode);
|
||||
public abstract DbResultSet ExecuteCodeQuery(List<ColumnDfn> columns, SaCode.Params prm);
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public abstract DataValue GetCodeDataValue (ColumnDfn column, NamedValue.Map values);
|
||||
public abstract DataValue GetCodeDataValue(ColumnDfn column, NamedValue.Map values);
|
||||
// Codes by filter.
|
||||
public abstract int GetCodeCount (SaCode.Params prmCode);
|
||||
public abstract SaCode GetCode (SaCode.Params prmCode);
|
||||
public abstract int GetCodeCount(SaCode.Params prmCode);
|
||||
public abstract SaCode GetCode(SaCode.Params prmCode);
|
||||
/// <summary>Get filtered code type codes, indexed by Code Type code.</summary>
|
||||
public abstract Dictionary<String, List<SaCode>> GetCodesByCodeType(SaCode.Params prmCode);
|
||||
public abstract Task<Dictionary<String, List<SaCode>>> GetCodesByCodeTypeAsync (SaCode.Params prmCode);
|
||||
public abstract Task<Dictionary<String, List<SaCode>>> GetCodesByCodeTypeAsync(SaCode.Params prmCode);
|
||||
/// <summary>Get filtered codes and descriptions, indexed by Code Type code.</summary>
|
||||
public abstract Dictionary<String, List<CodeDesc>> GetCodeDescsByCodeType (SaCode.Params prmCode);
|
||||
public abstract Dictionary<String, List<CodeDesc>> GetCodeDescsByCodeType(SaCode.Params prmCode);
|
||||
// Code updates.
|
||||
public abstract bool InsertCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
@@ -150,14 +175,14 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create codes.
|
||||
public abstract bool CreateCodeOfType (SysId codeTypeId, String code, String desc, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool CreateCodeOfType (String codeTypeCode, String code, String desc, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool CreateCodeOfType(SysId codeTypeId, String code, String desc, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool CreateCodeOfType(String codeTypeCode, String code, String desc, DbUpdateInfo dbUpdateInfo);
|
||||
// Population.
|
||||
public abstract bool PopulateCode (String codeTypeCode, String code, String desc, bool active, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool PopulateCode(String codeTypeCode, String code, String desc, bool active, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Select codes.
|
||||
public abstract List<String> SelectCodes (String codeTypeCode, List<String> codesSelected);
|
||||
public abstract List<String> SelectCodes(String codeTypeCode, List<String> codesSelected);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Static initialisation.
|
||||
static SaCodeTypeMgr ()
|
||||
static SaCodeTypeMgr()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaCodeTypeMgr ()
|
||||
protected SaCodeTypeMgr()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,29 +35,30 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// C o d e T y p e s
|
||||
//*******************************************************************
|
||||
// Associated data.
|
||||
public abstract bool CodeTypeHasCodes (SysId codeTypeId);
|
||||
public abstract bool CodeTypeHasCodes(SysId codeTypeId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create Item.
|
||||
public abstract SaCodeType CreateCodeType (String code);
|
||||
public abstract SaCodeType CreateCodeType(String code);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual Items.
|
||||
public abstract bool CodeTypeExistsById (SysId id);
|
||||
public abstract bool CodeTypeExistsByCode (String code);
|
||||
public abstract SaCodeType GetCodeType (SaCodeType.Params prmCodeType);
|
||||
public abstract SaCodeType GetCodeTypeById (SysId id);
|
||||
public abstract SaCodeType GetCodeTypeByCode (String code);
|
||||
public abstract bool CodeTypeExists(SaCodeType.Params prmCodeType);
|
||||
public abstract bool CodeTypeExistsById(SysId codeTypeId);
|
||||
public abstract bool CodeTypeExistsByCode(String codeTypeCode);
|
||||
public abstract SaCodeType GetCodeType(SaCodeType.Params prmCodeType);
|
||||
public abstract SaCodeType GetCodeTypeById(SysId codeTypeId);
|
||||
public abstract SaCodeType GetCodeTypeByCode(String codeTypeCode);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate Code Type.
|
||||
public bool IsValidCodeType (SaCodeType codeType)
|
||||
public bool IsValidCodeType(SaCodeType codeType)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (codeType == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidCodeTypeData(codeType.GetData(), new SaCodeType.ErrField());
|
||||
}
|
||||
public virtual bool IsValidCodeTypeData (SaCodeType.Data codeTypeData, SaCodeType.ErrField errField)
|
||||
public virtual bool IsValidCodeTypeData(SaCodeType.Data codeTypeData, SaCodeType.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!IsValidValue(codeTypeData.Code, "code", (long)SaCodeTypeDbDfn.GetColTextLen(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code), true))
|
||||
@@ -96,32 +97,32 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// CodeType database interface.
|
||||
public abstract bool InsertCodeType (SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCodeType (SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool CodeTypeCanBeDeleted (SaCodeType codeType)
|
||||
public abstract bool InsertCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool CodeTypeCanBeDeleted(SaCodeType codeType)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (CodeTypeHasCodes(codeType.Id)) return SetErrorState("code type has codes");
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteCodeType (SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Code Type list.
|
||||
public abstract ColumnDfn GetCodeTypeColumnDfn (SaCodeType.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetCodeTypeQueryFilter (SaCodeType.Params prm);
|
||||
public abstract long GetCodeTypeCount (SaCodeType.Params prm);
|
||||
public abstract List<SaCodeType> GetCodeTypeList (SaCodeType.Params prm);
|
||||
public abstract Task<List<SaCodeType>> GetCodeTypeListAsync (SaCodeType.Params prm);
|
||||
public abstract DbResultSet ExecuteCodeTypeQuery (List<ColumnDfn> columns, SaCodeType.Params prm);
|
||||
public abstract Task<DbResultSet> ExecuteCodeTypeQueryAsync (List<ColumnDfn> columns, SaCodeType.Params prm);
|
||||
public abstract ColumnDfn GetCodeTypeColumnDfn(SaCodeType.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetCodeTypeQueryFilter(SaCodeType.Params prm);
|
||||
public abstract long GetCodeTypeCount(SaCodeType.Params prm);
|
||||
public abstract List<SaCodeType> GetCodeTypeList(SaCodeType.Params prm);
|
||||
public abstract Task<List<SaCodeType>> GetCodeTypeListAsync(SaCodeType.Params prm);
|
||||
public abstract DbResultSet ExecuteCodeTypeQuery(List<ColumnDfn> columns, SaCodeType.Params prm);
|
||||
public abstract Task<DbResultSet> ExecuteCodeTypeQueryAsync(List<ColumnDfn> columns, SaCodeType.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetCodeTypeDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public virtual DataValue GetCodeTypeDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaCodeType.Column)column.Id)
|
||||
@@ -130,15 +131,15 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Item type.
|
||||
case SaCodeType.Column.AutoAssignCode_Y:
|
||||
case SaCodeType.Column.AutoAssignCode_Tick:
|
||||
{
|
||||
ushort flags = (ushort)values.GetValue(column.DataName).AsLong();
|
||||
bool autoAssignCode = SacsHierarchyItem.GetFlag(flags, SaCodeType.Flag_AutoAssignCode);
|
||||
if (column.Id == (int)SaCodeType.Column.AutoAssignCode_Y)
|
||||
value = new DataValue(autoAssignCode ? "Y" : "");
|
||||
else
|
||||
value = new DataValue(autoAssignCode);
|
||||
}
|
||||
break;
|
||||
{
|
||||
ushort flags = (ushort)values.GetValue(column.DataName).AsLong();
|
||||
bool autoAssignCode = SacsHierarchyItem.GetFlag(flags, SaCodeType.Flag_AutoAssignCode);
|
||||
if (column.Id == (int)SaCodeType.Column.AutoAssignCode_Y)
|
||||
value = new DataValue(autoAssignCode ? "Y" : "");
|
||||
else
|
||||
value = new DataValue(autoAssignCode);
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
@@ -150,25 +151,25 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Status.
|
||||
case SaCodeType.Column.Status_Desc:
|
||||
case SaCodeType.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaCodeType.Column.Status_Desc)
|
||||
{
|
||||
String statusDesc = SacsSystem.GetStatusDescForCode(statusCode);
|
||||
value = new DataValue(statusDesc);
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaCodeType.Column.Status_Desc)
|
||||
{
|
||||
String statusDesc = SacsSystem.GetStatusDescForCode(statusCode);
|
||||
value = new DataValue(statusDesc);
|
||||
}
|
||||
else if (column.Id == (int)SaCodeType.Column.Status_Ind)
|
||||
{
|
||||
DataValue.TriStateType triState = DataValue.TriStateType.Unknown;
|
||||
if (status == SaStatus.Current || status == SaStatus.Active)
|
||||
triState = DataValue.TriStateType.Green;
|
||||
value = new DataValue(triState);
|
||||
}
|
||||
}
|
||||
else if (column.Id == (int)SaCodeType.Column.Status_Ind)
|
||||
{
|
||||
DataValue.TriStateType triState = DataValue.TriStateType.Unknown;
|
||||
if (status == SaStatus.Current || status == SaStatus.Active)
|
||||
triState = DataValue.TriStateType.Green;
|
||||
value = new DataValue(triState);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -177,23 +178,23 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// C o d e s
|
||||
//*******************************************************************
|
||||
// Retrieve individual codes.
|
||||
public abstract bool CodeExistsById (SysId id);
|
||||
public abstract SaCode GetCode (SaCode.Params prmCode);
|
||||
public abstract SaCode GetCodeById (SysId id);
|
||||
public abstract SaCode GetCodeByCodeTypeCode (String codeTypeCode, String code);
|
||||
public abstract bool CodeExistsById(SysId id);
|
||||
public abstract SaCode GetCode(SaCode.Params prmCode);
|
||||
public abstract SaCode GetCodeById(SysId id);
|
||||
public abstract SaCode GetCodeByCodeTypeCode(String codeTypeCode, String code);
|
||||
|
||||
// Create code.
|
||||
public abstract SaCode CreateCode (SysId codeTypeId, String code);
|
||||
public abstract SaCode CreateCode(SysId codeTypeId, String code);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate code data.
|
||||
public bool IsValidCode (SaCode code)
|
||||
public bool IsValidCode(SaCode code)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (code == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidCodeData(code.GetData(), new SaCode.ErrField());
|
||||
}
|
||||
public virtual bool IsValidCodeData (SaCode.Data codeData, SaCode.ErrField errField)
|
||||
public virtual bool IsValidCodeData(SaCode.Data codeData, SaCode.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(codeData.CodeTypeId))
|
||||
@@ -237,31 +238,31 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Code database interface.
|
||||
public abstract bool InsertCode (SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCode (SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool CodeCanBeDeleted (SaCode code)
|
||||
public abstract bool InsertCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool CodeCanBeDeleted(SaCode code)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteCode (SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Code list.
|
||||
public abstract ColumnDfn GetCodeColumnDfn (SaCode.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetCodeQueryFilter (SaCode.Params prm);
|
||||
public abstract long GetCodeCount (SaCode.Params prm);
|
||||
public abstract List<SaCode> GetCodeList (SaCode.Params prm);
|
||||
public abstract Task<List<SaCode>> GetCodeListAsync (SaCode.Params prm);
|
||||
public abstract DbResultSet ExecuteCodeQuery (List<ColumnDfn> columns, SaCode.Params prm);
|
||||
public abstract Task<DbResultSet> ExecuteCodeQueryAsync (List<ColumnDfn> columns, SaCode.Params prm);
|
||||
public abstract ColumnDfn GetCodeColumnDfn(SaCode.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetCodeQueryFilter(SaCode.Params prm);
|
||||
public abstract long GetCodeCount(SaCode.Params prm);
|
||||
public abstract List<SaCode> GetCodeList(SaCode.Params prm);
|
||||
public abstract Task<List<SaCode>> GetCodeListAsync(SaCode.Params prm);
|
||||
public abstract DbResultSet ExecuteCodeQuery(List<ColumnDfn> columns, SaCode.Params prm);
|
||||
public abstract Task<DbResultSet> ExecuteCodeQueryAsync(List<ColumnDfn> columns, SaCode.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetCodeDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
public virtual DataValue GetCodeDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
SaCode.Column colId = (SaCode.Column)column.Id;
|
||||
@@ -273,20 +274,20 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
case SaCode.Column.Flag1_Tick:
|
||||
case SaCode.Column.Flag2_Y:
|
||||
case SaCode.Column.Flag2_Tick:
|
||||
{
|
||||
ushort flags = (ushort)values.GetValue(column.DataName).AsLong();
|
||||
bool flag1 = SacsHierarchyItem.GetFlag(flags, 1);
|
||||
bool flag2 = SacsHierarchyItem.GetFlag(flags, 2);
|
||||
if (column.Id == (int)SaCode.Column.Flag1_Y)
|
||||
value = new DataValue(flag1 ? "Y" : "");
|
||||
else if (column.Id == (int)SaCode.Column.Flag1_Tick)
|
||||
value = new DataValue(flag1);
|
||||
else if (column.Id == (int)SaCode.Column.Flag2_Y)
|
||||
value = new DataValue(flag2 ? "Y" : "");
|
||||
else if (column.Id == (int)SaCode.Column.Flag2_Tick)
|
||||
value = new DataValue(flag2);
|
||||
}
|
||||
break;
|
||||
{
|
||||
ushort flags = (ushort)values.GetValue(column.DataName).AsLong();
|
||||
bool flag1 = SacsHierarchyItem.GetFlag(flags, 1);
|
||||
bool flag2 = SacsHierarchyItem.GetFlag(flags, 2);
|
||||
if (column.Id == (int)SaCode.Column.Flag1_Y)
|
||||
value = new DataValue(flag1 ? "Y" : "");
|
||||
else if (column.Id == (int)SaCode.Column.Flag1_Tick)
|
||||
value = new DataValue(flag1);
|
||||
else if (column.Id == (int)SaCode.Column.Flag2_Y)
|
||||
value = new DataValue(flag2 ? "Y" : "");
|
||||
else if (column.Id == (int)SaCode.Column.Flag2_Tick)
|
||||
value = new DataValue(flag2);
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
@@ -298,17 +299,17 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Status.
|
||||
case SaCode.Column.Status_Desc:
|
||||
case SaCode.Column.Status_Ind:
|
||||
{
|
||||
String statusValue = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusValue);
|
||||
if (column.Id == (int)SaCode.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusValue));
|
||||
else if (column.Id == (int)SaCode.Column.Status_Ind)
|
||||
value = new DataValue(SaCode.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
{
|
||||
String statusValue = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusValue);
|
||||
if (column.Id == (int)SaCode.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusValue));
|
||||
else if (column.Id == (int)SaCode.Column.Status_Ind)
|
||||
value = new DataValue(SaCode.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -36,7 +37,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
/// <summary>Test for null, empty or a value that consists of whitespace characters only.</summary>
|
||||
public static bool IsBlank(this string value)
|
||||
{
|
||||
return String.IsNullOrEmpty(value) || Match(value, RegEx_Whitespace_Match);
|
||||
return String.IsNullOrEmpty(value) || IsMatch(value, RegEx_Whitespace_Match);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -65,37 +66,6 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
//-------------------------------------------------------------------
|
||||
// Regular expressions.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Apply Regex.Match to String value and return Match.Success.
|
||||
/// <para>- Case sensitive.</para>
|
||||
/// </summary>
|
||||
public static bool Match(this String value, String expression)
|
||||
{
|
||||
return value.Match(expression, RegexOptions.None);
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Match to String value and return Match.Success, ignoring case.
|
||||
/// <para>- Case insensitive.</para>
|
||||
/// </summary>
|
||||
public static bool MatchCI(this String value, String expression)
|
||||
{
|
||||
return value.Match(expression, RegexOptions.IgnoreCase);
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Match to String value and return Match.Success.
|
||||
/// </summary>
|
||||
public static bool Match(this String value, String expression, RegexOptions options)
|
||||
{
|
||||
return Regex.Match(value, expression, options).Success;
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Match to String value and return Match.Success.
|
||||
/// </summary>
|
||||
public static bool Match(this String value, Regex re)
|
||||
{
|
||||
return re.Match(value).Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply Regex.IsMatch to String value.
|
||||
/// <para>- Case sensitive.</para>
|
||||
@@ -110,7 +80,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
/// </summary>
|
||||
public static bool IsMatchCI(this String value, String expression)
|
||||
{
|
||||
return value.IsMatch(new Regex(Regex.Escape(expression), RegexOptions.IgnoreCase));
|
||||
return value.IsMatch(new Regex(expression, RegexOptions.IgnoreCase));
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.IsMatch to String value.
|
||||
@@ -127,33 +97,100 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
return re.IsMatch(value);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Apply Regex.Match to String value and return match value if successful.
|
||||
/// <para>- Case sensitive.</para>
|
||||
/// </summary>
|
||||
public static String GetMatch(this String value, String expression)
|
||||
{
|
||||
Match match = value.Match(expression, RegexOptions.None);
|
||||
return match.Success ? match.Value : null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Match to String value and return match value if successful, ignoring case.
|
||||
/// <para>- Case insensitive.</para>
|
||||
/// </summary>
|
||||
public static String GetMatchCI(this String value, String expression)
|
||||
{
|
||||
Match match = value.Match(expression, RegexOptions.IgnoreCase);
|
||||
return match.Success ? match.Value : null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Match to String value and return match.
|
||||
/// </summary>
|
||||
public static Match Match(this String value, String expression, RegexOptions options)
|
||||
{
|
||||
return Regex.Match(value, expression, options);
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Match to String value and return match.
|
||||
/// </summary>
|
||||
public static Match Match(this String value, Regex re)
|
||||
{
|
||||
return re.Match(value);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Apply Regex.Matches to String value and returns matches.
|
||||
/// <para>- Case sensitive.</para>
|
||||
/// </summary>
|
||||
public static List<String> GetMatches(this String value, String expression)
|
||||
{
|
||||
return value.Matches(expression, RegexOptions.None).Where(item => item.Success).Select(item => item.Value).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Matches to String value and returns matches, ignoring case.
|
||||
/// <para>- Case insensitive.</para>
|
||||
/// </summary>
|
||||
public static List<String> GetMatchesCI(this String value, String expression)
|
||||
{
|
||||
return value.Matches(expression, RegexOptions.IgnoreCase).Where(item => item.Success).Select(item => item.Value).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Matches to String value and returns matches.
|
||||
/// </summary>
|
||||
public static MatchCollection Matches(this String value, String expression, RegexOptions options)
|
||||
{
|
||||
return Regex.Matches(value, expression, options);
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Matches to String value and returns matches.
|
||||
/// </summary>
|
||||
public static MatchCollection Matches(this String value, Regex re)
|
||||
{
|
||||
return re.Matches(value);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Apply Regex.Matches to String value and return number of matches found.
|
||||
/// <para>- Case sensitive.</para>
|
||||
/// </summary>
|
||||
public static int MatchCount(this String value, String expression)
|
||||
public static int GetMatchCount(this String value, String expression)
|
||||
{
|
||||
return value.MatchCount(expression, RegexOptions.None);
|
||||
return value.MatchesCount(expression, RegexOptions.None);
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Matches to String value and return number of matches found.
|
||||
/// <para>- Case insensitive.</para>
|
||||
/// </summary>
|
||||
public static int MatchCountCI(this String value, String expression)
|
||||
public static int GetMatchCountCI(this String value, String expression)
|
||||
{
|
||||
return value.MatchCount(expression, RegexOptions.IgnoreCase);
|
||||
return value.MatchesCount(expression, RegexOptions.IgnoreCase);
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Matches to String value and return number of matches found.
|
||||
/// </summary>
|
||||
public static int MatchCount(this String value, String expression, RegexOptions options)
|
||||
public static int MatchesCount(this String value, String expression, RegexOptions options)
|
||||
{
|
||||
return Regex.Matches(value, expression, options).Count;
|
||||
}
|
||||
/// <summary>
|
||||
/// Apply Regex.Matches to String value and return number of matches found.
|
||||
/// </summary>
|
||||
public static int MatchCount(this String value, Regex re)
|
||||
public static int MatchesCount(this String value, Regex re)
|
||||
{
|
||||
return re.Matches(value).Count;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,25 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
public override int GetCodeTypeCount(SaCodeType.Params prmCodeType)
|
||||
{
|
||||
ClearErrorState();
|
||||
return (int)codeTypeMgr.GetCodeTypeCount(prmCodeType);
|
||||
int count = (int)codeTypeMgr.GetCodeTypeCount(prmCodeType);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return count;
|
||||
}
|
||||
public override int GetCodeTypeCountById(SysId codeTypeId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(codeTypeId)) return 0;
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.IdsIncluded.AddId(codeTypeId);
|
||||
return GetCodeTypeCount(prmCodeType);
|
||||
}
|
||||
public override int GetCodeTypeCountByCode(String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsBlank(codeTypeCode)) return 0;
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.Code = codeTypeCode;
|
||||
return GetCodeTypeCount(prmCodeType);
|
||||
}
|
||||
|
||||
// Get Code Type.
|
||||
@@ -101,13 +119,6 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return codeType;
|
||||
}
|
||||
public override SaCodeType GetCodeType(SaCodeType.Params prmCodeType)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeType codeType = codeTypeMgr.GetCodeType(prmCodeType);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return codeType;
|
||||
}
|
||||
|
||||
// Get name for Code Type.
|
||||
public override String GetNameForCodeType(String codeTypeCode)
|
||||
@@ -528,6 +539,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
// Create code type.
|
||||
codeType = codeTypeMgr.CreateCodeType(codeTypeCode);
|
||||
codeType.Name = codeTypeDfn.Description;
|
||||
codeType.MaxCodeLen = codeTypeDfn.MaxCodeLen;
|
||||
codeType.Notes = codeTypeDfn.Notes;
|
||||
codeType.Status = SaCodeType.DefaultStatus;
|
||||
if (!codeTypeMgr.InsertCodeType(codeType, dbUpdateInfo))
|
||||
@@ -537,6 +549,9 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
{
|
||||
// Code type exists - refresh properties.
|
||||
codeType.Name = codeTypeDfn.Description;
|
||||
codeType.MaxCodeLen = codeTypeDfn.MaxCodeLen;
|
||||
if (codeTypeDfn.MaxCodeLen > 0)
|
||||
codeType.MaxCodeLen = codeTypeDfn.MaxCodeLen;
|
||||
if (StringUtil.IsEmpty(codeType.Notes))
|
||||
codeType.Notes = codeTypeDfn.Notes;
|
||||
codeType.Status = SaCodeType.DefaultStatus;
|
||||
|
||||
@@ -79,17 +79,26 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public override bool CodeTypeExistsById(SysId id)
|
||||
public override bool CodeTypeExists(SaCodeType.Params prmCodeType)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
return GetCodeTypeCount($"{SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Id, aliasCodeType)}={SysId.ToLong(id)}") == 1;
|
||||
return GetCodeTypeCount(prmCodeType) == 1;
|
||||
}
|
||||
public override bool CodeTypeExistsByCode(string code)
|
||||
public override bool CodeTypeExistsById(SysId codeTypeId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(code)) return false;
|
||||
return GetCodeTypeCount($"{SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code, aliasCodeType)}='{DbQuery.FormatForCondition(code)}'") == 1;
|
||||
if (!SysId.IsValid(codeTypeId)) return false;
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.IdsIncluded.AddId(codeTypeId);
|
||||
return CodeTypeExists(prmCodeType);
|
||||
}
|
||||
public override bool CodeTypeExistsByCode(string codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsBlank(codeTypeCode)) return false;
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.Code = codeTypeCode;
|
||||
return CodeTypeExists(prmCodeType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -123,17 +132,21 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
ClearErrorState();
|
||||
return GetCodeType(GetCodeTypeQueryFilter(prmCodeType).Concat(" And ", "(", ")"));
|
||||
}
|
||||
public override SaCodeType GetCodeTypeById(SysId id)
|
||||
public override SaCodeType GetCodeTypeById(SysId codeTypeId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
return GetCodeType("Id=" + SysId.ToString(id));
|
||||
if (!SysId.IsValid(codeTypeId)) return null;
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.IdsIncluded.AddId(codeTypeId);
|
||||
return GetCodeType(prmCodeType);
|
||||
}
|
||||
public override SaCodeType GetCodeTypeByCode(string code)
|
||||
public override SaCodeType GetCodeTypeByCode(string codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(code)) return null;
|
||||
return GetCodeType("Code='" + DbQuery.FormatForCondition(code) + "'");
|
||||
if (StringUtil.IsBlank(codeTypeCode)) return null;
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.Code = codeTypeCode;
|
||||
return GetCodeType(prmCodeType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -449,16 +462,16 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item count.
|
||||
private long GetCodeTypeCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
return Database.GetRowCount(TableName_CodeType + " As " + aliasCodeType, filter);
|
||||
}
|
||||
public override long GetCodeTypeCount(SaCodeType.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
return GetCodeTypeCount(GetCodeTypeQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
}
|
||||
private long GetCodeTypeCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
return Database.GetRowCount(TableName_CodeType + " As " + aliasCodeType, filter);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
|
||||
Reference in New Issue
Block a user