Add project files.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
static partial class Sax
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public enum Sport
|
||||
{
|
||||
Baseball,
|
||||
Basketball,
|
||||
Dodgeball,
|
||||
RugbyUnion,
|
||||
RugbyLeague,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.App
|
||||
{
|
||||
//=======================================================================
|
||||
static partial class Sax
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Application version.
|
||||
//-------------------------------------------------------------------
|
||||
public static class Version
|
||||
{
|
||||
private static String version { get; } = "1.0.3.1";
|
||||
// Retrieve version.
|
||||
public static String GetFullVersion () { return version; }
|
||||
public static String GetAppVersion ()
|
||||
{
|
||||
if (!SaxSystem.DebugMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Live instance version is only first 3 elements.
|
||||
String[] versionElements = version.Split('.');
|
||||
return String.Join(".", versionElements.Take(3));
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Warn("Sax.VersionData.ToString " + ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Version history.
|
||||
// 1.0.3 11-May-2021 Admin Organisation Members
|
||||
// - Admin data filters & styling, organisation members.
|
||||
// - Online region and sport popups sorted and OK working.
|
||||
// 1.0.2 6-May-2021 Online bug fix.
|
||||
// - Resolve Online region & sport popup issue.
|
||||
// 1.0.1 4-May-2021 Demo test #2.
|
||||
// - Admin Form styling. Fixed: Create User, Request Password.
|
||||
// - Online Security forms, Profile - Contact.
|
||||
// 1.0.0 3-May-2021 Initial demo test version.
|
||||
// - Admin/Online security.
|
||||
// - Admin Users, Organisations, Regions, Sports
|
||||
// - Online Journalist Articles (header).
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public static partial class Sax
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Application configuration defaults.
|
||||
public static class Config
|
||||
{
|
||||
public static String Context_Defaults { get; } = "Defaults";
|
||||
public static class Security
|
||||
{
|
||||
public static class Password
|
||||
{
|
||||
}
|
||||
public static class Activation
|
||||
{
|
||||
public static int EmailLinkExpiresMins_Default { get; } = 60;
|
||||
public static int EmailLinkExpiresMins_Min { get; } = 30;
|
||||
public static int EmailLinkExpiresMins_Max { get; } = 60 * 24;
|
||||
}
|
||||
public static class SignIn
|
||||
{
|
||||
public static class PasswordRequest
|
||||
{
|
||||
public static int EmailLinkExpiresMins_Default { get; } = 60;
|
||||
public static int EmailLinkExpiresMins_Min { get; } = 30;
|
||||
public static int EmailLinkExpiresMins_Max { get; } = 60 * 24;
|
||||
}
|
||||
public static class KeepLoggedIn
|
||||
{
|
||||
public static bool Allowed_Default { get; } = true;
|
||||
public static int CookieExpiresDays_Default { get; } = 10;
|
||||
public static int CookieExpiresDays_Min { get; } = 1;
|
||||
public static int CookieExpiresDays_Max { get; } = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Online
|
||||
{
|
||||
public static class Session
|
||||
{
|
||||
public static class Cookie
|
||||
{
|
||||
/// <summary>Default cookie name: '.AspNetCore.Session'</summary>
|
||||
public static String Name { get; } = "Saxonite.Online.Session";
|
||||
public static bool HttpOnly { get; } = true;
|
||||
public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(60);
|
||||
public static long RememberMeTimeoutMilis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
public static class DataCache
|
||||
{
|
||||
public static class RefreshIntervalSecs
|
||||
{
|
||||
public static int Initial { get; } = SacsSystem.DebugMode ? 2 : 5;
|
||||
public static int Periodic{ get; } = SacsSystem.DebugMode ? 60 : 1800;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Admin
|
||||
{
|
||||
public static class Session
|
||||
{
|
||||
public static class Cookie
|
||||
{
|
||||
/// <summary>Default cookie name: '.AspNetCore.Session'</summary>
|
||||
public static String Name { get; } = "Saxonite.Admin.Session";
|
||||
public static bool HttpOnly { get; } = true;
|
||||
public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(15);
|
||||
public static long KeepLoggedInTimeoutMillis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Code types (static lists).
|
||||
/// <para>Defined by the underlying system and available for use throughout any application.</para>
|
||||
/// <para>Only maintainable by updates to the software, ie. not held on the database.</para>
|
||||
/// </summary>
|
||||
public enum CodeType
|
||||
{
|
||||
YesNo,
|
||||
RegionType,
|
||||
UserRole,
|
||||
Title,
|
||||
OrganisationType,
|
||||
OrganisationCategory,
|
||||
OrganisationRole,
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum Application
|
||||
{
|
||||
Admin,
|
||||
Online,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum InstanceType
|
||||
{
|
||||
Production,
|
||||
UAT,
|
||||
QC,
|
||||
Dev
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum DataItemType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the numeric values - tied to database. */
|
||||
// Reference data.
|
||||
Region = 10,
|
||||
Sport = 11,
|
||||
// Accounts.
|
||||
UserAccount = 100,
|
||||
UserRole = 101,
|
||||
UserOrganisation = 102,
|
||||
Organisation = 120,
|
||||
// Activty data.
|
||||
ScheduledEvent = 200,
|
||||
JournalistArticle = 210,
|
||||
OrganisationOpportunity = 220,
|
||||
// Item link components.
|
||||
ItemSport = 400,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum RegionType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the numeric values - tied to database. */
|
||||
Continent = 10,
|
||||
SubContinent = 20,
|
||||
/// <summary>Country - self-governing political entity, eg. Country, State (not US state)</summary>
|
||||
Country = 30,
|
||||
/// <summary>Nation, eg. Home Nation.</summary>
|
||||
Nation = 40,
|
||||
/// <summary>STate - major subdivision of country, eg. US state.</summary>
|
||||
State = 50,
|
||||
/// <summary>Province - eg. GB County.</summary>
|
||||
Province = 60
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>User roles</summary>
|
||||
public enum UserRole
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values - tied to database. */
|
||||
Journalist,
|
||||
SystemAdmin,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Yes or No option.</summary>
|
||||
public enum YesNo
|
||||
{
|
||||
Unknown = 0,
|
||||
Yes,
|
||||
No
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Titles - for Contact details.</summary>
|
||||
public enum Title
|
||||
{
|
||||
Unknown = 0,
|
||||
Mr,
|
||||
Mrs,
|
||||
Miss,
|
||||
Mx,
|
||||
Dr,
|
||||
Sir,
|
||||
Madam,
|
||||
Lord,
|
||||
Lady
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Organisation Types.</summary>
|
||||
public enum OrganisationType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the names/codes - tied to database. */
|
||||
Commercial,
|
||||
SocialEnterprise,
|
||||
CommunityGroup,
|
||||
Charity,
|
||||
PublicSector,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Organisation Category.</summary>
|
||||
public enum OrganisationCategory
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the names/codes - tied to database. */
|
||||
Association,
|
||||
Club,
|
||||
Education,
|
||||
Syndicate,
|
||||
/// <summary>Commercial partner</summary>
|
||||
Partner,
|
||||
/// <summary>Other</summary>
|
||||
Other,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Organisation roles</summary>
|
||||
public enum OrganisationRole
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values - tied to database. */
|
||||
Member,
|
||||
MemberAdmin,
|
||||
ScheduleAdmin,
|
||||
OpportunityAdmin,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Net.Standard.Base.Consoles;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxApplication_Base
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxApplication_Base()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public abstract SaxSystem System { get; }
|
||||
public abstract SaxConsoleHelper ConsoleHelper { get; }
|
||||
public abstract ISacsDatabase GetCoreDatabase(SaxSessionContext sessionContext);
|
||||
public abstract IDatabaseInfo CreateCoreDbInfo(SaxSessionContext sessionContext);
|
||||
// Application instance.
|
||||
public abstract Sax.InstanceType InstanceType { get; }
|
||||
public bool IsLiveHost() { return InstanceType == Sax.InstanceType.Production; }
|
||||
public bool IsTestHost() { return InstanceType != Sax.InstanceType.Production; }
|
||||
public bool IsDevHost() { return InstanceType == Sax.InstanceType.Dev; }
|
||||
public abstract String EnvironmentName { get; }
|
||||
// Email configuration.
|
||||
public abstract SaxEmailConfig EmailConfig { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,598 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Mon 10-May-2021 16:59:32
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Base.App
|
||||
{
|
||||
public class SaxDbDfn
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Table identifiers.
|
||||
public enum TableIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
ItemSport,
|
||||
JournalistArticle,
|
||||
Organisation,
|
||||
OrganisationOpportunity,
|
||||
Region,
|
||||
Sport,
|
||||
UserAccount,
|
||||
UserOrganisation,
|
||||
UserRole,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Column identifiers.
|
||||
public enum ColumnIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
ItemSport_Id,
|
||||
ItemSport_ItemType,
|
||||
ItemSport_ItemId,
|
||||
ItemSport_SportId,
|
||||
ItemSport_ItemSportData,
|
||||
ItemSport_Notes,
|
||||
ItemSport_Flags,
|
||||
ItemSport_Status,
|
||||
ItemSport_CreateOn,
|
||||
ItemSport_CreateBy,
|
||||
ItemSport_CreateHost,
|
||||
ItemSport_UpdateOn,
|
||||
ItemSport_UpdateBy,
|
||||
ItemSport_UpdateHost,
|
||||
JournalistArticle_Id,
|
||||
JournalistArticle_UserAccountIdJournalist,
|
||||
JournalistArticle_RegionIdPrimary,
|
||||
JournalistArticle_SportIdPrimary,
|
||||
JournalistArticle_Headline,
|
||||
JournalistArticle_Summary,
|
||||
JournalistArticle_BodyData,
|
||||
JournalistArticle_PublishedAt,
|
||||
JournalistArticle_Notes,
|
||||
JournalistArticle_Flags,
|
||||
JournalistArticle_Status,
|
||||
JournalistArticle_CreateOn,
|
||||
JournalistArticle_CreateBy,
|
||||
JournalistArticle_CreateHost,
|
||||
JournalistArticle_UpdateOn,
|
||||
JournalistArticle_UpdateBy,
|
||||
JournalistArticle_UpdateHost,
|
||||
Organisation_Id,
|
||||
Organisation_Name,
|
||||
Organisation_OrganisationType,
|
||||
Organisation_OrganisationCategory,
|
||||
Organisation_RegionIdPrimary,
|
||||
Organisation_SportIdPrimary,
|
||||
Organisation_CountryIso2Code,
|
||||
Organisation_PhoneMain,
|
||||
Organisation_PhoneAlt,
|
||||
Organisation_Notes,
|
||||
Organisation_Flags,
|
||||
Organisation_Status,
|
||||
Organisation_CreateOn,
|
||||
Organisation_CreateBy,
|
||||
Organisation_CreateHost,
|
||||
Organisation_UpdateOn,
|
||||
Organisation_UpdateBy,
|
||||
Organisation_UpdateHost,
|
||||
OrganisationOpportunity_Id,
|
||||
OrganisationOpportunity_OrganisationId,
|
||||
OrganisationOpportunity_RegionIdPrimary,
|
||||
OrganisationOpportunity_SportIdPrimary,
|
||||
OrganisationOpportunity_Position,
|
||||
OrganisationOpportunity_Outline,
|
||||
OrganisationOpportunity_OpportunityData,
|
||||
OrganisationOpportunity_PublishedAt,
|
||||
OrganisationOpportunity_ExpiresAt,
|
||||
OrganisationOpportunity_Notes,
|
||||
OrganisationOpportunity_Flags,
|
||||
OrganisationOpportunity_Status,
|
||||
OrganisationOpportunity_CreateOn,
|
||||
OrganisationOpportunity_CreateBy,
|
||||
OrganisationOpportunity_CreateHost,
|
||||
OrganisationOpportunity_UpdateOn,
|
||||
OrganisationOpportunity_UpdateBy,
|
||||
OrganisationOpportunity_UpdateHost,
|
||||
Region_Id,
|
||||
Region_RegionType,
|
||||
Region_CountryIso2Code,
|
||||
Region_Name,
|
||||
Region_Latitude,
|
||||
Region_Longitude,
|
||||
Region_RegionIdParent,
|
||||
Region_Notes,
|
||||
Region_Flags,
|
||||
Region_Status,
|
||||
Region_CreateOn,
|
||||
Region_CreateBy,
|
||||
Region_CreateHost,
|
||||
Region_UpdateOn,
|
||||
Region_UpdateBy,
|
||||
Region_UpdateHost,
|
||||
Sport_Id,
|
||||
Sport_Name,
|
||||
Sport_Notes,
|
||||
Sport_Flags,
|
||||
Sport_Status,
|
||||
Sport_CreateOn,
|
||||
Sport_CreateBy,
|
||||
Sport_CreateHost,
|
||||
Sport_UpdateOn,
|
||||
Sport_UpdateBy,
|
||||
Sport_UpdateHost,
|
||||
UserAccount_Id,
|
||||
UserAccount_EmailAddress,
|
||||
UserAccount_Title,
|
||||
UserAccount_FirstName,
|
||||
UserAccount_Initials,
|
||||
UserAccount_LastName,
|
||||
UserAccount_PhoneMain,
|
||||
UserAccount_PhoneMobile,
|
||||
UserAccount_PhoneAlt,
|
||||
UserAccount_DateOfBirth,
|
||||
UserAccount_PasswordToken,
|
||||
UserAccount_PasswordHashed,
|
||||
UserAccount_PasswordHistory,
|
||||
UserAccount_PasswordChangedAt,
|
||||
UserAccount_LastLoginAt,
|
||||
UserAccount_LastInvalidLoginAt,
|
||||
UserAccount_InvalidLoginCount,
|
||||
UserAccount_Notes,
|
||||
UserAccount_Flags,
|
||||
UserAccount_Status,
|
||||
UserAccount_CreateOn,
|
||||
UserAccount_CreateBy,
|
||||
UserAccount_CreateHost,
|
||||
UserAccount_UpdateOn,
|
||||
UserAccount_UpdateBy,
|
||||
UserAccount_UpdateHost,
|
||||
UserOrganisation_Id,
|
||||
UserOrganisation_UserAccountId,
|
||||
UserOrganisation_OrganisationId,
|
||||
UserOrganisation_OrganisationRoleCodes,
|
||||
UserOrganisation_OrganisationRoleCount,
|
||||
UserOrganisation_Notes,
|
||||
UserOrganisation_Flags,
|
||||
UserOrganisation_Status,
|
||||
UserOrganisation_CreateOn,
|
||||
UserOrganisation_CreateBy,
|
||||
UserOrganisation_CreateHost,
|
||||
UserOrganisation_UpdateOn,
|
||||
UserOrganisation_UpdateBy,
|
||||
UserOrganisation_UpdateHost,
|
||||
UserRole_Id,
|
||||
UserRole_UserAccountId,
|
||||
UserRole_UserRoleCode,
|
||||
UserRole_Notes,
|
||||
UserRole_Flags,
|
||||
UserRole_Status,
|
||||
UserRole_CreateOn,
|
||||
UserRole_CreateBy,
|
||||
UserRole_CreateHost,
|
||||
UserRole_UpdateOn,
|
||||
UserRole_UpdateBy,
|
||||
UserRole_UpdateHost,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 9;
|
||||
private static readonly int columnCount = 146;
|
||||
private static ulong maxTextLen = 0;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve Table details (eg. name: 'Company').
|
||||
public static int GetTableCount ()
|
||||
{
|
||||
return tableCount;
|
||||
}
|
||||
public static String GetTableName (TableIdx table, bool delimitReservedWords = true)
|
||||
{
|
||||
int tableIdx = (int)table - 1;
|
||||
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
|
||||
String tableName = tables[(int)tableIdx];
|
||||
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
|
||||
return tableName;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Identify the table that corresponds with the specified column.
|
||||
public static TableIdx GetTableForColumn (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return TableIdx.Unknown;
|
||||
return columns[columnIdx].TableIdx;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve the specified Column's name (Qualified include table name: '(<Table>.Column>)').
|
||||
public static String GetColumnName (ColumnIdx column, bool delimitReservedWords = true)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return String.Empty;
|
||||
String columnName = columns[columnIdx].Name;
|
||||
if (delimitReservedWords) columnName = DelimitReservedWord(columnName);
|
||||
return columnName;
|
||||
}
|
||||
public static String GetColumnNameQual (ColumnIdx column, String tableAlias = "", bool braces = false)
|
||||
{
|
||||
String columnName = GetColumnName(column);
|
||||
if (!String.IsNullOrEmpty(columnName))
|
||||
{
|
||||
String tableName = StringUtil.EmptyOnNull(tableAlias);
|
||||
if (tableName.IsEmpty()) tableName = GetTableName(GetTableForColumn(column));
|
||||
columnName = tableName + (tableName.Length > 0 ? "." : "") + columnName;
|
||||
if (braces)
|
||||
columnName = "(" + columnName + ")";
|
||||
}
|
||||
return columnName;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Reserved words.
|
||||
private static DbReservedWordDelim reservedWordDelim = DbReservedWordDelim.SquareBrackets;
|
||||
public static void SetReservedWordDelim (DbReservedWordDelim reservedWordDelim)
|
||||
{
|
||||
SaxDbDfn.reservedWordDelim = reservedWordDelim;
|
||||
}
|
||||
public static bool IsReservedWord (String word)
|
||||
{
|
||||
if (String.IsNullOrEmpty(word)) return false;
|
||||
if (reservedWords.Contains(word, StringComparer.OrdinalIgnoreCase)) return true;
|
||||
return false;
|
||||
}
|
||||
public static String DelimitReservedWord (String word)
|
||||
{
|
||||
if (!IsReservedWord(word)) return word;
|
||||
switch (reservedWordDelim)
|
||||
{
|
||||
case DbReservedWordDelim.None:
|
||||
break;
|
||||
case DbReservedWordDelim.DoubleQuotes:
|
||||
word = "\"" + word + "\"";
|
||||
break;
|
||||
case DbReservedWordDelim.SquareBrackets:
|
||||
default:
|
||||
word = "[" + word + "]";
|
||||
break;
|
||||
}
|
||||
return word;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve information about the specified Column.
|
||||
public static DbColumnDataType GetColDataType (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return DbColumnDataType.Unknown;
|
||||
return columns[columnIdx].DataType;
|
||||
}
|
||||
public static short GetColNativeDataType (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
|
||||
return columns[columnIdx].NativeDataType;
|
||||
}
|
||||
public static void SetMaxTextLen (ulong maxTextLen)
|
||||
{
|
||||
SaxDbDfn.maxTextLen = maxTextLen;
|
||||
}
|
||||
public static bool IsColFmtText (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
return (columns[columnIdx].DataType == DbColumnDataType.VarChar);
|
||||
}
|
||||
public static ulong GetColTextLen (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
|
||||
if (columns[columnIdx].DataType == DbColumnDataType.VarChar)
|
||||
{
|
||||
ulong textLen = columns[columnIdx].DataLen;
|
||||
if (maxTextLen > 0 && textLen > maxTextLen) textLen = maxTextLen;
|
||||
return textLen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static bool IsColFmtBool (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
return (columns[columnIdx].DataType == DbColumnDataType.Bit);
|
||||
}
|
||||
public static bool IsColFmtNumeric (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
switch (columns[columnIdx].DataType)
|
||||
{
|
||||
case DbColumnDataType.TinyInt:
|
||||
case DbColumnDataType.SmallInt:
|
||||
case DbColumnDataType.Int:
|
||||
case DbColumnDataType.BigInt:
|
||||
case DbColumnDataType.Single:
|
||||
case DbColumnDataType.Double:
|
||||
case DbColumnDataType.Decimal:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Table definitions.
|
||||
private static readonly String[] tables =
|
||||
{
|
||||
"ItemSport",
|
||||
"JournalistArticle",
|
||||
"Organisation",
|
||||
"OrganisationOpportunity",
|
||||
"Region",
|
||||
"Sport",
|
||||
"UserAccount",
|
||||
"UserOrganisation",
|
||||
"UserRole",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Table column definitions.
|
||||
private class ColumnDfn
|
||||
{
|
||||
internal TableIdx TableIdx { get; set; }
|
||||
internal String Name { get; set; }
|
||||
internal DbColumnDataType DataType { get; set; }
|
||||
internal short NativeDataType { get; set; }
|
||||
internal bool IsIdentity { get; set; }
|
||||
internal ulong DataLen { get; set; }
|
||||
internal ColumnDfn (int tableIdx, String name, int dataType, short nativeDataType, bool isIdentity, ulong dataLen)
|
||||
{
|
||||
this.TableIdx = (TableIdx)tableIdx;
|
||||
this.Name = name;
|
||||
this.DataType = (DbColumnDataType)dataType;
|
||||
this.NativeDataType = nativeDataType;
|
||||
this.IsIdentity = isIdentity;
|
||||
this.DataLen = dataLen;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private static readonly ColumnDfn[] columns =
|
||||
{
|
||||
new ColumnDfn(1,"Id",4,4,true,10),
|
||||
new ColumnDfn(1,"ItemType",3,5,false,5),
|
||||
new ColumnDfn(1,"ItemId",4,4,false,10),
|
||||
new ColumnDfn(1,"SportId",4,4,false,10),
|
||||
new ColumnDfn(1,"ItemSportData",0,-9,false,0),
|
||||
new ColumnDfn(1,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(1,"Flags",3,5,false,5),
|
||||
new ColumnDfn(1,"Status",0,12,false,3),
|
||||
new ColumnDfn(1,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(1,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(1,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(1,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(1,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(1,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(2,"Id",4,4,true,10),
|
||||
new ColumnDfn(2,"UserAccountIdJournalist",4,4,false,10),
|
||||
new ColumnDfn(2,"RegionIdPrimary",4,4,false,10),
|
||||
new ColumnDfn(2,"SportIdPrimary",4,4,false,10),
|
||||
new ColumnDfn(2,"Headline",0,-9,false,200),
|
||||
new ColumnDfn(2,"Summary",0,-9,false,2000),
|
||||
new ColumnDfn(2,"BodyData",0,-9,false,0),
|
||||
new ColumnDfn(2,"PublishedAt",9,93,false,16),
|
||||
new ColumnDfn(2,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(2,"Flags",3,5,false,5),
|
||||
new ColumnDfn(2,"Status",0,12,false,3),
|
||||
new ColumnDfn(2,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(2,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(2,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(2,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(2,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(2,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(3,"Id",4,4,true,10),
|
||||
new ColumnDfn(3,"Name",0,-9,false,100),
|
||||
new ColumnDfn(3,"OrganisationType",0,12,false,3),
|
||||
new ColumnDfn(3,"OrganisationCategory",0,12,false,3),
|
||||
new ColumnDfn(3,"RegionIdPrimary",4,4,false,10),
|
||||
new ColumnDfn(3,"SportIdPrimary",4,4,false,10),
|
||||
new ColumnDfn(3,"CountryIso2Code",0,12,false,2),
|
||||
new ColumnDfn(3,"PhoneMain",0,-9,false,50),
|
||||
new ColumnDfn(3,"PhoneAlt",0,-9,false,50),
|
||||
new ColumnDfn(3,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(3,"Flags",3,5,false,5),
|
||||
new ColumnDfn(3,"Status",0,12,false,3),
|
||||
new ColumnDfn(3,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(3,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(3,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(3,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(3,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(3,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(4,"Id",4,4,true,10),
|
||||
new ColumnDfn(4,"OrganisationId",4,4,false,10),
|
||||
new ColumnDfn(4,"RegionIdPrimary",4,4,false,10),
|
||||
new ColumnDfn(4,"SportIdPrimary",4,4,false,10),
|
||||
new ColumnDfn(4,"Position",0,-9,false,200),
|
||||
new ColumnDfn(4,"Outline",0,-9,false,2000),
|
||||
new ColumnDfn(4,"OpportunityData",0,-9,false,0),
|
||||
new ColumnDfn(4,"PublishedAt",9,93,false,16),
|
||||
new ColumnDfn(4,"ExpiresAt",9,93,false,16),
|
||||
new ColumnDfn(4,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(4,"Flags",3,5,false,5),
|
||||
new ColumnDfn(4,"Status",0,12,false,3),
|
||||
new ColumnDfn(4,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(4,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(4,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(4,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(4,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(4,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(5,"Id",4,4,true,10),
|
||||
new ColumnDfn(5,"RegionType",3,5,false,5),
|
||||
new ColumnDfn(5,"CountryIso2Code",0,12,false,2),
|
||||
new ColumnDfn(5,"Name",0,-9,false,100),
|
||||
new ColumnDfn(5,"Latitude",8,3,false,9),
|
||||
new ColumnDfn(5,"Longitude",8,3,false,9),
|
||||
new ColumnDfn(5,"RegionIdParent",4,4,false,10),
|
||||
new ColumnDfn(5,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(5,"Flags",3,5,false,5),
|
||||
new ColumnDfn(5,"Status",0,12,false,3),
|
||||
new ColumnDfn(5,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(5,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(5,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(5,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(5,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(5,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(6,"Id",4,4,true,10),
|
||||
new ColumnDfn(6,"Name",0,-9,false,100),
|
||||
new ColumnDfn(6,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(6,"Flags",3,5,false,5),
|
||||
new ColumnDfn(6,"Status",0,12,false,3),
|
||||
new ColumnDfn(6,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(6,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(6,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(6,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(6,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(6,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(7,"Id",4,4,true,10),
|
||||
new ColumnDfn(7,"EmailAddress",0,-9,false,200),
|
||||
new ColumnDfn(7,"Title",0,-9,false,20),
|
||||
new ColumnDfn(7,"FirstName",0,-9,false,100),
|
||||
new ColumnDfn(7,"Initials",0,-9,false,10),
|
||||
new ColumnDfn(7,"LastName",0,-9,false,100),
|
||||
new ColumnDfn(7,"PhoneMain",0,-9,false,50),
|
||||
new ColumnDfn(7,"PhoneMobile",0,-9,false,50),
|
||||
new ColumnDfn(7,"PhoneAlt",0,-9,false,50),
|
||||
new ColumnDfn(7,"DateOfBirth",9,93,false,16),
|
||||
new ColumnDfn(7,"PasswordToken",0,12,false,32),
|
||||
new ColumnDfn(7,"PasswordHashed",0,-9,false,100),
|
||||
new ColumnDfn(7,"PasswordHistory",0,-9,false,0),
|
||||
new ColumnDfn(7,"PasswordChangedAt",9,93,false,16),
|
||||
new ColumnDfn(7,"LastLoginAt",9,93,false,16),
|
||||
new ColumnDfn(7,"LastInvalidLoginAt",9,93,false,16),
|
||||
new ColumnDfn(7,"InvalidLoginCount",3,5,false,5),
|
||||
new ColumnDfn(7,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(7,"Flags",3,5,false,5),
|
||||
new ColumnDfn(7,"Status",0,12,false,3),
|
||||
new ColumnDfn(7,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(7,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(7,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(7,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(7,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(7,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(8,"Id",5,-5,true,19),
|
||||
new ColumnDfn(8,"UserAccountId",4,4,false,10),
|
||||
new ColumnDfn(8,"OrganisationId",4,4,false,10),
|
||||
new ColumnDfn(8,"OrganisationRoleCodes",0,12,false,256),
|
||||
new ColumnDfn(8,"OrganisationRoleCount",2,-6,false,3),
|
||||
new ColumnDfn(8,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(8,"Flags",3,5,false,5),
|
||||
new ColumnDfn(8,"Status",0,12,false,3),
|
||||
new ColumnDfn(8,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(8,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(8,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(8,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(8,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(8,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(9,"Id",4,4,true,10),
|
||||
new ColumnDfn(9,"UserAccountId",4,4,false,10),
|
||||
new ColumnDfn(9,"UserRoleCode",0,12,false,16),
|
||||
new ColumnDfn(9,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(9,"Flags",3,5,false,5),
|
||||
new ColumnDfn(9,"Status",0,12,false,3),
|
||||
new ColumnDfn(9,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(9,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(9,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(9,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(9,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(9,"UpdateHost",0,12,false,100),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Reserved words.
|
||||
private static readonly List<String> reservedWords = new List<String>()
|
||||
{
|
||||
"ADD",
|
||||
"ALL",
|
||||
"ALTER",
|
||||
"AND",
|
||||
"ANY",
|
||||
"AS",
|
||||
"ASC",
|
||||
"AVG",
|
||||
"BEGIN",
|
||||
"BETWEEN",
|
||||
"BY",
|
||||
"CASE",
|
||||
"CAST",
|
||||
"COLUMN",
|
||||
"COMMIT",
|
||||
"CONSTRAINT",
|
||||
"CONVERT",
|
||||
"COUNT",
|
||||
"CREATE",
|
||||
"CURRENCY",
|
||||
"DEFAULT",
|
||||
"DELETE",
|
||||
"DESC",
|
||||
"DISTINCT",
|
||||
"DROP",
|
||||
"ELSE",
|
||||
"END",
|
||||
"EXECUTE",
|
||||
"EXISTS",
|
||||
"FALSE",
|
||||
"FROM",
|
||||
"GRANT",
|
||||
"GROUP",
|
||||
"HAVING",
|
||||
"IN",
|
||||
"INDEX",
|
||||
"INNER",
|
||||
"INSERT",
|
||||
"INTO",
|
||||
"IS",
|
||||
"JOIN",
|
||||
"KEY",
|
||||
"LEFT",
|
||||
"LIKE",
|
||||
"MAX",
|
||||
"MIN",
|
||||
"NOT",
|
||||
"NULL",
|
||||
"ON",
|
||||
"OR",
|
||||
"ORDER",
|
||||
"OUTER",
|
||||
"OUTPUT",
|
||||
"PRIMARY",
|
||||
"PROCEDURE",
|
||||
"REVOKE",
|
||||
"ROLLBACK",
|
||||
"ROWCOUNT",
|
||||
"SELECT",
|
||||
"SET",
|
||||
"SQL",
|
||||
"SUM",
|
||||
"TABLE",
|
||||
"THEN",
|
||||
"TRANSACTION",
|
||||
"TRUE",
|
||||
"UNION",
|
||||
"UNIQUE",
|
||||
"UPDATE",
|
||||
"USER",
|
||||
"VALUES",
|
||||
"VIEW",
|
||||
"WHEN",
|
||||
"WHERE",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Saxonite.Net.Standard.Base.Consoles;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public static class SaxGlobals
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// System.
|
||||
public static SaxSystem System { get; set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Application.
|
||||
public static SaxApplication_Base App { get; set; }
|
||||
public static SaxConsoleHelper ConsoleHelper { get { return App.ConsoleHelper; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Net.Standard.Base.Mgr;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Saxonite.Net.Standard.Base.Consoles;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxInternals : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private class Managers
|
||||
{
|
||||
public SaxReferenceMgr referenceMgr = null;
|
||||
public SaxAccountMgr accountMgr = null;
|
||||
public SaxActivityMgr activityMgr = null;
|
||||
public SaxItemDataMgr itemDataMgr = null;
|
||||
}
|
||||
private readonly Managers mgr = new Managers();
|
||||
private class Consoles
|
||||
{
|
||||
public SaxEmailConsole emailConsole;
|
||||
}
|
||||
private readonly Consoles con = new Consoles();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaxInternals(SaxSessionContext sessionContext)
|
||||
{
|
||||
if (sessionContext == null)
|
||||
throw new NotSupportedException("Unable to create Internals with invalid session context");
|
||||
System = SaxGlobals.System;
|
||||
SessionContext = sessionContext;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (mgr.referenceMgr != null) mgr.referenceMgr.Dispose(); mgr.referenceMgr = null;
|
||||
if (mgr.accountMgr != null) mgr.accountMgr.Dispose(); mgr.accountMgr = null;
|
||||
if (mgr.activityMgr != null) mgr.activityMgr.Dispose(); mgr.activityMgr = null;
|
||||
if (mgr.itemDataMgr != null) mgr.itemDataMgr.Dispose(); mgr.itemDataMgr = null;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public SaxSystem System { get; }
|
||||
public SaxSessionContext SessionContext { get; }
|
||||
public ISacsDatabase CoreDatabase { get { return SaxGlobals.App.GetCoreDatabase(SessionContext); } }
|
||||
public IDatabaseInfo CreateCoreDbInfo()
|
||||
{
|
||||
return SaxGlobals.App.CreateCoreDbInfo(SessionContext);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// System codes.
|
||||
private readonly Dictionary<Sax.CodeType, List<TypeCodeDesc>> codeTypes = new Dictionary<Sax.CodeType, List<TypeCodeDesc>>();
|
||||
public List<TypeCodeDesc> RegionTypes { get { return GetCodesOfType(Sax.CodeType.RegionType); } }
|
||||
public List<TypeCodeDesc> UserRoles { get { return GetCodesOfType(Sax.CodeType.UserRole); } }
|
||||
public List<TypeCodeDesc> OrganisationTypes { get { return GetCodesOfType(Sax.CodeType.OrganisationType); } }
|
||||
public List<TypeCodeDesc> OrganisationCategories { get { return GetCodesOfType(Sax.CodeType.OrganisationCategory); } }
|
||||
public List<TypeCodeDesc> OrganisationRoles { get { return GetCodesOfType(Sax.CodeType.OrganisationRole); } }
|
||||
public List<TypeCodeDesc> GetCodesOfType(Sax.CodeType codeType)
|
||||
{
|
||||
if (!codeTypes.ContainsKey(codeType))
|
||||
codeTypes.Add(codeType, SaxSystem.GetCodesOfType(codeType));
|
||||
return new List<TypeCodeDesc>(codeTypes[codeType]);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Consoles.
|
||||
public SaxDataCacheConsole DataCacheConsole { get { return SaxGlobals.ConsoleHelper.GetDataCacheConsole(SessionContext); } }
|
||||
public SaxConsoleHelper ConsoleHelper { get { return SaxGlobals.App.ConsoleHelper; } }
|
||||
public SaxEmailConsole EmailConsole { get { if (con.emailConsole == null) con.emailConsole = ConsoleHelper.CreateEmailConsole(SessionContext); return con.emailConsole; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Business components.
|
||||
public SaxReferenceMgr ReferenceMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.referenceMgr == null)
|
||||
mgr.referenceMgr = System.CreateReferenceMgr(SessionContext);
|
||||
return mgr.referenceMgr;
|
||||
}
|
||||
}
|
||||
public SaxAccountMgr AccountMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.accountMgr == null)
|
||||
mgr.accountMgr = System.CreateAccountMgr(SessionContext);
|
||||
return mgr.accountMgr;
|
||||
}
|
||||
}
|
||||
public SaxActivityMgr ActivityMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.activityMgr == null)
|
||||
mgr.activityMgr = System.CreateActivityMgr(SessionContext);
|
||||
return mgr.activityMgr;
|
||||
}
|
||||
}
|
||||
public SaxItemDataMgr ItemDataMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.itemDataMgr == null)
|
||||
mgr.itemDataMgr = System.CreateItemDataMgr(SessionContext);
|
||||
return mgr.itemDataMgr;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxSessionContext : SacsSessionContext
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Hidden construction for deserialisation.</summary>
|
||||
protected SaxSessionContext()
|
||||
{
|
||||
}
|
||||
// Protected construction - use derived object.
|
||||
protected SaxSessionContext(ushort sessionIdx, Sax.Application application) : base(sessionIdx)
|
||||
{
|
||||
Application = application;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Sax.Application Application { get; private set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using Newtonsoft.Json;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxSessionData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxSessionData()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
/// <summary>Hidden constructor for deserialisation only.</summary>
|
||||
private SaxSessionData(SaxSessionContext sessionContext)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
User = new UserData(SessionContext, null, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// Primary constructor - on user login.
|
||||
/// <para>SessionContext and UserAccount must be supplied.</para>
|
||||
/// <para>Roles list is optional.</para>
|
||||
/// </summary>
|
||||
protected SaxSessionData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List<SaxUserRole> userRoles)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
User = new UserData(SessionContext, userAccount, userRoles);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public SaxSessionContext SessionContext { get; }
|
||||
[JsonIgnore]
|
||||
public bool ValidUserSession { get { return SysId.IsValid(User.UserAccountId) && SysId.IsValid(User.UserAccountId); } }
|
||||
[JsonIgnore]
|
||||
public DbUpdateInfo DbUpdateInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return new DbUpdateInfo(User.UserAccountId, StringUtil.OnEmpty(User.DisplayName, User.EmailAddress), SaxSystem.ComputerName);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// User.
|
||||
public class UserData
|
||||
{
|
||||
protected UserData() { }
|
||||
public UserData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List<SaxUserRole> userRoles)
|
||||
{
|
||||
if (userAccount != null)
|
||||
{
|
||||
UserAccountId = userAccount.Id;
|
||||
FirstName = userAccount.FirstName;
|
||||
LastName = userAccount.LastName;
|
||||
DisplayName = userAccount.GetDisplayName();
|
||||
EmailAddress = userAccount.EmailAddress;
|
||||
if (sessionContext.Application == Sax.Application.Admin)
|
||||
KeepLoggedIn = userAccount.KeepLoggedIn_Admin;
|
||||
else if (sessionContext.Application == Sax.Application.Online)
|
||||
KeepLoggedIn = userAccount.KeepLoggedIn_Online;
|
||||
else Debugger.Break();
|
||||
|
||||
if (userRoles != null)
|
||||
{
|
||||
foreach (SaxUserRole userRole in userRoles.FindAll(item => item.IsStatusActive))
|
||||
roles.Add(new RoleData(userRole));
|
||||
}
|
||||
}
|
||||
}
|
||||
public SysId UserAccountId { get; protected set; }
|
||||
public String FirstName { get; protected set; }
|
||||
public String LastName { get; protected set; }
|
||||
public String DisplayName { get; protected set; }
|
||||
public String EmailAddress { get; protected set; }
|
||||
public bool KeepLoggedIn { get; protected set; }
|
||||
public bool UserAccountSupplied { get; protected set; }
|
||||
// Roles.
|
||||
public class RoleData
|
||||
{
|
||||
private RoleData() { }
|
||||
public RoleData(SaxUserRole userRole)
|
||||
{
|
||||
if (userRole != null)
|
||||
{
|
||||
Role = userRole.UserRole;
|
||||
Status = userRole.Status;
|
||||
}
|
||||
}
|
||||
public Sax.UserRole Role { get; protected set; }
|
||||
public SaStatus Status { get; protected set; }
|
||||
}
|
||||
[JsonIgnore]
|
||||
private readonly List<RoleData> roles = new List<RoleData>();
|
||||
public List<RoleData> Roles { get { return new List<RoleData>(roles); } protected set { roles.Clear(); roles.AddRange(value); } }
|
||||
/// <summary>User - JSON deserialisation route.</summary>
|
||||
protected void SetRoles(List<RoleData> roles)
|
||||
{
|
||||
if (this.roles.Count > 0)
|
||||
throw new NotSupportedException("Session Data Roles cannot be replaced.");
|
||||
this.roles.AddRange(roles);
|
||||
}
|
||||
[JsonIgnore]
|
||||
public bool IsJournalist { get { return roles?.Exists(item => item.Role == Sax.UserRole.Journalist) ?? false; } }
|
||||
}
|
||||
public UserData User { get; private set; }
|
||||
/// <summary>User - JSON deserialisation route.</summary>
|
||||
protected void SetUser(UserData user)
|
||||
{
|
||||
if (User != null && User.UserAccountSupplied)
|
||||
throw new NotSupportedException("Session Data User cannot be replaced.");
|
||||
User = user;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
// S A X S y s t e m - C o d e T y p e s
|
||||
//=======================================================================
|
||||
partial class SaxSystem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
// S A X S y s t e m - S t a t i c s
|
||||
//=======================================================================
|
||||
partial class SaxSystem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
// Code types.
|
||||
private static readonly List<TypeCodeDesc> regionTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> yesNoCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> userRoleCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> titleCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> organisationTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> organisationCategoryCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> organisationRoleCodes = new List<TypeCodeDesc>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Static initialisation.</summary>
|
||||
static SaxSystem()
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Yes No options.
|
||||
yesNoCodes.Add(Sax.YesNo.Yes, "YES", "Yes");
|
||||
yesNoCodes.Add(Sax.YesNo.No, "NO", "No");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Region types.
|
||||
regionTypeCodes.Add(Sax.RegionType.Continent, "CONT", "Continent");
|
||||
regionTypeCodes.Add(Sax.RegionType.SubContinent, "SUBC", "SubContinent");
|
||||
regionTypeCodes.Add(Sax.RegionType.Country, "COUN", "Country");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// User roles.
|
||||
userRoleCodes.Add(Sax.UserRole.Journalist, "JRNLST", "Journalist");
|
||||
userRoleCodes.Add(Sax.UserRole.SystemAdmin, "SYSADM", "System Admin");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Titles.
|
||||
titleCodes.Add(Sax.Title.Mr, "Mr", "Mr");
|
||||
titleCodes.Add(Sax.Title.Mrs, "Mrs", "Mrs");
|
||||
titleCodes.Add(Sax.Title.Miss, "Miss", "Miss");
|
||||
titleCodes.Add(Sax.Title.Mx, "Mx", "Mx");
|
||||
titleCodes.Add(Sax.Title.Dr, "Dr", "Dr");
|
||||
titleCodes.Add(Sax.Title.Sir, "Sir", "Sir");
|
||||
titleCodes.Add(Sax.Title.Lord, "Lord", "Lord");
|
||||
titleCodes.Add(Sax.Title.Lady, "Lady", "Lady");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Organisation types.
|
||||
organisationTypeCodes.Add(Sax.OrganisationType.SocialEnterprise, "SEN", "Social Enterprise");
|
||||
organisationTypeCodes.Add(Sax.OrganisationType.CommunityGroup, "CGR", "Community Group");
|
||||
organisationTypeCodes.Add(Sax.OrganisationType.Charity, "CTY", "Charity");
|
||||
organisationTypeCodes.Add(Sax.OrganisationType.Commercial, "CMC", "Commercial");
|
||||
organisationTypeCodes.Add(Sax.OrganisationType.PublicSector, "PBS", "Public Sector");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Organisation types.
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Association, "ASC", "Association");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Club, "CLB", "Club");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Education, "EDU", "Education");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Syndicate, "SYN", "Syndicate");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Partner, "PRT", "Partner");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Other, "OTH", "Other");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Organisation types.
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.Member, "MBR", "Member");
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.MemberAdmin, "MBA", "Member Admin");
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.ScheduleAdmin, "SCA", "Schedule Admin");
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.OpportunityAdmin, "OPA", "Opportunity Admin");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Saxonite.Net.Standard.Base.Mgr;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxSystem : SacsSystem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected Construction.
|
||||
protected SaxSystem() : base()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Business components.
|
||||
//-------------------------------------------------------------------
|
||||
public abstract SaxReferenceMgr CreateReferenceMgr(SaxSessionContext sessionContext);
|
||||
public abstract SaxAccountMgr CreateAccountMgr(SaxSessionContext sessionContext);
|
||||
public abstract SaxItemDataMgr CreateItemDataMgr(SaxSessionContext sessionContext);
|
||||
public abstract SaxActivityMgr CreateActivityMgr(SaxSessionContext sessionContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// S y s t e m C o d e s
|
||||
//-------------------------------------------------------------------
|
||||
public static List<TypeCodeDesc> GetCodesOfType(Sax.CodeType systemCode)
|
||||
{
|
||||
// Lists are cloned to avoid modifications to the internal static lists.
|
||||
switch (systemCode)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
case Sax.CodeType.YesNo:
|
||||
return new List<TypeCodeDesc>(yesNoCodes);
|
||||
case Sax.CodeType.RegionType:
|
||||
return new List<TypeCodeDesc>(regionTypeCodes);
|
||||
case Sax.CodeType.UserRole:
|
||||
return new List<TypeCodeDesc>(userRoleCodes);
|
||||
case Sax.CodeType.Title:
|
||||
return new List<TypeCodeDesc>(titleCodes);
|
||||
case Sax.CodeType.OrganisationType:
|
||||
return new List<TypeCodeDesc>(organisationTypeCodes);
|
||||
case Sax.CodeType.OrganisationCategory:
|
||||
return new List<TypeCodeDesc>(organisationCategoryCodes);
|
||||
case Sax.CodeType.OrganisationRole:
|
||||
return new List<TypeCodeDesc>(organisationRoleCodes);
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
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 SaxItemSport : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// 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; }
|
||||
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 SaxItemSport(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)
|
||||
{
|
||||
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 (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
||||
throw new NotSupportedException(fn + " Item Id cannot be changed");
|
||||
if (SysId.IsValid(SportId) && SysId.ToInt(SportId) != SysId.ToInt(data.SportId))
|
||||
throw new NotSupportedException(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,
|
||||
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<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
public static class SaxItemSportList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// JournalistArticle.
|
||||
//=======================================================================
|
||||
public abstract class SaxJournalistArticle : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Journalist.
|
||||
UserAccountIdJournalist,
|
||||
Journalist_DisplayName,
|
||||
Journalist_Title,
|
||||
Journalist_FirstName,
|
||||
Journalist_LastName,
|
||||
// Region.
|
||||
RegionIdPrimary,
|
||||
Region_Name,
|
||||
// Sport.
|
||||
SportIdPrimary,
|
||||
Sport_Name,
|
||||
// Article.
|
||||
Headline,
|
||||
Summary,
|
||||
PublishedAt_Date,
|
||||
PublishedAt_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 UserAccountIdJournalist { get; set; }
|
||||
public SysId RegionIdPrimary { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public String Headline { get; set; } = String.Empty;
|
||||
public String Summary { get; set; } = String.Empty;
|
||||
public String BodyData { get; set; } = String.Empty;
|
||||
public DateTime PublishedAt { 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 UserAccountIdJournalist
|
||||
{
|
||||
get { return data.UserAccountIdJournalist; }
|
||||
set { CheckChanged(data.UserAccountIdJournalist, value); data.UserAccountIdJournalist = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { CheckChanged(data.RegionIdPrimary, value); data.RegionIdPrimary = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = 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 String BodyData
|
||||
{
|
||||
get { return data.BodyData; }
|
||||
set { CheckChanged(data.BodyData, value); data.BodyData = value; }
|
||||
}
|
||||
public DateTime PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { CheckChanged(data.PublishedAt, value); data.PublishedAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountIdJournalist = data.UserAccountIdJournalist;
|
||||
RegionIdPrimary = data.RegionIdPrimary;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
Headline = data.Headline;
|
||||
Summary = data.Summary;
|
||||
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 UserAccountIdJournalist { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Headline { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Summary { 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 SaxJournalistArticle(SysId id, SysId UserAccountIdJournalist) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.UserAccountIdJournalist = UserAccountIdJournalist;
|
||||
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.JournalistArticle, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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(UserAccountIdJournalist) && SysId.ToInt(UserAccountIdJournalist) != SysId.ToInt(data.UserAccountIdJournalist))
|
||||
throw new NotSupportedException(fn + " UserAccountIdJournalist cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountIdJournalist
|
||||
{
|
||||
get { return data.UserAccountIdJournalist; }
|
||||
protected set { data.UserAccountIdJournalist = 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 SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public DateTime PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { data.PublishedAt = value; }
|
||||
}
|
||||
public String BodyData
|
||||
{
|
||||
get { return data.BodyData; }
|
||||
set { data.BodyData = 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> UserAccountIdsJournalistIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> SportIdsIncluded { get; set; } = 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; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
public static class SaxJournalistArticleList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Organisation.
|
||||
//=======================================================================
|
||||
public abstract class SaxOrganisation : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
Name,
|
||||
OrganisationType,
|
||||
OrganisationType_Desc,
|
||||
OrganisationCategory,
|
||||
OrganisationCategory_Desc,
|
||||
PhoneMain,
|
||||
PhoneAlt,
|
||||
// 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,
|
||||
// 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 String PhoneMain { get; set; } = String.Empty;
|
||||
public String PhoneAlt { 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 String PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { CheckChanged(data.PhoneMain, value); data.PhoneMain = value; }
|
||||
}
|
||||
public String PhoneAlt
|
||||
{
|
||||
get { return data.PhoneAlt; }
|
||||
set { CheckChanged(data.PhoneAlt, value); data.PhoneAlt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom (Data data)
|
||||
{
|
||||
Name = data.Name;
|
||||
OrganisationType = data.OrganisationType;
|
||||
OrganisationCategory = data.OrganisationCategory;
|
||||
PhoneMain = data.PhoneMain;
|
||||
PhoneAlt = data.PhoneAlt;
|
||||
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 PhoneMain { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PhoneAlt { 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.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);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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");
|
||||
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 String PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { data.PhoneMain = value; }
|
||||
}
|
||||
public String PhoneAlt
|
||||
{
|
||||
get { return data.PhoneAlt; }
|
||||
set { data.PhoneAlt = 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 String NameFull { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
/// <summary>Partial match on a number of fields, including name, sport, address, etc.</summary>
|
||||
public String OrganisationFilter { get; set; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
public static class SaxOrganisationList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
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 : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// 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; }
|
||||
public Decimal Longitude { get; set; }
|
||||
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 { CheckChanged(data.Latitude, value); data.Latitude = value; }
|
||||
}
|
||||
public Decimal Longitude
|
||||
{
|
||||
get { return data.Longitude; }
|
||||
set { CheckChanged(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.Continent:
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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");
|
||||
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,
|
||||
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> IncludedParentRegionIds { 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; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
public static class SaxRegionList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
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 : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
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 String Name { 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; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom (Data data)
|
||||
{
|
||||
Name = data.Name;
|
||||
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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { data.Name = 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> IncludedIds { get; } = new List<SysId>();
|
||||
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
||||
/// <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; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
public static class SaxSportList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxUserAccount : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
EmailAddress,
|
||||
Title,
|
||||
FirstName,
|
||||
Initials,
|
||||
LastName,
|
||||
PhoneMain,
|
||||
PhoneMobile,
|
||||
DateOfBirth,
|
||||
// Security.
|
||||
PasswordToken,
|
||||
PasswordChangedOn,
|
||||
PasswordChangedAt,
|
||||
// Login.
|
||||
LastLoginOn,
|
||||
LastLoginAt,
|
||||
LastInvalidLoginOn,
|
||||
LastInvalidLoginAt,
|
||||
InvalidLoginCount,
|
||||
// Associated data.
|
||||
UserRoleCount,
|
||||
SystemAdminUser,
|
||||
// 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 PhoneMain { get; set; } = String.Empty;
|
||||
public String PhoneMobile { get; set; } = String.Empty;
|
||||
public DateTime DateOfBirth { 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; } = DateTime.MinValue;
|
||||
// Login.
|
||||
public DateTime LastLoginAt { get; set; } = DateTime.MinValue;
|
||||
public DateTime LastInvalidLoginAt { get; set; } = DateTime.MinValue;
|
||||
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 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 DateTime DateOfBirth
|
||||
{
|
||||
get { return data.DateOfBirth; }
|
||||
set { CheckChanged(data.DateOfBirth, value); data.DateOfBirth = 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 { CheckChanged(data.PasswordChangedAt, value); data.PasswordChangedAt = value; }
|
||||
}
|
||||
// Login.
|
||||
public DateTime LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { CheckChanged(data.LastLoginAt, value); data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { CheckChanged(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;
|
||||
PhoneMain = data.PhoneMain;
|
||||
PhoneMobile = data.PhoneMobile;
|
||||
DateOfBirth = data.DateOfBirth;
|
||||
// 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 PhoneMain { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PhoneMobile { get; set; } = ValidValue.Valid;
|
||||
public ValidValue DateOfBirth { 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)
|
||||
{
|
||||
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");
|
||||
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 PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { data.PhoneMain = value; }
|
||||
}
|
||||
public String PhoneMobile
|
||||
{
|
||||
get { return data.PhoneMobile; }
|
||||
set { data.PhoneMobile = value; }
|
||||
}
|
||||
public DateTime DateOfBirth
|
||||
{
|
||||
get { return data.DateOfBirth; }
|
||||
set { data.DateOfBirth = 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_Admin { get; } = 0x1;
|
||||
public Byte Flag_KeepLoggedIn_Online { get; } = 0x2;
|
||||
public bool KeepLoggedIn_Admin
|
||||
{
|
||||
get { return GetFlag(Flag_KeepLoggedIn_Admin); }
|
||||
set { SetFlag(Flag_KeepLoggedIn_Admin, value); }
|
||||
}
|
||||
public bool KeepLoggedIn_Online
|
||||
{
|
||||
get { return GetFlag(Flag_KeepLoggedIn_Online); }
|
||||
set { SetFlag(Flag_KeepLoggedIn_Online, 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,
|
||||
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 String EmailAddress { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
/// <summary>Partial match on various user account properties including name.</summary>
|
||||
public String UserAccountFilter { get; set; }
|
||||
public List<Sax.UserRole> ActiveRoles { get; } = new List<Sax.UserRole>();
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
public static class SaxUserAccountList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
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 : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserAccountId,
|
||||
UserRole,
|
||||
UserRole_Desc,
|
||||
// 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; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
UserRole = data.UserRole;
|
||||
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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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)
|
||||
{
|
||||
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 (UserRole == 0 && (int)UserRole != (int)UserRole)
|
||||
throw new NotSupportedException(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; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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<Sax.UserRole> UserRolesIncluded { get; } = new List<Sax.UserRole>();
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list 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,28 @@
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxConsoleHelper
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxConsoleHelper()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data cache console.
|
||||
public abstract SaxDataCacheConsole GetDataCacheConsole(SaxSessionContext sessionContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Email console.
|
||||
public abstract SaxEmailConsole CreateEmailConsole(SaxSessionContext sessionContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxDataCacheConsole : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxDataCacheConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing) { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Regions.
|
||||
public abstract List<SaxRegion> GetActiveRegions();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Sports.
|
||||
public abstract List<SaxSport> GetActiveSports();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using Sarand.Net.Standard.Base.Email;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxEmailConfig : SaEmailConfig
|
||||
{
|
||||
public SaxEmailConfig(String context) : base(context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
public abstract class SaxEmailConsole : SaEmailConsole
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxEmailConsole(SaxEmailConfig emailConfig)
|
||||
{
|
||||
EmailConfig = emailConfig;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public SaxEmailConfig EmailConfig { get; }
|
||||
public static String EmailTag_Header { get; } = "[#Email.Header]";
|
||||
public static String EmailTag_Footer { get; } = "[#Email.Footer]";
|
||||
public static String EmailTag_Caption { get; } = "[#Email.Caption]";
|
||||
public static String EmailTag_MainStylesheet { get; } = "[#Email.MainStylesheet]";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Replace dynamic tags in email message body.
|
||||
/// <para></para>
|
||||
/// </summary>
|
||||
public void ReplaceDynamicEmailBodyTags(SaEmailData emailData, SaxSessionData sessionData, SaxUserAccount userAccount)
|
||||
{
|
||||
// Replace core tags, eg. main stylesheet.
|
||||
SaEmailConsole.ReplaceDynamicEmailTags(emailData);
|
||||
|
||||
// Replace tags known to the web application.
|
||||
// Main stylesheet.
|
||||
if (EmailContainsTag(emailData, EmailTag_MainStylesheet))
|
||||
{
|
||||
// Tag replacement is expanded to avoid reading main stylesheet resource unless required.
|
||||
ReplaceDynamicEmailTag(emailData, EmailTag_MainStylesheet, "<style>\n" + SaxResourceHelper.GetTextResource(SaxResourceHelper.TextResource.Email_Main_Css) + "</style>");
|
||||
}
|
||||
|
||||
// Partial content - Header.
|
||||
if (EmailContainsTag(emailData, EmailTag_Header))
|
||||
{
|
||||
// Tag replacement is expanded to avoid reading Header resource unless required.
|
||||
ReplaceDynamicEmailTag(emailData, EmailTag_Header, SaxResourceHelper.GetTextResource(SaxResourceHelper.TextResource.Email_Header_Html));
|
||||
}
|
||||
|
||||
// Partial content - Footer.
|
||||
if (EmailContainsTag(emailData, EmailTag_Footer))
|
||||
{
|
||||
// Tag replacement is expanded to avoid reading Footer resource unless required.
|
||||
ReplaceDynamicEmailTag(emailData, EmailTag_Footer, SaxResourceHelper.GetTextResource(SaxResourceHelper.TextResource.Email_Footer_Html));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Helpers
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxPasswordHelper
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration parameters.
|
||||
public class PasswordParams
|
||||
{
|
||||
public int MinLength = 8;
|
||||
public int MinLengthNoComplexity = 12;
|
||||
}
|
||||
public static PasswordParams Params { get; } = new PasswordParams();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Validate password against parameters.</summary>
|
||||
public static bool IsValidPassword(String password)
|
||||
{
|
||||
return GetPasswordStrength(password) >= 4;
|
||||
}
|
||||
/// <summary>
|
||||
/// Assess the password strength - 4+ is valid.
|
||||
/// <para>0 - Blank</para>
|
||||
/// <para>1 - < min length - 2 [red]</para>
|
||||
/// <para>1 - < min length and only 1 character type [red]</para>
|
||||
/// <para>2 - < min length and only 2 character types [red]</para>
|
||||
/// <para>2 - < min length without complexity - 2 and only 1 character type [red]</para>
|
||||
/// <para>3 - < min length, min length with 3 character types [amber]</para>
|
||||
/// <para>3 - Min length without complexity - 2 [amber]</para>
|
||||
/// <para>3 - Other invalid passwords [amber]</para>
|
||||
/// <para>4 - Min length with 4 character types [green]</para>
|
||||
/// <para>4 - Min length without complexity [green]</para>
|
||||
/// <para>5 - Min lenth + 2 with 4 character types [green]</para>
|
||||
/// <para>5 - Min length without complexity with 3 character types [green]</para>
|
||||
/// </summary>
|
||||
public static int GetPasswordStrength(String password)
|
||||
{
|
||||
String fn = "PasswordHelper.GetPasswordStrength";
|
||||
|
||||
// 0 - Blank.
|
||||
if (StringUtil.IsEmpty(password)) return 0;
|
||||
|
||||
// Count number of different types of character.
|
||||
int characterTypeCount = 0;
|
||||
try
|
||||
{
|
||||
if (Regex.Matches(password, "[A-Z]").Count > 0) characterTypeCount++;
|
||||
if (Regex.Matches(password, "[a-z]").Count > 0) characterTypeCount++;
|
||||
if (Regex.Matches(password, "[0-9]").Count > 0) characterTypeCount++;
|
||||
if (Regex.Matches(password, "[^a-zA-Z0-9]").Count > 0) characterTypeCount++;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Debug(fn + " " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
int passwordLength = StringUtil.GetLength(password);
|
||||
|
||||
// 1 - Less than min length - 2;
|
||||
if (passwordLength < Params.MinLength - 2)
|
||||
return 1;
|
||||
|
||||
// 1 - Less than min length and only 1 character type.
|
||||
if (passwordLength < Params.MinLength && characterTypeCount == 1)
|
||||
return 1;
|
||||
|
||||
// 2 - Less than min length and only 2 character types.
|
||||
if (passwordLength < Params.MinLength && characterTypeCount == 2)
|
||||
return 2;
|
||||
|
||||
// 2 - Less than min length without complexity - 2 and only 1 character type.
|
||||
if (passwordLength < Params.MinLengthNoComplexity - 2 && characterTypeCount == 1)
|
||||
return 2;
|
||||
|
||||
// 3 - Less than minimum length.
|
||||
if (passwordLength < Params.MinLength)
|
||||
return 3;
|
||||
|
||||
// 3 - Minimum length with only 3 character types.
|
||||
if (passwordLength >= Params.MinLength && passwordLength < Params.MinLengthNoComplexity && characterTypeCount == 3)
|
||||
return 3;
|
||||
|
||||
// 3 - Minimum length without complexity - 2 with less than 4 character types.
|
||||
if (passwordLength >= Params.MinLengthNoComplexity - 2 && passwordLength < Params.MinLengthNoComplexity && characterTypeCount < 4)
|
||||
return 3;
|
||||
|
||||
// 3 Catch-all - ensure only valid passwords score 4 or more.
|
||||
if (passwordLength < Params.MinLengthNoComplexity && characterTypeCount < 4)
|
||||
return 3;
|
||||
|
||||
// 4 - Min length with 4 character types.
|
||||
if (passwordLength < Params.MinLengthNoComplexity)
|
||||
return 4;
|
||||
|
||||
// 4 - Min length without complexity.
|
||||
if (passwordLength >= Params.MinLengthNoComplexity && passwordLength < Params.MinLengthNoComplexity + 2 && characterTypeCount < 4)
|
||||
return 4;
|
||||
|
||||
// 5 - Anything more complex.
|
||||
return 5;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private static PasswordHasher<SaxUserAccount> passwordHasher = new PasswordHasher<SaxUserAccount>();
|
||||
/// <summary>Get the hashed value that corresponds to the password.</summary>
|
||||
public static String GetPasswordHash(SaxUserAccount userAccount, String password)
|
||||
{
|
||||
return passwordHasher.HashPassword(userAccount, password);
|
||||
}
|
||||
/// <summary>Verify password against hashed value stored against user account.</summary>
|
||||
public static bool VerifyHashedPassword(SaxUserAccount userAccount, String password)
|
||||
{
|
||||
return passwordHasher.VerifyHashedPassword(userAccount, userAccount.PasswordHashed, password) != PasswordVerificationResult.Failed;
|
||||
}
|
||||
/// <summary>Verify password against hashed value with user account as reference.</summary>
|
||||
public static bool VerifyHashedPassword(SaxUserAccount userAccount, String password, String passwordHashed)
|
||||
{
|
||||
return passwordHasher.VerifyHashedPassword(userAccount, passwordHashed, password) != PasswordVerificationResult.Failed;
|
||||
}
|
||||
/// <summary>Check whether the password needs rehashing.</summary>
|
||||
public static bool PasswordRequiresRehash(SaxUserAccount userAccount, String password)
|
||||
{
|
||||
return passwordHasher.VerifyHashedPassword(userAccount, userAccount.PasswordHashed, password) == PasswordVerificationResult.SuccessRehashNeeded;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Helpers;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Helpers
|
||||
{
|
||||
//=======================================================================
|
||||
public static class SaxResourceHelper
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public enum TextResource
|
||||
{
|
||||
// Email stylesheets.
|
||||
Email_Main_Css,
|
||||
// Email partial content.
|
||||
Email_Header_Html,
|
||||
Email_Footer_Html,
|
||||
// Email templates.
|
||||
Email_ContactUs_Html,
|
||||
Email_Signup_Activate_Html,
|
||||
Email_Signup_Welcome_Html,
|
||||
Email_RequestPassword_Html,
|
||||
// Data - countries etc.
|
||||
Data_CountriesWithRegions_Txt,
|
||||
}
|
||||
public enum ImageResource
|
||||
{
|
||||
Saxonite_logo_h75_png,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Text resources.
|
||||
public static String GetTextResource(TextResource textResource)
|
||||
{
|
||||
String partialPath = "";
|
||||
String resourceFilename = "";
|
||||
switch (textResource)
|
||||
{
|
||||
// Email stylesheet.
|
||||
case TextResource.Email_Main_Css:
|
||||
resourceFilename = "sax-email-main.css";
|
||||
break;
|
||||
// Email partial content.
|
||||
case TextResource.Email_Header_Html:
|
||||
resourceFilename = "sax-email-header.html";
|
||||
break;
|
||||
case TextResource.Email_Footer_Html:
|
||||
resourceFilename = "sax-email-footer.html";
|
||||
break;
|
||||
// Email templates.
|
||||
case TextResource.Email_ContactUs_Html:
|
||||
resourceFilename = "sax-email-contact-us.html";
|
||||
break;
|
||||
case TextResource.Email_Signup_Activate_Html:
|
||||
resourceFilename = "sax-email-signup-activate.html";
|
||||
break;
|
||||
case TextResource.Email_Signup_Welcome_Html:
|
||||
resourceFilename = "sax-email-signup-welcome.html";
|
||||
break;
|
||||
case TextResource.Email_RequestPassword_Html:
|
||||
resourceFilename = "sax-email-request-password.html";
|
||||
break;
|
||||
// Data.
|
||||
case TextResource.Data_CountriesWithRegions_Txt:
|
||||
resourceFilename = "CountriesWithRegions.txt";
|
||||
break;
|
||||
}
|
||||
if (!StringUtil.IsEmpty(resourceFilename))
|
||||
{
|
||||
var assembly = typeof(SaxResourceHelper).GetTypeInfo().Assembly;
|
||||
String resourceText = SacsResourceHelper.GetManifestResourceAsText(assembly, partialPath, resourceFilename);
|
||||
if (!StringUtil.IsEmpty(resourceText))
|
||||
return resourceText;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Image resources.
|
||||
public static byte[] GetImageResource(ImageResource imageResource)
|
||||
{
|
||||
String partialPath = "";
|
||||
String resourceFilename = "";
|
||||
switch (imageResource)
|
||||
{
|
||||
case ImageResource.Saxonite_logo_h75_png:
|
||||
resourceFilename = "saxonite-logo-h75.png";
|
||||
break;
|
||||
}
|
||||
if (!StringUtil.IsEmpty(resourceFilename))
|
||||
{
|
||||
var assembly = typeof(SaxResourceHelper).GetTypeInfo().Assembly;
|
||||
byte[] resourceData = SacsResourceHelper.GetManifestResourceAsBinary(assembly, partialPath, resourceFilename);
|
||||
if (resourceData != null)
|
||||
return resourceData;
|
||||
}
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Account Mgr - Organisation
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public long GetOrganisationMemberCount (SysId organisationId)
|
||||
{
|
||||
if (!SysId.IsValid(organisationId)) return 0;
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
|
||||
prmUserOrganisation.OrganisationMembersOnly = true;
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
|
||||
return GetUserOrganisationCount(prmUserOrganisation);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxOrganisation CreateOrganisation ();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool OrganisationExistsById (SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.IdsIncluded.Add(id);
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
|
||||
return GetOrganisationCount(prmOrganisation) == 1;
|
||||
}
|
||||
public bool OrganisationExistsByName (String name)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(name)) return false;
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.NameFull = name;
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
|
||||
return GetOrganisationCount(prmOrganisation) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxOrganisation GetOrganisation (SaxOrganisation.Params prmOrganisation);
|
||||
public SaxOrganisation GetOrganisationById (SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.IdsIncluded.Add(id);
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
|
||||
return GetOrganisation(prmOrganisation);
|
||||
}
|
||||
public SaxOrganisation GetOrganisationByName (String name)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(name)) return null;
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.NameFull = name;
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
|
||||
return GetOrganisation(prmOrganisation);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidOrganisation (SaxOrganisation organisation)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (organisation == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidOrganisationData(organisation.GetData(), new SaxOrganisation.ErrField());
|
||||
}
|
||||
public virtual bool IsValidOrganisationData (SaxOrganisation.Data data, SaxOrganisation.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// Name.
|
||||
if (errField.Name != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Name, "name", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Organisation_Name), true))
|
||||
{
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Organisation type.
|
||||
if (errField.OrganisationType != SacsHierarchyItem.ValidValue.Ignore && data.OrganisationType == 0)
|
||||
{
|
||||
errField.OrganisationType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Organisation type must be specified.");
|
||||
}
|
||||
// Organisation category.
|
||||
if (errField.OrganisationCategory != SacsHierarchyItem.ValidValue.Ignore && data.OrganisationCategory == 0)
|
||||
{
|
||||
errField.OrganisationCategory = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Organisation category must be specified.");
|
||||
}
|
||||
// Main phone.
|
||||
if (errField.PhoneMain != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PhoneMain, "phone", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Organisation_PhoneMain)))
|
||||
{
|
||||
errField.PhoneMain = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Alt phone.
|
||||
if (errField.PhoneAlt != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PhoneAlt, "alt. phone", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Organisation_PhoneAlt)))
|
||||
{
|
||||
errField.PhoneAlt = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Organisation_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Organisation_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxOrganisation.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Organisation database interface.
|
||||
public abstract bool InsertOrganisation (SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateOrganisation (SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool OrganisationCanBeDeleted (SaxOrganisation organisation)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteOrganisation (SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Organisation list:
|
||||
public abstract ColumnDfn GetOrganisationColumnDfn (SaxOrganisation.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetOrganisationQueryFilter (SaxOrganisation.Params prmOrganisation);
|
||||
public abstract long GetOrganisationCount (SaxOrganisation.Params prmOrganisation);
|
||||
public abstract List<SaxOrganisation> GetOrganisationList (SaxOrganisation.Params prmOrganisation);
|
||||
public abstract DbResultSet ExecuteOrganisationQuery (List<ColumnDfn> columns, SaxOrganisation.Params prmOrganisation);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetOrganisationDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxOrganisation.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Organisation type.
|
||||
case SaxOrganisation.Column.OrganisationType_Desc:
|
||||
String organisationType = values.GetValue(column.DataName).ToString();
|
||||
// ToDo Translate organisation type.
|
||||
value = new DataValue();
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Organisation category.
|
||||
case SaxOrganisation.Column.OrganisationCategory_Desc:
|
||||
String organisationCategory = values.GetValue(column.DataName).ToString();
|
||||
// ToDo Translate organisation category.
|
||||
value = new DataValue();
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxOrganisation.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxOrganisation.Column.Status_Desc:
|
||||
case SaxOrganisation.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxOrganisation.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxOrganisation.Column.Status_Ind)
|
||||
value = new DataValue(SaxOrganisation.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Account Mgr - User Account
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserAccount CreateUserAccount ();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserAccountExistsById (SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(id);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.Any;
|
||||
return GetUserAccountCount(prmUserAccount) == 1;
|
||||
}
|
||||
public bool UserAccountExistsByEmailAddress (string emailAddress)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(emailAddress)) return false;
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.EmailAddress = emailAddress;
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.Any;
|
||||
return GetUserAccountCount(prmUserAccount) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserAccount GetUserAccount (SaxUserAccount.Params prmUserAccount);
|
||||
public SaxUserAccount GetUserAccountById (SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(id);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.Any;
|
||||
return GetUserAccount(prmUserAccount);
|
||||
}
|
||||
public SaxUserAccount GetUserAccountByEmailAddress (string emailAddress)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(emailAddress)) return null;
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.EmailAddress = emailAddress;
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.Any;
|
||||
return GetUserAccount(prmUserAccount);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserAccount (SaxUserAccount userAccount)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userAccount == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserAccountData(userAccount.GetData(), new SaxUserAccount.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserAccountData (SaxUserAccount.Data data, SaxUserAccount.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Email address.
|
||||
if (errField.EmailAddress != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.EmailAddress, "email", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_EmailAddress), true))
|
||||
{
|
||||
errField.EmailAddress = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Title.
|
||||
if (errField.Title != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Title, "Title", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_Title)))
|
||||
{
|
||||
errField.Title = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// First name.
|
||||
if (errField.FirstName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.FirstName, "first name", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_FirstName)))
|
||||
{
|
||||
errField.FirstName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Initials.
|
||||
if (errField.Initials != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Initials, "initials", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_Initials)))
|
||||
{
|
||||
errField.Initials = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Last name.
|
||||
if (errField.LastName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.LastName, "last name", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_LastName)))
|
||||
{
|
||||
errField.LastName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Phone - main.
|
||||
if (errField.PhoneMain != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PhoneMain, "phone", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_PhoneMain)))
|
||||
{
|
||||
errField.PhoneMain = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Phone - mobile.
|
||||
if (errField.PhoneMobile != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PhoneMobile, "mobile", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_PhoneMobile)))
|
||||
{
|
||||
errField.PhoneMobile = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Date of birth.
|
||||
if (errField.DateOfBirth != SacsHierarchyItem.ValidValue.Ignore && DateUtil.IsValid(data.DateOfBirth) && data.DateOfBirth.CompareTo(DateTime.Today) > 0)
|
||||
{
|
||||
errField.PhoneMobile = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Date of birth must not be in the future");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Security.
|
||||
// Password token.
|
||||
if (errField.PasswordToken != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PasswordToken, "password token", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_PasswordToken)))
|
||||
{
|
||||
errField.PasswordToken = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserAccount_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxUserAccount.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Email Address must be unique.
|
||||
if (errField.EmailAddress != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmUserAccount.IdsExcluded.Add(data.Id);
|
||||
prmUserAccount.EmailAddress = data.EmailAddress;
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.Any;
|
||||
if (GetUserAccountCount(prmUserAccount) > 0)
|
||||
{
|
||||
errField.EmailAddress = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Email must unique");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserAccount (SaxUserAccount userAccount, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserAccount (SaxUserAccount userAccount, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserAccountCanBeDeleted (SaxUserAccount userAccount)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserAccount (SaxUserAccount userAccount, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserAccountColumnDfn (SaxUserAccount.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserAccountQueryFilter (SaxUserAccount.Params prmUserAccount);
|
||||
public abstract long GetUserAccountCount (SaxUserAccount.Params prmUserAccount);
|
||||
public abstract List<SaxUserAccount> GetUserAccountList (SaxUserAccount.Params prmUserAccount);
|
||||
public abstract DbResultSet ExecuteUserAccountQuery (List<ColumnDfn> columns, SaxUserAccount.Params prmUserAccount);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUserAccountDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserAccount.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxUserAccount.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxUserAccount.Column.Status_Desc:
|
||||
case SaxUserAccount.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxUserAccount.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxUserAccount.Column.Status_Ind)
|
||||
value = new DataValue(SaxUserAccount.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Account Mgr - User Role
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserOrganisation CreateUserOrganisation(SysId userAccountId, SysId OrganisationId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserOrganisationExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.IdsIncluded.Add(id);
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.Any;
|
||||
return GetUserOrganisationCount(prmUserOrganisation) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserOrganisation GetUserOrganisation(SaxUserOrganisation.Params prmUserOrganisation);
|
||||
public SaxUserOrganisation GetUserOrganisationById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.IdsIncluded.Add(id);
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.Any;
|
||||
return GetUserOrganisation(prmUserOrganisation);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserOrganisation(SaxUserOrganisation userOrganisation)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userOrganisation == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserOrganisationData(userOrganisation.GetData(), new SaxUserOrganisation.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserOrganisationData(SaxUserOrganisation.Data data, SaxUserOrganisation.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// User Account.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UserAccountId))
|
||||
{
|
||||
errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Account Id must be specified");
|
||||
}
|
||||
|
||||
// Organisation.
|
||||
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Organisation Id must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserOrganisation_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserOrganisation_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxUserOrganisation.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// User & Organisation combination must be unique.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.UserAccountId) && SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmUserOrganisation.IdsExcluded.Add(data.Id);
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(data.UserAccountId);
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(data.OrganisationId);
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.Any;
|
||||
if (GetUserOrganisationCount(prmUserOrganisation) > 0)
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Organisation must be unique for user");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserOrganisation(SaxUserOrganisation userOrganisation, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserOrganisation(SaxUserOrganisation userOrganisation, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserOrganisationCanBeDeleted(SaxUserOrganisation userOrganisation)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserOrganisation(SaxUserOrganisation userOrganisation, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserOrganisationColumnDfn(SaxUserOrganisation.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserOrganisationQueryFilter(SaxUserOrganisation.Params prmUserOrganisation);
|
||||
public abstract long GetUserOrganisationCount(SaxUserOrganisation.Params prmUserOrganisation);
|
||||
public abstract List<SaxUserOrganisation> GetUserOrganisationList(SaxUserOrganisation.Params prmUserOrganisation);
|
||||
public abstract DbResultSet ExecuteUserOrganisationQuery(List<ColumnDfn> columns, SaxUserOrganisation.Params prmUserOrganisation);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUserOrganisationDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserOrganisation.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// User Display Name.
|
||||
case SaxUserOrganisation.Column.User_DisplayName:
|
||||
{
|
||||
String userTitle = values.GetValue(GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.User_Title).DataName).ToString();
|
||||
String userFirstName = values.GetValue(GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.User_FirstName).DataName).ToString();
|
||||
String userLastName = values.GetValue(GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.User_LastName).DataName).ToString();
|
||||
value = new DataValue(SaxUserAccount.GetDisplayName(userTitle, userFirstName, userLastName));
|
||||
}
|
||||
break;
|
||||
/*
|
||||
//-----------------------------------------------------------
|
||||
// User Role.
|
||||
case SaxUserOrganisation.Column.UserOrganisation_Desc:
|
||||
{
|
||||
String userOrganisationCode = values.GetValue(column.DataName).ToString();
|
||||
value = new DataValue(UserOrganisations.GetDescForCode(userOrganisationCode));
|
||||
}
|
||||
break;
|
||||
*/
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxUserOrganisation.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxUserOrganisation.Column.Status_Desc:
|
||||
case SaxUserOrganisation.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxUserOrganisation.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxUserOrganisation.Column.Status_Ind)
|
||||
value = new DataValue(SaxUserOrganisation.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Account Mgr - User Role
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public bool UserHasRole(SysId userAccountId, Sax.UserRole userRole, SaxUserRole.StatusCat statusCat = SaxUserRole.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || userRole <= 0) return false;
|
||||
SaxUserRole.Params prmUserRole = new SaxUserRole.Params();
|
||||
prmUserRole.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserRole.UserRolesIncluded.Add(userRole);
|
||||
prmUserRole.StatusCat = statusCat;
|
||||
return GetUserRoleCount(prmUserRole) > 0;
|
||||
}
|
||||
public List<SaxUserRole> GetRolesForUser(SysId userAccountId, SaxUserRole.StatusCat statusCat = SaxUserRole.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId)) return new List<SaxUserRole>();
|
||||
SaxUserRole.Params prmUserRole = new SaxUserRole.Params();
|
||||
prmUserRole.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserRole.StatusCat = statusCat;
|
||||
return GetUserRoleList(prmUserRole);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserRole CreateUserRole(SysId userAccountId, Sax.UserRole userRole);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserRoleExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxUserRole.Params prmUserRole = new SaxUserRole.Params();
|
||||
prmUserRole.IdsIncluded.Add(id);
|
||||
prmUserRole.StatusCat = SaxUserRole.StatusCat.Any;
|
||||
return GetUserRoleCount(prmUserRole) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserRole GetUserRole(SaxUserRole.Params prmUserRole);
|
||||
public SaxUserRole GetUserRoleById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxUserRole.Params prmUserRole = new SaxUserRole.Params();
|
||||
prmUserRole.IdsIncluded.Add(id);
|
||||
prmUserRole.StatusCat = SaxUserRole.StatusCat.Any;
|
||||
return GetUserRole(prmUserRole);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserRole(SaxUserRole userRole)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userRole == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserRoleData(userRole.GetData(), new SaxUserRole.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserRoleData(SaxUserRole.Data data, SaxUserRole.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// User Account.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UserAccountId))
|
||||
{
|
||||
errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Account Id must be specified");
|
||||
}
|
||||
// User Role.
|
||||
if (errField.UserRole != SacsHierarchyItem.ValidValue.Ignore && (int)data.UserRole < 1)
|
||||
{
|
||||
errField.UserRole = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Role must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserRole_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.UserRole_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxUserRole.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// User & Role combination must be unique.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && errField.UserRole != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.UserAccountId) && data.UserRole > 0)
|
||||
{
|
||||
SaxUserRole.Params prmUserRole = new SaxUserRole.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmUserRole.IdsExcluded.Add(data.Id);
|
||||
prmUserRole.UserAccountIdsIncluded.Add(data.UserAccountId);
|
||||
prmUserRole.UserRolesIncluded.Add(data.UserRole);
|
||||
prmUserRole.StatusCat = SaxUserRole.StatusCat.Any;
|
||||
if (GetUserRoleCount(prmUserRole) > 0)
|
||||
{
|
||||
errField.UserRole = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Role must be unique for user");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserRole(SaxUserRole userRole, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserRole(SaxUserRole userRole, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserRoleCanBeDeleted(SaxUserRole userRole)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserRole(SaxUserRole userRole, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserRoleColumnDfn(SaxUserRole.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserRoleQueryFilter(SaxUserRole.Params prmUserRole);
|
||||
public abstract long GetUserRoleCount(SaxUserRole.Params prmUserRole);
|
||||
public abstract List<SaxUserRole> GetUserRoleList(SaxUserRole.Params prmUserRole);
|
||||
public abstract DbResultSet ExecuteUserRoleQuery(List<ColumnDfn> columns, SaxUserRole.Params prmUserRole);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUserRoleDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserRole.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// User Display Name.
|
||||
case SaxUserRole.Column.User_DisplayName:
|
||||
{
|
||||
String userTitle = values.GetValue(GetUserRoleColumnDfn(SaxUserRole.Column.User_Title).DataName).ToString();
|
||||
String userFirstName = values.GetValue(GetUserRoleColumnDfn(SaxUserRole.Column.User_FirstName).DataName).ToString();
|
||||
String userLastName = values.GetValue(GetUserRoleColumnDfn(SaxUserRole.Column.User_LastName).DataName).ToString();
|
||||
value = new DataValue(SaxUserAccount.GetDisplayName(userTitle, userFirstName, userLastName));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// User Role.
|
||||
case SaxUserRole.Column.UserRole_Desc:
|
||||
{
|
||||
String userRoleCode = values.GetValue(column.DataName).ToString();
|
||||
value = new DataValue(UserRoles.GetDescForCode(userRoleCode));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxUserRole.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxUserRole.Column.Status_Desc:
|
||||
case SaxUserRole.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxUserRole.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxUserRole.Column.Status_Ind)
|
||||
value = new DataValue(SaxUserRole.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxAccountMgr : SaxItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxAccountMgr(SaxSessionContext sessionContext) :base(sessionContext)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxActivityMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Activity Mgr - Journalist Article
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxJournalistArticle CreateJournalistArticle(SysId userAccountIdJournalist);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool JournalistArticleExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxJournalistArticle.Params prmJournalistArticle = new SaxJournalistArticle.Params();
|
||||
prmJournalistArticle.IdsIncluded.Add(id);
|
||||
prmJournalistArticle.StatusCat = SaxJournalistArticle.StatusCat.Any;
|
||||
return GetJournalistArticleCount(prmJournalistArticle) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxJournalistArticle GetJournalistArticle(SaxJournalistArticle.Params prmJournalistArticle);
|
||||
public SaxJournalistArticle GetJournalistArticleById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxJournalistArticle.Params prmJournalistArticle = new SaxJournalistArticle.Params();
|
||||
prmJournalistArticle.IdsIncluded.Add(id);
|
||||
prmJournalistArticle.StatusCat = SaxJournalistArticle.StatusCat.Any;
|
||||
return GetJournalistArticle(prmJournalistArticle);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidJournalistArticle(SaxJournalistArticle journalistArticle)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (journalistArticle == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidJournalistArticleData(journalistArticle.GetData(), new SaxJournalistArticle.ErrField());
|
||||
}
|
||||
public virtual bool IsValidJournalistArticleData(SaxJournalistArticle.Data data, SaxJournalistArticle.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// User Account - Journalist.
|
||||
if (errField.UserAccountIdJournalist != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UserAccountIdJournalist))
|
||||
{
|
||||
errField.UserAccountIdJournalist = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User must be specified");
|
||||
}
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Region must be specified");
|
||||
}
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Sport must be specified");
|
||||
}
|
||||
|
||||
// Headline.
|
||||
if (errField.Headline != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Headline, "headline", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.JournalistArticle_Headline), true))
|
||||
{
|
||||
errField.Headline = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Summary.
|
||||
if (errField.Summary != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Summary, "summary", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.JournalistArticle_Summary), true))
|
||||
{
|
||||
errField.Summary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.JournalistArticle_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.JournalistArticle_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxJournalistArticle.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
// Associated data.
|
||||
|
||||
// User Account - Journalist.
|
||||
if (errField.UserAccountIdJournalist != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.UserAccountIdJournalist))
|
||||
{
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(data.UserAccountIdJournalist);
|
||||
prmUserAccount.ActiveRoles.Add(App.Sax.UserRole.Journalist);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.ActiveOnly;
|
||||
if (AccountMgr.GetUserAccountCount(prmUserAccount) < 1)
|
||||
{
|
||||
errField.UserAccountIdJournalist = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User must be active Journalist");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.Add(data.RegionIdPrimary);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.ActiveOnly;
|
||||
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IncludedIds.Add(data.SportIdPrimary);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.ActiveOnly;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// JournalistArticle database interface.
|
||||
public abstract bool InsertJournalistArticle(SaxJournalistArticle journalistArticle, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateJournalistArticle(SaxJournalistArticle journalistArticle, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool JournalistArticleCanBeDeleted(SaxJournalistArticle journalistArticle)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteJournalistArticle(SaxJournalistArticle journalistArticle, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// JournalistArticle list:
|
||||
public abstract ColumnDfn GetJournalistArticleColumnDfn(SaxJournalistArticle.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetJournalistArticleQueryFilter(SaxJournalistArticle.Params prmJournalistArticle);
|
||||
public abstract long GetJournalistArticleCount(SaxJournalistArticle.Params prmJournalistArticle);
|
||||
public abstract List<SaxJournalistArticle> GetJournalistArticleList(SaxJournalistArticle.Params prmJournalistArticle);
|
||||
public abstract DbResultSet ExecuteJournalistArticleQuery(List<ColumnDfn> columns, SaxJournalistArticle.Params prmJournalistArticle);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetJournalistArticleDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxJournalistArticle.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Journalist display name.
|
||||
case SaxJournalistArticle.Column.Journalist_DisplayName:
|
||||
{
|
||||
String userTitle = values.GetValue(GetJournalistArticleColumnDfn(SaxJournalistArticle.Column.Journalist_Title).DataName).ToString();
|
||||
String userFirstName = values.GetValue(GetJournalistArticleColumnDfn(SaxJournalistArticle.Column.Journalist_FirstName).DataName).ToString();
|
||||
String userLastName = values.GetValue(GetJournalistArticleColumnDfn(SaxJournalistArticle.Column.Journalist_LastName).DataName).ToString();
|
||||
value = new DataValue(SaxUserAccount.GetDisplayName(userTitle, userFirstName, userLastName));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Summary - limit to 200 chars.
|
||||
case SaxJournalistArticle.Column.Summary:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxJournalistArticle.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxJournalistArticle.Column.Status_Desc:
|
||||
case SaxJournalistArticle.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxJournalistArticle.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxJournalistArticle.Column.Status_Ind)
|
||||
value = new DataValue(SaxJournalistArticle.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxActivityMgr : SaxItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxActivityMgr(SaxSessionContext sessionContext) : base(sessionContext)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxItemDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Item Data Mgr - Item Sport
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxItemSport CreateItemSport ();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool ItemSportExistsById (SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxItemSport.Params prmItemSport = new SaxItemSport.Params();
|
||||
prmItemSport.IdsIncluded.Add(id);
|
||||
prmItemSport.StatusCat = SaxItemSport.StatusCat.Any;
|
||||
return GetItemSportCount(prmItemSport) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxItemSport GetItemSport (SaxItemSport.Params prmItemSport);
|
||||
public SaxItemSport GetItemSportById (SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxItemSport.Params prmItemSport = new SaxItemSport.Params();
|
||||
prmItemSport.IdsIncluded.Add(id);
|
||||
prmItemSport.StatusCat = SaxItemSport.StatusCat.Any;
|
||||
return GetItemSport(prmItemSport);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidItemSport (SaxItemSport itemSport)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (itemSport == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidItemSportData(itemSport.GetData(), new SaxItemSport.ErrField());
|
||||
}
|
||||
public virtual bool IsValidItemSportData (SaxItemSport.Data data, SaxItemSport.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Item Id.
|
||||
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore && !ItemId.IsValid(data.ItemId))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Item Id must be specified");
|
||||
}
|
||||
// Sport.
|
||||
if (errField.SportId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.SportId))
|
||||
{
|
||||
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Role must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.ItemSport_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.ItemSport_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxItemSport.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Item & Sport combination must be unique.
|
||||
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore && errField.SportId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (ItemId.IsValid(data.ItemId) && SysId.IsValid(data.SportId))
|
||||
{
|
||||
SaxItemSport.Params prmItemSport = new SaxItemSport.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmItemSport.IdsExcluded.Add(data.Id);
|
||||
prmItemSport.ItemIdsIncluded.Add(data.ItemId);
|
||||
prmItemSport.SportIdsIncluded.Add(data.SportId);
|
||||
prmItemSport.StatusCat = SaxItemSport.StatusCat.Any;
|
||||
if (GetItemSportCount(prmItemSport) > 0)
|
||||
{
|
||||
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Sport must be unique for item");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertItemSport (SaxItemSport itemSport, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateItemSport (SaxItemSport itemSport, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool ItemSportCanBeDeleted (SaxItemSport itemSport)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteItemSport (SaxItemSport itemSport, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetItemSportColumnDfn (SaxItemSport.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetItemSportQueryFilter (SaxItemSport.Params prmItemSport);
|
||||
public abstract long GetItemSportCount (SaxItemSport.Params prmItemSport);
|
||||
public abstract List<SaxItemSport> GetItemSportList (SaxItemSport.Params prmItemSport);
|
||||
public abstract DbResultSet ExecuteItemSportQuery (List<ColumnDfn> columns, SaxItemSport.Params prmItemSport);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetItemSportDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxItemSport.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxItemSport.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxItemSport.Column.Status_Desc:
|
||||
case SaxItemSport.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxItemSport.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxItemSport.Column.Status_Ind)
|
||||
value = new DataValue(SaxItemSport.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxItemDataMgr : SaxItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxItemDataMgr(SaxSessionContext sessionContext) : base(sessionContext)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Consoles;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxItemMgr : SacsItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SaxInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxItemMgr(SaxSessionContext sessionContext)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Boolean DebugMode { get { return SacsSystem.DebugMode; } }
|
||||
public SaxSessionContext SessionContext { get; }
|
||||
public ISacsDatabase CoreDatabase { get { return Internals.CoreDatabase; } }
|
||||
public IDatabaseInfo CoreDbInfo { get { return Internals.CreateCoreDbInfo(); } }
|
||||
// Business components.
|
||||
private SaxInternals Internals { get { if (internals == null) internals = new SaxInternals(SessionContext); return internals; } }
|
||||
// Consoles.
|
||||
public SaxDataCacheConsole DataCacheConsole { get { return Internals.DataCacheConsole; } }
|
||||
// Managers.
|
||||
public SaxReferenceMgr ReferenceMgr { get { return Internals.ReferenceMgr; } }
|
||||
public SaxAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
||||
public SaxActivityMgr ActivityMgr { get { return Internals.ActivityMgr; } }
|
||||
public SaxItemDataMgr ItemDataMgr { get { return Internals.ItemDataMgr; } }
|
||||
// Application codes.
|
||||
public List<TypeCodeDesc> RegionTypes { get { return Internals.RegionTypes; } }
|
||||
public List<TypeCodeDesc> UserRoles { get { return Internals.UserRoles; } }
|
||||
public List<TypeCodeDesc> OrganisationTypes { get { return Internals.OrganisationTypes; } }
|
||||
public List<TypeCodeDesc> OrganisationCategories { get { return Internals.OrganisationCategories; } }
|
||||
public List<TypeCodeDesc> OrganisationRoles { get { return Internals.OrganisationRoles; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -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.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Region
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxRegion CreateRegion();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool RegionExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.Add(id);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.Any;
|
||||
return GetRegionCount(prmRegion) == 1;
|
||||
}
|
||||
public bool RegionExistsByName(String name)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(name)) return false;
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.NameFull = name;
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.Any;
|
||||
return GetRegionCount(prmRegion) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxRegion GetRegion(SaxRegion.Params prmRegion);
|
||||
public SaxRegion GetRegionById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.Add(id);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.Any;
|
||||
return GetRegion(prmRegion);
|
||||
}
|
||||
public SaxRegion GetRegionByName(String name)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(name)) return null;
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.NameFull = name;
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.Any;
|
||||
return GetRegion(prmRegion);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidRegion(SaxRegion region)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (region == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidRegionData(region.GetData(), new SaxRegion.ErrField());
|
||||
}
|
||||
public virtual bool IsValidRegionData(SaxRegion.Data data, SaxRegion.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Region type.
|
||||
if (errField.RegionType != SacsHierarchyItem.ValidValue.Ignore && (int)data.RegionType < 1)
|
||||
{
|
||||
errField.RegionType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("type must be specified");
|
||||
}
|
||||
// ISO 2 code.
|
||||
if (errField.CountryIso2Code != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (data.RegionType == App.Sax.RegionType.Country && !IsValidValue(data.CountryIso2Code, "ISO2 code", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Region_CountryIso2Code), true, true))
|
||||
{
|
||||
errField.CountryIso2Code = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
else if ((int)data.RegionType > 0 && data.RegionType != App.Sax.RegionType.Country && !StringUtil.IsEmpty(data.CountryIso2Code))
|
||||
{
|
||||
errField.CountryIso2Code = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("ISO2 code is only relevant to countries");
|
||||
}
|
||||
}
|
||||
// Name.
|
||||
if (errField.Name != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Name, "name", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Region_Name), true))
|
||||
{
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parent region.
|
||||
if (errField.RegionIdParent != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdParent))
|
||||
{
|
||||
SaxRegion parentRegion = GetRegionById(data.RegionIdParent);
|
||||
if (parentRegion == null)
|
||||
{
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Parent region doesn't exist");
|
||||
}
|
||||
if (!SaxRegion.IsValidParentRegionType(data.RegionType, parentRegion.RegionType))
|
||||
{
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid parent region type");
|
||||
}
|
||||
}
|
||||
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Region_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Region_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxRegion.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Region database interface.
|
||||
public abstract bool InsertRegion(SaxRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateRegion(SaxRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool RegionCanBeDeleted(SaxRegion region)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteRegion(SaxRegion region, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Region list:
|
||||
public abstract ColumnDfn GetRegionColumnDfn(SaxRegion.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetRegionQueryFilter(SaxRegion.Params prmRegion);
|
||||
public abstract long GetRegionCount(SaxRegion.Params prmRegion);
|
||||
public abstract List<SaxRegion> GetRegionList(SaxRegion.Params prmRegion);
|
||||
public abstract DbResultSet ExecuteRegionQuery(List<ColumnDfn> columns, SaxRegion.Params prmRegion);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetRegionDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxRegion.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxRegion.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxRegion.Column.Status_Desc:
|
||||
case SaxRegion.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxRegion.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxRegion.Column.Status_Ind)
|
||||
value = new DataValue(SaxRegion.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Sport
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxSport CreateSport ();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool SportExistsById (SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IncludedIds.Add(id);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.Any;
|
||||
return GetSportCount(prmSport) == 1;
|
||||
}
|
||||
public bool SportExistsByName (String name)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(name)) return false;
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.NameFull = name;
|
||||
prmSport.StatusCat = SaxSport.StatusCat.Any;
|
||||
return GetSportCount(prmSport) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxSport GetSport (SaxSport.Params prmSport);
|
||||
public SaxSport GetSportById (SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IncludedIds.Add(id);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.Any;
|
||||
return GetSport(prmSport);
|
||||
}
|
||||
public SaxSport GetSportByName (String name)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(name)) return null;
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.NameFull = name;
|
||||
prmSport.StatusCat = SaxSport.StatusCat.Any;
|
||||
return GetSport(prmSport);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidSport (SaxSport sport)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (sport == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidSportData(sport.GetData(), new SaxSport.ErrField());
|
||||
}
|
||||
public virtual bool IsValidSportData (SaxSport.Data data, SaxSport.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// Name.
|
||||
if (errField.Name != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Name, "name", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Sport_Name), true))
|
||||
{
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Sport_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Sport_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxSport.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Sport database interface.
|
||||
public abstract bool InsertSport (SaxSport sport, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateSport (SaxSport sport, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool SportCanBeDeleted (SaxSport sport)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteSport (SaxSport sport, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Sport list:
|
||||
public abstract ColumnDfn GetSportColumnDfn (SaxSport.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetSportQueryFilter (SaxSport.Params prmSport);
|
||||
public abstract long GetSportCount (SaxSport.Params prmSport);
|
||||
public abstract List<SaxSport> GetSportList (SaxSport.Params prmSport);
|
||||
public abstract DbResultSet ExecuteSportQuery (List<ColumnDfn> columns, SaxSport.Params prmSport);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetSportDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxSport.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxSport.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxSport.Column.Status_Desc:
|
||||
case SaxSport.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxSport.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxSport.Column.Status_Ind)
|
||||
value = new DataValue(SaxSport.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxReferenceMgr : SaxItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxReferenceMgr(SaxSessionContext sessionContext) :base(sessionContext)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Web
|
||||
{
|
||||
//=======================================================================
|
||||
public static class SaxSessionContextHelper
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user