Move Saxonite’s projects into a dedicated `Workspace` folder and align the solution with .NET 10 and the current Common workspace. Update encryption integration, test project structure and coverage, and repository guidance and upgrade notes. - Relocate application and library projects while retaining Git rename history. - Split tests into Admin, Online, and Shared projects; add representative behavioral and serialization tests. - Update Common integration, application version, and repository documentation. Application version: 1.3.0 Reviewed-on: #1 Co-authored-by: andy <andy@sarand.com>
477 lines
14 KiB
C#
477 lines
14 KiB
C#
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using Saxonite.Net.Standard.Base.App;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Saxonite.Net.Standard.Base.Bus
|
|
{
|
|
//=======================================================================
|
|
// ItemAddress.
|
|
//=======================================================================
|
|
public abstract class SaxItemAddress : SaxDisposableHierarchyItem
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Columns.
|
|
public enum Column
|
|
{
|
|
Pos,
|
|
Id,
|
|
// Item.
|
|
ItemType,
|
|
ItemType_Code,
|
|
ItemType_Desc,
|
|
ItemId,
|
|
Item_Caption,
|
|
// Address.
|
|
AddressType,
|
|
AddressType_Code,
|
|
AddressType_Desc,
|
|
Caption,
|
|
Line1,
|
|
Line2,
|
|
Line3,
|
|
Town,
|
|
Province,
|
|
Country,
|
|
PostalCode,
|
|
PhoneMain,
|
|
// Regions.
|
|
RegionIdProvince,
|
|
RegionProvince_Name,
|
|
RegionIdCountry,
|
|
RegionCountry_Name,
|
|
// Location.
|
|
// Associated data.
|
|
// Common.
|
|
Notes,
|
|
Flags,
|
|
Status,
|
|
Status_Desc,
|
|
Status_Ind,
|
|
CreateOn_Date,
|
|
UpdateOn_Date,
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Properties other than common.</summary>
|
|
public class DataProperties
|
|
{
|
|
public ItemId ItemId { get; set; } = new ItemId();
|
|
public Sax.AddressType AddressType { get; set; }
|
|
public String Caption { get; set; }
|
|
public String Line1 { get; set; }
|
|
public String Line2 { get; set; }
|
|
public String Line3 { get; set; }
|
|
public String Town { get; set; }
|
|
public String Province { get; set; }
|
|
public SysId RegionIdProvince { get; set; }
|
|
public String Country { get; set; }
|
|
public SysId RegionIdCountry { get; set; }
|
|
public String PostalCode { get; set; }
|
|
public String PhoneMain { get; set; }
|
|
// Location.
|
|
public String LocationSource { get; set; }
|
|
public DateTime? LocationStoredAt { get; set; } = null;
|
|
public bool LocationUpdateRequired { get; set; }
|
|
public String LocationData { get; set; }
|
|
public String LocationFormattedAddress { get; set; }
|
|
public Decimal? LocationLatitude { get; set; } = null;
|
|
public Decimal? LocationLongitude { get; set; } = null;
|
|
public Decimal? LocationAltitude { get; set; } = null;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data.
|
|
public new class Data : SacsHierarchyItem.Data
|
|
{
|
|
// Data members.
|
|
private readonly DataProperties data = new DataProperties();
|
|
// Construction.
|
|
public Data()
|
|
{
|
|
Status = DefaultStatus;
|
|
}
|
|
// Properties.
|
|
public ItemId ItemId
|
|
{
|
|
get { return data.ItemId; }
|
|
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
|
}
|
|
public Sax.AddressType AddressType
|
|
{
|
|
get { return data.AddressType; }
|
|
set { CheckChanged((short)data.AddressType, (short)value); data.AddressType = value; }
|
|
}
|
|
public String Caption
|
|
{
|
|
get { return data.Caption; }
|
|
set { CheckChanged(data.Caption, value); data.Caption = value; }
|
|
}
|
|
public String Line1
|
|
{
|
|
get { return data.Line1; }
|
|
set { CheckChanged(data.Line1, value); data.Line1 = value; }
|
|
}
|
|
public String Line2
|
|
{
|
|
get { return data.Line2; }
|
|
set { CheckChanged(data.Line2, value); data.Line2 = value; }
|
|
}
|
|
public String Line3
|
|
{
|
|
get { return data.Line3; }
|
|
set { CheckChanged(data.Line3, value); data.Line3 = value; }
|
|
}
|
|
public String Town
|
|
{
|
|
get { return data.Town; }
|
|
set { CheckChanged(data.Town, value); data.Town = value; }
|
|
}
|
|
public String PostalCode
|
|
{
|
|
get { return data.PostalCode; }
|
|
set { CheckChanged(data.PostalCode, value); data.PostalCode = value; }
|
|
}
|
|
public String Province
|
|
{
|
|
get { return data.Province; }
|
|
set { CheckChanged(data.Province, value); data.Province = value; }
|
|
}
|
|
public SysId RegionIdProvince
|
|
{
|
|
get { return data.RegionIdProvince; }
|
|
set { CheckChanged(data.RegionIdProvince, value); data.RegionIdProvince = value; }
|
|
}
|
|
public String Country
|
|
{
|
|
get { return data.Country; }
|
|
set { CheckChanged(data.Country, value); data.Country = value; }
|
|
}
|
|
public SysId RegionIdCountry
|
|
{
|
|
get { return data.RegionIdCountry; }
|
|
set { CheckChanged(data.RegionIdCountry, value); data.RegionIdCountry = value; }
|
|
}
|
|
public String PhoneMain
|
|
{
|
|
get { return data.PhoneMain; }
|
|
set { CheckChanged(data.PhoneMain, value); data.PhoneMain = value; }
|
|
}
|
|
|
|
// Location.
|
|
public String LocationSource
|
|
{
|
|
get { return data.LocationSource; }
|
|
set { CheckChanged(data.LocationSource, value); data.LocationSource = value; }
|
|
}
|
|
public DateTime? LocationStoredAt
|
|
{
|
|
get { return data.LocationStoredAt; }
|
|
set { CheckChangedNullable(data.LocationStoredAt, value); data.LocationStoredAt = value; }
|
|
}
|
|
public bool LocationUpdateRequired
|
|
{
|
|
get { return data.LocationUpdateRequired; }
|
|
set { CheckChanged(data.LocationUpdateRequired, value); data.LocationUpdateRequired = value; }
|
|
}
|
|
public String LocationData
|
|
{
|
|
get { return data.LocationData; }
|
|
set { CheckChanged(data.LocationData, value); data.LocationData = value; }
|
|
}
|
|
public String LocationFormattedAddress
|
|
{
|
|
get { return data.LocationFormattedAddress; }
|
|
set { CheckChanged(data.LocationFormattedAddress, value); data.LocationFormattedAddress = value; }
|
|
}
|
|
public Decimal? LocationLatitude
|
|
{
|
|
get { return data.LocationLatitude; }
|
|
set { CheckChangedNullable(data.LocationLatitude, value); data.LocationLatitude = value; }
|
|
}
|
|
public Decimal? LocationLongitude
|
|
{
|
|
get { return data.LocationLongitude; }
|
|
set { CheckChangedNullable(data.LocationLongitude, value); data.LocationLongitude = value; }
|
|
}
|
|
public Decimal? LocationAltitude
|
|
{
|
|
get { return data.LocationAltitude; }
|
|
set { CheckChangedNullable(data.LocationAltitude, value); data.LocationAltitude = value; }
|
|
}
|
|
// Population.
|
|
internal void PopulateFrom(Data data)
|
|
{
|
|
ItemId = data.ItemId;
|
|
AddressType = data.AddressType;
|
|
Caption = data.Caption;
|
|
Line1 = data.Line1;
|
|
Line2 = data.Line2;
|
|
Line3 = data.Line3;
|
|
Town = data.Town;
|
|
RegionIdProvince = data.RegionIdProvince;
|
|
Province = data.Province;
|
|
RegionIdCountry = data.RegionIdCountry;
|
|
Country = data.Country;
|
|
PostalCode = data.PostalCode;
|
|
PhoneMain = data.PhoneMain;
|
|
// Location.
|
|
LocationSource = data.LocationSource;
|
|
LocationStoredAt = data.LocationStoredAt;
|
|
LocationUpdateRequired = data.LocationUpdateRequired;
|
|
LocationData = data.LocationData;
|
|
LocationFormattedAddress = data.LocationFormattedAddress;
|
|
LocationLatitude = data.LocationLatitude;
|
|
LocationLongitude = data.LocationLongitude;
|
|
LocationAltitude = data.LocationAltitude;
|
|
base.PopulateFrom(data);
|
|
}
|
|
public Data Clone()
|
|
{
|
|
Data data = new Data();
|
|
data.PopulateFrom(this);
|
|
return data;
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Error field - identify properties with validation error.
|
|
public new class ErrField : SacsHierarchyItem.ErrField
|
|
{
|
|
// Identifies the field that has invalid data.
|
|
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
|
public ValidValue AddressType { get; set; } = ValidValue.Valid;
|
|
public ValidValue Caption { get; set; } = ValidValue.Valid;
|
|
public ValidValue Line1 { get; set; } = ValidValue.Valid;
|
|
public ValidValue Line2 { get; set; } = ValidValue.Valid;
|
|
public ValidValue Line3 { get; set; } = ValidValue.Valid;
|
|
public ValidValue Town { get; set; } = ValidValue.Valid;
|
|
public ValidValue RegionIdProvince { get; set; } = ValidValue.Valid;
|
|
public ValidValue Province { get; set; } = ValidValue.Valid;
|
|
public ValidValue RegionIdCountry { get; set; } = ValidValue.Valid;
|
|
public ValidValue Country { get; set; } = ValidValue.Valid;
|
|
public ValidValue PostalCode { get; set; } = ValidValue.Valid;
|
|
public ValidValue PhoneMain { get; set; } = ValidValue.Valid;
|
|
// Location.
|
|
public ValidValue LocationSource { get; set; } = ValidValue.Valid;
|
|
public ValidValue LocationStoredAt { get; set; } = ValidValue.Valid;
|
|
public ValidValue LocationUpdateRequired { get; set; } = ValidValue.Valid;
|
|
public ValidValue LocationData { get; set; } = ValidValue.Valid;
|
|
public ValidValue LocationFormattedAddress { get; set; } = ValidValue.Valid;
|
|
public ValidValue LocationLatitude { get; set; } = ValidValue.Valid;
|
|
public ValidValue LocationLongitude { get; set; } = ValidValue.Valid;
|
|
public ValidValue LocationAltitude { get; set; } = ValidValue.Valid;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly Data data = new Data();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SaxItemAddress(SysId id, ItemId itemId, Sax.AddressType addressType) : base(id)
|
|
{
|
|
base.SetData(data);
|
|
ItemId = itemId;
|
|
AddressType = addressType;
|
|
Status = DefaultStatus;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Status.
|
|
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
|
{
|
|
SaStatus.Active,
|
|
SaStatus.Inactive,
|
|
SaStatus.Deleted,
|
|
};
|
|
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
|
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
|
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
|
{
|
|
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
|
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
|
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
|
return DataValue.TriStateType.Unknown;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
public ItemId GetItemId()
|
|
{
|
|
return new ItemId((short)Sax.DataItemType.ItemAddress, Id);
|
|
}
|
|
// Address types.
|
|
public static Sax.AddressType DefaultOrganisationAddressType { get { return Sax.AddressType.Office; } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// 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");
|
|
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
|
throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed");
|
|
if (SysId.IsValid(RegionIdProvince) && SysId.ToInt(RegionIdProvince) != SysId.ToInt(data.RegionIdProvince))
|
|
throw new NotSupportedException($"{SysUtil.Fn} Address Id cannot be changed");
|
|
this.data.PopulateFrom(data);
|
|
}
|
|
public ItemId ItemId
|
|
{
|
|
get { return data.ItemId; }
|
|
protected set { data.ItemId = value; }
|
|
}
|
|
public Sax.AddressType AddressType
|
|
{
|
|
get { return data.AddressType; }
|
|
set { data.AddressType = value; }
|
|
}
|
|
public String Caption
|
|
{
|
|
get { return data.Caption; }
|
|
set { data.Caption = value; }
|
|
}
|
|
public String Line1
|
|
{
|
|
get { return data.Line1; }
|
|
set { data.Line1 = value; }
|
|
}
|
|
public String Line2
|
|
{
|
|
get { return data.Line2; }
|
|
set { data.Line2 = value; }
|
|
}
|
|
public String Line3
|
|
{
|
|
get { return data.Line3; }
|
|
set { data.Line3 = value; }
|
|
}
|
|
public String Town
|
|
{
|
|
get { return data.Town; }
|
|
set { data.Town = value; }
|
|
}
|
|
public String Province
|
|
{
|
|
get { return data.Province; }
|
|
set { data.Province = value; }
|
|
}
|
|
public SysId RegionIdProvince
|
|
{
|
|
get { return data.RegionIdProvince; }
|
|
set { data.RegionIdProvince = value; }
|
|
}
|
|
public String Country
|
|
{
|
|
get { return data.Country; }
|
|
set { data.Country = value; }
|
|
}
|
|
public SysId RegionIdCountry
|
|
{
|
|
get { return data.RegionIdCountry; }
|
|
set { data.RegionIdCountry = value; }
|
|
}
|
|
public String PostalCode
|
|
{
|
|
get { return data.PostalCode; }
|
|
set { data.PostalCode = value; }
|
|
}
|
|
public String PhoneMain
|
|
{
|
|
get { return data.PhoneMain; }
|
|
set { data.PhoneMain = value; }
|
|
}
|
|
|
|
// Location.
|
|
public String LocationSource
|
|
{
|
|
get { return data.LocationSource; }
|
|
set { data.LocationSource = value; }
|
|
}
|
|
public DateTime? LocationStoredAt
|
|
{
|
|
get { return data.LocationStoredAt; }
|
|
set { data.LocationStoredAt = value; }
|
|
}
|
|
public bool LocationUpdateRequired
|
|
{
|
|
get { return data.LocationUpdateRequired; }
|
|
set { data.LocationUpdateRequired = value; }
|
|
}
|
|
public String LocationData
|
|
{
|
|
get { return data.LocationData; }
|
|
set { data.LocationData = value; }
|
|
}
|
|
public String LocationFormattedAddress
|
|
{
|
|
get { return data.LocationFormattedAddress; }
|
|
set { data.LocationFormattedAddress = value; }
|
|
}
|
|
public Decimal? LocationLatitude
|
|
{
|
|
get { return data.LocationLatitude; }
|
|
set { data.LocationLatitude = value; }
|
|
}
|
|
public Decimal? LocationLongitude
|
|
{
|
|
get { return data.LocationLongitude; }
|
|
set { data.LocationLongitude = value; }
|
|
}
|
|
public Decimal? LocationAltitude
|
|
{
|
|
get { return data.LocationAltitude; }
|
|
set { data.LocationAltitude = value; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Flags - positions 1-16 available.
|
|
|
|
//-------------------------------------------------------------------
|
|
// A s s o c i a t e d D a t a
|
|
//-------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------
|
|
// P a r a m s
|
|
//-------------------------------------------------------------------
|
|
// List parameters.
|
|
public enum StatusCat
|
|
{
|
|
Any,
|
|
ActiveOnly,
|
|
InactiveOnly,
|
|
NotDeleted,
|
|
DeletedOnly,
|
|
}
|
|
/// <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>();
|
|
public Sax.AddressType AddressType = Sax.AddressType.Unknown;
|
|
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
|
public String AddressSearch { get; set; }
|
|
// Common properties.
|
|
public String NotesPartial { get; set; }
|
|
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
// Item list extension methods.
|
|
public static class SaxItemAddressList
|
|
{
|
|
}
|
|
|
|
//=======================================================================
|
|
}
|