Add project files.
This commit is contained in:
@@ -0,0 +1,270 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// UserOrganisation.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserOrganisation : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserAccountId,
|
||||
OrganisationId,
|
||||
OrganisationRoleCount,
|
||||
OrganisationRoleCodes,
|
||||
OrganisationRoleDescs,
|
||||
// User.
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Associated data.
|
||||
Organisation_Name,
|
||||
Organisation_Region_Name,
|
||||
Organisation_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 SysId UserAccountId { get; set; }
|
||||
public SysId OrganisationId { get; set; }
|
||||
public List<Sax.OrganisationRole> OrganisationRoles { get; } = new List<Sax.OrganisationRole>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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; }
|
||||
}
|
||||
public List<Sax.OrganisationRole> OrganisationRoles
|
||||
{
|
||||
get { return data.OrganisationRoles; }
|
||||
set { CheckChanged(data.OrganisationRoles, value); data.OrganisationRoles.Clear(); data.OrganisationRoles.AddRange(value); }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
OrganisationId = data.OrganisationId;
|
||||
OrganisationRoles = data.OrganisationRoles;
|
||||
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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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.
|
||||
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.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 OrganisationRoles)
|
||||
organisationRoleCodes.Add(roles.GetCodeForType(organisationRole));
|
||||
return organisationRoleCodes;
|
||||
}
|
||||
public String GetOrganisationRoleCodesData()
|
||||
{
|
||||
return GetOrganisationRoleCodes().Concat(UserOrgnisationRoleDelim);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
String fn = GetType().Name + ".SetData";
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException(fn + " Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException(fn + " User Account Id cannot be changed");
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException(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>Prganisation Roles.</summary>
|
||||
public List<Sax.OrganisationRole> OrganisationRoles
|
||||
{
|
||||
get { return data.OrganisationRoles; }
|
||||
set { data.OrganisationRoles = 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,
|
||||
NotDeleted,
|
||||
ActiveOnly,
|
||||
InctiveOnly,
|
||||
}
|
||||
/// <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> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Set true to restruct to User Organisations with at least one Organisation Role.</summary>
|
||||
public bool OrganisationMembersOnly { get; set; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
public static class SaxUserOrganisationList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user