v1.3.0 Restructure Saxonite workspace and upgrade to .NET 10 (#1)
Move Saxonite’s projects into a dedicated `Workspace` folder and align the solution with .NET 10 and the current Common workspace. Update encryption integration, test project structure and coverage, and repository guidance and upgrade notes. - Relocate application and library projects while retaining Git rename history. - Split tests into Admin, Online, and Shared projects; add representative behavioral and serialization tests. - Update Common integration, application version, and repository documentation. Application version: 1.3.0 Reviewed-on: #1 Co-authored-by: andy <andy@sarand.com>
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,202 @@
|
||||
using Sarand.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 - C o n f i g
|
||||
//=======================================================================
|
||||
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 * 6;
|
||||
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 * 3;
|
||||
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 static class User
|
||||
{
|
||||
public static class Image
|
||||
{
|
||||
// Physical image maximum dimensions - reduced on upload.
|
||||
public static ushort WidthMax { get; } = 240;
|
||||
public static ushort HeightMax { get; } = 320;
|
||||
// Maximum image display dimensions - organisation list.
|
||||
public static ushort DisplayWidthMax_List { get; } = 48;
|
||||
public static ushort DisplayHeightMax_List { get; } = 48;
|
||||
// Maximum image display dimensions - organisation edit etc.
|
||||
public static ushort DisplayWidthMax_Item { get; } = 96;
|
||||
public static ushort DisplayHeightMax_Item { get; } = 96;
|
||||
}
|
||||
}
|
||||
public static class Organisation
|
||||
{
|
||||
public static class Logo
|
||||
{
|
||||
// Physical image maximum dimensions - reduced on upload.
|
||||
public static ushort WidthMax { get; } = 240;
|
||||
public static ushort HeightMax { get; } = 240;
|
||||
// Maximum image display dimensions - organisation list.
|
||||
public static ushort DisplayWidthMax_List { get; } = 48;
|
||||
public static ushort DisplayHeightMax_List { get; } = 48;
|
||||
// Maximum image display dimensions - organisation edit etc.
|
||||
public static ushort DisplayWidthMax_Item { get; } = 96;
|
||||
public static ushort DisplayHeightMax_Item { get; } = 96;
|
||||
}
|
||||
}
|
||||
public static class Activities
|
||||
{
|
||||
public static class Thumbnail
|
||||
{
|
||||
// Maximum image display dimensions - activity list (eg. Online Home page).
|
||||
public static ushort DisplayWidthMax_List { get; } = 180;
|
||||
public static ushort DisplayHeightMax_List { get; } = 120;
|
||||
}
|
||||
}
|
||||
public static class Articles
|
||||
{
|
||||
public static class Segments
|
||||
{
|
||||
public static ushort Max { get; } = 12;
|
||||
public static ushort CharsMax { get; } = 8000;
|
||||
}
|
||||
public static class Images
|
||||
{
|
||||
// Physical image maximum dimensions - reduced on upload.
|
||||
public static ushort WidthMax { get; } = 800;
|
||||
public static ushort HeightMax { get; } = 640;
|
||||
}
|
||||
public static ushort PublishMaxDaysBefore { get; } = 7;
|
||||
public static ushort PublishMaxDaysAhead { get; } = 10;
|
||||
}
|
||||
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(1) : TimeSpan.FromMinutes(15)).TotalMilliseconds;
|
||||
}
|
||||
public static class DataCommit
|
||||
{
|
||||
public static class IntervalSecs
|
||||
{
|
||||
public static int Initial { get; } = SacsSystem.DebugMode ? 10 : 10;
|
||||
public static int DataWaiting { get; } = SacsSystem.DebugMode ? 1 : 2;
|
||||
public static int NoDataWaiting { get; } = SacsSystem.DebugMode ? 5 : 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class DataCache
|
||||
{
|
||||
public static class RefreshIntervalSecs
|
||||
{
|
||||
public static int Initial { get; } = SacsSystem.DebugMode ? 2 : 5;
|
||||
public static int Periodic { get; } = SacsSystem.DebugMode ? 120 : 1800;
|
||||
}
|
||||
}
|
||||
public static class Search
|
||||
{
|
||||
public static class Users
|
||||
{
|
||||
public static ushort PageLengthDefault { get; } = 8;
|
||||
public static ushort PageLengthMax { get; } = 20;
|
||||
}
|
||||
public static class Organisations
|
||||
{
|
||||
public static ushort PageLengthDefault { get; } = 8;
|
||||
public static ushort PageLengthMax { get; } = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Api
|
||||
{
|
||||
public static class Session
|
||||
{
|
||||
public static class Cookie
|
||||
{
|
||||
/// <summary>Default cookie name: '.AspNetCore.Session'</summary>
|
||||
public static String Name { get; } = "Saxonite.Api.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(1) : TimeSpan.FromMinutes(5)).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
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(1) : TimeSpan.FromMinutes(5)).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
public static class Processes
|
||||
{
|
||||
public static class Scheduled
|
||||
{
|
||||
public static class UsgaGolfDataLookup
|
||||
{
|
||||
public static bool Enabled { get; set; } = SacsSystem.DebugMode ? true : true;
|
||||
public static int MinsBetweenExecution { get; set; } = SacsSystem.DebugMode ? 8 : 12;
|
||||
public static int HoursBetweenCountryLookup { get; set; } = SacsSystem.DebugMode ? 24 : 24 * 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class Links
|
||||
{
|
||||
public static class Targets
|
||||
{
|
||||
public static String Website { get; } = "sax-lnk-web";
|
||||
public static String Wikipedia { get; } = "sax-lnk-wikip";
|
||||
public static String Facebook { get; } = "sax-lnk-fbook";
|
||||
public static String Twitter { get; } = "sax-lnk-twit";
|
||||
public static String Instagram { get; } = "sax-lnk-insta";
|
||||
public static String LinkedIn { get; } = "sax-lnk-lnkin";
|
||||
public static String Article { get; } = "sax-art-lnk";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -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,149 @@
|
||||
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.3.0.0";
|
||||
// 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.Version.GetAppVersion " + ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Version history.
|
||||
//-------------------------------------------------------------------
|
||||
// 1.2.11 6-Jul-2023
|
||||
// - Organisation associations, admin download. [Feb24]
|
||||
// - Basic Api app. [Apr24]
|
||||
// - Admin Database and logs pages evolved. [May24]
|
||||
// - Online events upgraded. [Aug24]
|
||||
// 1.2.10 11-Oct-2022
|
||||
// - Online organisations display issue fixed.
|
||||
// - User Sport 'Preparing' options.
|
||||
// - User reports.
|
||||
// 1.2.9 12-Oct-2022
|
||||
// - Online Sports Experience update bug resolved.
|
||||
// - Sports Experience Awards.
|
||||
// - Profile Sports and Organisations on separate pages.
|
||||
// - User Eligibility.
|
||||
// 1.2.8 16-Jul-2022 Online Organisations - Select Region
|
||||
// - Fix problem with selecting organisation region.
|
||||
// - Admin - Organisation associations, in progress.
|
||||
// 1.2.7 9-Jun-2022 Online Activity list images
|
||||
// - Organisation logo and article thumbnail in article list.
|
||||
// 1.2.6 16-May-2022 Image resizing
|
||||
// - Profile and article images resized to maximum width/height.
|
||||
// - Organisation About and Facilities properties.
|
||||
// - Online profile and search organisation contact methods.
|
||||
// - Admin organisation address.
|
||||
// 1.2.5 20-Apr-2022 Article feedback
|
||||
// - Online Activity/Article feedback 5 stars, summary on Article list/popup.
|
||||
// - Online Activity filter.
|
||||
// - Admin - User - Sports listed.
|
||||
// 1.2.4 3-Mar-2022 View own articles.
|
||||
// - Online Home page lists own articlesregardless of sport/region.
|
||||
// - Admin System Database Table info.
|
||||
// 1.2.3 16-Feb-2022 User online activity.
|
||||
// - Record user last online.
|
||||
// - Online Organisation category select - remove Partner/Other.
|
||||
// - Online Article edit - clear publication on add, future publication.
|
||||
// - Admin Users - region selection.
|
||||
// 1.2.2 8-Dec-2021 Online Activities.
|
||||
// - Organisation Events.
|
||||
// 1.2.1 20-Nov-2021 Online Profile.
|
||||
// - Online Organisation edit.
|
||||
// 1.2.0 1-Nov-2021 'Admin' Organisation role
|
||||
// - 'Admin' Organisation role
|
||||
// - Azure App Service configuration.
|
||||
// 1.1.8 21-Oct-2021 Online Users Search
|
||||
// - Online Search - Users.
|
||||
// - Admin Account Users filter.
|
||||
// 1.1.7 14-Oct-2021 Online Organisation Search
|
||||
// - Online Profile Sport About & snags.
|
||||
// - Online Organisation Search.
|
||||
// - Admin Awaiting item counts on home page.
|
||||
// 1.1.6 19-Sep-2021 Online profile.
|
||||
// - Online burger menus - all menus with icons.
|
||||
// - Online Profile - About.
|
||||
// - Sport specific speciality label.
|
||||
// 1.1.5 19-Aug-2021 Profile Sport Experience.
|
||||
// - Online Profile Sport Experience.
|
||||
// 1.1.4 9-Aug-2021 Organisation Articles.
|
||||
// - Journalist Article renamed Article and Organisation Id added.
|
||||
// - Online Organisation Articles. Contact Gender & DOB.
|
||||
// - Admin Send Emails for User.
|
||||
// 1.1.3 23-Jul-2021 Online Members.
|
||||
// - Online Members.
|
||||
// - Admin organisation activation.
|
||||
// 1.1.2 10-Jul-2021 Organisation Request.
|
||||
// - Online Organisation Request.
|
||||
// - Admin data maintenance paging, organisations filter.
|
||||
// 1.1.1 2-Jul-2021 Add User fix.
|
||||
// - Admin fix Internals Region cache issue on null value.
|
||||
// - Optional user title.
|
||||
// 1.1.0 25-Jun-2021 Article publication. Admin Regions.
|
||||
// - Online Articles publication date and paging.
|
||||
// - Admin Region paging and parent selection.
|
||||
// 1.0.9 22-Jun-2021 Journalist Articles
|
||||
// - Online Article Images.
|
||||
// 1.0.8 15-Jun-2021 Online Article Content
|
||||
// - Journalist Articles styled content.
|
||||
// - Online home page click through activity for details with reaction.
|
||||
// 1.0.7 8-Jun-2021 Online Activities & Profile
|
||||
// - Style Online Activities by type.
|
||||
// - Profile Contact Image upload.
|
||||
// 1.0.6 2-Jun-2021 Online Profile
|
||||
// - Refresh Online Session with profile region and sport changes.
|
||||
// - Profile Sport - participation and officiating dropdowns.
|
||||
// 1.0.5 31-May-2021 Activity Index
|
||||
// - Admin Database Schema (Home) and Tables page.
|
||||
// - Online Account country, Home activities.
|
||||
// 1.0.4 20-May-2021 Online profile sports & opportunities
|
||||
// - Admin Organisation Region & Sport.
|
||||
// - Online Profile Sports - simple list with name.
|
||||
// - Online Organisation Opportunities.
|
||||
// 1.0.3 11-May-2021 Admin Organisation Members
|
||||
// - Admin data filters & styling, organisation members.
|
||||
// - Online Profile Organisations - simple list with name.
|
||||
// - 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,479 @@
|
||||
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
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <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,
|
||||
DataItemType,
|
||||
Gender,
|
||||
SportGrouping,
|
||||
SportSpecialityLabel,
|
||||
SportContactType,
|
||||
SportParticipating,
|
||||
SportPreparing,
|
||||
SportOfficiating,
|
||||
RegionType,
|
||||
EligibilityType,
|
||||
UserRole,
|
||||
Title,
|
||||
ImageType,
|
||||
OrganisationType,
|
||||
OrganisationCategory,
|
||||
OrganisationRole,
|
||||
AssociationType,
|
||||
AddressType,
|
||||
ContactMethod,
|
||||
EventType,
|
||||
OpportunityType,
|
||||
ActivityReaction,
|
||||
// Support.
|
||||
UserReportType,
|
||||
SupportItemProcessType
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum Application
|
||||
{
|
||||
Online = 100,
|
||||
Api = 400,
|
||||
Admin = 900,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum Environment
|
||||
{
|
||||
Development = 0,
|
||||
Staging = 50,
|
||||
Production = 90,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum InstanceType
|
||||
{
|
||||
Prod,
|
||||
UAT,
|
||||
QC,
|
||||
Dev
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum Database
|
||||
{
|
||||
Unknown = 0,
|
||||
Core = 10,
|
||||
Reference = 20,
|
||||
Support = 90,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Yes or No option.</summary>
|
||||
public enum YesNo
|
||||
{
|
||||
Unknown = 0,
|
||||
Yes,
|
||||
No
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
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,
|
||||
UserSport = 103,
|
||||
UserSportExperience = 104,
|
||||
UserEligibility = 105,
|
||||
Organisation = 120,
|
||||
// Activity data.
|
||||
ActivityIndex = 200,
|
||||
UserActivity = 202,
|
||||
Article = 210,
|
||||
OrganisationOpportunity = 220,
|
||||
OrganisationEvent = 225,
|
||||
// Item link components.
|
||||
ItemImage = 400,
|
||||
ItemAddress = 405,
|
||||
ItemAssociation = 410,
|
||||
ItemSport = 420,
|
||||
// Reference.
|
||||
Golf_UsgaCountry = 1000,
|
||||
Golf_UsgaProvince = 1001,
|
||||
Golf_UsgaFacility = 1002,
|
||||
Golf_UsgaCourse = 1003,
|
||||
Golf_UsgaMarker = 1004,
|
||||
// Support.
|
||||
UserReport = 9010,
|
||||
SupportItemProcess = 9020,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum Gender
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the numeric values - tied to database. */
|
||||
Female = 1,
|
||||
Male = 2,
|
||||
TransFemale = 10,
|
||||
TransMale = 11,
|
||||
Nonconforming = 20,
|
||||
PreferNotToSay = 99,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum RegionType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the numeric values - tied to database. */
|
||||
Universe = 1,
|
||||
Galaxy = 2,
|
||||
World = 5,
|
||||
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 = 50,
|
||||
/// <summary>STate - major subdivision of country, eg. US state.</summary>
|
||||
State = 70,
|
||||
/// <summary>Province - eg. GB County.</summary>
|
||||
Province = 90
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum EligibilityType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the numeric values - tied to database. */
|
||||
Birth = 10,
|
||||
Naturalised = 20,
|
||||
Parent = 100,
|
||||
Grandparent = 110,
|
||||
Passport = 200,
|
||||
Visa = 210,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>User Config</summary>
|
||||
public enum UserConfigType
|
||||
{
|
||||
/* Do not change the values - tied to database. */
|
||||
Online_Profile = 100,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>User roles</summary>
|
||||
public enum UserRole
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values - tied to database. */
|
||||
Journalist,
|
||||
SystemAdmin,
|
||||
SystemReviewer,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Sport Grouping</summary>
|
||||
public enum SportGrouping
|
||||
{
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Specific = 10,
|
||||
Banner = 20,
|
||||
Group = 30,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Sport Speciality Label</summary>
|
||||
public enum SportSpecialityLabel
|
||||
{
|
||||
Default = 0,
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Positon = 10,
|
||||
Discipline = 20,
|
||||
NotRelevant = 90,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Sport Contact Type</summary>
|
||||
public enum SportContactType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Coach = 100,
|
||||
Manager = 200,
|
||||
Agent = 300,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Sport Participating</summary>
|
||||
public enum SportParticipating
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Professional = 100,
|
||||
Regular = 200,
|
||||
Occasional = 300,
|
||||
Spectator = 400,
|
||||
Interested = 900,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Sport Preparing</summary>
|
||||
public enum SportPreparing
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Coach = 100,
|
||||
Manager = 200,
|
||||
Agent = 300,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Sport Officiating</summary>
|
||||
public enum SportOfficiating
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Professional = 100,
|
||||
Regular = 200,
|
||||
Occasional = 300,
|
||||
Interested = 900,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Titles - for Contact details.</summary>
|
||||
public enum Title
|
||||
{
|
||||
Unknown = 0,
|
||||
Mr,
|
||||
Mrs,
|
||||
Miss,
|
||||
Mx,
|
||||
Dr,
|
||||
Sir,
|
||||
Madam,
|
||||
Lord,
|
||||
Lady
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Image Types.</summary>
|
||||
public enum ImageType
|
||||
{
|
||||
Unknown,
|
||||
/// <summary>User's profile image.</summary>
|
||||
Avatar = 100,
|
||||
/// <summary>User's profile image, uploaded awaiting confirmation.</summary>
|
||||
Avatar_Upload = 101,
|
||||
/// <summary>Organisation's main logo.</summary>
|
||||
OrganisationLogo = 120,
|
||||
/// <summary>Organisation's main logo, uploaded awaiting confirmation.</summary>
|
||||
OrganisationLogo_Upload = 121,
|
||||
/// <summary>Article image.</summary>
|
||||
Article = 200,
|
||||
/// <summary>Article image uploaded, awaiting confirmation.</summary>
|
||||
Article_Upload = 201,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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,
|
||||
Society,
|
||||
Education,
|
||||
SportDepartment,
|
||||
Syndicate,
|
||||
/// <summary>Commercial partner</summary>
|
||||
Partner,
|
||||
/// <summary>Other</summary>
|
||||
Other,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Organisation roles</summary>
|
||||
public enum OrganisationRole
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Member,
|
||||
Admin,
|
||||
MemberAdmin,
|
||||
ScheduleAdmin,
|
||||
OpportunityAdmin,
|
||||
ArticleAdmin,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associations.
|
||||
|
||||
/// <summary>
|
||||
/// <u><b>Association type.</b></u>
|
||||
/// <br>- Affiliate - parent-child relationship.</br>
|
||||
/// <br>- Partner - equal sided relationship.</br>
|
||||
/// </summary>
|
||||
public enum AssociationType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the numeric values - tied to database. */
|
||||
/// <summary>'To' Affiliated to 'From' item. From/To: Organisation.</summary>
|
||||
Affiliate = 10,
|
||||
/// <summary>Partner items. From/To: Organisation.</summary>
|
||||
Partner = 20,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Association type option.
|
||||
/// <br>- Encompasses association type and 'direction' from the perspective of one of the organisations.</br>
|
||||
/// <br>- Affiliate relationship is either from the parent or to the child.</br>
|
||||
/// <br>- Partner relationships are directionless.</br>
|
||||
/// </summary>
|
||||
public enum AssociationTypeOption
|
||||
{
|
||||
Unknown = 0,
|
||||
AffiliateParent,
|
||||
AffiliateChild,
|
||||
Partner,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum AddressType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the numeric values - tied to database. */
|
||||
Location = 10,
|
||||
Home = 20,
|
||||
Office = 50,
|
||||
Delivery = 60,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum ContactMethodType
|
||||
{
|
||||
Unknown,
|
||||
Phone,
|
||||
Email,
|
||||
WebUrl,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public enum ContactMethod
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the numeric values or names - tied to database. */
|
||||
PhoneMain = 10,
|
||||
PhoneMobile = 20,
|
||||
PhoneHome = 30,
|
||||
PhoneOffice = 40,
|
||||
// Online.
|
||||
Email = 100,
|
||||
Website = 200,
|
||||
Wikipedia = 210,
|
||||
Location = 220,
|
||||
// Social media.
|
||||
LinkedIn = 300,
|
||||
Twitter = 310,
|
||||
Facebook = 320,
|
||||
Instagram = 330,
|
||||
YouTube = 340,
|
||||
Twitch = 350,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Event Type</summary>
|
||||
public enum EventType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values or codes - tied to database. */
|
||||
Playing,
|
||||
Training,
|
||||
Organisation,
|
||||
Social,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Opportunity Type</summary>
|
||||
public enum OpportunityType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values or codes - tied to database. */
|
||||
Playing,
|
||||
Official,
|
||||
Coaching,
|
||||
Volunteer,
|
||||
Staff,
|
||||
Board,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Activity Reaction</summary>
|
||||
public enum ActivityReaction
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values or codes - tied to database. */
|
||||
OK = 1,
|
||||
Good = 2,
|
||||
VeryGood = 3,
|
||||
Outstanding = 4,
|
||||
Exceptional = 5,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Support.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>User Report Type</summary>
|
||||
public enum UserReportType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values or codes - tied to database. */
|
||||
Enhancement = 10,
|
||||
Information = 20,
|
||||
Bug = 30,
|
||||
}
|
||||
|
||||
/// <summary>Support Item Process Type</summary>
|
||||
public enum SupportItemProcessType
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values or codes - tied to database. */
|
||||
OrganisationSchedulePopulation = 200,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxApplication_Base : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxApplication_Base()
|
||||
{
|
||||
App = this;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
App = null;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Globals.
|
||||
public static SaxApplication_Base App { get; private set; }
|
||||
public abstract SaxSystem System { get; }
|
||||
public abstract SaxConsoleHelper ConsoleHelper { get; }
|
||||
// Database.
|
||||
public abstract ISacsDatabase GetDatabase(SaxSessionContext sessionContext, Sax.Database databaseType);
|
||||
public abstract IDatabaseInfo CreateDbInfo(SaxSessionContext sessionContext, Sax.Database databaseType);
|
||||
// Application instance.
|
||||
public abstract Sax.InstanceType InstanceType { get; }
|
||||
public bool IsLiveHost() { return InstanceType == Sax.InstanceType.Prod; }
|
||||
public bool IsTestHost() { return InstanceType != Sax.InstanceType.Prod; }
|
||||
public bool IsDevHost() { return InstanceType == Sax.InstanceType.Dev; }
|
||||
public abstract String EnvironmentName { get; }
|
||||
// Email configuration.
|
||||
public abstract SaxEmailConfig EmailConfig { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,518 @@
|
||||
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 Tue 27-Aug-2024 19:41:31
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Base.App
|
||||
{
|
||||
public class SaxDbDfn_Reference
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Table identifiers.
|
||||
public enum TableIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
UsgaCountry,
|
||||
UsgaCourse,
|
||||
UsgaFacility,
|
||||
UsgaMarker,
|
||||
UsgaProvince,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Column identifiers.
|
||||
public enum ColumnIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
UsgaCountry_Id,
|
||||
UsgaCountry_CountryCode,
|
||||
UsgaCountry_CountryName,
|
||||
UsgaCountry_EntCountryCode,
|
||||
UsgaCountry_ProvincesUpdateAt,
|
||||
UsgaCountry_Notes,
|
||||
UsgaCountry_Flags,
|
||||
UsgaCountry_Status,
|
||||
UsgaCountry_CreateOn,
|
||||
UsgaCountry_CreateBy,
|
||||
UsgaCountry_CreateHost,
|
||||
UsgaCountry_UpdateOn,
|
||||
UsgaCountry_UpdateBy,
|
||||
UsgaCountry_UpdateHost,
|
||||
UsgaCourse_Id,
|
||||
UsgaCourse_FacilityId,
|
||||
UsgaCourse_UsgaCourseId,
|
||||
UsgaCourse_LegacyCrpCourseId,
|
||||
UsgaCourse_Caption,
|
||||
UsgaCourse_CourseName,
|
||||
UsgaCourse_FullName,
|
||||
UsgaCourse_Address1,
|
||||
UsgaCourse_Address2,
|
||||
UsgaCourse_City,
|
||||
UsgaCourse_PostalCode,
|
||||
UsgaCourse_Latitude,
|
||||
UsgaCourse_Longitude,
|
||||
UsgaCourse_Email,
|
||||
UsgaCourse_Telephone,
|
||||
UsgaCourse_MarkersUpdateAt,
|
||||
UsgaCourse_MarkersData,
|
||||
UsgaCourse_Notes,
|
||||
UsgaCourse_Flags,
|
||||
UsgaCourse_Status,
|
||||
UsgaCourse_CreateOn,
|
||||
UsgaCourse_CreateBy,
|
||||
UsgaCourse_CreateHost,
|
||||
UsgaCourse_UpdateOn,
|
||||
UsgaCourse_UpdateBy,
|
||||
UsgaCourse_UpdateHost,
|
||||
UsgaFacility_Id,
|
||||
UsgaFacility_ProvinceId,
|
||||
UsgaFacility_UsgaFacilityId,
|
||||
UsgaFacility_FacilityName,
|
||||
UsgaFacility_Address1,
|
||||
UsgaFacility_Address2,
|
||||
UsgaFacility_City,
|
||||
UsgaFacility_PostalCode,
|
||||
UsgaFacility_Latitude,
|
||||
UsgaFacility_Longitude,
|
||||
UsgaFacility_Email,
|
||||
UsgaFacility_Telephone,
|
||||
UsgaFacility_Notes,
|
||||
UsgaFacility_Flags,
|
||||
UsgaFacility_Status,
|
||||
UsgaFacility_CreateOn,
|
||||
UsgaFacility_CreateBy,
|
||||
UsgaFacility_CreateHost,
|
||||
UsgaFacility_UpdateOn,
|
||||
UsgaFacility_UpdateBy,
|
||||
UsgaFacility_UpdateHost,
|
||||
UsgaMarker_Id,
|
||||
UsgaMarker_CourseId,
|
||||
UsgaMarker_UsgaMarkerId,
|
||||
UsgaMarker_Caption,
|
||||
UsgaMarker_Holes,
|
||||
UsgaMarker_HolesCaption,
|
||||
UsgaMarker_Tee,
|
||||
UsgaMarker_Gender,
|
||||
UsgaMarker_SlopeRating,
|
||||
UsgaMarker_Par,
|
||||
UsgaMarker_CourseRating,
|
||||
UsgaMarker_BogeyRating,
|
||||
UsgaMarker_Length,
|
||||
UsgaMarker_Notes,
|
||||
UsgaMarker_Flags,
|
||||
UsgaMarker_Status,
|
||||
UsgaMarker_CreateOn,
|
||||
UsgaMarker_CreateBy,
|
||||
UsgaMarker_CreateHost,
|
||||
UsgaMarker_UpdateOn,
|
||||
UsgaMarker_UpdateBy,
|
||||
UsgaMarker_UpdateHost,
|
||||
UsgaProvince_Id,
|
||||
UsgaProvince_CountryId,
|
||||
UsgaProvince_ProvinceCode,
|
||||
UsgaProvince_EntProvinceCode,
|
||||
UsgaProvince_ProvinceName,
|
||||
UsgaProvince_CoursesUpdateAt,
|
||||
UsgaProvince_Notes,
|
||||
UsgaProvince_Flags,
|
||||
UsgaProvince_Status,
|
||||
UsgaProvince_CreateOn,
|
||||
UsgaProvince_CreateBy,
|
||||
UsgaProvince_CreateHost,
|
||||
UsgaProvince_UpdateOn,
|
||||
UsgaProvince_UpdateBy,
|
||||
UsgaProvince_UpdateHost,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 5;
|
||||
private static readonly int columnCount = 98;
|
||||
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].Name;
|
||||
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
|
||||
return tableName;
|
||||
}
|
||||
public static String GetTableNameQual (TableIdx table, bool delimitReservedWords = true)
|
||||
{
|
||||
int tableIdx = (int)table - 1;
|
||||
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
|
||||
String schemaName = tables[(int)tableIdx].Schema;
|
||||
String tableName = tables[(int)tableIdx].Name;
|
||||
if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); tableName = DelimitReservedWord(tableName); }
|
||||
return (StringUtil.IsBlank(schemaName) ? "" : schemaName + ".") + 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_Reference.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)
|
||||
{
|
||||
return IsReservedWord(word) ? DelimitWord(word) : word;
|
||||
}
|
||||
public static String DelimitWord (String word)
|
||||
{
|
||||
return DelimitWord(word, reservedWordDelim);
|
||||
}
|
||||
public static String DelimitWord (String word, DbReservedWordDelim wordDelim)
|
||||
{
|
||||
switch (wordDelim)
|
||||
{
|
||||
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_Reference.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 class TableDfn
|
||||
{
|
||||
internal String Schema { get; set; }
|
||||
internal String Name { get; set; }
|
||||
internal TableDfn (String schema, String name)
|
||||
{
|
||||
this.Schema= schema;
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
private static readonly TableDfn[] tables =
|
||||
{
|
||||
new TableDfn("golf","UsgaCountry"),
|
||||
new TableDfn("golf","UsgaCourse"),
|
||||
new TableDfn("golf","UsgaFacility"),
|
||||
new TableDfn("golf","UsgaMarker"),
|
||||
new TableDfn("golf","UsgaProvince"),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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",5,-5,true,19),
|
||||
new ColumnDfn(1,"CountryCode",0,12,false,10),
|
||||
new ColumnDfn(1,"CountryName",0,-9,false,200),
|
||||
new ColumnDfn(1,"EntCountryCode",0,12,false,10),
|
||||
new ColumnDfn(1,"ProvincesUpdateAt",9,93,false,16),
|
||||
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",5,-5,true,19),
|
||||
new ColumnDfn(2,"FacilityId",5,-5,false,19),
|
||||
new ColumnDfn(2,"UsgaCourseId",5,-5,false,19),
|
||||
new ColumnDfn(2,"LegacyCrpCourseId",5,-5,false,19),
|
||||
new ColumnDfn(2,"Caption",0,-9,false,200),
|
||||
new ColumnDfn(2,"CourseName",0,-9,false,200),
|
||||
new ColumnDfn(2,"FullName",0,-9,false,200),
|
||||
new ColumnDfn(2,"Address1",0,-9,false,200),
|
||||
new ColumnDfn(2,"Address2",0,-9,false,200),
|
||||
new ColumnDfn(2,"City",0,-9,false,200),
|
||||
new ColumnDfn(2,"PostalCode",0,-9,false,20),
|
||||
new ColumnDfn(2,"Latitude",8,3,false,9),
|
||||
new ColumnDfn(2,"Longitude",8,3,false,9),
|
||||
new ColumnDfn(2,"Email",0,-9,false,200),
|
||||
new ColumnDfn(2,"Telephone",0,-9,false,200),
|
||||
new ColumnDfn(2,"MarkersUpdateAt",9,93,false,16),
|
||||
new ColumnDfn(2,"MarkersData",0,-9,false,0),
|
||||
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",5,-5,true,19),
|
||||
new ColumnDfn(3,"ProvinceId",5,-5,false,19),
|
||||
new ColumnDfn(3,"UsgaFacilityId",5,-5,false,19),
|
||||
new ColumnDfn(3,"FacilityName",0,-9,false,200),
|
||||
new ColumnDfn(3,"Address1",0,-9,false,200),
|
||||
new ColumnDfn(3,"Address2",0,-9,false,200),
|
||||
new ColumnDfn(3,"City",0,-9,false,200),
|
||||
new ColumnDfn(3,"PostalCode",0,-9,false,20),
|
||||
new ColumnDfn(3,"Latitude",8,3,false,9),
|
||||
new ColumnDfn(3,"Longitude",8,3,false,9),
|
||||
new ColumnDfn(3,"Email",0,-9,false,200),
|
||||
new ColumnDfn(3,"Telephone",0,-9,false,200),
|
||||
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",5,-5,true,19),
|
||||
new ColumnDfn(4,"CourseId",5,-5,false,19),
|
||||
new ColumnDfn(4,"UsgaMarkerId",5,-5,false,19),
|
||||
new ColumnDfn(4,"Caption",0,-9,false,200),
|
||||
new ColumnDfn(4,"Holes",3,5,false,5),
|
||||
new ColumnDfn(4,"HolesCaption",0,-9,false,200),
|
||||
new ColumnDfn(4,"Tee",0,-9,false,200),
|
||||
new ColumnDfn(4,"Gender",0,-9,false,32),
|
||||
new ColumnDfn(4,"SlopeRating",3,5,false,5),
|
||||
new ColumnDfn(4,"Par",3,5,false,5),
|
||||
new ColumnDfn(4,"CourseRating",8,3,false,9),
|
||||
new ColumnDfn(4,"BogeyRating",8,3,false,9),
|
||||
new ColumnDfn(4,"Length",3,5,false,5),
|
||||
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",5,-5,true,19),
|
||||
new ColumnDfn(5,"CountryId",5,-5,false,19),
|
||||
new ColumnDfn(5,"ProvinceCode",0,12,false,20),
|
||||
new ColumnDfn(5,"EntProvinceCode",0,12,false,20),
|
||||
new ColumnDfn(5,"ProvinceName",0,-9,false,200),
|
||||
new ColumnDfn(5,"CoursesUpdateAt",9,93,false,16),
|
||||
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),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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,376 @@
|
||||
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 Thu 22-Aug-2024 18:00:17
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Base.App
|
||||
{
|
||||
public class SaxDbDfn_Support
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Table identifiers.
|
||||
public enum TableIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
UserReport,
|
||||
UserReportComment,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Column identifiers.
|
||||
public enum ColumnIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
UserReport_Id,
|
||||
UserReport_UserAccountId,
|
||||
UserReport_ReportType,
|
||||
UserReport_Title,
|
||||
UserReport_Report,
|
||||
UserReport_RecordedOn,
|
||||
UserReport_ReportData,
|
||||
UserReport_Notes,
|
||||
UserReport_Flags,
|
||||
UserReport_Status,
|
||||
UserReport_CreateOn,
|
||||
UserReport_CreateBy,
|
||||
UserReport_CreateHost,
|
||||
UserReport_UpdateOn,
|
||||
UserReport_UpdateBy,
|
||||
UserReport_UpdateHost,
|
||||
UserReportComment_Id,
|
||||
UserReportComment_UserReportId,
|
||||
UserReportComment_RecordedAt,
|
||||
UserReportComment_UserAccountId,
|
||||
UserReportComment_CommentData,
|
||||
UserReportComment_Notes,
|
||||
UserReportComment_Flags,
|
||||
UserReportComment_Status,
|
||||
UserReportComment_CreateOn,
|
||||
UserReportComment_CreateBy,
|
||||
UserReportComment_CreateHost,
|
||||
UserReportComment_UpdateOn,
|
||||
UserReportComment_UpdateBy,
|
||||
UserReportComment_UpdateHost,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 2;
|
||||
private static readonly int columnCount = 30;
|
||||
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].Name;
|
||||
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
|
||||
return tableName;
|
||||
}
|
||||
public static String GetTableNameQual (TableIdx table, bool delimitReservedWords = true)
|
||||
{
|
||||
int tableIdx = (int)table - 1;
|
||||
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
|
||||
String schemaName = tables[(int)tableIdx].Schema;
|
||||
String tableName = tables[(int)tableIdx].Name;
|
||||
if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); tableName = DelimitReservedWord(tableName); }
|
||||
return (StringUtil.IsBlank(schemaName) ? "" : schemaName + ".") + 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_Support.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)
|
||||
{
|
||||
return IsReservedWord(word) ? DelimitWord(word) : word;
|
||||
}
|
||||
public static String DelimitWord (String word)
|
||||
{
|
||||
return DelimitWord(word, reservedWordDelim);
|
||||
}
|
||||
public static String DelimitWord (String word, DbReservedWordDelim wordDelim)
|
||||
{
|
||||
switch (wordDelim)
|
||||
{
|
||||
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_Support.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 class TableDfn
|
||||
{
|
||||
internal String Schema { get; set; }
|
||||
internal String Name { get; set; }
|
||||
internal TableDfn (String schema, String name)
|
||||
{
|
||||
this.Schema= schema;
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
private static readonly TableDfn[] tables =
|
||||
{
|
||||
new TableDfn("dbo","UserReport"),
|
||||
new TableDfn("dbo","UserReportComment"),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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",5,-5,true,19),
|
||||
new ColumnDfn(1,"UserAccountId",4,4,false,10),
|
||||
new ColumnDfn(1,"ReportType",3,5,false,5),
|
||||
new ColumnDfn(1,"Title",0,-9,false,1000),
|
||||
new ColumnDfn(1,"Report",0,-9,false,0),
|
||||
new ColumnDfn(1,"RecordedOn",9,93,false,16),
|
||||
new ColumnDfn(1,"ReportData",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",5,-5,true,19),
|
||||
new ColumnDfn(2,"UserReportId",5,-5,false,19),
|
||||
new ColumnDfn(2,"RecordedAt",9,93,false,23),
|
||||
new ColumnDfn(2,"UserAccountId",4,4,false,10),
|
||||
new ColumnDfn(2,"CommentData",0,-9,false,0),
|
||||
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),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 { return App.System; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Application.
|
||||
public static SaxApplication_Base App { get { return SaxApplication_Base.App; } }
|
||||
public static SaxConsoleHelper ConsoleHelper { get { return App.ConsoleHelper; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
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;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.Mgr.Support;
|
||||
using Saxonite.Net.Standard.Base.Mgr.Reference;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxInternals : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private class DataMembers
|
||||
{
|
||||
public bool useDataCacheConsole;
|
||||
}
|
||||
private readonly DataMembers data = new DataMembers();
|
||||
private class Managers
|
||||
{
|
||||
public SaxReferenceMgr referenceMgr = null;
|
||||
public SaxAccountMgr accountMgr = null;
|
||||
public SaxActivityMgr activityMgr = null;
|
||||
public SaxItemDataMgr itemDataMgr = null;
|
||||
// Reference.
|
||||
public SaxReferenceGolfMgr referenceGolfMgr = null;
|
||||
// Support.
|
||||
public SaxSupportMgr supportMgr = null;
|
||||
}
|
||||
private readonly Managers mgr = new Managers();
|
||||
private class Consoles
|
||||
{
|
||||
public SaxActivityConsole activityConsole;
|
||||
public SaxEmailConsole emailConsole;
|
||||
}
|
||||
private readonly Consoles con = new Consoles();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaxInternals(SaxSessionContext sessionContext, bool useDataCacheConsole = true)
|
||||
{
|
||||
if (sessionContext == null)
|
||||
throw new NotSupportedException("Unable to create Internals with invalid session context");
|
||||
data.useDataCacheConsole = useDataCacheConsole;
|
||||
System = SaxGlobals.System;
|
||||
SessionContext = sessionContext;
|
||||
|
||||
try
|
||||
{
|
||||
// Check for data cache.
|
||||
// NB Must not do this if Internals constructed by the DataCache console itself as cached data will not be requested from here.
|
||||
if (useDataCacheConsole)
|
||||
{
|
||||
// Inside try..catch as Admin app throws exception on GetDataCacheConsole().
|
||||
SaxDataCacheConsole dataCacheConsole = SaxGlobals.ConsoleHelper.GetDataCacheConsole(SessionContext);
|
||||
if (dataCacheConsole != null)
|
||||
dataCacheConsole.PopulateCachedDataToInternals(this);
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
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;
|
||||
if (mgr.referenceGolfMgr != null) mgr.referenceGolfMgr.Dispose(); mgr.referenceGolfMgr = null;
|
||||
if (mgr.supportMgr != null) mgr.supportMgr.Dispose(); mgr.supportMgr = null;
|
||||
if (con.activityConsole != null) con.activityConsole.Dispose(); con.activityConsole = null;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public bool DebugMode { get; } = SacsSystem.DebugMode;
|
||||
public SaxSystem System { get; }
|
||||
public SaxSessionContext SessionContext { get; }
|
||||
public ISacsDatabase CoreDatabase { get { return SaxGlobals.App.GetDatabase(SessionContext, Sax.Database.Core); } }
|
||||
public IDatabaseInfo CreateCoreDbInfo()
|
||||
{
|
||||
return SaxGlobals.App.CreateDbInfo(SessionContext, Sax.Database.Core);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// System codes.
|
||||
private readonly Dictionary<Sax.CodeType, List<TypeCodeDesc>> codeTypes = new Dictionary<Sax.CodeType, List<TypeCodeDesc>>();
|
||||
public List<TypeCodeDesc> GetCodesOfType(Sax.CodeType codeType)
|
||||
{
|
||||
if (!codeTypes.ContainsKey(codeType))
|
||||
codeTypes.Add(codeType, SaxSystem.GetCodesOfType(codeType));
|
||||
return new List<TypeCodeDesc>(codeTypes[codeType]);
|
||||
}
|
||||
public List<TypeCodeDesc> DataItemTypeCodes { get { return GetCodesOfType(Sax.CodeType.DataItemType); } }
|
||||
public List<TypeCodeDesc> YesNoCodes { get { return GetCodesOfType(Sax.CodeType.YesNo); } }
|
||||
public List<TypeCodeDesc> GenderCodes { get { return GetCodesOfType(Sax.CodeType.Gender); } }
|
||||
public List<TypeCodeDesc> SportGroupingCodes { get { return GetCodesOfType(Sax.CodeType.SportGrouping); } }
|
||||
public List<TypeCodeDesc> SportSpecialityLabelCodes { get { return GetCodesOfType(Sax.CodeType.SportSpecialityLabel); } }
|
||||
public List<TypeCodeDesc> SportContactTypeCodes { get { return GetCodesOfType(Sax.CodeType.SportContactType); } }
|
||||
public List<TypeCodeDesc> SportParticipatingCodes { get { return GetCodesOfType(Sax.CodeType.SportParticipating); } }
|
||||
public List<TypeCodeDesc> SportPreparingCodes { get { return GetCodesOfType(Sax.CodeType.SportPreparing); } }
|
||||
public List<TypeCodeDesc> SportOfficiatingCodes { get { return GetCodesOfType(Sax.CodeType.SportOfficiating); } }
|
||||
public List<TypeCodeDesc> RegionTypeCodes { get { return GetCodesOfType(Sax.CodeType.RegionType); } }
|
||||
public List<TypeCodeDesc> EligibilityTypeCodes { get { return GetCodesOfType(Sax.CodeType.EligibilityType); } }
|
||||
public List<TypeCodeDesc> UserRoleCodes { get { return GetCodesOfType(Sax.CodeType.UserRole); } }
|
||||
public List<TypeCodeDesc> OrganisationTypeCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationType); } }
|
||||
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationCategory); } }
|
||||
public List<TypeCodeDesc> OrganisationRoleCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationRole); } }
|
||||
public List<TypeCodeDesc> AssociationTypeCodes { get { return GetCodesOfType(Sax.CodeType.AssociationType); } }
|
||||
public List<TypeCodeDesc> AddressTypeCodes { get { return GetCodesOfType(Sax.CodeType.AddressType); } }
|
||||
public List<TypeCodeDesc> ContactMethodCodes { get { return GetCodesOfType(Sax.CodeType.ContactMethod); } }
|
||||
public List<TypeCodeDesc> EventTypeCodes { get { return GetCodesOfType(Sax.CodeType.EventType); } }
|
||||
public List<TypeCodeDesc> OpportunityTypeCodes { get { return GetCodesOfType(Sax.CodeType.OpportunityType); } }
|
||||
public List<TypeCodeDesc> ActivityReactionCodes { get { return GetCodesOfType(Sax.CodeType.ActivityReaction); } }
|
||||
// Support.
|
||||
public List<TypeCodeDesc> UserReportTypeCodes { get { return GetCodesOfType(Sax.CodeType.UserReportType); } }
|
||||
public List<TypeCodeDesc> SupportItemProcessTypeCodes { get { return GetCodesOfType(Sax.CodeType.SupportItemProcessType); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Consoles.
|
||||
public SaxConsoleHelper ConsoleHelper { get { return SaxGlobals.App.ConsoleHelper; } }
|
||||
public SaxDataCacheConsole DataCacheConsole { get { return SaxGlobals.ConsoleHelper.GetDataCacheConsole(SessionContext); } }
|
||||
public SaxSessionDataConsole SessionDataConsole { get { return SaxGlobals.ConsoleHelper.GetSessionDataConsole(SessionContext); } }
|
||||
public SaxActivityConsole ActivityConsole { get { if (con.activityConsole == null) con.activityConsole = ConsoleHelper.CreateActivityConsole(SessionContext); return con.activityConsole; } }
|
||||
public SaxEmailConsole EmailConsole { get { if (con.emailConsole == null) con.emailConsole = ConsoleHelper.CreateEmailConsole(SessionContext); return con.emailConsole; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Managers.
|
||||
public SaxReferenceMgr ReferenceMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.referenceMgr == null)
|
||||
mgr.referenceMgr = System.CreateReferenceMgr(SessionContext, this);
|
||||
return mgr.referenceMgr;
|
||||
}
|
||||
}
|
||||
public SaxAccountMgr AccountMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.accountMgr == null)
|
||||
mgr.accountMgr = System.CreateAccountMgr(SessionContext, this);
|
||||
return mgr.accountMgr;
|
||||
}
|
||||
}
|
||||
public SaxActivityMgr ActivityMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.activityMgr == null)
|
||||
mgr.activityMgr = System.CreateActivityMgr(SessionContext, this);
|
||||
return mgr.activityMgr;
|
||||
}
|
||||
}
|
||||
public SaxItemDataMgr ItemDataMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.itemDataMgr == null)
|
||||
mgr.itemDataMgr = System.CreateItemDataMgr(SessionContext, this);
|
||||
return mgr.itemDataMgr;
|
||||
}
|
||||
}
|
||||
public SaxReferenceGolfMgr ReferenceGolfMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.referenceGolfMgr == null)
|
||||
mgr.referenceGolfMgr = System.CreateReferenceGolfMgr(SessionContext, this);
|
||||
return mgr.referenceGolfMgr;
|
||||
}
|
||||
}
|
||||
public SaxSupportMgr SupportMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.supportMgr == null)
|
||||
mgr.supportMgr = System.CreateSupportMgr(SessionContext, this);
|
||||
return mgr.supportMgr;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Regions.
|
||||
// NB Online application caches regions and sports so these may be pre-populated in the Internals.
|
||||
// Otherwise they are populated on first request.
|
||||
private readonly Dictionary<SysId, SaxRegion.Data> regionCache = new Dictionary<SysId, SaxRegion.Data>();
|
||||
private bool regionCacheFullyPopulated = false;
|
||||
public void PopulateRegionCache(List<SaxRegion.Data> regions)
|
||||
{
|
||||
foreach (SaxRegion.Data regionData in regions)
|
||||
regionCache[regionData.Id] = regionData.Clone();
|
||||
regionCacheFullyPopulated = true;
|
||||
//if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}(regions) Regions populated: {regionCache.Count}.");
|
||||
}
|
||||
public void RefreshRegionCache()
|
||||
{
|
||||
if (regionCacheFullyPopulated) return;
|
||||
DateTime startedAt = DateTime.Now;
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.NotDeleted;
|
||||
int regionsQueried = 0;
|
||||
foreach (SaxRegion region in ReferenceMgr.GetRegionList(prmRegion))
|
||||
{
|
||||
regionsQueried++;
|
||||
regionCache[region.Id] = region.GetData();
|
||||
region.Dispose();
|
||||
}
|
||||
regionCacheFullyPopulated = true;
|
||||
SaLogger.Debug($"{SysUtil.Fn} Regions queried: {regionsQueried}. Regions in cache: {regionCache.Count}. Elapsed: {DateUtil.FormatNumberOfSeconds((DateTime.Now - startedAt).TotalSeconds)}.");
|
||||
}
|
||||
private void QueryRegionsToCache(List<SysId> regionsIds)
|
||||
{
|
||||
if (regionCacheFullyPopulated) return;
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.AddRange(regionsIds.FindAll(item => SysId.IsValid(item) && !regionCache.ContainsKey(item)));
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.NotDeleted;
|
||||
if (prmRegion.IdsIncluded.Count > 0)
|
||||
{
|
||||
// At least one region needs to be retrieved.
|
||||
DateTime startedAt = DateTime.Now;
|
||||
int regionsQueried = 0;
|
||||
foreach (SaxRegion region in ReferenceMgr.GetRegionList(prmRegion))
|
||||
{
|
||||
regionsQueried++;
|
||||
regionCache[region.Id] = region.GetData();
|
||||
region.Dispose();
|
||||
}
|
||||
SaLogger.Debug($"{SysUtil.Fn}(regionIds) Regions queried: {regionsQueried}. Regions in cache: {regionCache.Count}. Elapsed: {DateUtil.FormatNumberOfSeconds((DateTime.Now - startedAt).TotalSeconds)}.");
|
||||
}
|
||||
}
|
||||
public SaxRegion.Data GetRegion(SysId regionId)
|
||||
{
|
||||
QueryRegionsToCache(new List<SysId>() { regionId });
|
||||
return regionCache.GetValue(regionId, null);
|
||||
}
|
||||
public List<SaxRegion.Data> GetRegions(List<SysId> regionIds)
|
||||
{
|
||||
List<SaxRegion.Data> regions = new List<SaxRegion.Data>();
|
||||
QueryRegionsToCache(regionIds);
|
||||
foreach (SysId regionId in regionIds)
|
||||
{
|
||||
if (!SysId.IsValid(regionId)) continue;
|
||||
SaxRegion.Data region = regionCache.GetValue(regionId, null);
|
||||
if (region != null)
|
||||
regions.Add(region);
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Sports.
|
||||
// NB Online application caches sports and sports so these may be pre-populated in the Internals.
|
||||
// Otherwise they are populated on first request.
|
||||
private readonly Dictionary<SysId, SaxSport.Data> sportCache = new Dictionary<SysId, SaxSport.Data>();
|
||||
private bool sportCacheFullyPopulated = false;
|
||||
public void PopulateSportCache(List<SaxSport.Data> sports)
|
||||
{
|
||||
foreach (SaxSport.Data sportData in sports)
|
||||
sportCache[sportData.Id] = sportData.Clone();
|
||||
sportCacheFullyPopulated = true;
|
||||
//if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}(sports) Sports populated: {sportCache.Count}.");
|
||||
}
|
||||
public void RefreshSportCache()
|
||||
{
|
||||
if (sportCacheFullyPopulated) return;
|
||||
DateTime startedAt = DateTime.Now;
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
int sportsQueried = 0;
|
||||
foreach (SaxSport sport in ReferenceMgr.GetSportList(prmSport))
|
||||
{
|
||||
sportsQueried++;
|
||||
sportCache[sport.Id] = sport.GetData();
|
||||
sport.Dispose();
|
||||
}
|
||||
sportCacheFullyPopulated = true;
|
||||
SaLogger.Debug($"{SysUtil.Fn} Sports queried: {sportsQueried}. Sports in cache: {sportCache.Count}. Elapsed: {DateUtil.FormatNumberOfSeconds((DateTime.Now - startedAt).TotalSeconds)}.");
|
||||
}
|
||||
private void QuerySportsToCache(List<SysId> sportsIds)
|
||||
{
|
||||
if (sportCacheFullyPopulated) return;
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.AddRange(sportsIds.FindAll(item => SysId.IsValid(item) && !sportCache.ContainsKey(item)));
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
if (prmSport.IdsIncluded.Count > 0)
|
||||
{
|
||||
// At least one sport needs to be retrieved.
|
||||
DateTime startedAt = DateTime.Now;
|
||||
int sportsQueried = 0;
|
||||
foreach (SaxSport sport in ReferenceMgr.GetSportList(prmSport))
|
||||
{
|
||||
sportsQueried++;
|
||||
sportCache[sport.Id] = sport.GetData();
|
||||
sport.Dispose();
|
||||
}
|
||||
SaLogger.Debug($"{SysUtil.Fn}(sportIds) Sports queried: {sportsQueried}. Sports in cache: {sportCache.Count}. Elapsed: {DateUtil.FormatNumberOfSeconds((DateTime.Now - startedAt).TotalSeconds)}.");
|
||||
}
|
||||
}
|
||||
public SaxSport.Data GetSport(SysId sportId)
|
||||
{
|
||||
QuerySportsToCache(new List<SysId>() { sportId });
|
||||
return sportCache.GetValue(sportId, null);
|
||||
}
|
||||
public List<SaxSport.Data> GetSports(List<SysId> sportIds)
|
||||
{
|
||||
List<SaxSport.Data> sports = new List<SaxSport.Data>();
|
||||
QuerySportsToCache(sportIds);
|
||||
foreach (SysId sportId in sportIds)
|
||||
{
|
||||
if (!SysId.IsValid(sportId)) continue;
|
||||
SaxSport.Data sport = sportCache.GetValue(sportId, null);
|
||||
if (sport != null)
|
||||
sports.Add(sport);
|
||||
}
|
||||
return sports;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Common Data Components
|
||||
//-------------------------------------------------------------------
|
||||
// User Accounts.
|
||||
private readonly Dictionary<SysId, SaxUserAccount> userAccountCache = new Dictionary<SysId, SaxUserAccount>();
|
||||
public SaxUserAccount GetUserAccount(SysId userAccountId)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId)) return null;
|
||||
if (!userAccountCache.ContainsKey(userAccountId))
|
||||
userAccountCache.Add(userAccountId, AccountMgr.GetUserAccountById(userAccountId));
|
||||
return userAccountCache.GetValue(userAccountId, null);
|
||||
}
|
||||
public String GetUserAccountEmailAddress(SysId userAccountId)
|
||||
{
|
||||
SaxUserAccount userAccount = GetUserAccount(userAccountId);
|
||||
return userAccount?.EmailAddress ?? "";
|
||||
}
|
||||
public String GetUserAccountDisplayName(SysId userAccountId)
|
||||
{
|
||||
SaxUserAccount userAccount = GetUserAccount(userAccountId);
|
||||
return userAccount?.GetDisplayName() ?? "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// User Accounts.
|
||||
private readonly Dictionary<SysId, SaxOrganisation> organisationCache = new Dictionary<SysId, SaxOrganisation>();
|
||||
public SaxOrganisation GetOrganisation(SysId organisationId)
|
||||
{
|
||||
if (!SysId.IsValid(organisationId)) return null;
|
||||
if (!organisationCache.ContainsKey(organisationId))
|
||||
organisationCache.Add(organisationId, AccountMgr.GetOrganisationById(organisationId));
|
||||
return organisationCache.GetValue(organisationId, null);
|
||||
}
|
||||
public String GetOrganisationName(SysId organisationId)
|
||||
{
|
||||
SaxOrganisation organisation = GetOrganisation(organisationId);
|
||||
return organisation?.Name ?? "";
|
||||
}
|
||||
public SysId GetOrganisationRegionId(SysId organisationId)
|
||||
{
|
||||
SaxOrganisation organisation = GetOrganisation(organisationId);
|
||||
return organisation?.RegionIdPrimary ?? new SysId();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -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,174 @@
|
||||
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;
|
||||
using Sarand.Net.Standard.Base.Helpers;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxSessionData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
private static long sessionIdxRoot = SacsRandomHelper.GetInt32(1000, 1999);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
/// <summary>Protected constructor for deserialisation only.</summary>
|
||||
protected SaxSessionData(long sessionIdx, int itemIdx, SaxSessionContext sessionContext)
|
||||
{
|
||||
SessionIdx = sessionIdx;
|
||||
ItemIdx = itemIdx;
|
||||
SessionContext = sessionContext;
|
||||
userData = CreateUserData(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)
|
||||
{
|
||||
SessionIdx = ++sessionIdxRoot;
|
||||
ItemIdx = 1000;
|
||||
SessionContext = sessionContext;
|
||||
userData = CreateUserData(SessionContext, userAccount, userRoles);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
// Session and Item indexers.
|
||||
public long SessionIdx { get; }
|
||||
public int ItemIdx { get; private set; }
|
||||
[JsonIgnore]
|
||||
public int NextItemIdx { get { return ++ItemIdx; } }
|
||||
// Session context.
|
||||
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() { }
|
||||
protected UserData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List<SaxUserRole> userRoles)
|
||||
{
|
||||
if (userAccount != null)
|
||||
{
|
||||
UserAccountId = userAccount.Id;
|
||||
RefreshUserData(userAccount);
|
||||
if (sessionContext.Application == Sax.Application.Admin)
|
||||
{
|
||||
// Admin 'Keep logged in' recorded against System Admin user role.
|
||||
SaxUserRole userRole = userRoles.Find(item => item.UserRole == Sax.UserRole.SystemAdmin);
|
||||
if (userRole != null)
|
||||
KeepLoggedIn = userRole.KeepLoggedIn;
|
||||
}
|
||||
else if (sessionContext.Application == Sax.Application.Online)
|
||||
// Online 'Keep logged in' recorded against System Admin user role.
|
||||
KeepLoggedIn = userAccount.KeepLoggedIn;
|
||||
else Debugger.Break();
|
||||
|
||||
if (userRoles != null)
|
||||
{
|
||||
foreach (SaxUserRole userRole in userRoles.FindAll(item => item.IsStatusActive))
|
||||
roles.Add(new RoleData(userRole));
|
||||
}
|
||||
}
|
||||
}
|
||||
protected UserData(UserData userData)
|
||||
{
|
||||
UserAccountId = userData.UserAccountId;
|
||||
Title = userData.Title;
|
||||
FirstName = userData.FirstName;
|
||||
LastName = userData.LastName;
|
||||
DisplayName = userData.DisplayName;
|
||||
EmailAddress = userData.EmailAddress;
|
||||
RegionIdCountry = userData.RegionIdCountry;
|
||||
RegionIdProvince = userData.RegionIdProvince;
|
||||
KeepLoggedIn = userData.KeepLoggedIn;
|
||||
roles.AddRange(userData.Roles);
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId { get; protected set; }
|
||||
public String Title { 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 SysId RegionIdCountry { get; protected set; }
|
||||
public SysId RegionIdProvince { get; protected set; }
|
||||
public bool KeepLoggedIn { get; protected set; }
|
||||
public bool UserAccountSupplied { get; protected set; }
|
||||
// Refresh properties.
|
||||
protected bool RefreshUserData(SaxUserAccount userAccount)
|
||||
{
|
||||
// Check that user matches the session.
|
||||
if (!SysId.IsValid(UserAccountId) || !SysId.IsValid(userAccount?.Id ?? null) || !UserAccountId.Equals(userAccount.Id)) return false;
|
||||
// Refresh properties.
|
||||
Title = userAccount.Title;
|
||||
FirstName = userAccount.FirstName;
|
||||
LastName = userAccount.LastName;
|
||||
DisplayName = userAccount.GetDisplayName();
|
||||
EmailAddress = userAccount.EmailAddress;
|
||||
RegionIdCountry = userAccount.RegionIdCountry;
|
||||
RegionIdProvince = userAccount.RegionIdProvince;
|
||||
return true;
|
||||
}
|
||||
// Roles.
|
||||
public class 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; }
|
||||
}
|
||||
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); } }
|
||||
[JsonIgnore]
|
||||
public bool IsSystemAdmin { get { return roles?.Exists(item => item.Role == Sax.UserRole.SystemAdmin) ?? false; } }
|
||||
[JsonIgnore]
|
||||
public bool IsSystemReviewer { get { return roles?.Exists(item => item.Role == Sax.UserRole.SystemReviewer) ?? false; } }
|
||||
[JsonIgnore]
|
||||
public bool SupportMenuAllowed { get { return roles?.Exists(item => item.Role == Sax.UserRole.SystemAdmin || item.Role == Sax.UserRole.SystemReviewer) ?? false; } }
|
||||
[JsonIgnore]
|
||||
public bool IsJournalist { get { return roles?.Exists(item => item.Role == Sax.UserRole.Journalist) ?? false; } }
|
||||
}
|
||||
protected abstract UserData CreateUserData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List<SaxUserRole> userRoles);
|
||||
private UserData userData;
|
||||
public UserData User { get { return userData; } }
|
||||
/// <summary>User - JSON deserialisation route.</summary>
|
||||
protected void SetUser(UserData user)
|
||||
{
|
||||
if (this.userData != null && User.UserAccountSupplied)
|
||||
throw new NotSupportedException("Session User cannot be replaced.");
|
||||
this.userData = user;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
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.
|
||||
// Code types.
|
||||
private static readonly List<TypeCodeDesc> yesNoCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> dataItemTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> genderCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> sportGroupingCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> sportSpecialityLabelCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> sportContactCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> sportParticipatingCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> sportPreparingCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> sportOfficiatingCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> regionTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> eligibilityTypeCodes = 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> imageTypeCodes = 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>();
|
||||
private static readonly List<TypeCodeDesc> associationTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> addressTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> contactMethodCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> eventTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> opportunityTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> activityReactionCodes = new List<TypeCodeDesc>();
|
||||
// Support.
|
||||
private static readonly List<TypeCodeDesc> userReportTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> supportItemProcessTypeCodes = new List<TypeCodeDesc>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o d e T y p e s
|
||||
//-------------------------------------------------------------------
|
||||
public static List<TypeCodeDesc> GetCodesOfType(Sax.CodeType codeType)
|
||||
{
|
||||
// Lists are cloned to avoid modifications to the internal static lists.
|
||||
switch (codeType)
|
||||
{
|
||||
case Sax.CodeType.YesNo:
|
||||
return new List<TypeCodeDesc>(yesNoCodes);
|
||||
case Sax.CodeType.DataItemType:
|
||||
return new List<TypeCodeDesc>(dataItemTypeCodes);
|
||||
case Sax.CodeType.Gender:
|
||||
return new List<TypeCodeDesc>(genderCodes);
|
||||
case Sax.CodeType.SportGrouping:
|
||||
return new List<TypeCodeDesc>(sportGroupingCodes);
|
||||
case Sax.CodeType.SportSpecialityLabel:
|
||||
return new List<TypeCodeDesc>(sportSpecialityLabelCodes);
|
||||
case Sax.CodeType.SportContactType:
|
||||
return new List<TypeCodeDesc>(sportContactCodes);
|
||||
case Sax.CodeType.SportParticipating:
|
||||
return new List<TypeCodeDesc>(sportParticipatingCodes);
|
||||
case Sax.CodeType.SportPreparing:
|
||||
return new List<TypeCodeDesc>(sportPreparingCodes);
|
||||
case Sax.CodeType.SportOfficiating:
|
||||
return new List<TypeCodeDesc>(sportOfficiatingCodes);
|
||||
case Sax.CodeType.RegionType:
|
||||
return new List<TypeCodeDesc>(regionTypeCodes);
|
||||
case Sax.CodeType.EligibilityType:
|
||||
return new List<TypeCodeDesc>(eligibilityTypeCodes);
|
||||
case Sax.CodeType.UserRole:
|
||||
return new List<TypeCodeDesc>(userRoleCodes);
|
||||
case Sax.CodeType.Title:
|
||||
return new List<TypeCodeDesc>(titleCodes);
|
||||
case Sax.CodeType.ImageType:
|
||||
return new List<TypeCodeDesc>(imageTypeCodes);
|
||||
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);
|
||||
case Sax.CodeType.AssociationType:
|
||||
return new List<TypeCodeDesc>(associationTypeCodes);
|
||||
case Sax.CodeType.AddressType:
|
||||
return new List<TypeCodeDesc>(addressTypeCodes);
|
||||
case Sax.CodeType.ContactMethod:
|
||||
return new List<TypeCodeDesc>(contactMethodCodes);
|
||||
case Sax.CodeType.EventType:
|
||||
return new List<TypeCodeDesc>(eventTypeCodes);
|
||||
case Sax.CodeType.OpportunityType:
|
||||
return new List<TypeCodeDesc>(opportunityTypeCodes);
|
||||
case Sax.CodeType.ActivityReaction:
|
||||
return new List<TypeCodeDesc>(activityReactionCodes);
|
||||
|
||||
// Support.
|
||||
case Sax.CodeType.UserReportType:
|
||||
return new List<TypeCodeDesc>(userReportTypeCodes);
|
||||
case Sax.CodeType.SupportItemProcessType:
|
||||
return new List<TypeCodeDesc>(supportItemProcessTypeCodes);
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(nameof(SaxSystem) + ".GetCodesOfType Unexpected code type: " + codeType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Static code type initialisation.</summary>
|
||||
private static void InitCodeTypes()
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Yes No options.
|
||||
yesNoCodes.Add(Sax.YesNo.Yes, "YES", "Yes");
|
||||
yesNoCodes.Add(Sax.YesNo.No, "NO", "No");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Data item types.
|
||||
// Reference data.
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.Region, "Region", "Region");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.Sport, "Sport", "Sport");
|
||||
// Accounts.
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.UserAccount, "UserAccount", "User Account");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.UserRole, "UserRole", "User Role");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.UserOrganisation, "UserOrganisation", "User Organisation");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.UserSport, "UserSport", "User Sport");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.Organisation, "Organisation", "Organisation");
|
||||
// Activity data.
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.ActivityIndex, "ActivityIndex", "Activity Index");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.UserActivity, "UserActivity", "User Activity");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.Article, "Article", "Article");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.OrganisationOpportunity, "OrganisationOpportunity", "Organisation Opportunity");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.OrganisationEvent, "OrganisationEvent", "Organisation Event");
|
||||
// Item link components.
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.ItemSport, "ItemSport", "Item Sport");
|
||||
dataItemTypeCodes.Add(Sax.DataItemType.ItemImage, "ItemImage", "Item Image");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Gender.
|
||||
genderCodes.Add(Sax.Gender.Female, "Female", "Female");
|
||||
genderCodes.Add(Sax.Gender.Male, "Male", "Male");
|
||||
genderCodes.Add(Sax.Gender.TransFemale, "TransFemale", "TransFemale");
|
||||
genderCodes.Add(Sax.Gender.TransMale, "TransMale", "TransMale");
|
||||
genderCodes.Add(Sax.Gender.Nonconforming, "Nonconforming", "Nonconforming");
|
||||
genderCodes.Add(Sax.Gender.PreferNotToSay, "PreferNotToSay", "Prefer not to say");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport grouping.
|
||||
sportGroupingCodes.Add(Sax.SportGrouping.Specific, "SPC", "Specific");
|
||||
sportGroupingCodes.Add(Sax.SportGrouping.Banner, "BNR", "Banner");
|
||||
sportGroupingCodes.Add(Sax.SportGrouping.Group, "GRP", "Group");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport speciality label.
|
||||
sportSpecialityLabelCodes.Add(Sax.SportSpecialityLabel.Positon, "POS", "Positon");
|
||||
sportSpecialityLabelCodes.Add(Sax.SportSpecialityLabel.Discipline, "DIS", "Discipline");
|
||||
sportSpecialityLabelCodes.Add(Sax.SportSpecialityLabel.NotRelevant, "NRE", "Not relevant");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport contact.
|
||||
sportContactCodes.Add(Sax.SportContactType.Coach, "COA", "Coach");
|
||||
sportContactCodes.Add(Sax.SportContactType.Manager, "MAN", "Manager");
|
||||
sportContactCodes.Add(Sax.SportContactType.Agent, "AGE", "Agent");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport participating.
|
||||
sportParticipatingCodes.Add(Sax.SportParticipating.Professional, "PRO", "Professional");
|
||||
sportParticipatingCodes.Add(Sax.SportParticipating.Regular, "REG", "Regular");
|
||||
sportParticipatingCodes.Add(Sax.SportParticipating.Occasional, "OCC", "Occasional");
|
||||
sportParticipatingCodes.Add(Sax.SportParticipating.Spectator, "SPC", "Spectator");
|
||||
sportParticipatingCodes.Add(Sax.SportParticipating.Interested, "INT", "Interested");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport preparing.
|
||||
sportPreparingCodes.Add(Sax.SportPreparing.Coach, "CCH", "Coach");
|
||||
sportPreparingCodes.Add(Sax.SportPreparing.Manager, "MGR", "Manager");
|
||||
sportPreparingCodes.Add(Sax.SportPreparing.Agent, "AGT", "Agent");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport officiating.
|
||||
sportOfficiatingCodes.Add(Sax.SportOfficiating.Professional, "PRO", "Professional");
|
||||
sportOfficiatingCodes.Add(Sax.SportOfficiating.Regular, "REG", "Regular");
|
||||
sportOfficiatingCodes.Add(Sax.SportOfficiating.Occasional, "OCC", "Occasional");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Region types.
|
||||
regionTypeCodes.Add(Sax.RegionType.Universe, "UNIV", "Universe");
|
||||
regionTypeCodes.Add(Sax.RegionType.Galaxy, "GALAX", "Galaxy");
|
||||
regionTypeCodes.Add(Sax.RegionType.World, "WORLD", "World");
|
||||
regionTypeCodes.Add(Sax.RegionType.Continent, "CONT", "Continent");
|
||||
regionTypeCodes.Add(Sax.RegionType.SubContinent, "SUBC", "Sub-Continent");
|
||||
regionTypeCodes.Add(Sax.RegionType.Country, "COUN", "Country");
|
||||
regionTypeCodes.Add(Sax.RegionType.State, "STAT", "State");
|
||||
regionTypeCodes.Add(Sax.RegionType.Province, "PROV", "Province");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Eligibility types.
|
||||
eligibilityTypeCodes.Add(Sax.EligibilityType.Birth, "BTH", "Birth");
|
||||
eligibilityTypeCodes.Add(Sax.EligibilityType.Naturalised, "NLD", "Naturalised");
|
||||
eligibilityTypeCodes.Add(Sax.EligibilityType.Parent, "PRT", "Parent");
|
||||
eligibilityTypeCodes.Add(Sax.EligibilityType.Grandparent, "GRD", "Grandparent");
|
||||
eligibilityTypeCodes.Add(Sax.EligibilityType.Passport, "PST", "Passport");
|
||||
eligibilityTypeCodes.Add(Sax.EligibilityType.Visa, "VSA", "Visa");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// User roles.
|
||||
userRoleCodes.Add(Sax.UserRole.Journalist, "JRNLST", "Journalist");
|
||||
userRoleCodes.Add(Sax.UserRole.SystemAdmin, "SYSADM", "System Admin");
|
||||
userRoleCodes.Add(Sax.UserRole.SystemReviewer, "SYSRVR", "System Reviewer");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// 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");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Image types.
|
||||
imageTypeCodes.Add(Sax.ImageType.Avatar, "Avatar", "Avatar");
|
||||
imageTypeCodes.Add(Sax.ImageType.Avatar_Upload, "AvatarUpload", "Avatar - upload");
|
||||
imageTypeCodes.Add(Sax.ImageType.OrganisationLogo, "OrganisationLogo", "Organisation logo");
|
||||
imageTypeCodes.Add(Sax.ImageType.OrganisationLogo_Upload, "OrganisationLogoUpload", "Organisation logo - upload");
|
||||
imageTypeCodes.Add(Sax.ImageType.Article, "Article", "Article");
|
||||
imageTypeCodes.Add(Sax.ImageType.Article_Upload, "ArticleUpload", "Article - upload");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// 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 categories.
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Association, "ASC", "Association");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Club, "CLB", "Club");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Society, "SOC", "Society");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Education, "EDU", "Education");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.SportDepartment, "SPD", "Sport Department");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Syndicate, "SYN", "Syndicate");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Partner, "PRT", "Partner");
|
||||
organisationCategoryCodes.Add(Sax.OrganisationCategory.Other, "OTH", "Other");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Organisation roles.
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.Member, "MBR", "Member");
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.Admin, "ADM", "Admin");
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.MemberAdmin, "MBA", "Members");
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.ScheduleAdmin, "SCA", "Schedule");
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.OpportunityAdmin, "OPA", "Opportunities");
|
||||
organisationRoleCodes.Add(Sax.OrganisationRole.ArticleAdmin, "ARA", "Articles");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Association Types.
|
||||
associationTypeCodes.Add(Sax.AssociationType.Affiliate, "Affiliate", "Affiliate");
|
||||
associationTypeCodes.Add(Sax.AssociationType.Partner, "Partner", "Partner");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Address Types.
|
||||
addressTypeCodes.Add(Sax.AddressType.Location, "Location", "Location");
|
||||
addressTypeCodes.Add(Sax.AddressType.Home, "Home", "Home");
|
||||
addressTypeCodes.Add(Sax.AddressType.Office, "Office", "Office");
|
||||
addressTypeCodes.Add(Sax.AddressType.Delivery, "Delivery", "Delivery");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Contact methods.
|
||||
contactMethodCodes.Add(Sax.ContactMethod.PhoneMain, Sax.ContactMethod.PhoneMain.ToString(), "Phone - main");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.PhoneMobile, Sax.ContactMethod.PhoneMobile.ToString(), "Phone - mobile");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.PhoneHome, Sax.ContactMethod.PhoneHome.ToString(), "Phone - home");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.PhoneOffice, Sax.ContactMethod.PhoneOffice.ToString(), "Phone - office");
|
||||
// Online.
|
||||
contactMethodCodes.Add(Sax.ContactMethod.Email, Sax.ContactMethod.Email.ToString(), "Email");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.Website, Sax.ContactMethod.Website.ToString(), "Website");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.Wikipedia, Sax.ContactMethod.Wikipedia.ToString(), "Wikipedia");
|
||||
// Social media.
|
||||
contactMethodCodes.Add(Sax.ContactMethod.LinkedIn, Sax.ContactMethod.LinkedIn.ToString(), "LinkedIn");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.Twitter, Sax.ContactMethod.Twitter.ToString(), "X");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.Facebook, Sax.ContactMethod.Facebook.ToString(), "Facebook");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.Instagram, Sax.ContactMethod.Instagram.ToString(), "Instagram");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.YouTube, Sax.ContactMethod.YouTube.ToString(), "YouTube");
|
||||
contactMethodCodes.Add(Sax.ContactMethod.Twitch, Sax.ContactMethod.Twitch.ToString(), "Twitch");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Event types.
|
||||
eventTypeCodes.Add(Sax.EventType.Playing, "PLG", "Playing");
|
||||
eventTypeCodes.Add(Sax.EventType.Training, "TRN", "Training");
|
||||
eventTypeCodes.Add(Sax.EventType.Organisation, "ORG", "Organisation");
|
||||
eventTypeCodes.Add(Sax.EventType.Social, "SCL", "Social");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Opportunity types.
|
||||
opportunityTypeCodes.Add(Sax.OpportunityType.Playing, "PLG", "Playing");
|
||||
opportunityTypeCodes.Add(Sax.OpportunityType.Official, "OFL", "Official");
|
||||
opportunityTypeCodes.Add(Sax.OpportunityType.Coaching, "CHG", "Coaching");
|
||||
opportunityTypeCodes.Add(Sax.OpportunityType.Volunteer, "VTR", "Volunteer");
|
||||
opportunityTypeCodes.Add(Sax.OpportunityType.Staff, "STF", "Staff");
|
||||
opportunityTypeCodes.Add(Sax.OpportunityType.Board, "BRD", "Board");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Activity Reactions.
|
||||
activityReactionCodes.Add(Sax.ActivityReaction.Good, "Good", "Good");
|
||||
activityReactionCodes.Add(Sax.ActivityReaction.VeryGood, "VeryGood", "Very Good");
|
||||
activityReactionCodes.Add(Sax.ActivityReaction.Exceptional, "Exceptional", "Exceptional");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Support.
|
||||
|
||||
// User Report Types.
|
||||
userReportTypeCodes.Add(Sax.UserReportType.Enhancement, "ENH", "Enhancement request");
|
||||
userReportTypeCodes.Add(Sax.UserReportType.Information, "INF", "Information request");
|
||||
userReportTypeCodes.Add(Sax.UserReportType.Bug, "BUG", "Bug report");
|
||||
|
||||
// Support Item Process Types.
|
||||
supportItemProcessTypeCodes.Add(Sax.SupportItemProcessType.OrganisationSchedulePopulation, "OSP", "Organisation schedule population");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
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.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Static initialisation.</summary>
|
||||
static SaxSystem()
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Code types.
|
||||
InitCodeTypes();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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;
|
||||
using Saxonite.Net.Standard.Base.Mgr.Support;
|
||||
using Saxonite.Net.Standard.Base.Mgr.Reference;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxSystem : SacsSystem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected Construction.
|
||||
protected SaxSystem() : base()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Environment.
|
||||
//-------------------------------------------------------------------
|
||||
public static Sax.Environment GetEnvironment()
|
||||
{
|
||||
if (ComputerName.ContainsCI("Sarand602"))
|
||||
return Sax.Environment.Production;
|
||||
if (ComputerName.ContainsCI("Sarand"))
|
||||
return Sax.Environment.Development;
|
||||
return Sax.Environment.Production;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Business components.
|
||||
//-------------------------------------------------------------------
|
||||
public abstract SaxReferenceMgr CreateReferenceMgr(SaxSessionContext sessionContext, SaxInternals internals);
|
||||
public abstract SaxAccountMgr CreateAccountMgr(SaxSessionContext sessionContext, SaxInternals internals);
|
||||
public abstract SaxItemDataMgr CreateItemDataMgr(SaxSessionContext sessionContext, SaxInternals internals);
|
||||
public abstract SaxActivityMgr CreateActivityMgr(SaxSessionContext sessionContext, SaxInternals internals);
|
||||
public abstract SaxReferenceGolfMgr CreateReferenceGolfMgr(SaxSessionContext sessionContext, SaxInternals internals);
|
||||
public abstract SaxSupportMgr CreateSupportMgr(SaxSessionContext sessionContext, SaxInternals internals);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Sarand.Net.Standard.Base.Bus.SacsHierarchyItem;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
// Golf - USGA Country.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaCountry : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryCode,
|
||||
EntCountryCode,
|
||||
CountryName,
|
||||
ProvincesUpdateAt_Date,
|
||||
// Associated data.
|
||||
ProvinceCount_All,
|
||||
ProvinceCount_Active,
|
||||
FacilityCount_All,
|
||||
FacilityCount_Active,
|
||||
/// <summary>Facility population %.</summary>
|
||||
FacilityPercent,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public String CountryCode { get; set; } = String.Empty;
|
||||
public String EntCountryCode { get; set; } = String.Empty;
|
||||
public String CountryName { get; set; } = String.Empty;
|
||||
public DateTime? ProvincesUpdateAt { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public String CountryCode
|
||||
{
|
||||
get { return data.CountryCode; }
|
||||
set { CheckChanged(data.CountryCode, value); data.CountryCode = value; }
|
||||
}
|
||||
public String EntCountryCode
|
||||
{
|
||||
get { return data.EntCountryCode; }
|
||||
set { CheckChanged(data.EntCountryCode, value); data.EntCountryCode = value; }
|
||||
}
|
||||
public String CountryName
|
||||
{
|
||||
get { return data.CountryName; }
|
||||
set { CheckChanged(data.CountryName, value); data.CountryName = value; }
|
||||
}
|
||||
public DateTime? ProvincesUpdateAt
|
||||
{
|
||||
get { return data.ProvincesUpdateAt; }
|
||||
set { CheckChangedNullable(data.ProvincesUpdateAt, value); data.ProvincesUpdateAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
CountryCode = data.CountryCode;
|
||||
EntCountryCode = data.EntCountryCode;
|
||||
CountryName = data.CountryName;
|
||||
ProvincesUpdateAt = data.ProvincesUpdateAt;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue CountryCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EntCountryCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CountryName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProvincesUpdateAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaCountry(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Golf_UsgaCountry, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void Dispose() { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public String CountryCode
|
||||
{
|
||||
get { return data.CountryCode; }
|
||||
set { data.CountryCode = value; }
|
||||
}
|
||||
public String EntCountryCode
|
||||
{
|
||||
get { return data.EntCountryCode; }
|
||||
set { data.EntCountryCode = value; }
|
||||
}
|
||||
public String CountryName
|
||||
{
|
||||
get { return data.CountryName; }
|
||||
set { data.CountryName = value; }
|
||||
}
|
||||
public DateTime? ProvincesUpdateAt
|
||||
{
|
||||
get { return data.ProvincesUpdateAt; }
|
||||
set { data.ProvincesUpdateAt = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
public const byte Flag_Priority = 0x01;
|
||||
public bool Priority
|
||||
{
|
||||
get { return GetFlag(Flag_Priority); }
|
||||
set { SetFlag(Flag_Priority, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
NotDeleted = 0,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
Any,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
/// <summary>Generic filter - partial country code or name.</summary>
|
||||
public String CountryFilter { get; set; }
|
||||
/// <summary>Restrict the results by code.</summary>
|
||||
public HashSet<String> CountryCodesIncluded { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
|
||||
public String CountryNameFull { get; set; }
|
||||
public String CountryNamePartial { get; set; }
|
||||
// Flags.
|
||||
public FlagState PriorityFlagState { get; set; } = FlagState.Either;
|
||||
// Associated data.
|
||||
public BoolState HasProvinces { get; set; } = BoolState.Either;
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaCountryList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaCountry GetCountryById(this IEnumerable<SaxGolfUsgaCountry> values, SysId countryId)
|
||||
{
|
||||
if (!SysId.IsValid(countryId)) return null;
|
||||
foreach (SaxGolfUsgaCountry country in values)
|
||||
if (country.Id.Equals(countryId)) return country;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
// Golf - USGA Course.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaCourse : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryId,
|
||||
Country_Name,
|
||||
ProvinceId,
|
||||
Province_Name,
|
||||
FacilityId,
|
||||
Facility_Name,
|
||||
UsgaCourseId,
|
||||
LegacyCrpCourseId,
|
||||
Caption,
|
||||
CourseName,
|
||||
FullName,
|
||||
Address1,
|
||||
Address2,
|
||||
City,
|
||||
PostalCode,
|
||||
Email,
|
||||
Telephone,
|
||||
MarkersUpdateOn_Date,
|
||||
// Associated data.
|
||||
MarkerCount_All,
|
||||
MarkerCount_Active,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId FacilityId { get; set; }
|
||||
public SysId UsgaCourseId { get; set; }
|
||||
public SysId LegacyCrpCourseId { get; set; }
|
||||
public String Caption { get; set; } = String.Empty;
|
||||
public String CourseName { get; set; } = String.Empty;
|
||||
public String FullName { get; set; } = String.Empty;
|
||||
public String Address1 { get; set; } = String.Empty;
|
||||
public String Address2 { get; set; } = String.Empty;
|
||||
public String City { get; set; } = String.Empty;
|
||||
public String PostalCode { get; set; } = String.Empty;
|
||||
public Decimal? Latitude { get; set; } = null;
|
||||
public Decimal? Longitude { get; set; } = null;
|
||||
public String Email { get; set; } = String.Empty;
|
||||
public String Telephone { get; set; } = String.Empty;
|
||||
public DateTime? MarkersUpdateAt { get; set; } = null;
|
||||
public String MarkersData { get; set; } = String.Empty;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId FacilityId
|
||||
{
|
||||
get { return data.FacilityId; }
|
||||
set { CheckChanged(data.FacilityId, value); data.FacilityId = value; }
|
||||
}
|
||||
public SysId UsgaCourseId
|
||||
{
|
||||
get { return data.UsgaCourseId; }
|
||||
set { CheckChanged(data.UsgaCourseId, value); data.UsgaCourseId = value; }
|
||||
}
|
||||
public SysId LegacyCrpCourseId
|
||||
{
|
||||
get { return data.LegacyCrpCourseId; }
|
||||
set { CheckChanged(data.LegacyCrpCourseId, value); data.LegacyCrpCourseId = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { CheckChanged(data.Caption, value); data.Caption = value; }
|
||||
}
|
||||
public String CourseName
|
||||
{
|
||||
get { return data.CourseName; }
|
||||
set { CheckChanged(data.CourseName, value); data.CourseName = value; }
|
||||
}
|
||||
public String FullName
|
||||
{
|
||||
get { return data.FullName; }
|
||||
set { CheckChanged(data.FullName, value); data.FullName = value; }
|
||||
}
|
||||
public String Address1
|
||||
{
|
||||
get { return data.Address1; }
|
||||
set { CheckChanged(data.Address1, value); data.Address1 = value; }
|
||||
}
|
||||
public String Address2
|
||||
{
|
||||
get { return data.Address2; }
|
||||
set { CheckChanged(data.Address2, value); data.Address2 = value; }
|
||||
}
|
||||
public String City
|
||||
{
|
||||
get { return data.City; }
|
||||
set { CheckChanged(data.City, value); data.City = value; }
|
||||
}
|
||||
public String PostalCode
|
||||
{
|
||||
get { return data.PostalCode; }
|
||||
set { CheckChanged(data.PostalCode, value); data.PostalCode = value; }
|
||||
}
|
||||
public decimal? Latitude
|
||||
{
|
||||
get { return data.Latitude; }
|
||||
set { CheckChangedNullable(data.Latitude, value); data.Latitude = value; }
|
||||
}
|
||||
public decimal? Longitude
|
||||
{
|
||||
get { return data.Longitude; }
|
||||
set { CheckChangedNullable(data.Longitude, value); data.Longitude = value; }
|
||||
}
|
||||
public String Email
|
||||
{
|
||||
get { return data.Email; }
|
||||
set { CheckChanged(data.Email, value); data.Email = value; }
|
||||
}
|
||||
public String Telephone
|
||||
{
|
||||
get { return data.Telephone; }
|
||||
set { CheckChanged(data.Telephone, value); data.Telephone = value; }
|
||||
}
|
||||
public DateTime? MarkersUpdateAt
|
||||
{
|
||||
get { return data.MarkersUpdateAt; }
|
||||
set { CheckChangedNullable(data.MarkersUpdateAt, value); data.MarkersUpdateAt = value; }
|
||||
}
|
||||
public String MarkersData
|
||||
{
|
||||
get { return data.MarkersData; }
|
||||
set { CheckChanged(data.MarkersData, value); data.MarkersData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
FacilityId = data.FacilityId;
|
||||
UsgaCourseId = data.UsgaCourseId;
|
||||
LegacyCrpCourseId = data.LegacyCrpCourseId;
|
||||
Caption = data.Caption;
|
||||
CourseName = data.CourseName;
|
||||
FullName = data.FullName;
|
||||
Address1 = data.Address1;
|
||||
Address2 = data.Address2;
|
||||
City = data.City;
|
||||
PostalCode = data.PostalCode;
|
||||
Latitude = data.Latitude;
|
||||
Longitude = data.Longitude;
|
||||
Email = data.Email;
|
||||
Telephone = data.Telephone;
|
||||
MarkersUpdateAt = data.MarkersUpdateAt;
|
||||
MarkersData = data.MarkersData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue FacilityId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CourseId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LegacyCrpCourseId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Caption { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CourseName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FullName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Address1 { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Address2 { get; set; } = ValidValue.Valid;
|
||||
public ValidValue City { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PostalCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Latitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Longitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Email { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Telephone { get; set; } = ValidValue.Valid;
|
||||
public ValidValue MarkersUpdateAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue MarkersData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaCourse(SysId id, SysId facilityId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.FacilityId = facilityId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Golf_UsgaCourse, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void Dispose() { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId FacilityId
|
||||
{
|
||||
get { return data.FacilityId; }
|
||||
set { data.FacilityId = value; }
|
||||
}
|
||||
public SysId UsgaCourseId
|
||||
{
|
||||
get { return data.UsgaCourseId; }
|
||||
set { data.UsgaCourseId = value; }
|
||||
}
|
||||
public SysId LegacyCrpCourseId
|
||||
{
|
||||
get { return data.LegacyCrpCourseId; }
|
||||
set { data.LegacyCrpCourseId = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { data.Caption = value; }
|
||||
}
|
||||
public String CourseName
|
||||
{
|
||||
get { return data.CourseName; }
|
||||
set { data.CourseName = value; }
|
||||
}
|
||||
public String FullName
|
||||
{
|
||||
get { return data.FullName; }
|
||||
set { data.FullName = value; }
|
||||
}
|
||||
public String Address1
|
||||
{
|
||||
get { return data.Address1; }
|
||||
set { data.Address1 = value; }
|
||||
}
|
||||
public String Address2
|
||||
{
|
||||
get { return data.Address2; }
|
||||
set { data.Address2 = value; }
|
||||
}
|
||||
public String City
|
||||
{
|
||||
get { return data.City; }
|
||||
set { data.City = value; }
|
||||
}
|
||||
public String PostalCode
|
||||
{
|
||||
get { return data.PostalCode; }
|
||||
set { data.PostalCode = value; }
|
||||
}
|
||||
public decimal? Latitude
|
||||
{
|
||||
get { return data.Latitude; }
|
||||
set { data.Latitude = value; }
|
||||
}
|
||||
public decimal? Longitude
|
||||
{
|
||||
get { return data.Longitude; }
|
||||
set { data.Longitude = value; }
|
||||
}
|
||||
public String Email
|
||||
{
|
||||
get { return data.Email; }
|
||||
set { data.Email = value; }
|
||||
}
|
||||
public String Telephone
|
||||
{
|
||||
get { return data.Telephone; }
|
||||
set { data.Telephone = value; }
|
||||
}
|
||||
public DateTime? MarkersUpdateAt
|
||||
{
|
||||
get { return data.MarkersUpdateAt; }
|
||||
set { data.MarkersUpdateAt = value; }
|
||||
}
|
||||
public String MarkersData
|
||||
{
|
||||
get { return data.MarkersData; }
|
||||
set { data.MarkersData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
public const byte Flag_Priority = 0x01;
|
||||
public bool Priority
|
||||
{
|
||||
get { return GetFlag(Flag_Priority); }
|
||||
set { SetFlag(Flag_Priority, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
NotDeleted = 0,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
Any,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> ProvinceIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> FacilityIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>USGA Course Ids.</summary>
|
||||
public List<SysId> UsgaCourseIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Generic filter - partial name, address etc.</summary>
|
||||
public String CourseFilter { get; set; }
|
||||
public String CourseNameFull { get; set; }
|
||||
public String CourseNamePartial { get; set; }
|
||||
public BoolState HasMarkersData { get; set; } = BoolState.Either;
|
||||
// Flags.
|
||||
public FlagState PriorityFlagState { get; set; } = FlagState.Either;
|
||||
// Associated data.
|
||||
public BoolState HasMarkers { get; set; } = BoolState.Either;
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Country { get; set; }
|
||||
public String Alias_Province { get; set; }
|
||||
public String Alias_Facility { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaCourseList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaCourse GetCourseById(this IEnumerable<SaxGolfUsgaCourse> values, SysId courseId)
|
||||
{
|
||||
if (!SysId.IsValid(courseId)) return null;
|
||||
foreach (SaxGolfUsgaCourse province in values)
|
||||
if (province.Id.Equals(courseId)) return province;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
// Golf - USGA Facility.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaFacility : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryId,
|
||||
Country_Name,
|
||||
ProvinceId,
|
||||
Province_Name,
|
||||
UsgaFacilityId,
|
||||
FacilityName,
|
||||
Address1,
|
||||
Address2,
|
||||
City,
|
||||
PostalCode,
|
||||
Email,
|
||||
Telephone,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId ProvinceId { get; set; }
|
||||
public SysId UsgaFacilityId { get; set; }
|
||||
public String FacilityName { get; set; } = String.Empty;
|
||||
public String Address1 { get; set; } = String.Empty;
|
||||
public String Address2 { get; set; } = String.Empty;
|
||||
public String City { get; set; } = String.Empty;
|
||||
public String PostalCode { get; set; } = String.Empty;
|
||||
public Decimal? Latitude { get; set; } = null;
|
||||
public Decimal? Longitude { get; set; } = null;
|
||||
public String Email { get; set; } = String.Empty;
|
||||
public String Telephone { get; set; } = String.Empty;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId ProvinceId
|
||||
{
|
||||
get { return data.ProvinceId; }
|
||||
set { CheckChanged(data.ProvinceId, value); data.ProvinceId = value; }
|
||||
}
|
||||
public SysId UsgaFacilityId
|
||||
{
|
||||
get { return data.UsgaFacilityId; }
|
||||
set { CheckChanged(data.UsgaFacilityId, value); data.UsgaFacilityId = value; }
|
||||
}
|
||||
public String FacilityName
|
||||
{
|
||||
get { return data.FacilityName; }
|
||||
set { CheckChanged(data.FacilityName, value); data.FacilityName = value; }
|
||||
}
|
||||
public String Address1
|
||||
{
|
||||
get { return data.Address1; }
|
||||
set { CheckChanged(data.Address1, value); data.Address1 = value; }
|
||||
}
|
||||
public String Address2
|
||||
{
|
||||
get { return data.Address2; }
|
||||
set { CheckChanged(data.Address2, value); data.Address2 = value; }
|
||||
}
|
||||
public String City
|
||||
{
|
||||
get { return data.City; }
|
||||
set { CheckChanged(data.City, value); data.City = value; }
|
||||
}
|
||||
public String PostalCode
|
||||
{
|
||||
get { return data.PostalCode; }
|
||||
set { CheckChanged(data.PostalCode, value); data.PostalCode = value; }
|
||||
}
|
||||
public decimal? Latitude
|
||||
{
|
||||
get { return data.Latitude; }
|
||||
set { CheckChangedNullable(data.Latitude, value); data.Latitude = value; }
|
||||
}
|
||||
public decimal? Longitude
|
||||
{
|
||||
get { return data.Longitude; }
|
||||
set { CheckChangedNullable(data.Longitude, value); data.Longitude = value; }
|
||||
}
|
||||
public String Email
|
||||
{
|
||||
get { return data.Email; }
|
||||
set { CheckChanged(data.Email, value); data.Email = value; }
|
||||
}
|
||||
public String Telephone
|
||||
{
|
||||
get { return data.Telephone; }
|
||||
set { CheckChanged(data.Telephone, value); data.Telephone = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ProvinceId = data.ProvinceId;
|
||||
UsgaFacilityId = data.UsgaFacilityId;
|
||||
FacilityName = data.FacilityName;
|
||||
Address1 = data.Address1;
|
||||
Address2 = data.Address2;
|
||||
City = data.City;
|
||||
PostalCode = data.PostalCode;
|
||||
Latitude = data.Latitude;
|
||||
Longitude = data.Longitude;
|
||||
Email = data.Email;
|
||||
Telephone = data.Telephone;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ProvinceId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UsgaFacilityId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FacilityName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Address1 { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Address2 { get; set; } = ValidValue.Valid;
|
||||
public ValidValue City { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PostalCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Latitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Longitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Email { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Telephone { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaFacility(SysId id, SysId provinceId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.ProvinceId = provinceId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Golf_UsgaFacility, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void Dispose() { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId ProvinceId
|
||||
{
|
||||
get { return data.ProvinceId; }
|
||||
set { data.ProvinceId = value; }
|
||||
}
|
||||
public SysId UsgaFacilityId
|
||||
{
|
||||
get { return data.UsgaFacilityId; }
|
||||
set { data.UsgaFacilityId = value; }
|
||||
}
|
||||
public String FacilityName
|
||||
{
|
||||
get { return data.FacilityName; }
|
||||
set { data.FacilityName = value; }
|
||||
}
|
||||
public String Address1
|
||||
{
|
||||
get { return data.Address1; }
|
||||
set { data.Address1 = value; }
|
||||
}
|
||||
public String Address2
|
||||
{
|
||||
get { return data.Address2; }
|
||||
set { data.Address2 = value; }
|
||||
}
|
||||
public String City
|
||||
{
|
||||
get { return data.City; }
|
||||
set { data.City = value; }
|
||||
}
|
||||
public String PostalCode
|
||||
{
|
||||
get { return data.PostalCode; }
|
||||
set { data.PostalCode = value; }
|
||||
}
|
||||
public decimal? Latitude
|
||||
{
|
||||
get { return data.Latitude; }
|
||||
set { data.Latitude = value; }
|
||||
}
|
||||
public decimal? Longitude
|
||||
{
|
||||
get { return data.Longitude; }
|
||||
set { data.Longitude = value; }
|
||||
}
|
||||
public String Email
|
||||
{
|
||||
get { return data.Email; }
|
||||
set { data.Email = value; }
|
||||
}
|
||||
public String Telephone
|
||||
{
|
||||
get { return data.Telephone; }
|
||||
set { data.Telephone = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
NotDeleted = 0,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
Any,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> ProvinceIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>USGA Facility Ids.</summary>
|
||||
public List<SysId> UsgaFacilityIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Generic filter - partial province code or name.</summary>
|
||||
public String FacilityFilter { get; set; }
|
||||
public String FacilityNameFull { get; set; }
|
||||
public String FacilityNamePartial { get; set; }
|
||||
// Associated data.
|
||||
public BoolState HasCourses { get; set; } = BoolState.Either;
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Country { get; set; }
|
||||
public String Alias_Province { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaFacilityList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaFacility GetFacilityById(this IEnumerable<SaxGolfUsgaFacility> values, SysId facilityId)
|
||||
{
|
||||
if (!SysId.IsValid(facilityId)) return null;
|
||||
foreach (SaxGolfUsgaFacility province in values)
|
||||
if (province.Id.Equals(facilityId)) return province;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
// Golf - USGA Marker.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaMarker : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryId,
|
||||
Country_Name,
|
||||
ProvinceId,
|
||||
Province_Name,
|
||||
FacilityId,
|
||||
Facility_Name,
|
||||
CourseId,
|
||||
UsgaCourseId,
|
||||
Course_Name,
|
||||
UsgaMarkerId,
|
||||
Caption,
|
||||
Holes,
|
||||
HolesCaption,
|
||||
Tee,
|
||||
Gender,
|
||||
SlopeRating,
|
||||
Par,
|
||||
CourseRating,
|
||||
BogeyRating,
|
||||
Length,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId CourseId { get; set; }
|
||||
public SysId UsgaMarkerId { get; set; }
|
||||
public String Caption { get; set; } = "";
|
||||
public short Holes { get; set; }
|
||||
public String HolesCaption { get; set; } = "";
|
||||
public String Tee { get; set; } = "";
|
||||
public String Gender { get; set; } = "";
|
||||
public short SlopeRating { get; set; }
|
||||
public short Par { get; set; }
|
||||
public decimal CourseRating { get; set; }
|
||||
public decimal BogeyRating { get; set; }
|
||||
public short Length { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId CourseId
|
||||
{
|
||||
get { return data.CourseId; }
|
||||
set { CheckChanged(data.CourseId, value); data.CourseId = value; }
|
||||
}
|
||||
public SysId UsgaMarkerId
|
||||
{
|
||||
get { return data.UsgaMarkerId; }
|
||||
set { CheckChanged(data.UsgaMarkerId, value); data.UsgaMarkerId = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { CheckChanged(data.Caption, value); data.Caption = value; }
|
||||
}
|
||||
public short Holes
|
||||
{
|
||||
get { return data.Holes; }
|
||||
set { CheckChanged(data.Holes, value); data.Holes = value; }
|
||||
}
|
||||
public String HolesCaption
|
||||
{
|
||||
get { return data.HolesCaption; }
|
||||
set { CheckChanged(data.HolesCaption, value); data.HolesCaption = value; }
|
||||
}
|
||||
public String Tee
|
||||
{
|
||||
get { return data.Tee; }
|
||||
set { CheckChanged(data.Tee, value); data.Tee = value; }
|
||||
}
|
||||
public String Gender
|
||||
{
|
||||
get { return data.Gender; }
|
||||
set { CheckChanged(data.Gender, value); data.Gender = value; }
|
||||
}
|
||||
public short SlopeRating
|
||||
{
|
||||
get { return data.SlopeRating; }
|
||||
set { CheckChanged(data.SlopeRating, value); data.SlopeRating = value; }
|
||||
}
|
||||
public short Par
|
||||
{
|
||||
get { return data.Par; }
|
||||
set { CheckChanged(data.Par, value); data.Par = value; }
|
||||
}
|
||||
public decimal CourseRating
|
||||
{
|
||||
get { return data.CourseRating; }
|
||||
set { CheckChanged(data.CourseRating, value); data.CourseRating = value; }
|
||||
}
|
||||
public decimal BogeyRating
|
||||
{
|
||||
get { return data.BogeyRating; }
|
||||
set { CheckChanged(data.BogeyRating, value); data.BogeyRating = value; }
|
||||
}
|
||||
public short Length
|
||||
{
|
||||
get { return data.Length; }
|
||||
set { CheckChanged(data.Length, value); data.Length = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
CourseId = data.CourseId;
|
||||
UsgaMarkerId = data.UsgaMarkerId;
|
||||
Caption = data.Caption;
|
||||
Holes = data.Holes;
|
||||
HolesCaption = data.HolesCaption;
|
||||
Tee = data.Tee;
|
||||
Gender = data.Gender;
|
||||
SlopeRating = data.SlopeRating;
|
||||
Par = data.Par;
|
||||
CourseRating = data.CourseRating;
|
||||
BogeyRating = data.BogeyRating;
|
||||
Length = data.Length;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue CourseId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UsgaMarkerId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Caption { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Holes { get; set; } = ValidValue.Valid;
|
||||
public ValidValue HolesCaption { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Tee { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Gender { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SlopeRating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Par { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CourseRating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue BogeyRating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Length { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaMarker(SysId id, SysId facilityId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.CourseId = facilityId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Golf_UsgaMarker, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId CourseId
|
||||
{
|
||||
get { return data.CourseId; }
|
||||
set { data.CourseId = value; }
|
||||
}
|
||||
public SysId UsgaMarkerId
|
||||
{
|
||||
get { return data.UsgaMarkerId; }
|
||||
set { data.UsgaMarkerId = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { data.Caption = value; }
|
||||
}
|
||||
public short Holes
|
||||
{
|
||||
get { return data.Holes; }
|
||||
set { data.Holes = value; }
|
||||
}
|
||||
public String HolesCaption
|
||||
{
|
||||
get { return data.HolesCaption; }
|
||||
set { data.HolesCaption = value; }
|
||||
}
|
||||
public String Tee
|
||||
{
|
||||
get { return data.Tee; }
|
||||
set { data.Tee = value; }
|
||||
}
|
||||
public String Gender
|
||||
{
|
||||
get { return data.Gender; }
|
||||
set { data.Gender = value; }
|
||||
}
|
||||
public short SlopeRating
|
||||
{
|
||||
get { return data.SlopeRating; }
|
||||
set { data.SlopeRating = value; }
|
||||
}
|
||||
public short Par
|
||||
{
|
||||
get { return data.Par; }
|
||||
set { data.Par = value; }
|
||||
}
|
||||
public decimal CourseRating
|
||||
{
|
||||
get { return data.CourseRating; }
|
||||
set { data.CourseRating = value; }
|
||||
}
|
||||
public decimal BogeyRating
|
||||
{
|
||||
get { return data.BogeyRating; }
|
||||
set { data.BogeyRating = value; }
|
||||
}
|
||||
public short Length
|
||||
{
|
||||
get { return data.Length; }
|
||||
set { data.Length = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
NotDeleted = 0,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
Any,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> CourseIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>USGA Marker Ids.</summary>
|
||||
public List<SysId> UsgaMarkerIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Generic filter - partial caption, holes, tee, gender etc.</summary>
|
||||
public String MarkerFilter { get; set; }
|
||||
// Marker proprerties.
|
||||
public short Holes { get; set; }
|
||||
public String Gender { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Country { get; set; }
|
||||
public String Alias_Province { get; set; }
|
||||
public String Alias_Facility { get; set; }
|
||||
public String Alias_Course{ get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaMarkerList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaMarker GetMarkerById(this IEnumerable<SaxGolfUsgaMarker> values, SysId markerId)
|
||||
{
|
||||
if (!SysId.IsValid(markerId)) return null;
|
||||
foreach (SaxGolfUsgaMarker province in values)
|
||||
if (province.Id.Equals(markerId)) return province;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
// Golf - USGA Province.
|
||||
//=======================================================================
|
||||
public abstract class SaxGolfUsgaProvince : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
CountryId,
|
||||
Country_Name,
|
||||
ProvinceCode,
|
||||
EntProvinceCode,
|
||||
ProvinceName,
|
||||
CoursesUpdateAt_Date,
|
||||
// Associated data.
|
||||
FacilityCount_All,
|
||||
FacilityCount_Active,
|
||||
CourseCount_All,
|
||||
CourseCount_Active,
|
||||
/// <summary>Marker population %.</summary>
|
||||
MarkerPercent,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId CountryId { get; set; }
|
||||
public String ProvinceCode { get; set; } = String.Empty;
|
||||
public String EntProvinceCode { get; set; } = String.Empty;
|
||||
public String ProvinceName { get; set; } = String.Empty;
|
||||
public DateTime? CoursesUpdateAt { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId CountryId
|
||||
{
|
||||
get { return data.CountryId; }
|
||||
set { CheckChanged(data.CountryId, value); data.CountryId = value; }
|
||||
}
|
||||
public String ProvinceCode
|
||||
{
|
||||
get { return data.ProvinceCode; }
|
||||
set { CheckChanged(data.ProvinceCode, value); data.ProvinceCode = value; }
|
||||
}
|
||||
public String EntProvinceCode
|
||||
{
|
||||
get { return data.EntProvinceCode; }
|
||||
set { CheckChanged(data.EntProvinceCode, value); data.EntProvinceCode = value; }
|
||||
}
|
||||
public String ProvinceName
|
||||
{
|
||||
get { return data.ProvinceName; }
|
||||
set { CheckChanged(data.ProvinceName, value); data.ProvinceName = value; }
|
||||
}
|
||||
public DateTime? CoursesUpdateAt
|
||||
{
|
||||
get { return data.CoursesUpdateAt; }
|
||||
set { CheckChangedNullable(data.CoursesUpdateAt, value); data.CoursesUpdateAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
CountryId = data.CountryId;
|
||||
ProvinceCode = data.ProvinceCode;
|
||||
EntProvinceCode = data.EntProvinceCode;
|
||||
ProvinceName = data.ProvinceName;
|
||||
CoursesUpdateAt = data.CoursesUpdateAt;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue CountryId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProvinceCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EntProvinceCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProvinceName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CoursesUpdateAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxGolfUsgaProvince(SysId id, SysId countryId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.CountryId = countryId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Golf_UsgaProvince, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void Dispose() { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId CountryId
|
||||
{
|
||||
get { return data.CountryId; }
|
||||
set { data.CountryId = value; }
|
||||
}
|
||||
public String ProvinceCode
|
||||
{
|
||||
get { return data.ProvinceCode; }
|
||||
set { data.ProvinceCode = value; }
|
||||
}
|
||||
public String EntProvinceCode
|
||||
{
|
||||
get { return data.EntProvinceCode; }
|
||||
set { data.EntProvinceCode = value; }
|
||||
}
|
||||
public String ProvinceName
|
||||
{
|
||||
get { return data.ProvinceName; }
|
||||
set { data.ProvinceName = value; }
|
||||
}
|
||||
public DateTime? CoursesUpdateAt
|
||||
{
|
||||
get { return data.CoursesUpdateAt; }
|
||||
set { data.CoursesUpdateAt = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
public const byte Flag_Priority = 0x01;
|
||||
public bool Priority
|
||||
{
|
||||
get { return GetFlag(Flag_Priority); }
|
||||
set { SetFlag(Flag_Priority, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
NotDeleted = 0,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
Any,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> CountryIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Generic filter - partial province code or name.</summary>
|
||||
public String ProvinceFilter { get; set; }
|
||||
public String ProvinceCodeFull { get; set; }
|
||||
public String ProvinceNameFull { get; set; }
|
||||
public String ProvinceNamePartial { get; set; }
|
||||
// Flags.
|
||||
public FlagState PriorityFlagState { get; set; } = FlagState.Either;
|
||||
// Associated data.
|
||||
public BoolState HasFacilities { get; set; } = BoolState.Either;
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Country { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxGolfUsgaProvinceList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxGolfUsgaProvince GetProvinceById(this IEnumerable<SaxGolfUsgaProvince> values, SysId provinceId)
|
||||
{
|
||||
if (!SysId.IsValid(provinceId)) return null;
|
||||
foreach (SaxGolfUsgaProvince province in values)
|
||||
if (province.Id.Equals(provinceId)) return province;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// ActivityIndex.
|
||||
//=======================================================================
|
||||
public abstract class SaxActivityFeedback : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
// Feedback.
|
||||
ViewCount,
|
||||
FeedbackCount,
|
||||
FeedbackTotal,
|
||||
FeedbackAverage,
|
||||
// Common.
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public long ViewCount { get; set; }
|
||||
public long FeedbackCount { get; set; }
|
||||
public long FeedbackTotal { get; set; }
|
||||
public decimal FeedbackAverage { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data() { }
|
||||
// Properties.
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public long ViewCount
|
||||
{
|
||||
get { return data.ViewCount; }
|
||||
set { CheckChanged(data.ViewCount, value); data.ViewCount = value; }
|
||||
}
|
||||
public long FeedbackCount
|
||||
{
|
||||
get { return data.FeedbackCount; }
|
||||
set { CheckChanged(data.FeedbackCount, value); data.FeedbackCount = value; }
|
||||
}
|
||||
public long FeedbackTotal
|
||||
{
|
||||
get { return data.FeedbackTotal; }
|
||||
set { CheckChanged(data.FeedbackTotal, value); data.FeedbackTotal = value; }
|
||||
}
|
||||
public decimal FeedbackAverage
|
||||
{
|
||||
get { return data.FeedbackAverage; }
|
||||
set { CheckChanged(data.FeedbackAverage, value); data.FeedbackAverage = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
ViewCount = data.ViewCount;
|
||||
FeedbackCount = data.FeedbackCount;
|
||||
FeedbackTotal = data.FeedbackTotal;
|
||||
FeedbackAverage = data.FeedbackAverage;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ViewCount { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FeedbackCount { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FeedbackTotal { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FeedbackAverage { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxActivityFeedback(ItemId itemId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item Types.
|
||||
private readonly static List<Sax.DataItemType> validItemTypes = new List<Sax.DataItemType>()
|
||||
{ Sax.DataItemType.Article, Sax.DataItemType.OrganisationEvent, Sax.DataItemType.OrganisationOpportunity };
|
||||
public static List<Sax.DataItemType> ValidItemTypes { get { return new List<Sax.DataItemType>(validItemTypes); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void Dispose() { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public long ViewCount
|
||||
{
|
||||
get { return data.ViewCount; }
|
||||
set { data.ViewCount = value; }
|
||||
}
|
||||
public long FeedbackCount
|
||||
{
|
||||
get { return data.FeedbackCount; }
|
||||
set { data.FeedbackCount = value; }
|
||||
}
|
||||
public long FeedbackTotal
|
||||
{
|
||||
get { return data.FeedbackTotal; }
|
||||
set { data.FeedbackTotal = value; }
|
||||
}
|
||||
public decimal FeedbackAverage
|
||||
{
|
||||
get { return data.FeedbackAverage; }
|
||||
set { data.FeedbackAverage = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Combination Sport and Region Ids to index activities.
|
||||
/// </summary>
|
||||
public class SportFeedbackAverages
|
||||
{
|
||||
public SportFeedbackAverages(SysId sportId, SysId regionId)
|
||||
{
|
||||
FeedbackTotal = sportId;
|
||||
FeedbackAverage = regionId;
|
||||
}
|
||||
public SysId FeedbackTotal { get; }
|
||||
public SysId FeedbackAverage { get; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxActivityFeedbackList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// ActivityIndex.
|
||||
//=======================================================================
|
||||
public abstract class SaxActivityIndex : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
// Author.
|
||||
// Organisation.
|
||||
OrganisationIdOwner,
|
||||
OrganisationOwner_Name,
|
||||
OrganisationOwner_LogoCount,
|
||||
// User Activity.
|
||||
UserActivity_UserAccountId,
|
||||
UserActivity_ListedAtLast,
|
||||
UserActivity_ViewedAtLast,
|
||||
UserActivity_Reaction,
|
||||
UserActivity_ReactedAtLast,
|
||||
// Article.
|
||||
Article_Headline,
|
||||
Article_Summary,
|
||||
// Organisation opportunity.
|
||||
Opportunity_Position,
|
||||
Opportunity_Outline,
|
||||
// Sport.
|
||||
SportId,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionId,
|
||||
Region_Name,
|
||||
// Properties.
|
||||
EffectiveOn,
|
||||
ExpiresOn,
|
||||
// Associated data.
|
||||
// Derived properties.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public SysId UserAccountIdOwner { get; set; }
|
||||
public SysId OrganisationIdOwner { get; set; }
|
||||
public SysId SportId { get; set; }
|
||||
public SysId RegionId { get; set; }
|
||||
public DateTime EffectiveOn { get; set; }
|
||||
public DateTime? ExpiresOn { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public SysId UserAccountIdOwner
|
||||
{
|
||||
get { return data.UserAccountIdOwner; }
|
||||
set { CheckChanged(data.UserAccountIdOwner, value); data.UserAccountIdOwner = value; }
|
||||
}
|
||||
public SysId OrganisationIdOwner
|
||||
{
|
||||
get { return data.OrganisationIdOwner; }
|
||||
set { CheckChanged(data.OrganisationIdOwner, value); data.OrganisationIdOwner = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
set { CheckChanged(data.SportId, value); data.SportId = value; }
|
||||
}
|
||||
public SysId RegionId
|
||||
{
|
||||
get { return data.RegionId; }
|
||||
set { CheckChanged(data.RegionId, value); data.RegionId = value; }
|
||||
}
|
||||
public DateTime EffectiveOn
|
||||
{
|
||||
get { return data.EffectiveOn; }
|
||||
set
|
||||
{
|
||||
// Values are restricted to whole date, ie. no time.
|
||||
CheckChanged(data.EffectiveOn, value.Date);
|
||||
data.EffectiveOn = value.Date;
|
||||
}
|
||||
}
|
||||
public DateTime? ExpiresOn
|
||||
{
|
||||
get { return data.ExpiresOn; }
|
||||
set
|
||||
{
|
||||
// Values are restricted to whole date, ie. no time.
|
||||
CheckChangedNullable(data.ExpiresOn, value?.Date);
|
||||
data.ExpiresOn = value?.Date;
|
||||
}
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
UserAccountIdOwner = data.UserAccountIdOwner;
|
||||
OrganisationIdOwner = data.OrganisationIdOwner;
|
||||
SportId = data.SportId;
|
||||
RegionId = data.RegionId;
|
||||
EffectiveOn = data.EffectiveOn;
|
||||
ExpiresOn = data.ExpiresOn;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserAccountIdOwner { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationIdOwner { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EffectiveOn { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpiresOn { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxActivityIndex(ItemId itemId, SysId sportId, SysId regionId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
SportId = sportId;
|
||||
RegionId = regionId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item Types.
|
||||
private readonly static List<Sax.DataItemType> validItemTypes = new List<Sax.DataItemType>()
|
||||
{ Sax.DataItemType.Article, Sax.DataItemType.OrganisationEvent, Sax.DataItemType.OrganisationOpportunity };
|
||||
public static List<Sax.DataItemType> ValidItemTypes { get { return new List<Sax.DataItemType>(validItemTypes); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
/// <summary>
|
||||
/// Match the item to the sport and region.
|
||||
/// </summary>
|
||||
public bool MatchesSportRegion(SysId sportId, SysId regionId)
|
||||
{
|
||||
if (!SportId.Equals(sportId)) return false;
|
||||
if (!RegionId.Equals(regionId)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override bool ItemHasId() { return false; }
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed");
|
||||
if (SysId.IsValid(SportId) && SysId.ToInt(SportId) != SysId.ToInt(data.SportId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Sport Id cannot be changed");
|
||||
if (SysId.IsValid(RegionId) && SysId.ToInt(RegionId) != SysId.ToInt(data.RegionId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Region Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public SysId UserAccountIdOwner
|
||||
{
|
||||
get { return data.UserAccountIdOwner; }
|
||||
set { data.UserAccountIdOwner = value; }
|
||||
}
|
||||
public SysId OrganisationIdOwner
|
||||
{
|
||||
get { return data.OrganisationIdOwner; }
|
||||
set { data.OrganisationIdOwner = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
protected set { data.SportId = value; }
|
||||
}
|
||||
public SysId RegionId
|
||||
{
|
||||
get { return data.RegionId; }
|
||||
protected set { data.RegionId = value; }
|
||||
}
|
||||
public DateTime EffectiveOn
|
||||
{
|
||||
get { return data.EffectiveOn; }
|
||||
set { data.EffectiveOn = value; }
|
||||
}
|
||||
public DateTime? ExpiresOn
|
||||
{
|
||||
get { return data.ExpiresOn; }
|
||||
set { data.ExpiresOn = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Combination Sport and Region Ids to index activities.
|
||||
/// </summary>
|
||||
public class SportRegionIds
|
||||
{
|
||||
public SportRegionIds(SysId sportId, SysId regionId)
|
||||
{
|
||||
SportId = sportId;
|
||||
RegionId = regionId;
|
||||
}
|
||||
public SysId SportId { get; }
|
||||
public SysId RegionId { get; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
/// <summary>Activities must match one of the sport/region combinations specified.</summary>
|
||||
public List<SportRegionIds> SportRegionIdsIncluded { get; } = new List<SportRegionIds>();
|
||||
/// <summary>Owner User Accounts - to include activities in result for users regardless of sports/regions.</summary>
|
||||
public List<SysId> UserAccountIdsOwnerIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Owner Organisations - to include activities in result for organisations regardless of sport/region combinations.</summary>
|
||||
public List<SysId> OrganisationIdsOwnerIncluded { get; } = new List<SysId>();
|
||||
/// <summary>User Account - to include User Activity data in result.</summary>
|
||||
public SysId UserAccountId { get; set; }
|
||||
public DateTime EffectiveFrom { get; set; }
|
||||
public DateTime EffectiveTo { get; set; }
|
||||
/// <summary>Not Expired - either Expiry date not set or is after specified date.</summary>
|
||||
public DateTime NotExpiredOn { get; set; }
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_ActivityIndex { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxActivityIndexList
|
||||
{
|
||||
/// <summary>
|
||||
/// Get first entry that matches the sport and region.
|
||||
/// </summary>
|
||||
public static SaxActivityIndex GetActivityIndexBySportRegion(this List<SaxActivityIndex> values, SysId sportId, SysId regionId)
|
||||
{
|
||||
return values.Find(item => item.MatchesSportRegion(sportId, regionId));
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Article - Content data.
|
||||
//=======================================================================
|
||||
partial class SaxArticle
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
private static readonly String ElementName_Content = "content";
|
||||
private static readonly String ElementName_Segments = "segments";
|
||||
private static readonly String ElementName_Segment = "segment";
|
||||
private static readonly String ElementName_Body = "body";
|
||||
private static readonly String ElementName_Html = "html";
|
||||
private static readonly String ElementName_Image = "image";
|
||||
private static readonly String ElementName_ImageId = "imageId";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Article content.</summary>
|
||||
public class ContentData
|
||||
{
|
||||
/// <summary>
|
||||
/// Article Content Segment - either body content or image.
|
||||
/// </summary>
|
||||
public class SegmentData
|
||||
{
|
||||
// Segment body.
|
||||
public class BodyData
|
||||
{
|
||||
public bool IsValid()
|
||||
{
|
||||
if (!StringUtil.IsEmpty(Html)) return true;
|
||||
return false;
|
||||
}
|
||||
public String Html { get; set; } = String.Empty;
|
||||
}
|
||||
public BodyData Body { get; } = new BodyData();
|
||||
// Segment image.
|
||||
public class ImageData
|
||||
{
|
||||
public bool IsValid()
|
||||
{
|
||||
if (SysId.IsValid(ItemImageId)) return true;
|
||||
return false;
|
||||
}
|
||||
public SysId ItemImageId { get; set; }
|
||||
}
|
||||
public ImageData Image { get; } = new ImageData();
|
||||
// Validate.
|
||||
public bool IsValid()
|
||||
{
|
||||
if (Body.IsValid()) return true;
|
||||
if (Image.IsValid()) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public List<SegmentData> Segments { get; } = new List<SegmentData>();
|
||||
// Add segment.
|
||||
public SegmentData AddSegment()
|
||||
{
|
||||
SegmentData segment = new SegmentData();
|
||||
Segments.Add(segment);
|
||||
return segment;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Convert serialised data from database to Content.
|
||||
/// </summary>
|
||||
public static ContentData ExtractContent(String contentData)
|
||||
{
|
||||
ContentData content = new ContentData();
|
||||
if (StringUtil.IsEmpty(contentData)) return content;
|
||||
|
||||
try
|
||||
{
|
||||
// Load XML data.
|
||||
XDocument doc = XDocument.Parse(contentData);
|
||||
XElement rootElement = doc.Root;
|
||||
foreach (XElement rootChildElement in rootElement.GetChildElements())
|
||||
{
|
||||
String rootChildElementName = rootChildElement.GetLocalName();
|
||||
if (rootChildElementName.EqualsCI(ElementName_Segments))
|
||||
{
|
||||
// Content segments.
|
||||
XElement segmentsElement = rootChildElement;
|
||||
foreach (XElement segmentsChildElement in segmentsElement.GetChildElements())
|
||||
{
|
||||
String segmentsChildElementName = segmentsChildElement.GetLocalName();
|
||||
if (segmentsChildElementName.EqualsCI(ElementName_Segment))
|
||||
{
|
||||
// Content segment.
|
||||
ContentData.SegmentData segment = new ContentData.SegmentData();
|
||||
XElement segmentElement = segmentsChildElement;
|
||||
foreach (XElement segmentChildElement in segmentElement.GetChildElements())
|
||||
{
|
||||
String segmentChildElementName = segmentChildElement.GetLocalName();
|
||||
if (segmentChildElementName.EqualsCI(ElementName_Body))
|
||||
{
|
||||
// Content segment body.
|
||||
XElement bodyElement = segmentChildElement;
|
||||
foreach (XElement bodyChildElement in bodyElement.GetChildElements())
|
||||
{
|
||||
String bodyChildElementName = bodyChildElement.GetLocalName();
|
||||
if (bodyChildElementName.EqualsCI(ElementName_Html))
|
||||
{
|
||||
// Content segment body HTML.
|
||||
XElement htmlElement = bodyChildElement;
|
||||
segment.Body.Html = htmlElement.Value;
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Segment' child element: " + segmentChildElementName);
|
||||
}
|
||||
}
|
||||
else if (segmentChildElementName.EqualsCI(ElementName_Image))
|
||||
{
|
||||
// Content segment image.
|
||||
XElement imageElement = segmentChildElement;
|
||||
foreach (XElement imageChildElement in imageElement.GetChildElements())
|
||||
{
|
||||
String imageChildElementName = imageChildElement.GetLocalName();
|
||||
if (imageChildElementName.EqualsCI(ElementName_ImageId))
|
||||
{
|
||||
// Content segment image Id.
|
||||
XElement imageIdElement = imageChildElement;
|
||||
segment.Image.ItemImageId = SysId.ToSysId(imageIdElement.Value);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Segment' child element: " + segmentChildElementName);
|
||||
}
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Segment' child element: " + segmentChildElementName);
|
||||
}
|
||||
// Add this segment to the list.
|
||||
if (segment.IsValid())
|
||||
content.Segments.Add(segment);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Segments' child element: " + segmentsChildElementName);
|
||||
}
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Root' child element: " + rootChildElementName);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Convert Content to serialised data to store on database.
|
||||
/// </summary>
|
||||
public static String GetContentData(ContentData content)
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
XElement contentElement = doc.AppendElement(ElementName_Content);
|
||||
XElement segmentsElement = contentElement.AppendElement(ElementName_Segments);
|
||||
foreach (ContentData.SegmentData segment in content.Segments)
|
||||
{
|
||||
if (!segment.IsValid()) continue;
|
||||
XElement segmentElement = segmentsElement.AppendElement(ElementName_Segment);
|
||||
if (segment.Body.IsValid())
|
||||
{
|
||||
// Segment Body.
|
||||
XElement bodyElement = segmentElement.AppendElement(ElementName_Body);
|
||||
if (!StringUtil.IsEmpty(segment.Body.Html))
|
||||
bodyElement.AppendElement(ElementName_Html, segment.Body.Html);
|
||||
}
|
||||
else if (segment.Image.IsValid())
|
||||
{
|
||||
// Segment Image.
|
||||
XElement imageElement = segmentElement.AppendElement(ElementName_Image);
|
||||
if (SysId.IsValid(segment.Image.ItemImageId))
|
||||
imageElement.AppendElement(ElementName_ImageId, SysId.ToString(segment.Image.ItemImageId));
|
||||
}
|
||||
}
|
||||
return doc.GetXml();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Article.
|
||||
//=======================================================================
|
||||
public abstract partial class SaxArticle : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Author.
|
||||
UserAccountIdAuthor,
|
||||
Author_DisplayName,
|
||||
Author_Title,
|
||||
Author_FirstName,
|
||||
Author_LastName,
|
||||
// Organisation.
|
||||
OrganisationId,
|
||||
Organisation_Name,
|
||||
Organisation_LogoCount,
|
||||
// Sport.
|
||||
SportIdPrimary,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionIdPrimary,
|
||||
Region_Name,
|
||||
// Article.
|
||||
Headline,
|
||||
Summary,
|
||||
ItemImageIdThumbnail,
|
||||
PublishedAt_Date,
|
||||
PublishedAt_DateTime,
|
||||
// Feedback.
|
||||
Feedback_ViewCount,
|
||||
Feedback_FeedbackCount,
|
||||
Feedback_FeedbackTotal,
|
||||
Feedback_FeedbackAverage,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountIdAuthor { get; set; }
|
||||
public SysId OrganisationId { get; set; }
|
||||
public String Headline { get; set; } = String.Empty;
|
||||
public String Summary { get; set; } = String.Empty;
|
||||
public SysId ItemImageIdThumbnail { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public SysId RegionIdPrimary { get; set; }
|
||||
public String BodyData { get; set; } = String.Empty;
|
||||
public DateTime? PublishedAt { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountIdAuthor
|
||||
{
|
||||
get { return data.UserAccountIdAuthor; }
|
||||
set { CheckChanged(data.UserAccountIdAuthor, value); data.UserAccountIdAuthor = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { CheckChanged(data.RegionIdPrimary, value); data.RegionIdPrimary = value; }
|
||||
}
|
||||
public String Headline
|
||||
{
|
||||
get { return data.Headline; }
|
||||
set { CheckChanged(data.Headline, value); data.Headline = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { CheckChanged(data.Summary, value); data.Summary = value; }
|
||||
}
|
||||
public SysId ItemImageIdThumbnail
|
||||
{
|
||||
get { return data.ItemImageIdThumbnail; }
|
||||
set { CheckChanged(data.ItemImageIdThumbnail, value); data.ItemImageIdThumbnail = value; }
|
||||
}
|
||||
public String BodyData
|
||||
{
|
||||
get { return data.BodyData; }
|
||||
set { CheckChanged(data.BodyData, value); data.BodyData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { CheckChangedNullable(data.PublishedAt, value); data.PublishedAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountIdAuthor = data.UserAccountIdAuthor;
|
||||
OrganisationId = data.OrganisationId;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
RegionIdPrimary = data.RegionIdPrimary;
|
||||
Headline = data.Headline;
|
||||
Summary = data.Summary;
|
||||
ItemImageIdThumbnail = data.ItemImageIdThumbnail;
|
||||
BodyData = data.BodyData;
|
||||
PublishedAt = data.PublishedAt;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountIdAuthor { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Headline { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Summary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ItemImageIdThumbnail { get; set; } = ValidValue.Valid;
|
||||
public ValidValue BodyData { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PublishedAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxArticle(SysId id, SysId UserAccountIdAuthor, SysId organisationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.UserAccountIdAuthor = UserAccountIdAuthor;
|
||||
this.OrganisationId = organisationId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Article, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountIdAuthor) && SysId.ToInt(UserAccountIdAuthor) != SysId.ToInt(data.UserAccountIdAuthor))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} UserAccountIdAuthor cannot be changed");
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} OrganisationId cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountIdAuthor
|
||||
{
|
||||
get { return data.UserAccountIdAuthor; }
|
||||
protected set { data.UserAccountIdAuthor = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
protected set { data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { data.RegionIdPrimary = value; }
|
||||
}
|
||||
public String Headline
|
||||
{
|
||||
get { return data.Headline; }
|
||||
set { data.Headline = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { data.Summary = value; }
|
||||
}
|
||||
public SysId ItemImageIdThumbnail
|
||||
{
|
||||
get { return data.ItemImageIdThumbnail; }
|
||||
set { data.ItemImageIdThumbnail = value; }
|
||||
}
|
||||
public String BodyData
|
||||
{
|
||||
get { return data.BodyData; }
|
||||
set { data.BodyData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { data.PublishedAt = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> UserAccountIdsAuthorIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Restrict to articles belonging to organisation.</summary>
|
||||
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
/// <summary>Exclude articles belonging to organisations. Ignored if any organisations specified.</summary>
|
||||
public bool ExcludeOrganisationArticles { get; set; }
|
||||
public List<SysId> SportIdsIncluded { get; set; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public String HeadlinePartial { get; set; }
|
||||
public String SummaryPartial { get; set; }
|
||||
/// <summary>General filter value - headline, summary, sport, body etc. </summary>
|
||||
public String ArticleFilter { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxAuthorArticleList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Contact data - associated with Organisations, Users etc.
|
||||
//=======================================================================
|
||||
public class SaxContactData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
private static readonly String ElementName_ContactMethods = "contactMethods";
|
||||
private static readonly String ElementName_ContactMethod = "contactMethod";
|
||||
private static readonly String AttributeName_Method = "method";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private class ContactMethodData
|
||||
{
|
||||
public Sax.ContactMethod Method { get; set; }
|
||||
public String Value { get; set; }
|
||||
}
|
||||
private Dictionary<Sax.ContactMethod, ContactMethodData> contactMethods { get; } = new Dictionary<Sax.ContactMethod, ContactMethodData>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction - from serialised data.
|
||||
public SaxContactData(String contactData = "")
|
||||
{
|
||||
ExtractContactData(contactData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public List<Sax.ContactMethod> Methods { get { return contactMethods.Keys.ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Contact Methods.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Extract the value associated with the specified method.</summary>
|
||||
public String GetContactMethodValue(Sax.ContactMethod method)
|
||||
{
|
||||
return contactMethods.GetValueOrDefault(method, new ContactMethodData()).Value;
|
||||
}
|
||||
|
||||
/// <summary>Set the value associated with the specified method.</summary>
|
||||
public bool SetContactMethodValue(Sax.ContactMethod method, String value)
|
||||
{
|
||||
if ((int)method < 1 || value.IsEmpty()) return false;
|
||||
ContactMethodData contactMethod = contactMethods.GetValueOrDefault(method, null);
|
||||
if (contactMethod == null)
|
||||
contactMethods.Add(method, contactMethod = new ContactMethodData() { Method = method });
|
||||
contactMethod.Value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Clear the value associated with the specified method.</summary>
|
||||
public bool ClearContactMethod(Sax.ContactMethod method)
|
||||
{
|
||||
return contactMethods.Remove(method);
|
||||
}
|
||||
|
||||
/// <summary>Clear all contact methods.</summary>
|
||||
public void ClearContactMethods()
|
||||
{
|
||||
contactMethods.Clear();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Serialisation.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract contact methods from serialised data.
|
||||
/// </summary>
|
||||
private void ExtractContactData(String contactData)
|
||||
{
|
||||
contactMethods.Clear();
|
||||
if (StringUtil.IsEmpty(contactData)) return;
|
||||
|
||||
try
|
||||
{
|
||||
// Load XML data.
|
||||
XDocument doc = XDocument.Parse(contactData);
|
||||
XElement rootElement = doc.Root;
|
||||
foreach (XElement rootChildElement in rootElement.GetChildElements())
|
||||
{
|
||||
String rootChildElementName = rootChildElement.GetLocalName();
|
||||
if (rootChildElementName.EqualsCI(ElementName_ContactMethod))
|
||||
{
|
||||
// Contact Method.
|
||||
String methodValue = rootChildElement.GetAttributeValue(AttributeName_Method);
|
||||
Sax.ContactMethod method = EnumUtil.ParseEnum(methodValue, Sax.ContactMethod.Unknown);
|
||||
if (method != Sax.ContactMethod.Unknown)
|
||||
{
|
||||
ContactMethodData contactMethod = new ContactMethodData()
|
||||
{
|
||||
Method = method,
|
||||
Value = rootChildElement.Value
|
||||
};
|
||||
contactMethods.Add(method, contactMethod);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unrecognised contact method: " + methodValue);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Root' child element: " + rootChildElementName);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Convert to serialised data.
|
||||
/// </summary>
|
||||
public String GetContactData()
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
XElement contactMethodsElement = doc.AppendElement(ElementName_ContactMethods);
|
||||
foreach (ContactMethodData contactMethod in contactMethods.Values)
|
||||
{
|
||||
if ((int)contactMethod.Method < 1 || contactMethod.Value.IsEmpty()) continue;
|
||||
XElement contactMethodElement = contactMethodsElement.AppendElement(ElementName_ContactMethod, contactMethod.Value);
|
||||
contactMethodElement.SetAttribute(AttributeName_Method, contactMethod.Method.ToString());
|
||||
}
|
||||
return doc.GetXml();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using System;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
/// <summary>Preserves Saxonite's disposable hierarchy-item contract over Common hierarchy items.</summary>
|
||||
public abstract class SaxDisposableHierarchyItem : SacsHierarchyItem, IDisposable
|
||||
{
|
||||
protected SaxDisposableHierarchyItem() : base() { }
|
||||
protected SaxDisposableHierarchyItem(SysId id) : base(id) { }
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
/// <summary>Combines Common error-state behavior with Saxonite disposal behavior.</summary>
|
||||
public abstract class SaxDisposableStateItem : SacsDisposable
|
||||
{
|
||||
public enum ErrorMessage
|
||||
{
|
||||
DatabaseNotAvailable,
|
||||
DatabaseQueryException,
|
||||
ItemNotSpecified,
|
||||
ValidItemId,
|
||||
InvalidItemId,
|
||||
ItemIdNotSpecified,
|
||||
ItemTypeNotSpecified,
|
||||
InvalidItemSpecified,
|
||||
MultipleItemsFound,
|
||||
InvalidDate,
|
||||
InvalidStatus,
|
||||
}
|
||||
|
||||
private SacsErrorState errorState;
|
||||
|
||||
public bool OK { get { return !HasErrorState(); } }
|
||||
public bool HasErrorState() { return errorState != null; }
|
||||
public SacsErrorState ErrorState { get { return errorState; } }
|
||||
public String ErrorStateMessage { get { return errorState?.Message ?? String.Empty; } }
|
||||
|
||||
public bool SetErrorState(String message)
|
||||
{
|
||||
if (StringUtil.IsBlank(message)) return false;
|
||||
errorState = new SacsErrorState(message);
|
||||
return false;
|
||||
}
|
||||
public void ClearErrorState() { errorState = null; }
|
||||
|
||||
protected bool SetErrorState(ErrorMessage errorMessage) { return SetErrorState(GetErrorMessage(errorMessage)); }
|
||||
private String GetErrorMessage(ErrorMessage errorMessage)
|
||||
{
|
||||
return errorMessage switch
|
||||
{
|
||||
ErrorMessage.DatabaseNotAvailable => "Database is not available",
|
||||
ErrorMessage.DatabaseQueryException => "Database query exception",
|
||||
ErrorMessage.ItemNotSpecified => "Item not specified",
|
||||
ErrorMessage.ValidItemId => "Item has a valid id",
|
||||
ErrorMessage.InvalidItemId => "Invalid item id",
|
||||
ErrorMessage.ItemIdNotSpecified => "Item Id must be specified",
|
||||
ErrorMessage.ItemTypeNotSpecified => "Item type must be specified",
|
||||
ErrorMessage.InvalidItemSpecified => "Invalid item specified",
|
||||
ErrorMessage.MultipleItemsFound => "Multiple items found",
|
||||
ErrorMessage.InvalidDate => "Invalid date",
|
||||
ErrorMessage.InvalidStatus => "Invalid status",
|
||||
_ => errorMessage.ToString(),
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,476 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemAddress.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemAddress : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
Item_Caption,
|
||||
// Address.
|
||||
AddressType,
|
||||
AddressType_Code,
|
||||
AddressType_Desc,
|
||||
Caption,
|
||||
Line1,
|
||||
Line2,
|
||||
Line3,
|
||||
Town,
|
||||
Province,
|
||||
Country,
|
||||
PostalCode,
|
||||
PhoneMain,
|
||||
// Regions.
|
||||
RegionIdProvince,
|
||||
RegionProvince_Name,
|
||||
RegionIdCountry,
|
||||
RegionCountry_Name,
|
||||
// Location.
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public Sax.AddressType AddressType { get; set; }
|
||||
public String Caption { get; set; }
|
||||
public String Line1 { get; set; }
|
||||
public String Line2 { get; set; }
|
||||
public String Line3 { get; set; }
|
||||
public String Town { get; set; }
|
||||
public String Province { get; set; }
|
||||
public SysId RegionIdProvince { get; set; }
|
||||
public String Country { get; set; }
|
||||
public SysId RegionIdCountry { get; set; }
|
||||
public String PostalCode { get; set; }
|
||||
public String PhoneMain { get; set; }
|
||||
// Location.
|
||||
public String LocationSource { get; set; }
|
||||
public DateTime? LocationStoredAt { get; set; } = null;
|
||||
public bool LocationUpdateRequired { get; set; }
|
||||
public String LocationData { get; set; }
|
||||
public String LocationFormattedAddress { get; set; }
|
||||
public Decimal? LocationLatitude { get; set; } = null;
|
||||
public Decimal? LocationLongitude { get; set; } = null;
|
||||
public Decimal? LocationAltitude { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public Sax.AddressType AddressType
|
||||
{
|
||||
get { return data.AddressType; }
|
||||
set { CheckChanged((short)data.AddressType, (short)value); data.AddressType = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { CheckChanged(data.Caption, value); data.Caption = value; }
|
||||
}
|
||||
public String Line1
|
||||
{
|
||||
get { return data.Line1; }
|
||||
set { CheckChanged(data.Line1, value); data.Line1 = value; }
|
||||
}
|
||||
public String Line2
|
||||
{
|
||||
get { return data.Line2; }
|
||||
set { CheckChanged(data.Line2, value); data.Line2 = value; }
|
||||
}
|
||||
public String Line3
|
||||
{
|
||||
get { return data.Line3; }
|
||||
set { CheckChanged(data.Line3, value); data.Line3 = value; }
|
||||
}
|
||||
public String Town
|
||||
{
|
||||
get { return data.Town; }
|
||||
set { CheckChanged(data.Town, value); data.Town = value; }
|
||||
}
|
||||
public String PostalCode
|
||||
{
|
||||
get { return data.PostalCode; }
|
||||
set { CheckChanged(data.PostalCode, value); data.PostalCode = value; }
|
||||
}
|
||||
public String Province
|
||||
{
|
||||
get { return data.Province; }
|
||||
set { CheckChanged(data.Province, value); data.Province = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { CheckChanged(data.RegionIdProvince, value); data.RegionIdProvince = value; }
|
||||
}
|
||||
public String Country
|
||||
{
|
||||
get { return data.Country; }
|
||||
set { CheckChanged(data.Country, value); data.Country = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { CheckChanged(data.RegionIdCountry, value); data.RegionIdCountry = value; }
|
||||
}
|
||||
public String PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { CheckChanged(data.PhoneMain, value); data.PhoneMain = value; }
|
||||
}
|
||||
|
||||
// Location.
|
||||
public String LocationSource
|
||||
{
|
||||
get { return data.LocationSource; }
|
||||
set { CheckChanged(data.LocationSource, value); data.LocationSource = value; }
|
||||
}
|
||||
public DateTime? LocationStoredAt
|
||||
{
|
||||
get { return data.LocationStoredAt; }
|
||||
set { CheckChangedNullable(data.LocationStoredAt, value); data.LocationStoredAt = value; }
|
||||
}
|
||||
public bool LocationUpdateRequired
|
||||
{
|
||||
get { return data.LocationUpdateRequired; }
|
||||
set { CheckChanged(data.LocationUpdateRequired, value); data.LocationUpdateRequired = value; }
|
||||
}
|
||||
public String LocationData
|
||||
{
|
||||
get { return data.LocationData; }
|
||||
set { CheckChanged(data.LocationData, value); data.LocationData = value; }
|
||||
}
|
||||
public String LocationFormattedAddress
|
||||
{
|
||||
get { return data.LocationFormattedAddress; }
|
||||
set { CheckChanged(data.LocationFormattedAddress, value); data.LocationFormattedAddress = value; }
|
||||
}
|
||||
public Decimal? LocationLatitude
|
||||
{
|
||||
get { return data.LocationLatitude; }
|
||||
set { CheckChangedNullable(data.LocationLatitude, value); data.LocationLatitude = value; }
|
||||
}
|
||||
public Decimal? LocationLongitude
|
||||
{
|
||||
get { return data.LocationLongitude; }
|
||||
set { CheckChangedNullable(data.LocationLongitude, value); data.LocationLongitude = value; }
|
||||
}
|
||||
public Decimal? LocationAltitude
|
||||
{
|
||||
get { return data.LocationAltitude; }
|
||||
set { CheckChangedNullable(data.LocationAltitude, value); data.LocationAltitude = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
AddressType = data.AddressType;
|
||||
Caption = data.Caption;
|
||||
Line1 = data.Line1;
|
||||
Line2 = data.Line2;
|
||||
Line3 = data.Line3;
|
||||
Town = data.Town;
|
||||
RegionIdProvince = data.RegionIdProvince;
|
||||
Province = data.Province;
|
||||
RegionIdCountry = data.RegionIdCountry;
|
||||
Country = data.Country;
|
||||
PostalCode = data.PostalCode;
|
||||
PhoneMain = data.PhoneMain;
|
||||
// Location.
|
||||
LocationSource = data.LocationSource;
|
||||
LocationStoredAt = data.LocationStoredAt;
|
||||
LocationUpdateRequired = data.LocationUpdateRequired;
|
||||
LocationData = data.LocationData;
|
||||
LocationFormattedAddress = data.LocationFormattedAddress;
|
||||
LocationLatitude = data.LocationLatitude;
|
||||
LocationLongitude = data.LocationLongitude;
|
||||
LocationAltitude = data.LocationAltitude;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue AddressType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Caption { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Line1 { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Line2 { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Line3 { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Town { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdProvince { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Province { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdCountry { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Country { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PostalCode { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PhoneMain { get; set; } = ValidValue.Valid;
|
||||
// Location.
|
||||
public ValidValue LocationSource { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LocationStoredAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LocationUpdateRequired { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LocationData { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LocationFormattedAddress { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LocationLatitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LocationLongitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LocationAltitude { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemAddress(SysId id, ItemId itemId, Sax.AddressType addressType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
AddressType = addressType;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.ItemAddress, Id);
|
||||
}
|
||||
// Address types.
|
||||
public static Sax.AddressType DefaultOrganisationAddressType { get { return Sax.AddressType.Office; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed");
|
||||
if (SysId.IsValid(RegionIdProvince) && SysId.ToInt(RegionIdProvince) != SysId.ToInt(data.RegionIdProvince))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Address Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public Sax.AddressType AddressType
|
||||
{
|
||||
get { return data.AddressType; }
|
||||
set { data.AddressType = value; }
|
||||
}
|
||||
public String Caption
|
||||
{
|
||||
get { return data.Caption; }
|
||||
set { data.Caption = value; }
|
||||
}
|
||||
public String Line1
|
||||
{
|
||||
get { return data.Line1; }
|
||||
set { data.Line1 = value; }
|
||||
}
|
||||
public String Line2
|
||||
{
|
||||
get { return data.Line2; }
|
||||
set { data.Line2 = value; }
|
||||
}
|
||||
public String Line3
|
||||
{
|
||||
get { return data.Line3; }
|
||||
set { data.Line3 = value; }
|
||||
}
|
||||
public String Town
|
||||
{
|
||||
get { return data.Town; }
|
||||
set { data.Town = value; }
|
||||
}
|
||||
public String Province
|
||||
{
|
||||
get { return data.Province; }
|
||||
set { data.Province = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { data.RegionIdProvince = value; }
|
||||
}
|
||||
public String Country
|
||||
{
|
||||
get { return data.Country; }
|
||||
set { data.Country = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { data.RegionIdCountry = value; }
|
||||
}
|
||||
public String PostalCode
|
||||
{
|
||||
get { return data.PostalCode; }
|
||||
set { data.PostalCode = value; }
|
||||
}
|
||||
public String PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { data.PhoneMain = value; }
|
||||
}
|
||||
|
||||
// Location.
|
||||
public String LocationSource
|
||||
{
|
||||
get { return data.LocationSource; }
|
||||
set { data.LocationSource = value; }
|
||||
}
|
||||
public DateTime? LocationStoredAt
|
||||
{
|
||||
get { return data.LocationStoredAt; }
|
||||
set { data.LocationStoredAt = value; }
|
||||
}
|
||||
public bool LocationUpdateRequired
|
||||
{
|
||||
get { return data.LocationUpdateRequired; }
|
||||
set { data.LocationUpdateRequired = value; }
|
||||
}
|
||||
public String LocationData
|
||||
{
|
||||
get { return data.LocationData; }
|
||||
set { data.LocationData = value; }
|
||||
}
|
||||
public String LocationFormattedAddress
|
||||
{
|
||||
get { return data.LocationFormattedAddress; }
|
||||
set { data.LocationFormattedAddress = value; }
|
||||
}
|
||||
public Decimal? LocationLatitude
|
||||
{
|
||||
get { return data.LocationLatitude; }
|
||||
set { data.LocationLatitude = value; }
|
||||
}
|
||||
public Decimal? LocationLongitude
|
||||
{
|
||||
get { return data.LocationLongitude; }
|
||||
set { data.LocationLongitude = value; }
|
||||
}
|
||||
public Decimal? LocationAltitude
|
||||
{
|
||||
get { return data.LocationAltitude; }
|
||||
set { data.LocationAltitude = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public Sax.AddressType AddressType = Sax.AddressType.Unknown;
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
public String AddressSearch { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemAddressList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using static Sarand.Net.Standard.Base.Bus.ItemId;
|
||||
using static Sarand.Net.Standard.Base.ItemOptions.SaItemOptionDfn;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemAssociation : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item From.
|
||||
ItemTypeFrom,
|
||||
ItemTypeFrom_Code,
|
||||
ItemTypeFrom_Desc,
|
||||
ItemIdFrom,
|
||||
ItemFrom_Caption,
|
||||
// Item To.
|
||||
ItemTypeTo,
|
||||
ItemTypeTo_Code,
|
||||
ItemTypeTo_Desc,
|
||||
ItemIdTo,
|
||||
ItemTo_Caption,
|
||||
// Specific item properties.
|
||||
OrganisationFrom_Name,
|
||||
OrganisationFrom_SportIdPrimary,
|
||||
OrganisationFrom_RegionIdPrimary,
|
||||
OrganisationTo_Name,
|
||||
OrganisationTo_SportIdPrimary,
|
||||
OrganisationTo_RegionIdPrimary,
|
||||
// Association type.
|
||||
AssociationType,
|
||||
AssociationType_Code,
|
||||
AssociationType_Desc,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public class TypeOptionData
|
||||
{
|
||||
public TypeOptionData(Sax.AssociationTypeOption typeOption, String caption)
|
||||
{
|
||||
TypeOption = typeOption;
|
||||
Caption = StringUtil.OnBlank(caption);
|
||||
}
|
||||
public TypeOptionData(Sax.AssociationType associationType, bool reversed, String caption) :
|
||||
this(GetAssociationTypeOption(associationType, reversed), caption)
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public AssociationTypeOption TypeOption { get; }
|
||||
public String Caption { get; }
|
||||
// Comparison.
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null) return false;
|
||||
return Equals(obj as TypeOptionData);
|
||||
}
|
||||
public bool Equals(TypeOptionData value)
|
||||
{
|
||||
if (value == null) return false;
|
||||
if (this.TypeOption != value.TypeOption) return false;
|
||||
if (!this.Caption.EqualsCI(value.Caption)) return false;
|
||||
return true;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(TypeOption, Caption);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemIdFrom { get; set; } = new ItemId();
|
||||
public ItemId ItemIdTo { get; set; } = new ItemId();
|
||||
public Sax.AssociationType AssociationType { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public ItemId ItemIdFrom
|
||||
{
|
||||
get { return data.ItemIdFrom; }
|
||||
set { value = ItemId.InvalidOnNull(value); CheckChanged(data.ItemIdFrom, value); data.ItemIdFrom = value; }
|
||||
}
|
||||
public ItemId ItemIdTo
|
||||
{
|
||||
get { return data.ItemIdTo; }
|
||||
set { value = ItemId.InvalidOnNull(value); CheckChanged(data.ItemIdTo, value); data.ItemIdTo = value; }
|
||||
}
|
||||
public Sax.AssociationType AssociationType
|
||||
{
|
||||
get { return data.AssociationType; }
|
||||
set { CheckChanged((int)data.AssociationType, (int)value); data.AssociationType = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemIdFrom = data.ItemIdFrom;
|
||||
ItemIdTo = data.ItemIdTo;
|
||||
AssociationType = data.AssociationType;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemIdFrom { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ItemIdTo { get; set; } = ValidValue.Valid;
|
||||
public ValidValue AssociationType { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemAssociation(SysId id, ItemId itemIdFrom, ItemId itemIdTo, Sax.AssociationType associationType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemIdFrom = itemIdFrom;
|
||||
ItemIdTo = itemIdTo;
|
||||
AssociationType = associationType;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.ItemAssociation, Id);
|
||||
}
|
||||
/// <summary>Valid 'From' item types for Association type.</summary>
|
||||
public static List<Sax.DataItemType> GetValidFromItemTypesForAssociation(Sax.AssociationType associationType)
|
||||
{
|
||||
List<Sax.DataItemType> itemTypes = new List<Sax.DataItemType>();
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate:
|
||||
case Sax.AssociationType.Partner:
|
||||
itemTypes.Add(Sax.DataItemType.Organisation);
|
||||
break;
|
||||
}
|
||||
return itemTypes;
|
||||
}
|
||||
/// <summary>Valid 'To' item types for Association type.</summary>
|
||||
public static List<Sax.DataItemType> GetValidToItemTypesForAssociation(Sax.AssociationType associationType)
|
||||
{
|
||||
List<Sax.DataItemType> itemTypes = new List<Sax.DataItemType>();
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate:
|
||||
case Sax.AssociationType.Partner:
|
||||
itemTypes.Add(Sax.DataItemType.Organisation);
|
||||
break;
|
||||
}
|
||||
return itemTypes;
|
||||
}
|
||||
/// <summary>Determin type option from type and parent/child direction.</summary>
|
||||
/// <param name="associationType"></param>
|
||||
/// <param name="reversed"></param>
|
||||
/// <returns></returns>
|
||||
public static AssociationTypeOption GetAssociationTypeOption(Sax.AssociationType associationType, bool reversed)
|
||||
{
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate: return reversed ? AssociationTypeOption.AffiliateChild : AssociationTypeOption.AffiliateParent;
|
||||
case Sax.AssociationType.Partner: return AssociationTypeOption.Partner;
|
||||
}
|
||||
return AssociationTypeOption.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemIdFrom) && ItemIdFrom.Type != data.ItemIdFrom.Type && SysId.ToInt(ItemIdFrom.Id) != SysId.ToInt(data.ItemIdFrom.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} From Item Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemIdTo) && ItemIdTo.Type != data.ItemIdTo.Type && SysId.ToInt(ItemIdTo.Id) != SysId.ToInt(data.ItemIdTo.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} To Item Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemIdFrom
|
||||
{
|
||||
get { return data.ItemIdFrom; }
|
||||
set { data.ItemIdFrom = value; }
|
||||
}
|
||||
public ItemId ItemIdTo
|
||||
{
|
||||
get { return data.ItemIdTo; }
|
||||
set { data.ItemIdTo = value; }
|
||||
}
|
||||
public Sax.AssociationType AssociationType
|
||||
{
|
||||
get { return data.AssociationType; }
|
||||
set { data.AssociationType = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
/// <summary>Items that can be eitehr 'From' or 'To'.</summary>
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
/// <summary>Items that can only be the 'From' item.</summary>
|
||||
public List<ItemId> ItemIdsFromIncluded { get; } = new List<ItemId>();
|
||||
/// <summary>Items that can only be the 'To' item.</summary>
|
||||
public List<ItemId> ItemIdsToIncluded { get; } = new List<ItemId>();
|
||||
public List<Sax.AssociationType> AssociationTypesIncluded { get; } = new List<Sax.AssociationType>();
|
||||
// Common properties.
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxAssociationList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemImage.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemImage : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
Item_Caption,
|
||||
// Image.
|
||||
ImageType,
|
||||
ImageType_Code,
|
||||
ImageType_Desc,
|
||||
ImageSeq,
|
||||
Filename,
|
||||
Mime,
|
||||
ContentType,
|
||||
Width,
|
||||
Height,
|
||||
DataSize,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public Sax.ImageType ImageType { get; set; }
|
||||
public byte ImageSeq { get; set; }
|
||||
public long SessionUid { get; set; }
|
||||
public int ImageUid { get; set; }
|
||||
public String Filename { get; set; }
|
||||
public String Mime { get; set; }
|
||||
public String ContentType { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public byte[] ImageData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public Sax.ImageType ImageType
|
||||
{
|
||||
get { return data.ImageType; }
|
||||
set { CheckChanged((int)data.ImageType, (int)value); data.ImageType = value; }
|
||||
}
|
||||
public byte ImageSeq
|
||||
{
|
||||
get { return data.ImageSeq; }
|
||||
set { CheckChanged(data.ImageSeq, value); data.ImageSeq = value; }
|
||||
}
|
||||
public long SessionUid
|
||||
{
|
||||
get { return data.SessionUid; }
|
||||
set { CheckChanged(data.SessionUid, value); data.SessionUid = value; }
|
||||
}
|
||||
public int ImageUid
|
||||
{
|
||||
get { return data.ImageUid; }
|
||||
set { CheckChanged(data.ImageUid, value); data.ImageUid = value; }
|
||||
}
|
||||
public String Filename
|
||||
{
|
||||
get { return data.Filename; }
|
||||
set { CheckChanged(data.Filename, value); data.Filename = value; }
|
||||
}
|
||||
public String Mime
|
||||
{
|
||||
get { return data.Mime; }
|
||||
set { CheckChanged(data.Mime, value); data.Mime = value; }
|
||||
}
|
||||
public String ContentType
|
||||
{
|
||||
get { return data.ContentType; }
|
||||
set { CheckChanged(data.ContentType, value); data.ContentType = value; }
|
||||
}
|
||||
public int Width
|
||||
{
|
||||
get { return data.Width; }
|
||||
set { CheckChanged(data.Width, value); data.Width = value; }
|
||||
}
|
||||
public int Height
|
||||
{
|
||||
get { return data.Height; }
|
||||
set { CheckChanged(data.Height, value); data.Height = value; }
|
||||
}
|
||||
public byte[] ImageData
|
||||
{
|
||||
get { return data.ImageData; }
|
||||
set { CheckChanged(data.ImageData, value); data.ImageData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
ImageType = data.ImageType;
|
||||
ImageSeq = data.ImageSeq;
|
||||
SessionUid = data.SessionUid;
|
||||
ImageUid = data.ImageUid;
|
||||
Filename = data.Filename;
|
||||
Mime = data.Mime;
|
||||
ContentType = data.ContentType;
|
||||
Width = data.Width;
|
||||
Height = data.Height;
|
||||
ImageData = data.ImageData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ImageType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ImageSeq { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SessionUid { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ImageUid { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Filename { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Mime { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ContentType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Width { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Height { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ImageData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemImage(SysId id, ItemId itemId, Sax.ImageType imageType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
ImageType = imageType;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.ItemImage, Id);
|
||||
}
|
||||
|
||||
// Validation.
|
||||
public static List<Sax.DataItemType> ValidItemTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<Sax.DataItemType> { Sax.DataItemType.UserAccount, Sax.DataItemType.Organisation, Sax.DataItemType.Article };
|
||||
}
|
||||
}
|
||||
public static List<Sacs.MimeType> GetValidMimeTypes(Sax.DataItemType itemType)
|
||||
{
|
||||
switch (itemType)
|
||||
{
|
||||
case Sax.DataItemType.UserAccount:
|
||||
case Sax.DataItemType.Organisation:
|
||||
case Sax.DataItemType.Article:
|
||||
return new List<Sacs.MimeType> { Sacs.MimeType.Jpeg, Sacs.MimeType.Webp, Sacs.MimeType.Png, Sacs.MimeType.Svg };
|
||||
}
|
||||
return new List<Sacs.MimeType>();
|
||||
}
|
||||
public static List<String> GetValidContentTypes(Sax.DataItemType itemType)
|
||||
{
|
||||
switch (itemType)
|
||||
{
|
||||
case Sax.DataItemType.UserAccount:
|
||||
case Sax.DataItemType.Organisation:
|
||||
case Sax.DataItemType.Article:
|
||||
return new List<string> { "image/jpg", "image/jpeg", "image/webp", "image/png", "image/svg+xml" };
|
||||
}
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed");
|
||||
if (ImageType > 0 && ImageType != data.ImageType)
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Image Type cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { data.ItemId = value; }
|
||||
}
|
||||
public Sax.ImageType ImageType
|
||||
{
|
||||
get { return data.ImageType; }
|
||||
set { data.ImageType = value; }
|
||||
}
|
||||
public byte ImageSeq
|
||||
{
|
||||
get { return data.ImageSeq; }
|
||||
set { data.ImageSeq = value; }
|
||||
}
|
||||
public long SessionUid
|
||||
{
|
||||
get { return data.SessionUid; }
|
||||
set { data.SessionUid = value; }
|
||||
}
|
||||
public int ImageUid
|
||||
{
|
||||
get { return data.ImageUid; }
|
||||
set { data.ImageUid = value; }
|
||||
}
|
||||
public String Filename
|
||||
{
|
||||
get { return data.Filename; }
|
||||
set { data.Filename = value; }
|
||||
}
|
||||
public String Mime
|
||||
{
|
||||
get { return data.Mime; }
|
||||
set { data.Mime = value; }
|
||||
}
|
||||
public String ContentType
|
||||
{
|
||||
get { return data.ContentType; }
|
||||
set { data.ContentType = value; }
|
||||
}
|
||||
public int Width
|
||||
{
|
||||
get { return data.Width; }
|
||||
set { data.Width = value; }
|
||||
}
|
||||
public int Height
|
||||
{
|
||||
get { return data.Height; }
|
||||
set { data.Height = value; }
|
||||
}
|
||||
public byte[] ImageData
|
||||
{
|
||||
get { return data.ImageData; }
|
||||
set { data.ImageData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
public List<Sax.ImageType> ImageTypesIncluded { get; } = new List<Sax.ImageType>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemImageList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxItemImage GetItemImageById(this List<SaxItemImage> values, SysId itemImageId)
|
||||
{
|
||||
if (!SysId.IsValid(itemImageId)) return null;
|
||||
return values.Find(item => item.Id.Equals(itemImageId));
|
||||
}
|
||||
|
||||
public static SaxItemImage GetItemImageBySessionImage(this List<SaxItemImage> values, long sessionUid, int imageUid)
|
||||
{
|
||||
if (sessionUid < 1 || imageUid < 1) return null;
|
||||
return values.Find(item => item.SessionUid == sessionUid && item.ImageUid == imageUid);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemProcess : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
Item_Caption,
|
||||
// Sport.
|
||||
SportId,
|
||||
Sport_Name,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public SysId SportId { get; set; }
|
||||
public String ItemSportData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
set { CheckChanged(data.SportId, value); data.SportId = value; }
|
||||
}
|
||||
public String ItemSportData
|
||||
{
|
||||
get { return data.ItemSportData; }
|
||||
set { CheckChanged(data.ItemSportData, value); data.ItemSportData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
SportId = data.SportId;
|
||||
ItemSportData = data.ItemSportData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ItemSportData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemProcess(SysId id, ItemId itemId, SysId sportId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
SportId = sportId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.ItemSport, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed");
|
||||
if (SysId.IsValid(SportId) && SysId.ToInt(SportId) != SysId.ToInt(data.SportId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Sport Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
protected set { data.SportId = value; }
|
||||
}
|
||||
public String ItemSportData
|
||||
{
|
||||
get { return data.ItemSportData; }
|
||||
set { data.ItemSportData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemSportList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Organisation.
|
||||
//=======================================================================
|
||||
public abstract class SaxOrganisation : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
Name,
|
||||
OrganisationType,
|
||||
OrganisationType_Desc,
|
||||
OrganisationCategory,
|
||||
OrganisationCategory_Desc,
|
||||
// Sport.
|
||||
SportId,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionId,
|
||||
Region_Name,
|
||||
// Associated data.
|
||||
/// <summary>Number of users with an active interest in the organisation.</summary>
|
||||
User_Count,
|
||||
/// <summary>Number of users who are 'members' of the organisation.</summary>
|
||||
Member_Count,
|
||||
/// <summary>Number of active logo images.</summary>
|
||||
LogoImage_Count,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public String Name { get; set; } = String.Empty;
|
||||
public Sax.OrganisationType OrganisationType { get; set; }
|
||||
public Sax.OrganisationCategory OrganisationCategory { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public SysId RegionIdPrimary { get; set; }
|
||||
public String About { get; set; } = String.Empty;
|
||||
public String Facilities { get; set; } = String.Empty;
|
||||
public String ContactData { get; set; } = String.Empty;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = value; }
|
||||
}
|
||||
public Sax.OrganisationType OrganisationType
|
||||
{
|
||||
get { return data.OrganisationType; }
|
||||
set { CheckChangedEnum(data.OrganisationType, value); data.OrganisationType = value; }
|
||||
}
|
||||
public Sax.OrganisationCategory OrganisationCategory
|
||||
{
|
||||
get { return data.OrganisationCategory; }
|
||||
set { CheckChangedEnum(data.OrganisationCategory, value); data.OrganisationCategory = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { CheckChanged(data.RegionIdPrimary, value); data.RegionIdPrimary = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { CheckChanged(data.About, value); data.About = value; }
|
||||
}
|
||||
public String Facilities
|
||||
{
|
||||
get { return data.Facilities; }
|
||||
set { CheckChanged(data.Facilities, value); data.Facilities = value; }
|
||||
}
|
||||
public String ContactData
|
||||
{
|
||||
get { return data.ContactData; }
|
||||
set { CheckChanged(data.ContactData, value); data.ContactData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
Name = data.Name;
|
||||
OrganisationType = data.OrganisationType;
|
||||
OrganisationCategory = data.OrganisationCategory;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
RegionIdPrimary = data.RegionIdPrimary;
|
||||
About = data.About;
|
||||
Facilities = data.Facilities;
|
||||
ContactData = data.ContactData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationCategory { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue About { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Facilities { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ContactData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxOrganisation(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Awaiting,
|
||||
SaStatus.Active,
|
||||
SaStatus.OnHold,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.OnHold) return DataValue.TriStateType.Amber;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Organisation, Id);
|
||||
}
|
||||
// Sport is mandatory for certain organisation categories.
|
||||
public static bool IsSportMandatory(Sax.OrganisationCategory organisationCategory)
|
||||
{
|
||||
if (organisationCategory == Sax.OrganisationCategory.Club) return true;
|
||||
if (organisationCategory == Sax.OrganisationCategory.Association) return true;
|
||||
if (organisationCategory == Sax.OrganisationCategory.SportDepartment) return true;
|
||||
return false;
|
||||
}
|
||||
private static List<Sax.ContactMethod> validContactMethods = new List<Sax.ContactMethod>
|
||||
{
|
||||
Sax.ContactMethod.PhoneMain,
|
||||
Sax.ContactMethod.PhoneOffice,
|
||||
// Online.
|
||||
Sax.ContactMethod.Email,
|
||||
Sax.ContactMethod.Website,
|
||||
Sax.ContactMethod.Wikipedia,
|
||||
// Social media.
|
||||
Sax.ContactMethod.LinkedIn,
|
||||
Sax.ContactMethod.Twitter,
|
||||
Sax.ContactMethod.Facebook,
|
||||
Sax.ContactMethod.Instagram,
|
||||
Sax.ContactMethod.YouTube,
|
||||
Sax.ContactMethod.Twitch,
|
||||
};
|
||||
public static List<Sax.ContactMethod> ValidContactMethods { get { return new List<Sax.ContactMethod>(validContactMethods); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { data.Name = value; }
|
||||
}
|
||||
public Sax.OrganisationType OrganisationType
|
||||
{
|
||||
get { return data.OrganisationType; }
|
||||
set { data.OrganisationType = value; }
|
||||
}
|
||||
public Sax.OrganisationCategory OrganisationCategory
|
||||
{
|
||||
get { return data.OrganisationCategory; }
|
||||
set { data.OrganisationCategory = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { data.RegionIdPrimary = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { data.About = value; }
|
||||
}
|
||||
public String Facilities
|
||||
{
|
||||
get { return data.Facilities; }
|
||||
set { data.Facilities = value; }
|
||||
}
|
||||
public String ContactData
|
||||
{
|
||||
get { return data.ContactData; }
|
||||
set { data.ContactData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
AwaitingOnly,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public String NameFull { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
public Sax.OrganisationCategory OrganisationCategory { get; set; } = Sax.OrganisationCategory.Unknown;
|
||||
public HashSet<Sax.OrganisationCategory> OrganisationCategoriesExcluded { get; } = new HashSet<Sax.OrganisationCategory>();
|
||||
public Sax.OrganisationType OrganisationType { get; set; } = Sax.OrganisationType.Unknown;
|
||||
/// <summary>Partial match on a number of fields, including name, sport, address, etc.</summary>
|
||||
public String OrganisationFilter { get; set; }
|
||||
public HashSet<SysId> SportIdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> RegionIdsIncluded { get; } = new HashSet<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Sport_Primary { get; set; }
|
||||
public String Alias_Region_Primary { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxOrganisationList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the Organisation Ids.
|
||||
/// </summary>
|
||||
public static List<SysId> GetIds(this List<SaxOrganisation> values)
|
||||
{
|
||||
return values.Select(item => item.Id).ToList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the first Organisation in list with the specified Id.
|
||||
/// </summary>
|
||||
public static SaxOrganisation GetOrganisationById(this List<SaxOrganisation> values, SysId organisationId)
|
||||
{
|
||||
return values.Find(item => item.Id.Equals(organisationId));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Get the name of the first Organisation in list with the specified Id.
|
||||
/// </summary>
|
||||
public static String GetOrganisationName(this List<SaxOrganisation> values, SysId organisationId)
|
||||
{
|
||||
return values.Find(item => item.Id.Equals(organisationId))?.Name ?? "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Organisation Event.
|
||||
//=======================================================================
|
||||
public abstract class SaxOrganisationEvent : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Organisation.
|
||||
OrganisationId,
|
||||
Organisation_Name,
|
||||
Organisation_LogoCount,
|
||||
// Sport.
|
||||
SportIdPrimary,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionIdCountry,
|
||||
Region_Name,
|
||||
// Event.
|
||||
EventAt_Date,
|
||||
EventAt_DateTime,
|
||||
EventTo_Date,
|
||||
EventTo_DateTime,
|
||||
EventTypeCode,
|
||||
EventType_Desc,
|
||||
Summary,
|
||||
Details,
|
||||
PublishedAt_Date,
|
||||
PublishedAt_DateTime,
|
||||
ExpiresAt_Date,
|
||||
ExpiresAt_DateTime,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId OrganisationId { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public SysId RegionIdCountry { get; set; }
|
||||
public DateTime EventAt { get; set; }
|
||||
public DateTime? EventTo { get; set; }
|
||||
public Sax.EventType EventType { get; set; }
|
||||
public String Summary { get; set; } = String.Empty;
|
||||
public String Details { get; set; } = String.Empty;
|
||||
public String EventData { get; set; } = String.Empty;
|
||||
public DateTime? PublishedAt { get; set; } = null;
|
||||
public DateTime? ExpiresAt { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { CheckChanged(data.RegionIdCountry, value); data.RegionIdCountry = value; }
|
||||
}
|
||||
public DateTime EventAt
|
||||
{
|
||||
get { return data.EventAt; }
|
||||
set { CheckChanged(data.EventAt, value); data.EventAt = value; }
|
||||
}
|
||||
public DateTime? EventTo
|
||||
{
|
||||
get { return data.EventTo; }
|
||||
set { CheckChangedNullable(data.EventTo, value); data.EventTo = value; }
|
||||
}
|
||||
public Sax.EventType EventType
|
||||
{
|
||||
get { return data.EventType; }
|
||||
set { CheckChanged((int)data.EventType, (int)value); data.EventType = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { CheckChanged(data.Summary, value); data.Summary = value; }
|
||||
}
|
||||
public String Details
|
||||
{
|
||||
get { return data.Details; }
|
||||
set { CheckChanged(data.Details, value); data.Details = value; }
|
||||
}
|
||||
public String EventData
|
||||
{
|
||||
get { return data.EventData; }
|
||||
set { CheckChanged(data.EventData, value); data.EventData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { CheckChangedNullable(data.PublishedAt, value); data.PublishedAt = value; }
|
||||
}
|
||||
public DateTime? ExpiresAt
|
||||
{
|
||||
get { return data.ExpiresAt; }
|
||||
set { CheckChangedNullable(data.ExpiresAt, value); data.ExpiresAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
OrganisationId = data.OrganisationId;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
RegionIdCountry = data.RegionIdCountry;
|
||||
EventAt = data.EventAt;
|
||||
EventTo = data.EventTo;
|
||||
EventType = data.EventType;
|
||||
Summary = data.Summary;
|
||||
Details = data.Details;
|
||||
EventData = data.EventData;
|
||||
PublishedAt = data.PublishedAt;
|
||||
ExpiresAt = data.ExpiresAt;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdCountry { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EventAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EventTo { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EventType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Summary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Details { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EventData { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PublishedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpiresAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxOrganisationEvent(SysId id, SysId organisationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.OrganisationId = organisationId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.OrganisationEvent, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time of exactly midnight is treated as invalid.
|
||||
/// <para>- Valid start time of midnight is stored with at least +1 minute (00:01:00).</para>
|
||||
/// </summary>
|
||||
public static bool HasValidEventTime(DateTime? eventDateTime)
|
||||
{
|
||||
return DateUtil.IsValid(eventDateTime) && DateUtil.Format(eventDateTime, "HH:mm:ss") != "00:00:00";
|
||||
}
|
||||
|
||||
public bool HasValidEventAtTime()
|
||||
{
|
||||
return HasValidEventTime(EventAt);
|
||||
}
|
||||
|
||||
public bool HasValidEventToTime()
|
||||
{
|
||||
return HasValidEventTime(EventTo);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Organisation Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
protected set { data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { data.RegionIdCountry = value; }
|
||||
}
|
||||
public DateTime EventAt
|
||||
{
|
||||
get { return data.EventAt; }
|
||||
set { data.EventAt = value; }
|
||||
}
|
||||
public DateTime? EventTo
|
||||
{
|
||||
get { return data.EventTo; }
|
||||
set { data.EventTo = value; }
|
||||
}
|
||||
public Sax.EventType EventType
|
||||
{
|
||||
get { return data.EventType; }
|
||||
set { data.EventType = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { data.Summary = value; }
|
||||
}
|
||||
public String Details
|
||||
{
|
||||
get { return data.Details; }
|
||||
set { data.Details = value; }
|
||||
}
|
||||
public String EventData
|
||||
{
|
||||
get { return data.EventData; }
|
||||
set { data.EventData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { data.PublishedAt = value; }
|
||||
}
|
||||
public DateTime? ExpiresAt
|
||||
{
|
||||
get { return data.ExpiresAt; }
|
||||
set { data.ExpiresAt = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
/// <summary>Restrict to User Account via User Organisations and Organisations.</summary>
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> SportIdsIncluded { get; set; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public DateTime EventFrom { get; set; }
|
||||
public DateTime EventTo { get; set; }
|
||||
public String SummaryPartial { get; set; }
|
||||
/// <summary>General filter value - position, outline, sport, body etc. </summary>
|
||||
public String EventFilter { get; set; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Organisation { get; set; }
|
||||
public String Alias_UserOrganisation { get; set; }
|
||||
public String Alias_UserAccount { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxOrganisationEventList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Organisation Opportunity.
|
||||
//=======================================================================
|
||||
public abstract class SaxOrganisationOpportunity : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Organisation.
|
||||
OrganisationId,
|
||||
Organisation_Name,
|
||||
Organisation_LogoCount,
|
||||
// Sport.
|
||||
SportIdPrimary,
|
||||
Sport_Name,
|
||||
// Region.
|
||||
RegionIdPrimary,
|
||||
Region_Name,
|
||||
// Opportunity.
|
||||
OpportunityTypeCode,
|
||||
OpportunityType_Desc,
|
||||
Position,
|
||||
Outline,
|
||||
PublishedAt_Date,
|
||||
PublishedAt_DateTime,
|
||||
ExpiresAt_Date,
|
||||
ExpiresAt_DateTime,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId OrganisationId { get; set; }
|
||||
public SysId SportIdPrimary { get; set; }
|
||||
public SysId RegionIdPrimary { get; set; }
|
||||
public Sax.OpportunityType OpportunityType { get; set; }
|
||||
public String Position { get; set; } = String.Empty;
|
||||
public String Outline { get; set; } = String.Empty;
|
||||
public String OpportunityData { get; set; } = String.Empty;
|
||||
public DateTime? PublishedAt { get; set; } = null;
|
||||
public DateTime? ExpiresAt { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { CheckChanged(data.RegionIdPrimary, value); data.RegionIdPrimary = value; }
|
||||
}
|
||||
public Sax.OpportunityType OpportunityType
|
||||
{
|
||||
get { return data.OpportunityType; }
|
||||
set { CheckChanged((int)data.OpportunityType, (int)value); data.OpportunityType = value; }
|
||||
}
|
||||
public String Position
|
||||
{
|
||||
get { return data.Position; }
|
||||
set { CheckChanged(data.Position, value); data.Position = value; }
|
||||
}
|
||||
public String Outline
|
||||
{
|
||||
get { return data.Outline; }
|
||||
set { CheckChanged(data.Outline, value); data.Outline = value; }
|
||||
}
|
||||
public String OpportunityData
|
||||
{
|
||||
get { return data.OpportunityData; }
|
||||
set { CheckChanged(data.OpportunityData, value); data.OpportunityData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { CheckChangedNullable(data.PublishedAt, value); data.PublishedAt = value; }
|
||||
}
|
||||
public DateTime? ExpiresAt
|
||||
{
|
||||
get { return data.ExpiresAt; }
|
||||
set { CheckChangedNullable(data.ExpiresAt, value); data.ExpiresAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
OrganisationId = data.OrganisationId;
|
||||
SportIdPrimary = data.SportIdPrimary;
|
||||
RegionIdPrimary = data.RegionIdPrimary;
|
||||
OpportunityType = data.OpportunityType;
|
||||
Position = data.Position;
|
||||
Outline = data.Outline;
|
||||
OpportunityData = data.OpportunityData;
|
||||
PublishedAt = data.PublishedAt;
|
||||
ExpiresAt = data.ExpiresAt;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdPrimary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OpportunityType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Position { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Outline { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OpportunityData { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PublishedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpiresAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxOrganisationOpportunity(SysId id, SysId OrganisationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.OrganisationId = OrganisationId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.OrganisationOpportunity, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Organisation Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
protected set { data.OrganisationId = value; }
|
||||
}
|
||||
public SysId SportIdPrimary
|
||||
{
|
||||
get { return data.SportIdPrimary; }
|
||||
set { data.SportIdPrimary = value; }
|
||||
}
|
||||
public SysId RegionIdPrimary
|
||||
{
|
||||
get { return data.RegionIdPrimary; }
|
||||
set { data.RegionIdPrimary = value; }
|
||||
}
|
||||
public Sax.OpportunityType OpportunityType
|
||||
{
|
||||
get { return data.OpportunityType; }
|
||||
set { data.OpportunityType = value; }
|
||||
}
|
||||
public String Position
|
||||
{
|
||||
get { return data.Position; }
|
||||
set { data.Position = value; }
|
||||
}
|
||||
public String Outline
|
||||
{
|
||||
get { return data.Outline; }
|
||||
set { data.Outline = value; }
|
||||
}
|
||||
public String OpportunityData
|
||||
{
|
||||
get { return data.OpportunityData; }
|
||||
set { data.OpportunityData = value; }
|
||||
}
|
||||
public DateTime? PublishedAt
|
||||
{
|
||||
get { return data.PublishedAt; }
|
||||
set { data.PublishedAt = value; }
|
||||
}
|
||||
public DateTime? ExpiresAt
|
||||
{
|
||||
get { return data.ExpiresAt; }
|
||||
set { data.ExpiresAt = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
/// <summary>Restrict to User Account via User Organisations and Organisations.</summary>
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> SportIdsIncluded { get; set; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public String PositionPartial { get; set; }
|
||||
public String OutlinePartial { get; set; }
|
||||
/// <summary>General filter value - position, outline, sport, body etc. </summary>
|
||||
public String OpportunityFilter { get; set; }
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_Organisation { get; set; }
|
||||
public String Alias_UserOrganisation { get; set; }
|
||||
public String Alias_UserAccount { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxOrganisationOpportunityList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Region.
|
||||
//=======================================================================
|
||||
public abstract class SaxRegion : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
RegionType,
|
||||
RegionType_Desc,
|
||||
CountryIso2Code,
|
||||
Name,
|
||||
// Parent region.
|
||||
RegionIdParent,
|
||||
Parent_Name,
|
||||
Parent_RegionType,
|
||||
Parent_RegionType_Desc,
|
||||
// Associated data.
|
||||
ChildRegionCount,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public Sax.RegionType RegionType { get; set; } = Sax.RegionType.Unknown;
|
||||
public String CountryIso2Code { get; set; } = String.Empty;
|
||||
public String Name { get; set; } = String.Empty;
|
||||
public Decimal? Latitude { get; set; } = null;
|
||||
public Decimal? Longitude { get; set; } = null;
|
||||
public SysId RegionIdParent { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public Sax.RegionType RegionType
|
||||
{
|
||||
get { return data.RegionType; }
|
||||
set { CheckChangedEnum(data.RegionType, value); data.RegionType = value; }
|
||||
}
|
||||
public String CountryIso2Code
|
||||
{
|
||||
get { return data.CountryIso2Code; }
|
||||
set { CheckChanged(data.CountryIso2Code, value); data.CountryIso2Code = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = value; }
|
||||
}
|
||||
public Decimal? Latitude
|
||||
{
|
||||
get { return data.Latitude; }
|
||||
set { CheckChangedNullable(data.Latitude, value); data.Latitude = value; }
|
||||
}
|
||||
public Decimal? Longitude
|
||||
{
|
||||
get { return data.Longitude; }
|
||||
set { CheckChangedNullable(data.Longitude, value); data.Longitude = value; }
|
||||
}
|
||||
public SysId RegionIdParent
|
||||
{
|
||||
get { return data.RegionIdParent; }
|
||||
set { CheckChanged(data.RegionIdParent, value); data.RegionIdParent = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
RegionType = data.RegionType;
|
||||
CountryIso2Code = data.CountryIso2Code;
|
||||
Name = data.Name;
|
||||
Latitude = data.Latitude;
|
||||
Longitude = data.Longitude;
|
||||
RegionIdParent = data.RegionIdParent;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue RegionType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CountryIso2Code { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Latitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Longitude { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdParent { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxRegion(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Region, Id);
|
||||
}
|
||||
public static List<Sax.RegionType> GetValidParentRegionTypes(Sax.RegionType regionType)
|
||||
{
|
||||
List<Sax.RegionType> parentRegionTypes = new List<Sax.RegionType>();
|
||||
switch (regionType)
|
||||
{
|
||||
case Sax.RegionType.World:
|
||||
parentRegionTypes.Add(Sax.RegionType.Galaxy);
|
||||
break;
|
||||
case Sax.RegionType.Continent:
|
||||
parentRegionTypes.Add(Sax.RegionType.World);
|
||||
break;
|
||||
case Sax.RegionType.SubContinent:
|
||||
parentRegionTypes.Add(Sax.RegionType.Continent);
|
||||
break;
|
||||
case Sax.RegionType.Country:
|
||||
parentRegionTypes.Add(Sax.RegionType.Continent);
|
||||
parentRegionTypes.Add(Sax.RegionType.SubContinent);
|
||||
break;
|
||||
case Sax.RegionType.Nation:
|
||||
parentRegionTypes.Add(Sax.RegionType.Country);
|
||||
break;
|
||||
case Sax.RegionType.State:
|
||||
parentRegionTypes.Add(Sax.RegionType.Country);
|
||||
break;
|
||||
case Sax.RegionType.Province:
|
||||
parentRegionTypes.Add(Sax.RegionType.Country);
|
||||
parentRegionTypes.Add(Sax.RegionType.Nation);
|
||||
break;
|
||||
}
|
||||
return parentRegionTypes;
|
||||
}
|
||||
public static bool IsValidParentRegionType(Sax.RegionType regionType, Sax.RegionType parentRegionType)
|
||||
{
|
||||
return GetValidParentRegionTypes(regionType).Contains(parentRegionType);
|
||||
}
|
||||
public bool IsValidParentRegionType(Sax.RegionType parentRegionType)
|
||||
{
|
||||
return IsValidParentRegionType(RegionType, parentRegionType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void Dispose() { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public Sax.RegionType RegionType
|
||||
{
|
||||
get { return data.RegionType; }
|
||||
set { data.RegionType = value; }
|
||||
}
|
||||
public String CountryIso2Code
|
||||
{
|
||||
get { return data.CountryIso2Code; }
|
||||
set { data.CountryIso2Code = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { data.Name = value; }
|
||||
}
|
||||
public Decimal? Latitude
|
||||
{
|
||||
get { return data.Latitude; }
|
||||
set { data.Latitude = value; }
|
||||
}
|
||||
public Decimal? Longitude
|
||||
{
|
||||
get { return data.Longitude; }
|
||||
set { data.Longitude = value; }
|
||||
}
|
||||
public SysId RegionIdParent
|
||||
{
|
||||
get { return data.RegionIdParent; }
|
||||
set { data.RegionIdParent = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> ParentRegionIdsIncluded { get; } = new List<SysId>();
|
||||
public Sax.RegionType RegionType { get; set; }
|
||||
public List<String> CountryIso2CodesIncluded { get; } = new List<String>();
|
||||
public List<String> CountryIso2CodesExcluded { get; } = new List<String>();
|
||||
/// <summary>Generic filter - partial region name, iso2 code or other matching value (tbd).</summary>
|
||||
public String RegionFilter { get; set; }
|
||||
public String NameFull { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxRegionList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the first Region in list with the specified Id.
|
||||
/// </summary>
|
||||
public static SaxRegion GetRegionById(this List<SaxRegion> values, SysId regionId)
|
||||
{
|
||||
return values.Find(item => item.Id.Equals(regionId));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Sport.
|
||||
//=======================================================================
|
||||
public abstract class SaxSport : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
Grouping,
|
||||
Grouping_Desc,
|
||||
SportIdParent,
|
||||
ParentSport_Name,
|
||||
Name,
|
||||
SpecialityLabel,
|
||||
SpecialityLabel_Desc,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public Sax.SportGrouping Grouping { get; set; }
|
||||
public SysId SportIdParent { get; set; }
|
||||
public String Name { get; set; } = String.Empty;
|
||||
public Sax.SportSpecialityLabel SpecialityLabel { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public Sax.SportGrouping Grouping
|
||||
{
|
||||
get { return data.Grouping; }
|
||||
set { CheckChanged((short)data.Grouping, (short)value); data.Grouping = value; }
|
||||
}
|
||||
public SysId SportIdParent
|
||||
{
|
||||
get { return data.SportIdParent; }
|
||||
set { CheckChanged(data.SportIdParent, value); data.SportIdParent = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = value; }
|
||||
}
|
||||
public Sax.SportSpecialityLabel SpecialityLabel
|
||||
{
|
||||
get { return data.SpecialityLabel; }
|
||||
set { CheckChanged((short)data.SpecialityLabel, (short)value); data.SpecialityLabel = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
Grouping = data.Grouping;
|
||||
SportIdParent = data.SportIdParent;
|
||||
Name = data.Name;
|
||||
SpecialityLabel = data.SpecialityLabel;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue Grouping { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportIdParent { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SpecialityLabel { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxSport(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.Sport, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void Dispose() { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public Sax.SportGrouping Grouping
|
||||
{
|
||||
get { return data.Grouping; }
|
||||
set { data.Grouping = value; }
|
||||
}
|
||||
public SysId SportIdParent
|
||||
{
|
||||
get { return data.SportIdParent; }
|
||||
set { data.SportIdParent = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { data.Name = value; }
|
||||
}
|
||||
public Sax.SportSpecialityLabel SpecialityLabel
|
||||
{
|
||||
get { return data.SpecialityLabel; }
|
||||
set { data.SpecialityLabel = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum SportGroupingCat
|
||||
{
|
||||
Any,
|
||||
Specific,
|
||||
Banner,
|
||||
BannerOrSpecific,
|
||||
Group,
|
||||
}
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public SportGroupingCat SportGroupingCat { get; set; } = SportGroupingCat.BannerOrSpecific;
|
||||
public SysId SportIdParent { get; set; }
|
||||
/// <summary>Generic filter - partial sport name, or other matching value (tbd).</summary>
|
||||
public String SportFilter { get; set; }
|
||||
public String NameFull { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxSportList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxSport GetSportById(this IEnumerable<SaxSport> values, SysId sportId)
|
||||
{
|
||||
if (!SysId.IsValid(sportId)) return null;
|
||||
foreach (SaxSport sport in values)
|
||||
if (sport.Id.Equals(sportId)) return sport;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// Contact data - associated with Organisations, Users etc.
|
||||
//=======================================================================
|
||||
public class SaxSportContactsData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
private static readonly String ElementName_Contacts = "Contacts";
|
||||
private static readonly String ElementName_Contact = "Contact";
|
||||
private static readonly String AttributeName_Type = "Type";
|
||||
private static readonly String ElementName_Type = "Type";
|
||||
private static readonly String ElementName_UserAccountId = "UserAccountId";
|
||||
private static readonly String ElementName_Title = "Title";
|
||||
private static readonly String ElementName_FirstName = "FirstName";
|
||||
private static readonly String ElementName_LastName = "LastName";
|
||||
private static readonly String ElementName_Phone = "Phone";
|
||||
private static readonly String ElementName_EmailAddress = "EmailAddress";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private class ContactData
|
||||
{
|
||||
public Sax.SportContactType ContactType { get; set; }
|
||||
public SysId UserAccountId { get; set; }
|
||||
public String Title { get; set; }
|
||||
public String FirstName { get; set; }
|
||||
public String LastName { get; set; }
|
||||
public String EmailAddress { get; set; }
|
||||
public String Phone { get; set; }
|
||||
}
|
||||
private Dictionary<Sax.SportContactType, ContactData> contacts { get; } = new Dictionary<Sax.SportContactType, ContactData>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction - from serialised data.
|
||||
public SaxSportContactsData(String contactsData = "")
|
||||
{
|
||||
FromXml(contactsData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public List<Sax.SportContactType> ContactTypes { get { return contacts.Keys.ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
/// <summary>Get the contact for the specified type.</summary>
|
||||
private ContactData GetContactData(Sax.SportContactType contactType)
|
||||
{
|
||||
if ((int)contactType < 1) return null;
|
||||
ContactData contact = contacts.GetValueOrDefault(contactType, null);
|
||||
if (contact == null)
|
||||
contacts.Add(contactType, contact = new ContactData() { ContactType = contactType });
|
||||
return contact;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Contacts.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Extract the title associated with the specified type.</summary>
|
||||
public String GetContactTitle(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).Title;
|
||||
}
|
||||
|
||||
/// <summary>Extract the first name associated with the specified type.</summary>
|
||||
public String GetContactFirstName(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).FirstName;
|
||||
}
|
||||
|
||||
/// <summary>Extract the last name associated with the specified type.</summary>
|
||||
public String GetContactLastName(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).LastName;
|
||||
}
|
||||
|
||||
/// <summary>Extract the email address associated with the specified type.</summary>
|
||||
public String GetContactEmailAddress(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).EmailAddress;
|
||||
}
|
||||
|
||||
/// <summary>Extract the phone associated with the specified type.</summary>
|
||||
public String GetContactPhone(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).Phone;
|
||||
}
|
||||
|
||||
/// <summary>Set the name associated with the specified contact.</summary>
|
||||
public bool SetContactName(Sax.SportContactType contactType, String title, String firstName, String lastName)
|
||||
{
|
||||
if ((int)contactType < 1 || lastName.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.Title = title;
|
||||
contact.FirstName = firstName;
|
||||
contact.LastName = lastName;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Set the email address associated with the specified contact.</summary>
|
||||
public bool SetContactEmailAddress(Sax.SportContactType contactType, String emailAddress)
|
||||
{
|
||||
if ((int)contactType < 1 || emailAddress.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.EmailAddress = emailAddress;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Set the phone associated with the specified contact.</summary>
|
||||
public bool SetContactPhone(Sax.SportContactType contactType, String phone)
|
||||
{
|
||||
if ((int)contactType < 1 || phone.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.Phone = phone;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Clear the value associated with the specified method.</summary>
|
||||
public bool ClearContact(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.Remove(contactType);
|
||||
}
|
||||
|
||||
/// <summary>Clear all contact methods.</summary>
|
||||
public void ClearContacts()
|
||||
{
|
||||
contacts.Clear();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Serialisation.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Serialise as XML.</summary>
|
||||
public String ToXml()
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
XElement contactsElement = doc.AppendElement(ElementName_Contacts);
|
||||
foreach (ContactData contactData in contacts.Values)
|
||||
{
|
||||
if ((int)contactData.ContactType < 1 || (!SysId.IsValid(contactData.UserAccountId) && StringUtil.IsBlank(contactData.LastName))) continue;
|
||||
XElement contactElement = contactsElement.AppendElement(ElementName_Contact);
|
||||
contactElement.SetAttribute(AttributeName_Type, ((int)contactData.ContactType).ToString());
|
||||
contactElement.AppendElement(ElementName_Type, contactData.ContactType.ToString());
|
||||
if (!StringUtil.IsBlank(contactData.Title))
|
||||
contactElement.AppendElement(ElementName_Title, contactData.Title);
|
||||
if (!StringUtil.IsBlank(contactData.FirstName))
|
||||
contactElement.AppendElement(ElementName_FirstName, contactData.FirstName);
|
||||
if (!StringUtil.IsBlank(contactData.LastName))
|
||||
contactElement.AppendElement(ElementName_LastName, contactData.LastName);
|
||||
if (!StringUtil.IsBlank(contactData.EmailAddress))
|
||||
contactElement.AppendElement(ElementName_EmailAddress, contactData.EmailAddress);
|
||||
if (!StringUtil.IsBlank(contactData.Phone))
|
||||
contactElement.AppendElement(ElementName_Phone, contactData.Phone);
|
||||
}
|
||||
return doc.GetXml();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Deserialise from XML data.</summary>
|
||||
private void FromXml(String contactsData)
|
||||
{
|
||||
contacts.Clear();
|
||||
if (StringUtil.IsEmpty(contactsData)) return;
|
||||
|
||||
try
|
||||
{
|
||||
// Load XML data.
|
||||
XDocument doc = XDocument.Parse(contactsData);
|
||||
XElement rootElement = doc.Root;
|
||||
foreach (XElement rootChildElement in rootElement.GetChildElements())
|
||||
{
|
||||
String rootChildElementName = rootChildElement.GetLocalName();
|
||||
if (rootChildElementName.EqualsCI(ElementName_Contact))
|
||||
{
|
||||
// Contact.
|
||||
String contactTypeValue = rootChildElement.GetChildText(ElementName_Type);
|
||||
Sax.SportContactType contactType = EnumUtil.ParseEnum(contactTypeValue, Sax.SportContactType.Unknown);
|
||||
if (contactType != Sax.SportContactType.Unknown)
|
||||
{
|
||||
ContactData contactData = new ContactData()
|
||||
{
|
||||
ContactType = contactType,
|
||||
UserAccountId = SysId.ToSysId(rootChildElement.GetChildText(ElementName_UserAccountId)),
|
||||
Title = rootChildElement.GetChildText(ElementName_Title),
|
||||
FirstName = rootChildElement.GetChildText(ElementName_FirstName),
|
||||
LastName = rootChildElement.GetChildText(ElementName_LastName),
|
||||
EmailAddress = rootChildElement.GetChildText(ElementName_EmailAddress),
|
||||
Phone = rootChildElement.GetChildText(ElementName_Phone),
|
||||
};
|
||||
contacts.Add(contactType, contactData);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unrecognised contact type: " + contactType);
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unexpected 'Root' child element: " + rootChildElementName);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,554 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxUserAccount : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
EmailAddress,
|
||||
Title,
|
||||
FirstName,
|
||||
Initials,
|
||||
LastName,
|
||||
About,
|
||||
PhoneMain,
|
||||
PhoneMobile,
|
||||
DateOfBirthDay,
|
||||
DateOfBirthMonth,
|
||||
DateOfBirthYear,
|
||||
DateOfBirth,
|
||||
// Regions.
|
||||
RegionIdCountry,
|
||||
RegionCountry_Name,
|
||||
RegionIdProvince,
|
||||
RegionProvince_Name,
|
||||
// Security.
|
||||
PasswordToken,
|
||||
PasswordChangedOn,
|
||||
PasswordChangedAt,
|
||||
// Login.
|
||||
LastLoginOn,
|
||||
LastLoginAt,
|
||||
LastInvalidLoginOn,
|
||||
LastInvalidLoginAt,
|
||||
InvalidLoginCount,
|
||||
// Associated data.
|
||||
UserSportCount,
|
||||
UserSportCount_Active,
|
||||
UserRoleCount,
|
||||
SystemAdminUser,
|
||||
LastAdminLoginOn,
|
||||
LastAdminLoginAt,
|
||||
LastInvalidAdminLoginOn,
|
||||
LastInvalidAdminLoginAt,
|
||||
InvalidAdminLoginCount,
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public String EmailAddress { get; set; } = String.Empty;
|
||||
public String Title { get; set; } = String.Empty;
|
||||
public String FirstName { get; set; } = String.Empty;
|
||||
public String Initials { get; set; } = String.Empty;
|
||||
public String LastName { get; set; } = String.Empty;
|
||||
public String About { get; set; } = String.Empty;
|
||||
public String PhoneMain { get; set; } = String.Empty;
|
||||
public String PhoneMobile { get; set; } = String.Empty;
|
||||
public Sax.Gender Gender { get; set; }
|
||||
public String GenderOther { get; set; }
|
||||
public byte? DateOfBirthDay { get; set; } = null;
|
||||
public byte? DateOfBirthMonth { get; set; } = null;
|
||||
public short? DateOfBirthYear { get; set; } = null;
|
||||
public SysId RegionIdCountry { get; set; }
|
||||
public SysId RegionIdProvince { get; set; }
|
||||
// Security.
|
||||
public String PasswordHashed { get; set; } = String.Empty;
|
||||
public List<String> PasswordHistory { get; } = new List<string>();
|
||||
public String PasswordToken { get; set; } = String.Empty;
|
||||
public DateTime? PasswordChangedAt { get; set; } = null;
|
||||
// Login.
|
||||
public DateTime? LastLoginAt { get; set; } = null;
|
||||
public DateTime? LastInvalidLoginAt { get; set; } = null;
|
||||
public short InvalidLoginCount { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public String EmailAddress
|
||||
{
|
||||
get { return data.EmailAddress; }
|
||||
set { CheckChanged(data.EmailAddress, value); data.EmailAddress = value; }
|
||||
}
|
||||
public String Title
|
||||
{
|
||||
get { return data.Title; }
|
||||
set { CheckChanged(data.Title, value); data.Title = value; }
|
||||
}
|
||||
public String FirstName
|
||||
{
|
||||
get { return data.FirstName; }
|
||||
set { CheckChanged(data.FirstName, value); data.FirstName = value; }
|
||||
}
|
||||
public String Initials
|
||||
{
|
||||
get { return data.Initials; }
|
||||
set { CheckChanged(data.Initials, value); data.Initials = value; }
|
||||
}
|
||||
public String LastName
|
||||
{
|
||||
get { return data.LastName; }
|
||||
set { CheckChanged(data.LastName, value); data.LastName = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { CheckChanged(data.About, value); data.About = value; }
|
||||
}
|
||||
public String PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { CheckChanged(data.PhoneMain, value); data.PhoneMain = value; }
|
||||
}
|
||||
public String PhoneMobile
|
||||
{
|
||||
get { return data.PhoneMobile; }
|
||||
set { CheckChanged(data.PhoneMobile, value); data.PhoneMobile = value; }
|
||||
}
|
||||
public Sax.Gender Gender
|
||||
{
|
||||
get { return data.Gender; }
|
||||
set { CheckChanged((int)data.Gender, (int)value); data.Gender = value; }
|
||||
}
|
||||
public String GenderOther
|
||||
{
|
||||
get { return data.GenderOther; }
|
||||
set { CheckChanged(data.GenderOther, value); data.GenderOther = value; }
|
||||
}
|
||||
public byte? DateOfBirthDay
|
||||
{
|
||||
get { return data.DateOfBirthDay; }
|
||||
set { if ((value??0) < 1) value = null; CheckChangedNullable(data.DateOfBirthDay, value); data.DateOfBirthDay = value; }
|
||||
}
|
||||
public byte? DateOfBirthMonth
|
||||
{
|
||||
get { return data.DateOfBirthMonth; }
|
||||
set { if ((value ?? 0) < 1) value = null; CheckChangedNullable(data.DateOfBirthMonth, value); data.DateOfBirthMonth = value; }
|
||||
}
|
||||
public short? DateOfBirthYear
|
||||
{
|
||||
get { return data.DateOfBirthYear; }
|
||||
set { if ((value ?? 0) < 1) value = null; CheckChangedNullable(data.DateOfBirthYear, value); data.DateOfBirthYear = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { CheckChanged(data.RegionIdCountry, value); data.RegionIdCountry = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { CheckChanged(data.RegionIdProvince, value); data.RegionIdProvince = value; }
|
||||
}
|
||||
// Security.
|
||||
public String PasswordHashed
|
||||
{
|
||||
get { return data.PasswordHashed; }
|
||||
set { CheckChanged(data.PasswordHashed, value); data.PasswordHashed = value; }
|
||||
}
|
||||
public List<String> PasswordHistory
|
||||
{
|
||||
get { return data.PasswordHistory; }
|
||||
set
|
||||
{
|
||||
CheckChanged(data.PasswordHistory, value);
|
||||
data.PasswordHistory.Clear();
|
||||
data.PasswordHistory.AddRange((value ?? new List<String>()).FindAll(item => !StringUtil.IsEmpty(StringUtil.TrimAll(item))));
|
||||
}
|
||||
}
|
||||
public String PasswordToken
|
||||
{
|
||||
get { return data.PasswordToken; }
|
||||
set { CheckChanged(data.PasswordToken, value); data.PasswordToken = value; }
|
||||
}
|
||||
public DateTime? PasswordChangedAt
|
||||
{
|
||||
get { return data.PasswordChangedAt; }
|
||||
set { CheckChangedNullable(data.PasswordChangedAt, value); data.PasswordChangedAt = value; }
|
||||
}
|
||||
// Login.
|
||||
public DateTime? LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { CheckChangedNullable(data.LastLoginAt, value); data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime? LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { CheckChangedNullable(data.LastInvalidLoginAt, value); data.LastInvalidLoginAt = value; }
|
||||
}
|
||||
public short InvalidLoginCount
|
||||
{
|
||||
get { return data.InvalidLoginCount; }
|
||||
set { CheckChanged(data.InvalidLoginCount, value); data.InvalidLoginCount = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
EmailAddress = data.EmailAddress;
|
||||
Title = data.Title;
|
||||
FirstName = data.FirstName;
|
||||
Initials = data.Initials;
|
||||
LastName = data.LastName;
|
||||
About = data.About;
|
||||
PhoneMain = data.PhoneMain;
|
||||
PhoneMobile = data.PhoneMobile;
|
||||
Gender = data.Gender;
|
||||
GenderOther = data.GenderOther;
|
||||
DateOfBirthDay = data.DateOfBirthDay;
|
||||
DateOfBirthMonth = data.DateOfBirthMonth;
|
||||
DateOfBirthYear = data.DateOfBirthYear;
|
||||
RegionIdCountry = data.RegionIdCountry;
|
||||
RegionIdProvince = data.RegionIdProvince;
|
||||
// Security.
|
||||
PasswordHashed = data.PasswordHashed;
|
||||
PasswordHistory = data.PasswordHistory;
|
||||
PasswordToken = data.PasswordToken;
|
||||
PasswordChangedAt = data.PasswordChangedAt;
|
||||
// Login.
|
||||
LastLoginAt = data.LastLoginAt;
|
||||
LastInvalidLoginAt = data.LastInvalidLoginAt;
|
||||
InvalidLoginCount = data.InvalidLoginCount;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue EmailAddress { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Title { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FirstName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Initials { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue About { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PhoneMain { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PhoneMobile { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Gender { get; set; } = ValidValue.Valid;
|
||||
public ValidValue GenderOther { get; set; } = ValidValue.Valid;
|
||||
public ValidValue DateOfBirthDay { get; set; } = ValidValue.Valid;
|
||||
public ValidValue DateOfBirthMonth { get; set; } = ValidValue.Valid;
|
||||
public ValidValue DateOfBirthYear { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdCountry { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdProvince { get; set; } = ValidValue.Valid;
|
||||
// Security.
|
||||
public ValidValue Password { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PasswordHistory { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PasswordToken { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PasswordChanged { get; set; } = ValidValue.Valid;
|
||||
// Login.
|
||||
public ValidValue LastLogin { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastInvalidLogin { get; set; } = ValidValue.Valid;
|
||||
public ValidValue InvalidLoginCount { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
public static readonly String UserRoleDelim = ",";
|
||||
public static readonly String PasswordHistoryDelim = ",";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserAccount(SysId id) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Awaiting,
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Awaiting; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Awaiting) return DataValue.TriStateType.Amber;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.UserAccount, Id);
|
||||
}
|
||||
public static String GetDisplayName(SaxUserAccount userAccount)
|
||||
{
|
||||
return GetDisplayName(userAccount.Title, userAccount.FirstName, userAccount.LastName);
|
||||
}
|
||||
public static String GetDisplayName(String title, String firstName, String lastName)
|
||||
{
|
||||
return StringUtil.TrimAll(StringUtil.EmptyOnNull(title) + " " + StringUtil.EmptyOnNull(firstName) + " " + StringUtil.EmptyOnNull(lastName));
|
||||
}
|
||||
public String GetDisplayName()
|
||||
{
|
||||
return GetDisplayName(this);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public String EmailAddress
|
||||
{
|
||||
get { return data.EmailAddress; }
|
||||
set { data.EmailAddress = value; }
|
||||
}
|
||||
public String Title
|
||||
{
|
||||
get { return data.Title; }
|
||||
set { data.Title = value; }
|
||||
}
|
||||
public String FirstName
|
||||
{
|
||||
get { return data.FirstName; }
|
||||
set { data.FirstName = value; }
|
||||
}
|
||||
public String Initials
|
||||
{
|
||||
get { return data.Initials; }
|
||||
set { data.Initials = value; }
|
||||
}
|
||||
public String LastName
|
||||
{
|
||||
get { return data.LastName; }
|
||||
set { data.LastName = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { data.About = value; }
|
||||
}
|
||||
public String PhoneMain
|
||||
{
|
||||
get { return data.PhoneMain; }
|
||||
set { data.PhoneMain = value; }
|
||||
}
|
||||
public String PhoneMobile
|
||||
{
|
||||
get { return data.PhoneMobile; }
|
||||
set { data.PhoneMobile = value; }
|
||||
}
|
||||
public Sax.Gender Gender
|
||||
{
|
||||
get { return data.Gender; }
|
||||
set { data.Gender = value; }
|
||||
}
|
||||
public String GenderOther
|
||||
{
|
||||
get { return data.GenderOther; }
|
||||
set { data.GenderOther = value; }
|
||||
}
|
||||
public byte? DateOfBirthDay
|
||||
{
|
||||
get { return data.DateOfBirthDay; }
|
||||
set { data.DateOfBirthDay = value; }
|
||||
}
|
||||
public byte? DateOfBirthMonth
|
||||
{
|
||||
get { return data.DateOfBirthMonth; }
|
||||
set { data.DateOfBirthMonth = value; }
|
||||
}
|
||||
public short? DateOfBirthYear
|
||||
{
|
||||
get { return data.DateOfBirthYear; }
|
||||
set { data.DateOfBirthYear = value; }
|
||||
}
|
||||
public SysId RegionIdCountry
|
||||
{
|
||||
get { return data.RegionIdCountry; }
|
||||
set { data.RegionIdCountry = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { data.RegionIdProvince = value; }
|
||||
}
|
||||
|
||||
// Security.
|
||||
public String PasswordHashed
|
||||
{
|
||||
get { return data.PasswordHashed; }
|
||||
set { data.PasswordHashed = value; }
|
||||
}
|
||||
public List<String> PasswordHistory
|
||||
{
|
||||
get { return data.PasswordHistory; }
|
||||
set { data.PasswordHistory = value; }
|
||||
}
|
||||
public String PasswordToken
|
||||
{
|
||||
get { return data.PasswordToken; }
|
||||
set { data.PasswordToken = value; }
|
||||
}
|
||||
public DateTime ?PasswordChangedAt
|
||||
{
|
||||
get { return data.PasswordChangedAt; }
|
||||
set { data.PasswordChangedAt = value; }
|
||||
}
|
||||
|
||||
// Login.
|
||||
public DateTime? LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime? LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { data.LastInvalidLoginAt = value; }
|
||||
}
|
||||
public short InvalidLoginCount
|
||||
{
|
||||
get { return data.InvalidLoginCount; }
|
||||
set { data.InvalidLoginCount = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
public Byte Flag_KeepLoggedIn { get; } = 0x1;
|
||||
public bool KeepLoggedIn
|
||||
{
|
||||
get { return GetFlag(Flag_KeepLoggedIn); }
|
||||
set { SetFlag(Flag_KeepLoggedIn, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
AwaitingOnly,
|
||||
ActiveOnly,
|
||||
AwaitingOrActive,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public String EmailAddress { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
/// <summary>Exact match on various user account properties including name, email etc.</summary>
|
||||
public String UserFilter { get; set; }
|
||||
/// <summary>Partial match on various user account properties including name, countries etc. Not to be used in Online application!</summary>
|
||||
public String UserFilterPartial { get; set; }
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public List<Sax.UserRole> ActiveRoles { get; } = new List<Sax.UserRole>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_UserSport { get; set; }
|
||||
public String Alias_UserSport_Sport { get; set; }
|
||||
public String Alias_UserRole { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserAccountList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the User Account Ids.
|
||||
/// </summary>
|
||||
public static List<SysId> GetIds(this List<SaxUserAccount> values)
|
||||
{
|
||||
return values.Select(item => item.Id).ToList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract the first User Account in list with the specified Id.
|
||||
/// </summary>
|
||||
public static SaxUserAccount GetUserAccountById(this List<SaxUserAccount> values, SysId userAccountId)
|
||||
{
|
||||
return values.Find(item => item.Id.Equals(userAccountId));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserActivity.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserActivity : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Activity.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
FirstListedAt,
|
||||
LastListedAt,
|
||||
FirstViewedAt,
|
||||
LastViewedAt,
|
||||
Reaction,
|
||||
FirstReactedAt,
|
||||
LastReactedAt,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public bool CurrentlyListed {get; set; }
|
||||
public DateTime ListedAtFirst { get; set; }
|
||||
public DateTime? ListedAtLast { get; set; } = null;
|
||||
public DateTime? ViewedAtFirst { get; set; } = null;
|
||||
public DateTime? ViewedAtLast { get; set; } = null;
|
||||
public Sax.ActivityReaction Reaction { get; set; }
|
||||
public DateTime? ReactedAtFirst { get; set; } = null;
|
||||
public DateTime? ReactedAtLast { get; set; } = null;
|
||||
public String UserActivityData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public bool CurrentlyListed
|
||||
{
|
||||
get { return data.CurrentlyListed; }
|
||||
set { CheckChanged(data.CurrentlyListed, value); data.CurrentlyListed = value; }
|
||||
}
|
||||
public DateTime ListedAtFirst
|
||||
{
|
||||
get { return data.ListedAtFirst; }
|
||||
set { CheckChanged(data.ListedAtFirst, value); data.ListedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ListedAtLast
|
||||
{
|
||||
get { return data.ListedAtLast; }
|
||||
set { CheckChangedNullable(data.ListedAtLast, value); data.ListedAtLast = value; }
|
||||
}
|
||||
public DateTime? ViewedAtFirst
|
||||
{
|
||||
get { return data.ViewedAtFirst; }
|
||||
set { CheckChangedNullable(data.ViewedAtFirst, value); data.ViewedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ViewedAtLast
|
||||
{
|
||||
get { return data.ViewedAtLast; }
|
||||
set { CheckChangedNullable(data.ViewedAtLast, value); data.ViewedAtLast = value; }
|
||||
}
|
||||
public Sax.ActivityReaction Reaction
|
||||
{
|
||||
get { return data.Reaction; }
|
||||
set { CheckChanged((int)data.Reaction, (int)value); data.Reaction = value; }
|
||||
}
|
||||
public DateTime? ReactedAtFirst
|
||||
{
|
||||
get { return data.ReactedAtFirst; }
|
||||
set { CheckChangedNullable(data.ReactedAtFirst, value); data.ReactedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ReactedAtLast
|
||||
{
|
||||
get { return data.ReactedAtLast; }
|
||||
set { CheckChangedNullable(data.ReactedAtLast, value); data.ReactedAtLast = value; }
|
||||
}
|
||||
public String UserActivityData
|
||||
{
|
||||
get { return data.UserActivityData; }
|
||||
set { CheckChanged(data.UserActivityData, value); data.UserActivityData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ItemId = data.ItemId;
|
||||
CurrentlyListed = data.CurrentlyListed;
|
||||
ListedAtFirst = data.ListedAtFirst;
|
||||
ListedAtLast = data.ListedAtLast;
|
||||
ViewedAtFirst = data.ViewedAtFirst;
|
||||
ViewedAtLast = data.ViewedAtLast;
|
||||
Reaction = data.Reaction;
|
||||
ReactedAtFirst = data.ReactedAtFirst;
|
||||
ReactedAtLast = data.ReactedAtLast;
|
||||
UserActivityData = data.UserActivityData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CurrentlyListed { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ListedAtFirst { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ListedAtLast { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ViewedAtFirst { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ViewedAtLast { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Reaction { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ReactedAtFirst { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ReactedAtLast { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserActivityData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserActivity(SysId id, SysId userAccountId, ItemId itemId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
ItemId = itemId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.UserActivity, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public bool CurrentlyListed
|
||||
{
|
||||
get { return data.CurrentlyListed; }
|
||||
set { data.CurrentlyListed = value; }
|
||||
}
|
||||
public DateTime ListedAtFirst
|
||||
{
|
||||
get { return data.ListedAtFirst; }
|
||||
set { data.ListedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ListedAtLast
|
||||
{
|
||||
get { return data.ListedAtLast; }
|
||||
set { data.ListedAtLast = value; }
|
||||
}
|
||||
public DateTime? ViewedAtFirst
|
||||
{
|
||||
get { return data.ViewedAtFirst; }
|
||||
set { data.ViewedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ViewedAtLast
|
||||
{
|
||||
get { return data.ViewedAtLast; }
|
||||
set { data.ViewedAtLast = value; }
|
||||
}
|
||||
public Sax.ActivityReaction Reaction
|
||||
{
|
||||
get { return data.Reaction; }
|
||||
set { data.Reaction = value; }
|
||||
}
|
||||
public DateTime? ReactedAtFirst
|
||||
{
|
||||
get { return data.ReactedAtFirst; }
|
||||
set { data.ReactedAtFirst = value; }
|
||||
}
|
||||
public DateTime? ReactedAtLast
|
||||
{
|
||||
get { return data.ReactedAtLast; }
|
||||
set { data.ReactedAtLast = value; }
|
||||
}
|
||||
public String UserActivityData
|
||||
{
|
||||
get { return data.UserActivityData; }
|
||||
set { data.UserActivityData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
// Table aliases - blank if not specified/linked.
|
||||
public String Alias_UserActivity { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserActivityList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// User Config.
|
||||
//=======================================================================
|
||||
/// <summary>
|
||||
/// User Config - parameters to control application behaviour.
|
||||
/// </summary>
|
||||
public abstract partial class SaxUserConfig : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Configuration.
|
||||
ConfigType,
|
||||
// Associated data.
|
||||
// Common.
|
||||
//Flags,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public Sax.UserConfigType ConfigType { get; set; }
|
||||
public String ConfigData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserConfigType ConfigType
|
||||
{
|
||||
get { return data.ConfigType; }
|
||||
set { CheckChanged((int)data.ConfigType, (int)value); data.ConfigType = value; }
|
||||
}
|
||||
public String ConfigData
|
||||
{
|
||||
get { return data.ConfigData; }
|
||||
set { CheckChanged(data.ConfigData, value); data.ConfigData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ConfigType = data.ConfigType;
|
||||
ConfigData = data.ConfigData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ConfigType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ConfigData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserConfig(SysId id, SysId userAccountId, Sax.UserConfigType configType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
ConfigType = configType;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public static String ActivityIndexDelim { get; } = ",";
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (ConfigType != data.ConfigType)
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Config Type cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserConfigType ConfigType
|
||||
{
|
||||
get { return data.ConfigType; }
|
||||
protected set { data.ConfigType = value; }
|
||||
}
|
||||
public String ConfigData
|
||||
{
|
||||
get { return data.ConfigData; }
|
||||
set { data.ConfigData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public Sax.UserConfigType ConfigType { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserConfigList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax.Config.Security;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// User Eligibility.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserEligibility : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Region.
|
||||
RegionId,
|
||||
Region_Type,
|
||||
Region_Type_Desc,
|
||||
Region_CountryIso2Code,
|
||||
Region_Name,
|
||||
Region_ParentId,
|
||||
// Eligibility.
|
||||
EligibilityType,
|
||||
EligibilityType_Desc,
|
||||
Info,
|
||||
ExpiresOn,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public SysId RegionId { get; set; }
|
||||
public String Info { get; set; }
|
||||
public Sax.EligibilityType EligibilityType { get; set; }
|
||||
public DateTime? ExpiresOn { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public SysId RegionId
|
||||
{
|
||||
get { return data.RegionId; }
|
||||
set { CheckChanged(data.RegionId, value); data.RegionId = value; }
|
||||
}
|
||||
public Sax.EligibilityType EligibilityType
|
||||
{
|
||||
get { return data.EligibilityType; }
|
||||
set { CheckChanged((int)data.EligibilityType, (int)value); data.EligibilityType = value; }
|
||||
}
|
||||
public String Info
|
||||
{
|
||||
get { return data.Info; }
|
||||
set { CheckChanged(data.Info, value); data.Info = value; }
|
||||
}
|
||||
public DateTime? ExpiresOn
|
||||
{
|
||||
get { return data.ExpiresOn; }
|
||||
set { CheckChangedNullable(data.ExpiresOn, value); data.ExpiresOn = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
RegionId = data.RegionId;
|
||||
EligibilityType = data.EligibilityType;
|
||||
Info = data.Info;
|
||||
ExpiresOn = data.ExpiresOn;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue EligibilityType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Info { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ExpiresOn { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserEligibility(SysId id, SysId userAccountId, SysId regionId, Sax.EligibilityType eligibilityType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
RegionId = regionId;
|
||||
EligibilityType = eligibilityType;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.UserEligibility, Id);
|
||||
}
|
||||
|
||||
/// <summary>Maximum number of instances per user, regardless of region.</summary>
|
||||
public static int GetMaxInstances(Sax.EligibilityType eligibilityType)
|
||||
{
|
||||
switch (eligibilityType)
|
||||
{
|
||||
case Sax.EligibilityType.Birth: return 1;
|
||||
case Sax.EligibilityType.Naturalised: return 1;
|
||||
case Sax.EligibilityType.Parent: return 2;
|
||||
case Sax.EligibilityType.Grandparent: return 4;
|
||||
case Sax.EligibilityType.Passport: return 9;
|
||||
case Sax.EligibilityType.Visa: return 9;
|
||||
}
|
||||
return 9;
|
||||
}
|
||||
|
||||
/// <summary>Does the eligibility allow a date range.</summary>
|
||||
public static bool AllowsApplicablePeriod(Sax.EligibilityType eligibilityType)
|
||||
{
|
||||
switch (eligibilityType)
|
||||
{
|
||||
//case Sax.EligibilityType.Birth:
|
||||
//case Sax.EligibilityType.Naturalised:
|
||||
//case Sax.EligibilityType.Parent:
|
||||
//case Sax.EligibilityType.Grandparent:
|
||||
case Sax.EligibilityType.Passport:
|
||||
case Sax.EligibilityType.Visa:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (SysId.IsValid(RegionId) && SysId.ToInt(RegionId) != SysId.ToInt(data.RegionId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Region Id cannot be changed");
|
||||
if (EligibilityType == 0 && (int)EligibilityType != (int)EligibilityType)
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Eligibility cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
|
||||
/// <summary>User Account Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set
|
||||
{
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException("EligibilityType.UserAccountId cannot be changed");
|
||||
data.UserAccountId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Region Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId RegionId
|
||||
{
|
||||
get { return data.RegionId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(RegionId) && SysId.ToInt(RegionId) != SysId.ToInt(data.RegionId))
|
||||
throw new NotSupportedException("EligibilityType.RegionId cannot be changed");
|
||||
data.RegionId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>User Eligibility. Can only be populated on construction.</summary>
|
||||
public Sax.EligibilityType EligibilityType
|
||||
{
|
||||
get { return data.EligibilityType; }
|
||||
set { data.EligibilityType = value; }
|
||||
}
|
||||
|
||||
public String Info
|
||||
{
|
||||
get { return data.Info; }
|
||||
set { data.Info = value; }
|
||||
}
|
||||
|
||||
public DateTime? ExpiresOn
|
||||
{
|
||||
get { return data.ExpiresOn; }
|
||||
set { data.ExpiresOn = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
public List<Sax.EligibilityType> EligibilityTypesIncluded { get; } = new List<Sax.EligibilityType>();
|
||||
public DateTime ValidOn { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxEligibilityTypeList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve the first entry in the list matching the specified Region.</summary>
|
||||
public static List<SaxUserEligibility> GetEligibilityTypesByStatus(this List<SaxUserEligibility> values, SysId regionId)
|
||||
{
|
||||
return values.FindAll(item => item.RegionId == regionId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve the first entry in the list matching the specified Eligibility.</summary>
|
||||
public static SaxUserEligibility GetEligibilityTypeByEligibility(this List<SaxUserEligibility> values, Sax.EligibilityType EligibilityType)
|
||||
{
|
||||
return values.Find(item => item.EligibilityType == EligibilityType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserRole.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserOnline : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
UserAccountId,
|
||||
OnlineOn,
|
||||
OnlineAt,
|
||||
// User properties.
|
||||
EmailAddress,
|
||||
DisplayName, Title, FirstName, LastName,
|
||||
LastLoginOn,
|
||||
LastLoginAt,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public DateTime OnlineAt { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public DateTime OnlineAt
|
||||
{
|
||||
get { return data.OnlineAt; }
|
||||
set { CheckChanged(data.OnlineAt, value); data.OnlineAt = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
OnlineAt = data.OnlineAt;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OnlineAt { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserOnline(SysId userAccountId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
/// <summary>User Account Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException("UserRole.UserAccountId cannot be changed");
|
||||
data.UserAccountId = value;
|
||||
}
|
||||
}
|
||||
/// <summary>Online At - last time user was active Online.</summary>
|
||||
public DateTime OnlineAt
|
||||
{
|
||||
get { return data.OnlineAt; }
|
||||
set { data.OnlineAt = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public DateTime OnlineOnFrom { get; set; }
|
||||
public DateTime OnlineOnTo { get; set; }
|
||||
/// <summary>Exact match on various user account properties including name, email etc.</summary>
|
||||
public String UserFilter { get; set; }
|
||||
/// <summary>Partial match on various user account properties including name, email etc. Not to be used in Online application!</summary>
|
||||
public String UserFilterPartial { get; set; }
|
||||
// User Account filters.
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
|
||||
// Table aliases - blank if not linked.
|
||||
public String Alias_UserAccount { get; set; }
|
||||
public String Alias_UserSport { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserOnlineList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserOrganisation.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserOrganisation : SaxDisposableHierarchyItem, IDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserAccountId,
|
||||
OrganisationId,
|
||||
OrganisationRoleCount,
|
||||
OrganisationRoleCodes,
|
||||
OrganisationRoleDescs,
|
||||
// User.
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
User_Status,
|
||||
User_Status_Desc,
|
||||
// Organisation.
|
||||
Organisation_Name,
|
||||
Organisation_Category,
|
||||
Organisation_Type,
|
||||
Organisation_RegionId,
|
||||
Organisation_Region_Name,
|
||||
Organisation_SportId,
|
||||
Organisation_Sport_Name,
|
||||
Organisation_Member_Count,
|
||||
Organisation_Opportunity_Count,
|
||||
Organisation_LogoImage_Count,
|
||||
// Properties.
|
||||
AdminComment,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public SysId OrganisationId { get; set; }
|
||||
public HashSet<Sax.OrganisationRole> OrganisationRoles { get; } = new HashSet<Sax.OrganisationRole>();
|
||||
public String AdminComment { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
// Organisation roles.
|
||||
public byte OrganisationRoleCount
|
||||
{
|
||||
get { return (byte)data.OrganisationRoles.Count; }
|
||||
}
|
||||
public ReadOnlyCollection<Sax.OrganisationRole> GetOrganisationRoles()
|
||||
{
|
||||
return data.OrganisationRoles.ToList().AsReadOnly();
|
||||
}
|
||||
public void ClearOrganisationRoles()
|
||||
{
|
||||
if (!Changed) Changed = !data.OrganisationRoles.IsEmpty();
|
||||
data.OrganisationRoles.Clear();
|
||||
}
|
||||
public bool HasAnyOrganisationRole(IEnumerable<Sax.OrganisationRole> organisationRoles)
|
||||
{
|
||||
return data.OrganisationRoles.Any(item => organisationRoles.Contains(item));
|
||||
}
|
||||
public void AddOrganisationRole(Sax.OrganisationRole organisationRole)
|
||||
{
|
||||
if (!data.OrganisationRoles.Contains(organisationRole))
|
||||
{
|
||||
if (!Changed) Changed = true;
|
||||
data.OrganisationRoles.Add(organisationRole);
|
||||
}
|
||||
}
|
||||
/// <summary>Store organisation roles.</summary>
|
||||
public IEnumerable<Sax.OrganisationRole> OrganisationRoles
|
||||
{
|
||||
set
|
||||
{
|
||||
if (Object.ReferenceEquals(data.OrganisationRoles, value))
|
||||
{
|
||||
// Lists are the same object.
|
||||
// Assume the list has been modified, sort it and immediately return.
|
||||
// NB Shouldn't happen as HashSet isn't exposed.
|
||||
Changed = true;
|
||||
return;
|
||||
}
|
||||
CheckChanged(data.OrganisationRoles.ToList(), value);
|
||||
data.OrganisationRoles.Clear();
|
||||
foreach (Sax.OrganisationRole organisationRole in value)
|
||||
data.OrganisationRoles.Add(organisationRole);
|
||||
}
|
||||
}
|
||||
// Admin comment.
|
||||
public String AdminComment
|
||||
{
|
||||
get { return data.AdminComment; }
|
||||
set { CheckChanged(data.AdminComment, value); data.AdminComment = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
OrganisationId = data.OrganisationId;
|
||||
OrganisationRoles = data.GetOrganisationRoles().ToList();
|
||||
AdminComment = data.AdminComment;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationRoles { get; set; } = ValidValue.Valid;
|
||||
public ValidValue AdminComment { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
public static readonly String UserOrgnisationRoleDelim = ",";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserOrganisation(SysId id, SysId userAccountId, SysId organisationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
OrganisationId = organisationId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
/// <summary>
|
||||
/// UserOrganisation is either active or deleted.
|
||||
/// <para>Other status are handled by the User Account itself.</para>
|
||||
/// <para>As the User Organisation is simple a link between the user and Organisation and membership is defined by the presence of the 'Member' role.</para>
|
||||
/// </summary>
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.UserOrganisation, Id);
|
||||
}
|
||||
public static List<Sax.OrganisationRole> GetOrganisationRolesFromCodes(String organisationRoleCodes)
|
||||
{
|
||||
return GetOrganisationRolesFromCodes(StringListUtil.Split(organisationRoleCodes, UserOrgnisationRoleDelim, true, true, true));
|
||||
}
|
||||
public static List<Sax.OrganisationRole> GetOrganisationRolesFromCodes(List<String> organisationRoleCodes)
|
||||
{
|
||||
List<Sax.OrganisationRole> organisationRoles = new List<Sax.OrganisationRole>();
|
||||
List<TypeCodeDesc> roles = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationRole);
|
||||
foreach (String organisationRoleCode in organisationRoleCodes)
|
||||
{
|
||||
Sax.OrganisationRole organisationRole = (Sax.OrganisationRole)roles.GetTypeForCode(organisationRoleCode);
|
||||
if (organisationRole == 0)
|
||||
organisationRole = EnumUtil.ParseEnum(organisationRoleCode, Sax.OrganisationRole.Unknown);
|
||||
if (organisationRole > 0)
|
||||
organisationRoles.Add(organisationRole);
|
||||
}
|
||||
return organisationRoles;
|
||||
}
|
||||
public List<String> GetOrganisationRoleCodes()
|
||||
{
|
||||
List<String> organisationRoleCodes = new List<string>();
|
||||
List<TypeCodeDesc> roles = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationRole);
|
||||
foreach (Sax.OrganisationRole organisationRole in GetOrganisationRoles())
|
||||
organisationRoleCodes.Add(roles.GetCodeForType(organisationRole));
|
||||
organisationRoleCodes.Sort();
|
||||
return organisationRoleCodes;
|
||||
}
|
||||
public String GetOrganisationRoleCodesData()
|
||||
{
|
||||
return GetOrganisationRoleCodes().Concat(UserOrgnisationRoleDelim);
|
||||
}
|
||||
// Query roles.
|
||||
public bool CanManageOrganisation{ get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin }); } }
|
||||
public bool CanManageMembers { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin }); } }
|
||||
public bool CanManageOpportunities { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.OpportunityAdmin }); } }
|
||||
public bool CanManageSchedule { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ScheduleAdmin }); } }
|
||||
public bool CanManageArticles { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin }); } }
|
||||
public bool HasAnyOrganisationRole(IEnumerable<Sax.OrganisationRole> organisationRoles)
|
||||
{
|
||||
return data.HasAnyOrganisationRole(organisationRoles);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void Dispose() { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Organisation Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
/// <summary>User Account Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException("UserOrganisation.UserAccountId cannot be changed");
|
||||
data.UserAccountId = value;
|
||||
}
|
||||
}
|
||||
/// <summary>Organisation Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
|
||||
throw new NotSupportedException("UserOrganisation.OrganisationId cannot be changed");
|
||||
data.OrganisationId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Number of Organisation Roles.</summary>
|
||||
public byte OrganisationRoleCount
|
||||
{
|
||||
get { return data.OrganisationRoleCount; }
|
||||
}
|
||||
/// <summary>Organisation Roles - use setter to populate.</summary>
|
||||
public ReadOnlyCollection<Sax.OrganisationRole> GetOrganisationRoles()
|
||||
{
|
||||
return data.GetOrganisationRoles();
|
||||
}
|
||||
/// <summary>Store Organisation Roles.</summary>
|
||||
public IEnumerable<Sax.OrganisationRole> OrganisationRoles
|
||||
{
|
||||
set { data.OrganisationRoles = value; }
|
||||
}
|
||||
public void ClearOrganisationRoles()
|
||||
{
|
||||
data.ClearOrganisationRoles();
|
||||
}
|
||||
public void AddOrganisationRole(Sax.OrganisationRole organisationRole)
|
||||
{
|
||||
data.AddOrganisationRole(organisationRole);
|
||||
}
|
||||
|
||||
/// <summary>Organisation admin comment.</summary>
|
||||
public String AdminComment
|
||||
{
|
||||
get { return StringUtil.EmptyOnNull(data.AdminComment); }
|
||||
set { data.AdminComment = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
|
||||
// User Account properties.
|
||||
public HashSet<SysId> UserAccountIdsIncluded { get; } = new HashSet<SysId>();
|
||||
public SaxUserAccount.StatusCat UserAccountStatusCat { get; set; } = SaxUserAccount.StatusCat.NotDeleted;
|
||||
/// <summary>Exact match on various user account properties including name, email etc.</summary>
|
||||
public String UserFilter { get; set; }
|
||||
/// <summary>Partial match on various user account properties including name, countries etc.</summary>
|
||||
public String UserFilterPartial { get; set; }
|
||||
|
||||
// Organisation properties.
|
||||
public HashSet<SysId> OrganisationIdsIncluded { get; } = new HashSet<SysId>();
|
||||
/// <summary>Exclude organisations with no upcoming events (from 7 days ago).</summary>
|
||||
public bool OrganisationHasScheduledEvents { get; set; }
|
||||
public SaxOrganisation.StatusCat OrganisationStatusCat { get; set; } = SaxOrganisation.StatusCat.NotDeleted;
|
||||
|
||||
// Organisation User properties.
|
||||
/// <summary>Set true to restruct to User Organisations with at least one Organisation Role.</summary>
|
||||
public bool OrganisationMembersOnly { get; set; }
|
||||
public HashSet<Sax.OrganisationRole> OrganisationRoles { get; } = new HashSet<Sax.OrganisationRole>();
|
||||
public HashSet<Sax.OrganisationRole> OrganisationRolesAny { get; } = new HashSet<Sax.OrganisationRole>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
// Table aliases - blank if not specified/linked.
|
||||
public String Alias_UserOrganisation { get; set; }
|
||||
public String Alias_UserAccount { get; set; }
|
||||
public String Alias_Organisation { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserOrganisationList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract list of unique Organisation Ids from the list.
|
||||
/// </summary>
|
||||
public static List<SysId> GetOrganisationIds(this List<SaxUserOrganisation> values)
|
||||
{
|
||||
return new HashSet<SysId>(values.Select(item => item.OrganisationId)).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract list of unique User Account Ids from the list.
|
||||
/// </summary>
|
||||
public static List<SysId> GetUserAccountIds(this List<SaxUserOrganisation> values)
|
||||
{
|
||||
return new HashSet<SysId>(values.Select(item => item.UserAccountId)).ToList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserRole.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserRole : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserAccountId,
|
||||
UserRole,
|
||||
UserRole_Desc,
|
||||
// Login - Admin for System user.
|
||||
LastLoginOn,
|
||||
LastLoginAt,
|
||||
LastInvalidLoginOn,
|
||||
LastInvalidLoginAt,
|
||||
InvalidLoginCount,
|
||||
// User.
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public Sax.UserRole UserRole { get; set; }
|
||||
// Login.
|
||||
public DateTime? LastLoginAt { get; set; } = null;
|
||||
public DateTime? LastInvalidLoginAt { get; set; } = null;
|
||||
public short? InvalidLoginCount { get; set; } = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserRole UserRole
|
||||
{
|
||||
get { return data.UserRole; }
|
||||
set { CheckChanged((int)data.UserRole, (int)value); data.UserRole = value; }
|
||||
}
|
||||
// Login.
|
||||
public DateTime? LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { CheckChangedNullable(data.LastLoginAt, value); data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime? LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { CheckChangedNullable(data.LastInvalidLoginAt, value); data.LastInvalidLoginAt = value; }
|
||||
}
|
||||
public short? InvalidLoginCount
|
||||
{
|
||||
get { return data.InvalidLoginCount; }
|
||||
set { CheckChangedNullable(data.InvalidLoginCount, value); data.InvalidLoginCount = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
UserRole = data.UserRole;
|
||||
// Login.
|
||||
LastLoginAt = data.LastLoginAt;
|
||||
LastInvalidLoginAt = data.LastInvalidLoginAt;
|
||||
InvalidLoginCount = data.InvalidLoginCount;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserRole { get; set; } = ValidValue.Valid;
|
||||
// Login.
|
||||
public ValidValue LastLogin { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastInvalidLogin { get; set; } = ValidValue.Valid;
|
||||
public ValidValue InvalidLoginCount { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserRole(SysId id, SysId userAccountId, Sax.UserRole userRole) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
UserRole = userRole;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.UserRole, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (UserRole == 0 && (int)UserRole != (int)UserRole)
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Role cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
/// <summary>User Account Id. NB Can only be set where previously invalid.</summary>
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set
|
||||
{
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException("UserRole.UserAccountId cannot be changed");
|
||||
data.UserAccountId = value;
|
||||
}
|
||||
}
|
||||
/// <summary>User Role. Can only be populated on construction.</summary>
|
||||
public Sax.UserRole UserRole
|
||||
{
|
||||
get { return data.UserRole; }
|
||||
protected set { data.UserRole = value; }
|
||||
}
|
||||
|
||||
// Login - Admin application for System Admin role.
|
||||
public DateTime? LastLoginAt
|
||||
{
|
||||
get { return data.LastLoginAt; }
|
||||
set { data.LastLoginAt = value; }
|
||||
}
|
||||
public DateTime? LastInvalidLoginAt
|
||||
{
|
||||
get { return data.LastInvalidLoginAt; }
|
||||
set { data.LastInvalidLoginAt = value; }
|
||||
}
|
||||
public short? InvalidLoginCount
|
||||
{
|
||||
get { return data.InvalidLoginCount; }
|
||||
set { data.InvalidLoginCount = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
// Keep logged in - Admin application for System Admin role.
|
||||
public Byte Flag_KeepLoggedIn { get; } = 0x1;
|
||||
public bool KeepLoggedIn
|
||||
{
|
||||
get { return GetFlag(Flag_KeepLoggedIn); }
|
||||
set { SetFlag(Flag_KeepLoggedIn, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<Sax.UserRole> UserRolesIncluded { get; } = new List<Sax.UserRole>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserRoleList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve the first entry in the list matching the specified role.</summary>
|
||||
public static SaxUserRole GetUserRoleByRole(this List<SaxUserRole> values, Sax.UserRole userRole)
|
||||
{
|
||||
return values.Find(item => item.UserRole == userRole);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve the first entry in the list matching the specified role.</summary>
|
||||
public static List<SaxUserRole> GetUserRolesByStatus(this List<SaxUserRole> values, SaStatus status)
|
||||
{
|
||||
return values.FindAll(item => item.Status == status);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// User Session.
|
||||
//=======================================================================
|
||||
/// <summary>
|
||||
/// User Session - persistent properties from the user's session.
|
||||
/// </summary>
|
||||
public abstract class SaxUserSession : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Session data.
|
||||
// Associated data.
|
||||
// Common.
|
||||
Flags,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public List<SysId> ActivityIndexIds { get; } = new List<SysId>();
|
||||
public String UserSessionData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public List<SysId> ActivityIndexIds
|
||||
{
|
||||
get { return data.ActivityIndexIds.ToList(); }
|
||||
set { CheckChanged(data.ActivityIndexIds, value); data.ActivityIndexIds.Clear(); data.ActivityIndexIds.AddRange(value); }
|
||||
}
|
||||
public String UserSessionData
|
||||
{
|
||||
get { return data.UserSessionData; }
|
||||
set { CheckChanged(data.UserSessionData, value); data.UserSessionData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ActivityIndexIds = data.ActivityIndexIds;
|
||||
UserSessionData = data.UserSessionData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ActivityIndexIds { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserSessionData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserSession(SysId userAccountId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public static String ActivityIndexDelim { get; } = ",";
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public List<SysId> ActivityIndexIds
|
||||
{
|
||||
get { return data.ActivityIndexIds; }
|
||||
set { data.ActivityIndexIds = value; }
|
||||
}
|
||||
public String UserSessionData
|
||||
{
|
||||
get { return data.UserSessionData; }
|
||||
set { data.UserSessionData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserSessionList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserSport : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Sport.
|
||||
SportId,
|
||||
Sport_Name,
|
||||
About,
|
||||
SportParticipating,
|
||||
SportParticipating_Code,
|
||||
SportParticipating_Desc,
|
||||
SportPreparing,
|
||||
SportPreparing_Code,
|
||||
SportPreparing_Desc,
|
||||
SportOfficiating,
|
||||
SportOfficiating_Code,
|
||||
SportOfficiating_Desc,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public SysId SportId { get; set; }
|
||||
public String About { get; set; } = String.Empty;
|
||||
public String ContactsData { get; set; } = String.Empty;
|
||||
public Sax.SportParticipating Participating { get; set; }
|
||||
public Sax.SportPreparing Preparing { get; set; }
|
||||
public Sax.SportOfficiating Officiating { get; set; }
|
||||
public String UserSportData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
set { CheckChanged(data.SportId, value); data.SportId = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { CheckChanged(data.About, value); data.About = value; }
|
||||
}
|
||||
public String ContactsData
|
||||
{
|
||||
get { return data.ContactsData; }
|
||||
set { CheckChanged(data.ContactsData, value); data.ContactsData = value; }
|
||||
}
|
||||
public Sax.SportParticipating Participating
|
||||
{
|
||||
get { return data.Participating; }
|
||||
set { CheckChanged((int)data.Participating, (int)value); data.Participating = value; }
|
||||
}
|
||||
public Sax.SportPreparing Preparing
|
||||
{
|
||||
get { return data.Preparing; }
|
||||
set { CheckChanged((int)data.Preparing, (int)value); data.Preparing = value; }
|
||||
}
|
||||
public Sax.SportOfficiating Officiating
|
||||
{
|
||||
get { return data.Officiating; }
|
||||
set { CheckChanged((int)data.Officiating, (int)value); data.Officiating = value; }
|
||||
}
|
||||
public String UserSportData
|
||||
{
|
||||
get { return data.UserSportData; }
|
||||
set { CheckChanged(data.UserSportData, value); data.UserSportData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
SportId = data.SportId;
|
||||
About = data.About;
|
||||
ContactsData = data.ContactsData;
|
||||
Participating = data.Participating;
|
||||
Preparing = data.Preparing;
|
||||
Officiating = data.Officiating;
|
||||
UserSportData = data.UserSportData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SportId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue About { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ContactsAbout { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Participating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Preparing { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Officiating { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserSportData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserSport(SysId id, SysId userAccountId, SysId sportId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
SportId = sportId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.UserSport, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Account Id cannot be changed");
|
||||
if (SysId.IsValid(SportId) && SysId.ToInt(SportId) != SysId.ToInt(data.SportId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Sport Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public SysId SportId
|
||||
{
|
||||
get { return data.SportId; }
|
||||
protected set { data.SportId = value; }
|
||||
}
|
||||
public String About
|
||||
{
|
||||
get { return data.About; }
|
||||
set { data.About = value; }
|
||||
}
|
||||
public String ContactsData
|
||||
{
|
||||
get { return data.ContactsData; }
|
||||
set { data.ContactsData = value; }
|
||||
}
|
||||
public Sax.SportParticipating Participating
|
||||
{
|
||||
get { return data.Participating; }
|
||||
set { data.Participating = value; }
|
||||
}
|
||||
public Sax.SportPreparing Preparing
|
||||
{
|
||||
get { return data.Preparing; }
|
||||
set { data.Preparing = value; }
|
||||
}
|
||||
public Sax.SportOfficiating Officiating
|
||||
{
|
||||
get { return data.Officiating; }
|
||||
set { data.Officiating = value; }
|
||||
}
|
||||
public String UserSportData
|
||||
{
|
||||
get { return data.UserSportData; }
|
||||
set { data.UserSportData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserSportList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Extract Sport Ids.
|
||||
public static List<SysId> GetSportIds(this IEnumerable<SaxUserSport> values)
|
||||
{
|
||||
List<SysId> sportIds = new List<SysId>();
|
||||
foreach (SaxUserSport userSport in values)
|
||||
sportIds.AddId(userSport.SportId);
|
||||
return sportIds;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// UserSportExperience.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserSportExperience : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserSportId,
|
||||
// Sport.
|
||||
Sport_Id,
|
||||
// Period.
|
||||
PeriodFrom,
|
||||
PeriodTo,
|
||||
// Organisation.
|
||||
OrganisationId,
|
||||
OrganisationName,
|
||||
Organisation_Name,
|
||||
// Properties.
|
||||
Summary,
|
||||
Team,
|
||||
League,
|
||||
Speciality,
|
||||
SpecialitiesOther,
|
||||
Awards,
|
||||
// Regions.
|
||||
RegionIdNation,
|
||||
Region_Nation_Name,
|
||||
RegionIdProvince,
|
||||
Region_Province_Name,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserSportId { get; set; }
|
||||
public DateTime PeriodFrom { get; set; }
|
||||
public DateTime? PeriodTo { get; set; }
|
||||
public SysId OrganisationId { get; set; }
|
||||
public String OrganisationName { get; set; }
|
||||
public String Summary { get; set; }
|
||||
public String Team { get; set; }
|
||||
public String League { get; set; }
|
||||
public String Speciality { get; set; }
|
||||
public HashSet<String> SpecialitiesOther { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
|
||||
public String Awards { get; set; }
|
||||
public SysId RegionIdNation { get; set; }
|
||||
public SysId RegionIdProvince { get; set; }
|
||||
public String UserSportExperienceData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserSportId
|
||||
{
|
||||
get { return data.UserSportId; }
|
||||
set { CheckChanged(data.UserSportId, value); data.UserSportId = value; }
|
||||
}
|
||||
public DateTime PeriodFrom
|
||||
{
|
||||
get { return data.PeriodFrom; }
|
||||
set { CheckChanged(data.PeriodFrom, value); data.PeriodFrom = value; }
|
||||
}
|
||||
public DateTime? PeriodTo
|
||||
{
|
||||
get { return data.PeriodTo; }
|
||||
set { CheckChangedNullable(data.PeriodTo, value); data.PeriodTo = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
|
||||
}
|
||||
public String OrganisationName
|
||||
{
|
||||
get { return data.OrganisationName; }
|
||||
set { CheckChanged(data.OrganisationName, value); data.OrganisationName = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { CheckChanged(data.Summary, value); data.Summary = value; }
|
||||
}
|
||||
public String Team
|
||||
{
|
||||
get { return data.Team; }
|
||||
set { CheckChanged(data.Team, value); data.Team = value; }
|
||||
}
|
||||
public String League
|
||||
{
|
||||
get { return data.League; }
|
||||
set { CheckChanged(data.League, value); data.League = value; }
|
||||
}
|
||||
public String Speciality
|
||||
{
|
||||
get { return data.Speciality; }
|
||||
set { CheckChanged(data.Speciality, value); data.Speciality = value; }
|
||||
}
|
||||
public ReadOnlyCollection<String> GetSpecialitiesOther()
|
||||
{
|
||||
return data.SpecialitiesOther.ToList().AsReadOnly();
|
||||
}
|
||||
public List<String> SpecialitiesOther
|
||||
{
|
||||
set
|
||||
{
|
||||
CheckChanged(data.SpecialitiesOther.ToList(), value);
|
||||
data.SpecialitiesOther.Clear();
|
||||
foreach (String speciality in value)
|
||||
{
|
||||
if (StringUtil.IsEmpty(speciality.Trim())) continue;
|
||||
data.SpecialitiesOther.Add(speciality.Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
public String Awards
|
||||
{
|
||||
get { return data.Awards; }
|
||||
set { CheckChanged(data.Awards, value); data.Awards = value; }
|
||||
}
|
||||
public SysId RegionIdNation
|
||||
{
|
||||
get { return data.RegionIdNation; }
|
||||
set { CheckChanged(data.RegionIdNation, value); data.RegionIdNation = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { CheckChanged(data.RegionIdProvince, value); data.RegionIdProvince = value; }
|
||||
}
|
||||
public String UserSportExperienceData
|
||||
{
|
||||
get { return data.UserSportExperienceData; }
|
||||
set { CheckChanged(data.UserSportExperienceData, value); data.UserSportExperienceData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserSportId = data.UserSportId;
|
||||
PeriodFrom = data.PeriodFrom;
|
||||
PeriodTo = data.PeriodTo;
|
||||
OrganisationId = data.OrganisationId;
|
||||
Summary = data.Summary;
|
||||
Team = data.Team;
|
||||
League = data.League;
|
||||
Speciality = data.Speciality;
|
||||
SpecialitiesOther = data.GetSpecialitiesOther().ToList();
|
||||
Awards = data.Awards;
|
||||
RegionIdNation = data.RegionIdNation;
|
||||
RegionIdProvince = data.RegionIdProvince;
|
||||
UserSportExperienceData = data.UserSportExperienceData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserSportId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PeriodFrom { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PeriodTo { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue OrganisationName { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Summary { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Team { get; set; } = ValidValue.Valid;
|
||||
public ValidValue League { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Speciality { get; set; } = ValidValue.Valid;
|
||||
public ValidValue SpecialitiesOther { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Awards { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdNation { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RegionIdProvince { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserSportExperienceData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
public static readonly String SpecialitiesOtherDelim = "\n";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserSportExperience(SysId id, SysId userSportId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
UserSportId = userSportId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.UserSportExperience, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserSportId) && SysId.ToInt(UserSportId) != SysId.ToInt(data.UserSportId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} User Sport Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserSportId
|
||||
{
|
||||
get { return data.UserSportId; }
|
||||
protected set { data.UserSportId = value; }
|
||||
}
|
||||
public DateTime PeriodFrom
|
||||
{
|
||||
get { return data.PeriodFrom; }
|
||||
set { data.PeriodFrom = value; }
|
||||
}
|
||||
public DateTime? PeriodTo
|
||||
{
|
||||
get { return data.PeriodTo; }
|
||||
set { data.PeriodTo = value; }
|
||||
}
|
||||
public SysId OrganisationId
|
||||
{
|
||||
get { return data.OrganisationId; }
|
||||
set { data.OrganisationId = value; }
|
||||
}
|
||||
public String OrganisationName
|
||||
{
|
||||
get { return data.OrganisationName; }
|
||||
set { data.OrganisationName = value; }
|
||||
}
|
||||
public String Summary
|
||||
{
|
||||
get { return data.Summary; }
|
||||
set { data.Summary = value; }
|
||||
}
|
||||
public String Team
|
||||
{
|
||||
get { return data.Team; }
|
||||
set { data.Team = value; }
|
||||
}
|
||||
public String League
|
||||
{
|
||||
get { return data.League; }
|
||||
set { data.League = value; }
|
||||
}
|
||||
public String Speciality
|
||||
{
|
||||
get { return data.Speciality; }
|
||||
set { data.Speciality = value; }
|
||||
}
|
||||
public ReadOnlyCollection<String> GetSpecialitiesOther()
|
||||
{
|
||||
return data.GetSpecialitiesOther();
|
||||
}
|
||||
public List<String> SpecialitiesOther
|
||||
{
|
||||
set { data.SpecialitiesOther = value; }
|
||||
}
|
||||
public String Awards
|
||||
{
|
||||
get { return data.Awards; }
|
||||
set { data.Awards = value; }
|
||||
}
|
||||
public SysId RegionIdNation
|
||||
{
|
||||
get { return data.RegionIdNation; }
|
||||
set { data.RegionIdNation = value; }
|
||||
}
|
||||
public SysId RegionIdProvince
|
||||
{
|
||||
get { return data.RegionIdProvince; }
|
||||
set { data.RegionIdProvince = value; }
|
||||
}
|
||||
public String UserSportExperienceData
|
||||
{
|
||||
get { return data.UserSportExperienceData; }
|
||||
set { data.UserSportExperienceData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> UserSportIdsIncluded { get; } = new List<SysId>();
|
||||
public DateTime PeriodFrom { get; set; }
|
||||
public DateTime PeriodTo { get; set; }
|
||||
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsNationIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIdsProvinceIncluded { get; } = new List<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserSportExperienceList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemProcess : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item.
|
||||
ItemType,
|
||||
ItemType_Code,
|
||||
ItemType_Desc,
|
||||
ItemId,
|
||||
Item_Caption,
|
||||
// Process.
|
||||
ProcessType,
|
||||
ProcessType_Desc,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public ItemId ItemId { get; set; } = new ItemId();
|
||||
public Sax.SupportItemProcessType ProcessType { get; set; }
|
||||
public String ProcessData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
||||
}
|
||||
public Sax.SupportItemProcessType ProcessType
|
||||
{
|
||||
get { return data.ProcessType; }
|
||||
set { CheckChanged((int)data.ProcessType, (int)value); data.ProcessType = value; }
|
||||
}
|
||||
public String ProcessData
|
||||
{
|
||||
get { return data.ProcessData; }
|
||||
set { CheckChanged(data.ProcessData, value); data.ProcessData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemId = data.ItemId;
|
||||
ProcessType = data.ProcessType;
|
||||
ProcessData = data.ProcessData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProcessType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProcessData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemProcess(SysId id, ItemId itemId, Sax.SupportItemProcessType processType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemId = itemId;
|
||||
ProcessType = processType;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.SupportItemProcess, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public ItemId ItemId
|
||||
{
|
||||
get { return data.ItemId; }
|
||||
protected set { data.ItemId = value; }
|
||||
}
|
||||
public Sax.SupportItemProcessType ProcessType
|
||||
{
|
||||
get { return data.ProcessType; }
|
||||
set { data.ProcessType = value; }
|
||||
}
|
||||
public String ProcessData
|
||||
{
|
||||
get { return data.ProcessData; }
|
||||
set { data.ProcessData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<ItemId> ItemIdsIncluded { get; } = new HashSet<ItemId>();
|
||||
public HashSet<Sax.SupportItemProcessType> ProcessTypesIncluded { get; } = new HashSet<Sax.SupportItemProcessType>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemProcessList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemProcessInstance : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item process.
|
||||
ItemProcessId,
|
||||
// Process instance.
|
||||
Started_DateTime,
|
||||
Started_Date,
|
||||
Started_Time,
|
||||
Completed_DateTime,
|
||||
Completed_Date,
|
||||
Completed_Time,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId ItemProcessId { get; set; }
|
||||
public DateTime? StartedAt { get; set; }
|
||||
public DateTime? CompletedAt { get; set; }
|
||||
public String ProcessingData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId ItemProcessId
|
||||
{
|
||||
get { return data.ItemProcessId; }
|
||||
set { CheckChanged(data.ItemProcessId, value); data.ItemProcessId = value; }
|
||||
}
|
||||
public DateTime? StartedAt
|
||||
{
|
||||
get { return data.StartedAt; }
|
||||
set { CheckChangedNullable(data.StartedAt, value); data.StartedAt = value; }
|
||||
}
|
||||
public DateTime? CompletedAt
|
||||
{
|
||||
get { return data.CompletedAt; }
|
||||
set { CheckChangedNullable(data.CompletedAt, value); data.CompletedAt = value; }
|
||||
}
|
||||
public String ProcessingData
|
||||
{
|
||||
get { return data.ProcessingData; }
|
||||
set { CheckChanged(data.ProcessingData, value); data.ProcessingData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemProcessId = data.ItemProcessId;
|
||||
StartedAt = data.StartedAt;
|
||||
CompletedAt = data.CompletedAt;
|
||||
ProcessingData = data.ProcessingData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemProcessId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue StartedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CompletedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ProcessingData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemProcessInstance(SysId id, SysId itemProcessId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemProcessId = itemProcessId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Inactive,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(ItemProcessId) && SysId.ToInt(ItemProcessId) != SysId.ToInt(data.ItemProcessId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Process Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId ItemProcessId
|
||||
{
|
||||
get { return data.ItemProcessId; }
|
||||
protected set { data.ItemProcessId = value; }
|
||||
}
|
||||
public DateTime? StartedAt
|
||||
{
|
||||
get { return data.StartedAt; }
|
||||
set { data.StartedAt = value; }
|
||||
}
|
||||
public DateTime? CompletedAt
|
||||
{
|
||||
get { return data.CompletedAt; }
|
||||
set { data.CompletedAt = value; }
|
||||
}
|
||||
public String ProcessingData
|
||||
{
|
||||
get { return data.ProcessingData; }
|
||||
set { data.ProcessingData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> ItemProcessIdsIncluded { get; } = new HashSet<SysId>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemProcessInstanceList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// ItemSport.
|
||||
//=======================================================================
|
||||
public abstract class SaxItemProcessMessage : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// Item process.
|
||||
ItemProcessInstanceId,
|
||||
// Process message.
|
||||
MessageType,
|
||||
MessageType_Desc,
|
||||
Message,
|
||||
Recorded_DateTime,
|
||||
Recorded_Date,
|
||||
Recorded_Time,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId ItemProcessInstanceId { get; set; }
|
||||
public DateTime? RecordedAt { get; set; }
|
||||
public SaMessageLevel MessageType { get; set; }
|
||||
public String Message { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId ItemProcessInstanceId
|
||||
{
|
||||
get { return data.ItemProcessInstanceId; }
|
||||
set { CheckChanged(data.ItemProcessInstanceId, value); data.ItemProcessInstanceId = value; }
|
||||
}
|
||||
public DateTime? RecordedAt
|
||||
{
|
||||
get { return data.RecordedAt; }
|
||||
set { CheckChangedNullable(data.RecordedAt, value); data.RecordedAt = value; }
|
||||
}
|
||||
public SaMessageLevel MessageType
|
||||
{
|
||||
get { return data.MessageType; }
|
||||
set { CheckChanged((int)data.MessageType, (int)value); data.MessageType = value; }
|
||||
}
|
||||
public String Message
|
||||
{
|
||||
get { return data.Message; }
|
||||
set { CheckChanged(data.Message, value); data.Message = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
ItemProcessInstanceId = data.ItemProcessInstanceId;
|
||||
RecordedAt = data.RecordedAt;
|
||||
MessageType = data.MessageType;
|
||||
Message = data.Message;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue ItemProcessInstanceId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RecordedAt { get; set; } = ValidValue.Valid;
|
||||
public ValidValue MessageType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Message { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxItemProcessMessage(SysId id, SysId itemProcessId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemProcessInstanceId = itemProcessId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(ItemProcessInstanceId) && SysId.ToInt(ItemProcessInstanceId) != SysId.ToInt(data.ItemProcessInstanceId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Item Process Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId ItemProcessInstanceId
|
||||
{
|
||||
get { return data.ItemProcessInstanceId; }
|
||||
protected set { data.ItemProcessInstanceId = value; }
|
||||
}
|
||||
public DateTime? RecordedAt
|
||||
{
|
||||
get { return data.RecordedAt; }
|
||||
set { data.RecordedAt = value; }
|
||||
}
|
||||
public SaMessageLevel MessageType
|
||||
{
|
||||
get { return data.MessageType; }
|
||||
set { data.MessageType = value; }
|
||||
}
|
||||
public String Message
|
||||
{
|
||||
get { return data.Message; }
|
||||
set { data.Message = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> ItemProcessInstanceIdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SaMessageLevel> MessageTypesIncluded { get; } = new HashSet<SaMessageLevel>();
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxItemProcessMessageList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static Sarand.Net.Standard.Base.Bus.SacsHierarchyItem;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// UserReport.
|
||||
//=======================================================================
|
||||
public abstract class SaxUserReport : SaxDisposableHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
UserAccountId,
|
||||
ReportType,
|
||||
ReportType_Desc,
|
||||
Title,
|
||||
Report,
|
||||
RecordedOn,
|
||||
// Associated data.
|
||||
// Common.
|
||||
Notes,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public Sax.UserReportType ReportType { get; set; }
|
||||
public String Title { get; set; } = String.Empty;
|
||||
public String Report { get; set; } = String.Empty;
|
||||
public DateTime RecordedOn { get; set; }
|
||||
public String ReportData { get; set; } = String.Empty;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserReportType ReportType
|
||||
{
|
||||
get { return data.ReportType; }
|
||||
set { CheckChanged((short)data.ReportType, (short)value); data.ReportType = value; }
|
||||
}
|
||||
public String Title
|
||||
{
|
||||
get { return data.Title; }
|
||||
set { CheckChanged(data.Title, value); data.Title = value; }
|
||||
}
|
||||
public String Report
|
||||
{
|
||||
get { return data.Report; }
|
||||
set { CheckChanged(data.Report, value); data.Report = value; }
|
||||
}
|
||||
public DateTime RecordedOn
|
||||
{
|
||||
get { return data.RecordedOn; }
|
||||
set { CheckChanged(data.RecordedOn, value); data.RecordedOn = value; }
|
||||
}
|
||||
public String ReportData
|
||||
{
|
||||
get { return data.ReportData; }
|
||||
set { CheckChanged(data.ReportData, value); data.ReportData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ReportType = data.ReportType;
|
||||
Title = data.Title;
|
||||
Report = data.Report;
|
||||
RecordedOn = data.RecordedOn;
|
||||
ReportData = data.ReportData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ReportType { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Title { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Report { get; set; } = ValidValue.Valid;
|
||||
public ValidValue RecordedOn { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ReportData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserReport(SysId id, SysId userAccountId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
this.UserAccountId = userAccountId;
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status.
|
||||
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Preparation,
|
||||
SaStatus.InProgress,
|
||||
SaStatus.Cancelled,
|
||||
SaStatus.Closed,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Preparation; } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
if (status == SaStatus.Preparation) return DataValue.TriStateType.Yellow;
|
||||
if (status == SaStatus.InProgress) return DataValue.TriStateType.Green;
|
||||
if (status == SaStatus.Completed) return DataValue.TriStateType.Blue;
|
||||
if (status == SaStatus.Cancelled) return DataValue.TriStateType.Red;
|
||||
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
|
||||
return DataValue.TriStateType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sax.DataItemType.UserReport, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
{
|
||||
// Properties that cannot be changed if previously specified.
|
||||
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
|
||||
if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException($"{SysUtil.Fn} UserAccountId cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public Sax.UserReportType ReportType
|
||||
{
|
||||
get { return data.ReportType; }
|
||||
set { data.ReportType = value; }
|
||||
}
|
||||
public String Title
|
||||
{
|
||||
get { return data.Title; }
|
||||
set { data.Title = value; }
|
||||
}
|
||||
public String Report
|
||||
{
|
||||
get { return data.Report; }
|
||||
set { data.Report = value; }
|
||||
}
|
||||
public DateTime RecordedOn
|
||||
{
|
||||
get { return data.RecordedOn; }
|
||||
set { data.RecordedOn = value; }
|
||||
}
|
||||
public String ReportData
|
||||
{
|
||||
get { return data.ReportData; }
|
||||
set { data.ReportData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
Preparation,
|
||||
Open,
|
||||
Completed,
|
||||
Cancelled,
|
||||
Closed,
|
||||
NotDeleted,
|
||||
Deleted,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> IdsIncluded { get; } = new List<SysId>();
|
||||
public List<SysId> IdsExcluded { get; } = new List<SysId>();
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
public List<Sax.UserReportType> ReportTypesIncluded { get; } = new List<Sax.UserReportType>();
|
||||
/// <summary>Generic filter - caption, report, or other matching value (tbd).</summary>
|
||||
public String UserReportFilter { get; set; }
|
||||
public String TitlePartial { get; set; }
|
||||
public String ReportPartial { get; set; }
|
||||
// Common properties.
|
||||
public String NotesPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.Open;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserReportList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static SaxUserReport GetUserReportById(this IEnumerable<SaxUserReport> values, SysId userReportId)
|
||||
{
|
||||
if (!SysId.IsValid(userReportId)) return null;
|
||||
foreach (SaxUserReport userReport in values)
|
||||
if (userReport.Id.Equals(userReportId)) return userReport;
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
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.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
// The index data is intended to provide a common, performance effective route
|
||||
// to identifying the activities that are relevant to a User or other context
|
||||
// that defines at least one region/sport combination and an effective date (usually today).
|
||||
//=======================================================================
|
||||
public abstract class SaxActivityConsole : SaxDisposableStateItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
/// <summary>
|
||||
/// Parameters required to query the index for activities to identify relevant activities.
|
||||
/// </summary>
|
||||
public class IndexContext
|
||||
{
|
||||
// ToDo Include Localiser.
|
||||
/// <summary>
|
||||
/// Index Context - high level activity filter.
|
||||
/// <para>User Account allows User specific information about the activities to be included.</para>
|
||||
/// </summary>
|
||||
public IndexContext(SysId userAccountId)
|
||||
{
|
||||
UserAccountId = userAccountId;
|
||||
}
|
||||
public SysId UserAccountId { get; }
|
||||
/// <summary>Activities must match one of the sport/region combinations specified.</summary>
|
||||
public List<SaxActivityIndex.SportRegionIds> SportRegionIdsIncluded { get; } = new List<SaxActivityIndex.SportRegionIds>();
|
||||
/// <summary>
|
||||
/// Owner Users - eg. journalist for articles.
|
||||
/// <para>Allows the users' activities to be queried without relying on matching sport/region combinations.</para>
|
||||
/// </summary>
|
||||
public List<SysId> UserAccountIdsOwner { get; } = new List<SysId>();
|
||||
/// <summary>
|
||||
/// Owner Organisations - for articles, events and opportunities.
|
||||
/// <para>Allows the organisations' own activities to be queried without relying on matching sport/region combinations.</para>
|
||||
/// </summary>
|
||||
public List<SysId> OrganisationIdsOwner { get; } = new List<SysId>();
|
||||
// Todo: Default effective period for Activities.
|
||||
public DateTime EffectiveFrom { get; set; } = DateUtil.IncrementDate(DateTime.Today, -365);
|
||||
public DateTime EffectiveTo { get; set; } = DateUtil.IncrementDate(DateTime.Today, 30);
|
||||
public DateTime NotExpiredOn { get; set; } = DateTime.Today;
|
||||
public bool IsValid()
|
||||
{
|
||||
// Context must contain at least a sport, a region and a valid effective period.
|
||||
if (!SportRegionIdsIncluded.Exists(item => SysId.IsValid(item.SportId) && SysId.IsValid(item.RegionId)) && !UserAccountIdsOwner.HasValidIds() && !OrganisationIdsOwner.HasValidIds()) return false;
|
||||
if (!DateUtil.IsValid(EffectiveFrom) || EffectiveTo < EffectiveFrom) return false;
|
||||
return true;
|
||||
}
|
||||
public DbQuery.Paging Paging { get; } = new DbQuery.Paging();
|
||||
}
|
||||
/// <summary>
|
||||
/// Activities identified by querying index with context.
|
||||
/// </summary>
|
||||
public class IndexResults
|
||||
{
|
||||
public class ActivityData
|
||||
{
|
||||
public ActivityData(ItemId itemId, DateTime effectiveOn)
|
||||
{
|
||||
ItemId = itemId;
|
||||
EffectiveOn = effectiveOn;
|
||||
}
|
||||
public ItemId ItemId { get; }
|
||||
public DateTime EffectiveOn { get; }
|
||||
// Organisation.
|
||||
public SysId OrganisationId { get; set; }
|
||||
public String Organisation { get; set; }
|
||||
public bool OrganisationHasLogo { get; set; }
|
||||
// Author.
|
||||
public SysId UserAccountIdAuthor { get; set; }
|
||||
public String Author { get; set; }
|
||||
// Activity details.
|
||||
public String Caption { get; protected set; }
|
||||
public String Blurb { get; protected set; }
|
||||
// Thumbnail.
|
||||
public SysId ItemImageIdThumbnail { get; set; }
|
||||
// Sport.
|
||||
public SysId SportId { get; protected set; }
|
||||
public String SportName { get; protected set; }
|
||||
// Region.
|
||||
public SysId RegionId { get; protected set; }
|
||||
public String RegionName { get; protected set; }
|
||||
// User Activity.
|
||||
public DateTime LastListedAt { get; protected set; }
|
||||
public DateTime LastViewedAt { get; protected set; }
|
||||
public Sax.ActivityReaction Reaction { get; protected set; }
|
||||
public DateTime LastReactedAt { get; protected set; }
|
||||
}
|
||||
public List<ActivityData> Items { get; } = new List<ActivityData>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SaxInternals internals = null;
|
||||
private readonly List<Sax.DataItemType> validActivityItemTypes = new List<Sax.DataItemType>()
|
||||
{
|
||||
Sax.DataItemType.Article,
|
||||
Sax.DataItemType.OrganisationEvent,
|
||||
Sax.DataItemType.OrganisationOpportunity,
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxActivityConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && internals != null) internals.Dispose(); internals = null;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected SaxSessionContext SessionContext { get; }
|
||||
protected SaxInternals Internals { get { if (internals == null) internals = new SaxInternals(SessionContext); return internals; } }
|
||||
protected ISacsDatabase CoreDatabase { get { return Internals.CoreDatabase; } }
|
||||
protected List<Sax.DataItemType> ValidActivityItemTypes { get { return validActivityItemTypes.ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Query Activity Index Entries for User Context.
|
||||
//-------------------------------------------------------------------
|
||||
public abstract IndexResults QueryIndex(IndexContext context);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Store Activity Index for Specific activities.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Store the Activity Index for an Article.
|
||||
/// </summary>
|
||||
public bool StoreActivityIndex(SaxArticle article, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Determine whether article should be included in the Activity Index.
|
||||
bool includeInActivityIndex = true;
|
||||
|
||||
// Only published articles have an activity index.
|
||||
if (!DateUtil.IsValid(article.PublishedAt)) includeInActivityIndex = false;
|
||||
|
||||
// Only active articles have an activity index.
|
||||
if (!article.IsStatusActive) includeInActivityIndex = false;
|
||||
|
||||
// NB There will be other rules as well, eg. whether expired.
|
||||
|
||||
if (includeInActivityIndex)
|
||||
{
|
||||
// Activity Index properties.
|
||||
IndexData indexData = new IndexData(article.GetItemId());
|
||||
indexData.UserAccountIdOwner = article.UserAccountIdAuthor;
|
||||
indexData.OrganisationIdOwner = article.OrganisationId;
|
||||
indexData.SportIds.Add(article.SportIdPrimary);
|
||||
indexData.RegionIds.Add(article.RegionIdPrimary);
|
||||
indexData.EffectiveOn = DateUtil.OnInvalid(article.PublishedAt, article.CreateStamp.On).Date;
|
||||
return StoreActivityIndexData(indexData, dbUpdateInfo);
|
||||
}
|
||||
return ClearActivityIndex(article.GetItemId(), dbUpdateInfo);
|
||||
}
|
||||
public bool ClearActivityIndex(SaxArticle article, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
return ClearActivityIndex(article.GetItemId(), dbUpdateInfo);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Store the Activity Index for a Organisation Event.
|
||||
/// </summary>
|
||||
public bool StoreActivityIndex(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Only active opportunities have an activity index.
|
||||
if (!organisationEvent.IsStatusActive) ClearActivityIndex(organisationEvent.GetItemId(), dbUpdateInfo);
|
||||
|
||||
// NB There will be other rules as well, eg. whether published.
|
||||
|
||||
// Activity Index properties.
|
||||
IndexData indexData = new IndexData(organisationEvent.GetItemId());
|
||||
indexData.OrganisationIdOwner = organisationEvent.OrganisationId;
|
||||
indexData.SportIds.Add(organisationEvent.SportIdPrimary);
|
||||
indexData.RegionIds.Add(organisationEvent.RegionIdCountry);
|
||||
indexData.EffectiveOn = organisationEvent.EventAt.Date;
|
||||
indexData.ExpiresOn = DateUtil.OnInvalid(organisationEvent.ExpiresAt, DateUtil.IncrementDate(DateUtil.OnInvalid(organisationEvent.EventTo, organisationEvent.EventAt), 2)).Date;
|
||||
return StoreActivityIndexData(indexData, dbUpdateInfo);
|
||||
}
|
||||
public bool ClearActivityIndex(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
return ClearActivityIndex(organisationEvent.GetItemId(), dbUpdateInfo);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Store the Activity Index for a Organisation Opportunity.
|
||||
/// </summary>
|
||||
public bool StoreActivityIndex(SaxOrganisationOpportunity opportunity, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Only active opportunities have an activity index.
|
||||
if (!opportunity.IsStatusActive) ClearActivityIndex(opportunity.GetItemId(), dbUpdateInfo);
|
||||
|
||||
// NB There will be other rules as well, eg. whether published.
|
||||
|
||||
// Activity Index properties.
|
||||
IndexData indexData = new IndexData(opportunity.GetItemId());
|
||||
indexData.OrganisationIdOwner = opportunity.OrganisationId;
|
||||
indexData.SportIds.Add(opportunity.SportIdPrimary);
|
||||
indexData.RegionIds.Add(opportunity.RegionIdPrimary);
|
||||
indexData.EffectiveOn = DateUtil.OnInvalid(opportunity.PublishedAt, opportunity.CreateStamp.On).Date;
|
||||
indexData.ExpiresOn = DateUtil.OnInvalid(opportunity.ExpiresAt, DateUtil.IncrementDate(indexData.EffectiveOn, 28)).Date;
|
||||
return StoreActivityIndexData(indexData, dbUpdateInfo);
|
||||
}
|
||||
public bool ClearActivityIndex(SaxOrganisationOpportunity opportunity, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
return ClearActivityIndex(opportunity.GetItemId(), dbUpdateInfo);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Store Activity Index.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Data values that make up the index for an activity.</summary>
|
||||
protected class IndexData
|
||||
{
|
||||
public IndexData(ItemId itemId)
|
||||
{
|
||||
ItemId = itemId;
|
||||
}
|
||||
public ItemId ItemId { get; }
|
||||
public SysId UserAccountIdOwner { get; set; }
|
||||
public SysId OrganisationIdOwner { get; set; }
|
||||
public List<SysId> SportIds { get; } = new List<SysId>();
|
||||
public List<SysId> RegionIds { get; } = new List<SysId>();
|
||||
public DateTime EffectiveOn { get; set; }
|
||||
public DateTime ExpiresOn { get; set; }
|
||||
public bool IsValid()
|
||||
{
|
||||
if (!ItemId.IsValid(ItemId)) return false;
|
||||
if (!SportIds.HasValidIds()) return false;
|
||||
if (!RegionIds.HasValidIds()) return false;
|
||||
if (!DateUtil.IsValid(EffectiveOn)) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/// <summary>Single entry in the index for an activity.</summary>
|
||||
protected class IndexEntryData
|
||||
{
|
||||
public IndexEntryData(ItemId itemId, SysId userAccountIdOwner, SysId organisationIdOwner, SysId sportId, SysId regionId, DateTime effectiveOn, DateTime expiresOn)
|
||||
{
|
||||
ItemId = itemId;
|
||||
UserAccountIdOwner = userAccountIdOwner;
|
||||
OrganisationIdOwner = organisationIdOwner;
|
||||
SportId = sportId;
|
||||
RegionId = regionId;
|
||||
EffectiveOn = effectiveOn;
|
||||
ExpiresOn = expiresOn;
|
||||
}
|
||||
public ItemId ItemId { get; }
|
||||
public SysId UserAccountIdOwner { get; }
|
||||
public SysId OrganisationIdOwner { get; }
|
||||
public SysId SportId { get; }
|
||||
public SysId RegionId { get; }
|
||||
public DateTime EffectiveOn { get; }
|
||||
public DateTime? ExpiresOn { get; }
|
||||
public bool IsValid()
|
||||
{
|
||||
if (!ItemId.IsValid(ItemId)) return false;
|
||||
if (!SysId.IsValid(SportId)) return false;
|
||||
if (!SysId.IsValid(RegionId)) return false;
|
||||
if (!DateUtil.IsValid(EffectiveOn)) return false;
|
||||
return true;
|
||||
}
|
||||
/// <summary>Compare index entry Ids - Item, Sport & Region.</summary>
|
||||
public bool MatchesIds(SaxActivityIndex activityIndex)
|
||||
{
|
||||
if (!ItemId.Equals(activityIndex.ItemId)) return false;
|
||||
if (!SportId.Equals(activityIndex.SportId)) return false;
|
||||
if (!RegionId.Equals(activityIndex.RegionId)) return false;
|
||||
return true;
|
||||
}
|
||||
/// <summary>Compare index entry Ids - Item, Sport & Region - and effective date.</summary>
|
||||
public bool Matches(SaxActivityIndex activityIndex)
|
||||
{
|
||||
if (!MatchesIds(activityIndex)) return false;
|
||||
if (!EffectiveOn.Equals(activityIndex.EffectiveOn)) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Activity Index data.
|
||||
protected abstract bool StoreActivityIndexData(IndexData indexData, DbUpdateInfo dbUpdateInfo);
|
||||
protected abstract bool ClearActivityIndex(ItemId itemId, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Activity Index Utilities.
|
||||
protected List<IndexEntryData> GetEntriesForIndex(IndexData indexData)
|
||||
{
|
||||
ClearErrorState();
|
||||
List<IndexEntryData> indexEntries = new List<IndexEntryData>();
|
||||
if (ItemId.IsValid(indexData.ItemId) && DateUtil.IsValid(indexData.EffectiveOn))
|
||||
{
|
||||
foreach (SysId sportId in indexData.SportIds.FindAll(item => SysId.IsValid(item)))
|
||||
{
|
||||
foreach (SysId regionId in indexData.RegionIds.FindAll(item => SysId.IsValid(item)))
|
||||
{
|
||||
IndexEntryData indexEntry = new IndexEntryData(indexData.ItemId, indexData.UserAccountIdOwner, indexData.OrganisationIdOwner, sportId, regionId, indexData.EffectiveOn, indexData.ExpiresOn);
|
||||
if (indexEntry.IsValid())
|
||||
indexEntries.Add(indexEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
return indexEntries;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// User Activities
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool RecordUserActivitiesListed(SysId userAccountId, List<ItemId> activityItemIds, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool RecordUserActivityViewed(SysId userAccountId, ItemId activityItemId, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool RecordUserActivityReaction(SysId userAccountId, ItemId activityItemId, Sax.ActivityReaction activityReaction, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxConsoleHelper : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxConsoleHelper()
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data cache console.
|
||||
public abstract SaxDataCacheConsole GetDataCacheConsole(SaxSessionContext sessionContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Session data console.
|
||||
public abstract SaxSessionDataConsole GetSessionDataConsole(SaxSessionContext sessionContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Activity console.
|
||||
public abstract SaxActivityConsole CreateActivityConsole(SaxSessionContext sessionContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Email console.
|
||||
public abstract SaxEmailConsole CreateEmailConsole(SaxSessionContext sessionContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
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)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
}
|
||||
protected override void Dispose(bool disposing) { }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected SaxSessionContext SessionContext { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract void PopulateCachedDataToInternals(SaxInternals internals);
|
||||
/// <summary>
|
||||
/// Encrypted Ids are stored in cache to ensure that they are consistent throughout a user's session
|
||||
/// by persisting them through the life of the cache (application restart).
|
||||
/// <para>Required as the encrypted values are compared in javascript.</para>
|
||||
/// <para>Candidate encrypted value supplied by calling routine as cache doesn't know how to encrypt - used if Id not previously encrypted.</para>
|
||||
/// </summary>
|
||||
public abstract String GetEncryptedId(Sax.DataItemType itemType, SysId id, String candidateValue);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Regions.
|
||||
/// <summary>
|
||||
/// Get the cached list of regions.
|
||||
/// </summary>
|
||||
public abstract List<SaxRegion.Data> GetAllRegions();
|
||||
/// <summary>
|
||||
/// Get the cached list of active regions.
|
||||
/// </summary>
|
||||
public abstract List<SaxRegion.Data> GetActiveRegions();
|
||||
/// <summary>
|
||||
/// Persistent encrypted Region Ids.
|
||||
/// </summary>
|
||||
public String GetEncryptedRegionId(SysId regionId, String candidateValue)
|
||||
{
|
||||
return GetEncryptedId(Sax.DataItemType.Region, regionId, candidateValue);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Sports.
|
||||
/// <summary>
|
||||
/// Get the cached list of sports.
|
||||
/// </summary>
|
||||
public abstract List<SaxSport.Data> GetAllSports();
|
||||
/// <summary>
|
||||
/// Get the cached list of active sports.
|
||||
/// </summary>
|
||||
public abstract List<SaxSport.Data> GetActiveSports();
|
||||
/// <summary>
|
||||
/// Persistent encrypted Sport Ids.
|
||||
/// </summary>
|
||||
public String GetEncryptedSportId(SysId sportId, String candidateValue)
|
||||
{
|
||||
return GetEncryptedId(Sax.DataItemType.Sport, sportId, candidateValue);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -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.GetResourceText(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.GetResourceText(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.GetResourceText(SaxResourceHelper.TextResource.Email_Footer_Html));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
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 class SaxProcessConsole : SaxDisposableStateItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SaxInternals internals = null;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxProcessConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && internals != null) internals.Dispose(); internals = null;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected SaxSessionContext SessionContext { get; }
|
||||
protected SaxInternals Internals { get { if (internals == null) internals = new SaxInternals(SessionContext); return internals; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
// Some session data is stored to the database but, to avoid potential
|
||||
// performance issues in action execution, the data to store is cached and
|
||||
// periodically committed in batches.
|
||||
//=======================================================================
|
||||
public abstract class SaxSessionDataConsole : SaxDisposableStateItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SaxInternals internals = null;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxSessionDataConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && internals != null) internals.Dispose(); internals = null;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected SaxSessionContext SessionContext { get; }
|
||||
protected SaxInternals Internals { get { if (internals == null) internals = new SaxInternals(SessionContext); return internals; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// User activity.
|
||||
//-------------------------------------------------------------------
|
||||
// Record latest user active time.
|
||||
public abstract bool RecordUserActive(SysId userAccountId, DateTime activeAt);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data commit.
|
||||
//-------------------------------------------------------------------
|
||||
public abstract DateTime LastDataCommit();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static Saxonite.Net.Standard.Base.Bus.SaxUserConfig;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Data
|
||||
{
|
||||
//==========================================================================
|
||||
public class SaxConfigData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
private static readonly String ElementName_Config = "Config";
|
||||
private static readonly String ElementName_Profile = "Profile";
|
||||
private static readonly String ElementName_Eligibility = "Eligibility";
|
||||
private static readonly String ElementName_HideInfo = "HideInfo";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Profile settings.</summary>
|
||||
public class ProfileData
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
/// <summary>Eligibility settings.</summary>
|
||||
public class EligibilityData
|
||||
{
|
||||
/// <summary>Hide the eligbiility information tip.</summary>
|
||||
public bool HideInfo { get; set; }
|
||||
}
|
||||
public EligibilityData Eligibility { get; set; } = new EligibilityData();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
/// <summary>Serialise to XML.</summary>
|
||||
public static String ToXml(ProfileData profile)
|
||||
{
|
||||
String fn = typeof(ProfileData).FullName + ".GetConfigData";
|
||||
try
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
XElement configElement = doc.AppendElement(ElementName_Config);
|
||||
// Profile.
|
||||
XElement profileElement = configElement.AppendElement(ElementName_Profile);
|
||||
// Profile - Eligibility.
|
||||
XElement eligibilityElement = profileElement.AppendElement(ElementName_Eligibility);
|
||||
if (profile.Eligibility.HideInfo)
|
||||
eligibilityElement.AppendElement(ElementName_HideInfo, "1");
|
||||
return doc.GetXml();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
/// <summary>Deserialise from XML.</summary>
|
||||
public static ProfileData FromXml(String configData)
|
||||
{
|
||||
String fn = typeof(ProfileData).FullName + ".ExtractConfig";
|
||||
ProfileData profile = new ProfileData();
|
||||
if (StringUtil.IsEmpty(configData)) return profile;
|
||||
try
|
||||
{
|
||||
// Load XML data.
|
||||
// NB Serialised data has 'Config' as root element
|
||||
XDocument doc = XDocument.Parse(configData);
|
||||
XElement rootElement = doc.Root;
|
||||
foreach (XElement rootChildElement in rootElement.GetChildElements())
|
||||
{
|
||||
String rootChildElementName = rootChildElement.GetLocalName();
|
||||
if (rootChildElementName.EqualsCI(ElementName_Profile))
|
||||
{
|
||||
// Profile.
|
||||
XElement profileElement = rootChildElement;
|
||||
foreach (XElement profileChildElement in profileElement.GetChildElements())
|
||||
{
|
||||
String profileChildElementName = profileChildElement.GetLocalName();
|
||||
if (profileChildElementName.EqualsCI(ElementName_Eligibility))
|
||||
{
|
||||
// Profile - Eligibility.
|
||||
XElement eligibilityElement = profileChildElement;
|
||||
String hideInfo = eligibilityElement.GetChildText(ElementName_HideInfo);
|
||||
profile.Eligibility.HideInfo = StringUtil.ToBool(hideInfo);
|
||||
}
|
||||
else SaLogger.Warn(fn + " Unexpected 'Profile' child element: " + profileChildElementName);
|
||||
}
|
||||
}
|
||||
else SaLogger.Warn(fn + " Unexpected 'Root' child element: " + rootChildElementName);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using Sarand.Net.Standard.Base.Helpers;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Helpers
|
||||
{
|
||||
//=======================================================================
|
||||
public static class SaxContactMethodHelper
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
//-------------------------------------------------------------------
|
||||
public static Sax.ContactMethodType GetContactMethodType(Sax.ContactMethod contactMethod)
|
||||
{
|
||||
switch (contactMethod)
|
||||
{
|
||||
case Sax.ContactMethod.PhoneMain:
|
||||
case Sax.ContactMethod.PhoneMobile:
|
||||
case Sax.ContactMethod.PhoneHome:
|
||||
case Sax.ContactMethod.PhoneOffice:
|
||||
return Sax.ContactMethodType.Phone;
|
||||
case Sax.ContactMethod.Email:
|
||||
return Sax.ContactMethodType.Email;
|
||||
case Sax.ContactMethod.Website:
|
||||
case Sax.ContactMethod.Wikipedia:
|
||||
case Sax.ContactMethod.Location:
|
||||
case Sax.ContactMethod.LinkedIn:
|
||||
case Sax.ContactMethod.Twitter:
|
||||
case Sax.ContactMethod.Facebook:
|
||||
case Sax.ContactMethod.Instagram:
|
||||
return Sax.ContactMethodType.WebUrl;
|
||||
}
|
||||
return Sax.ContactMethodType.Unknown;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Validate Contact Method value.</summary>
|
||||
public static bool IsValidContactMethodValue(Sax.ContactMethod method, String value)
|
||||
{
|
||||
Sax.ContactMethodType contactMethodType = GetContactMethodType(method);
|
||||
|
||||
// Method specific value validation.
|
||||
if (contactMethodType == Sax.ContactMethodType.Phone)
|
||||
{
|
||||
// Phone number.
|
||||
return SacsDataValidationHelper.IsValidPhone(value);
|
||||
}
|
||||
else if (contactMethodType == Sax.ContactMethodType.Email)
|
||||
{
|
||||
// Email address.
|
||||
return SacsDataValidationHelper.IsValidEmailAddress(value);
|
||||
}
|
||||
else if (contactMethodType == Sax.ContactMethodType.WebUrl)
|
||||
{
|
||||
if (method == Sax.ContactMethod.Wikipedia)
|
||||
{
|
||||
// Wikipedia.
|
||||
return SacsDataValidationHelper.IsValidWikipediaUrl(value);
|
||||
}
|
||||
else if (method == Sax.ContactMethod.Location)
|
||||
{
|
||||
// Location URL.
|
||||
return SacsDataValidationHelper.IsValidLocationUrl(value);
|
||||
}
|
||||
else if (method == Sax.ContactMethod.LinkedIn)
|
||||
{
|
||||
// LinkedIn.
|
||||
return SacsDataValidationHelper.IsValidLinkedInUrl(value);
|
||||
}
|
||||
else if (method == Sax.ContactMethod.Twitter)
|
||||
{
|
||||
// X (was Twitter).
|
||||
return SacsDataValidationHelper.IsValidTwitterUrl(value);
|
||||
}
|
||||
else if (method == Sax.ContactMethod.Facebook)
|
||||
{
|
||||
// Facebook.
|
||||
return SacsDataValidationHelper.IsValidFacebookUrl(value);
|
||||
}
|
||||
else if (method == Sax.ContactMethod.Instagram)
|
||||
{
|
||||
// Instagram.
|
||||
return SacsDataValidationHelper.IsValidInstagramUrl(value);
|
||||
}
|
||||
else if (method == Sax.ContactMethod.YouTube)
|
||||
{
|
||||
// YouTube.
|
||||
return SacsDataValidationHelper.IsValidYouTubeUrl(value);
|
||||
}
|
||||
else if (method == Sax.ContactMethod.Twitch)
|
||||
{
|
||||
// Twitch.
|
||||
return SacsDataValidationHelper.IsValidTwitchUrl(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Generic URL.
|
||||
return SacsDataValidationHelper.IsValidUrl(value);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -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,127 @@
|
||||
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.IO;
|
||||
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_Security_AccountActivated_Html,
|
||||
Email_Security_RequestPassword_Html,
|
||||
// Data - countries etc.
|
||||
Data_CountriesWithRegions_Txt,
|
||||
}
|
||||
public enum ImageResource
|
||||
{
|
||||
Saxonite_logo_h75_png,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public static Assembly MyAssembly { get; } = typeof(SaxResourceHelper).GetTypeInfo().Assembly;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Text resources.
|
||||
|
||||
/// <summary> Retrieve contents of text resource in this assembly by type.</summary>
|
||||
public static String GetResourceText(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_Security_AccountActivated_Html:
|
||||
resourceFilename = "sax-email-account-activated.html";
|
||||
break;
|
||||
case TextResource.Email_Security_RequestPassword_Html:
|
||||
resourceFilename = "sax-email-request-password.html";
|
||||
break;
|
||||
// Data.
|
||||
case TextResource.Data_CountriesWithRegions_Txt:
|
||||
resourceFilename = "CountriesWithRegions.txt";
|
||||
break;
|
||||
}
|
||||
return GetResourceText(resourceFilename, partialPath);
|
||||
}
|
||||
|
||||
/// <summary> Retrieve contents of text resource in this assembly by name.</summary>
|
||||
public static String GetResourceText(String resourceFilename, String partialPath = "")
|
||||
{
|
||||
if (!StringUtil.IsBlank(resourceFilename))
|
||||
{
|
||||
String resourceText = SacsResourceHelper.GetManifestResourceAsText(MyAssembly, partialPath, resourceFilename);
|
||||
if (!StringUtil.IsBlank(resourceText))
|
||||
return resourceText;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Image resources.
|
||||
public static byte[] GetResourceImage(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];
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Resource stream.
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve stream to resource in this assembly.
|
||||
/// </summary>
|
||||
public static Stream GetResourceStream(String resourceFilename, String partialPath = "")
|
||||
{
|
||||
if (!StringUtil.IsBlank(resourceFilename))
|
||||
{
|
||||
return SacsResourceHelper.GetManifestResourceStream(MyAssembly, partialPath, resourceFilename);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxItemMgr_Reference : SaxItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxItemMgr_Reference(SaxSessionContext sessionContext, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISacsDatabase ReferenceDatabase { get { return SaxGlobals.App.GetDatabase(SessionContext, Sax.Database.Reference); } }
|
||||
public IDatabaseInfo ReferenceDbInfo { get { return SaxGlobals.App.CreateDbInfo(SessionContext, Sax.Database.Reference); } }
|
||||
// Managers.
|
||||
public SaxReferenceGolfMgr ReferenceGolfMgr { get { return Internals.ReferenceGolfMgr; } }
|
||||
// Application codes.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
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.Reference;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Country
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaCountry CreateUsgaCountry();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaCountryExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaCountry.Params prmUsgaCountry = new SaxGolfUsgaCountry.Params();
|
||||
prmUsgaCountry.IdsIncluded.Add(id);
|
||||
prmUsgaCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.Any;
|
||||
return GetUsgaCountryCount(prmUsgaCountry) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaCountry GetUsgaCountry(SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
public SaxGolfUsgaCountry GetUsgaCountryById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaCountry.Params prmUsgaCountry = new SaxGolfUsgaCountry.Params();
|
||||
prmUsgaCountry.IdsIncluded.Add(id);
|
||||
prmUsgaCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.Any;
|
||||
return GetUsgaCountry(prmUsgaCountry);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaCountry(SaxGolfUsgaCountry usgaCountry)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaCountry == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaCountryData(usgaCountry.GetData(), new SaxGolfUsgaCountry.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaCountryData(SaxGolfUsgaCountry.Data data, SaxGolfUsgaCountry.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Country code.
|
||||
if (errField.CountryCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.CountryCode, "code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_CountryCode), true))
|
||||
{
|
||||
errField.CountryCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// ENT Country code.
|
||||
if (errField.EntCountryCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.EntCountryCode, "ent code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_EntCountryCode)))
|
||||
{
|
||||
errField.EntCountryCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Country name.
|
||||
if (errField.CountryName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.CountryName, "name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_CountryName), true))
|
||||
{
|
||||
errField.CountryName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaCountry.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaCountry(SaxGolfUsgaCountry usgaCountry, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaCountry(SaxGolfUsgaCountry usgaCountry, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaCountryCanBeDeleted(SaxGolfUsgaCountry usgaCountry)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaCountry(SaxGolfUsgaCountry usgaCountry, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaCountryData
|
||||
{
|
||||
public String CountryCode { get; set; }
|
||||
public String EntCountryCode { get; set; } = null;
|
||||
public String CountryName { get; set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Countries.
|
||||
/// <para>- Country code must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per country rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaCountries(List<UsgaCountryData> countries, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaCountryQueryFilter(SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
public abstract long GetUsgaCountryCount(SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
public long GetActiveUsgaCountryCount() { return GetUsgaCountryCount(new SaxGolfUsgaCountry.Params()); }
|
||||
public abstract List<SaxGolfUsgaCountry> GetUsgaCountryList(SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
public abstract DbResultSet ExecuteUsgaCountryQuery(List<ColumnDfn> columns, SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUsgaCountryDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaCountry.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaCountry.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaCountry.Column.Status_Desc:
|
||||
case SaxGolfUsgaCountry.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaCountry.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaCountry.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaCountry.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
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 Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Course
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaCourse CreateUsgaCourse(SysId facilityId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaCourseExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaCourse.Params prmUsgaCourse = new SaxGolfUsgaCourse.Params();
|
||||
prmUsgaCourse.IdsIncluded.Add(id);
|
||||
prmUsgaCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.Any;
|
||||
return GetUsgaCourseCount(prmUsgaCourse) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaCourse GetUsgaCourse(SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
public SaxGolfUsgaCourse GetUsgaCourseById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaCourse.Params prmUsgaCourse = new SaxGolfUsgaCourse.Params();
|
||||
prmUsgaCourse.IdsIncluded.Add(id);
|
||||
prmUsgaCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.Any;
|
||||
return GetUsgaCourse(prmUsgaCourse);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaCourse(SaxGolfUsgaCourse usgaCourse)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaCourse == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaCourseData(usgaCourse.GetData(), new SaxGolfUsgaCourse.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaCourseData(SaxGolfUsgaCourse.Data data, SaxGolfUsgaCourse.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Facility.
|
||||
if (errField.FacilityId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.FacilityId))
|
||||
{
|
||||
errField.FacilityId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Facility must be specified");
|
||||
}
|
||||
// Course Id.
|
||||
if (errField.CourseId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UsgaCourseId))
|
||||
{
|
||||
errField.CourseId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Course Id must be specified");
|
||||
}
|
||||
// Caption.
|
||||
if (errField.Caption != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Caption, "caption", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Caption), true))
|
||||
{
|
||||
errField.Caption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Course name.
|
||||
if (errField.CourseName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.CourseName, "name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_CourseName), true))
|
||||
{
|
||||
errField.CourseName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Full name.
|
||||
if (errField.FullName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.FullName, "full name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_FullName)))
|
||||
{
|
||||
errField.FullName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Address line 1.
|
||||
if (errField.Address1 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Address1, "address line 1", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Address1)))
|
||||
{
|
||||
errField.Address1 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Address line 2.
|
||||
if (errField.Address2 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Address2, "address line 2", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Address2)))
|
||||
{
|
||||
errField.Address2 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// City.
|
||||
if (errField.City != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.City, "city", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_City)))
|
||||
{
|
||||
errField.City = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Postal Code.
|
||||
if (errField.PostalCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PostalCode, "postal code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_PostalCode)))
|
||||
{
|
||||
errField.PostalCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Email.
|
||||
if (errField.Email != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Email, "email", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Email)))
|
||||
{
|
||||
errField.Email = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Telephone.
|
||||
if (errField.Telephone != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Telephone, "telephone", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Telephone)))
|
||||
{
|
||||
errField.Telephone = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaCourse.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Facility.
|
||||
if (errField.FacilityId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.FacilityId))
|
||||
{
|
||||
SaxGolfUsgaFacility.Params prmFacility = new SaxGolfUsgaFacility.Params();
|
||||
prmFacility.IdsIncluded.Add(data.FacilityId);
|
||||
prmFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.NotDeleted;
|
||||
if (ReferenceGolfMgr.GetUsgaFacilityCount(prmFacility) < 1)
|
||||
{
|
||||
errField.FacilityId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid course specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaCourse(SaxGolfUsgaCourse usgaCourse, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaCourse(SaxGolfUsgaCourse usgaCourse, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaCourseCanBeDeleted(SaxGolfUsgaCourse usgaCourse)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaCourse(SaxGolfUsgaCourse usgaCourse, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaCourseData
|
||||
{
|
||||
public SysId UsgaFacilityId { get; set; }
|
||||
public SysId UsgaCourseId { get; set; }
|
||||
public SysId LegacyCrpCourseId { get; set; }
|
||||
public string Caption { get; set; } = null;
|
||||
public string CourseName { get; set; } = null;
|
||||
public string FullName { get; set; } = null;
|
||||
public string Address1 { get; set; } = null;
|
||||
public string Address2 { get; set; } = null;
|
||||
public string City { get; set; } = null;
|
||||
public string PostalCode { get; set; } = null;
|
||||
public string Email { get; set; } = null;
|
||||
public string Telephone { get; set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Courses.
|
||||
/// <para>- Facility code must be supplied to identify parent.</para>
|
||||
/// <para>- Course Id must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per province rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaCourses(List<UsgaCourseData> courses, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaCourseColumnDfn(SaxGolfUsgaCourse.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaCourseQueryFilter(SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
public abstract long GetUsgaCourseCount(SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
public abstract List<SaxGolfUsgaCourse> GetUsgaCourseList(SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
public abstract DbResultSet ExecuteUsgaCourseQuery(List<ColumnDfn> columns, SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUsgaCourseDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaCourse.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaCourse.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaCourse.Column.Status_Desc:
|
||||
case SaxGolfUsgaCourse.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaCourse.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaCourse.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaCourse.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
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 Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Facility
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaFacility CreateUsgaFacility(SysId provinceId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaFacilityExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaFacility.Params prmUsgaFacility = new SaxGolfUsgaFacility.Params();
|
||||
prmUsgaFacility.IdsIncluded.Add(id);
|
||||
prmUsgaFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.Any;
|
||||
return GetUsgaFacilityCount(prmUsgaFacility) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaFacility GetUsgaFacility(SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
public SaxGolfUsgaFacility GetUsgaFacilityById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaFacility.Params prmUsgaFacility = new SaxGolfUsgaFacility.Params();
|
||||
prmUsgaFacility.IdsIncluded.Add(id);
|
||||
prmUsgaFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.Any;
|
||||
return GetUsgaFacility(prmUsgaFacility);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaFacility(SaxGolfUsgaFacility usgaFacility)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaFacility == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaFacilityData(usgaFacility.GetData(), new SaxGolfUsgaFacility.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaFacilityData(SaxGolfUsgaFacility.Data data, SaxGolfUsgaFacility.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Province.
|
||||
if (errField.ProvinceId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.ProvinceId))
|
||||
{
|
||||
errField.ProvinceId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Province must be specified");
|
||||
}
|
||||
// Facility code.
|
||||
if (errField.UsgaFacilityId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UsgaFacilityId))
|
||||
{
|
||||
errField.UsgaFacilityId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Facility Id must be specified");
|
||||
}
|
||||
// Facility name.
|
||||
if (errField.FacilityName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.FacilityName, "name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaFacility_FacilityName), true))
|
||||
{
|
||||
errField.FacilityName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaFacility_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaFacility_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaFacility.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Province.
|
||||
if (errField.ProvinceId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.ProvinceId))
|
||||
{
|
||||
SaxGolfUsgaProvince.Params prmProvince = new SaxGolfUsgaProvince.Params();
|
||||
prmProvince.IdsIncluded.Add(data.ProvinceId);
|
||||
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.NotDeleted;
|
||||
if (ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince) < 1)
|
||||
{
|
||||
errField.ProvinceId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid province specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaFacility(SaxGolfUsgaFacility usgaFacility, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaFacility(SaxGolfUsgaFacility usgaFacility, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaFacilityCanBeDeleted(SaxGolfUsgaFacility usgaFacility)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaFacility(SaxGolfUsgaFacility usgaFacility, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaFacilityData
|
||||
{
|
||||
public String ProvinceCode { get; set; }
|
||||
public SysId UsgaFacilityId { get; set; }
|
||||
public String FacilityName { get; set; } = null;
|
||||
public string Address1 { get; set; } = null;
|
||||
public string Address2 { get; set; } = null;
|
||||
public string City { get; set; } = null;
|
||||
public string PostalCode { get; set; } = null;
|
||||
public string Email { get; set; } = null;
|
||||
public string Telephone { get; set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Facilities.
|
||||
/// <para>- Province code must be supplied to identify parent.</para>
|
||||
/// <para>- Facility Id must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per province rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaFacilities(List<UsgaFacilityData> facilities, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaFacilityColumnDfn(SaxGolfUsgaFacility.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaFacilityQueryFilter(SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
public abstract long GetUsgaFacilityCount(SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
public abstract List<SaxGolfUsgaFacility> GetUsgaFacilityList(SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
public abstract DbResultSet ExecuteUsgaFacilityQuery(List<ColumnDfn> columns, SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUsgaFacilityDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaFacility.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaFacility.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaFacility.Column.Status_Desc:
|
||||
case SaxGolfUsgaFacility.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaFacility.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaFacility.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaFacility.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
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 Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Marker
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaMarker CreateUsgaMarker(SysId courseId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaMarkerExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaMarker.Params prmUsgaMarker = new SaxGolfUsgaMarker.Params();
|
||||
prmUsgaMarker.IdsIncluded.Add(id);
|
||||
prmUsgaMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.Any;
|
||||
return GetUsgaMarkerCount(prmUsgaMarker) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaMarker GetUsgaMarker(SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
public SaxGolfUsgaMarker GetUsgaMarkerById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaMarker.Params prmUsgaMarker = new SaxGolfUsgaMarker.Params();
|
||||
prmUsgaMarker.IdsIncluded.Add(id);
|
||||
prmUsgaMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.Any;
|
||||
return GetUsgaMarker(prmUsgaMarker);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaMarker(SaxGolfUsgaMarker usgaMarker)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaMarker == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaMarkerData(usgaMarker.GetData(), new SaxGolfUsgaMarker.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaMarkerData(SaxGolfUsgaMarker.Data data, SaxGolfUsgaMarker.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Course.
|
||||
if (errField.CourseId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.CourseId))
|
||||
{
|
||||
errField.CourseId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Course must be specified");
|
||||
}
|
||||
// Marker Id.
|
||||
if (errField.UsgaMarkerId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UsgaMarkerId))
|
||||
{
|
||||
errField.UsgaMarkerId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Marker Id must be specified");
|
||||
}
|
||||
// Caption.
|
||||
if (errField.Caption != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Caption, "caption", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Caption), true))
|
||||
{
|
||||
errField.Caption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Holes.
|
||||
if (errField.Holes != SacsHierarchyItem.ValidValue.Ignore && data.Holes < 1)
|
||||
{
|
||||
errField.HolesCaption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Holes must be specified");
|
||||
}
|
||||
// Holes caption.
|
||||
if (errField.HolesCaption != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.HolesCaption, "holes caption", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_HolesCaption), true))
|
||||
{
|
||||
errField.HolesCaption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Tee.
|
||||
if (errField.Tee != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Tee, "tee", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Tee), true))
|
||||
{
|
||||
errField.Tee = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Gender.
|
||||
if (errField.Gender != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Gender, "gender", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Gender)))
|
||||
{
|
||||
errField.Gender = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Slope Rating.
|
||||
if (errField.SlopeRating != SacsHierarchyItem.ValidValue.Ignore && data.SlopeRating < 1)
|
||||
{
|
||||
errField.SlopeRating = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Slope rating must be specified");
|
||||
}
|
||||
// Par.
|
||||
if (errField.Par != SacsHierarchyItem.ValidValue.Ignore && data.Par < 1)
|
||||
{
|
||||
errField.Par = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Par must be specified");
|
||||
}
|
||||
// Course Rating.
|
||||
if (errField.CourseRating != SacsHierarchyItem.ValidValue.Ignore && data.CourseRating < 1)
|
||||
{
|
||||
errField.CourseRating = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Course rating must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaMarker.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Course.
|
||||
if (errField.CourseId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.CourseId))
|
||||
{
|
||||
SaxGolfUsgaCourse.Params prmCourse = new SaxGolfUsgaCourse.Params();
|
||||
prmCourse.IdsIncluded.Add(data.CourseId);
|
||||
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.NotDeleted;
|
||||
if (ReferenceGolfMgr.GetUsgaCourseCount(prmCourse) < 1)
|
||||
{
|
||||
errField.CourseId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid marker specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaMarker(SaxGolfUsgaMarker usgaMarker, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaMarker(SaxGolfUsgaMarker usgaMarker, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaMarkerCanBeDeleted(SaxGolfUsgaMarker usgaMarker)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaMarker(SaxGolfUsgaMarker usgaMarker, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaMarkerData
|
||||
{
|
||||
public SysId UsgaCourseId { get; set; }
|
||||
public SysId UsgaMarkerId { get; set; }
|
||||
public string Caption { get; set; }
|
||||
public short Holes { get; set; }
|
||||
public string HolesCaption { get; set; }
|
||||
public string Tee { get; set; }
|
||||
public string Gender { get; set; }
|
||||
public short SlopeRating { get; set; }
|
||||
public short Par { get; set; }
|
||||
public decimal CourseRating { get; set; }
|
||||
public decimal BogeyRating { get; set; }
|
||||
public short Length { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Markers.
|
||||
/// <para>- Course Id must be supplied to identify parent.</para>
|
||||
/// <para>- Marker Id must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per merker rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaMarkers(List<UsgaMarkerData> markers, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaMarkerQueryFilter(SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
public abstract long GetUsgaMarkerCount(SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
public abstract List<SaxGolfUsgaMarker> GetUsgaMarkerList(SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
public abstract DbResultSet ExecuteUsgaMarkerQuery(List<ColumnDfn> columns, SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUsgaMarkerDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaMarker.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaMarker.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaMarker.Column.Status_Desc:
|
||||
case SaxGolfUsgaMarker.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaMarker.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaMarker.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaMarker.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
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 Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Province
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaProvince CreateUsgaProvince(SysId countryId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaProvinceExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaProvince.Params prmUsgaProvince = new SaxGolfUsgaProvince.Params();
|
||||
prmUsgaProvince.IdsIncluded.Add(id);
|
||||
prmUsgaProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.Any;
|
||||
return GetUsgaProvinceCount(prmUsgaProvince) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaProvince GetUsgaProvince(SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
public SaxGolfUsgaProvince GetUsgaProvinceById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaProvince.Params prmUsgaProvince = new SaxGolfUsgaProvince.Params();
|
||||
prmUsgaProvince.IdsIncluded.Add(id);
|
||||
prmUsgaProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.Any;
|
||||
return GetUsgaProvince(prmUsgaProvince);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaProvince(SaxGolfUsgaProvince usgaProvince)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaProvince == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaProvinceData(usgaProvince.GetData(), new SaxGolfUsgaProvince.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaProvinceData(SaxGolfUsgaProvince.Data data, SaxGolfUsgaProvince.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Country.
|
||||
if (errField.CountryId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.CountryId))
|
||||
{
|
||||
errField.CountryId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Country must be specified");
|
||||
}
|
||||
// Province code.
|
||||
if (errField.ProvinceCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.ProvinceCode, "code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_ProvinceCode), true))
|
||||
{
|
||||
errField.ProvinceCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// ENT Province code.
|
||||
if (errField.EntProvinceCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.EntProvinceCode, "ENT code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_EntProvinceCode)))
|
||||
{
|
||||
errField.EntProvinceCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Province name.
|
||||
if (errField.ProvinceName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.ProvinceName, "name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_ProvinceName), true))
|
||||
{
|
||||
errField.ProvinceName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaProvince.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Country.
|
||||
if (errField.CountryId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.CountryId))
|
||||
{
|
||||
SaxGolfUsgaCountry.Params prmCountry = new SaxGolfUsgaCountry.Params();
|
||||
prmCountry.IdsIncluded.Add(data.CountryId);
|
||||
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.NotDeleted;
|
||||
if (ReferenceGolfMgr.GetUsgaCountryCount(prmCountry) < 1)
|
||||
{
|
||||
errField.CountryId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid country specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaProvince(SaxGolfUsgaProvince usgaProvince, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaProvince(SaxGolfUsgaProvince usgaProvince, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaProvinceCanBeDeleted(SaxGolfUsgaProvince usgaProvince)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaProvince(SaxGolfUsgaProvince usgaProvince, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaProvinceData
|
||||
{
|
||||
public String CountryCode { get; set; }
|
||||
public String ProvinceCode { get; set; }
|
||||
public String EntProvinceCode { get; set; } = null;
|
||||
public String ProvinceName { get; set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Provinces.
|
||||
/// <para>- Country code must be supplied to identify parent.</para>
|
||||
/// <para>- Province code must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per province rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaProvinces(List<UsgaProvinceData> provinces, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaProvinceQueryFilter(SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
public abstract long GetUsgaProvinceCount(SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
public abstract List<SaxGolfUsgaProvince> GetUsgaProvinceList(SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
public abstract DbResultSet ExecuteUsgaProvinceQuery(List<ColumnDfn> columns, SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUsgaProvinceDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaProvince.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaProvince.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaProvince.Column.Status_Desc:
|
||||
case SaxGolfUsgaProvince.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaProvince.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaProvince.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaProvince.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxReferenceGolfMgr : SaxItemMgr_Reference
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxReferenceGolfMgr(SaxSessionContext sessionContext, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
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.
|
||||
/// <summary>Get number of active members for Organisation.</summary>
|
||||
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.UserAccountStatusCat = SaxUserAccount.StatusCat.ActiveOnly;
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
|
||||
return GetUserOrganisationCount(prmUserOrganisation);
|
||||
}
|
||||
/// <summary>Get number of active opportunities for organisation.</summary>
|
||||
public long GetOrganisationOpportunityCount(SysId organisationId)
|
||||
{
|
||||
if (!SysId.IsValid(organisationId)) return 0;
|
||||
SaxOrganisationOpportunity.Params prmOrganisationOpportunity = new SaxOrganisationOpportunity.Params();
|
||||
prmOrganisationOpportunity.OrganisationIdsIncluded.Add(organisationId);
|
||||
prmOrganisationOpportunity.StatusCat = SaxOrganisationOpportunity.StatusCat.ActiveOnly;
|
||||
return ActivityMgr.GetOrganisationOpportunityCount(prmOrganisationOpportunity);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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_Core.GetColTextLen(SaxDbDfn_Core.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.");
|
||||
}
|
||||
// Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!SysId.IsValid(data.SportIdPrimary) && SaxOrganisation.IsSportMandatory(data.OrganisationCategory))
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Sport must be specified.");
|
||||
}
|
||||
}
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Region must be specified.");
|
||||
}
|
||||
}
|
||||
|
||||
// About.
|
||||
if (errField.About != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.About, "about", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Organisation_About)))
|
||||
{
|
||||
errField.About = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Facilities.
|
||||
if (errField.Facilities != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Facilities, "facilities", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Organisation_Facilities)))
|
||||
{
|
||||
errField.Facilities = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Contact data.
|
||||
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Organisation_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
if (!ReferenceMgr.SportExistsById(data.SportIdPrimary))
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
SaxRegion region = ReferenceMgr.GetRegionById(data.RegionIdPrimary);
|
||||
if (region == null)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
}
|
||||
if (region.RegionType != App.Sax.RegionType.Country && region.RegionType != App.Sax.RegionType.Continent && region.RegionType != App.Sax.RegionType.World)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Region must be a country or international region");
|
||||
}
|
||||
}
|
||||
|
||||
// Region & name must be unique.
|
||||
if (errField.Name != SacsHierarchyItem.ValidValue.Ignore && !StringUtil.IsEmpty(data.Name) && errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
// Name must be unique within region.
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmOrganisation.IdsExcluded.Add(data.Id);
|
||||
prmOrganisation.NameFull = data.Name;
|
||||
prmOrganisation.RegionIdsIncluded.Add(data.RegionIdPrimary);
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
|
||||
if (AccountMgr.GetOrganisationCount(prmOrganisation) > 0)
|
||||
{
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Name must be unique within region");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
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 organisationTypeCode = values.GetValue(column.DataName).ToString();
|
||||
TypeCodeDesc organisationType = OrganisationTypeCodes.Find(item => item.Code.Equals(organisationTypeCode));
|
||||
if (!StringUtil.IsBlank(organisationType?.Desc ?? ""))
|
||||
value = new DataValue(organisationType.Desc);
|
||||
else
|
||||
value = new DataValue(organisationTypeCode);
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Organisation category.
|
||||
case SaxOrganisation.Column.OrganisationCategory_Desc:
|
||||
{
|
||||
String organisationCategoryCode = values.GetValue(column.DataName).ToString();
|
||||
TypeCodeDesc organisationCategory = OrganisationCategoryCodes.Find(item => item.Code.Equals(organisationCategoryCode));
|
||||
if (!StringUtil.IsBlank(organisationCategory?.Desc ?? ""))
|
||||
value = new DataValue(organisationCategory.Desc);
|
||||
else
|
||||
value = new DataValue(organisationCategoryCode);
|
||||
}
|
||||
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;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
{
|
||||
value = values.GetValue(column.DataName);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
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.Helpers;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
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)
|
||||
{
|
||||
if (!IsValidValue(data.EmailAddress, "email", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress), true))
|
||||
{
|
||||
errField.EmailAddress = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SacsDataValidationHelper.IsValidEmailAddress(data.EmailAddress))
|
||||
{
|
||||
errField.EmailAddress = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid email address");
|
||||
}
|
||||
}
|
||||
// Title.
|
||||
if (errField.Title != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Title, "Title", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName)))
|
||||
{
|
||||
errField.FirstName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Initials.
|
||||
if (errField.Initials != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Initials, "initials", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName), true))
|
||||
{
|
||||
errField.LastName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// About.
|
||||
if (errField.About != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.About, "about", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_About)))
|
||||
{
|
||||
errField.About = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Phone - main.
|
||||
if (errField.PhoneMain != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PhoneMain, "phone", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_PhoneMain)))
|
||||
{
|
||||
errField.PhoneMain = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Phone - mobile.
|
||||
if (errField.PhoneMobile != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PhoneMobile, "mobile", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_PhoneMobile)))
|
||||
{
|
||||
errField.PhoneMobile = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Gender other.
|
||||
if (errField.GenderOther != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.GenderOther, "gender", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_GenderOther)))
|
||||
{
|
||||
errField.GenderOther = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Date of birth year.
|
||||
if (errField.DateOfBirthYear != SacsHierarchyItem.ValidValue.Ignore && data.DateOfBirthYear > DateTime.Today.Year)
|
||||
{
|
||||
errField.PhoneMobile = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Date of birth year must not be in the future");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Regions.
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
}
|
||||
if (errField.RegionIdProvince != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Security.
|
||||
// Password token.
|
||||
if (errField.PasswordToken != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PasswordToken, "password token", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_PasswordToken)))
|
||||
{
|
||||
errField.PasswordToken = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
// Regions.
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore || errField.RegionIdProvince != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
List<SaxRegion.Data> regions = Internals.GetRegions(new List<SysId>() { data.RegionIdCountry, data.RegionIdProvince });
|
||||
SaxRegion.Data regionCountry = regions.Find(item => item.Id.Equals(data.RegionIdCountry));
|
||||
SaxRegion.Data regionProvince = regions.Find(item => item.Id.Equals(data.RegionIdProvince));
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.RegionIdCountry) && regionCountry == null)
|
||||
return SetErrorState("Invalid country specified");
|
||||
}
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.RegionIdCountry) && regionCountry == null)
|
||||
return SetErrorState("Invalid country specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
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, CultureInfo cultureInfo = null)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserAccount.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
case SaxUserAccount.Column.DateOfBirth:
|
||||
{
|
||||
byte dobDay = (byte)values.GetValue(GetUserAccountColumnDfn(SaxUserAccount.Column.DateOfBirthDay).DataName).AsLong();
|
||||
byte dobMonth = (byte)values.GetValue(GetUserAccountColumnDfn(SaxUserAccount.Column.DateOfBirthMonth).DataName).AsLong();
|
||||
short dobYear = (short)values.GetValue(GetUserAccountColumnDfn(SaxUserAccount.Column.DateOfBirthYear).DataName).AsLong();
|
||||
List<String> dobParts = new List<string>();
|
||||
if (dobYear > 0)
|
||||
{
|
||||
if (dobMonth > 0)
|
||||
{
|
||||
if (dobDay > 0)
|
||||
dobParts.Add(dobDay.ToString());
|
||||
// Format date with month to extract name.
|
||||
DateTime monthDate = new DateTime(DateTime.Today.Year, dobMonth, 1);
|
||||
dobParts.Add(DateUtil.Format(monthDate, "MMM", cultureInfo));
|
||||
}
|
||||
dobParts.Add(dobYear.ToString());
|
||||
}
|
||||
value = new DataValue(dobParts.Concat("-"));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// 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,139 @@
|
||||
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 Config
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public List<SaxUserConfig> GetConfigsForUser(SysId userAccountId)
|
||||
{
|
||||
SaxUserConfig.Params prmUserConfig = new SaxUserConfig.Params();
|
||||
prmUserConfig.UserAccountIdsIncluded.Add(userAccountId);
|
||||
List<SaxUserConfig> userConfigs = AccountMgr.GetUserConfigList(prmUserConfig);
|
||||
return userConfigs;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserConfig CreateUserConfig(SysId userAccountId, Sax.UserConfigType configType);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserConfigExists(SysId userAccountId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId)) return false;
|
||||
SaxUserConfig.Params prmUserConfig = new SaxUserConfig.Params();
|
||||
prmUserConfig.UserAccountIdsIncluded.Add(userAccountId);
|
||||
return GetUserConfigCount(prmUserConfig) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserConfig GetUserConfig(SaxUserConfig.Params prmUserConfig);
|
||||
public SaxUserConfig GetUserConfig(SysId userAccountId, Sax.UserConfigType configType)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId) || configType <= 0) return null;
|
||||
SaxUserConfig.Params prmUserConfig = new SaxUserConfig.Params();
|
||||
prmUserConfig.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserConfig.ConfigType = configType;
|
||||
return GetUserConfig(prmUserConfig);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserConfig(SaxUserConfig userConfig)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userConfig == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserConfigData(userConfig.GetData(), new SaxUserConfig.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserConfigData(SaxUserConfig.Data data, SaxUserConfig.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");
|
||||
}
|
||||
|
||||
// Config Type.
|
||||
if (errField.ConfigType != SacsHierarchyItem.ValidValue.Ignore && data.ConfigType <= 0)
|
||||
{
|
||||
errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Config type must be specified");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserConfigCanBeDeleted(SaxUserConfig userConfig)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserConfigColumnDfn(SaxUserConfig.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserConfigQueryFilter(SaxUserConfig.Params prmUserConfig);
|
||||
public abstract long GetUserConfigCount(SaxUserConfig.Params prmUserConfig);
|
||||
public abstract List<SaxUserConfig> GetUserConfigList(SaxUserConfig.Params prmUserConfig);
|
||||
public abstract DbResultSet ExecuteUserConfigQuery(List<ColumnDfn> columns, SaxUserConfig.Params prmUserConfig);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUserConfigDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserConfig.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// User Display Name.
|
||||
case SaxUserConfig.Column.User_DisplayName:
|
||||
{
|
||||
String userTitle = values.GetValue(GetUserConfigColumnDfn(SaxUserConfig.Column.User_Title).DataName).ToString();
|
||||
String userFirstName = values.GetValue(GetUserConfigColumnDfn(SaxUserConfig.Column.User_FirstName).DataName).ToString();
|
||||
String userLastName = values.GetValue(GetUserConfigColumnDfn(SaxUserConfig.Column.User_LastName).DataName).ToString();
|
||||
value = new DataValue(SaxUserAccount.GetDisplayName(userTitle, userFirstName, userLastName));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
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.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 Eligibility
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public bool UserRegionHasEligibility(SysId userAccountId, SysId regionId, DateTime validOn, SaxUserEligibility.StatusCat statusCat = SaxUserEligibility.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || !SysId.IsValid(regionId)) return false;
|
||||
SaxUserEligibility.Params prmEligibilityType = new SaxUserEligibility.Params();
|
||||
prmEligibilityType.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmEligibilityType.RegionIdsIncluded.Add(regionId);
|
||||
prmEligibilityType.ValidOn = validOn;
|
||||
prmEligibilityType.StatusCat = statusCat;
|
||||
return GetUserEligibilityCount(prmEligibilityType) > 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// Retrievethe eligibility entries for the specified user.
|
||||
/// <para>- Optional region can be supplied to restrict results.</para>
|
||||
/// <para>- Optional valid on date can be supplied to restrict results.</para>
|
||||
/// <para>- Eligibility status defaults to active.</para>
|
||||
/// </summary>
|
||||
/// <param name="userAccountId">User account</param>
|
||||
/// <param name="regionId"></param>
|
||||
/// <param name="statusCat"></param>
|
||||
/// <returns></returns>
|
||||
public List<SaxUserEligibility> GetUserEligibility(SysId userAccountId, SysId regionId = null, DateTime? validOn = null, SaxUserEligibility.StatusCat statusCat = SaxUserEligibility.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId)) return new List<SaxUserEligibility>();
|
||||
SaxUserEligibility.Params prmEligibilityType = new SaxUserEligibility.Params();
|
||||
prmEligibilityType.UserAccountIdsIncluded.Add(userAccountId);
|
||||
if (SysId.IsValid(regionId))
|
||||
prmEligibilityType.RegionIdsIncluded.Add(regionId);
|
||||
if (DateUtil.IsValid(validOn))
|
||||
prmEligibilityType.ValidOn = (DateTime)validOn;
|
||||
prmEligibilityType.StatusCat = statusCat;
|
||||
return GetUserEligibilityList(prmEligibilityType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserEligibility CreateUserEligibility(SysId userAccountId, SysId regionId, Sax.EligibilityType userEligibility);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserEligibilityExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxUserEligibility.Params prmEligibilityType = new SaxUserEligibility.Params();
|
||||
prmEligibilityType.IdsIncluded.Add(id);
|
||||
prmEligibilityType.StatusCat = SaxUserEligibility.StatusCat.Any;
|
||||
return GetUserEligibilityCount(prmEligibilityType) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserEligibility GetUserEligibility(SaxUserEligibility.Params prmEligibilityType);
|
||||
public SaxUserEligibility GetUserEligibilityById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxUserEligibility.Params prmEligibilityType = new SaxUserEligibility.Params();
|
||||
prmEligibilityType.IdsIncluded.Add(id);
|
||||
prmEligibilityType.StatusCat = SaxUserEligibility.StatusCat.Any;
|
||||
return GetUserEligibility(prmEligibilityType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserEligibility(SaxUserEligibility userEligibility)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userEligibility == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserEligibilityData(userEligibility.GetData(), new SaxUserEligibility.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserEligibilityData(SaxUserEligibility.Data data, SaxUserEligibility.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");
|
||||
}
|
||||
|
||||
// Region.
|
||||
if (errField.RegionId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionId))
|
||||
{
|
||||
errField.RegionId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Region Id must be specified");
|
||||
}
|
||||
|
||||
// Eligibility Type.
|
||||
if (errField.EligibilityType != SacsHierarchyItem.ValidValue.Ignore && (int)data.EligibilityType < 1)
|
||||
{
|
||||
errField.EligibilityType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Eligibility must be specified");
|
||||
}
|
||||
|
||||
// Info.
|
||||
if (errField.Info != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Info, "info", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserEligibility_Info)))
|
||||
{
|
||||
errField.Info = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Expires on.
|
||||
if (errField.ExpiresOn != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserEligibility_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserEligibility_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxUserEligibility.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// User & Eligibility combination must be unique.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && errField.RegionId != SacsHierarchyItem.ValidValue.Ignore && errField.EligibilityType != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.UserAccountId) && SysId.IsValid(data.RegionId) && data.EligibilityType > 0)
|
||||
{
|
||||
SaxUserEligibility.Params prmEligibilityType = new SaxUserEligibility.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmEligibilityType.IdsExcluded.Add(data.Id);
|
||||
prmEligibilityType.UserAccountIdsIncluded.Add(data.UserAccountId);
|
||||
prmEligibilityType.RegionIdsIncluded.Add(data.RegionId);
|
||||
prmEligibilityType.EligibilityTypesIncluded.Add(data.EligibilityType);
|
||||
prmEligibilityType.StatusCat = SaxUserEligibility.StatusCat.Any;
|
||||
if (GetUserEligibilityCount(prmEligibilityType) > 0)
|
||||
{
|
||||
errField.EligibilityType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Eligibility must be unique for user, region and type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserEligibility(SaxUserEligibility userEligibility, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserEligibility(SaxUserEligibility userEligibility, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserEligibilityCanBeDeleted(SaxUserEligibility userEligibility)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserEligibility(SaxUserEligibility userEligibility, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserEligibilityColumnDfn(SaxUserEligibility.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserEligibilityQueryFilter(SaxUserEligibility.Params prmEligibilityType);
|
||||
public abstract long GetUserEligibilityCount(SaxUserEligibility.Params prmEligibilityType);
|
||||
public abstract List<SaxUserEligibility> GetUserEligibilityList(SaxUserEligibility.Params prmEligibilityType);
|
||||
public abstract DbResultSet ExecuteUserEligibilityQuery(List<ColumnDfn> columns, SaxUserEligibility.Params prmEligibilityType);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUserEligibilityDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserEligibility.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Eligibility Type.
|
||||
case SaxUserEligibility.Column.EligibilityType_Desc:
|
||||
{
|
||||
Sax.EligibilityType eligibilityType = (Sax.EligibilityType)values.GetValue(column.DataName).AsLong();
|
||||
value = new DataValue(EligibilityTypeCodes.GetDescForType(eligibilityType));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Region Type.
|
||||
case SaxUserEligibility.Column.Region_Type_Desc:
|
||||
{
|
||||
Sax.RegionType regionType = (Sax.RegionType)values.GetValue(column.DataName).AsLong();
|
||||
value = new DataValue(RegionTypeCodes.GetDescForType(regionType));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxUserEligibility.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxUserEligibility.Column.Status_Desc:
|
||||
case SaxUserEligibility.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxUserEligibility.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxUserEligibility.Column.Status_Ind)
|
||||
value = new DataValue(SaxUserEligibility.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
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.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 Online
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public abstract bool CommitUsersOnline(IEnumerable <SaxUserOnline.DataProperties> usersOnline);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserOnline CreateUserOnline(SysId userAccountId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserOnlineExistsByUserAccountId(SysId userAccountId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId)) return false;
|
||||
SaxUserOnline.Params prmUserOnline = new SaxUserOnline.Params();
|
||||
prmUserOnline.UserAccountIdsIncluded.Add(userAccountId);
|
||||
return GetUserOnlineCount(prmUserOnline) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserOnline GetUserOnline(SaxUserOnline.Params prmUserOnline);
|
||||
public SaxUserOnline GetUserOnlineByUserAccountId(SysId userAccountId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId)) return null;
|
||||
SaxUserOnline.Params prmUserOnline = new SaxUserOnline.Params();
|
||||
prmUserOnline.UserAccountIdsIncluded.Add(userAccountId);
|
||||
return GetUserOnline(prmUserOnline);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserOnline(SaxUserOnline userRole)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userRole == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserOnlineData(userRole.GetData(), new SaxUserOnline.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserOnlineData(SaxUserOnline.Data data, SaxUserOnline.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");
|
||||
}
|
||||
// Online at.
|
||||
if (errField.OnlineAt != SacsHierarchyItem.ValidValue.Ignore && !DateUtil.IsValid(data.OnlineAt))
|
||||
{
|
||||
errField.OnlineAt = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("last online time must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserOnline(SaxUserOnline userRole, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserOnline(SaxUserOnline userRole, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserOnlineCanBeDeleted(SaxUserOnline userRole)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserOnline(SaxUserOnline userRole, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserOnlineColumnDfn(SaxUserOnline.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserOnlineQueryFilter(SaxUserOnline.Params prmUserOnline);
|
||||
public abstract long GetUserOnlineCount(SaxUserOnline.Params prmUserOnline);
|
||||
public abstract List<SaxUserOnline> GetUserOnlineList(SaxUserOnline.Params prmUserOnline);
|
||||
public abstract DbResultSet ExecuteUserOnlineQuery(List<ColumnDfn> columns, SaxUserOnline.Params prmUserOnline);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUserOnlineDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserOnline.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
case SaxUserOnline.Column.DisplayName:
|
||||
String title = values.GetValue(GetUserOnlineColumnDfn(SaxUserOnline.Column.Title).DataName).ToString();
|
||||
String firstName = values.GetValue(GetUserOnlineColumnDfn(SaxUserOnline.Column.FirstName).DataName).ToString();
|
||||
String lastName = values.GetValue(GetUserOnlineColumnDfn(SaxUserOnline.Column.LastName).DataName).ToString();
|
||||
value = new DataValue(SaxUserAccount.GetDisplayName(title, firstName, lastName));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
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.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 Organisation
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
/// <summary>
|
||||
/// Is the user a member of the organisation - excluding relationships which just indicate an 'interest'.
|
||||
/// </summary>
|
||||
public bool UserIsOrganisationMember(SysId userAccountId, SysId organisationId, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || !SysId.IsValid(organisationId)) return false;
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
|
||||
prmUserOrganisation.OrganisationMembersOnly = true;
|
||||
prmUserOrganisation.StatusCat = statusCat;
|
||||
return GetUserOrganisationCount(prmUserOrganisation) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does the user have the specified role with the organisation.
|
||||
/// </summary>
|
||||
public bool UserHasOrganisationRole(SysId userAccountId, SysId organisationId, Sax.OrganisationRole organisationRole, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
return UserHasAnyOrganisationRole(userAccountId, organisationId, new [] { organisationRole }, statusCat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does the user have any of the specified roles with the organisation.
|
||||
/// </summary>
|
||||
public bool UserHasAnyOrganisationRole(SysId userAccountId, SysId organisationId, IEnumerable<Sax.OrganisationRole> organisationRoles, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || !SysId.IsValid(organisationId) || organisationRoles.IsEmpty() || !organisationRoles.Any(item => item > 0)) return false;
|
||||
return GetOrganisationRolesForUser(userAccountId, organisationId, statusCat).Any(item => organisationRoles.Contains(item));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the roles that a user has with the organisation.
|
||||
/// </summary>
|
||||
public List<Sax.OrganisationRole> GetOrganisationRolesForUser(SysId userAccountId, SysId organisationId, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
List<Sax.OrganisationRole> organisationRoles = new List<Sax.OrganisationRole>();
|
||||
if (!SysId.IsValid(userAccountId) || !SysId.IsValid(organisationId)) return organisationRoles;
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
|
||||
prmUserOrganisation.StatusCat = statusCat;
|
||||
using (SaxUserOrganisation userOrganisation = GetUserOrganisation(prmUserOrganisation))
|
||||
if (userOrganisation != null)
|
||||
organisationRoles = userOrganisation.GetOrganisationRoles().ToList();
|
||||
return organisationRoles;
|
||||
}
|
||||
|
||||
public class OrganisationIdName
|
||||
{
|
||||
public SysId Id { get; internal set; }
|
||||
public String Name { get; internal set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of organisation Ids and names that the user has the specified role with.
|
||||
/// </summary>
|
||||
public List<OrganisationIdName> GetOrganisationsForUserRole(SysId userAccountId, Sax.OrganisationRole organisationRole, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
return GetOrganisationsForAnyUserRole(userAccountId, new [] { organisationRole }, statusCat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of organisation Ids and names that the user has any of the specified roles with.
|
||||
/// </summary>
|
||||
public List<OrganisationIdName> GetOrganisationsForAnyUserRole(SysId userAccountId, IEnumerable<Sax.OrganisationRole> organisationRoles, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || organisationRoles.IsEmpty() || !organisationRoles.Any(item => item > 0)) return null;
|
||||
// Filter.
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly;
|
||||
prmUserOrganisation.OrganisationMembersOnly = true;
|
||||
prmUserOrganisation.OrganisationRolesAny.UnionWith(organisationRoles);
|
||||
prmUserOrganisation.StatusCat = statusCat;
|
||||
return GetOrganisations(prmUserOrganisation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of organisation Ids and names that matc the specified parameters.
|
||||
/// </summary>
|
||||
public List<OrganisationIdName> GetOrganisations(SaxUserOrganisation.Params prmUserOrganisation)
|
||||
{
|
||||
List<OrganisationIdName> organisationsData = new List<OrganisationIdName>();
|
||||
// Columns.
|
||||
ColumnDfn colOrganisationId = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
|
||||
ColumnDfn colOrganisationName = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
|
||||
if (prmUserOrganisation.SortColumns.IsEmpty())
|
||||
prmUserOrganisation.SortColumns.Add(colOrganisationName);
|
||||
// Query.
|
||||
using (DbResultSet resultSet = ExecuteUserOrganisationQuery(new List<ColumnDfn>() { colOrganisationId, colOrganisationName }, prmUserOrganisation))
|
||||
{
|
||||
while (resultSet != null && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
SysId organisationId = new SysId(values.GetLong(colOrganisationId.DataName));
|
||||
String organisationName = values.GetString(colOrganisationName.DataName);
|
||||
if (SysId.IsValid(organisationId) && !StringUtil.IsEmpty(organisationName))
|
||||
{
|
||||
OrganisationIdName organisationData = new OrganisationIdName()
|
||||
{
|
||||
Id = organisationId,
|
||||
Name = organisationName
|
||||
};
|
||||
organisationsData.Add(organisationData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return organisationsData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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);
|
||||
}
|
||||
public SaxUserOrganisation GetUserOrganisationByUserOrganisation(SysId userAccountId, SysId organisationId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId) || !SysId.IsValid(organisationId)) return null;
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
|
||||
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");
|
||||
}
|
||||
|
||||
// Admin comment.
|
||||
if (errField.AdminComment != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.AdminComment, "comment", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserOrganisation_AdminComment)))
|
||||
{
|
||||
errField.AdminComment = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserOrganisation_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// 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;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
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.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");
|
||||
}
|
||||
|
||||
// Login - Admin application for System users.
|
||||
if (errField.LastLogin != SacsHierarchyItem.ValidValue.Ignore && DateUtil.IsValid(data.LastLoginAt))
|
||||
{
|
||||
if (data.UserRole != Sax.UserRole.SystemAdmin)
|
||||
{
|
||||
errField.LastLogin = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Last Login can only be set for System Admin role");
|
||||
}
|
||||
}
|
||||
if (errField.LastInvalidLogin != SacsHierarchyItem.ValidValue.Ignore && DateUtil.IsValid(data.LastInvalidLoginAt))
|
||||
{
|
||||
if (data.UserRole != Sax.UserRole.SystemAdmin)
|
||||
{
|
||||
errField.LastLogin = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Last Invalid Login can only be set for System Admin role");
|
||||
}
|
||||
}
|
||||
if (errField.InvalidLoginCount != SacsHierarchyItem.ValidValue.Ignore && data.InvalidLoginCount > 0)
|
||||
{
|
||||
if (data.UserRole != Sax.UserRole.SystemAdmin)
|
||||
{
|
||||
errField.LastLogin = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid Login Count can only be set for System Admin role");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserRole_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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(UserRoleCodes.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;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
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 Session
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserSession CreateUserSession(SysId userAccountId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserSessionExists(SysId userAccountId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId)) return false;
|
||||
SaxUserSession.Params prmUserSession = new SaxUserSession.Params();
|
||||
prmUserSession.UserAccountIdsIncluded.Add(userAccountId);
|
||||
return GetUserSessionCount(prmUserSession) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserSession GetUserSession(SaxUserSession.Params prmUserSession);
|
||||
public SaxUserSession GetUserSession(SysId userAccountId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId)) return null;
|
||||
SaxUserSession.Params prmUserSession = new SaxUserSession.Params();
|
||||
prmUserSession.UserAccountIdsIncluded.Add(userAccountId);
|
||||
return GetUserSession(prmUserSession);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserSession(SaxUserSession userSession)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userSession == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserSessionData(userSession.GetData(), new SaxUserSession.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserSessionData(SaxUserSession.Data data, SaxUserSession.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");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserSessionCanBeDeleted(SaxUserSession userSession)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserSessionColumnDfn(SaxUserSession.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserSessionQueryFilter(SaxUserSession.Params prmUserSession);
|
||||
public abstract long GetUserSessionCount(SaxUserSession.Params prmUserSession);
|
||||
public abstract List<SaxUserSession> GetUserSessionList(SaxUserSession.Params prmUserSession);
|
||||
public abstract DbResultSet ExecuteUserSessionQuery(List<ColumnDfn> columns, SaxUserSession.Params prmUserSession);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUserSessionDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserSession.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// User Display Name.
|
||||
case SaxUserSession.Column.User_DisplayName:
|
||||
{
|
||||
String userTitle = values.GetValue(GetUserSessionColumnDfn(SaxUserSession.Column.User_Title).DataName).ToString();
|
||||
String userFirstName = values.GetValue(GetUserSessionColumnDfn(SaxUserSession.Column.User_FirstName).DataName).ToString();
|
||||
String userLastName = values.GetValue(GetUserSessionColumnDfn(SaxUserSession.Column.User_LastName).DataName).ToString();
|
||||
value = new DataValue(SaxUserAccount.GetDisplayName(userTitle, userFirstName, userLastName));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
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 Sport
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public bool UserHasSport(SysId userAccountId, SysId sportId, SaxUserSport.StatusCat statusCat = SaxUserSport.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || !SysId.IsValid(sportId)) return false;
|
||||
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
|
||||
prmUserSport.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserSport.SportIdsIncluded.Add(sportId);
|
||||
prmUserSport.StatusCat = statusCat;
|
||||
return GetUserSportCount(prmUserSport) > 0;
|
||||
}
|
||||
public List<SaxUserSport> GetSportsForUser(SysId userAccountId, SaxUserSport.StatusCat statusCat = SaxUserSport.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId)) return new List<SaxUserSport>();
|
||||
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
|
||||
prmUserSport.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserSport.StatusCat = statusCat;
|
||||
return GetUserSportList(prmUserSport);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserSport CreateUserSport(SysId userAccountId, SysId sportId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserSportExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
|
||||
prmUserSport.IdsIncluded.Add(id);
|
||||
prmUserSport.StatusCat = SaxUserSport.StatusCat.Any;
|
||||
return GetUserSportCount(prmUserSport) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserSport GetUserSport(SaxUserSport.Params prmUserSport);
|
||||
public SaxUserSport GetUserSportById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
|
||||
prmUserSport.IdsIncluded.Add(id);
|
||||
prmUserSport.StatusCat = SaxUserSport.StatusCat.Any;
|
||||
return GetUserSport(prmUserSport);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserSport(SaxUserSport userSport)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userSport == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserSportData(userSport.GetData(), new SaxUserSport.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserSportData(SaxUserSport.Data data, SaxUserSport.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");
|
||||
}
|
||||
// Sport.
|
||||
if (errField.SportId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.SportId))
|
||||
{
|
||||
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Sport must be specified");
|
||||
}
|
||||
// About.
|
||||
if (errField.About != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.About, "about", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSport_About)))
|
||||
{
|
||||
errField.About = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSport_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSport_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxUserSport.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
// User & Sport combination must be unique.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && errField.SportId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.UserAccountId) && SysId.IsValid(data.SportId))
|
||||
{
|
||||
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmUserSport.IdsExcluded.Add(data.Id);
|
||||
prmUserSport.UserAccountIdsIncluded.Add(data.UserAccountId);
|
||||
prmUserSport.SportIdsIncluded.Add(data.SportId);
|
||||
prmUserSport.StatusCat = SaxUserSport.StatusCat.Any;
|
||||
if (GetUserSportCount(prmUserSport) > 0)
|
||||
{
|
||||
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Sport must be unique for user");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// User must exist.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.UserAccountId))
|
||||
{
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(data.UserAccountId);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.NotDeleted;
|
||||
if (GetUserAccountCount(prmUserAccount) < 1)
|
||||
{
|
||||
errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid user specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sport must exist.
|
||||
if (errField.SportId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.SportId))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportId);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid sport specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserSport(SaxUserSport userSport, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserSport(SaxUserSport userSport, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserSportCanBeDeleted(SaxUserSport userSport)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserSport(SaxUserSport userSport, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserSportColumnDfn(SaxUserSport.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserSportQueryFilter(SaxUserSport.Params prmUserSport);
|
||||
public abstract long GetUserSportCount(SaxUserSport.Params prmUserSport);
|
||||
public abstract List<SaxUserSport> GetUserSportList(SaxUserSport.Params prmUserSport);
|
||||
public abstract DbResultSet ExecuteUserSportQuery(List<ColumnDfn> columns, SaxUserSport.Params prmUserSport);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUserSportDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserSport.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Sport Participating.
|
||||
case SaxUserSport.Column.SportParticipating_Code:
|
||||
case SaxUserSport.Column.SportParticipating_Desc:
|
||||
Sax.SportParticipating sportParticipating = (Sax.SportParticipating)values.GetLong(column.DataName);
|
||||
if (column.Id == (int)SaxUserSport.Column.SportParticipating_Code)
|
||||
value = new DataValue(SportParticipatingCodes.GetCodeForType(sportParticipating));
|
||||
else
|
||||
value = new DataValue(SportParticipatingCodes.GetDescForType(sportParticipating));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Sport Preparing.
|
||||
case SaxUserSport.Column.SportPreparing_Code:
|
||||
case SaxUserSport.Column.SportPreparing_Desc:
|
||||
Sax.SportPreparing sportPreparing = (Sax.SportPreparing)values.GetLong(column.DataName);
|
||||
if (column.Id == (int)SaxUserSport.Column.SportPreparing_Code)
|
||||
value = new DataValue(SportPreparingCodes.GetCodeForType(sportPreparing));
|
||||
else
|
||||
value = new DataValue(SportPreparingCodes.GetDescForType(sportPreparing));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Sport Officiating.
|
||||
case SaxUserSport.Column.SportOfficiating_Code:
|
||||
case SaxUserSport.Column.SportOfficiating_Desc:
|
||||
Sax.SportOfficiating sportOfficiating = (Sax.SportOfficiating)values.GetLong(column.DataName);
|
||||
if (column.Id == (int)SaxUserSport.Column.SportOfficiating_Code)
|
||||
value = new DataValue(SportOfficiatingCodes.GetCodeForType(sportOfficiating));
|
||||
else
|
||||
value = new DataValue(SportOfficiatingCodes.GetDescForType(sportOfficiating));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxUserSport.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxUserSport.Column.Status_Desc:
|
||||
case SaxUserSport.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxUserSport.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxUserSport.Column.Status_Ind)
|
||||
value = new DataValue(SaxUserSport.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
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.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 Sport Experience
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserSportExperience CreateUserSportExperience(SysId userUserId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserSportExperienceExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxUserSportExperience.Params prmUserSportExperience = new SaxUserSportExperience.Params();
|
||||
prmUserSportExperience.IdsIncluded.Add(id);
|
||||
prmUserSportExperience.StatusCat = SaxUserSportExperience.StatusCat.Any;
|
||||
return GetUserSportExperienceCount(prmUserSportExperience) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserSportExperience GetUserSportExperience(SaxUserSportExperience.Params prmUserSportExperience);
|
||||
public SaxUserSportExperience GetUserSportExperienceById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxUserSportExperience.Params prmUserSportExperience = new SaxUserSportExperience.Params();
|
||||
prmUserSportExperience.IdsIncluded.Add(id);
|
||||
prmUserSportExperience.StatusCat = SaxUserSportExperience.StatusCat.Any;
|
||||
return GetUserSportExperience(prmUserSportExperience);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserSportExperience(SaxUserSportExperience userSportExperience)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userSportExperience == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserSportExperienceData(userSportExperience.GetData(), new SaxUserSportExperience.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserSportExperienceData(SaxUserSportExperience.Data data, SaxUserSportExperience.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// User Sport.
|
||||
if (errField.UserSportId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UserSportId))
|
||||
{
|
||||
errField.UserSportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Sport Id must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Organisation name.
|
||||
if (errField.OrganisationName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.OrganisationName, "organisation name", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_OrganisationName)))
|
||||
{
|
||||
errField.OrganisationName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Summary.
|
||||
if (errField.Summary != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Summary, "summary", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_Summary)))
|
||||
{
|
||||
errField.Summary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Team.
|
||||
if (errField.Team != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Team, "team", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_Team)))
|
||||
{
|
||||
errField.Team = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// League.
|
||||
if (errField.League != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.League, "league", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_League)))
|
||||
{
|
||||
errField.League = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Speciality.
|
||||
if (errField.Speciality != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Speciality, "speciality", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_Speciality)))
|
||||
{
|
||||
errField.Speciality = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Other specialities.
|
||||
if (errField.SpecialitiesOther != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.GetSpecialitiesOther().ToList().Concat(SaxUserSportExperience.SpecialitiesOtherDelim), "other specialities", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_SpecialitiesOther)))
|
||||
{
|
||||
errField.Speciality = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Awards.
|
||||
if (errField.Awards != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Awards, "Awards", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_Awards)))
|
||||
{
|
||||
errField.Awards = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Regions.
|
||||
if (errField.RegionIdNation != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
}
|
||||
if (errField.RegionIdProvince != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSportExperience_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxUserSportExperience.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// User Sport must be valid.
|
||||
if (errField.UserSportId != SacsHierarchyItem.ValidValue.Ignore && errField.UserSportId != SacsHierarchyItem.ValidValue.Invalid)
|
||||
{
|
||||
if (SysId.IsValid(data.UserSportId))
|
||||
{
|
||||
if (!UserSportExistsById(data.UserSportId))
|
||||
{
|
||||
errField.UserSportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Sport does not exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Regions.
|
||||
if (errField.RegionIdNation != SacsHierarchyItem.ValidValue.Ignore && errField.RegionIdNation != SacsHierarchyItem.ValidValue.Invalid && SysId.IsValid(data.RegionIdNation))
|
||||
{
|
||||
if (!ReferenceMgr.RegionExistsById(data.RegionIdNation))
|
||||
{
|
||||
errField.RegionIdNation = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid 'Nation' region");
|
||||
}
|
||||
}
|
||||
if (errField.RegionIdProvince != SacsHierarchyItem.ValidValue.Ignore && errField.RegionIdProvince != SacsHierarchyItem.ValidValue.Invalid && SysId.IsValid(data.RegionIdProvince))
|
||||
{
|
||||
if (!ReferenceMgr.RegionExistsById(data.RegionIdProvince))
|
||||
{
|
||||
errField.RegionIdProvince = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid 'Province' region");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserSportExperience(SaxUserSportExperience userSportExperience, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserSportExperience(SaxUserSportExperience userSportExperience, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserSportExperienceCanBeDeleted(SaxUserSportExperience userSportExperience)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserSportExperience(SaxUserSportExperience userSportExperience, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserSportExperienceColumnDfn(SaxUserSportExperience.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserSportExperienceQueryFilter(SaxUserSportExperience.Params prmUserSportExperience);
|
||||
public abstract long GetUserSportExperienceCount(SaxUserSportExperience.Params prmUserSportExperience);
|
||||
public abstract List<SaxUserSportExperience> GetUserSportExperienceList(SaxUserSportExperience.Params prmUserSportExperience);
|
||||
public abstract DbResultSet ExecuteUserSportExperienceQuery(List<ColumnDfn> columns, SaxUserSportExperience.Params prmUserSportExperience);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUserSportExperienceDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserSportExperience.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Organisation name.
|
||||
case SaxUserSportExperience.Column.Organisation_Name:
|
||||
{
|
||||
String organisationName = values.GetString(column.DataName).TrimAll();
|
||||
if (StringUtil.IsEmpty(organisationName))
|
||||
organisationName = values.GetString(GetUserSportExperienceColumnDfn(SaxUserSportExperience.Column.OrganisationName).DataName).TrimAll();
|
||||
value = new DataValue(organisationName);
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxUserSportExperience.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxUserSportExperience.Column.Status_Desc:
|
||||
case SaxUserSportExperience.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxUserSportExperience.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxUserSportExperience.Column.Status_Ind)
|
||||
value = new DataValue(SaxUserSportExperience.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
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.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 - Activity Index
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public Boolean IsValidItemForFeedback(ItemId itemId)
|
||||
{
|
||||
if (!ItemId.IsValid(itemId))
|
||||
return false;
|
||||
if (!SaxActivityFeedback.ValidItemTypes.Contains((Sax.DataItemType)itemId.Type))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public SaxActivityFeedback GetActivityFeedbackForItem(ItemId itemId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!ItemId.IsValid(itemId))
|
||||
return null;
|
||||
SaxActivityFeedback.Params prmActivityFeedback = new SaxActivityFeedback.Params();
|
||||
prmActivityFeedback.ItemIdsIncluded.Add(itemId);
|
||||
return GetActivityFeedback(prmActivityFeedback);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public Boolean UpdateActivityFeedback(ItemId itemId, int viewCountIncrement, int feedbackCountIncrement, int feedbackTotalIncrement, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!ItemId.IsValid(itemId))
|
||||
return SetErrorState("Unable to update activity feedback - Item Id must be supplied");
|
||||
if (viewCountIncrement == 0 && feedbackCountIncrement == 0 && feedbackTotalIncrement == 0)
|
||||
return true;
|
||||
if (DebugMode)
|
||||
SaLogger.Info($"{SysUtil.Fn} View count incr: {viewCountIncrement}. Feedback count incr: {feedbackCountIncrement}. Feedback total incr: {feedbackTotalIncrement}.");
|
||||
using (DisposableCollection<IDisposable> disposableItems = new DisposableCollection<IDisposable>())
|
||||
{
|
||||
bool activityFeedbackCreated = false;
|
||||
SaxActivityFeedback activityFeedback = GetActivityFeedbackForItem(itemId);
|
||||
if (activityFeedback == null)
|
||||
{
|
||||
activityFeedback = CreateActivityFeedback(itemId);
|
||||
activityFeedbackCreated = true;
|
||||
}
|
||||
disposableItems.Add(activityFeedback);
|
||||
// Update properties.
|
||||
activityFeedback.ViewCount = Math.Max(0, activityFeedback.ViewCount + viewCountIncrement);
|
||||
activityFeedback.FeedbackCount = Math.Max(0, activityFeedback.FeedbackCount + feedbackCountIncrement);
|
||||
activityFeedback.FeedbackTotal = Math.Max(0, activityFeedback.FeedbackTotal + feedbackTotalIncrement);
|
||||
activityFeedback.FeedbackAverage = activityFeedback.FeedbackCount > 0 ? (decimal)activityFeedback.FeedbackTotal / activityFeedback.FeedbackCount : 0;
|
||||
// Store feedback.
|
||||
if (activityFeedbackCreated)
|
||||
InsertActivityFeedback(activityFeedback, dbUpdateInfo);
|
||||
else
|
||||
UpdateActivityFeedback(activityFeedback, dbUpdateInfo);
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxActivityFeedback CreateActivityFeedback(ItemId itemId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxActivityFeedback GetActivityFeedback(SaxActivityFeedback.Params prmActivityFeedback);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidActivityFeedback(SaxActivityFeedback activityIndex)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (activityIndex == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidActivityFeedbackData(activityIndex.GetData(), new SaxActivityFeedback.ErrField());
|
||||
}
|
||||
public virtual bool IsValidActivityFeedbackData(SaxActivityFeedback.Data data, SaxActivityFeedback.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Item Id.
|
||||
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!ItemId.IsValid(data.ItemId))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("item id must be specified");
|
||||
}
|
||||
if (!IsValidItemForFeedback(data.ItemId))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid item type specified");
|
||||
}
|
||||
}
|
||||
// View Count.
|
||||
if (errField.ViewCount != SacsHierarchyItem.ValidValue.Ignore && data.ViewCount < 0)
|
||||
{
|
||||
errField.ViewCount = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("View count must not be negative");
|
||||
}
|
||||
// Feedback Count.
|
||||
if (errField.FeedbackCount != SacsHierarchyItem.ValidValue.Ignore && data.FeedbackCount < 0)
|
||||
{
|
||||
errField.FeedbackCount = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Feedback count must not be negative");
|
||||
}
|
||||
// Feedback Total.
|
||||
if (errField.FeedbackTotal != SacsHierarchyItem.ValidValue.Ignore && data.FeedbackTotal < 0)
|
||||
{
|
||||
errField.FeedbackTotal = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Feedback count must not be negative");
|
||||
}
|
||||
// Feedback Average.
|
||||
if (errField.FeedbackAverage != SacsHierarchyItem.ValidValue.Ignore && data.FeedbackAverage < 0)
|
||||
{
|
||||
errField.FeedbackAverage = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Feedback count must not be negative");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ActivityFeedback database interface.
|
||||
public abstract bool InsertActivityFeedback(SaxActivityFeedback activityIndex, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateActivityFeedback(SaxActivityFeedback activityIndex, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool ActivityFeedbackCanBeDeleted(SaxActivityFeedback activityIndex)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteActivityFeedback(SaxActivityFeedback activityIndex, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ActivityFeedback list:
|
||||
public abstract ColumnDfn GetActivityFeedbackColumnDfn(SaxActivityFeedback.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetActivityFeedbackQueryFilter(SaxActivityFeedback.Params prmActivityFeedback);
|
||||
public abstract long GetActivityFeedbackCount(SaxActivityFeedback.Params prmActivityFeedback);
|
||||
public abstract List<SaxActivityFeedback> GetActivityFeedbackList(SaxActivityFeedback.Params prmActivityFeedback);
|
||||
public abstract DbResultSet ExecuteActivityFeedbackQuery(List<ColumnDfn> columns, SaxActivityFeedback.Params prmActivityFeedback);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetActivityFeedbackDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxActivityFeedback.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Data item type.
|
||||
case SaxActivityFeedback.Column.ItemType_Code:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetCodeForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
case SaxActivityFeedback.Column.ItemType_Desc:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetDescForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
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.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 - Activity Index
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public Boolean IsValidItemForIndex(ItemId itemId)
|
||||
{
|
||||
if (!ItemId.IsValid(itemId))
|
||||
return false;
|
||||
if (!SaxActivityFeedback.ValidItemTypes.Contains((Sax.DataItemType)itemId.Type))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public List<SaxActivityIndex> GetActivityIndexListForItem(ItemId itemId)
|
||||
{
|
||||
ClearErrorState();
|
||||
List<SaxActivityIndex> activityIndexEntries = new List<SaxActivityIndex>();
|
||||
if (!IsValidItemForIndex(itemId)) return activityIndexEntries;
|
||||
SaxActivityIndex.Params prmActivityIndex = new SaxActivityIndex.Params();
|
||||
prmActivityIndex.ItemIdsIncluded.Add(itemId);
|
||||
return GetActivityIndexList(prmActivityIndex);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxActivityIndex CreateActivityIndex(ItemId itemId, SysId sportId, SysId regionId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxActivityIndex GetActivityIndex(SaxActivityIndex.Params prmActivityIndex);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidActivityIndex(SaxActivityIndex activityIndex)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (activityIndex == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidActivityIndexData(activityIndex.GetData(), new SaxActivityIndex.ErrField());
|
||||
}
|
||||
public virtual bool IsValidActivityIndexData(SaxActivityIndex.Data data, SaxActivityIndex.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Item Id.
|
||||
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!ItemId.IsValid(data.ItemId))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("item id must be specified");
|
||||
}
|
||||
if (!IsValidItemForIndex(data.ItemId))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid item type specified");
|
||||
}
|
||||
}
|
||||
// Sport.
|
||||
if (errField.SportId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.SportId))
|
||||
{
|
||||
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Sport must be specified");
|
||||
}
|
||||
// Region.
|
||||
if (errField.RegionId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionId))
|
||||
{
|
||||
errField.RegionId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Region must be specified");
|
||||
}
|
||||
// Effective date.
|
||||
if (errField.EffectiveOn != SacsHierarchyItem.ValidValue.Ignore && !DateUtil.IsValid(data.EffectiveOn))
|
||||
{
|
||||
errField.EffectiveOn = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Effective date must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ActivityIndex_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ActivityIndex_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxActivityIndex.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
// NB Associated data items shouldn't need to be validated as these should be valid on the 'parent' object.
|
||||
if (errField.OrganisationIdOwner != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.OrganisationIdOwner))
|
||||
{
|
||||
}
|
||||
|
||||
if (errField.OrganisationIdOwner != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.OrganisationIdOwner))
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ActivityIndex database interface.
|
||||
public abstract bool InsertActivityIndex(SaxActivityIndex activityIndex, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateActivityIndex(SaxActivityIndex activityIndex, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool ActivityIndexCanBeDeleted(SaxActivityIndex activityIndex)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteActivityIndex(SaxActivityIndex activityIndex, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ActivityIndex list:
|
||||
public abstract ColumnDfn GetActivityIndexColumnDfn(SaxActivityIndex.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetActivityIndexQueryFilter(SaxActivityIndex.Params prmActivityIndex);
|
||||
public abstract long GetActivityIndexCount(SaxActivityIndex.Params prmActivityIndex);
|
||||
public abstract List<SaxActivityIndex> GetActivityIndexList(SaxActivityIndex.Params prmActivityIndex);
|
||||
public abstract DbResultSet ExecuteActivityIndexQuery(List<ColumnDfn> columns, SaxActivityIndex.Params prmActivityIndex);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetActivityIndexDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxActivityIndex.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Data item type.
|
||||
case SaxActivityIndex.Column.ItemType_Code:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetCodeForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
case SaxActivityIndex.Column.ItemType_Desc:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetDescForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxActivityIndex.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxActivityIndex.Column.Status_Desc:
|
||||
case SaxActivityIndex.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxActivityIndex.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxActivityIndex.Column.Status_Ind)
|
||||
value = new DataValue(SaxActivityIndex.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
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 - Article
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxArticle CreateArticle(SysId userAccountIdAuthor, SysId organisationId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool ArticleExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxArticle.Params prmArticle = new SaxArticle.Params();
|
||||
prmArticle.IdsIncluded.Add(id);
|
||||
prmArticle.StatusCat = SaxArticle.StatusCat.Any;
|
||||
return GetArticleCount(prmArticle) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxArticle GetArticle(SaxArticle.Params prmArticle);
|
||||
public SaxArticle GetArticleById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxArticle.Params prmArticle = new SaxArticle.Params();
|
||||
prmArticle.IdsIncluded.Add(id);
|
||||
prmArticle.StatusCat = SaxArticle.StatusCat.Any;
|
||||
return GetArticle(prmArticle);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidArticle(SaxArticle article)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (article == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidArticleData(article.GetData(), new SaxArticle.ErrField());
|
||||
}
|
||||
public virtual bool IsValidArticleData(SaxArticle.Data data, SaxArticle.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// User Account - Author.
|
||||
if (errField.UserAccountIdAuthor != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UserAccountIdAuthor))
|
||||
{
|
||||
errField.UserAccountIdAuthor = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Author 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");
|
||||
}
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Region must be specified");
|
||||
}
|
||||
|
||||
// Headline.
|
||||
if (errField.Headline != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Headline, "headline", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Article_Headline), true))
|
||||
{
|
||||
errField.Headline = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Summary.
|
||||
if (errField.Summary != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Summary, "summary", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Article_Summary), true))
|
||||
{
|
||||
errField.Summary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Article_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Article_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxArticle.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// User Account - Author.
|
||||
if (errField.UserAccountIdAuthor != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.UserAccountIdAuthor))
|
||||
{
|
||||
if (SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
// Validate user.
|
||||
if (!AccountMgr.UserAccountExistsById(data.UserAccountIdAuthor))
|
||||
{
|
||||
errField.UserAccountIdAuthor = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid Author specified");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Organisation not specified - user must be a journalist.
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(data.UserAccountIdAuthor);
|
||||
prmUserAccount.ActiveRoles.Add(App.Sax.UserRole.Journalist);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.NotDeleted;
|
||||
if (AccountMgr.GetUserAccountCount(prmUserAccount) < 1)
|
||||
{
|
||||
errField.UserAccountIdAuthor = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User must be active Journalist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Organisation.
|
||||
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
// Validate organisation.
|
||||
if (!AccountMgr.OrganisationExistsById(data.OrganisationId))
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid Organisation specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportIdPrimary);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// 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.NotDeleted;
|
||||
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Article database interface.
|
||||
public abstract bool InsertArticle(SaxArticle article, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateArticle(SaxArticle article, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool ArticleCanBeDeleted(SaxArticle article)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteArticle(SaxArticle article, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Article list:
|
||||
public abstract ColumnDfn GetArticleColumnDfn(SaxArticle.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetArticleQueryFilter(SaxArticle.Params prmArticle);
|
||||
public abstract long GetArticleCount(SaxArticle.Params prmArticle);
|
||||
public abstract List<SaxArticle> GetArticleList(SaxArticle.Params prmArticle);
|
||||
public abstract DbResultSet ExecuteArticleQuery(List<ColumnDfn> columns, SaxArticle.Params prmArticle);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetArticleDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxArticle.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Author display name.
|
||||
case SaxArticle.Column.Author_DisplayName:
|
||||
{
|
||||
String userTitle = values.GetValue(GetArticleColumnDfn(SaxArticle.Column.Author_Title).DataName).ToString();
|
||||
String userFirstName = values.GetValue(GetArticleColumnDfn(SaxArticle.Column.Author_FirstName).DataName).ToString();
|
||||
String userLastName = values.GetValue(GetArticleColumnDfn(SaxArticle.Column.Author_LastName).DataName).ToString();
|
||||
value = new DataValue(SaxUserAccount.GetDisplayName(userTitle, userFirstName, userLastName));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Summary - limit to 200 chars.
|
||||
case SaxArticle.Column.Summary:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxArticle.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxArticle.Column.Status_Desc:
|
||||
case SaxArticle.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxArticle.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxArticle.Column.Status_Ind)
|
||||
value = new DataValue(SaxArticle.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
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 - Organisation Event
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxOrganisationEvent CreateOrganisationEvent(SysId organisationId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool OrganisationEventExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxOrganisationEvent.Params prmOrganisationEvent = new SaxOrganisationEvent.Params();
|
||||
prmOrganisationEvent.IdsIncluded.Add(id);
|
||||
prmOrganisationEvent.StatusCat = SaxOrganisationEvent.StatusCat.Any;
|
||||
return GetOrganisationEventCount(prmOrganisationEvent) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxOrganisationEvent GetOrganisationEvent(SaxOrganisationEvent.Params prmOrganisationEvent);
|
||||
public SaxOrganisationEvent GetOrganisationEventById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxOrganisationEvent.Params prmOrganisationEvent = new SaxOrganisationEvent.Params();
|
||||
prmOrganisationEvent.IdsIncluded.Add(id);
|
||||
prmOrganisationEvent.StatusCat = SaxOrganisationEvent.StatusCat.Any;
|
||||
return GetOrganisationEvent(prmOrganisationEvent);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidOrganisationEvent(SaxOrganisationEvent organisationEvent)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (organisationEvent == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidOrganisationEventData(organisationEvent.GetData(), new SaxOrganisationEvent.ErrField());
|
||||
}
|
||||
public virtual bool IsValidOrganisationEventData(SaxOrganisationEvent.Data data, SaxOrganisationEvent.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Organisation.
|
||||
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Organisation 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");
|
||||
}
|
||||
// Country Region.
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionIdCountry))
|
||||
{
|
||||
errField.RegionIdCountry = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Country Region must be specified");
|
||||
}
|
||||
|
||||
// Event date and time.
|
||||
if (errField.EventAt != SacsHierarchyItem.ValidValue.Ignore && !DateUtil.IsValid(data.EventAt))
|
||||
{
|
||||
errField.EventType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Event data and time must be specified.");
|
||||
}
|
||||
// Event type.
|
||||
if (errField.EventType != SacsHierarchyItem.ValidValue.Ignore && data.EventType <= 0)
|
||||
{
|
||||
errField.EventType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Event type must be specified.");
|
||||
}
|
||||
// Summary.
|
||||
if (errField.Summary != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Summary, "outline", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Summary), true))
|
||||
{
|
||||
errField.Summary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Details.
|
||||
if (errField.Details != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Details, "details", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Details)))
|
||||
{
|
||||
errField.Details = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxOrganisationEvent.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Organisation.
|
||||
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.IdsIncluded.Add(data.OrganisationId);
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.NotDeleted;
|
||||
if (AccountMgr.GetOrganisationCount(prmOrganisation) < 1)
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid organisation specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportIdPrimary);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Country Region.
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdCountry))
|
||||
{
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.Add(data.RegionIdCountry);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
|
||||
{
|
||||
errField.RegionIdCountry = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// OrganisationEvent database interface.
|
||||
public abstract bool InsertOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool OrganisationEventCanBeDeleted(SaxOrganisationEvent organisationEvent)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// OrganisationEvent list:
|
||||
public abstract ColumnDfn GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetOrganisationEventQueryFilter(SaxOrganisationEvent.Params prmOrganisationEvent);
|
||||
public abstract long GetOrganisationEventCount(SaxOrganisationEvent.Params prmOrganisationEvent);
|
||||
public abstract List<SaxOrganisationEvent> GetOrganisationEventList(SaxOrganisationEvent.Params prmOrganisationEvent);
|
||||
public abstract DbResultSet ExecuteOrganisationEventQuery(List<ColumnDfn> columns, SaxOrganisationEvent.Params prmOrganisationEvent);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetOrganisationEventDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxOrganisationEvent.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Event type desc.
|
||||
case SaxOrganisationEvent.Column.EventType_Desc:
|
||||
{
|
||||
String code = values.GetValue(column.DataName).ToString();
|
||||
value = new DataValue(EventTypeCodes.GetDescForCode(code, code));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Summary - limit to 200 chars.
|
||||
case SaxOrganisationEvent.Column.Summary:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Details - limit to 200 chars.
|
||||
case SaxOrganisationEvent.Column.Details:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxOrganisationEvent.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxOrganisationEvent.Column.Status_Desc:
|
||||
case SaxOrganisationEvent.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxOrganisationEvent.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxOrganisationEvent.Column.Status_Ind)
|
||||
value = new DataValue(SaxOrganisationEvent.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
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 - Organisation Opportunity
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxOrganisationOpportunity CreateOrganisationOpportunity(SysId organisationId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool OrganisationOpportunityExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxOrganisationOpportunity.Params prmOrganisationOpportunity = new SaxOrganisationOpportunity.Params();
|
||||
prmOrganisationOpportunity.IdsIncluded.Add(id);
|
||||
prmOrganisationOpportunity.StatusCat = SaxOrganisationOpportunity.StatusCat.Any;
|
||||
return GetOrganisationOpportunityCount(prmOrganisationOpportunity) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxOrganisationOpportunity GetOrganisationOpportunity(SaxOrganisationOpportunity.Params prmOrganisationOpportunity);
|
||||
public SaxOrganisationOpportunity GetOrganisationOpportunityById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxOrganisationOpportunity.Params prmOrganisationOpportunity = new SaxOrganisationOpportunity.Params();
|
||||
prmOrganisationOpportunity.IdsIncluded.Add(id);
|
||||
prmOrganisationOpportunity.StatusCat = SaxOrganisationOpportunity.StatusCat.Any;
|
||||
return GetOrganisationOpportunity(prmOrganisationOpportunity);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidOrganisationOpportunity(SaxOrganisationOpportunity organisationOpportunity)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (organisationOpportunity == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidOrganisationOpportunityData(organisationOpportunity.GetData(), new SaxOrganisationOpportunity.ErrField());
|
||||
}
|
||||
public virtual bool IsValidOrganisationOpportunityData(SaxOrganisationOpportunity.Data data, SaxOrganisationOpportunity.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Organisation.
|
||||
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Organisation 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");
|
||||
}
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Region must be specified");
|
||||
}
|
||||
|
||||
// Opportunity type.
|
||||
if (errField.OpportunityType != SacsHierarchyItem.ValidValue.Ignore && data.OpportunityType <= 0)
|
||||
{
|
||||
errField.OpportunityType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Opportunity type must be specified.");
|
||||
}
|
||||
// Position.
|
||||
if (errField.Position != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Position, "position", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_Position), true))
|
||||
{
|
||||
errField.Position = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Summary.
|
||||
if (errField.Outline != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Outline, "outline", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_Outline), true))
|
||||
{
|
||||
errField.Outline = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxOrganisationOpportunity.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Organisation.
|
||||
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.IdsIncluded.Add(data.OrganisationId);
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.NotDeleted;
|
||||
if (AccountMgr.GetOrganisationCount(prmOrganisation) < 1)
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid organisation specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportIdPrimary);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// 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.NotDeleted;
|
||||
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// OrganisationOpportunity database interface.
|
||||
public abstract bool InsertOrganisationOpportunity(SaxOrganisationOpportunity organisationOpportunity, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateOrganisationOpportunity(SaxOrganisationOpportunity organisationOpportunity, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool OrganisationOpportunityCanBeDeleted(SaxOrganisationOpportunity organisationOpportunity)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteOrganisationOpportunity(SaxOrganisationOpportunity organisationOpportunity, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// OrganisationOpportunity list:
|
||||
public abstract ColumnDfn GetOrganisationOpportunityColumnDfn(SaxOrganisationOpportunity.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetOrganisationOpportunityQueryFilter(SaxOrganisationOpportunity.Params prmOrganisationOpportunity);
|
||||
public abstract long GetOrganisationOpportunityCount(SaxOrganisationOpportunity.Params prmOrganisationOpportunity);
|
||||
public abstract List<SaxOrganisationOpportunity> GetOrganisationOpportunityList(SaxOrganisationOpportunity.Params prmOrganisationOpportunity);
|
||||
public abstract DbResultSet ExecuteOrganisationOpportunityQuery(List<ColumnDfn> columns, SaxOrganisationOpportunity.Params prmOrganisationOpportunity);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetOrganisationOpportunityDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxOrganisationOpportunity.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Opportunity type desc.
|
||||
case SaxOrganisationOpportunity.Column.OpportunityType_Desc:
|
||||
{
|
||||
String code = values.GetValue(column.DataName).ToString();
|
||||
value = new DataValue(OpportunityTypeCodes.GetDescForCode(code, code));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Summary - limit to 200 chars.
|
||||
case SaxOrganisationOpportunity.Column.Outline:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxOrganisationOpportunity.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxOrganisationOpportunity.Column.Status_Desc:
|
||||
case SaxOrganisationOpportunity.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxOrganisationOpportunity.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxOrganisationOpportunity.Column.Status_Ind)
|
||||
value = new DataValue(SaxOrganisationOpportunity.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
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 - User Activity
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserActivity CreateUserActivity(SysId userAccountId, ItemId itemId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserActivity GetUserActivity(SaxUserActivity.Params prmUserActivity);
|
||||
public SaxUserActivity GetUserActivityForUserItem(SysId userAccountId, ItemId itemId)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || !ItemId.IsValid(itemId)) return null;
|
||||
SaxUserActivity.Params prmUserActivity = new SaxUserActivity.Params();
|
||||
prmUserActivity.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserActivity.ItemIdsIncluded.Add(itemId);
|
||||
prmUserActivity.StatusCat = SaxUserActivity.StatusCat.Any;
|
||||
return ActivityMgr.GetUserActivity(prmUserActivity);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserActivity(SaxUserActivity userActivity)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userActivity == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserActivityData(userActivity.GetData(), new SaxUserActivity.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserActivityData(SaxUserActivity.Data data, SaxUserActivity.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");
|
||||
}
|
||||
// Item Id.
|
||||
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore && !ItemId.IsValid(data.ItemId))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Item Id must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserActivity_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserActivity_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxUserActivity.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for existing or deleted items.
|
||||
if (!SysId.IsValid(data.Id) && !data.IsStatusDeleted)
|
||||
{
|
||||
// User must exist.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.UserAccountId))
|
||||
{
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(data.UserAccountId);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.NotDeleted;
|
||||
if (AccountMgr.GetUserAccountCount(prmUserAccount) < 1)
|
||||
{
|
||||
errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid user specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UserActivity database interface.
|
||||
public abstract bool InsertUserActivity(SaxUserActivity userActivity, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserActivity(SaxUserActivity userActivity, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserActivityCanBeDeleted(SaxUserActivity userActivity)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserActivity(SaxUserActivity userActivity, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UserActivity list:
|
||||
public abstract ColumnDfn GetUserActivityColumnDfn(SaxUserActivity.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserActivityQueryFilter(SaxUserActivity.Params prmUserActivity);
|
||||
public abstract long GetUserActivityCount(SaxUserActivity.Params prmUserActivity);
|
||||
public abstract List<SaxUserActivity> GetUserActivityList(SaxUserActivity.Params prmUserActivity);
|
||||
public abstract DbResultSet ExecuteUserActivityQuery(List<ColumnDfn> columns, SaxUserActivity.Params prmUserActivity);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUserActivityDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserActivity.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Data item type.
|
||||
case SaxUserActivity.Column.ItemType_Code:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetCodeForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
case SaxUserActivity.Column.ItemType_Desc:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetDescForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes - limit to 200 chars.
|
||||
case SaxUserActivity.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxUserActivity.Column.Status_Desc:
|
||||
case SaxUserActivity.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxUserActivity.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxUserActivity.Column.Status_Ind)
|
||||
value = new DataValue(SaxUserActivity.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
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 SaxItemDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Item Data Mgr - Item Address
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxItemAddress CreateItemAddress(ItemId itemId, Sax.AddressType addressType);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool ItemAddressExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxItemAddress.Params prmItemAddress = new SaxItemAddress.Params();
|
||||
prmItemAddress.IdsIncluded.Add(id);
|
||||
prmItemAddress.StatusCat = SaxItemAddress.StatusCat.Any;
|
||||
return GetItemAddressCount(prmItemAddress) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxItemAddress GetItemAddress(SaxItemAddress.Params prmItemAddress);
|
||||
public SaxItemAddress GetItemAddressById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxItemAddress.Params prmItemAddress = new SaxItemAddress.Params();
|
||||
prmItemAddress.IdsIncluded.Add(id);
|
||||
prmItemAddress.StatusCat = SaxItemAddress.StatusCat.Any;
|
||||
return GetItemAddress(prmItemAddress);
|
||||
}
|
||||
public SaxItemAddress GetFirstItemAddressByItemAndType(ItemId itemId, Sax.AddressType addressType = Sax.AddressType.Unknown)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!ItemId.IsValid(itemId)) return null;
|
||||
SaxItemAddress.Params prmItemAddress = new SaxItemAddress.Params();
|
||||
prmItemAddress.AddressType = addressType;
|
||||
prmItemAddress.ItemIdsIncluded.Add(itemId);
|
||||
prmItemAddress.StatusCat = SaxItemAddress.StatusCat.Any;
|
||||
List<SaxItemAddress> addresses = GetItemAddressList(prmItemAddress);
|
||||
return addresses.Count > 0 ? addresses[0] : null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidItemAddress(SaxItemAddress itemAddress)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (itemAddress == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidItemAddressData(itemAddress.GetData(), new SaxItemAddress.ErrField());
|
||||
}
|
||||
public virtual bool IsValidItemAddressData(SaxItemAddress.Data data, SaxItemAddress.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Some mandatory properties become optional if the address is deleted.
|
||||
bool deleted = data.IsStatusDeleted;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Item Id.
|
||||
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore && !ItemId.IsValid(data.ItemId))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Item Id must be specified");
|
||||
}
|
||||
// Address.
|
||||
if (errField.Caption != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Caption, "caption", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Caption)))
|
||||
{
|
||||
errField.Caption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Line1 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Line1, "line 1", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1)))
|
||||
{
|
||||
errField.Line1 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Line2 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Line2, "line 2", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2)))
|
||||
{
|
||||
errField.Line2 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Line3 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Line3, "line 3", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3)))
|
||||
{
|
||||
errField.Line3 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Town != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Town, "town", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town), !deleted))
|
||||
{
|
||||
errField.Town = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.RegionIdProvince != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionIdProvince))
|
||||
{
|
||||
// Province is not mandatory.
|
||||
}
|
||||
if (errField.Province != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Province, "province", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province)))
|
||||
{
|
||||
errField.Province = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionIdCountry))
|
||||
{
|
||||
errField.RegionIdCountry = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Country region must be specified");
|
||||
}
|
||||
if (errField.Country != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Country, "country", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Country), !deleted))
|
||||
{
|
||||
errField.Country = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.PostalCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PostalCode, "postal code", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode)))
|
||||
{
|
||||
errField.PostalCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.PhoneMain != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PhoneMain, "country", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_PhoneMain)))
|
||||
{
|
||||
errField.PhoneMain = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Location.
|
||||
if (errField.LocationSource != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.LocationSource, "location source", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_LocationSource)))
|
||||
{
|
||||
errField.LocationSource = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.LocationData != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.LocationData, "location data", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_LocationData)))
|
||||
{
|
||||
errField.LocationData = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.LocationFormattedAddress != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.LocationFormattedAddress, "location source", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_LocationFormattedAddress)))
|
||||
{
|
||||
errField.LocationFormattedAddress = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAddress_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxItemAddress.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
// Item must exists.
|
||||
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore && ItemId.IsValid(data.ItemId))
|
||||
{
|
||||
switch ((Sax.DataItemType)data.ItemId.Type)
|
||||
{
|
||||
case Sax.DataItemType.Organisation:
|
||||
if (!AccountMgr.OrganisationExistsById(data.ItemId.Id))
|
||||
return SetErrorState("Invalid organisation specified");
|
||||
break;
|
||||
default:
|
||||
return SetErrorState("Invalid Item Type specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertItemAddress(SaxItemAddress itemAddress, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateItemAddress(SaxItemAddress itemAddress, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool ItemAddressCanBeDeleted(SaxItemAddress itemAddress)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteItemAddress(SaxItemAddress itemAddress, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetItemAddressColumnDfn(SaxItemAddress.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetItemAddressQueryFilter(SaxItemAddress.Params prmItemAddress);
|
||||
public abstract long GetItemAddressCount(SaxItemAddress.Params prmItemAddress);
|
||||
public abstract List<SaxItemAddress> GetItemAddressList(SaxItemAddress.Params prmItemAddress);
|
||||
public abstract DbResultSet ExecuteItemAddressQuery(List<ColumnDfn> columns, SaxItemAddress.Params prmItemAddress);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetItemAddressDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxItemAddress.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Data item type.
|
||||
case SaxItemAddress.Column.ItemType_Code:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetCodeForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
case SaxItemAddress.Column.ItemType_Desc:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetDescForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxItemAddress.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxItemAddress.Column.Status_Desc:
|
||||
case SaxItemAddress.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxItemAddress.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxItemAddress.Column.Status_Ind)
|
||||
value = new DataValue(SaxItemAddress.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
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 SaxItemDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Item Data Mgr - Item Sport
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxItemAssociation CreateItemAssociation(ItemId itemIdFrom, ItemId itemIdTo, Sax.AssociationType associationType);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool ItemAssociationExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxItemAssociation.Params prmItemAssociation = new SaxItemAssociation.Params();
|
||||
prmItemAssociation.IdsIncluded.Add(id);
|
||||
prmItemAssociation.StatusCat = SaxItemAssociation.StatusCat.Any;
|
||||
return GetItemAssociationCount(prmItemAssociation) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxItemAssociation GetItemAssociation(SaxItemAssociation.Params prmItemAssociation);
|
||||
public SaxItemAssociation GetItemAssociationById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxItemAssociation.Params prmItemAssociation = new SaxItemAssociation.Params();
|
||||
prmItemAssociation.IdsIncluded.Add(id);
|
||||
prmItemAssociation.StatusCat = SaxItemAssociation.StatusCat.Any;
|
||||
return GetItemAssociation(prmItemAssociation);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidItemAssociation(SaxItemAssociation itemAssociation)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (itemAssociation == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidItemAssociationData(itemAssociation.GetData(), new SaxItemAssociation.ErrField());
|
||||
}
|
||||
public virtual bool IsValidItemAssociationData(SaxItemAssociation.Data data, SaxItemAssociation.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Item Id From.
|
||||
if (errField.ItemIdFrom != SacsHierarchyItem.ValidValue.Ignore && !ItemId.IsValid(data.ItemIdFrom))
|
||||
{
|
||||
errField.ItemIdFrom = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Item Id From must be specified");
|
||||
}
|
||||
// Item Id To.
|
||||
if (errField.ItemIdTo != SacsHierarchyItem.ValidValue.Ignore && !ItemId.IsValid(data.ItemIdTo))
|
||||
{
|
||||
errField.ItemIdTo = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Item Id To must be specified");
|
||||
}
|
||||
// Item Ids must differ.
|
||||
if (errField.ItemIdFrom != SacsHierarchyItem.ValidValue.Ignore && errField.ItemIdTo != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (data.ItemIdFrom.Equals(data.ItemIdTo))
|
||||
{
|
||||
errField.ItemIdTo = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Item Ids must differ");
|
||||
}
|
||||
}
|
||||
// Association type.
|
||||
if (errField.AssociationType != SacsHierarchyItem.ValidValue.Ignore && (int)data.AssociationType < 1)
|
||||
{
|
||||
errField.AssociationType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Association type must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAssociation_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemAssociation_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxItemAssociation.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertItemAssociation(SaxItemAssociation itemAssociation, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateItemAssociation(SaxItemAssociation itemAssociation, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool ItemAssociationCanBeDeleted(SaxItemAssociation itemAssociation)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteItemAssociation(SaxItemAssociation itemAssociation, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetItemAssociationColumnDfn(SaxItemAssociation.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetItemAssociationQueryFilter(SaxItemAssociation.Params prmItemAssociation);
|
||||
public abstract long GetItemAssociationCount(SaxItemAssociation.Params prmItemAssociation);
|
||||
public abstract List<SaxItemAssociation> GetItemAssociationList(SaxItemAssociation.Params prmItemAssociation);
|
||||
public abstract DbResultSet ExecuteItemAssociationQuery(List<ColumnDfn> columns, SaxItemAssociation.Params prmItemAssociation);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetItemAssociationDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxItemAssociation.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// From item type.
|
||||
case SaxItemAssociation.Column.ItemTypeFrom_Code:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetCodeForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
case SaxItemAssociation.Column.ItemTypeFrom_Desc:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetDescForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// To item type.
|
||||
case SaxItemAssociation.Column.ItemTypeTo_Code:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetCodeForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
case SaxItemAssociation.Column.ItemTypeTo_Desc:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetDescForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Association type.
|
||||
case SaxItemAssociation.Column.AssociationType_Code:
|
||||
case SaxItemAssociation.Column.AssociationType_Desc:
|
||||
{
|
||||
Sax.AssociationType associationType = (Sax.AssociationType)values.GetLong(column.DataName);
|
||||
if (column.Id == (int)SaxItemAssociation.Column.AssociationType_Code)
|
||||
value = new DataValue(AssociationTypeCodes.GetCodeForType(associationType));
|
||||
else
|
||||
value = new DataValue(AssociationTypeCodes.GetDescForType(associationType));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxItemAssociation.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxItemAssociation.Column.Status_Desc:
|
||||
case SaxItemAssociation.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxItemAssociation.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxItemAssociation.Column.Status_Ind)
|
||||
value = new DataValue(SaxItemAssociation.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
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 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 SaxItemDataMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Item Data Mgr - Item Image
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
public bool ItemHasActiveImage(ItemId itemId, Sax.ImageType imageType)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!ItemId.IsValid(itemId) || (int)imageType < 1) return false;
|
||||
SaxItemImage.Params prmItemImage = new SaxItemImage.Params();
|
||||
prmItemImage.ItemIdsIncluded.Add(itemId);
|
||||
prmItemImage.ImageTypesIncluded.Add(imageType);
|
||||
prmItemImage.StatusCat = SaxItemImage.StatusCat.ActiveOnly;
|
||||
return GetItemImageCount(prmItemImage) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxItemImage CreateItemImage(ItemId itemId, Sax.ImageType imageType);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool ItemImageExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxItemImage.Params prmItemImage = new SaxItemImage.Params();
|
||||
prmItemImage.IdsIncluded.Add(id);
|
||||
prmItemImage.StatusCat = SaxItemImage.StatusCat.Any;
|
||||
return GetItemImageCount(prmItemImage) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxItemImage GetItemImage(SaxItemImage.Params prmItemImage);
|
||||
public SaxItemImage GetItemImageById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxItemImage.Params prmItemImage = new SaxItemImage.Params();
|
||||
prmItemImage.IdsIncluded.Add(id);
|
||||
prmItemImage.StatusCat = SaxItemImage.StatusCat.Any;
|
||||
return GetItemImage(prmItemImage);
|
||||
}
|
||||
public SaxItemImage GetItemImage(ItemId itemId, Sax.ImageType imageType, SaxItemImage.StatusCat statusCat)
|
||||
{
|
||||
if (!ItemId.IsValid(itemId) || imageType <= 0) return null;
|
||||
SaxItemImage.Params prmItemImage = new SaxItemImage.Params();
|
||||
prmItemImage.ItemIdsIncluded.Add(itemId);
|
||||
prmItemImage.ImageTypesIncluded.Add(imageType);
|
||||
prmItemImage.StatusCat = statusCat;
|
||||
return GetItemImage(prmItemImage);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidItemImage(SaxItemImage itemImage)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (itemImage == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidItemImageData(itemImage.GetData(), new SaxItemImage.ErrField());
|
||||
}
|
||||
public virtual bool IsValidItemImageData(SaxItemImage.Data data, SaxItemImage.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Item Id.
|
||||
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!ItemId.IsValid(data.ItemId))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Item Id must be specified");
|
||||
}
|
||||
if (!SaxItemImage.ValidItemTypes.Contains((Sax.DataItemType)data.ItemId.Type))
|
||||
{
|
||||
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid item type specified");
|
||||
}
|
||||
}
|
||||
// Image type.
|
||||
if (errField.ImageType != SacsHierarchyItem.ValidValue.Ignore && (int)data.ImageType < 1)
|
||||
{
|
||||
errField.ImageType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Image type must be specified");
|
||||
}
|
||||
// Filename
|
||||
if (errField.Filename != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Filename, "filename", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemImage_Filename), true))
|
||||
{
|
||||
errField.Filename = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Mime
|
||||
if (errField.Mime != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Mime, "mime", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemImage_Mime), true))
|
||||
{
|
||||
errField.Mime = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Content Type
|
||||
if (errField.ContentType != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.ContentType, "content type", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemImage_ContentType), true))
|
||||
{
|
||||
errField.ContentType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Image data.
|
||||
if (errField.ImageData != SacsHierarchyItem.ValidValue.Ignore && (data.ImageData == null || data.ImageData.Length < 1))
|
||||
{
|
||||
errField.ImageData = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Image data must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemImage_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemImage_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxItemImage.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Dependencies - only tested if not deleted.
|
||||
if (data.Status != SaStatus.Deleted)
|
||||
{
|
||||
// Item must exist.
|
||||
// ...
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertItemImage(SaxItemImage itemImage, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateItemImage(SaxItemImage itemImage, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool ItemImageCanBeDeleted(SaxItemImage itemImage)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteItemImage(SaxItemImage itemImage, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetItemImageColumnDfn(SaxItemImage.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetItemImageQueryFilter(SaxItemImage.Params prmItemImage);
|
||||
public abstract long GetItemImageCount(SaxItemImage.Params prmItemImage);
|
||||
public abstract List<SaxItemImage> GetItemImageList(SaxItemImage.Params prmItemImage);
|
||||
public abstract DbResultSet ExecuteItemImageQuery(List<ColumnDfn> columns, SaxItemImage.Params prmItemImage);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetItemImageDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxItemImage.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Data item type.
|
||||
case SaxItemImage.Column.ItemType_Code:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetCodeForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
case SaxItemImage.Column.ItemType_Desc:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetDescForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxItemImage.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxItemImage.Column.Status_Desc:
|
||||
case SaxItemImage.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxItemImage.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxItemImage.Column.Status_Ind)
|
||||
value = new DataValue(SaxItemImage.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
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 SaxItemProcess CreateItemSport();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool ItemSportExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxItemProcess.Params prmItemSport = new SaxItemProcess.Params();
|
||||
prmItemSport.IdsIncluded.Add(id);
|
||||
prmItemSport.StatusCat = SaxItemProcess.StatusCat.Any;
|
||||
return GetItemSportCount(prmItemSport) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxItemProcess GetItemSport(SaxItemProcess.Params prmItemSport);
|
||||
public SaxItemProcess GetItemSportById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxItemProcess.Params prmItemSport = new SaxItemProcess.Params();
|
||||
prmItemSport.IdsIncluded.Add(id);
|
||||
prmItemSport.StatusCat = SaxItemProcess.StatusCat.Any;
|
||||
return GetItemSport(prmItemSport);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidItemSport(SaxItemProcess itemSport)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (itemSport == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidItemSportData(itemSport.GetData(), new SaxItemProcess.ErrField());
|
||||
}
|
||||
public virtual bool IsValidItemSportData(SaxItemProcess.Data data, SaxItemProcess.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("Sport must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemSport_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.ItemSport_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxItemProcess.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))
|
||||
{
|
||||
SaxItemProcess.Params prmItemSport = new SaxItemProcess.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmItemSport.IdsExcluded.Add(data.Id);
|
||||
prmItemSport.ItemIdsIncluded.Add(data.ItemId);
|
||||
prmItemSport.SportIdsIncluded.Add(data.SportId);
|
||||
prmItemSport.StatusCat = SaxItemProcess.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(SaxItemProcess itemSport, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateItemSport(SaxItemProcess itemSport, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool ItemSportCanBeDeleted(SaxItemProcess itemSport)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteItemSport(SaxItemProcess itemSport, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetItemSportColumnDfn(SaxItemProcess.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetItemSportQueryFilter(SaxItemProcess.Params prmItemSport);
|
||||
public abstract long GetItemSportCount(SaxItemProcess.Params prmItemSport);
|
||||
public abstract List<SaxItemProcess> GetItemSportList(SaxItemProcess.Params prmItemSport);
|
||||
public abstract DbResultSet ExecuteItemSportQuery(List<ColumnDfn> columns, SaxItemProcess.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 ((SaxItemProcess.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Data item type.
|
||||
case SaxItemProcess.Column.ItemType_Code:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetCodeForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
case SaxItemProcess.Column.ItemType_Desc:
|
||||
{
|
||||
value = new DataValue(DataItemTypeCodes.GetDescForType(values.GetLong(column.DataName)));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxItemProcess.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxItemProcess.Column.Status_Desc:
|
||||
case SaxItemProcess.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxItemProcess.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxItemProcess.Column.Status_Ind)
|
||||
value = new DataValue(SaxItemProcess.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
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 class DataMembers
|
||||
{
|
||||
public SaxInternals internals = null;
|
||||
public bool internalsCreatedHere = false;
|
||||
}
|
||||
private DataMembers data = new DataMembers();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxItemMgr(SaxSessionContext sessionContext, SaxInternals internals)
|
||||
{
|
||||
data.internals = internals;
|
||||
SessionContext = sessionContext;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (data.internals != null && data.internalsCreatedHere)
|
||||
data.internals.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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.
|
||||
protected SaxInternals Internals
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.internals == null)
|
||||
{
|
||||
data.internals = new SaxInternals(SessionContext);
|
||||
data.internalsCreatedHere = true;
|
||||
}
|
||||
return data.internals;
|
||||
}
|
||||
}
|
||||
// Consoles.
|
||||
public SaxDataCacheConsole DataCacheConsole { get { return Internals.DataCacheConsole; } }
|
||||
public SaxActivityConsole ActivityConsole { get { return Internals.ActivityConsole; } }
|
||||
// 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> DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } }
|
||||
public List<TypeCodeDesc> SportGroupingCodes { get { return Internals.SportGroupingCodes; } }
|
||||
public List<TypeCodeDesc> SportSpecialityLabelCodes { get { return Internals.SportSpecialityLabelCodes; } }
|
||||
public List<TypeCodeDesc> SportContactTypeCodes { get { return Internals.SportContactTypeCodes; } }
|
||||
public List<TypeCodeDesc> SportParticipatingCodes { get { return Internals.SportParticipatingCodes; } }
|
||||
public List<TypeCodeDesc> SportPreparingCodes { get { return Internals.SportPreparingCodes; } }
|
||||
public List<TypeCodeDesc> SportOfficiatingCodes { get { return Internals.SportOfficiatingCodes; } }
|
||||
public List<TypeCodeDesc> RegionTypeCodes { get { return Internals.RegionTypeCodes; } }
|
||||
public List<TypeCodeDesc> EligibilityTypeCodes { get { return Internals.EligibilityTypeCodes; } }
|
||||
public List<TypeCodeDesc> UserRoleCodes { get { return Internals.UserRoleCodes; } }
|
||||
public List<TypeCodeDesc> OrganisationTypeCodes { get { return Internals.OrganisationTypeCodes; } }
|
||||
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } }
|
||||
public List<TypeCodeDesc> OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } }
|
||||
public List<TypeCodeDesc> AssociationTypeCodes { get { return Internals.AssociationTypeCodes; } }
|
||||
public List<TypeCodeDesc> AddressTypeCodes { get { return Internals.AddressTypeCodes; } }
|
||||
public List<TypeCodeDesc> ContactMethodCodes { get { return Internals.ContactMethodCodes; } }
|
||||
public List<TypeCodeDesc> EventTypeCodes { get { return Internals.EventTypeCodes; } }
|
||||
public List<TypeCodeDesc> OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } }
|
||||
public List<TypeCodeDesc> ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
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_Core.GetColTextLen(SaxDbDfn_Core.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_Core.GetColTextLen(SaxDbDfn_Core.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_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Region_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
// ToDo Parent region.
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
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 List<SaxRegion> GetRegionListByIds(List<SysId> regionIds)
|
||||
{
|
||||
if (regionIds.IsEmpty()) return new List<SaxRegion>();
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.AddIds(regionIds);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.Any;
|
||||
return GetRegionList(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;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
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 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.IdsIncluded.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.IdsIncluded.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();
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<IDisposable> disposableItems = new DisposableCollection<IDisposable>())
|
||||
{
|
||||
|
||||
// Name.
|
||||
if (errField.Name != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Name, "name", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Sport_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.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);
|
||||
}
|
||||
}
|
||||
|
||||
// Associated data.
|
||||
if (data.Status != SaStatus.Deleted)
|
||||
{
|
||||
if (errField.SportIdParent != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdParent))
|
||||
{
|
||||
SaxSport sport = GetSportById(data.SportIdParent);
|
||||
disposableItems.Add(sport);
|
||||
if (sport == null)
|
||||
{
|
||||
errField.SportIdParent = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid parent");
|
||||
}
|
||||
if (SysId.IsValid(sport.SportIdParent))
|
||||
{
|
||||
errField.SportIdParent = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("parent already has a parent.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 List<SaxSport> GetSportListByIds(List<SysId> sportIds)
|
||||
{
|
||||
if (sportIds.IsEmpty()) return new List<SaxSport>();
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.AddIds(sportIds);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.Any;
|
||||
return GetSportList(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)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Grouping.
|
||||
case SaxSport.Column.Grouping_Desc:
|
||||
value = new DataValue(Internals.SportGroupingCodes.GetDescForType(values.GetValue(column.DataName).AsLong()));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Speciality label.
|
||||
case SaxSport.Column.SpecialityLabel_Desc:
|
||||
value = new DataValue(Internals.SportSpecialityLabelCodes.GetDescForType(values.GetValue(column.DataName).AsLong()));
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// 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;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
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.Support
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxItemMgr_Support : SaxItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxItemMgr_Support(SaxSessionContext sessionContext, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISacsDatabase SupportDatabase { get { return SaxGlobals.App.GetDatabase(SessionContext, Sax.Database.Support); } }
|
||||
public IDatabaseInfo SupportDbInfo { get { return SaxGlobals.App.CreateDbInfo(SessionContext, Sax.Database.Support); } }
|
||||
// Support.
|
||||
public List<TypeCodeDesc> UserReportTypeCodes { get { return Internals.UserReportTypeCodes; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
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.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.Bus.Support;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Support
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxSupportMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Support Mgr - User Report
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserReport CreateUserReport(SysId userAccountId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserReportExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxUserReport.Params prmUserReport = new SaxUserReport.Params();
|
||||
prmUserReport.IdsIncluded.Add(id);
|
||||
prmUserReport.StatusCat = SaxUserReport.StatusCat.Any;
|
||||
return GetUserReportCount(prmUserReport) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserReport GetUserReport(SaxUserReport.Params prmUserReport);
|
||||
public SaxUserReport GetUserReportById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxUserReport.Params prmUserReport = new SaxUserReport.Params();
|
||||
prmUserReport.IdsIncluded.Add(id);
|
||||
prmUserReport.StatusCat = SaxUserReport.StatusCat.Any;
|
||||
return GetUserReport(prmUserReport);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserReport(SaxUserReport userReport)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userReport == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserReportData(userReport.GetData(), new SaxUserReport.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserReportData(SaxUserReport.Data data, SaxUserReport.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");
|
||||
}
|
||||
// Report Type.
|
||||
if (errField.ReportType != SacsHierarchyItem.ValidValue.Ignore && (int)data.ReportType < 1)
|
||||
{
|
||||
errField.ReportType = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Report type must be specified");
|
||||
}
|
||||
// Title.
|
||||
if (errField.Title != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Title, "title", (long)SaxDbDfn_Support.GetColTextLen(SaxDbDfn_Support.ColumnIdx.UserReport_Title), true))
|
||||
{
|
||||
errField.Title = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Report.
|
||||
if (errField.Report != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Report, "report", (long)SaxDbDfn_Support.GetColTextLen(SaxDbDfn_Support.ColumnIdx.UserReport_Report)))
|
||||
{
|
||||
errField.Report = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Recorded On.
|
||||
if (errField.RecordedOn != SacsHierarchyItem.ValidValue.Ignore && !DateUtil.IsValid(data.RecordedOn))
|
||||
{
|
||||
errField.RecordedOn = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Recorded on date must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Support.GetColTextLen(SaxDbDfn_Support.ColumnIdx.UserReport_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Support.GetColTextLen(SaxDbDfn_Support.ColumnIdx.UserReport_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxUserReport.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserReportCanBeDeleted(SaxUserReport userReport)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserReportColumnDfn(SaxUserReport.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserReportQueryFilter(SaxUserReport.Params prmUserReport);
|
||||
public abstract long GetUserReportCount(SaxUserReport.Params prmUserReport);
|
||||
public abstract List<SaxUserReport> GetUserReportList(SaxUserReport.Params prmUserReport);
|
||||
public abstract DbResultSet ExecuteUserReportQuery(List<ColumnDfn> columns, SaxUserReport.Params prmUserReport);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <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 GetUserReportDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserReport.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Report Type.
|
||||
case SaxUserReport.Column.ReportType_Desc:
|
||||
{
|
||||
Sax.UserReportType userReportType = (Sax.UserReportType)values.GetValue(column.DataName).AsLong();
|
||||
value = new DataValue(UserReportTypeCodes.GetDescForType(userReportType));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxUserReport.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxUserReport.Column.Status_Desc:
|
||||
case SaxUserReport.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxUserReport.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxUserReport.Column.Status_Ind)
|
||||
value = new DataValue(SaxUserReport.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Support
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxSupportMgr : SaxItemMgr_Support
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxSupportMgr(SaxSessionContext sessionContext, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using Sarand.Net.Standard.Proc.Procs;
|
||||
using Saxonite.Net.Standard.Base.Mgr.Support;
|
||||
using Saxonite.Net.Standard.Base.Mgr;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Proc.Excel;
|
||||
using Saxonite.Net.Standard.Base.Mgr.Reference;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Procs
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxProcess_Base : SaProcess
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public new class Config : SaProcess.Config
|
||||
{
|
||||
protected Config(SaxSessionContext sessionContext, DbUpdateInfo dbUpdateInfo) : base(dbUpdateInfo)
|
||||
{
|
||||
this.SessionContext = sessionContext;
|
||||
}
|
||||
public SaxSessionContext SessionContext { get; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SaxInternals internals;
|
||||
private Config config;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxProcess_Base(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (internals != null) internals.Dispose();
|
||||
internals = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public SaxInternals Internals { get { if (internals == null) internals = new SaxInternals(config.SessionContext); return internals; } }
|
||||
// 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; } }
|
||||
public SaxReferenceGolfMgr ReferenceGolfMgr { get { return Internals.ReferenceGolfMgr; } }
|
||||
public SaxSupportMgr SupportMgr { get { return Internals.SupportMgr; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Excel Spreadsheet utilities.
|
||||
//-------------------------------------------------------------------
|
||||
protected virtual SaMsExcelColumnHeading_Config GetExcelColumnHeadingConfig()
|
||||
{
|
||||
SaMsExcelColumnHeading_Config configHeading = new SaMsExcelColumnHeading_Config();
|
||||
configHeading.FontAttr.Name = "Arial";
|
||||
configHeading.FontAttr.HeightInPoints = 10;
|
||||
configHeading.FontAttr.ColourIndex = SaXlColourIndex.DarkBlue;
|
||||
configHeading.FontAttr.Bold = true;
|
||||
configHeading.HeadingTextWrap = true;
|
||||
configHeading.ForegroundColourIndex = SaXlColourIndex.LightYellow;
|
||||
configHeading.BorderWeight = SaXlBorderWeight.Medium;
|
||||
return configHeading;
|
||||
}
|
||||
|
||||
protected virtual SaMsExcelStyleAttr GetExcelDefaultWorkbookStyle()
|
||||
{
|
||||
SaMsExcelStyleAttr styleAttr = new SaMsExcelStyleAttr();
|
||||
styleAttr.FontAttr.Name = "Arial";
|
||||
styleAttr.FontAttr.HeightInPoints = 9;
|
||||
styleAttr.FontAttr.ColourIndex = SaXlColourIndex.Black;
|
||||
styleAttr.HorizontalAlignment = (short)XlHAlign.xlHAlignLeft;
|
||||
styleAttr.VerticalAlignment = (short)XlVAlign.xlVAlignTop;
|
||||
styleAttr.WrapText = true;
|
||||
return styleAttr;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -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