BusinessMgr
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Code type properties.
|
||||
CodeTypeId,
|
||||
CodeType_Code,
|
||||
CodeType_Desc,
|
||||
CodeType_Name,
|
||||
// Code properties.
|
||||
Id,
|
||||
Code,
|
||||
@@ -205,16 +205,20 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
||||
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
||||
public List<SysId> CodeTypeIds { get; } = new List<SysId>();
|
||||
public List<String> CodeTypeCodes { get; } = new List<string>();
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> CodeTypeIds { get; } = new HashSet<SysId>();
|
||||
public HashSet<String> CodeTypeCodes { get; } = new HashSet<string>();
|
||||
/// <summary>Generic search - code, description etc.</summary>
|
||||
public string Search{ get; set; }
|
||||
public string Code { get; set; }
|
||||
public string CodePartial { get; set; }
|
||||
public string Desc { get; set; }
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Code type properties.
|
||||
Id,
|
||||
Code,
|
||||
Description,
|
||||
Name,
|
||||
MaxCodeLen,
|
||||
CodeFormat,
|
||||
NextCode,
|
||||
@@ -39,7 +39,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
public class DataProperties
|
||||
{
|
||||
public String Code { get; set; } = String.Empty;
|
||||
public String Description { get; set; } = String.Empty;
|
||||
public String Name { get; set; } = String.Empty;
|
||||
public byte MaxCodeLen { get; set; } = 0;
|
||||
public String CodeFormat { get; set; } = String.Empty;
|
||||
public String NextCode { get; set; } = String.Empty;
|
||||
@@ -52,7 +52,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data ()
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
@@ -62,10 +62,10 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
get { return data.Code; }
|
||||
set { CheckChanged(data.Code, value); data.Code = value; }
|
||||
}
|
||||
public String Description
|
||||
public String Name
|
||||
{
|
||||
get { return data.Description; }
|
||||
set { CheckChanged(data.Description, value); data.Description = value; }
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = value; }
|
||||
}
|
||||
public byte MaxCodeLen
|
||||
{
|
||||
@@ -83,16 +83,16 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
set { CheckChanged(data.NextCode, value); data.NextCode = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom (Data data)
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
Code = data.Code;
|
||||
Description = data.Description;
|
||||
Name = data.Name;
|
||||
MaxCodeLen = data.MaxCodeLen;
|
||||
CodeFormat = data.CodeFormat;
|
||||
NextCode = data.NextCode;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone ()
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
@@ -106,7 +106,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue Code { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Description { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue MaxCodeLen { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CodeFormat { get; set; } = ValidValue.Valid;
|
||||
public ValidValue NextCode { get; set; } = ValidValue.Valid;
|
||||
@@ -120,7 +120,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaCodeType (SysId id, String code) :
|
||||
public SaCodeType(SysId id, String code) :
|
||||
base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
@@ -137,7 +137,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
public static SaStatus DefaultStatus { get { return CurrentStatus; } }
|
||||
public static SaStatus CurrentStatus { get { return SaStatus.Current; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState (SaStatus status)
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
@@ -151,8 +151,8 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData () { return data.Clone(); }
|
||||
public void SetData (Data data)
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
@@ -167,10 +167,10 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
get { return data.Code; }
|
||||
set { data.Code = value; }
|
||||
}
|
||||
public String Description
|
||||
public String Name
|
||||
{
|
||||
get { return data.Description; }
|
||||
set { data.Description = value; }
|
||||
get { return data.Name; }
|
||||
set { data.Name = value; }
|
||||
}
|
||||
public byte MaxCodeLen
|
||||
{
|
||||
@@ -201,19 +201,23 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
||||
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
/// <summary>Generic search - code or name etc.</summary>
|
||||
public String Search { get; set; }
|
||||
public String Code { get; set; }
|
||||
public String CodePartial { get; set; }
|
||||
public String Desc { get; set; }
|
||||
public String DescPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
public String Name { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
return null;
|
||||
}
|
||||
public abstract SaCodeTypeDfn GetCodeTypeDefinition (SysId codeTypeId);
|
||||
public virtual String GetDescForCodeType (String codeTypeCode)
|
||||
public virtual String GetNameForCodeType (String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeTypeDfn codeTypeDfn = GetCodeTypeDefinition(codeTypeCode);
|
||||
@@ -85,9 +85,13 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
//*******************************************************************
|
||||
// C o d e T y p e s
|
||||
//*******************************************************************
|
||||
public abstract bool CodeTypeExists (String codeTypeCode);
|
||||
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 SaCodeType GetCodeType (SaCodeType.Params prmCodeType);
|
||||
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);
|
||||
// Code type list.
|
||||
public abstract ColumnDfn GetCodeTypeColumnDfn (SaCodeType.Column columnId, String caption = "", int width = 0);
|
||||
@@ -99,21 +103,29 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
public abstract DataValue GetCodeTypeDataValue (ColumnDfn column, NamedValue.Map values);
|
||||
// Population.
|
||||
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);
|
||||
public abstract bool DeleteCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
// Maintain code types - returns true if changes made.
|
||||
public abstract bool MaintainCodeTypes (bool userCanManageCodeTypes, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool MaintainCodeType (String codeTypeCode, DbUpdateInfo dbUpdateInfo);
|
||||
// NB Only relevant to desktop application.
|
||||
public abstract bool MaintainCodeTypes(bool userCanManageCodeTypes, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool MaintainCodeType(String codeTypeCode, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//*******************************************************************
|
||||
// C o d e s
|
||||
//*******************************************************************
|
||||
// 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);
|
||||
// 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 GetCodeForCodeType (String codeTypeCode, String code, 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> GetCodeListForCodeType (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);
|
||||
@@ -126,11 +138,15 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Codes by filter.
|
||||
public abstract int GetCodeCount (SaCode.Params prmCode);
|
||||
public abstract SaCode GetCode (SaCode.Params prmCode);
|
||||
/// <summary>Get filtered codes, indexed by Code Type code.</summary>
|
||||
public abstract Dictionary<String, List<SaCode>> GetCodesByCodeType (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);
|
||||
/// <summary>Get filtered codes and descriptions, indexed by Code Type code.</summary>
|
||||
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);
|
||||
public abstract bool DeleteCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create codes.
|
||||
|
||||
@@ -65,9 +65,9 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
errField.Code = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!IsValidValue(codeTypeData.Description, "description", (long)SaCodeTypeDbDfn.GetColTextLen(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name), true))
|
||||
if (!IsValidValue(codeTypeData.Name, "description", (long)SaCodeTypeDbDfn.GetColTextLen(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name), true))
|
||||
{
|
||||
errField.Description = SacsHierarchyItem.ValidValue.Invalid;
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!IsValidValue(codeTypeData.CodeFormat, "code format", (long)SaCodeTypeDbDfn.GetColTextLen(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_CodeFormat)))
|
||||
|
||||
@@ -332,7 +332,7 @@ namespace Sarand.Net.Standard.Base.Dbas
|
||||
/// <para>- Format as: ('Value1','Value2','Value3') if string data, else (Value1,Value2,Value3) etc.</para>
|
||||
/// <para>- Returns empty string if list is empty.</para>
|
||||
/// </summary>
|
||||
public static String FormatForIn(List<String> rawValues, bool stringData = true, bool ignoreBlanks = true)
|
||||
public static String FormatForIn(IEnumerable<String> rawValues, bool stringData = true, bool ignoreBlanks = true)
|
||||
{
|
||||
String result = String.Empty;
|
||||
List<String> values = new List<String>();
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
|
||||
struct _IMAGE_FILE_HEADER
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
public ushort Machine;
|
||||
public ushort NumberOfSections;
|
||||
public uint TimeDateStamp;
|
||||
@@ -23,6 +24,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
public uint NumberOfSymbols;
|
||||
public ushort SizeOfOptionalHeader;
|
||||
public ushort Characteristics;
|
||||
#pragma warning restore CS0649
|
||||
};
|
||||
|
||||
public static DateTime GetBuildDateTime (this Assembly assembly)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
public static class EnumUtil
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static bool IsValid<TEnum> (int value) where TEnum : struct, IConvertible
|
||||
public static bool IsValid<TEnum>(int value) where TEnum : struct, IConvertible
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
catch (Exception) { }
|
||||
return false;
|
||||
}
|
||||
public static bool IsValid<TEnum> (String value) where TEnum : struct, IConvertible
|
||||
public static bool IsValid<TEnum>(String value) where TEnum : struct, IConvertible
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -29,6 +29,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
catch (Exception) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Get Name for enum value.
|
||||
@@ -36,10 +37,11 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
/// <typeparam name="TEnum"></typeparam>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static String GetName<TEnum> (Object value) where TEnum : struct, IConvertible
|
||||
public static String GetName<TEnum>(Object value) where TEnum : struct, IConvertible
|
||||
{
|
||||
return Enum.GetName(typeof(TEnum), value);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// <para>Get enum values.</para>
|
||||
@@ -47,10 +49,11 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
/// </summary>
|
||||
/// <typeparam name="TEnum">Enum type</typeparam>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<TEnum> GetValues<TEnum> () where TEnum : struct, IConvertible
|
||||
public static IEnumerable<TEnum> GetValues<TEnum>() where TEnum : struct, IConvertible
|
||||
{
|
||||
return Enum.GetValues(typeof(TEnum)).Cast<TEnum>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// <para>Convert String to enum.</para>
|
||||
@@ -58,11 +61,11 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
/// <typeparam name="TEnum"></typeparam>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static TEnum ParseEnum<TEnum> (string value) where TEnum : struct, IConvertible
|
||||
public static TEnum ParseEnum<TEnum>(string value) where TEnum : struct, IConvertible
|
||||
{
|
||||
return (TEnum)Enum.Parse(typeof(TEnum), value, true);
|
||||
}
|
||||
public static TEnum ParseEnum<TEnum> (string value, TEnum defaultValue) where TEnum : struct, IConvertible
|
||||
public static TEnum ParseEnum<TEnum>(string value, TEnum defaultValue) where TEnum : struct, IConvertible
|
||||
{
|
||||
if (StringUtil.IsEmpty(value)) return defaultValue;
|
||||
try
|
||||
@@ -72,6 +75,22 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
catch (Exception exc) { SaLogger.Debug("EnumUtil.ParseEnum " + ExceptionUtil.GetErrorStateMessage(exc) + " [Enum: " + typeof(TEnum).Name + ". Value: " + value + "]"); }
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public static HashSet<TEnum> ParseEnums<TEnum>(IEnumerable<String> values) where TEnum : struct, IConvertible
|
||||
{
|
||||
HashSet<TEnum> enums = new HashSet<TEnum>();
|
||||
foreach (String value in values)
|
||||
{
|
||||
try
|
||||
{
|
||||
enums.Add((TEnum)Enum.Parse(typeof(TEnum), value, true));
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Debug("EnumUtil.ParseEnums " + ExceptionUtil.GetErrorStateMessage(exc) + " [Enum: " + typeof(TEnum).Name + ". Value: " + value + "]"); }
|
||||
}
|
||||
return enums;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Retrieve the first enum value whose name starts with the specified value.
|
||||
@@ -80,7 +99,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
/// <param name="value"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public static TEnum StartsWith<TEnum> (string value, TEnum defaultValue) where TEnum : struct, IConvertible
|
||||
public static TEnum StartsWith<TEnum>(string value, TEnum defaultValue) where TEnum : struct, IConvertible
|
||||
{
|
||||
foreach (TEnum t in GetValues<TEnum>())
|
||||
{
|
||||
@@ -89,6 +108,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
Reference in New Issue
Block a user