Add project files.
This commit is contained in:
@@ -0,0 +1,257 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SbmAssetProcess : SbmHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Hidden,
|
||||
Pos,
|
||||
Id,
|
||||
// AssetProcess.
|
||||
AssetId,
|
||||
Seq,
|
||||
ProcessId,
|
||||
RequiredOn,
|
||||
ExpectedOn,
|
||||
ProcessedOn,
|
||||
// Common properties.
|
||||
Notes,
|
||||
Flag,
|
||||
Status,
|
||||
Status_Ind,
|
||||
Status_Desc,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId AssetId { get; set; } = new SysId();
|
||||
public String Seq { get; set; } = "";
|
||||
public SysId ProcessId { get; set; } = new SysId();
|
||||
public DateTime RequiredOn { get; set; } = DateTime.MinValue;
|
||||
public DateTime ExpectedOn { get; set; } = DateTime.MinValue;
|
||||
public DateTime ProcessedOn { get; set; } = DateTime.MinValue;
|
||||
}
|
||||
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
public SysId AssetId
|
||||
{
|
||||
get { return data.AssetId; }
|
||||
set { CheckChanged(data.AssetId, value); data.AssetId = value; }
|
||||
}
|
||||
public String Seq
|
||||
{
|
||||
get { return data.Seq; }
|
||||
set { CheckChanged(data.Seq, value); data.Seq = value; }
|
||||
}
|
||||
public SysId ProcessId
|
||||
{
|
||||
get { return data.ProcessId; }
|
||||
set { CheckChanged(data.ProcessId, value); data.ProcessId = value; }
|
||||
}
|
||||
public DateTime RequiredOn
|
||||
{
|
||||
get { return data.RequiredOn; }
|
||||
set { CheckChanged(data.RequiredOn, value); data.RequiredOn = value; }
|
||||
}
|
||||
public DateTime ExpectedOn
|
||||
{
|
||||
get { return data.ExpectedOn; }
|
||||
set { CheckChanged(data.ExpectedOn, value); data.ExpectedOn = value; }
|
||||
}
|
||||
public DateTime ProcessedOn
|
||||
{
|
||||
get { return data.ProcessedOn; }
|
||||
set { CheckChanged(data.ProcessedOn, value); data.ProcessedOn = value; }
|
||||
}
|
||||
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
AssetId = data.AssetId;
|
||||
Seq = data.Seq;
|
||||
ProcessId = data.ProcessId;
|
||||
RequiredOn = data.RequiredOn;
|
||||
ExpectedOn = data.ExpectedOn;
|
||||
ProcessedOn = data.ProcessedOn;
|
||||
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 AssetId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Seq { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProcessId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RequiredOn { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpectedOn { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProcessedOn { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmAssetProcess(SbmUserContext userContext, SysId id, SysId assetId, SysId processId) : base(userContext, id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Id = id;
|
||||
AssetId = assetId;
|
||||
ProcessId = processId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// AssetProcess status.
|
||||
private static readonly List<SaStatus> assetCategoryStatuses = new List<SaStatus>()
|
||||
{
|
||||
/*SaStatus.Provisional,*/
|
||||
SaStatus.Active,
|
||||
/*SaStatus.Actioned,*/
|
||||
SaStatus.Cancelled,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
||||
public static List<SaStatus> AssetProcessStatuses { get { return new List<SaStatus>(assetCategoryStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case SaStatus.Active:
|
||||
return DataValue.TriStateType.Green;
|
||||
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)
|
||||
{
|
||||
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");
|
||||
// Populate individual properties to ensure that 'Changed' indicator is kept up to date.
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Attributes.
|
||||
public SysId AssetId
|
||||
{
|
||||
get { return data.AssetId; }
|
||||
set { data.AssetId = value; }
|
||||
}
|
||||
public String Seq
|
||||
{
|
||||
get { return data.Seq; }
|
||||
set { data.Seq = value; }
|
||||
}
|
||||
public SysId ProcessId
|
||||
{
|
||||
get { return data.ProcessId; }
|
||||
set { data.ProcessId = value; }
|
||||
}
|
||||
public DateTime RequiredOn
|
||||
{
|
||||
get { return data.RequiredOn; }
|
||||
set { data.RequiredOn = value; }
|
||||
}
|
||||
public DateTime ExpectedOn
|
||||
{
|
||||
get { return data.ExpectedOn; }
|
||||
set { data.ExpectedOn = value; }
|
||||
}
|
||||
public DateTime ProcessedOn
|
||||
{
|
||||
get { return data.ProcessedOn; }
|
||||
set { data.ProcessedOn = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Parameters - used to define the filters that should be applied to a List of Asset Processes</summary>
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
||||
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
||||
// AssetProcess.
|
||||
public SysId AssetId { get; set; }
|
||||
public SysId ProcessId { get; set; }
|
||||
public String Seq { get; set; }
|
||||
public bool RestrictToActive { get; set; }
|
||||
/// <summary>Asset Process status.</summary>
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.Any;
|
||||
// Utilities.
|
||||
public List<StringPair> GetDisplayValues()
|
||||
{
|
||||
List<StringPair> values = new List<StringPair>();
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// A s s e t D a t a L i s t
|
||||
//=======================================================================
|
||||
public static class SbmAssetProcessList
|
||||
{
|
||||
/// <summary>Check whether assetCategory exists/locate in list with specified Id.</summary>
|
||||
public static bool FindById(this List<SbmAssetProcess> values, SysId assetCategoryId)
|
||||
{
|
||||
if (!SysId.IsValid(assetCategoryId)) return false;
|
||||
return values.Exists(item => item.Id.Equals(assetCategoryId));
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user