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>
345 lines
10 KiB
C#
345 lines
10 KiB
C#
using NPOI.SS.Formula.Functions;
|
|
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.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Saxonite.Net.Standard.Base.Bus.Reference
|
|
{
|
|
//=======================================================================
|
|
// Golf - USGA Facility.
|
|
//=======================================================================
|
|
public abstract class SaxGolfUsgaFacility : SaxDisposableHierarchyItem, IDisposable
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Columns.
|
|
public enum Column
|
|
{
|
|
Pos,
|
|
Id,
|
|
CountryId,
|
|
Country_Name,
|
|
ProvinceId,
|
|
Province_Name,
|
|
UsgaFacilityId,
|
|
FacilityName,
|
|
Address1,
|
|
Address2,
|
|
City,
|
|
PostalCode,
|
|
Email,
|
|
Telephone,
|
|
// Associated data.
|
|
// Common.
|
|
Notes,
|
|
Flags,
|
|
Status,
|
|
Status_Desc,
|
|
Status_Ind,
|
|
CreateOn_Date,
|
|
UpdateOn_Date,
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Properties other than common.</summary>
|
|
public class DataProperties
|
|
{
|
|
public SysId ProvinceId { get; set; }
|
|
public SysId UsgaFacilityId { get; set; }
|
|
public String FacilityName { get; set; } = String.Empty;
|
|
public String Address1 { get; set; } = String.Empty;
|
|
public String Address2 { get; set; } = String.Empty;
|
|
public String City { get; set; } = String.Empty;
|
|
public String PostalCode { get; set; } = String.Empty;
|
|
public Decimal? Latitude { get; set; } = null;
|
|
public Decimal? Longitude { get; set; } = null;
|
|
public String Email { get; set; } = String.Empty;
|
|
public String Telephone { get; set; } = String.Empty;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data.
|
|
public new class Data : SacsHierarchyItem.Data
|
|
{
|
|
// Data members.
|
|
private readonly DataProperties data = new DataProperties();
|
|
// Construction.
|
|
public Data()
|
|
{
|
|
Status = DefaultStatus;
|
|
}
|
|
// Properties.
|
|
public SysId ProvinceId
|
|
{
|
|
get { return data.ProvinceId; }
|
|
set { CheckChanged(data.ProvinceId, value); data.ProvinceId = value; }
|
|
}
|
|
public SysId UsgaFacilityId
|
|
{
|
|
get { return data.UsgaFacilityId; }
|
|
set { CheckChanged(data.UsgaFacilityId, value); data.UsgaFacilityId = value; }
|
|
}
|
|
public String FacilityName
|
|
{
|
|
get { return data.FacilityName; }
|
|
set { CheckChanged(data.FacilityName, value); data.FacilityName = value; }
|
|
}
|
|
public String Address1
|
|
{
|
|
get { return data.Address1; }
|
|
set { CheckChanged(data.Address1, value); data.Address1 = value; }
|
|
}
|
|
public String Address2
|
|
{
|
|
get { return data.Address2; }
|
|
set { CheckChanged(data.Address2, value); data.Address2 = value; }
|
|
}
|
|
public String City
|
|
{
|
|
get { return data.City; }
|
|
set { CheckChanged(data.City, value); data.City = value; }
|
|
}
|
|
public String PostalCode
|
|
{
|
|
get { return data.PostalCode; }
|
|
set { CheckChanged(data.PostalCode, value); data.PostalCode = value; }
|
|
}
|
|
public decimal? Latitude
|
|
{
|
|
get { return data.Latitude; }
|
|
set { CheckChangedNullable(data.Latitude, value); data.Latitude = value; }
|
|
}
|
|
public decimal? Longitude
|
|
{
|
|
get { return data.Longitude; }
|
|
set { CheckChangedNullable(data.Longitude, value); data.Longitude = value; }
|
|
}
|
|
public String Email
|
|
{
|
|
get { return data.Email; }
|
|
set { CheckChanged(data.Email, value); data.Email = value; }
|
|
}
|
|
public String Telephone
|
|
{
|
|
get { return data.Telephone; }
|
|
set { CheckChanged(data.Telephone, value); data.Telephone = value; }
|
|
}
|
|
// Population.
|
|
internal void PopulateFrom(Data data)
|
|
{
|
|
ProvinceId = data.ProvinceId;
|
|
UsgaFacilityId = data.UsgaFacilityId;
|
|
FacilityName = data.FacilityName;
|
|
Address1 = data.Address1;
|
|
Address2 = data.Address2;
|
|
City = data.City;
|
|
PostalCode = data.PostalCode;
|
|
Latitude = data.Latitude;
|
|
Longitude = data.Longitude;
|
|
Email = data.Email;
|
|
Telephone = data.Telephone;
|
|
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 ProvinceId { get; set; } = ValidValue.Valid;
|
|
public ValidValue UsgaFacilityId { get; set; } = ValidValue.Valid;
|
|
public ValidValue FacilityName { get; set; } = ValidValue.Valid;
|
|
public ValidValue Address1 { get; set; } = ValidValue.Valid;
|
|
public ValidValue Address2 { get; set; } = ValidValue.Valid;
|
|
public ValidValue City { get; set; } = ValidValue.Valid;
|
|
public ValidValue PostalCode { get; set; } = ValidValue.Valid;
|
|
public ValidValue Latitude { get; set; } = ValidValue.Valid;
|
|
public ValidValue Longitude { get; set; } = ValidValue.Valid;
|
|
public ValidValue Email { get; set; } = ValidValue.Valid;
|
|
public ValidValue Telephone { get; set; } = ValidValue.Valid;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly Data data = new Data();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SaxGolfUsgaFacility(SysId id, SysId provinceId) : base(id)
|
|
{
|
|
base.SetData(data);
|
|
this.ProvinceId = provinceId;
|
|
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.Golf_UsgaFacility, Id);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
public void Dispose() { }
|
|
|
|
//-------------------------------------------------------------------
|
|
// 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");
|
|
this.data.PopulateFrom(data);
|
|
}
|
|
public SysId ProvinceId
|
|
{
|
|
get { return data.ProvinceId; }
|
|
set { data.ProvinceId = value; }
|
|
}
|
|
public SysId UsgaFacilityId
|
|
{
|
|
get { return data.UsgaFacilityId; }
|
|
set { data.UsgaFacilityId = value; }
|
|
}
|
|
public String FacilityName
|
|
{
|
|
get { return data.FacilityName; }
|
|
set { data.FacilityName = value; }
|
|
}
|
|
public String Address1
|
|
{
|
|
get { return data.Address1; }
|
|
set { data.Address1 = value; }
|
|
}
|
|
public String Address2
|
|
{
|
|
get { return data.Address2; }
|
|
set { data.Address2 = value; }
|
|
}
|
|
public String City
|
|
{
|
|
get { return data.City; }
|
|
set { data.City = value; }
|
|
}
|
|
public String PostalCode
|
|
{
|
|
get { return data.PostalCode; }
|
|
set { data.PostalCode = value; }
|
|
}
|
|
public decimal? Latitude
|
|
{
|
|
get { return data.Latitude; }
|
|
set { data.Latitude = value; }
|
|
}
|
|
public decimal? Longitude
|
|
{
|
|
get { return data.Longitude; }
|
|
set { data.Longitude = value; }
|
|
}
|
|
public String Email
|
|
{
|
|
get { return data.Email; }
|
|
set { data.Email = value; }
|
|
}
|
|
public String Telephone
|
|
{
|
|
get { return data.Telephone; }
|
|
set { data.Telephone = 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
|
|
{
|
|
NotDeleted = 0,
|
|
ActiveOnly,
|
|
InactiveOnly,
|
|
Any,
|
|
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 List<SysId> ProvinceIdsIncluded { get; } = new List<SysId>();
|
|
/// <summary>USGA Facility Ids.</summary>
|
|
public List<SysId> UsgaFacilityIdsIncluded { get; } = new List<SysId>();
|
|
/// <summary>Generic filter - partial province code or name.</summary>
|
|
public String FacilityFilter { get; set; }
|
|
public String FacilityNameFull { get; set; }
|
|
public String FacilityNamePartial { get; set; }
|
|
// Associated data.
|
|
public BoolState HasCourses { get; set; } = BoolState.Either;
|
|
// Common properties.
|
|
public String NotesPartial { get; set; }
|
|
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
|
// Table aliases - blank if not linked.
|
|
public String Alias_Country { get; set; }
|
|
public String Alias_Province { get; set; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
// Item list extension methods.
|
|
public static class SaxGolfUsgaFacilityList
|
|
{
|
|
//-------------------------------------------------------------------
|
|
public static SaxGolfUsgaFacility GetFacilityById(this IEnumerable<SaxGolfUsgaFacility> values, SysId facilityId)
|
|
{
|
|
if (!SysId.IsValid(facilityId)) return null;
|
|
foreach (SaxGolfUsgaFacility province in values)
|
|
if (province.Id.Equals(facilityId)) return province;
|
|
return null;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
|
|
//=======================================================================
|
|
}
|