v1.3.0 Restructure Saxonite workspace and upgrade to .NET 10 (#1)
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>
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
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;
|
||||
using static Sarand.Net.Standard.Base.Bus.SacsHierarchyItem;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
// Golf - USGA Country.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaCountry : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryCode,
|
||||
EntCountryCode,
|
||||
CountryName,
|
||||
ProvincesUpdateAt_Date,
|
||||
// Associated data.
|
||||
ProvinceCount_All,
|
||||
ProvinceCount_Active,
|
||||
FacilityCount_All,
|
||||
FacilityCount_Active,
|
||||
/// <summary>Facility population %.</summary>
|
||||
FacilityPercent,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public String CountryCode { get; set; } = String.Empty;
|
||||
public String EntCountryCode { get; set; } = String.Empty;
|
||||
public String CountryName { get; set; } = String.Empty;
|
||||
public DateTime? ProvincesUpdateAt { 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 String CountryCode
|
||||
{
|
||||
get { return data.CountryCode; }
|
||||
set { CheckChanged(data.CountryCode, value); data.CountryCode = value; }
|
||||
}
|
||||
public String EntCountryCode
|
||||
{
|
||||
get { return data.EntCountryCode; }
|
||||
set { CheckChanged(data.EntCountryCode, value); data.EntCountryCode = value; }
|
||||
}
|
||||
public String CountryName
|
||||
{
|
||||
get { return data.CountryName; }
|
||||
set { CheckChanged(data.CountryName, value); data.CountryName = value; }
|
||||
}
|
||||
public DateTime? ProvincesUpdateAt
|
||||
{
|
||||
get { return data.ProvincesUpdateAt; }
|
||||
set { CheckChangedNullable(data.ProvincesUpdateAt, value); data.ProvincesUpdateAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
CountryCode = data.CountryCode;
|
||||
EntCountryCode = data.EntCountryCode;
|
||||
CountryName = data.CountryName;
|
||||
ProvincesUpdateAt = data.ProvincesUpdateAt;
|
||||
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 CountryCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EntCountryCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CountryName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProvincesUpdateAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaCountry(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
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_UsgaCountry, 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 String CountryCode
|
||||
{
|
||||
get { return data.CountryCode; }
|
||||
set { data.CountryCode = value; }
|
||||
}
|
||||
public String EntCountryCode
|
||||
{
|
||||
get { return data.EntCountryCode; }
|
||||
set { data.EntCountryCode = value; }
|
||||
}
|
||||
public String CountryName
|
||||
{
|
||||
get { return data.CountryName; }
|
||||
set { data.CountryName = value; }
|
||||
}
|
||||
public DateTime? ProvincesUpdateAt
|
||||
{
|
||||
get { return data.ProvincesUpdateAt; }
|
||||
set { data.ProvincesUpdateAt = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
public const byte Flag_Priority = 0x01;
|
||||
public bool Priority
|
||||
{
|
||||
get { return GetFlag(Flag_Priority); }
|
||||
set { SetFlag(Flag_Priority, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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>();
|
||||
/// <summary>Generic filter - partial country code or name.</summary>
|
||||
public String CountryFilter { get; set; }
|
||||
/// <summary>Restrict the results by code.</summary>
|
||||
public HashSet<String> CountryCodesIncluded { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
|
||||
public String CountryNameFull { get; set; }
|
||||
public String CountryNamePartial { get; set; }
|
||||
// Flags.
|
||||
public FlagState PriorityFlagState { get; set; } = FlagState.Either;
|
||||
// Associated data.
|
||||
public BoolState HasProvinces { get; set; } = BoolState.Either;
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaCountryList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaCountry GetCountryById(this IEnumerable<SaxGolfUsgaCountry> values, SysId countryId)
|
||||
{
|
||||
if (!SysId.IsValid(countryId)) return null;
|
||||
foreach (SaxGolfUsgaCountry country in values)
|
||||
if (country.Id.Equals(countryId)) return country;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
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 Course.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaCourse : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryId,
|
||||
Country_Name,
|
||||
ProvinceId,
|
||||
Province_Name,
|
||||
FacilityId,
|
||||
Facility_Name,
|
||||
UsgaCourseId,
|
||||
LegacyCrpCourseId,
|
||||
Caption,
|
||||
CourseName,
|
||||
FullName,
|
||||
Address1,
|
||||
Address2,
|
||||
City,
|
||||
PostalCode,
|
||||
Email,
|
||||
Telephone,
|
||||
MarkersUpdateOn_Date,
|
||||
// Associated data.
|
||||
MarkerCount_All,
|
||||
MarkerCount_Active,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId FacilityId { get; set; }
|
||||
public SysId UsgaCourseId { get; set; }
|
||||
public SysId LegacyCrpCourseId { get; set; }
|
||||
public String Caption { get; set; } = String.Empty;
|
||||
public String CourseName { get; set; } = String.Empty;
|
||||
public String FullName { 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;
|
||||
public DateTime? MarkersUpdateAt { get; set; } = null;
|
||||
public String MarkersData { 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 FacilityId
|
||||
{
|
||||
get { return data.FacilityId; }
|
||||
set { CheckChanged(data.FacilityId, value); data.FacilityId = value; }
|
||||
}
|
||||
public SysId UsgaCourseId
|
||||
{
|
||||
get { return data.UsgaCourseId; }
|
||||
set { CheckChanged(data.UsgaCourseId, value); data.UsgaCourseId = value; }
|
||||
}
|
||||
public SysId LegacyCrpCourseId
|
||||
{
|
||||
get { return data.LegacyCrpCourseId; }
|
||||
set { CheckChanged(data.LegacyCrpCourseId, value); data.LegacyCrpCourseId = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { CheckChanged(data.Caption, value); data.Caption = value; }
|
||||
}
|
||||
public String CourseName
|
||||
{
|
||||
get { return data.CourseName; }
|
||||
set { CheckChanged(data.CourseName, value); data.CourseName = value; }
|
||||
}
|
||||
public String FullName
|
||||
{
|
||||
get { return data.FullName; }
|
||||
set { CheckChanged(data.FullName, value); data.FullName = 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; }
|
||||
}
|
||||
public DateTime? MarkersUpdateAt
|
||||
{
|
||||
get { return data.MarkersUpdateAt; }
|
||||
set { CheckChangedNullable(data.MarkersUpdateAt, value); data.MarkersUpdateAt = value; }
|
||||
}
|
||||
public String MarkersData
|
||||
{
|
||||
get { return data.MarkersData; }
|
||||
set { CheckChanged(data.MarkersData, value); data.MarkersData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
FacilityId = data.FacilityId;
|
||||
UsgaCourseId = data.UsgaCourseId;
|
||||
LegacyCrpCourseId = data.LegacyCrpCourseId;
|
||||
Caption = data.Caption;
|
||||
CourseName = data.CourseName;
|
||||
FullName = data.FullName;
|
||||
Address1 = data.Address1;
|
||||
Address2 = data.Address2;
|
||||
City = data.City;
|
||||
PostalCode = data.PostalCode;
|
||||
Latitude = data.Latitude;
|
||||
Longitude = data.Longitude;
|
||||
Email = data.Email;
|
||||
Telephone = data.Telephone;
|
||||
MarkersUpdateAt = data.MarkersUpdateAt;
|
||||
MarkersData = data.MarkersData;
|
||||
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 FacilityId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CourseId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LegacyCrpCourseId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Caption { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CourseName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FullName { 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;
|
||||
public ValidValue MarkersUpdateAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue MarkersData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaCourse(SysId id, SysId facilityId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.FacilityId = facilityId;
|
||||
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_UsgaCourse, 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 FacilityId
|
||||
{
|
||||
get { return data.FacilityId; }
|
||||
set { data.FacilityId = value; }
|
||||
}
|
||||
public SysId UsgaCourseId
|
||||
{
|
||||
get { return data.UsgaCourseId; }
|
||||
set { data.UsgaCourseId = value; }
|
||||
}
|
||||
public SysId LegacyCrpCourseId
|
||||
{
|
||||
get { return data.LegacyCrpCourseId; }
|
||||
set { data.LegacyCrpCourseId = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { data.Caption = value; }
|
||||
}
|
||||
public String CourseName
|
||||
{
|
||||
get { return data.CourseName; }
|
||||
set { data.CourseName = value; }
|
||||
}
|
||||
public String FullName
|
||||
{
|
||||
get { return data.FullName; }
|
||||
set { data.FullName = 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; }
|
||||
}
|
||||
public DateTime? MarkersUpdateAt
|
||||
{
|
||||
get { return data.MarkersUpdateAt; }
|
||||
set { data.MarkersUpdateAt = value; }
|
||||
}
|
||||
public String MarkersData
|
||||
{
|
||||
get { return data.MarkersData; }
|
||||
set { data.MarkersData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
public const byte Flag_Priority = 0x01;
|
||||
public bool Priority
|
||||
{
|
||||
get { return GetFlag(Flag_Priority); }
|
||||
set { SetFlag(Flag_Priority, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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>();
|
||||
public List<SysId> FacilityIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>USGA Course Ids.</summary>
|
||||
public List<SysId> UsgaCourseIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Generic filter - partial name, address etc.</summary>
|
||||
public String CourseFilter { get; set; }
|
||||
public String CourseNameFull { get; set; }
|
||||
public String CourseNamePartial { get; set; }
|
||||
public BoolState HasMarkersData { get; set; } = BoolState.Either;
|
||||
// Flags.
|
||||
public FlagState PriorityFlagState { get; set; } = FlagState.Either;
|
||||
// Associated data.
|
||||
public BoolState HasMarkers { 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; }
|
||||
public String Alias_Facility { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaCourseList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaCourse GetCourseById(this IEnumerable<SaxGolfUsgaCourse> values, SysId courseId)
|
||||
{
|
||||
if (!SysId.IsValid(courseId)) return null;
|
||||
foreach (SaxGolfUsgaCourse province in values)
|
||||
if (province.Id.Equals(courseId)) return province;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
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 Marker.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaMarker : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryId,
|
||||
Country_Name,
|
||||
ProvinceId,
|
||||
Province_Name,
|
||||
FacilityId,
|
||||
Facility_Name,
|
||||
CourseId,
|
||||
UsgaCourseId,
|
||||
Course_Name,
|
||||
UsgaMarkerId,
|
||||
Caption,
|
||||
Holes,
|
||||
HolesCaption,
|
||||
Tee,
|
||||
Gender,
|
||||
SlopeRating,
|
||||
Par,
|
||||
CourseRating,
|
||||
BogeyRating,
|
||||
Length,
|
||||
// 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 CourseId { get; set; }
|
||||
public SysId UsgaMarkerId { get; set; }
|
||||
public String Caption { get; set; } = "";
|
||||
public short Holes { get; set; }
|
||||
public String HolesCaption { get; set; } = "";
|
||||
public String Tee { get; set; } = "";
|
||||
public String Gender { get; set; } = "";
|
||||
public short SlopeRating { get; set; }
|
||||
public short Par { get; set; }
|
||||
public decimal CourseRating { get; set; }
|
||||
public decimal BogeyRating { get; set; }
|
||||
public short Length { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId CourseId
|
||||
{
|
||||
get { return data.CourseId; }
|
||||
set { CheckChanged(data.CourseId, value); data.CourseId = value; }
|
||||
}
|
||||
public SysId UsgaMarkerId
|
||||
{
|
||||
get { return data.UsgaMarkerId; }
|
||||
set { CheckChanged(data.UsgaMarkerId, value); data.UsgaMarkerId = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { CheckChanged(data.Caption, value); data.Caption = value; }
|
||||
}
|
||||
public short Holes
|
||||
{
|
||||
get { return data.Holes; }
|
||||
set { CheckChanged(data.Holes, value); data.Holes = value; }
|
||||
}
|
||||
public String HolesCaption
|
||||
{
|
||||
get { return data.HolesCaption; }
|
||||
set { CheckChanged(data.HolesCaption, value); data.HolesCaption = value; }
|
||||
}
|
||||
public String Tee
|
||||
{
|
||||
get { return data.Tee; }
|
||||
set { CheckChanged(data.Tee, value); data.Tee = value; }
|
||||
}
|
||||
public String Gender
|
||||
{
|
||||
get { return data.Gender; }
|
||||
set { CheckChanged(data.Gender, value); data.Gender = value; }
|
||||
}
|
||||
public short SlopeRating
|
||||
{
|
||||
get { return data.SlopeRating; }
|
||||
set { CheckChanged(data.SlopeRating, value); data.SlopeRating = value; }
|
||||
}
|
||||
public short Par
|
||||
{
|
||||
get { return data.Par; }
|
||||
set { CheckChanged(data.Par, value); data.Par = value; }
|
||||
}
|
||||
public decimal CourseRating
|
||||
{
|
||||
get { return data.CourseRating; }
|
||||
set { CheckChanged(data.CourseRating, value); data.CourseRating = value; }
|
||||
}
|
||||
public decimal BogeyRating
|
||||
{
|
||||
get { return data.BogeyRating; }
|
||||
set { CheckChanged(data.BogeyRating, value); data.BogeyRating = value; }
|
||||
}
|
||||
public short Length
|
||||
{
|
||||
get { return data.Length; }
|
||||
set { CheckChanged(data.Length, value); data.Length = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
CourseId = data.CourseId;
|
||||
UsgaMarkerId = data.UsgaMarkerId;
|
||||
Caption = data.Caption;
|
||||
Holes = data.Holes;
|
||||
HolesCaption = data.HolesCaption;
|
||||
Tee = data.Tee;
|
||||
Gender = data.Gender;
|
||||
SlopeRating = data.SlopeRating;
|
||||
Par = data.Par;
|
||||
CourseRating = data.CourseRating;
|
||||
BogeyRating = data.BogeyRating;
|
||||
Length = data.Length;
|
||||
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 CourseId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UsgaMarkerId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Caption { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Holes { get; set; } = ValidValue.Valid;
|
||||
public ValidValue HolesCaption { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Tee { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Gender { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SlopeRating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Par { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CourseRating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue BogeyRating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Length { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaMarker(SysId id, SysId facilityId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.CourseId = facilityId;
|
||||
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_UsgaMarker, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 CourseId
|
||||
{
|
||||
get { return data.CourseId; }
|
||||
set { data.CourseId = value; }
|
||||
}
|
||||
public SysId UsgaMarkerId
|
||||
{
|
||||
get { return data.UsgaMarkerId; }
|
||||
set { data.UsgaMarkerId = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { data.Caption = value; }
|
||||
}
|
||||
public short Holes
|
||||
{
|
||||
get { return data.Holes; }
|
||||
set { data.Holes = value; }
|
||||
}
|
||||
public String HolesCaption
|
||||
{
|
||||
get { return data.HolesCaption; }
|
||||
set { data.HolesCaption = value; }
|
||||
}
|
||||
public String Tee
|
||||
{
|
||||
get { return data.Tee; }
|
||||
set { data.Tee = value; }
|
||||
}
|
||||
public String Gender
|
||||
{
|
||||
get { return data.Gender; }
|
||||
set { data.Gender = value; }
|
||||
}
|
||||
public short SlopeRating
|
||||
{
|
||||
get { return data.SlopeRating; }
|
||||
set { data.SlopeRating = value; }
|
||||
}
|
||||
public short Par
|
||||
{
|
||||
get { return data.Par; }
|
||||
set { data.Par = value; }
|
||||
}
|
||||
public decimal CourseRating
|
||||
{
|
||||
get { return data.CourseRating; }
|
||||
set { data.CourseRating = value; }
|
||||
}
|
||||
public decimal BogeyRating
|
||||
{
|
||||
get { return data.BogeyRating; }
|
||||
set { data.BogeyRating = value; }
|
||||
}
|
||||
public short Length
|
||||
{
|
||||
get { return data.Length; }
|
||||
set { data.Length = 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> CourseIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>USGA Marker Ids.</summary>
|
||||
public List<SysId> UsgaMarkerIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Generic filter - partial caption, holes, tee, gender etc.</summary>
|
||||
public String MarkerFilter { get; set; }
|
||||
// Marker proprerties.
|
||||
public short Holes { get; set; }
|
||||
public String Gender { get; set; }
|
||||
// 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; }
|
||||
public String Alias_Facility { get; set; }
|
||||
public String Alias_Course{ get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaMarkerList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaMarker GetMarkerById(this IEnumerable<SaxGolfUsgaMarker> values, SysId markerId)
|
||||
{
|
||||
if (!SysId.IsValid(markerId)) return null;
|
||||
foreach (SaxGolfUsgaMarker province in values)
|
||||
if (province.Id.Equals(markerId)) return province;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
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 Province.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaProvince : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryId,
|
||||
Country_Name,
|
||||
ProvinceCode,
|
||||
EntProvinceCode,
|
||||
ProvinceName,
|
||||
CoursesUpdateAt_Date,
|
||||
// Associated data.
|
||||
FacilityCount_All,
|
||||
FacilityCount_Active,
|
||||
CourseCount_All,
|
||||
CourseCount_Active,
|
||||
/// <summary>Marker population %.</summary>
|
||||
MarkerPercent,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId CountryId { get; set; }
|
||||
public String ProvinceCode { get; set; } = String.Empty;
|
||||
public String EntProvinceCode { get; set; } = String.Empty;
|
||||
public String ProvinceName { get; set; } = String.Empty;
|
||||
public DateTime? CoursesUpdateAt { 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 SysId CountryId
|
||||
{
|
||||
get { return data.CountryId; }
|
||||
set { CheckChanged(data.CountryId, value); data.CountryId = value; }
|
||||
}
|
||||
public String ProvinceCode
|
||||
{
|
||||
get { return data.ProvinceCode; }
|
||||
set { CheckChanged(data.ProvinceCode, value); data.ProvinceCode = value; }
|
||||
}
|
||||
public String EntProvinceCode
|
||||
{
|
||||
get { return data.EntProvinceCode; }
|
||||
set { CheckChanged(data.EntProvinceCode, value); data.EntProvinceCode = value; }
|
||||
}
|
||||
public String ProvinceName
|
||||
{
|
||||
get { return data.ProvinceName; }
|
||||
set { CheckChanged(data.ProvinceName, value); data.ProvinceName = value; }
|
||||
}
|
||||
public DateTime? CoursesUpdateAt
|
||||
{
|
||||
get { return data.CoursesUpdateAt; }
|
||||
set { CheckChangedNullable(data.CoursesUpdateAt, value); data.CoursesUpdateAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
CountryId = data.CountryId;
|
||||
ProvinceCode = data.ProvinceCode;
|
||||
EntProvinceCode = data.EntProvinceCode;
|
||||
ProvinceName = data.ProvinceName;
|
||||
CoursesUpdateAt = data.CoursesUpdateAt;
|
||||
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 CountryId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProvinceCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EntProvinceCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProvinceName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CoursesUpdateAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaProvince(SysId id, SysId countryId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.CountryId = countryId;
|
||||
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_UsgaProvince, 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 CountryId
|
||||
{
|
||||
get { return data.CountryId; }
|
||||
set { data.CountryId = value; }
|
||||
}
|
||||
public String ProvinceCode
|
||||
{
|
||||
get { return data.ProvinceCode; }
|
||||
set { data.ProvinceCode = value; }
|
||||
}
|
||||
public String EntProvinceCode
|
||||
{
|
||||
get { return data.EntProvinceCode; }
|
||||
set { data.EntProvinceCode = value; }
|
||||
}
|
||||
public String ProvinceName
|
||||
{
|
||||
get { return data.ProvinceName; }
|
||||
set { data.ProvinceName = value; }
|
||||
}
|
||||
public DateTime? CoursesUpdateAt
|
||||
{
|
||||
get { return data.CoursesUpdateAt; }
|
||||
set { data.CoursesUpdateAt = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
public const byte Flag_Priority = 0x01;
|
||||
public bool Priority
|
||||
{
|
||||
get { return GetFlag(Flag_Priority); }
|
||||
set { SetFlag(Flag_Priority, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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> CountryIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Generic filter - partial province code or name.</summary>
|
||||
public String ProvinceFilter { get; set; }
|
||||
public String ProvinceCodeFull { get; set; }
|
||||
public String ProvinceNameFull { get; set; }
|
||||
public String ProvinceNamePartial { get; set; }
|
||||
// Flags.
|
||||
public FlagState PriorityFlagState { get; set; } = FlagState.Either;
|
||||
// Associated data.
|
||||
public BoolState HasFacilities { 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; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaProvinceList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaProvince GetProvinceById(this IEnumerable<SaxGolfUsgaProvince> values, SysId provinceId)
|
||||
{
|
||||
if (!SysId.IsValid(provinceId)) return null;
|
||||
foreach (SaxGolfUsgaProvince province in values)
|
||||
if (province.Id.Equals(provinceId)) return province;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// ActivityIndex.
|
||||
//=======================================================================
|
||||
public abstract class SaxActivityFeedback : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
// Feedback.
|
||||
ViewCount,
|
||||
FeedbackCount,
|
||||
FeedbackTotal,
|
||||
FeedbackAverage,
|
||||
// Common.
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public long ViewCount { get; set; }
|
||||
public long FeedbackCount { get; set; }
|
||||
public long FeedbackTotal { get; set; }
|
||||
public decimal FeedbackAverage { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data() { }
|
||||
// Properties.
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public long ViewCount
|
||||
{
|
||||
get { return data.ViewCount; }
|
||||
set { CheckChanged(data.ViewCount, value); data.ViewCount = value; }
|
||||
}
|
||||
public long FeedbackCount
|
||||
{
|
||||
get { return data.FeedbackCount; }
|
||||
set { CheckChanged(data.FeedbackCount, value); data.FeedbackCount = value; }
|
||||
}
|
||||
public long FeedbackTotal
|
||||
{
|
||||
get { return data.FeedbackTotal; }
|
||||
set { CheckChanged(data.FeedbackTotal, value); data.FeedbackTotal = value; }
|
||||
}
|
||||
public decimal FeedbackAverage
|
||||
{
|
||||
get { return data.FeedbackAverage; }
|
||||
set { CheckChanged(data.FeedbackAverage, value); data.FeedbackAverage = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
ViewCount = data.ViewCount;
|
||||
FeedbackCount = data.FeedbackCount;
|
||||
FeedbackTotal = data.FeedbackTotal;
|
||||
FeedbackAverage = data.FeedbackAverage;
|
||||
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 ViewCount { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FeedbackCount { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FeedbackTotal { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FeedbackAverage { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxActivityFeedback(ItemId itemId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item Types.
|
||||
private readonly static List<Sax.DataItemType> validItemTypes = new List<Sax.DataItemType>()
|
||||
{ Sax.DataItemType.Article, Sax.DataItemType.OrganisationEvent, Sax.DataItemType.OrganisationOpportunity };
|
||||
public static List<Sax.DataItemType> ValidItemTypes { get { return new List<Sax.DataItemType>(validItemTypes); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
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");
|
||||
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");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public long ViewCount
|
||||
{
|
||||
get { return data.ViewCount; }
|
||||
set { data.ViewCount = value; }
|
||||
}
|
||||
public long FeedbackCount
|
||||
{
|
||||
get { return data.FeedbackCount; }
|
||||
set { data.FeedbackCount = value; }
|
||||
}
|
||||
public long FeedbackTotal
|
||||
{
|
||||
get { return data.FeedbackTotal; }
|
||||
set { data.FeedbackTotal = value; }
|
||||
}
|
||||
public decimal FeedbackAverage
|
||||
{
|
||||
get { return data.FeedbackAverage; }
|
||||
set { data.FeedbackAverage = 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
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Combination Sport and Region Ids to index activities.
|
||||
/// </summary>
|
||||
public class SportFeedbackAverages
|
||||
{
|
||||
public SportFeedbackAverages(SysId sportId, SysId regionId)
|
||||
{
|
||||
FeedbackTotal = sportId;
|
||||
FeedbackAverage = regionId;
|
||||
}
|
||||
public SysId FeedbackTotal { get; }
|
||||
public SysId FeedbackAverage { get; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxActivityFeedbackList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// ActivityIndex.
|
||||
//=======================================================================
|
||||
public abstract class SaxActivityIndex : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
// Author.
|
||||
// Organisation.
|
||||
OrganisationIdOwner,
|
||||
OrganisationOwner_Name,
|
||||
OrganisationOwner_LogoCount,
|
||||
// User Activity.
|
||||
UserActivity_UserAccountId,
|
||||
UserActivity_ListedAtLast,
|
||||
UserActivity_ViewedAtLast,
|
||||
UserActivity_Reaction,
|
||||
UserActivity_ReactedAtLast,
|
||||
// Article.
|
||||
Article_Headline,
|
||||
Article_Summary,
|
||||
// Organisation opportunity.
|
||||
Opportunity_Position,
|
||||
Opportunity_Outline,
|
||||
// Sport.
|
||||
SportId,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionId,
|
||||
Region_Name,
|
||||
// Properties.
|
||||
EffectiveOn,
|
||||
ExpiresOn,
|
||||
// Associated data.
|
||||
// Derived properties.
|
||||
// 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 SysId UserAccountIdOwner { get; set; }
|
||||
public SysId OrganisationIdOwner { get; set; }
|
||||
public SysId SportId { get; set; }
|
||||
public SysId RegionId { get; set; }
|
||||
public DateTime EffectiveOn { get; set; }
|
||||
public DateTime? ExpiresOn { 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 SysId UserAccountIdOwner
|
||||
{
|
||||
get { return data.UserAccountIdOwner; }
|
||||
set { CheckChanged(data.UserAccountIdOwner, value); data.UserAccountIdOwner = value; }
|
||||
}
|
||||
public SysId OrganisationIdOwner
|
||||
{
|
||||
get { return data.OrganisationIdOwner; }
|
||||
set { CheckChanged(data.OrganisationIdOwner, value); data.OrganisationIdOwner = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
set { CheckChanged(data.SportId, value); data.SportId = value; }
|
||||
}
|
||||
public SysId RegionId
|
||||
{
|
||||
get { return data.RegionId; }
|
||||
set { CheckChanged(data.RegionId, value); data.RegionId = value; }
|
||||
}
|
||||
public DateTime EffectiveOn
|
||||
{
|
||||
get { return data.EffectiveOn; }
|
||||
set
|
||||
{
|
||||
// Values are restricted to whole date, ie. no time.
|
||||
CheckChanged(data.EffectiveOn, value.Date);
|
||||
data.EffectiveOn = value.Date;
|
||||
}
|
||||
}
|
||||
public DateTime? ExpiresOn
|
||||
{
|
||||
get { return data.ExpiresOn; }
|
||||
set
|
||||
{
|
||||
// Values are restricted to whole date, ie. no time.
|
||||
CheckChangedNullable(data.ExpiresOn, value?.Date);
|
||||
data.ExpiresOn = value?.Date;
|
||||
}
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
UserAccountIdOwner = data.UserAccountIdOwner;
|
||||
OrganisationIdOwner = data.OrganisationIdOwner;
|
||||
SportId = data.SportId;
|
||||
RegionId = data.RegionId;
|
||||
EffectiveOn = data.EffectiveOn;
|
||||
ExpiresOn = data.ExpiresOn;
|
||||
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 UserAccountIdOwner { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationIdOwner { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EffectiveOn { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpiresOn { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxActivityIndex(ItemId itemId, SysId sportId, SysId regionId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
SportId = sportId;
|
||||
RegionId = regionId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item Types.
|
||||
private readonly static List<Sax.DataItemType> validItemTypes = new List<Sax.DataItemType>()
|
||||
{ Sax.DataItemType.Article, Sax.DataItemType.OrganisationEvent, Sax.DataItemType.OrganisationOpportunity };
|
||||
public static List<Sax.DataItemType> ValidItemTypes { get { return new List<Sax.DataItemType>(validItemTypes); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
};
|
||||
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.
|
||||
/// <summary>
|
||||
/// Match the item to the sport and region.
|
||||
/// </summary>
|
||||
public bool MatchesSportRegion(SysId sportId, SysId regionId)
|
||||
{
|
||||
if (!SportId.Equals(sportId)) return false;
|
||||
if (!RegionId.Equals(regionId)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override bool ItemHasId() { return false; }
|
||||
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(SportId) && SysId.ToInt(SportId) != SysId.ToInt(data.SportId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Sport Id cannot be changed");
|
||||
if (SysId.IsValid(RegionId) && SysId.ToInt(RegionId) != SysId.ToInt(data.RegionId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Region Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public SysId UserAccountIdOwner
|
||||
{
|
||||
get { return data.UserAccountIdOwner; }
|
||||
set { data.UserAccountIdOwner = value; }
|
||||
}
|
||||
public SysId OrganisationIdOwner
|
||||
{
|
||||
get { return data.OrganisationIdOwner; }
|
||||
set { data.OrganisationIdOwner = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
protected set { data.SportId = value; }
|
||||
}
|
||||
public SysId RegionId
|
||||
{
|
||||
get { return data.RegionId; }
|
||||
protected set { data.RegionId = value; }
|
||||
}
|
||||
public DateTime EffectiveOn
|
||||
{
|
||||
get { return data.EffectiveOn; }
|
||||
set { data.EffectiveOn = value; }
|
||||
}
|
||||
public DateTime? ExpiresOn
|
||||
{
|
||||
get { return data.ExpiresOn; }
|
||||
set { data.ExpiresOn = 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
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Combination Sport and Region Ids to index activities.
|
||||
/// </summary>
|
||||
public class SportRegionIds
|
||||
{
|
||||
public SportRegionIds(SysId sportId, SysId regionId)
|
||||
{
|
||||
SportId = sportId;
|
||||
RegionId = regionId;
|
||||
}
|
||||
public SysId SportId { get; }
|
||||
public SysId RegionId { get; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
/// <summary>Activities must match one of the sport/region combinations specified.</summary>
|
||||
public List<SportRegionIds> SportRegionIdsIncluded { get; } = new List<SportRegionIds>();
|
||||
/// <summary>Owner User Accounts - to include activities in result for users regardless of sports/regions.</summary>
|
||||
public List<SysId> UserAccountIdsOwnerIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Owner Organisations - to include activities in result for organisations regardless of sport/region combinations.</summary>
|
||||
public List<SysId> OrganisationIdsOwnerIncluded { get; } = new List<SysId>();
|
||||
/// <summary>User Account - to include User Activity data in result.</summary>
|
||||
public SysId UserAccountId { get; set; }
|
||||
public DateTime EffectiveFrom { get; set; }
|
||||
public DateTime EffectiveTo { get; set; }
|
||||
/// <summary>Not Expired - either Expiry date not set or is after specified date.</summary>
|
||||
public DateTime NotExpiredOn { get; set; }
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_ActivityIndex { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxActivityIndexList
|
||||
{
|
||||
/// <summary>
|
||||
/// Get first entry that matches the sport and region.
|
||||
/// </summary>
|
||||
public static SaxActivityIndex GetActivityIndexBySportRegion(this List<SaxActivityIndex> values, SysId sportId, SysId regionId)
|
||||
{
|
||||
return values.Find(item => item.MatchesSportRegion(sportId, regionId));
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Article - Content data.
|
||||
//=======================================================================
|
||||
partial class SaxArticle
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
private static readonly String ElementName_Content = "content";
|
||||
private static readonly String ElementName_Segments = "segments";
|
||||
private static readonly String ElementName_Segment = "segment";
|
||||
private static readonly String ElementName_Body = "body";
|
||||
private static readonly String ElementName_Html = "html";
|
||||
private static readonly String ElementName_Image = "image";
|
||||
private static readonly String ElementName_ImageId = "imageId";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Article content.</summary>
|
||||
public class ContentData
|
||||
{
|
||||
/// <summary>
|
||||
/// Article Content Segment - either body content or image.
|
||||
/// </summary>
|
||||
public class SegmentData
|
||||
{
|
||||
// Segment body.
|
||||
public class BodyData
|
||||
{
|
||||
public bool IsValid()
|
||||
{
|
||||
if (!StringUtil.IsEmpty(Html)) return true;
|
||||
return false;
|
||||
}
|
||||
public String Html { get; set; } = String.Empty;
|
||||
}
|
||||
public BodyData Body { get; } = new BodyData();
|
||||
// Segment image.
|
||||
public class ImageData
|
||||
{
|
||||
public bool IsValid()
|
||||
{
|
||||
if (SysId.IsValid(ItemImageId)) return true;
|
||||
return false;
|
||||
}
|
||||
public SysId ItemImageId { get; set; }
|
||||
}
|
||||
public ImageData Image { get; } = new ImageData();
|
||||
// Validate.
|
||||
public bool IsValid()
|
||||
{
|
||||
if (Body.IsValid()) return true;
|
||||
if (Image.IsValid()) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public List<SegmentData> Segments { get; } = new List<SegmentData>();
|
||||
// Add segment.
|
||||
public SegmentData AddSegment()
|
||||
{
|
||||
SegmentData segment = new SegmentData();
|
||||
Segments.Add(segment);
|
||||
return segment;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Convert serialised data from database to Content.
|
||||
/// </summary>
|
||||
public static ContentData ExtractContent(String contentData)
|
||||
{
|
||||
ContentData content = new ContentData();
|
||||
if (StringUtil.IsEmpty(contentData)) return content;
|
||||
|
||||
try
|
||||
{
|
||||
// Load XML data.
|
||||
XDocument doc = XDocument.Parse(contentData);
|
||||
XElement rootElement = doc.Root;
|
||||
foreach (XElement rootChildElement in rootElement.GetChildElements())
|
||||
{
|
||||
String rootChildElementName = rootChildElement.GetLocalName();
|
||||
if (rootChildElementName.EqualsCI(ElementName_Segments))
|
||||
{
|
||||
// Content segments.
|
||||
XElement segmentsElement = rootChildElement;
|
||||
foreach (XElement segmentsChildElement in segmentsElement.GetChildElements())
|
||||
{
|
||||
String segmentsChildElementName = segmentsChildElement.GetLocalName();
|
||||
if (segmentsChildElementName.EqualsCI(ElementName_Segment))
|
||||
{
|
||||
// Content segment.
|
||||
ContentData.SegmentData segment = new ContentData.SegmentData();
|
||||
XElement segmentElement = segmentsChildElement;
|
||||
foreach (XElement segmentChildElement in segmentElement.GetChildElements())
|
||||
{
|
||||
String segmentChildElementName = segmentChildElement.GetLocalName();
|
||||
if (segmentChildElementName.EqualsCI(ElementName_Body))
|
||||
{
|
||||
// Content segment body.
|
||||
XElement bodyElement = segmentChildElement;
|
||||
foreach (XElement bodyChildElement in bodyElement.GetChildElements())
|
||||
{
|
||||
String bodyChildElementName = bodyChildElement.GetLocalName();
|
||||
if (bodyChildElementName.EqualsCI(ElementName_Html))
|
||||
{
|
||||
// Content segment body HTML.
|
||||
XElement htmlElement = bodyChildElement;
|
||||
segment.Body.Html = htmlElement.Value;
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Segment' child element: " + segmentChildElementName);
|
||||
}
|
||||
}
|
||||
else if (segmentChildElementName.EqualsCI(ElementName_Image))
|
||||
{
|
||||
// Content segment image.
|
||||
XElement imageElement = segmentChildElement;
|
||||
foreach (XElement imageChildElement in imageElement.GetChildElements())
|
||||
{
|
||||
String imageChildElementName = imageChildElement.GetLocalName();
|
||||
if (imageChildElementName.EqualsCI(ElementName_ImageId))
|
||||
{
|
||||
// Content segment image Id.
|
||||
XElement imageIdElement = imageChildElement;
|
||||
segment.Image.ItemImageId = SysId.ToSysId(imageIdElement.Value);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Segment' child element: " + segmentChildElementName);
|
||||
}
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Segment' child element: " + segmentChildElementName);
|
||||
}
|
||||
// Add this segment to the list.
|
||||
if (segment.IsValid())
|
||||
content.Segments.Add(segment);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Segments' child element: " + segmentsChildElementName);
|
||||
}
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Root' child element: " + rootChildElementName);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Convert Content to serialised data to store on database.
|
||||
/// </summary>
|
||||
public static String GetContentData(ContentData content)
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
XElement contentElement = doc.AppendElement(ElementName_Content);
|
||||
XElement segmentsElement = contentElement.AppendElement(ElementName_Segments);
|
||||
foreach (ContentData.SegmentData segment in content.Segments)
|
||||
{
|
||||
if (!segment.IsValid()) continue;
|
||||
XElement segmentElement = segmentsElement.AppendElement(ElementName_Segment);
|
||||
if (segment.Body.IsValid())
|
||||
{
|
||||
// Segment Body.
|
||||
XElement bodyElement = segmentElement.AppendElement(ElementName_Body);
|
||||
if (!StringUtil.IsEmpty(segment.Body.Html))
|
||||
bodyElement.AppendElement(ElementName_Html, segment.Body.Html);
|
||||
}
|
||||
else if (segment.Image.IsValid())
|
||||
{
|
||||
// Segment Image.
|
||||
XElement imageElement = segmentElement.AppendElement(ElementName_Image);
|
||||
if (SysId.IsValid(segment.Image.ItemImageId))
|
||||
imageElement.AppendElement(ElementName_ImageId, SysId.ToString(segment.Image.ItemImageId));
|
||||
}
|
||||
}
|
||||
return doc.GetXml();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// Article.
|
||||
//=======================================================================
|
||||
public abstract partial class SaxArticle : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Author.
|
||||
UserAccountIdAuthor,
|
||||
Author_DisplayName,
|
||||
Author_Title,
|
||||
Author_FirstName,
|
||||
Author_LastName,
|
||||
// Organisation.
|
||||
OrganisationId,
|
||||
Organisation_Name,
|
||||
Organisation_LogoCount,
|
||||
// Sport.
|
||||
SportIdPrimary,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionIdPrimary,
|
||||
Region_Name,
|
||||
// Article.
|
||||
Headline,
|
||||
Summary,
|
||||
ItemImageIdThumbnail,
|
||||
PublishedAt_Date,
|
||||
PublishedAt_DateTime,
|
||||
// Feedback.
|
||||
Feedback_ViewCount,
|
||||
Feedback_FeedbackCount,
|
||||
Feedback_FeedbackTotal,
|
||||
Feedback_FeedbackAverage,
|
||||
// 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 UserAccountIdAuthor { get; set; }
|
||||
public SysId OrganisationId { get; set; }
|
||||
public String Headline { get; set; } = String.Empty;
|
||||
public String Summary { get; set; } = String.Empty;
|
||||
public SysId ItemImageIdThumbnail { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public SysId RegionIdPrimary { get; set; }
|
||||
public String BodyData { get; set; } = String.Empty;
|
||||
public DateTime? PublishedAt { 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 SysId UserAccountIdAuthor
|
||||
{
|
||||
get { return data.UserAccountIdAuthor; }
|
||||
set { CheckChanged(data.UserAccountIdAuthor, value); data.UserAccountIdAuthor = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { CheckChanged(data.RegionIdPrimary, value); data.RegionIdPrimary = value; }
|
||||
}
|
||||
public String Headline
|
||||
{
|
||||
get { return data.Headline; }
|
||||
set { CheckChanged(data.Headline, value); data.Headline = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { CheckChanged(data.Summary, value); data.Summary = value; }
|
||||
}
|
||||
public SysId ItemImageIdThumbnail
|
||||
{
|
||||
get { return data.ItemImageIdThumbnail; }
|
||||
set { CheckChanged(data.ItemImageIdThumbnail, value); data.ItemImageIdThumbnail = value; }
|
||||
}
|
||||
public String BodyData
|
||||
{
|
||||
get { return data.BodyData; }
|
||||
set { CheckChanged(data.BodyData, value); data.BodyData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { CheckChangedNullable(data.PublishedAt, value); data.PublishedAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountIdAuthor = data.UserAccountIdAuthor;
|
||||
OrganisationId = data.OrganisationId;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
RegionIdPrimary = data.RegionIdPrimary;
|
||||
Headline = data.Headline;
|
||||
Summary = data.Summary;
|
||||
ItemImageIdThumbnail = data.ItemImageIdThumbnail;
|
||||
BodyData = data.BodyData;
|
||||
PublishedAt = data.PublishedAt;
|
||||
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 UserAccountIdAuthor { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Headline { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Summary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ItemImageIdThumbnail { get; set; } = ValidValue.Valid;
|
||||
public ValidValue BodyData { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PublishedAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxArticle(SysId id, SysId UserAccountIdAuthor, SysId organisationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.UserAccountIdAuthor = UserAccountIdAuthor;
|
||||
this.OrganisationId = organisationId;
|
||||
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.Article, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(UserAccountIdAuthor) && SysId.ToInt(UserAccountIdAuthor) != SysId.ToInt(data.UserAccountIdAuthor))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} UserAccountIdAuthor cannot be changed");
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} OrganisationId cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountIdAuthor
|
||||
{
|
||||
get { return data.UserAccountIdAuthor; }
|
||||
protected set { data.UserAccountIdAuthor = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
protected set { data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { data.RegionIdPrimary = value; }
|
||||
}
|
||||
public String Headline
|
||||
{
|
||||
get { return data.Headline; }
|
||||
set { data.Headline = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { data.Summary = value; }
|
||||
}
|
||||
public SysId ItemImageIdThumbnail
|
||||
{
|
||||
get { return data.ItemImageIdThumbnail; }
|
||||
set { data.ItemImageIdThumbnail = value; }
|
||||
}
|
||||
public String BodyData
|
||||
{
|
||||
get { return data.BodyData; }
|
||||
set { data.BodyData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { data.PublishedAt = 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 List<SysId> UserAccountIdsAuthorIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Restrict to articles belonging to organisation.</summary>
|
||||
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Exclude articles belonging to organisations. Ignored if any organisations specified.</summary>
|
||||
public bool ExcludeOrganisationArticles { get; set; }
|
||||
public List<SysId> SportIdsIncluded { get; set; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public String HeadlinePartial { get; set; }
|
||||
public String SummaryPartial { get; set; }
|
||||
/// <summary>General filter value - headline, summary, sport, body etc. </summary>
|
||||
public String ArticleFilter { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxAuthorArticleList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Xml.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Contact data - associated with Organisations, Users etc.
|
||||
//=======================================================================
|
||||
public class SaxContactData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
private static readonly String ElementName_ContactMethods = "contactMethods";
|
||||
private static readonly String ElementName_ContactMethod = "contactMethod";
|
||||
private static readonly String AttributeName_Method = "method";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private class ContactMethodData
|
||||
{
|
||||
public Sax.ContactMethod Method { get; set; }
|
||||
public String Value { get; set; }
|
||||
}
|
||||
private Dictionary<Sax.ContactMethod, ContactMethodData> contactMethods { get; } = new Dictionary<Sax.ContactMethod, ContactMethodData>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction - from serialised data.
|
||||
public SaxContactData(String contactData = "")
|
||||
{
|
||||
ExtractContactData(contactData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public List<Sax.ContactMethod> Methods { get { return contactMethods.Keys.ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Contact Methods.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Extract the value associated with the specified method.</summary>
|
||||
public String GetContactMethodValue(Sax.ContactMethod method)
|
||||
{
|
||||
return contactMethods.GetValueOrDefault(method, new ContactMethodData()).Value;
|
||||
}
|
||||
|
||||
/// <summary>Set the value associated with the specified method.</summary>
|
||||
public bool SetContactMethodValue(Sax.ContactMethod method, String value)
|
||||
{
|
||||
if ((int)method < 1 || value.IsEmpty()) return false;
|
||||
ContactMethodData contactMethod = contactMethods.GetValueOrDefault(method, null);
|
||||
if (contactMethod == null)
|
||||
contactMethods.Add(method, contactMethod = new ContactMethodData() { Method = method });
|
||||
contactMethod.Value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Clear the value associated with the specified method.</summary>
|
||||
public bool ClearContactMethod(Sax.ContactMethod method)
|
||||
{
|
||||
return contactMethods.Remove(method);
|
||||
}
|
||||
|
||||
/// <summary>Clear all contact methods.</summary>
|
||||
public void ClearContactMethods()
|
||||
{
|
||||
contactMethods.Clear();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Serialisation.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract contact methods from serialised data.
|
||||
/// </summary>
|
||||
private void ExtractContactData(String contactData)
|
||||
{
|
||||
contactMethods.Clear();
|
||||
if (StringUtil.IsEmpty(contactData)) return;
|
||||
|
||||
try
|
||||
{
|
||||
// Load XML data.
|
||||
XDocument doc = XDocument.Parse(contactData);
|
||||
XElement rootElement = doc.Root;
|
||||
foreach (XElement rootChildElement in rootElement.GetChildElements())
|
||||
{
|
||||
String rootChildElementName = rootChildElement.GetLocalName();
|
||||
if (rootChildElementName.EqualsCI(ElementName_ContactMethod))
|
||||
{
|
||||
// Contact Method.
|
||||
String methodValue = rootChildElement.GetAttributeValue(AttributeName_Method);
|
||||
Sax.ContactMethod method = EnumUtil.ParseEnum(methodValue, Sax.ContactMethod.Unknown);
|
||||
if (method != Sax.ContactMethod.Unknown)
|
||||
{
|
||||
ContactMethodData contactMethod = new ContactMethodData()
|
||||
{
|
||||
Method = method,
|
||||
Value = rootChildElement.Value
|
||||
};
|
||||
contactMethods.Add(method, contactMethod);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unrecognised contact method: " + methodValue);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Root' child element: " + rootChildElementName);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Convert to serialised data.
|
||||
/// </summary>
|
||||
public String GetContactData()
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
XElement contactMethodsElement = doc.AppendElement(ElementName_ContactMethods);
|
||||
foreach (ContactMethodData contactMethod in contactMethods.Values)
|
||||
{
|
||||
if ((int)contactMethod.Method < 1 || contactMethod.Value.IsEmpty()) continue;
|
||||
XElement contactMethodElement = contactMethodsElement.AppendElement(ElementName_ContactMethod, contactMethod.Value);
|
||||
contactMethodElement.SetAttribute(AttributeName_Method, contactMethod.Method.ToString());
|
||||
}
|
||||
return doc.GetXml();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using System;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
/// <summary>Preserves Saxonite's disposable hierarchy-item contract over Common hierarchy items.</summary>
|
||||
public abstract class SaxDisposableHierarchyItem : SacsHierarchyItem, IDisposable
|
||||
{
|
||||
protected SaxDisposableHierarchyItem() : base() { }
|
||||
protected SaxDisposableHierarchyItem(SysId id) : base(id) { }
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
/// <summary>Combines Common error-state behavior with Saxonite disposal behavior.</summary>
|
||||
public abstract class SaxDisposableStateItem : SacsDisposable
|
||||
{
|
||||
public enum ErrorMessage
|
||||
{
|
||||
DatabaseNotAvailable,
|
||||
DatabaseQueryException,
|
||||
ItemNotSpecified,
|
||||
ValidItemId,
|
||||
InvalidItemId,
|
||||
ItemIdNotSpecified,
|
||||
ItemTypeNotSpecified,
|
||||
InvalidItemSpecified,
|
||||
MultipleItemsFound,
|
||||
InvalidDate,
|
||||
InvalidStatus,
|
||||
}
|
||||
|
||||
private SacsErrorState errorState;
|
||||
|
||||
public bool OK { get { return !HasErrorState(); } }
|
||||
public bool HasErrorState() { return errorState != null; }
|
||||
public SacsErrorState ErrorState { get { return errorState; } }
|
||||
public String ErrorStateMessage { get { return errorState?.Message ?? String.Empty; } }
|
||||
|
||||
public bool SetErrorState(String message)
|
||||
{
|
||||
if (StringUtil.IsBlank(message)) return false;
|
||||
errorState = new SacsErrorState(message);
|
||||
return false;
|
||||
}
|
||||
public void ClearErrorState() { errorState = null; }
|
||||
|
||||
protected bool SetErrorState(ErrorMessage errorMessage) { return SetErrorState(GetErrorMessage(errorMessage)); }
|
||||
private String GetErrorMessage(ErrorMessage errorMessage)
|
||||
{
|
||||
return errorMessage switch
|
||||
{
|
||||
ErrorMessage.DatabaseNotAvailable => "Database is not available",
|
||||
ErrorMessage.DatabaseQueryException => "Database query exception",
|
||||
ErrorMessage.ItemNotSpecified => "Item not specified",
|
||||
ErrorMessage.ValidItemId => "Item has a valid id",
|
||||
ErrorMessage.InvalidItemId => "Invalid item id",
|
||||
ErrorMessage.ItemIdNotSpecified => "Item Id must be specified",
|
||||
ErrorMessage.ItemTypeNotSpecified => "Item type must be specified",
|
||||
ErrorMessage.InvalidItemSpecified => "Invalid item specified",
|
||||
ErrorMessage.MultipleItemsFound => "Multiple items found",
|
||||
ErrorMessage.InvalidDate => "Invalid date",
|
||||
ErrorMessage.InvalidStatus => "Invalid status",
|
||||
_ => errorMessage.ToString(),
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,476 @@
|
||||
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
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
using Org.BouncyCastle.Utilities;
|
||||
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.Data;
|
||||
using System.Text;
|
||||
using static Sarand.Net.Standard.Base.Bus.ItemId;
|
||||
using static Sarand.Net.Standard.Base.ItemOptions.SaItemOptionDfn;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemAssociation : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item From.
|
||||
ItemTypeFrom,
|
||||
ItemTypeFrom_Code,
|
||||
ItemTypeFrom_Desc,
|
||||
ItemIdFrom,
|
||||
ItemFrom_Caption,
|
||||
// Item To.
|
||||
ItemTypeTo,
|
||||
ItemTypeTo_Code,
|
||||
ItemTypeTo_Desc,
|
||||
ItemIdTo,
|
||||
ItemTo_Caption,
|
||||
// Specific item properties.
|
||||
OrganisationFrom_Name,
|
||||
OrganisationFrom_SportIdPrimary,
|
||||
OrganisationFrom_RegionIdPrimary,
|
||||
OrganisationTo_Name,
|
||||
OrganisationTo_SportIdPrimary,
|
||||
OrganisationTo_RegionIdPrimary,
|
||||
// Association type.
|
||||
AssociationType,
|
||||
AssociationType_Code,
|
||||
AssociationType_Desc,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public class TypeOptionData
|
||||
{
|
||||
public TypeOptionData(Sax.AssociationTypeOption typeOption, String caption)
|
||||
{
|
||||
TypeOption = typeOption;
|
||||
Caption = StringUtil.OnBlank(caption);
|
||||
}
|
||||
public TypeOptionData(Sax.AssociationType associationType, bool reversed, String caption) :
|
||||
this(GetAssociationTypeOption(associationType, reversed), caption)
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public AssociationTypeOption TypeOption { get; }
|
||||
public String Caption { get; }
|
||||
// Comparison.
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null) return false;
|
||||
return Equals(obj as TypeOptionData);
|
||||
}
|
||||
public bool Equals(TypeOptionData value)
|
||||
{
|
||||
if (value == null) return false;
|
||||
if (this.TypeOption != value.TypeOption) return false;
|
||||
if (!this.Caption.EqualsCI(value.Caption)) return false;
|
||||
return true;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(TypeOption, Caption);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemIdFrom { get; set; } = new ItemId();
|
||||
public ItemId ItemIdTo { get; set; } = new ItemId();
|
||||
public Sax.AssociationType AssociationType { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public ItemId ItemIdFrom
|
||||
{
|
||||
get { return data.ItemIdFrom; }
|
||||
set { value = ItemId.InvalidOnNull(value); CheckChanged(data.ItemIdFrom, value); data.ItemIdFrom = value; }
|
||||
}
|
||||
public ItemId ItemIdTo
|
||||
{
|
||||
get { return data.ItemIdTo; }
|
||||
set { value = ItemId.InvalidOnNull(value); CheckChanged(data.ItemIdTo, value); data.ItemIdTo = value; }
|
||||
}
|
||||
public Sax.AssociationType AssociationType
|
||||
{
|
||||
get { return data.AssociationType; }
|
||||
set { CheckChanged((int)data.AssociationType, (int)value); data.AssociationType = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemIdFrom = data.ItemIdFrom;
|
||||
ItemIdTo = data.ItemIdTo;
|
||||
AssociationType = data.AssociationType;
|
||||
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 ItemIdFrom { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ItemIdTo { get; set; } = ValidValue.Valid;
|
||||
public ValidValue AssociationType { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemAssociation(SysId id, ItemId itemIdFrom, ItemId itemIdTo, Sax.AssociationType associationType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemIdFrom = itemIdFrom;
|
||||
ItemIdTo = itemIdTo;
|
||||
AssociationType = associationType;
|
||||
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.ItemAssociation, Id);
|
||||
}
|
||||
/// <summary>Valid 'From' item types for Association type.</summary>
|
||||
public static List<Sax.DataItemType> GetValidFromItemTypesForAssociation(Sax.AssociationType associationType)
|
||||
{
|
||||
List<Sax.DataItemType> itemTypes = new List<Sax.DataItemType>();
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate:
|
||||
case Sax.AssociationType.Partner:
|
||||
itemTypes.Add(Sax.DataItemType.Organisation);
|
||||
break;
|
||||
}
|
||||
return itemTypes;
|
||||
}
|
||||
/// <summary>Valid 'To' item types for Association type.</summary>
|
||||
public static List<Sax.DataItemType> GetValidToItemTypesForAssociation(Sax.AssociationType associationType)
|
||||
{
|
||||
List<Sax.DataItemType> itemTypes = new List<Sax.DataItemType>();
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate:
|
||||
case Sax.AssociationType.Partner:
|
||||
itemTypes.Add(Sax.DataItemType.Organisation);
|
||||
break;
|
||||
}
|
||||
return itemTypes;
|
||||
}
|
||||
/// <summary>Determin type option from type and parent/child direction.</summary>
|
||||
/// <param name="associationType"></param>
|
||||
/// <param name="reversed"></param>
|
||||
/// <returns></returns>
|
||||
public static AssociationTypeOption GetAssociationTypeOption(Sax.AssociationType associationType, bool reversed)
|
||||
{
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate: return reversed ? AssociationTypeOption.AffiliateChild : AssociationTypeOption.AffiliateParent;
|
||||
case Sax.AssociationType.Partner: return AssociationTypeOption.Partner;
|
||||
}
|
||||
return AssociationTypeOption.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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(ItemIdFrom) && ItemIdFrom.Type != data.ItemIdFrom.Type && SysId.ToInt(ItemIdFrom.Id) != SysId.ToInt(data.ItemIdFrom.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} From Item Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemIdTo) && ItemIdTo.Type != data.ItemIdTo.Type && SysId.ToInt(ItemIdTo.Id) != SysId.ToInt(data.ItemIdTo.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} To Item Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemIdFrom
|
||||
{
|
||||
get { return data.ItemIdFrom; }
|
||||
set { data.ItemIdFrom = value; }
|
||||
}
|
||||
public ItemId ItemIdTo
|
||||
{
|
||||
get { return data.ItemIdTo; }
|
||||
set { data.ItemIdTo = value; }
|
||||
}
|
||||
public Sax.AssociationType AssociationType
|
||||
{
|
||||
get { return data.AssociationType; }
|
||||
set { data.AssociationType = 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>();
|
||||
/// <summary>Items that can be eitehr 'From' or 'To'.</summary>
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
/// <summary>Items that can only be the 'From' item.</summary>
|
||||
public List<ItemId> ItemIdsFromIncluded { get; } = new List<ItemId>();
|
||||
/// <summary>Items that can only be the 'To' item.</summary>
|
||||
public List<ItemId> ItemIdsToIncluded { get; } = new List<ItemId>();
|
||||
public List<Sax.AssociationType> AssociationTypesIncluded { get; } = new List<Sax.AssociationType>();
|
||||
// Common properties.
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxAssociationList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemImage.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemImage : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
Item_Caption,
|
||||
// Image.
|
||||
ImageType,
|
||||
ImageType_Code,
|
||||
ImageType_Desc,
|
||||
ImageSeq,
|
||||
Filename,
|
||||
Mime,
|
||||
ContentType,
|
||||
Width,
|
||||
Height,
|
||||
DataSize,
|
||||
// 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.ImageType ImageType { get; set; }
|
||||
public byte ImageSeq { get; set; }
|
||||
public long SessionUid { get; set; }
|
||||
public int ImageUid { get; set; }
|
||||
public String Filename { get; set; }
|
||||
public String Mime { get; set; }
|
||||
public String ContentType { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public byte[] ImageData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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.ImageType ImageType
|
||||
{
|
||||
get { return data.ImageType; }
|
||||
set { CheckChanged((int)data.ImageType, (int)value); data.ImageType = value; }
|
||||
}
|
||||
public byte ImageSeq
|
||||
{
|
||||
get { return data.ImageSeq; }
|
||||
set { CheckChanged(data.ImageSeq, value); data.ImageSeq = value; }
|
||||
}
|
||||
public long SessionUid
|
||||
{
|
||||
get { return data.SessionUid; }
|
||||
set { CheckChanged(data.SessionUid, value); data.SessionUid = value; }
|
||||
}
|
||||
public int ImageUid
|
||||
{
|
||||
get { return data.ImageUid; }
|
||||
set { CheckChanged(data.ImageUid, value); data.ImageUid = value; }
|
||||
}
|
||||
public String Filename
|
||||
{
|
||||
get { return data.Filename; }
|
||||
set { CheckChanged(data.Filename, value); data.Filename = value; }
|
||||
}
|
||||
public String Mime
|
||||
{
|
||||
get { return data.Mime; }
|
||||
set { CheckChanged(data.Mime, value); data.Mime = value; }
|
||||
}
|
||||
public String ContentType
|
||||
{
|
||||
get { return data.ContentType; }
|
||||
set { CheckChanged(data.ContentType, value); data.ContentType = value; }
|
||||
}
|
||||
public int Width
|
||||
{
|
||||
get { return data.Width; }
|
||||
set { CheckChanged(data.Width, value); data.Width = value; }
|
||||
}
|
||||
public int Height
|
||||
{
|
||||
get { return data.Height; }
|
||||
set { CheckChanged(data.Height, value); data.Height = value; }
|
||||
}
|
||||
public byte[] ImageData
|
||||
{
|
||||
get { return data.ImageData; }
|
||||
set { CheckChanged(data.ImageData, value); data.ImageData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
ImageType = data.ImageType;
|
||||
ImageSeq = data.ImageSeq;
|
||||
SessionUid = data.SessionUid;
|
||||
ImageUid = data.ImageUid;
|
||||
Filename = data.Filename;
|
||||
Mime = data.Mime;
|
||||
ContentType = data.ContentType;
|
||||
Width = data.Width;
|
||||
Height = data.Height;
|
||||
ImageData = data.ImageData;
|
||||
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 ImageType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ImageSeq { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SessionUid { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ImageUid { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Filename { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Mime { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ContentType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Width { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Height { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ImageData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemImage(SysId id, ItemId itemId, Sax.ImageType imageType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
ImageType = imageType;
|
||||
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.ItemImage, Id);
|
||||
}
|
||||
|
||||
// Validation.
|
||||
public static List<Sax.DataItemType> ValidItemTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<Sax.DataItemType> { Sax.DataItemType.UserAccount, Sax.DataItemType.Organisation, Sax.DataItemType.Article };
|
||||
}
|
||||
}
|
||||
public static List<Sacs.MimeType> GetValidMimeTypes(Sax.DataItemType itemType)
|
||||
{
|
||||
switch (itemType)
|
||||
{
|
||||
case Sax.DataItemType.UserAccount:
|
||||
case Sax.DataItemType.Organisation:
|
||||
case Sax.DataItemType.Article:
|
||||
return new List<Sacs.MimeType> { Sacs.MimeType.Jpeg, Sacs.MimeType.Webp, Sacs.MimeType.Png, Sacs.MimeType.Svg };
|
||||
}
|
||||
return new List<Sacs.MimeType>();
|
||||
}
|
||||
public static List<String> GetValidContentTypes(Sax.DataItemType itemType)
|
||||
{
|
||||
switch (itemType)
|
||||
{
|
||||
case Sax.DataItemType.UserAccount:
|
||||
case Sax.DataItemType.Organisation:
|
||||
case Sax.DataItemType.Article:
|
||||
return new List<string> { "image/jpg", "image/jpeg", "image/webp", "image/png", "image/svg+xml" };
|
||||
}
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (ImageType > 0 && ImageType != data.ImageType)
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Image Type cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { data.ItemId = value; }
|
||||
}
|
||||
public Sax.ImageType ImageType
|
||||
{
|
||||
get { return data.ImageType; }
|
||||
set { data.ImageType = value; }
|
||||
}
|
||||
public byte ImageSeq
|
||||
{
|
||||
get { return data.ImageSeq; }
|
||||
set { data.ImageSeq = value; }
|
||||
}
|
||||
public long SessionUid
|
||||
{
|
||||
get { return data.SessionUid; }
|
||||
set { data.SessionUid = value; }
|
||||
}
|
||||
public int ImageUid
|
||||
{
|
||||
get { return data.ImageUid; }
|
||||
set { data.ImageUid = value; }
|
||||
}
|
||||
public String Filename
|
||||
{
|
||||
get { return data.Filename; }
|
||||
set { data.Filename = value; }
|
||||
}
|
||||
public String Mime
|
||||
{
|
||||
get { return data.Mime; }
|
||||
set { data.Mime = value; }
|
||||
}
|
||||
public String ContentType
|
||||
{
|
||||
get { return data.ContentType; }
|
||||
set { data.ContentType = value; }
|
||||
}
|
||||
public int Width
|
||||
{
|
||||
get { return data.Width; }
|
||||
set { data.Width = value; }
|
||||
}
|
||||
public int Height
|
||||
{
|
||||
get { return data.Height; }
|
||||
set { data.Height = value; }
|
||||
}
|
||||
public byte[] ImageData
|
||||
{
|
||||
get { return data.ImageData; }
|
||||
set { data.ImageData = 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 List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
public List<Sax.ImageType> ImageTypesIncluded { get; } = new List<Sax.ImageType>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemImageList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxItemImage GetItemImageById(this List<SaxItemImage> values, SysId itemImageId)
|
||||
{
|
||||
if (!SysId.IsValid(itemImageId)) return null;
|
||||
return values.Find(item => item.Id.Equals(itemImageId));
|
||||
}
|
||||
|
||||
public static SaxItemImage GetItemImageBySessionImage(this List<SaxItemImage> values, long sessionUid, int imageUid)
|
||||
{
|
||||
if (sessionUid < 1 || imageUid < 1) return null;
|
||||
return values.Find(item => item.SessionUid == sessionUid && item.ImageUid == imageUid);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemProcess : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
Item_Caption,
|
||||
// Sport.
|
||||
SportId,
|
||||
Sport_Name,
|
||||
// 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 SysId SportId { get; set; }
|
||||
public String ItemSportData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
set { CheckChanged(data.SportId, value); data.SportId = value; }
|
||||
}
|
||||
public String ItemSportData
|
||||
{
|
||||
get { return data.ItemSportData; }
|
||||
set { CheckChanged(data.ItemSportData, value); data.ItemSportData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
SportId = data.SportId;
|
||||
ItemSportData = data.ItemSportData;
|
||||
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 SportId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ItemSportData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemProcess(SysId id, ItemId itemId, SysId sportId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
SportId = sportId;
|
||||
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.ItemSport, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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(SportId) && SysId.ToInt(SportId) != SysId.ToInt(data.SportId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Sport Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
protected set { data.SportId = value; }
|
||||
}
|
||||
public String ItemSportData
|
||||
{
|
||||
get { return data.ItemSportData; }
|
||||
set { data.ItemSportData = 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 List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemSportList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
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;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Organisation.
|
||||
//=======================================================================
|
||||
public abstract class SaxOrganisation : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
Name,
|
||||
OrganisationType,
|
||||
OrganisationType_Desc,
|
||||
OrganisationCategory,
|
||||
OrganisationCategory_Desc,
|
||||
// Sport.
|
||||
SportId,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionId,
|
||||
Region_Name,
|
||||
// Associated data.
|
||||
/// <summary>Number of users with an active interest in the organisation.</summary>
|
||||
User_Count,
|
||||
/// <summary>Number of users who are 'members' of the organisation.</summary>
|
||||
Member_Count,
|
||||
/// <summary>Number of active logo images.</summary>
|
||||
LogoImage_Count,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public String Name { get; set; } = String.Empty;
|
||||
public Sax.OrganisationType OrganisationType { get; set; }
|
||||
public Sax.OrganisationCategory OrganisationCategory { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public SysId RegionIdPrimary { get; set; }
|
||||
public String About { get; set; } = String.Empty;
|
||||
public String Facilities { get; set; } = String.Empty;
|
||||
public String ContactData { 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 String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = value; }
|
||||
}
|
||||
public Sax.OrganisationType OrganisationType
|
||||
{
|
||||
get { return data.OrganisationType; }
|
||||
set { CheckChangedEnum(data.OrganisationType, value); data.OrganisationType = value; }
|
||||
}
|
||||
public Sax.OrganisationCategory OrganisationCategory
|
||||
{
|
||||
get { return data.OrganisationCategory; }
|
||||
set { CheckChangedEnum(data.OrganisationCategory, value); data.OrganisationCategory = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { CheckChanged(data.RegionIdPrimary, value); data.RegionIdPrimary = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { CheckChanged(data.About, value); data.About = value; }
|
||||
}
|
||||
public String Facilities
|
||||
{
|
||||
get { return data.Facilities; }
|
||||
set { CheckChanged(data.Facilities, value); data.Facilities = value; }
|
||||
}
|
||||
public String ContactData
|
||||
{
|
||||
get { return data.ContactData; }
|
||||
set { CheckChanged(data.ContactData, value); data.ContactData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
Name = data.Name;
|
||||
OrganisationType = data.OrganisationType;
|
||||
OrganisationCategory = data.OrganisationCategory;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
RegionIdPrimary = data.RegionIdPrimary;
|
||||
About = data.About;
|
||||
Facilities = data.Facilities;
|
||||
ContactData = data.ContactData;
|
||||
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 Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationCategory { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue About { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Facilities { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ContactData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxOrganisation(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Awaiting,
|
||||
SaStatus.Active,
|
||||
SaStatus.OnHold,
|
||||
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.OnHold) return DataValue.TriStateType.Amber;
|
||||
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.Organisation, Id);
|
||||
}
|
||||
// Sport is mandatory for certain organisation categories.
|
||||
public static bool IsSportMandatory(Sax.OrganisationCategory organisationCategory)
|
||||
{
|
||||
if (organisationCategory == Sax.OrganisationCategory.Club) return true;
|
||||
if (organisationCategory == Sax.OrganisationCategory.Association) return true;
|
||||
if (organisationCategory == Sax.OrganisationCategory.SportDepartment) return true;
|
||||
return false;
|
||||
}
|
||||
private static List<Sax.ContactMethod> validContactMethods = new List<Sax.ContactMethod>
|
||||
{
|
||||
Sax.ContactMethod.PhoneMain,
|
||||
Sax.ContactMethod.PhoneOffice,
|
||||
// Online.
|
||||
Sax.ContactMethod.Email,
|
||||
Sax.ContactMethod.Website,
|
||||
Sax.ContactMethod.Wikipedia,
|
||||
// Social media.
|
||||
Sax.ContactMethod.LinkedIn,
|
||||
Sax.ContactMethod.Twitter,
|
||||
Sax.ContactMethod.Facebook,
|
||||
Sax.ContactMethod.Instagram,
|
||||
Sax.ContactMethod.YouTube,
|
||||
Sax.ContactMethod.Twitch,
|
||||
};
|
||||
public static List<Sax.ContactMethod> ValidContactMethods { get { return new List<Sax.ContactMethod>(validContactMethods); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { data.Name = value; }
|
||||
}
|
||||
public Sax.OrganisationType OrganisationType
|
||||
{
|
||||
get { return data.OrganisationType; }
|
||||
set { data.OrganisationType = value; }
|
||||
}
|
||||
public Sax.OrganisationCategory OrganisationCategory
|
||||
{
|
||||
get { return data.OrganisationCategory; }
|
||||
set { data.OrganisationCategory = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { data.RegionIdPrimary = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { data.About = value; }
|
||||
}
|
||||
public String Facilities
|
||||
{
|
||||
get { return data.Facilities; }
|
||||
set { data.Facilities = value; }
|
||||
}
|
||||
public String ContactData
|
||||
{
|
||||
get { return data.ContactData; }
|
||||
set { data.ContactData = 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,
|
||||
AwaitingOnly,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public String NameFull { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
public Sax.OrganisationCategory OrganisationCategory { get; set; } = Sax.OrganisationCategory.Unknown;
|
||||
public HashSet<Sax.OrganisationCategory> OrganisationCategoriesExcluded { get; } = new HashSet<Sax.OrganisationCategory>();
|
||||
public Sax.OrganisationType OrganisationType { get; set; } = Sax.OrganisationType.Unknown;
|
||||
/// <summary>Partial match on a number of fields, including name, sport, address, etc.</summary>
|
||||
public String OrganisationFilter { get; set; }
|
||||
public HashSet<SysId> SportIdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> RegionIdsIncluded { get; } = new HashSet<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Sport_Primary { get; set; }
|
||||
public String Alias_Region_Primary { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxOrganisationList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the Organisation Ids.
|
||||
/// </summary>
|
||||
public static List<SysId> GetIds(this List<SaxOrganisation> values)
|
||||
{
|
||||
return values.Select(item => item.Id).ToList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the first Organisation in list with the specified Id.
|
||||
/// </summary>
|
||||
public static SaxOrganisation GetOrganisationById(this List<SaxOrganisation> values, SysId organisationId)
|
||||
{
|
||||
return values.Find(item => item.Id.Equals(organisationId));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Get the name of the first Organisation in list with the specified Id.
|
||||
/// </summary>
|
||||
public static String GetOrganisationName(this List<SaxOrganisation> values, SysId organisationId)
|
||||
{
|
||||
return values.Find(item => item.Id.Equals(organisationId))?.Name ?? "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// Organisation Event.
|
||||
//=======================================================================
|
||||
public abstract class SaxOrganisationEvent : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Organisation.
|
||||
OrganisationId,
|
||||
Organisation_Name,
|
||||
Organisation_LogoCount,
|
||||
// Sport.
|
||||
SportIdPrimary,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionIdCountry,
|
||||
Region_Name,
|
||||
// Event.
|
||||
EventAt_Date,
|
||||
EventAt_DateTime,
|
||||
EventTo_Date,
|
||||
EventTo_DateTime,
|
||||
EventTypeCode,
|
||||
EventType_Desc,
|
||||
Summary,
|
||||
Details,
|
||||
PublishedAt_Date,
|
||||
PublishedAt_DateTime,
|
||||
ExpiresAt_Date,
|
||||
ExpiresAt_DateTime,
|
||||
// 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 OrganisationId { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public SysId RegionIdCountry { get; set; }
|
||||
public DateTime EventAt { get; set; }
|
||||
public DateTime? EventTo { get; set; }
|
||||
public Sax.EventType EventType { get; set; }
|
||||
public String Summary { get; set; } = String.Empty;
|
||||
public String Details { get; set; } = String.Empty;
|
||||
public String EventData { get; set; } = String.Empty;
|
||||
public DateTime? PublishedAt { get; set; } = null;
|
||||
public DateTime? ExpiresAt { 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 SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { CheckChanged(data.RegionIdCountry, value); data.RegionIdCountry = value; }
|
||||
}
|
||||
public DateTime EventAt
|
||||
{
|
||||
get { return data.EventAt; }
|
||||
set { CheckChanged(data.EventAt, value); data.EventAt = value; }
|
||||
}
|
||||
public DateTime? EventTo
|
||||
{
|
||||
get { return data.EventTo; }
|
||||
set { CheckChangedNullable(data.EventTo, value); data.EventTo = value; }
|
||||
}
|
||||
public Sax.EventType EventType
|
||||
{
|
||||
get { return data.EventType; }
|
||||
set { CheckChanged((int)data.EventType, (int)value); data.EventType = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { CheckChanged(data.Summary, value); data.Summary = value; }
|
||||
}
|
||||
public String Details
|
||||
{
|
||||
get { return data.Details; }
|
||||
set { CheckChanged(data.Details, value); data.Details = value; }
|
||||
}
|
||||
public String EventData
|
||||
{
|
||||
get { return data.EventData; }
|
||||
set { CheckChanged(data.EventData, value); data.EventData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { CheckChangedNullable(data.PublishedAt, value); data.PublishedAt = value; }
|
||||
}
|
||||
public DateTime? ExpiresAt
|
||||
{
|
||||
get { return data.ExpiresAt; }
|
||||
set { CheckChangedNullable(data.ExpiresAt, value); data.ExpiresAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
OrganisationId = data.OrganisationId;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
RegionIdCountry = data.RegionIdCountry;
|
||||
EventAt = data.EventAt;
|
||||
EventTo = data.EventTo;
|
||||
EventType = data.EventType;
|
||||
Summary = data.Summary;
|
||||
Details = data.Details;
|
||||
EventData = data.EventData;
|
||||
PublishedAt = data.PublishedAt;
|
||||
ExpiresAt = data.ExpiresAt;
|
||||
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 OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdCountry { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EventAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EventTo { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EventType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Summary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Details { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EventData { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PublishedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpiresAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxOrganisationEvent(SysId id, SysId organisationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.OrganisationId = organisationId;
|
||||
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.OrganisationEvent, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time of exactly midnight is treated as invalid.
|
||||
/// <para>- Valid start time of midnight is stored with at least +1 minute (00:01:00).</para>
|
||||
/// </summary>
|
||||
public static bool HasValidEventTime(DateTime? eventDateTime)
|
||||
{
|
||||
return DateUtil.IsValid(eventDateTime) && DateUtil.Format(eventDateTime, "HH:mm:ss") != "00:00:00";
|
||||
}
|
||||
|
||||
public bool HasValidEventAtTime()
|
||||
{
|
||||
return HasValidEventTime(EventAt);
|
||||
}
|
||||
|
||||
public bool HasValidEventToTime()
|
||||
{
|
||||
return HasValidEventTime(EventTo);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Organisation Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
protected set { data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { data.RegionIdCountry = value; }
|
||||
}
|
||||
public DateTime EventAt
|
||||
{
|
||||
get { return data.EventAt; }
|
||||
set { data.EventAt = value; }
|
||||
}
|
||||
public DateTime? EventTo
|
||||
{
|
||||
get { return data.EventTo; }
|
||||
set { data.EventTo = value; }
|
||||
}
|
||||
public Sax.EventType EventType
|
||||
{
|
||||
get { return data.EventType; }
|
||||
set { data.EventType = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { data.Summary = value; }
|
||||
}
|
||||
public String Details
|
||||
{
|
||||
get { return data.Details; }
|
||||
set { data.Details = value; }
|
||||
}
|
||||
public String EventData
|
||||
{
|
||||
get { return data.EventData; }
|
||||
set { data.EventData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { data.PublishedAt = value; }
|
||||
}
|
||||
public DateTime? ExpiresAt
|
||||
{
|
||||
get { return data.ExpiresAt; }
|
||||
set { data.ExpiresAt = 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>();
|
||||
/// <summary>Restrict to User Account via User Organisations and Organisations.</summary>
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> SportIdsIncluded { get; set; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public DateTime EventFrom { get; set; }
|
||||
public DateTime EventTo { get; set; }
|
||||
public String SummaryPartial { get; set; }
|
||||
/// <summary>General filter value - position, outline, sport, body etc. </summary>
|
||||
public String EventFilter { get; set; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Organisation { get; set; }
|
||||
public String Alias_UserOrganisation { get; set; }
|
||||
public String Alias_UserAccount { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxOrganisationEventList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// Organisation Opportunity.
|
||||
//=======================================================================
|
||||
public abstract class SaxOrganisationOpportunity : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Organisation.
|
||||
OrganisationId,
|
||||
Organisation_Name,
|
||||
Organisation_LogoCount,
|
||||
// Sport.
|
||||
SportIdPrimary,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionIdPrimary,
|
||||
Region_Name,
|
||||
// Opportunity.
|
||||
OpportunityTypeCode,
|
||||
OpportunityType_Desc,
|
||||
Position,
|
||||
Outline,
|
||||
PublishedAt_Date,
|
||||
PublishedAt_DateTime,
|
||||
ExpiresAt_Date,
|
||||
ExpiresAt_DateTime,
|
||||
// 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 OrganisationId { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public SysId RegionIdPrimary { get; set; }
|
||||
public Sax.OpportunityType OpportunityType { get; set; }
|
||||
public String Position { get; set; } = String.Empty;
|
||||
public String Outline { get; set; } = String.Empty;
|
||||
public String OpportunityData { get; set; } = String.Empty;
|
||||
public DateTime? PublishedAt { get; set; } = null;
|
||||
public DateTime? ExpiresAt { 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 SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { CheckChanged(data.RegionIdPrimary, value); data.RegionIdPrimary = value; }
|
||||
}
|
||||
public Sax.OpportunityType OpportunityType
|
||||
{
|
||||
get { return data.OpportunityType; }
|
||||
set { CheckChanged((int)data.OpportunityType, (int)value); data.OpportunityType = value; }
|
||||
}
|
||||
public String Position
|
||||
{
|
||||
get { return data.Position; }
|
||||
set { CheckChanged(data.Position, value); data.Position = value; }
|
||||
}
|
||||
public String Outline
|
||||
{
|
||||
get { return data.Outline; }
|
||||
set { CheckChanged(data.Outline, value); data.Outline = value; }
|
||||
}
|
||||
public String OpportunityData
|
||||
{
|
||||
get { return data.OpportunityData; }
|
||||
set { CheckChanged(data.OpportunityData, value); data.OpportunityData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { CheckChangedNullable(data.PublishedAt, value); data.PublishedAt = value; }
|
||||
}
|
||||
public DateTime? ExpiresAt
|
||||
{
|
||||
get { return data.ExpiresAt; }
|
||||
set { CheckChangedNullable(data.ExpiresAt, value); data.ExpiresAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
OrganisationId = data.OrganisationId;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
RegionIdPrimary = data.RegionIdPrimary;
|
||||
OpportunityType = data.OpportunityType;
|
||||
Position = data.Position;
|
||||
Outline = data.Outline;
|
||||
OpportunityData = data.OpportunityData;
|
||||
PublishedAt = data.PublishedAt;
|
||||
ExpiresAt = data.ExpiresAt;
|
||||
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 OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OpportunityType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Position { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Outline { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OpportunityData { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PublishedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpiresAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxOrganisationOpportunity(SysId id, SysId OrganisationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.OrganisationId = OrganisationId;
|
||||
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.OrganisationOpportunity, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Organisation Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
protected set { data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { data.RegionIdPrimary = value; }
|
||||
}
|
||||
public Sax.OpportunityType OpportunityType
|
||||
{
|
||||
get { return data.OpportunityType; }
|
||||
set { data.OpportunityType = value; }
|
||||
}
|
||||
public String Position
|
||||
{
|
||||
get { return data.Position; }
|
||||
set { data.Position = value; }
|
||||
}
|
||||
public String Outline
|
||||
{
|
||||
get { return data.Outline; }
|
||||
set { data.Outline = value; }
|
||||
}
|
||||
public String OpportunityData
|
||||
{
|
||||
get { return data.OpportunityData; }
|
||||
set { data.OpportunityData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { data.PublishedAt = value; }
|
||||
}
|
||||
public DateTime? ExpiresAt
|
||||
{
|
||||
get { return data.ExpiresAt; }
|
||||
set { data.ExpiresAt = 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>();
|
||||
/// <summary>Restrict to User Account via User Organisations and Organisations.</summary>
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> SportIdsIncluded { get; set; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public String PositionPartial { get; set; }
|
||||
public String OutlinePartial { get; set; }
|
||||
/// <summary>General filter value - position, outline, sport, body etc. </summary>
|
||||
public String OpportunityFilter { get; set; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Organisation { get; set; }
|
||||
public String Alias_UserOrganisation { get; set; }
|
||||
public String Alias_UserAccount { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxOrganisationOpportunityList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// Region.
|
||||
//=======================================================================
|
||||
public abstract class SaxRegion : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
RegionType,
|
||||
RegionType_Desc,
|
||||
CountryIso2Code,
|
||||
Name,
|
||||
// Parent region.
|
||||
RegionIdParent,
|
||||
Parent_Name,
|
||||
Parent_RegionType,
|
||||
Parent_RegionType_Desc,
|
||||
// Associated data.
|
||||
ChildRegionCount,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public Sax.RegionType RegionType { get; set; } = Sax.RegionType.Unknown;
|
||||
public String CountryIso2Code { get; set; } = String.Empty;
|
||||
public String Name { get; set; } = String.Empty;
|
||||
public Decimal? Latitude { get; set; } = null;
|
||||
public Decimal? Longitude { get; set; } = null;
|
||||
public SysId RegionIdParent { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public Sax.RegionType RegionType
|
||||
{
|
||||
get { return data.RegionType; }
|
||||
set { CheckChangedEnum(data.RegionType, value); data.RegionType = value; }
|
||||
}
|
||||
public String CountryIso2Code
|
||||
{
|
||||
get { return data.CountryIso2Code; }
|
||||
set { CheckChanged(data.CountryIso2Code, value); data.CountryIso2Code = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = 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 SysId RegionIdParent
|
||||
{
|
||||
get { return data.RegionIdParent; }
|
||||
set { CheckChanged(data.RegionIdParent, value); data.RegionIdParent = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
RegionType = data.RegionType;
|
||||
CountryIso2Code = data.CountryIso2Code;
|
||||
Name = data.Name;
|
||||
Latitude = data.Latitude;
|
||||
Longitude = data.Longitude;
|
||||
RegionIdParent = data.RegionIdParent;
|
||||
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 RegionType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CountryIso2Code { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Latitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Longitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdParent { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxRegion(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
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.Region, Id);
|
||||
}
|
||||
public static List<Sax.RegionType> GetValidParentRegionTypes(Sax.RegionType regionType)
|
||||
{
|
||||
List<Sax.RegionType> parentRegionTypes = new List<Sax.RegionType>();
|
||||
switch (regionType)
|
||||
{
|
||||
case Sax.RegionType.World:
|
||||
parentRegionTypes.Add(Sax.RegionType.Galaxy);
|
||||
break;
|
||||
case Sax.RegionType.Continent:
|
||||
parentRegionTypes.Add(Sax.RegionType.World);
|
||||
break;
|
||||
case Sax.RegionType.SubContinent:
|
||||
parentRegionTypes.Add(Sax.RegionType.Continent);
|
||||
break;
|
||||
case Sax.RegionType.Country:
|
||||
parentRegionTypes.Add(Sax.RegionType.Continent);
|
||||
parentRegionTypes.Add(Sax.RegionType.SubContinent);
|
||||
break;
|
||||
case Sax.RegionType.Nation:
|
||||
parentRegionTypes.Add(Sax.RegionType.Country);
|
||||
break;
|
||||
case Sax.RegionType.State:
|
||||
parentRegionTypes.Add(Sax.RegionType.Country);
|
||||
break;
|
||||
case Sax.RegionType.Province:
|
||||
parentRegionTypes.Add(Sax.RegionType.Country);
|
||||
parentRegionTypes.Add(Sax.RegionType.Nation);
|
||||
break;
|
||||
}
|
||||
return parentRegionTypes;
|
||||
}
|
||||
public static bool IsValidParentRegionType(Sax.RegionType regionType, Sax.RegionType parentRegionType)
|
||||
{
|
||||
return GetValidParentRegionTypes(regionType).Contains(parentRegionType);
|
||||
}
|
||||
public bool IsValidParentRegionType(Sax.RegionType parentRegionType)
|
||||
{
|
||||
return IsValidParentRegionType(RegionType, parentRegionType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
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 Sax.RegionType RegionType
|
||||
{
|
||||
get { return data.RegionType; }
|
||||
set { data.RegionType = value; }
|
||||
}
|
||||
public String CountryIso2Code
|
||||
{
|
||||
get { return data.CountryIso2Code; }
|
||||
set { data.CountryIso2Code = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { data.Name = value; }
|
||||
}
|
||||
public Decimal? Latitude
|
||||
{
|
||||
get { return data.Latitude; }
|
||||
set { data.Latitude = value; }
|
||||
}
|
||||
public Decimal? Longitude
|
||||
{
|
||||
get { return data.Longitude; }
|
||||
set { data.Longitude = value; }
|
||||
}
|
||||
public SysId RegionIdParent
|
||||
{
|
||||
get { return data.RegionIdParent; }
|
||||
set { data.RegionIdParent = 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 List<SysId> ParentRegionIdsIncluded { get; } = new List<SysId>();
|
||||
public Sax.RegionType RegionType { get; set; }
|
||||
public List<String> CountryIso2CodesIncluded { get; } = new List<String>();
|
||||
public List<String> CountryIso2CodesExcluded { get; } = new List<String>();
|
||||
/// <summary>Generic filter - partial region name, iso2 code or other matching value (tbd).</summary>
|
||||
public String RegionFilter { get; set; }
|
||||
public String NameFull { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxRegionList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the first Region in list with the specified Id.
|
||||
/// </summary>
|
||||
public static SaxRegion GetRegionById(this List<SaxRegion> values, SysId regionId)
|
||||
{
|
||||
return values.Find(item => item.Id.Equals(regionId));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// Sport.
|
||||
//=======================================================================
|
||||
public abstract class SaxSport : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
Grouping,
|
||||
Grouping_Desc,
|
||||
SportIdParent,
|
||||
ParentSport_Name,
|
||||
Name,
|
||||
SpecialityLabel,
|
||||
SpecialityLabel_Desc,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public Sax.SportGrouping Grouping { get; set; }
|
||||
public SysId SportIdParent { get; set; }
|
||||
public String Name { get; set; } = String.Empty;
|
||||
public Sax.SportSpecialityLabel SpecialityLabel { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public Sax.SportGrouping Grouping
|
||||
{
|
||||
get { return data.Grouping; }
|
||||
set { CheckChanged((short)data.Grouping, (short)value); data.Grouping = value; }
|
||||
}
|
||||
public SysId SportIdParent
|
||||
{
|
||||
get { return data.SportIdParent; }
|
||||
set { CheckChanged(data.SportIdParent, value); data.SportIdParent = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = value; }
|
||||
}
|
||||
public Sax.SportSpecialityLabel SpecialityLabel
|
||||
{
|
||||
get { return data.SpecialityLabel; }
|
||||
set { CheckChanged((short)data.SpecialityLabel, (short)value); data.SpecialityLabel = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
Grouping = data.Grouping;
|
||||
SportIdParent = data.SportIdParent;
|
||||
Name = data.Name;
|
||||
SpecialityLabel = data.SpecialityLabel;
|
||||
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 Grouping { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdParent { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SpecialityLabel { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxSport(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
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.Sport, 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 Sax.SportGrouping Grouping
|
||||
{
|
||||
get { return data.Grouping; }
|
||||
set { data.Grouping = value; }
|
||||
}
|
||||
public SysId SportIdParent
|
||||
{
|
||||
get { return data.SportIdParent; }
|
||||
set { data.SportIdParent = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { data.Name = value; }
|
||||
}
|
||||
public Sax.SportSpecialityLabel SpecialityLabel
|
||||
{
|
||||
get { return data.SpecialityLabel; }
|
||||
set { data.SpecialityLabel = 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 SportGroupingCat
|
||||
{
|
||||
Any,
|
||||
Specific,
|
||||
Banner,
|
||||
BannerOrSpecific,
|
||||
Group,
|
||||
}
|
||||
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 SportGroupingCat SportGroupingCat { get; set; } = SportGroupingCat.BannerOrSpecific;
|
||||
public SysId SportIdParent { get; set; }
|
||||
/// <summary>Generic filter - partial sport name, or other matching value (tbd).</summary>
|
||||
public String SportFilter { get; set; }
|
||||
public String NameFull { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxSportList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxSport GetSportById(this IEnumerable<SaxSport> values, SysId sportId)
|
||||
{
|
||||
if (!SysId.IsValid(sportId)) return null;
|
||||
foreach (SaxSport sport in values)
|
||||
if (sport.Id.Equals(sportId)) return sport;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Contact data - associated with Organisations, Users etc.
|
||||
//=======================================================================
|
||||
public class SaxSportContactsData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
private static readonly String ElementName_Contacts = "Contacts";
|
||||
private static readonly String ElementName_Contact = "Contact";
|
||||
private static readonly String AttributeName_Type = "Type";
|
||||
private static readonly String ElementName_Type = "Type";
|
||||
private static readonly String ElementName_UserAccountId = "UserAccountId";
|
||||
private static readonly String ElementName_Title = "Title";
|
||||
private static readonly String ElementName_FirstName = "FirstName";
|
||||
private static readonly String ElementName_LastName = "LastName";
|
||||
private static readonly String ElementName_Phone = "Phone";
|
||||
private static readonly String ElementName_EmailAddress = "EmailAddress";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private class ContactData
|
||||
{
|
||||
public Sax.SportContactType ContactType { get; set; }
|
||||
public SysId UserAccountId { get; set; }
|
||||
public String Title { get; set; }
|
||||
public String FirstName { get; set; }
|
||||
public String LastName { get; set; }
|
||||
public String EmailAddress { get; set; }
|
||||
public String Phone { get; set; }
|
||||
}
|
||||
private Dictionary<Sax.SportContactType, ContactData> contacts { get; } = new Dictionary<Sax.SportContactType, ContactData>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction - from serialised data.
|
||||
public SaxSportContactsData(String contactsData = "")
|
||||
{
|
||||
FromXml(contactsData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public List<Sax.SportContactType> ContactTypes { get { return contacts.Keys.ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
/// <summary>Get the contact for the specified type.</summary>
|
||||
private ContactData GetContactData(Sax.SportContactType contactType)
|
||||
{
|
||||
if ((int)contactType < 1) return null;
|
||||
ContactData contact = contacts.GetValueOrDefault(contactType, null);
|
||||
if (contact == null)
|
||||
contacts.Add(contactType, contact = new ContactData() { ContactType = contactType });
|
||||
return contact;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Contacts.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Extract the title associated with the specified type.</summary>
|
||||
public String GetContactTitle(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).Title;
|
||||
}
|
||||
|
||||
/// <summary>Extract the first name associated with the specified type.</summary>
|
||||
public String GetContactFirstName(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).FirstName;
|
||||
}
|
||||
|
||||
/// <summary>Extract the last name associated with the specified type.</summary>
|
||||
public String GetContactLastName(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).LastName;
|
||||
}
|
||||
|
||||
/// <summary>Extract the email address associated with the specified type.</summary>
|
||||
public String GetContactEmailAddress(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).EmailAddress;
|
||||
}
|
||||
|
||||
/// <summary>Extract the phone associated with the specified type.</summary>
|
||||
public String GetContactPhone(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).Phone;
|
||||
}
|
||||
|
||||
/// <summary>Set the name associated with the specified contact.</summary>
|
||||
public bool SetContactName(Sax.SportContactType contactType, String title, String firstName, String lastName)
|
||||
{
|
||||
if ((int)contactType < 1 || lastName.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.Title = title;
|
||||
contact.FirstName = firstName;
|
||||
contact.LastName = lastName;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Set the email address associated with the specified contact.</summary>
|
||||
public bool SetContactEmailAddress(Sax.SportContactType contactType, String emailAddress)
|
||||
{
|
||||
if ((int)contactType < 1 || emailAddress.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.EmailAddress = emailAddress;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Set the phone associated with the specified contact.</summary>
|
||||
public bool SetContactPhone(Sax.SportContactType contactType, String phone)
|
||||
{
|
||||
if ((int)contactType < 1 || phone.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.Phone = phone;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Clear the value associated with the specified method.</summary>
|
||||
public bool ClearContact(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.Remove(contactType);
|
||||
}
|
||||
|
||||
/// <summary>Clear all contact methods.</summary>
|
||||
public void ClearContacts()
|
||||
{
|
||||
contacts.Clear();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Serialisation.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Serialise as XML.</summary>
|
||||
public String ToXml()
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
XElement contactsElement = doc.AppendElement(ElementName_Contacts);
|
||||
foreach (ContactData contactData in contacts.Values)
|
||||
{
|
||||
if ((int)contactData.ContactType < 1 || (!SysId.IsValid(contactData.UserAccountId) && StringUtil.IsBlank(contactData.LastName))) continue;
|
||||
XElement contactElement = contactsElement.AppendElement(ElementName_Contact);
|
||||
contactElement.SetAttribute(AttributeName_Type, ((int)contactData.ContactType).ToString());
|
||||
contactElement.AppendElement(ElementName_Type, contactData.ContactType.ToString());
|
||||
if (!StringUtil.IsBlank(contactData.Title))
|
||||
contactElement.AppendElement(ElementName_Title, contactData.Title);
|
||||
if (!StringUtil.IsBlank(contactData.FirstName))
|
||||
contactElement.AppendElement(ElementName_FirstName, contactData.FirstName);
|
||||
if (!StringUtil.IsBlank(contactData.LastName))
|
||||
contactElement.AppendElement(ElementName_LastName, contactData.LastName);
|
||||
if (!StringUtil.IsBlank(contactData.EmailAddress))
|
||||
contactElement.AppendElement(ElementName_EmailAddress, contactData.EmailAddress);
|
||||
if (!StringUtil.IsBlank(contactData.Phone))
|
||||
contactElement.AppendElement(ElementName_Phone, contactData.Phone);
|
||||
}
|
||||
return doc.GetXml();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Deserialise from XML data.</summary>
|
||||
private void FromXml(String contactsData)
|
||||
{
|
||||
contacts.Clear();
|
||||
if (StringUtil.IsEmpty(contactsData)) return;
|
||||
|
||||
try
|
||||
{
|
||||
// Load XML data.
|
||||
XDocument doc = XDocument.Parse(contactsData);
|
||||
XElement rootElement = doc.Root;
|
||||
foreach (XElement rootChildElement in rootElement.GetChildElements())
|
||||
{
|
||||
String rootChildElementName = rootChildElement.GetLocalName();
|
||||
if (rootChildElementName.EqualsCI(ElementName_Contact))
|
||||
{
|
||||
// Contact.
|
||||
String contactTypeValue = rootChildElement.GetChildText(ElementName_Type);
|
||||
Sax.SportContactType contactType = EnumUtil.ParseEnum(contactTypeValue, Sax.SportContactType.Unknown);
|
||||
if (contactType != Sax.SportContactType.Unknown)
|
||||
{
|
||||
ContactData contactData = new ContactData()
|
||||
{
|
||||
ContactType = contactType,
|
||||
UserAccountId = SysId.ToSysId(rootChildElement.GetChildText(ElementName_UserAccountId)),
|
||||
Title = rootChildElement.GetChildText(ElementName_Title),
|
||||
FirstName = rootChildElement.GetChildText(ElementName_FirstName),
|
||||
LastName = rootChildElement.GetChildText(ElementName_LastName),
|
||||
EmailAddress = rootChildElement.GetChildText(ElementName_EmailAddress),
|
||||
Phone = rootChildElement.GetChildText(ElementName_Phone),
|
||||
};
|
||||
contacts.Add(contactType, contactData);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unrecognised contact type: " + contactType);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Root' child element: " + rootChildElementName);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,554 @@
|
||||
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;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxUserAccount : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
EmailAddress,
|
||||
Title,
|
||||
FirstName,
|
||||
Initials,
|
||||
LastName,
|
||||
About,
|
||||
PhoneMain,
|
||||
PhoneMobile,
|
||||
DateOfBirthDay,
|
||||
DateOfBirthMonth,
|
||||
DateOfBirthYear,
|
||||
DateOfBirth,
|
||||
// Regions.
|
||||
RegionIdCountry,
|
||||
RegionCountry_Name,
|
||||
RegionIdProvince,
|
||||
RegionProvince_Name,
|
||||
// Security.
|
||||
PasswordToken,
|
||||
PasswordChangedOn,
|
||||
PasswordChangedAt,
|
||||
// Login.
|
||||
LastLoginOn,
|
||||
LastLoginAt,
|
||||
LastInvalidLoginOn,
|
||||
LastInvalidLoginAt,
|
||||
InvalidLoginCount,
|
||||
// Associated data.
|
||||
UserSportCount,
|
||||
UserSportCount_Active,
|
||||
UserRoleCount,
|
||||
SystemAdminUser,
|
||||
LastAdminLoginOn,
|
||||
LastAdminLoginAt,
|
||||
LastInvalidAdminLoginOn,
|
||||
LastInvalidAdminLoginAt,
|
||||
InvalidAdminLoginCount,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public String EmailAddress { get; set; } = String.Empty;
|
||||
public String Title { get; set; } = String.Empty;
|
||||
public String FirstName { get; set; } = String.Empty;
|
||||
public String Initials { get; set; } = String.Empty;
|
||||
public String LastName { get; set; } = String.Empty;
|
||||
public String About { get; set; } = String.Empty;
|
||||
public String PhoneMain { get; set; } = String.Empty;
|
||||
public String PhoneMobile { get; set; } = String.Empty;
|
||||
public Sax.Gender Gender { get; set; }
|
||||
public String GenderOther { get; set; }
|
||||
public byte? DateOfBirthDay { get; set; } = null;
|
||||
public byte? DateOfBirthMonth { get; set; } = null;
|
||||
public short? DateOfBirthYear { get; set; } = null;
|
||||
public SysId RegionIdCountry { get; set; }
|
||||
public SysId RegionIdProvince { get; set; }
|
||||
// Security.
|
||||
public String PasswordHashed { get; set; } = String.Empty;
|
||||
public List<String> PasswordHistory { get; } = new List<string>();
|
||||
public String PasswordToken { get; set; } = String.Empty;
|
||||
public DateTime? PasswordChangedAt { get; set; } = null;
|
||||
// Login.
|
||||
public DateTime? LastLoginAt { get; set; } = null;
|
||||
public DateTime? LastInvalidLoginAt { get; set; } = null;
|
||||
public short InvalidLoginCount { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public String EmailAddress
|
||||
{
|
||||
get { return data.EmailAddress; }
|
||||
set { CheckChanged(data.EmailAddress, value); data.EmailAddress = value; }
|
||||
}
|
||||
public String Title
|
||||
{
|
||||
get { return data.Title; }
|
||||
set { CheckChanged(data.Title, value); data.Title = value; }
|
||||
}
|
||||
public String FirstName
|
||||
{
|
||||
get { return data.FirstName; }
|
||||
set { CheckChanged(data.FirstName, value); data.FirstName = value; }
|
||||
}
|
||||
public String Initials
|
||||
{
|
||||
get { return data.Initials; }
|
||||
set { CheckChanged(data.Initials, value); data.Initials = value; }
|
||||
}
|
||||
public String LastName
|
||||
{
|
||||
get { return data.LastName; }
|
||||
set { CheckChanged(data.LastName, value); data.LastName = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { CheckChanged(data.About, value); data.About = value; }
|
||||
}
|
||||
public String PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { CheckChanged(data.PhoneMain, value); data.PhoneMain = value; }
|
||||
}
|
||||
public String PhoneMobile
|
||||
{
|
||||
get { return data.PhoneMobile; }
|
||||
set { CheckChanged(data.PhoneMobile, value); data.PhoneMobile = value; }
|
||||
}
|
||||
public Sax.Gender Gender
|
||||
{
|
||||
get { return data.Gender; }
|
||||
set { CheckChanged((int)data.Gender, (int)value); data.Gender = value; }
|
||||
}
|
||||
public String GenderOther
|
||||
{
|
||||
get { return data.GenderOther; }
|
||||
set { CheckChanged(data.GenderOther, value); data.GenderOther = value; }
|
||||
}
|
||||
public byte? DateOfBirthDay
|
||||
{
|
||||
get { return data.DateOfBirthDay; }
|
||||
set { if ((value??0) < 1) value = null; CheckChangedNullable(data.DateOfBirthDay, value); data.DateOfBirthDay = value; }
|
||||
}
|
||||
public byte? DateOfBirthMonth
|
||||
{
|
||||
get { return data.DateOfBirthMonth; }
|
||||
set { if ((value ?? 0) < 1) value = null; CheckChangedNullable(data.DateOfBirthMonth, value); data.DateOfBirthMonth = value; }
|
||||
}
|
||||
public short? DateOfBirthYear
|
||||
{
|
||||
get { return data.DateOfBirthYear; }
|
||||
set { if ((value ?? 0) < 1) value = null; CheckChangedNullable(data.DateOfBirthYear, value); data.DateOfBirthYear = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { CheckChanged(data.RegionIdCountry, value); data.RegionIdCountry = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { CheckChanged(data.RegionIdProvince, value); data.RegionIdProvince = value; }
|
||||
}
|
||||
// Security.
|
||||
public String PasswordHashed
|
||||
{
|
||||
get { return data.PasswordHashed; }
|
||||
set { CheckChanged(data.PasswordHashed, value); data.PasswordHashed = value; }
|
||||
}
|
||||
public List<String> PasswordHistory
|
||||
{
|
||||
get { return data.PasswordHistory; }
|
||||
set
|
||||
{
|
||||
CheckChanged(data.PasswordHistory, value);
|
||||
data.PasswordHistory.Clear();
|
||||
data.PasswordHistory.AddRange((value ?? new List<String>()).FindAll(item => !StringUtil.IsEmpty(StringUtil.TrimAll(item))));
|
||||
}
|
||||
}
|
||||
public String PasswordToken
|
||||
{
|
||||
get { return data.PasswordToken; }
|
||||
set { CheckChanged(data.PasswordToken, value); data.PasswordToken = value; }
|
||||
}
|
||||
public DateTime? PasswordChangedAt
|
||||
{
|
||||
get { return data.PasswordChangedAt; }
|
||||
set { CheckChangedNullable(data.PasswordChangedAt, value); data.PasswordChangedAt = value; }
|
||||
}
|
||||
// Login.
|
||||
public DateTime? LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { CheckChangedNullable(data.LastLoginAt, value); data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime? LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { CheckChangedNullable(data.LastInvalidLoginAt, value); data.LastInvalidLoginAt = value; }
|
||||
}
|
||||
public short InvalidLoginCount
|
||||
{
|
||||
get { return data.InvalidLoginCount; }
|
||||
set { CheckChanged(data.InvalidLoginCount, value); data.InvalidLoginCount = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
EmailAddress = data.EmailAddress;
|
||||
Title = data.Title;
|
||||
FirstName = data.FirstName;
|
||||
Initials = data.Initials;
|
||||
LastName = data.LastName;
|
||||
About = data.About;
|
||||
PhoneMain = data.PhoneMain;
|
||||
PhoneMobile = data.PhoneMobile;
|
||||
Gender = data.Gender;
|
||||
GenderOther = data.GenderOther;
|
||||
DateOfBirthDay = data.DateOfBirthDay;
|
||||
DateOfBirthMonth = data.DateOfBirthMonth;
|
||||
DateOfBirthYear = data.DateOfBirthYear;
|
||||
RegionIdCountry = data.RegionIdCountry;
|
||||
RegionIdProvince = data.RegionIdProvince;
|
||||
// Security.
|
||||
PasswordHashed = data.PasswordHashed;
|
||||
PasswordHistory = data.PasswordHistory;
|
||||
PasswordToken = data.PasswordToken;
|
||||
PasswordChangedAt = data.PasswordChangedAt;
|
||||
// Login.
|
||||
LastLoginAt = data.LastLoginAt;
|
||||
LastInvalidLoginAt = data.LastInvalidLoginAt;
|
||||
InvalidLoginCount = data.InvalidLoginCount;
|
||||
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 EmailAddress { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Title { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FirstName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Initials { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue About { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PhoneMain { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PhoneMobile { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Gender { get; set; } = ValidValue.Valid;
|
||||
public ValidValue GenderOther { get; set; } = ValidValue.Valid;
|
||||
public ValidValue DateOfBirthDay { get; set; } = ValidValue.Valid;
|
||||
public ValidValue DateOfBirthMonth { get; set; } = ValidValue.Valid;
|
||||
public ValidValue DateOfBirthYear { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdCountry { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdProvince { get; set; } = ValidValue.Valid;
|
||||
// Security.
|
||||
public ValidValue Password { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PasswordHistory { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PasswordToken { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PasswordChanged { get; set; } = ValidValue.Valid;
|
||||
// Login.
|
||||
public ValidValue LastLogin { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastInvalidLogin { get; set; } = ValidValue.Valid;
|
||||
public ValidValue InvalidLoginCount { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
public static readonly String UserRoleDelim = ",";
|
||||
public static readonly String PasswordHistoryDelim = ",";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserAccount(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Awaiting,
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Awaiting; } }
|
||||
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.Awaiting) return DataValue.TriStateType.Amber;
|
||||
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.UserAccount, Id);
|
||||
}
|
||||
public static String GetDisplayName(SaxUserAccount userAccount)
|
||||
{
|
||||
return GetDisplayName(userAccount.Title, userAccount.FirstName, userAccount.LastName);
|
||||
}
|
||||
public static String GetDisplayName(String title, String firstName, String lastName)
|
||||
{
|
||||
return StringUtil.TrimAll(StringUtil.EmptyOnNull(title) + " " + StringUtil.EmptyOnNull(firstName) + " " + StringUtil.EmptyOnNull(lastName));
|
||||
}
|
||||
public String GetDisplayName()
|
||||
{
|
||||
return GetDisplayName(this);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 String EmailAddress
|
||||
{
|
||||
get { return data.EmailAddress; }
|
||||
set { data.EmailAddress = value; }
|
||||
}
|
||||
public String Title
|
||||
{
|
||||
get { return data.Title; }
|
||||
set { data.Title = value; }
|
||||
}
|
||||
public String FirstName
|
||||
{
|
||||
get { return data.FirstName; }
|
||||
set { data.FirstName = value; }
|
||||
}
|
||||
public String Initials
|
||||
{
|
||||
get { return data.Initials; }
|
||||
set { data.Initials = value; }
|
||||
}
|
||||
public String LastName
|
||||
{
|
||||
get { return data.LastName; }
|
||||
set { data.LastName = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { data.About = value; }
|
||||
}
|
||||
public String PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { data.PhoneMain = value; }
|
||||
}
|
||||
public String PhoneMobile
|
||||
{
|
||||
get { return data.PhoneMobile; }
|
||||
set { data.PhoneMobile = value; }
|
||||
}
|
||||
public Sax.Gender Gender
|
||||
{
|
||||
get { return data.Gender; }
|
||||
set { data.Gender = value; }
|
||||
}
|
||||
public String GenderOther
|
||||
{
|
||||
get { return data.GenderOther; }
|
||||
set { data.GenderOther = value; }
|
||||
}
|
||||
public byte? DateOfBirthDay
|
||||
{
|
||||
get { return data.DateOfBirthDay; }
|
||||
set { data.DateOfBirthDay = value; }
|
||||
}
|
||||
public byte? DateOfBirthMonth
|
||||
{
|
||||
get { return data.DateOfBirthMonth; }
|
||||
set { data.DateOfBirthMonth = value; }
|
||||
}
|
||||
public short? DateOfBirthYear
|
||||
{
|
||||
get { return data.DateOfBirthYear; }
|
||||
set { data.DateOfBirthYear = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { data.RegionIdCountry = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { data.RegionIdProvince = value; }
|
||||
}
|
||||
|
||||
// Security.
|
||||
public String PasswordHashed
|
||||
{
|
||||
get { return data.PasswordHashed; }
|
||||
set { data.PasswordHashed = value; }
|
||||
}
|
||||
public List<String> PasswordHistory
|
||||
{
|
||||
get { return data.PasswordHistory; }
|
||||
set { data.PasswordHistory = value; }
|
||||
}
|
||||
public String PasswordToken
|
||||
{
|
||||
get { return data.PasswordToken; }
|
||||
set { data.PasswordToken = value; }
|
||||
}
|
||||
public DateTime ?PasswordChangedAt
|
||||
{
|
||||
get { return data.PasswordChangedAt; }
|
||||
set { data.PasswordChangedAt = value; }
|
||||
}
|
||||
|
||||
// Login.
|
||||
public DateTime? LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime? LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { data.LastInvalidLoginAt = value; }
|
||||
}
|
||||
public short InvalidLoginCount
|
||||
{
|
||||
get { return data.InvalidLoginCount; }
|
||||
set { data.InvalidLoginCount = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
public Byte Flag_KeepLoggedIn { get; } = 0x1;
|
||||
public bool KeepLoggedIn
|
||||
{
|
||||
get { return GetFlag(Flag_KeepLoggedIn); }
|
||||
set { SetFlag(Flag_KeepLoggedIn, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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,
|
||||
AwaitingOnly,
|
||||
ActiveOnly,
|
||||
AwaitingOrActive,
|
||||
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 String EmailAddress { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
/// <summary>Exact match on various user account properties including name, email etc.</summary>
|
||||
public String UserFilter { get; set; }
|
||||
/// <summary>Partial match on various user account properties including name, countries etc. Not to be used in Online application!</summary>
|
||||
public String UserFilterPartial { get; set; }
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public List<Sax.UserRole> ActiveRoles { get; } = new List<Sax.UserRole>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_UserSport { get; set; }
|
||||
public String Alias_UserSport_Sport { get; set; }
|
||||
public String Alias_UserRole { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserAccountList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the User Account Ids.
|
||||
/// </summary>
|
||||
public static List<SysId> GetIds(this List<SaxUserAccount> values)
|
||||
{
|
||||
return values.Select(item => item.Id).ToList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the first User Account in list with the specified Id.
|
||||
/// </summary>
|
||||
public static SaxUserAccount GetUserAccountById(this List<SaxUserAccount> values, SysId userAccountId)
|
||||
{
|
||||
return values.Find(item => item.Id.Equals(userAccountId));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// UserActivity.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserActivity : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Activity.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
FirstListedAt,
|
||||
LastListedAt,
|
||||
FirstViewedAt,
|
||||
LastViewedAt,
|
||||
Reaction,
|
||||
FirstReactedAt,
|
||||
LastReactedAt,
|
||||
// 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 UserAccountId { get; set; }
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public bool CurrentlyListed {get; set; }
|
||||
public DateTime ListedAtFirst { get; set; }
|
||||
public DateTime? ListedAtLast { get; set; } = null;
|
||||
public DateTime? ViewedAtFirst { get; set; } = null;
|
||||
public DateTime? ViewedAtLast { get; set; } = null;
|
||||
public Sax.ActivityReaction Reaction { get; set; }
|
||||
public DateTime? ReactedAtFirst { get; set; } = null;
|
||||
public DateTime? ReactedAtLast { get; set; } = null;
|
||||
public String UserActivityData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public bool CurrentlyListed
|
||||
{
|
||||
get { return data.CurrentlyListed; }
|
||||
set { CheckChanged(data.CurrentlyListed, value); data.CurrentlyListed = value; }
|
||||
}
|
||||
public DateTime ListedAtFirst
|
||||
{
|
||||
get { return data.ListedAtFirst; }
|
||||
set { CheckChanged(data.ListedAtFirst, value); data.ListedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ListedAtLast
|
||||
{
|
||||
get { return data.ListedAtLast; }
|
||||
set { CheckChangedNullable(data.ListedAtLast, value); data.ListedAtLast = value; }
|
||||
}
|
||||
public DateTime? ViewedAtFirst
|
||||
{
|
||||
get { return data.ViewedAtFirst; }
|
||||
set { CheckChangedNullable(data.ViewedAtFirst, value); data.ViewedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ViewedAtLast
|
||||
{
|
||||
get { return data.ViewedAtLast; }
|
||||
set { CheckChangedNullable(data.ViewedAtLast, value); data.ViewedAtLast = value; }
|
||||
}
|
||||
public Sax.ActivityReaction Reaction
|
||||
{
|
||||
get { return data.Reaction; }
|
||||
set { CheckChanged((int)data.Reaction, (int)value); data.Reaction = value; }
|
||||
}
|
||||
public DateTime? ReactedAtFirst
|
||||
{
|
||||
get { return data.ReactedAtFirst; }
|
||||
set { CheckChangedNullable(data.ReactedAtFirst, value); data.ReactedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ReactedAtLast
|
||||
{
|
||||
get { return data.ReactedAtLast; }
|
||||
set { CheckChangedNullable(data.ReactedAtLast, value); data.ReactedAtLast = value; }
|
||||
}
|
||||
public String UserActivityData
|
||||
{
|
||||
get { return data.UserActivityData; }
|
||||
set { CheckChanged(data.UserActivityData, value); data.UserActivityData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ItemId = data.ItemId;
|
||||
CurrentlyListed = data.CurrentlyListed;
|
||||
ListedAtFirst = data.ListedAtFirst;
|
||||
ListedAtLast = data.ListedAtLast;
|
||||
ViewedAtFirst = data.ViewedAtFirst;
|
||||
ViewedAtLast = data.ViewedAtLast;
|
||||
Reaction = data.Reaction;
|
||||
ReactedAtFirst = data.ReactedAtFirst;
|
||||
ReactedAtLast = data.ReactedAtLast;
|
||||
UserActivityData = data.UserActivityData;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CurrentlyListed { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ListedAtFirst { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ListedAtLast { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ViewedAtFirst { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ViewedAtLast { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Reaction { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ReactedAtFirst { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ReactedAtLast { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserActivityData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserActivity(SysId id, SysId userAccountId, ItemId itemId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
ItemId = itemId;
|
||||
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.UserActivity, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account 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");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public bool CurrentlyListed
|
||||
{
|
||||
get { return data.CurrentlyListed; }
|
||||
set { data.CurrentlyListed = value; }
|
||||
}
|
||||
public DateTime ListedAtFirst
|
||||
{
|
||||
get { return data.ListedAtFirst; }
|
||||
set { data.ListedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ListedAtLast
|
||||
{
|
||||
get { return data.ListedAtLast; }
|
||||
set { data.ListedAtLast = value; }
|
||||
}
|
||||
public DateTime? ViewedAtFirst
|
||||
{
|
||||
get { return data.ViewedAtFirst; }
|
||||
set { data.ViewedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ViewedAtLast
|
||||
{
|
||||
get { return data.ViewedAtLast; }
|
||||
set { data.ViewedAtLast = value; }
|
||||
}
|
||||
public Sax.ActivityReaction Reaction
|
||||
{
|
||||
get { return data.Reaction; }
|
||||
set { data.Reaction = value; }
|
||||
}
|
||||
public DateTime? ReactedAtFirst
|
||||
{
|
||||
get { return data.ReactedAtFirst; }
|
||||
set { data.ReactedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ReactedAtLast
|
||||
{
|
||||
get { return data.ReactedAtLast; }
|
||||
set { data.ReactedAtLast = value; }
|
||||
}
|
||||
public String UserActivityData
|
||||
{
|
||||
get { return data.UserActivityData; }
|
||||
set { data.UserActivityData = 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 List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
// Table aliases - blank if not specified/linked.
|
||||
public String Alias_UserActivity { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserActivityList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
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 static Saxonite.Net.Standard.Base.App.Sax;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// User Config.
|
||||
//=======================================================================
|
||||
/// <summary>
|
||||
/// User Config - parameters to control application behaviour.
|
||||
/// </summary>
|
||||
public abstract partial class SaxUserConfig : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Configuration.
|
||||
ConfigType,
|
||||
// Associated data.
|
||||
// Common.
|
||||
//Flags,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public Sax.UserConfigType ConfigType { get; set; }
|
||||
public String ConfigData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserConfigType ConfigType
|
||||
{
|
||||
get { return data.ConfigType; }
|
||||
set { CheckChanged((int)data.ConfigType, (int)value); data.ConfigType = value; }
|
||||
}
|
||||
public String ConfigData
|
||||
{
|
||||
get { return data.ConfigData; }
|
||||
set { CheckChanged(data.ConfigData, value); data.ConfigData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ConfigType = data.ConfigType;
|
||||
ConfigData = data.ConfigData;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ConfigType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ConfigData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserConfig(SysId id, SysId userAccountId, Sax.UserConfigType configType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
ConfigType = configType;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public static String ActivityIndexDelim { get; } = ",";
|
||||
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 (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (ConfigType != data.ConfigType)
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Config Type cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserConfigType ConfigType
|
||||
{
|
||||
get { return data.ConfigType; }
|
||||
protected set { data.ConfigType = value; }
|
||||
}
|
||||
public String ConfigData
|
||||
{
|
||||
get { return data.ConfigData; }
|
||||
set { data.ConfigData = 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.
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public Sax.UserConfigType ConfigType { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserConfigList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax.Config.Security;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// User Eligibility.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserEligibility : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Region.
|
||||
RegionId,
|
||||
Region_Type,
|
||||
Region_Type_Desc,
|
||||
Region_CountryIso2Code,
|
||||
Region_Name,
|
||||
Region_ParentId,
|
||||
// Eligibility.
|
||||
EligibilityType,
|
||||
EligibilityType_Desc,
|
||||
Info,
|
||||
ExpiresOn,
|
||||
// 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 UserAccountId { get; set; }
|
||||
public SysId RegionId { get; set; }
|
||||
public String Info { get; set; }
|
||||
public Sax.EligibilityType EligibilityType { get; set; }
|
||||
public DateTime? ExpiresOn { 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 SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public SysId RegionId
|
||||
{
|
||||
get { return data.RegionId; }
|
||||
set { CheckChanged(data.RegionId, value); data.RegionId = value; }
|
||||
}
|
||||
public Sax.EligibilityType EligibilityType
|
||||
{
|
||||
get { return data.EligibilityType; }
|
||||
set { CheckChanged((int)data.EligibilityType, (int)value); data.EligibilityType = value; }
|
||||
}
|
||||
public String Info
|
||||
{
|
||||
get { return data.Info; }
|
||||
set { CheckChanged(data.Info, value); data.Info = value; }
|
||||
}
|
||||
public DateTime? ExpiresOn
|
||||
{
|
||||
get { return data.ExpiresOn; }
|
||||
set { CheckChangedNullable(data.ExpiresOn, value); data.ExpiresOn = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
RegionId = data.RegionId;
|
||||
EligibilityType = data.EligibilityType;
|
||||
Info = data.Info;
|
||||
ExpiresOn = data.ExpiresOn;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EligibilityType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Info { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpiresOn { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserEligibility(SysId id, SysId userAccountId, SysId regionId, Sax.EligibilityType eligibilityType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
RegionId = regionId;
|
||||
EligibilityType = eligibilityType;
|
||||
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.UserEligibility, Id);
|
||||
}
|
||||
|
||||
/// <summary>Maximum number of instances per user, regardless of region.</summary>
|
||||
public static int GetMaxInstances(Sax.EligibilityType eligibilityType)
|
||||
{
|
||||
switch (eligibilityType)
|
||||
{
|
||||
case Sax.EligibilityType.Birth: return 1;
|
||||
case Sax.EligibilityType.Naturalised: return 1;
|
||||
case Sax.EligibilityType.Parent: return 2;
|
||||
case Sax.EligibilityType.Grandparent: return 4;
|
||||
case Sax.EligibilityType.Passport: return 9;
|
||||
case Sax.EligibilityType.Visa: return 9;
|
||||
}
|
||||
return 9;
|
||||
}
|
||||
|
||||
/// <summary>Does the eligibility allow a date range.</summary>
|
||||
public static bool AllowsApplicablePeriod(Sax.EligibilityType eligibilityType)
|
||||
{
|
||||
switch (eligibilityType)
|
||||
{
|
||||
//case Sax.EligibilityType.Birth:
|
||||
//case Sax.EligibilityType.Naturalised:
|
||||
//case Sax.EligibilityType.Parent:
|
||||
//case Sax.EligibilityType.Grandparent:
|
||||
case Sax.EligibilityType.Passport:
|
||||
case Sax.EligibilityType.Visa:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (SysId.IsValid(RegionId) && SysId.ToInt(RegionId) != SysId.ToInt(data.RegionId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Region Id cannot be changed");
|
||||
if (EligibilityType == 0 && (int)EligibilityType != (int)EligibilityType)
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Eligibility cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
|
||||
/// <summary>User Account Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set
|
||||
{
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException("EligibilityType.UserAccountId cannot be changed");
|
||||
data.UserAccountId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Region Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId RegionId
|
||||
{
|
||||
get { return data.RegionId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(RegionId) && SysId.ToInt(RegionId) != SysId.ToInt(data.RegionId))
|
||||
throw new NotSupportedException("EligibilityType.RegionId cannot be changed");
|
||||
data.RegionId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>User Eligibility. Can only be populated on construction.</summary>
|
||||
public Sax.EligibilityType EligibilityType
|
||||
{
|
||||
get { return data.EligibilityType; }
|
||||
set { data.EligibilityType = value; }
|
||||
}
|
||||
|
||||
public String Info
|
||||
{
|
||||
get { return data.Info; }
|
||||
set { data.Info = value; }
|
||||
}
|
||||
|
||||
public DateTime? ExpiresOn
|
||||
{
|
||||
get { return data.ExpiresOn; }
|
||||
set { data.ExpiresOn = 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 List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public List<Sax.EligibilityType> EligibilityTypesIncluded { get; } = new List<Sax.EligibilityType>();
|
||||
public DateTime ValidOn { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxEligibilityTypeList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve the first entry in the list matching the specified Region.</summary>
|
||||
public static List<SaxUserEligibility> GetEligibilityTypesByStatus(this List<SaxUserEligibility> values, SysId regionId)
|
||||
{
|
||||
return values.FindAll(item => item.RegionId == regionId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve the first entry in the list matching the specified Eligibility.</summary>
|
||||
public static SaxUserEligibility GetEligibilityTypeByEligibility(this List<SaxUserEligibility> values, Sax.EligibilityType EligibilityType)
|
||||
{
|
||||
return values.Find(item => item.EligibilityType == EligibilityType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// UserRole.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserOnline : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
UserAccountId,
|
||||
OnlineOn,
|
||||
OnlineAt,
|
||||
// User properties.
|
||||
EmailAddress,
|
||||
DisplayName, Title, FirstName, LastName,
|
||||
LastLoginOn,
|
||||
LastLoginAt,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public DateTime OnlineAt { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public DateTime OnlineAt
|
||||
{
|
||||
get { return data.OnlineAt; }
|
||||
set { CheckChanged(data.OnlineAt, value); data.OnlineAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
OnlineAt = data.OnlineAt;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OnlineAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserOnline(SysId userAccountId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
/// <summary>User Account Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException("UserRole.UserAccountId cannot be changed");
|
||||
data.UserAccountId = value;
|
||||
}
|
||||
}
|
||||
/// <summary>Online At - last time user was active Online.</summary>
|
||||
public DateTime OnlineAt
|
||||
{
|
||||
get { return data.OnlineAt; }
|
||||
set { data.OnlineAt = 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.
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public DateTime OnlineOnFrom { get; set; }
|
||||
public DateTime OnlineOnTo { get; set; }
|
||||
/// <summary>Exact match on various user account properties including name, email etc.</summary>
|
||||
public String UserFilter { get; set; }
|
||||
/// <summary>Partial match on various user account properties including name, email etc. Not to be used in Online application!</summary>
|
||||
public String UserFilterPartial { get; set; }
|
||||
// User Account filters.
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_UserAccount { get; set; }
|
||||
public String Alias_UserSport { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserOnlineList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
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.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserOrganisation.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserOrganisation : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserAccountId,
|
||||
OrganisationId,
|
||||
OrganisationRoleCount,
|
||||
OrganisationRoleCodes,
|
||||
OrganisationRoleDescs,
|
||||
// User.
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
User_Status,
|
||||
User_Status_Desc,
|
||||
// Organisation.
|
||||
Organisation_Name,
|
||||
Organisation_Category,
|
||||
Organisation_Type,
|
||||
Organisation_RegionId,
|
||||
Organisation_Region_Name,
|
||||
Organisation_SportId,
|
||||
Organisation_Sport_Name,
|
||||
Organisation_Member_Count,
|
||||
Organisation_Opportunity_Count,
|
||||
Organisation_LogoImage_Count,
|
||||
// Properties.
|
||||
AdminComment,
|
||||
// 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 UserAccountId { get; set; }
|
||||
public SysId OrganisationId { get; set; }
|
||||
public HashSet<Sax.OrganisationRole> OrganisationRoles { get; } = new HashSet<Sax.OrganisationRole>();
|
||||
public String AdminComment { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
// Organisation roles.
|
||||
public byte OrganisationRoleCount
|
||||
{
|
||||
get { return (byte)data.OrganisationRoles.Count; }
|
||||
}
|
||||
public ReadOnlyCollection<Sax.OrganisationRole> GetOrganisationRoles()
|
||||
{
|
||||
return data.OrganisationRoles.ToList().AsReadOnly();
|
||||
}
|
||||
public void ClearOrganisationRoles()
|
||||
{
|
||||
if (!Changed) Changed = !data.OrganisationRoles.IsEmpty();
|
||||
data.OrganisationRoles.Clear();
|
||||
}
|
||||
public bool HasAnyOrganisationRole(IEnumerable<Sax.OrganisationRole> organisationRoles)
|
||||
{
|
||||
return data.OrganisationRoles.Any(item => organisationRoles.Contains(item));
|
||||
}
|
||||
public void AddOrganisationRole(Sax.OrganisationRole organisationRole)
|
||||
{
|
||||
if (!data.OrganisationRoles.Contains(organisationRole))
|
||||
{
|
||||
if (!Changed) Changed = true;
|
||||
data.OrganisationRoles.Add(organisationRole);
|
||||
}
|
||||
}
|
||||
/// <summary>Store organisation roles.</summary>
|
||||
public IEnumerable<Sax.OrganisationRole> OrganisationRoles
|
||||
{
|
||||
set
|
||||
{
|
||||
if (Object.ReferenceEquals(data.OrganisationRoles, value))
|
||||
{
|
||||
// Lists are the same object.
|
||||
// Assume the list has been modified, sort it and immediately return.
|
||||
// NB Shouldn't happen as HashSet isn't exposed.
|
||||
Changed = true;
|
||||
return;
|
||||
}
|
||||
CheckChanged(data.OrganisationRoles.ToList(), value);
|
||||
data.OrganisationRoles.Clear();
|
||||
foreach (Sax.OrganisationRole organisationRole in value)
|
||||
data.OrganisationRoles.Add(organisationRole);
|
||||
}
|
||||
}
|
||||
// Admin comment.
|
||||
public String AdminComment
|
||||
{
|
||||
get { return data.AdminComment; }
|
||||
set { CheckChanged(data.AdminComment, value); data.AdminComment = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
OrganisationId = data.OrganisationId;
|
||||
OrganisationRoles = data.GetOrganisationRoles().ToList();
|
||||
AdminComment = data.AdminComment;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationRoles { get; set; } = ValidValue.Valid;
|
||||
public ValidValue AdminComment { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
public static readonly String UserOrgnisationRoleDelim = ",";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserOrganisation(SysId id, SysId userAccountId, SysId organisationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
OrganisationId = organisationId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
/// <summary>
|
||||
/// UserOrganisation is either active or deleted.
|
||||
/// <para>Other status are handled by the User Account itself.</para>
|
||||
/// <para>As the User Organisation is simple a link between the user and Organisation and membership is defined by the presence of the 'Member' role.</para>
|
||||
/// </summary>
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
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.UserOrganisation, Id);
|
||||
}
|
||||
public static List<Sax.OrganisationRole> GetOrganisationRolesFromCodes(String organisationRoleCodes)
|
||||
{
|
||||
return GetOrganisationRolesFromCodes(StringListUtil.Split(organisationRoleCodes, UserOrgnisationRoleDelim, true, true, true));
|
||||
}
|
||||
public static List<Sax.OrganisationRole> GetOrganisationRolesFromCodes(List<String> organisationRoleCodes)
|
||||
{
|
||||
List<Sax.OrganisationRole> organisationRoles = new List<Sax.OrganisationRole>();
|
||||
List<TypeCodeDesc> roles = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationRole);
|
||||
foreach (String organisationRoleCode in organisationRoleCodes)
|
||||
{
|
||||
Sax.OrganisationRole organisationRole = (Sax.OrganisationRole)roles.GetTypeForCode(organisationRoleCode);
|
||||
if (organisationRole == 0)
|
||||
organisationRole = EnumUtil.ParseEnum(organisationRoleCode, Sax.OrganisationRole.Unknown);
|
||||
if (organisationRole > 0)
|
||||
organisationRoles.Add(organisationRole);
|
||||
}
|
||||
return organisationRoles;
|
||||
}
|
||||
public List<String> GetOrganisationRoleCodes()
|
||||
{
|
||||
List<String> organisationRoleCodes = new List<string>();
|
||||
List<TypeCodeDesc> roles = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationRole);
|
||||
foreach (Sax.OrganisationRole organisationRole in GetOrganisationRoles())
|
||||
organisationRoleCodes.Add(roles.GetCodeForType(organisationRole));
|
||||
organisationRoleCodes.Sort();
|
||||
return organisationRoleCodes;
|
||||
}
|
||||
public String GetOrganisationRoleCodesData()
|
||||
{
|
||||
return GetOrganisationRoleCodes().Concat(UserOrgnisationRoleDelim);
|
||||
}
|
||||
// Query roles.
|
||||
public bool CanManageOrganisation{ get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin }); } }
|
||||
public bool CanManageMembers { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin }); } }
|
||||
public bool CanManageOpportunities { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.OpportunityAdmin }); } }
|
||||
public bool CanManageSchedule { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ScheduleAdmin }); } }
|
||||
public bool CanManageArticles { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin }); } }
|
||||
public bool HasAnyOrganisationRole(IEnumerable<Sax.OrganisationRole> organisationRoles)
|
||||
{
|
||||
return data.HasAnyOrganisationRole(organisationRoles);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
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");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Organisation Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
/// <summary>User Account Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException("UserOrganisation.UserAccountId cannot be changed");
|
||||
data.UserAccountId = value;
|
||||
}
|
||||
}
|
||||
/// <summary>Organisation Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException("UserOrganisation.OrganisationId cannot be changed");
|
||||
data.OrganisationId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Number of Organisation Roles.</summary>
|
||||
public byte OrganisationRoleCount
|
||||
{
|
||||
get { return data.OrganisationRoleCount; }
|
||||
}
|
||||
/// <summary>Organisation Roles - use setter to populate.</summary>
|
||||
public ReadOnlyCollection<Sax.OrganisationRole> GetOrganisationRoles()
|
||||
{
|
||||
return data.GetOrganisationRoles();
|
||||
}
|
||||
/// <summary>Store Organisation Roles.</summary>
|
||||
public IEnumerable<Sax.OrganisationRole> OrganisationRoles
|
||||
{
|
||||
set { data.OrganisationRoles = value; }
|
||||
}
|
||||
public void ClearOrganisationRoles()
|
||||
{
|
||||
data.ClearOrganisationRoles();
|
||||
}
|
||||
public void AddOrganisationRole(Sax.OrganisationRole organisationRole)
|
||||
{
|
||||
data.AddOrganisationRole(organisationRole);
|
||||
}
|
||||
|
||||
/// <summary>Organisation admin comment.</summary>
|
||||
public String AdminComment
|
||||
{
|
||||
get { return StringUtil.EmptyOnNull(data.AdminComment); }
|
||||
set { data.AdminComment = 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,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
|
||||
// User Account properties.
|
||||
public HashSet<SysId> UserAccountIdsIncluded { get; } = new HashSet<SysId>();
|
||||
public SaxUserAccount.StatusCat UserAccountStatusCat { get; set; } = SaxUserAccount.StatusCat.NotDeleted;
|
||||
/// <summary>Exact match on various user account properties including name, email etc.</summary>
|
||||
public String UserFilter { get; set; }
|
||||
/// <summary>Partial match on various user account properties including name, countries etc.</summary>
|
||||
public String UserFilterPartial { get; set; }
|
||||
|
||||
// Organisation properties.
|
||||
public HashSet<SysId> OrganisationIdsIncluded { get; } = new HashSet<SysId>();
|
||||
/// <summary>Exclude organisations with no upcoming events (from 7 days ago).</summary>
|
||||
public bool OrganisationHasScheduledEvents { get; set; }
|
||||
public SaxOrganisation.StatusCat OrganisationStatusCat { get; set; } = SaxOrganisation.StatusCat.NotDeleted;
|
||||
|
||||
// Organisation User properties.
|
||||
/// <summary>Set true to restruct to User Organisations with at least one Organisation Role.</summary>
|
||||
public bool OrganisationMembersOnly { get; set; }
|
||||
public HashSet<Sax.OrganisationRole> OrganisationRoles { get; } = new HashSet<Sax.OrganisationRole>();
|
||||
public HashSet<Sax.OrganisationRole> OrganisationRolesAny { get; } = new HashSet<Sax.OrganisationRole>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
// Table aliases - blank if not specified/linked.
|
||||
public String Alias_UserOrganisation { get; set; }
|
||||
public String Alias_UserAccount { get; set; }
|
||||
public String Alias_Organisation { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserOrganisationList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract list of unique Organisation Ids from the list.
|
||||
/// </summary>
|
||||
public static List<SysId> GetOrganisationIds(this List<SaxUserOrganisation> values)
|
||||
{
|
||||
return new HashSet<SysId>(values.Select(item => item.OrganisationId)).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract list of unique User Account Ids from the list.
|
||||
/// </summary>
|
||||
public static List<SysId> GetUserAccountIds(this List<SaxUserOrganisation> values)
|
||||
{
|
||||
return new HashSet<SysId>(values.Select(item => item.UserAccountId)).ToList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// UserRole.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserRole : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserAccountId,
|
||||
UserRole,
|
||||
UserRole_Desc,
|
||||
// Login - Admin for System user.
|
||||
LastLoginOn,
|
||||
LastLoginAt,
|
||||
LastInvalidLoginOn,
|
||||
LastInvalidLoginAt,
|
||||
InvalidLoginCount,
|
||||
// User.
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// 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 UserAccountId { get; set; }
|
||||
public Sax.UserRole UserRole { get; set; }
|
||||
// Login.
|
||||
public DateTime? LastLoginAt { get; set; } = null;
|
||||
public DateTime? LastInvalidLoginAt { get; set; } = null;
|
||||
public short? InvalidLoginCount { 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 SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserRole UserRole
|
||||
{
|
||||
get { return data.UserRole; }
|
||||
set { CheckChanged((int)data.UserRole, (int)value); data.UserRole = value; }
|
||||
}
|
||||
// Login.
|
||||
public DateTime? LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { CheckChangedNullable(data.LastLoginAt, value); data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime? LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { CheckChangedNullable(data.LastInvalidLoginAt, value); data.LastInvalidLoginAt = value; }
|
||||
}
|
||||
public short? InvalidLoginCount
|
||||
{
|
||||
get { return data.InvalidLoginCount; }
|
||||
set { CheckChangedNullable(data.InvalidLoginCount, value); data.InvalidLoginCount = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
UserRole = data.UserRole;
|
||||
// Login.
|
||||
LastLoginAt = data.LastLoginAt;
|
||||
LastInvalidLoginAt = data.LastInvalidLoginAt;
|
||||
InvalidLoginCount = data.InvalidLoginCount;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserRole { get; set; } = ValidValue.Valid;
|
||||
// Login.
|
||||
public ValidValue LastLogin { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastInvalidLogin { get; set; } = ValidValue.Valid;
|
||||
public ValidValue InvalidLoginCount { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserRole(SysId id, SysId userAccountId, Sax.UserRole userRole) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
UserRole = userRole;
|
||||
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.UserRole, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (UserRole == 0 && (int)UserRole != (int)UserRole)
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Role cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
/// <summary>User Account Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException("UserRole.UserAccountId cannot be changed");
|
||||
data.UserAccountId = value;
|
||||
}
|
||||
}
|
||||
/// <summary>User Role. Can only be populated on construction.</summary>
|
||||
public Sax.UserRole UserRole
|
||||
{
|
||||
get { return data.UserRole; }
|
||||
protected set { data.UserRole = value; }
|
||||
}
|
||||
|
||||
// Login - Admin application for System Admin role.
|
||||
public DateTime? LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime? LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { data.LastInvalidLoginAt = value; }
|
||||
}
|
||||
public short? InvalidLoginCount
|
||||
{
|
||||
get { return data.InvalidLoginCount; }
|
||||
set { data.InvalidLoginCount = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
// Keep logged in - Admin application for System Admin role.
|
||||
public Byte Flag_KeepLoggedIn { get; } = 0x1;
|
||||
public bool KeepLoggedIn
|
||||
{
|
||||
get { return GetFlag(Flag_KeepLoggedIn); }
|
||||
set { SetFlag(Flag_KeepLoggedIn, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<Sax.UserRole> UserRolesIncluded { get; } = new List<Sax.UserRole>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserRoleList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve the first entry in the list matching the specified role.</summary>
|
||||
public static SaxUserRole GetUserRoleByRole(this List<SaxUserRole> values, Sax.UserRole userRole)
|
||||
{
|
||||
return values.Find(item => item.UserRole == userRole);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve the first entry in the list matching the specified role.</summary>
|
||||
public static List<SaxUserRole> GetUserRolesByStatus(this List<SaxUserRole> values, SaStatus status)
|
||||
{
|
||||
return values.FindAll(item => item.Status == status);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
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;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// User Session.
|
||||
//=======================================================================
|
||||
/// <summary>
|
||||
/// User Session - persistent properties from the user's session.
|
||||
/// </summary>
|
||||
public abstract class SaxUserSession : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Session data.
|
||||
// Associated data.
|
||||
// Common.
|
||||
Flags,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public List<SysId> ActivityIndexIds { get; } = new List<SysId>();
|
||||
public String UserSessionData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public List<SysId> ActivityIndexIds
|
||||
{
|
||||
get { return data.ActivityIndexIds.ToList(); }
|
||||
set { CheckChanged(data.ActivityIndexIds, value); data.ActivityIndexIds.Clear(); data.ActivityIndexIds.AddRange(value); }
|
||||
}
|
||||
public String UserSessionData
|
||||
{
|
||||
get { return data.UserSessionData; }
|
||||
set { CheckChanged(data.UserSessionData, value); data.UserSessionData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ActivityIndexIds = data.ActivityIndexIds;
|
||||
UserSessionData = data.UserSessionData;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ActivityIndexIds { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserSessionData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserSession(SysId userAccountId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public static String ActivityIndexDelim { get; } = ",";
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public List<SysId> ActivityIndexIds
|
||||
{
|
||||
get { return data.ActivityIndexIds; }
|
||||
set { data.ActivityIndexIds = value; }
|
||||
}
|
||||
public String UserSessionData
|
||||
{
|
||||
get { return data.UserSessionData; }
|
||||
set { data.UserSessionData = 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.
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserSessionList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
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;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserSport : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Sport.
|
||||
SportId,
|
||||
Sport_Name,
|
||||
About,
|
||||
SportParticipating,
|
||||
SportParticipating_Code,
|
||||
SportParticipating_Desc,
|
||||
SportPreparing,
|
||||
SportPreparing_Code,
|
||||
SportPreparing_Desc,
|
||||
SportOfficiating,
|
||||
SportOfficiating_Code,
|
||||
SportOfficiating_Desc,
|
||||
// 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 UserAccountId { get; set; }
|
||||
public SysId SportId { get; set; }
|
||||
public String About { get; set; } = String.Empty;
|
||||
public String ContactsData { get; set; } = String.Empty;
|
||||
public Sax.SportParticipating Participating { get; set; }
|
||||
public Sax.SportPreparing Preparing { get; set; }
|
||||
public Sax.SportOfficiating Officiating { get; set; }
|
||||
public String UserSportData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
set { CheckChanged(data.SportId, value); data.SportId = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { CheckChanged(data.About, value); data.About = value; }
|
||||
}
|
||||
public String ContactsData
|
||||
{
|
||||
get { return data.ContactsData; }
|
||||
set { CheckChanged(data.ContactsData, value); data.ContactsData = value; }
|
||||
}
|
||||
public Sax.SportParticipating Participating
|
||||
{
|
||||
get { return data.Participating; }
|
||||
set { CheckChanged((int)data.Participating, (int)value); data.Participating = value; }
|
||||
}
|
||||
public Sax.SportPreparing Preparing
|
||||
{
|
||||
get { return data.Preparing; }
|
||||
set { CheckChanged((int)data.Preparing, (int)value); data.Preparing = value; }
|
||||
}
|
||||
public Sax.SportOfficiating Officiating
|
||||
{
|
||||
get { return data.Officiating; }
|
||||
set { CheckChanged((int)data.Officiating, (int)value); data.Officiating = value; }
|
||||
}
|
||||
public String UserSportData
|
||||
{
|
||||
get { return data.UserSportData; }
|
||||
set { CheckChanged(data.UserSportData, value); data.UserSportData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
SportId = data.SportId;
|
||||
About = data.About;
|
||||
ContactsData = data.ContactsData;
|
||||
Participating = data.Participating;
|
||||
Preparing = data.Preparing;
|
||||
Officiating = data.Officiating;
|
||||
UserSportData = data.UserSportData;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue About { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ContactsAbout { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Participating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Preparing { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Officiating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserSportData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserSport(SysId id, SysId userAccountId, SysId sportId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
SportId = sportId;
|
||||
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.UserSport, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (SysId.IsValid(SportId) && SysId.ToInt(SportId) != SysId.ToInt(data.SportId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Sport Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
protected set { data.SportId = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { data.About = value; }
|
||||
}
|
||||
public String ContactsData
|
||||
{
|
||||
get { return data.ContactsData; }
|
||||
set { data.ContactsData = value; }
|
||||
}
|
||||
public Sax.SportParticipating Participating
|
||||
{
|
||||
get { return data.Participating; }
|
||||
set { data.Participating = value; }
|
||||
}
|
||||
public Sax.SportPreparing Preparing
|
||||
{
|
||||
get { return data.Preparing; }
|
||||
set { data.Preparing = value; }
|
||||
}
|
||||
public Sax.SportOfficiating Officiating
|
||||
{
|
||||
get { return data.Officiating; }
|
||||
set { data.Officiating = value; }
|
||||
}
|
||||
public String UserSportData
|
||||
{
|
||||
get { return data.UserSportData; }
|
||||
set { data.UserSportData = 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 List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserSportList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Extract Sport Ids.
|
||||
public static List<SysId> GetSportIds(this IEnumerable<SaxUserSport> values)
|
||||
{
|
||||
List<SysId> sportIds = new List<SysId>();
|
||||
foreach (SaxUserSport userSport in values)
|
||||
sportIds.AddId(userSport.SportId);
|
||||
return sportIds;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
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.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserSportExperience.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserSportExperience : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserSportId,
|
||||
// Sport.
|
||||
Sport_Id,
|
||||
// Period.
|
||||
PeriodFrom,
|
||||
PeriodTo,
|
||||
// Organisation.
|
||||
OrganisationId,
|
||||
OrganisationName,
|
||||
Organisation_Name,
|
||||
// Properties.
|
||||
Summary,
|
||||
Team,
|
||||
League,
|
||||
Speciality,
|
||||
SpecialitiesOther,
|
||||
Awards,
|
||||
// Regions.
|
||||
RegionIdNation,
|
||||
Region_Nation_Name,
|
||||
RegionIdProvince,
|
||||
Region_Province_Name,
|
||||
// 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 UserSportId { get; set; }
|
||||
public DateTime PeriodFrom { get; set; }
|
||||
public DateTime? PeriodTo { get; set; }
|
||||
public SysId OrganisationId { get; set; }
|
||||
public String OrganisationName { get; set; }
|
||||
public String Summary { get; set; }
|
||||
public String Team { get; set; }
|
||||
public String League { get; set; }
|
||||
public String Speciality { get; set; }
|
||||
public HashSet<String> SpecialitiesOther { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
|
||||
public String Awards { get; set; }
|
||||
public SysId RegionIdNation { get; set; }
|
||||
public SysId RegionIdProvince { get; set; }
|
||||
public String UserSportExperienceData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserSportId
|
||||
{
|
||||
get { return data.UserSportId; }
|
||||
set { CheckChanged(data.UserSportId, value); data.UserSportId = value; }
|
||||
}
|
||||
public DateTime PeriodFrom
|
||||
{
|
||||
get { return data.PeriodFrom; }
|
||||
set { CheckChanged(data.PeriodFrom, value); data.PeriodFrom = value; }
|
||||
}
|
||||
public DateTime? PeriodTo
|
||||
{
|
||||
get { return data.PeriodTo; }
|
||||
set { CheckChangedNullable(data.PeriodTo, value); data.PeriodTo = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
public String OrganisationName
|
||||
{
|
||||
get { return data.OrganisationName; }
|
||||
set { CheckChanged(data.OrganisationName, value); data.OrganisationName = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { CheckChanged(data.Summary, value); data.Summary = value; }
|
||||
}
|
||||
public String Team
|
||||
{
|
||||
get { return data.Team; }
|
||||
set { CheckChanged(data.Team, value); data.Team = value; }
|
||||
}
|
||||
public String League
|
||||
{
|
||||
get { return data.League; }
|
||||
set { CheckChanged(data.League, value); data.League = value; }
|
||||
}
|
||||
public String Speciality
|
||||
{
|
||||
get { return data.Speciality; }
|
||||
set { CheckChanged(data.Speciality, value); data.Speciality = value; }
|
||||
}
|
||||
public ReadOnlyCollection<String> GetSpecialitiesOther()
|
||||
{
|
||||
return data.SpecialitiesOther.ToList().AsReadOnly();
|
||||
}
|
||||
public List<String> SpecialitiesOther
|
||||
{
|
||||
set
|
||||
{
|
||||
CheckChanged(data.SpecialitiesOther.ToList(), value);
|
||||
data.SpecialitiesOther.Clear();
|
||||
foreach (String speciality in value)
|
||||
{
|
||||
if (StringUtil.IsEmpty(speciality.Trim())) continue;
|
||||
data.SpecialitiesOther.Add(speciality.Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
public String Awards
|
||||
{
|
||||
get { return data.Awards; }
|
||||
set { CheckChanged(data.Awards, value); data.Awards = value; }
|
||||
}
|
||||
public SysId RegionIdNation
|
||||
{
|
||||
get { return data.RegionIdNation; }
|
||||
set { CheckChanged(data.RegionIdNation, value); data.RegionIdNation = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { CheckChanged(data.RegionIdProvince, value); data.RegionIdProvince = value; }
|
||||
}
|
||||
public String UserSportExperienceData
|
||||
{
|
||||
get { return data.UserSportExperienceData; }
|
||||
set { CheckChanged(data.UserSportExperienceData, value); data.UserSportExperienceData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserSportId = data.UserSportId;
|
||||
PeriodFrom = data.PeriodFrom;
|
||||
PeriodTo = data.PeriodTo;
|
||||
OrganisationId = data.OrganisationId;
|
||||
Summary = data.Summary;
|
||||
Team = data.Team;
|
||||
League = data.League;
|
||||
Speciality = data.Speciality;
|
||||
SpecialitiesOther = data.GetSpecialitiesOther().ToList();
|
||||
Awards = data.Awards;
|
||||
RegionIdNation = data.RegionIdNation;
|
||||
RegionIdProvince = data.RegionIdProvince;
|
||||
UserSportExperienceData = data.UserSportExperienceData;
|
||||
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 UserSportId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PeriodFrom { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PeriodTo { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Summary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Team { get; set; } = ValidValue.Valid;
|
||||
public ValidValue League { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Speciality { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SpecialitiesOther { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Awards { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdNation { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdProvince { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserSportExperienceData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
public static readonly String SpecialitiesOtherDelim = "\n";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserSportExperience(SysId id, SysId userSportId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserSportId = userSportId;
|
||||
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.UserSportExperience, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(UserSportId) && SysId.ToInt(UserSportId) != SysId.ToInt(data.UserSportId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Sport Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserSportId
|
||||
{
|
||||
get { return data.UserSportId; }
|
||||
protected set { data.UserSportId = value; }
|
||||
}
|
||||
public DateTime PeriodFrom
|
||||
{
|
||||
get { return data.PeriodFrom; }
|
||||
set { data.PeriodFrom = value; }
|
||||
}
|
||||
public DateTime? PeriodTo
|
||||
{
|
||||
get { return data.PeriodTo; }
|
||||
set { data.PeriodTo = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { data.OrganisationId = value; }
|
||||
}
|
||||
public String OrganisationName
|
||||
{
|
||||
get { return data.OrganisationName; }
|
||||
set { data.OrganisationName = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { data.Summary = value; }
|
||||
}
|
||||
public String Team
|
||||
{
|
||||
get { return data.Team; }
|
||||
set { data.Team = value; }
|
||||
}
|
||||
public String League
|
||||
{
|
||||
get { return data.League; }
|
||||
set { data.League = value; }
|
||||
}
|
||||
public String Speciality
|
||||
{
|
||||
get { return data.Speciality; }
|
||||
set { data.Speciality = value; }
|
||||
}
|
||||
public ReadOnlyCollection<String> GetSpecialitiesOther()
|
||||
{
|
||||
return data.GetSpecialitiesOther();
|
||||
}
|
||||
public List<String> SpecialitiesOther
|
||||
{
|
||||
set { data.SpecialitiesOther = value; }
|
||||
}
|
||||
public String Awards
|
||||
{
|
||||
get { return data.Awards; }
|
||||
set { data.Awards = value; }
|
||||
}
|
||||
public SysId RegionIdNation
|
||||
{
|
||||
get { return data.RegionIdNation; }
|
||||
set { data.RegionIdNation = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { data.RegionIdProvince = value; }
|
||||
}
|
||||
public String UserSportExperienceData
|
||||
{
|
||||
get { return data.UserSportExperienceData; }
|
||||
set { data.UserSportExperienceData = 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 List<SysId> UserSportIdsIncluded { get; } = new List<SysId>();
|
||||
public DateTime PeriodFrom { get; set; }
|
||||
public DateTime PeriodTo { get; set; }
|
||||
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsNationIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsProvinceIncluded { get; } = new List<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserSportExperienceList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
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.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemProcess : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
Item_Caption,
|
||||
// Process.
|
||||
ProcessType,
|
||||
ProcessType_Desc,
|
||||
// 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.SupportItemProcessType ProcessType { get; set; }
|
||||
public String ProcessData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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.SupportItemProcessType ProcessType
|
||||
{
|
||||
get { return data.ProcessType; }
|
||||
set { CheckChanged((int)data.ProcessType, (int)value); data.ProcessType = value; }
|
||||
}
|
||||
public String ProcessData
|
||||
{
|
||||
get { return data.ProcessData; }
|
||||
set { CheckChanged(data.ProcessData, value); data.ProcessData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
ProcessType = data.ProcessType;
|
||||
ProcessData = data.ProcessData;
|
||||
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 ProcessType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProcessData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemProcess(SysId id, ItemId itemId, Sax.SupportItemProcessType processType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
ProcessType = processType;
|
||||
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.SupportItemProcess, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public Sax.SupportItemProcessType ProcessType
|
||||
{
|
||||
get { return data.ProcessType; }
|
||||
set { data.ProcessType = value; }
|
||||
}
|
||||
public String ProcessData
|
||||
{
|
||||
get { return data.ProcessData; }
|
||||
set { data.ProcessData = 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 HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<ItemId> ItemIdsIncluded { get; } = new HashSet<ItemId>();
|
||||
public HashSet<Sax.SupportItemProcessType> ProcessTypesIncluded { get; } = new HashSet<Sax.SupportItemProcessType>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemProcessList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
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.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemProcessInstance : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item process.
|
||||
ItemProcessId,
|
||||
// Process instance.
|
||||
Started_DateTime,
|
||||
Started_Date,
|
||||
Started_Time,
|
||||
Completed_DateTime,
|
||||
Completed_Date,
|
||||
Completed_Time,
|
||||
// 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 ItemProcessId { get; set; }
|
||||
public DateTime? StartedAt { get; set; }
|
||||
public DateTime? CompletedAt { get; set; }
|
||||
public String ProcessingData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId ItemProcessId
|
||||
{
|
||||
get { return data.ItemProcessId; }
|
||||
set { CheckChanged(data.ItemProcessId, value); data.ItemProcessId = value; }
|
||||
}
|
||||
public DateTime? StartedAt
|
||||
{
|
||||
get { return data.StartedAt; }
|
||||
set { CheckChangedNullable(data.StartedAt, value); data.StartedAt = value; }
|
||||
}
|
||||
public DateTime? CompletedAt
|
||||
{
|
||||
get { return data.CompletedAt; }
|
||||
set { CheckChangedNullable(data.CompletedAt, value); data.CompletedAt = value; }
|
||||
}
|
||||
public String ProcessingData
|
||||
{
|
||||
get { return data.ProcessingData; }
|
||||
set { CheckChanged(data.ProcessingData, value); data.ProcessingData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemProcessId = data.ItemProcessId;
|
||||
StartedAt = data.StartedAt;
|
||||
CompletedAt = data.CompletedAt;
|
||||
ProcessingData = data.ProcessingData;
|
||||
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 ItemProcessId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue StartedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CompletedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProcessingData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemProcessInstance(SysId id, SysId itemProcessId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemProcessId = itemProcessId;
|
||||
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.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(ItemProcessId) && SysId.ToInt(ItemProcessId) != SysId.ToInt(data.ItemProcessId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Process Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId ItemProcessId
|
||||
{
|
||||
get { return data.ItemProcessId; }
|
||||
protected set { data.ItemProcessId = value; }
|
||||
}
|
||||
public DateTime? StartedAt
|
||||
{
|
||||
get { return data.StartedAt; }
|
||||
set { data.StartedAt = value; }
|
||||
}
|
||||
public DateTime? CompletedAt
|
||||
{
|
||||
get { return data.CompletedAt; }
|
||||
set { data.CompletedAt = value; }
|
||||
}
|
||||
public String ProcessingData
|
||||
{
|
||||
get { return data.ProcessingData; }
|
||||
set { data.ProcessingData = 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 HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> ItemProcessIdsIncluded { get; } = new HashSet<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemProcessInstanceList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
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.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemProcessMessage : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item process.
|
||||
ItemProcessInstanceId,
|
||||
// Process message.
|
||||
MessageType,
|
||||
MessageType_Desc,
|
||||
Message,
|
||||
Recorded_DateTime,
|
||||
Recorded_Date,
|
||||
Recorded_Time,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId ItemProcessInstanceId { get; set; }
|
||||
public DateTime? RecordedAt { get; set; }
|
||||
public SaMessageLevel MessageType { get; set; }
|
||||
public String Message { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId ItemProcessInstanceId
|
||||
{
|
||||
get { return data.ItemProcessInstanceId; }
|
||||
set { CheckChanged(data.ItemProcessInstanceId, value); data.ItemProcessInstanceId = value; }
|
||||
}
|
||||
public DateTime? RecordedAt
|
||||
{
|
||||
get { return data.RecordedAt; }
|
||||
set { CheckChangedNullable(data.RecordedAt, value); data.RecordedAt = value; }
|
||||
}
|
||||
public SaMessageLevel MessageType
|
||||
{
|
||||
get { return data.MessageType; }
|
||||
set { CheckChanged((int)data.MessageType, (int)value); data.MessageType = value; }
|
||||
}
|
||||
public String Message
|
||||
{
|
||||
get { return data.Message; }
|
||||
set { CheckChanged(data.Message, value); data.Message = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemProcessInstanceId = data.ItemProcessInstanceId;
|
||||
RecordedAt = data.RecordedAt;
|
||||
MessageType = data.MessageType;
|
||||
Message = data.Message;
|
||||
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 ItemProcessInstanceId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RecordedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue MessageType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Message { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemProcessMessage(SysId id, SysId itemProcessId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemProcessInstanceId = itemProcessId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
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.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");
|
||||
if (SysId.IsValid(ItemProcessInstanceId) && SysId.ToInt(ItemProcessInstanceId) != SysId.ToInt(data.ItemProcessInstanceId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Process Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId ItemProcessInstanceId
|
||||
{
|
||||
get { return data.ItemProcessInstanceId; }
|
||||
protected set { data.ItemProcessInstanceId = value; }
|
||||
}
|
||||
public DateTime? RecordedAt
|
||||
{
|
||||
get { return data.RecordedAt; }
|
||||
set { data.RecordedAt = value; }
|
||||
}
|
||||
public SaMessageLevel MessageType
|
||||
{
|
||||
get { return data.MessageType; }
|
||||
set { data.MessageType = value; }
|
||||
}
|
||||
public String Message
|
||||
{
|
||||
get { return data.Message; }
|
||||
set { data.Message = 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 HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> ItemProcessInstanceIdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SaMessageLevel> MessageTypesIncluded { get; } = new HashSet<SaMessageLevel>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemProcessMessageList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
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;
|
||||
using static Sarand.Net.Standard.Base.Bus.SacsHierarchyItem;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// UserReport.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserReport : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserAccountId,
|
||||
ReportType,
|
||||
ReportType_Desc,
|
||||
Title,
|
||||
Report,
|
||||
RecordedOn,
|
||||
// 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 UserAccountId { get; set; }
|
||||
public Sax.UserReportType ReportType { get; set; }
|
||||
public String Title { get; set; } = String.Empty;
|
||||
public String Report { get; set; } = String.Empty;
|
||||
public DateTime RecordedOn { get; set; }
|
||||
public String ReportData { 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 UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserReportType ReportType
|
||||
{
|
||||
get { return data.ReportType; }
|
||||
set { CheckChanged((short)data.ReportType, (short)value); data.ReportType = value; }
|
||||
}
|
||||
public String Title
|
||||
{
|
||||
get { return data.Title; }
|
||||
set { CheckChanged(data.Title, value); data.Title = value; }
|
||||
}
|
||||
public String Report
|
||||
{
|
||||
get { return data.Report; }
|
||||
set { CheckChanged(data.Report, value); data.Report = value; }
|
||||
}
|
||||
public DateTime RecordedOn
|
||||
{
|
||||
get { return data.RecordedOn; }
|
||||
set { CheckChanged(data.RecordedOn, value); data.RecordedOn = value; }
|
||||
}
|
||||
public String ReportData
|
||||
{
|
||||
get { return data.ReportData; }
|
||||
set { CheckChanged(data.ReportData, value); data.ReportData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ReportType = data.ReportType;
|
||||
Title = data.Title;
|
||||
Report = data.Report;
|
||||
RecordedOn = data.RecordedOn;
|
||||
ReportData = data.ReportData;
|
||||
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 UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ReportType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Title { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Report { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RecordedOn { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ReportData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserReport(SysId id, SysId userAccountId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.UserAccountId = userAccountId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Preparation,
|
||||
SaStatus.InProgress,
|
||||
SaStatus.Cancelled,
|
||||
SaStatus.Closed,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Preparation; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Preparation) return DataValue.TriStateType.Yellow;
|
||||
if (status == SaStatus.InProgress) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Completed) return DataValue.TriStateType.Blue;
|
||||
if (status == SaStatus.Cancelled) 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.UserReport, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} UserAccountId cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserReportType ReportType
|
||||
{
|
||||
get { return data.ReportType; }
|
||||
set { data.ReportType = value; }
|
||||
}
|
||||
public String Title
|
||||
{
|
||||
get { return data.Title; }
|
||||
set { data.Title = value; }
|
||||
}
|
||||
public String Report
|
||||
{
|
||||
get { return data.Report; }
|
||||
set { data.Report = value; }
|
||||
}
|
||||
public DateTime RecordedOn
|
||||
{
|
||||
get { return data.RecordedOn; }
|
||||
set { data.RecordedOn = value; }
|
||||
}
|
||||
public String ReportData
|
||||
{
|
||||
get { return data.ReportData; }
|
||||
set { data.ReportData = 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,
|
||||
Preparation,
|
||||
Open,
|
||||
Completed,
|
||||
Cancelled,
|
||||
Closed,
|
||||
NotDeleted,
|
||||
Deleted,
|
||||
}
|
||||
/// <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> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<Sax.UserReportType> ReportTypesIncluded { get; } = new List<Sax.UserReportType>();
|
||||
/// <summary>Generic filter - caption, report, or other matching value (tbd).</summary>
|
||||
public String UserReportFilter { get; set; }
|
||||
public String TitlePartial { get; set; }
|
||||
public String ReportPartial { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.Open;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserReportList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxUserReport GetUserReportById(this IEnumerable<SaxUserReport> values, SysId userReportId)
|
||||
{
|
||||
if (!SysId.IsValid(userReportId)) return null;
|
||||
foreach (SaxUserReport userReport in values)
|
||||
if (userReport.Id.Equals(userReportId)) return userReport;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user