270 lines
8.3 KiB
C#
270 lines
8.3 KiB
C#
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
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
|
|
{
|
|
//=======================================================================
|
|
public abstract class SbmSystemAccount : SbmHierarchyItem
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Columns.
|
|
public enum Column
|
|
{
|
|
//Hidden.
|
|
Pos,
|
|
Id,
|
|
// SystemAccount.
|
|
Type_Desc,
|
|
Code,
|
|
Name,
|
|
UserCount,
|
|
Interface_Code,
|
|
Interface_Caption,
|
|
Assoc_Status_Desc,
|
|
Assoc_Status_Ind,
|
|
// Common properties.
|
|
Notes,
|
|
Flag,
|
|
Status,
|
|
Status_Desc,
|
|
Status_Ind,
|
|
CreateOn_Date,
|
|
UpdateOn_Date,
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Properties other than common.</summary>
|
|
public class DataProperties
|
|
{
|
|
public SysId AffiliateIdOwner { get; set; } = new SysId();
|
|
public Sbm.SystemAccountType SystemAccountType { get; set; } = Sbm.SystemAccountType.Unknown;
|
|
public SysId InterfaceId { get; set; } = new SysId();
|
|
public SysId AssociationId { get; set; } = new SysId();
|
|
public String Code { get; set; } = "";
|
|
public String Name { get; set; } = "";
|
|
public String AuthCodeEnc { get; set; } = "";
|
|
}
|
|
|
|
// Data.
|
|
public new class Data : SacsHierarchyItem.Data
|
|
{
|
|
// Data members.
|
|
private readonly DataProperties data = new DataProperties();
|
|
// Construction.
|
|
public Data()
|
|
{
|
|
Status = DefaultStatus;
|
|
}
|
|
|
|
public SysId AffiliateIdOwner
|
|
{
|
|
get { return data.AffiliateIdOwner; }
|
|
set { CheckChanged(data.AffiliateIdOwner, value); data.AffiliateIdOwner = value; }
|
|
}
|
|
public Sbm.SystemAccountType SystemAccountType
|
|
{
|
|
get { return data.SystemAccountType; }
|
|
set { CheckChanged((int)data.SystemAccountType, (int)value); data.SystemAccountType = value; }
|
|
}
|
|
public SysId InterfaceId
|
|
{
|
|
get { return data.InterfaceId; }
|
|
set { CheckChanged(data.InterfaceId, value); data.InterfaceId = value; }
|
|
}
|
|
public SysId AssociationId
|
|
{
|
|
get { return data.AssociationId; }
|
|
set { CheckChanged(data.AssociationId, value); data.AssociationId = value; }
|
|
}
|
|
public String Code
|
|
{
|
|
get { return data.Code; }
|
|
set { CheckChanged(data.Code, value); data.Code = value; }
|
|
}
|
|
public String Name
|
|
{
|
|
get { return data.Name; }
|
|
set { CheckChanged(data.Name, value); data.Name = value; }
|
|
}
|
|
public String AuthCodeEnc
|
|
{
|
|
get { return data.AuthCodeEnc; }
|
|
set { CheckChanged(data.AuthCodeEnc, value); data.AuthCodeEnc = value; }
|
|
}
|
|
|
|
internal void PopulateFrom(Data data)
|
|
{
|
|
AffiliateIdOwner = data.AffiliateIdOwner;
|
|
SystemAccountType = data.SystemAccountType;
|
|
InterfaceId = data.InterfaceId;
|
|
AssociationId = data.AssociationId;
|
|
Code = data.Code;
|
|
Name = data.Name;
|
|
AuthCodeEnc = data.AuthCodeEnc;
|
|
base.PopulateFrom(data);
|
|
}
|
|
public Data Clone()
|
|
{
|
|
Data data = new Data();
|
|
data.PopulateFrom(this);
|
|
|
|
return data;
|
|
}
|
|
}
|
|
|
|
public new class ErrField : SacsHierarchyItem.ErrField
|
|
{
|
|
// Identifies the field that has invalid data.
|
|
public ValidValue AffiliateIdOwner { get; set; } = ValidValue.Valid;
|
|
public ValidValue SystemAccountType { get; set; } = ValidValue.Valid;
|
|
public ValidValue InterfaceId { get; set; } = ValidValue.Valid;
|
|
public ValidValue AssociationId { get; set; } = ValidValue.Valid;
|
|
public ValidValue Code { get; set; } = ValidValue.Valid;
|
|
public ValidValue Name { get; set; } = ValidValue.Valid;
|
|
public ValidValue AuthCodeEnc { get; set; } = ValidValue.Valid;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly Data data = new Data();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SbmSystemAccount(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.SystemAccountType systemAccountType, SysId interfaceId, SysId associationId) : base(userContext, id)
|
|
{
|
|
base.SetData(data);
|
|
AffiliateIdOwner = affiliateIdOwner;
|
|
SystemAccountType = systemAccountType;
|
|
InterfaceId = interfaceId;
|
|
AssociationId = associationId;
|
|
Status = DefaultStatus;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// SystemAccount status.
|
|
private static readonly List<SaStatus> systemAccountStatuses = new List<SaStatus>()
|
|
{
|
|
SaStatus.Active,
|
|
SaStatus.Disabled,
|
|
};
|
|
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
|
public static List<SaStatus> SystemAccountStatuses { get { return new List<SaStatus>(systemAccountStatuses); } }
|
|
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
|
{
|
|
switch (status)
|
|
{
|
|
case SaStatus.Active:
|
|
return DataValue.TriStateType.Green;
|
|
case SaStatus.OnHold:
|
|
return DataValue.TriStateType.Amber;
|
|
case SaStatus.Cancelled:
|
|
return DataValue.TriStateType.Red;
|
|
case SaStatus.Disabled:
|
|
return DataValue.TriStateType.Red;
|
|
case SaStatus.Deleted:
|
|
return DataValue.TriStateType.Purple;
|
|
}
|
|
return DataValue.TriStateType.Unknown;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
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))
|
|
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);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Attributes.
|
|
public SysId AffiliateIdOwner
|
|
{
|
|
get { return data.AffiliateIdOwner; }
|
|
set { data.AffiliateIdOwner = value; }
|
|
}
|
|
public Sbm.SystemAccountType SystemAccountType
|
|
{
|
|
get { return data.SystemAccountType; }
|
|
set { data.SystemAccountType = value; }
|
|
}
|
|
public SysId InterfaceId
|
|
{
|
|
get { return data.InterfaceId; }
|
|
set { data.InterfaceId = value; }
|
|
}
|
|
public SysId AssociationId
|
|
{
|
|
get { return data.AssociationId; }
|
|
set { data.AssociationId = value; }
|
|
}
|
|
public String Code
|
|
{
|
|
get { return data.Code; }
|
|
set { data.Code = value; }
|
|
}
|
|
public String Name
|
|
{
|
|
get { return data.Name; }
|
|
set { data.Name = value; }
|
|
}
|
|
public String AuthCodeEnc
|
|
{
|
|
get { return data.AuthCodeEnc; }
|
|
set { data.AuthCodeEnc = value; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// A s s o c i a t e d D a t a E l e m e n t s
|
|
//-------------------------------------------------------------------
|
|
public abstract bool HasUsers();
|
|
|
|
//-------------------------------------------------------------------
|
|
// P a r a m s
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Parameters - used to define the filters that should be applied to a List of System Accounts</summary>
|
|
// List parameters.
|
|
public enum StatusCat
|
|
{
|
|
Any,
|
|
}
|
|
/// <summary>
|
|
/// Item list parameters.
|
|
/// </summary>
|
|
public new class Params : SacsHierarchyItem.Params
|
|
{
|
|
// List filtering.
|
|
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
|
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
|
// SystemAccount.
|
|
public Sbm.SystemAccountType Type { get; set; } = Sbm.SystemAccountType.Customer;
|
|
public SysId InterfaceId { get; set; }
|
|
public SysId AssocId { get; set; }
|
|
public SysId AffiliateExcludeIdUserAccounts { get; set; }
|
|
public String Code { get; set; }
|
|
public String CodePartial { get; set; }
|
|
public String Name { get; set; }
|
|
public String NamePartial { get; set; }
|
|
public bool RestrictToActive { get; set; }
|
|
|
|
public StatusCat StatusCat { get; set; } = StatusCat.Any;
|
|
// Assignment.
|
|
}
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
// S y s t e m A c c o u n t D a t a L i s t
|
|
//=======================================================================
|
|
}
|