From 03ea1058bef46193374dae9cf5e2a4615797d083 Mon Sep 17 00:00:00 2001 From: Andy Howard Date: Fri, 2 Jul 2021 09:28:37 +0100 Subject: [PATCH] v1.1.1.0 --- .../Base/Controllers/SaxController_Base.cs | 1 + SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs | 35 +- .../OrganisationController-Ajax.cs | 18 +- .../Admin/Models/Model_Organisation.cs | 48 +- .../Admin/Models/Model_User.cs | 2 - .../Localisation/SaxAdminProperties.resx | 12 + .../Panel-OrganisationDialog.cshtml | 10 +- .../Views/User/Panel-UserDialog.cshtml | 2 +- .../wwwroot/js/sax-organisation.js | 13 +- .../Localisation/SaxOnlineProperties.resx | 11 +- .../Controllers/ActivityController-Ajax.cs | 8 + .../Controllers/ReferenceController-Ajax.cs | 68 +- .../Online/Models/Model_Organisation.cs | 8 + .../Views/Account/Profile.cshtml | 4 +- .../Views/Common/OrganisationRequest.cshtml | 79 +++ ...ation.cshtml => OrganisationSelect.cshtml} | 8 +- ...electRegion.cshtml => RegionSelect.cshtml} | 9 +- ...{SelectSport.cshtml => SportSelect.cshtml} | 19 +- SaxoniteCoreWebOnline/Views/Home/Index.cshtml | 20 + .../Journalist/Panel-ArticleDialog.cshtml | 28 +- .../Views/Organisation/Opportunities.cshtml | 2 +- .../Panel-OpportunityDialog.cshtml | 4 +- .../Views/Shared/_Layout.cshtml | 2 +- .../wwwroot/css/sax-data.css | 2 +- .../wwwroot/css/sax-home.css | 22 +- .../wwwroot/css/sax-main.css | 7 + ...selectOrganisation.css => sax-org-sel.css} | 0 .../{sax-selectRegion.css => sax-reg-sel.css} | 0 .../{sax-selectSport.css => sax-spt-sel.css} | 0 SaxoniteCoreWebOnline/wwwroot/js/sax-home.js | 1 + .../wwwroot/js/sax-jrn-art.js | 26 +- .../wwwroot/js/sax-org-req.js | 69 ++ ...x-selectOrganisation.js => sax-org-sel.js} | 8 +- .../{sax-selectRegion.js => sax-reg-sel.js} | 16 +- .../wwwroot/js/sax-resultsPaging.js | 4 +- .../js/{sax-selectSport.js => sax-spt-sel.js} | 9 +- SaxoniteStandardBase/Base/App/Sax-Version.cs | 7 +- SaxoniteStandardBase/Base/App/Sax.cs | 13 + .../Base/App/SaxDbDfn_Core.cs | 248 ++++--- SaxoniteStandardBase/Base/App/SaxInternals.cs | 47 ++ .../Base/App/SaxSystem-Statics.cs | 10 +- SaxoniteStandardBase/Base/App/SaxSystem.cs | 2 + .../Base/Bus/SaxItemAddress.cs | 471 +++++++++++++ .../Base/Mgr/SaxAccountMgr-Organisation.cs | 29 +- .../Base/Mgr/SaxItemDataMgr-ItemAddress.cs | 259 +++++++ SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs | 1 + .../Dbas/Bus/SaxItemAddress_Dbas.cs | 33 + .../Dbas/Internal/ActivityIndex_Db.cs | 2 +- .../Dbas/Internal/ItemAddress_Db.cs | 332 +++++++++ .../Dbas/Internal/ItemImage_Db.cs | 2 +- .../Dbas/Internal/ItemSport_Db.cs | 2 +- .../Dbas/Internal/JournalistArticle_Db.cs | 2 +- .../Internal/OrganisationOpportunity_Db.cs | 2 +- .../Dbas/Internal/Organisation_Db.cs | 2 +- .../Dbas/Internal/Region_Db.cs | 2 +- .../Dbas/Internal/Sport_Db.cs | 2 +- .../Dbas/Internal/UserAccount_Db.cs | 2 +- .../Dbas/Internal/UserActivity_Db.cs | 2 +- .../Dbas/Internal/UserOrganisation_Db.cs | 2 +- .../Dbas/Internal/UserRole_Db.cs | 2 +- .../Dbas/Internal/UserSession_Db.cs | 2 +- .../Dbas/Internal/UserSport_Db.cs | 2 +- .../Mgr/SaxItemDataMgr_Dbas-ItemAddress.cs | 598 +++++++++++++++++ .../Resources/Database/SaxDbDfn_Core.xml | 635 +++++++++++++++++- 64 files changed, 3038 insertions(+), 250 deletions(-) create mode 100644 SaxoniteCoreWebOnline/Views/Common/OrganisationRequest.cshtml rename SaxoniteCoreWebOnline/Views/Common/{SelectOrganisation.cshtml => OrganisationSelect.cshtml} (84%) rename SaxoniteCoreWebOnline/Views/Common/{SelectRegion.cshtml => RegionSelect.cshtml} (85%) rename SaxoniteCoreWebOnline/Views/Common/{SelectSport.cshtml => SportSelect.cshtml} (77%) rename SaxoniteCoreWebOnline/wwwroot/css/{sax-selectOrganisation.css => sax-org-sel.css} (100%) rename SaxoniteCoreWebOnline/wwwroot/css/{sax-selectRegion.css => sax-reg-sel.css} (100%) rename SaxoniteCoreWebOnline/wwwroot/css/{sax-selectSport.css => sax-spt-sel.css} (100%) create mode 100644 SaxoniteCoreWebOnline/wwwroot/js/sax-org-req.js rename SaxoniteCoreWebOnline/wwwroot/js/{sax-selectOrganisation.js => sax-org-sel.js} (94%) rename SaxoniteCoreWebOnline/wwwroot/js/{sax-selectRegion.js => sax-reg-sel.js} (87%) rename SaxoniteCoreWebOnline/wwwroot/js/{sax-selectSport.js => sax-spt-sel.js} (94%) create mode 100644 SaxoniteStandardBase/Base/Bus/SaxItemAddress.cs create mode 100644 SaxoniteStandardBase/Base/Mgr/SaxItemDataMgr-ItemAddress.cs create mode 100644 SaxoniteStandardDbas/Dbas/Bus/SaxItemAddress_Dbas.cs create mode 100644 SaxoniteStandardDbas/Dbas/Internal/ItemAddress_Db.cs create mode 100644 SaxoniteStandardDbas/Dbas/Mgr/SaxItemDataMgr_Dbas-ItemAddress.cs diff --git a/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs b/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs index b13d82f..84f4e49 100644 --- a/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs +++ b/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs @@ -98,6 +98,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers public List OrganisationTypeCodes { get { return Internals.OrganisationTypeCodes; } } public List OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } } public List OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } } + public List AddressTypeCodes { get { return Internals.AddressTypeCodes; } } public List OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } } public List ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } } // Email. diff --git a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs index cab652f..674d03b 100644 --- a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs +++ b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs @@ -7,6 +7,7 @@ using Sarand.Net.Standard.Base.Utils; using Saxonite.Base.App; using Saxonite.Net.Core.Web.Base.App; using Saxonite.Net.Standard.Base.App; +using Saxonite.Net.Standard.Base.Bus; using Saxonite.Net.Standard.Base.Consoles; using Saxonite.Net.Standard.Base.Mgr; using System; @@ -43,6 +44,14 @@ namespace Saxonite.Net.Core.Web.Base.Models public bool DebugMode { get { return SaxSystem.DebugMode; } } public SaxLocaliser Localiser { get; } + //------------------------------------------------------------------- + // Page configuration. + public bool OK { get { return !HasMessages(); } } + public virtual bool ProhibitCache { get; set; } = true; + public String PageCaption { get; set; } + public String InstanceVersion { get { return !StringUtil.IsEmpty(App.SessionConfig.Instance) ? App.SessionConfig.Instance + " v" + Sax.Version.GetFullVersion() : "v" + Sax.Version.GetAppVersion(); } } + public bool IncludeGoogleAnalytics { get; set; } = false; + //------------------------------------------------------------------- // Business components. protected SaxInternals Internals { get { if (internals == null) internals = new SaxInternals(SessionContext); return internals; } } @@ -63,16 +72,30 @@ namespace Saxonite.Net.Core.Web.Base.Models public List OrganisationTypeCodes { get { return Internals.OrganisationTypeCodes; } } public List OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } } public List OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } } + public List AddressTypeCodes { get { return Internals.AddressTypeCodes; } } public List OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } } public List ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } } //------------------------------------------------------------------- - // Page configuration. - public bool OK { get { return !HasMessages(); } } - public virtual bool ProhibitCache { get; set; } = true; - public String PageCaption { get; set; } - public String InstanceVersion { get { return !StringUtil.IsEmpty(App.SessionConfig.Instance) ? App.SessionConfig.Instance + " v" + Sax.Version.GetFullVersion() : "v" + Sax.Version.GetAppVersion(); } } - public bool IncludeGoogleAnalytics { get; set; } = false; + // Common data components. + // User Accounts. + public SaxUserAccount GetUserAccount(SysId userAccountId) + { + return Internals.GetUserAccount(userAccountId); + } + public String GetUserAccountDisplayName(SysId userAccountId) + { + return Internals.GetUserAccountDisplayName(userAccountId); + } + // User Accounts. + public SaxOrganisation GetOrganisation(SysId organisationId) + { + return Internals.GetOrganisation(organisationId); + } + public String GetOrganisationName(SysId organisationId) + { + return Internals.GetOrganisationName(organisationId); + } //------------------------------------------------------------------- // Security. diff --git a/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController-Ajax.cs b/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController-Ajax.cs index 226cac3..00c5dc6 100644 --- a/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController-Ajax.cs +++ b/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController-Ajax.cs @@ -33,9 +33,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers // Sport. public long SportId { get; set; } public String SportName { get; set; } - // Region. - public long RegionId { get; set; } - public String RegionName { get; set; } + // Region - country. + public long RegionIdCountry { get; set; } + public String RegionNameCountry { get; set; } // Common properties. public String StatusCode { get; set; } public String StatusDesc { get; set; } @@ -57,9 +57,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers using (SaxSport sport = ReferenceMgr.GetSportById(organisation.SportIdPrimary)) data.SportName = sport?.Name ?? ""; // Region. - data.RegionId = SysId.ToLong(organisation.RegionIdPrimary); + data.RegionIdCountry = SysId.ToLong(organisation.RegionIdPrimary); using (SaxRegion region = ReferenceMgr.GetRegionById(organisation.RegionIdPrimary)) - data.RegionName = region?.Name ?? ""; + data.RegionNameCountry = region?.Name ?? ""; // Common properties. data.StatusCode = organisation.StatusCode; data.StatusDesc = organisation.StatusDesc; @@ -154,8 +154,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers MemberCount = StringUtil.ToLong(values.GetString(colMemberCount.DataName)), SportId = values.GetLong(colSportId.DataName), SportName = values.GetString(colSportName.DataName), - RegionId = values.GetLong(colRegionId.DataName), - RegionName = values.GetString(colRegionName.DataName), + RegionIdCountry = values.GetLong(colRegionId.DataName), + RegionNameCountry = values.GetString(colRegionName.DataName), StatusCode = values.GetString(colStatus.DataName), StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)) }; @@ -257,8 +257,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers organisation.OrganisationCategory = model.OrganisationCategory; if (model.OrganisationSportId != null) organisation.SportIdPrimary = model.OrganisationSportId.ToSysId(); - if (model.OrganisationRegionId != null) - organisation.RegionIdPrimary = model.OrganisationRegionId.ToSysId(); + if (model.OrganisationRegionIdCountry != null) + organisation.RegionIdPrimary = model.OrganisationRegionIdCountry.ToSysId(); // Common properties. if (model.OrganisationStatusCode != null) organisation.Status = model.OrganisationStatus; diff --git a/SaxoniteCoreWebAdmin/Admin/Models/Model_Organisation.cs b/SaxoniteCoreWebAdmin/Admin/Models/Model_Organisation.cs index 258d487..53cf98c 100644 --- a/SaxoniteCoreWebAdmin/Admin/Models/Model_Organisation.cs +++ b/SaxoniteCoreWebAdmin/Admin/Models/Model_Organisation.cs @@ -53,12 +53,20 @@ namespace Saxonite.Net.Core.Web.Admin.Models public String OrganisationCategoryValue { get; set; } public Sax.OrganisationCategory OrganisationCategory { get { return (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(OrganisationCategoryValue); } } public String OrganisationSportId { get; set; } - public String OrganisationRegionId { get; set; } + public String OrganisationRegionIdCountry { get; set; } // Common properties. public String OrganisationNotes { get; set; } public String OrganisationStatusCode { get; set; } public SaStatus OrganisationStatus { get { return SacsSystem.GetStatusForCode(OrganisationStatusCode); } } + // Utilities. + public bool IsSportMandatory() + { + if (OrganisationCategory == Sax.OrganisationCategory.Club) return true; + if (OrganisationCategory == Sax.OrganisationCategory.Association) return true; + return false; + } + //------------------------------------------------------------------- // Validation. //------------------------------------------------------------------- @@ -89,6 +97,44 @@ namespace Saxonite.Net.Core.Web.Admin.Models responseData.SetControlError(nameof(OrganisationCategoryValue), Localiser["msg.validation.mandatory.value"]); } + // Organisation sport. + if (OrganisationSportId != null) + { + if (SysId.IsValid(OrganisationSportId.ToSysId()) || IsSportMandatory()) + { + using (SaxSport sport = ReferenceMgr.GetSportById(OrganisationSportId.ToSysId())) + { + if (sport == null) + responseData.SetControlError(nameof(OrganisationSportId), Localiser["msg.validation.invalid.value"]); + } + } + } + + // Organisation country. + if (OrganisationRegionIdCountry != null) + { + using (SaxRegion region = ReferenceMgr.GetRegionById(OrganisationRegionIdCountry.ToSysId())) + { + if (region == null) + responseData.SetControlError(nameof(OrganisationRegionIdCountry), Localiser["msg.validation.invalid.value"]); + else if (region.RegionType != Sax.RegionType.Country) + responseData.SetControlError(nameof(OrganisationRegionIdCountry), "Organisation region must be a country"); + } + + if (!StringUtil.IsEmpty(OrganisationName)) + { + // Name must be unqiue within region. + SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params(); + if (SysId.IsValid(OrganisationId.ToSysId())) + prmOrganisation.IdsExcluded.Add(OrganisationId.ToSysId()); + prmOrganisation.NameFull = OrganisationName; + prmOrganisation.RegionIdsIncluded.Add(OrganisationRegionIdCountry.ToSysId()); + prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any; + if (AccountMgr.GetOrganisationCount(prmOrganisation) > 0) + responseData.SetControlError(nameof(OrganisationName), Localiser["msg.validation.duplicate.value"]); + } + } + // Organisation status. if (OrganisationStatusCode != null) { diff --git a/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs b/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs index e30bfaa..9dda3ca 100644 --- a/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs +++ b/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs @@ -90,8 +90,6 @@ namespace Saxonite.Net.Core.Web.Admin.Models // User title. if (UserTitle != null) { - if (StringUtil.IsEmpty(UserTitle)) - responseData.SetControlError(nameof(UserTitle), Localiser["msg.validation.mandatory.value"]); } // User first name. diff --git a/SaxoniteCoreWebAdmin/Localisation/SaxAdminProperties.resx b/SaxoniteCoreWebAdmin/Localisation/SaxAdminProperties.resx index fbcd31f..15d4e61 100644 --- a/SaxoniteCoreWebAdmin/Localisation/SaxAdminProperties.resx +++ b/SaxoniteCoreWebAdmin/Localisation/SaxAdminProperties.resx @@ -165,6 +165,12 @@ Columns + + Country + + + County + Create @@ -231,6 +237,9 @@ No + + Not specified + OK @@ -252,6 +261,9 @@ Previous + + Province + Reference diff --git a/SaxoniteCoreWebAdmin/Views/Organisation/Panel-OrganisationDialog.cshtml b/SaxoniteCoreWebAdmin/Views/Organisation/Panel-OrganisationDialog.cshtml index e8b85aa..f289db3 100644 --- a/SaxoniteCoreWebAdmin/Views/Organisation/Panel-OrganisationDialog.cshtml +++ b/SaxoniteCoreWebAdmin/Views/Organisation/Panel-OrganisationDialog.cshtml @@ -56,7 +56,7 @@ @* Organisation sport *@
- +
@Html.HiddenFor(model => model.OrganisationSportId, new { @id = "ifOrganisationSportId", @class = "OrganisationSportId" }) @@ -67,13 +67,13 @@
@* Organisation region *@ -
+
- +
- @Html.HiddenFor(model => model.OrganisationRegionId, new { @id = "ifOrganisationRegionId", @class = "OrganisationRegionId" }) -
+ @Html.HiddenFor(model => model.OrganisationRegionIdCountry, new { @id = "ifOrganisationRegionIdCountry", @class = "OrganisationRegionIdCountry" }) +
diff --git a/SaxoniteCoreWebAdmin/Views/User/Panel-UserDialog.cshtml b/SaxoniteCoreWebAdmin/Views/User/Panel-UserDialog.cshtml index 89969a1..0380544 100644 --- a/SaxoniteCoreWebAdmin/Views/User/Panel-UserDialog.cshtml +++ b/SaxoniteCoreWebAdmin/Views/User/Panel-UserDialog.cshtml @@ -36,7 +36,7 @@
- @Html.DropDownListFor(model => model.UserTitle, Model.TitlesForSelect, Localiser["label.select"], new { @id = "cbUserTitle", @class = "UserTitle sax-select" }) + @Html.DropDownListFor(model => model.UserTitle, Model.TitlesForSelect, Localiser["label.not.specified"], new { @id = "cbUserTitle", @class = "UserTitle sax-select" })
diff --git a/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js b/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js index 5fb02e6..82b9733 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js +++ b/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js @@ -89,6 +89,7 @@ let $frm = sax.$frm.organisation; $('.OrganisationSportId', $frm).val(rgn.id); $('.OrganisationSportCaption', $frm).val(rgn.name); + sax.clearControlError($('.OrganisationSportCaption', $frm)); } //-------------------------------------------------------------- @@ -115,15 +116,16 @@ { //sax.debug('onRegionSelected', rgn); let $frm = sax.$frm.organisation; - $('.OrganisationRegionId', $frm).val(rgn.id); - $('.OrganisationRegionCaption', $frm).val(rgn.name); + $('.OrganisationRegionIdCountry', $frm).val(rgn.id); + $('.OrganisationRegionCaptionCountry', $frm).val(rgn.name); + sax.clearControlError($('.OrganisationRegionCaptionCountry', $frm)); } //-------------------------------------------------------------- sax.createItem = function () { let $frm = sax.$frm.organisation; - $('.OrganisationId,.OrganisationSportId,.OrganisationRegionId,input[type="text"],textarea,select', $frm).val(''); + $('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdCountry,input[type="text"],textarea,select', $frm).val(''); $('.OrganisationStatus', $frm).val(sax.data.defaultStatusCode); sax.clearControlErrors(); sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.createOrganisation); @@ -154,8 +156,8 @@ $('.OrganisationCategory', $frm).val(item.categoryCode); $('.OrganisationSportId', $frm).val(item.sportId); $('.OrganisationSportCaption', $frm).val(item.sportName); - $('.OrganisationRegionId', $frm).val(item.regionId); - $('.OrganisationRegionCaption', $frm).val(item.regionName); + $('.OrganisationRegionIdCountry', $frm).val(item.regionIdCountry); + $('.OrganisationRegionCaptionCountry', $frm).val(item.regionNameCountry); $('.OrganisationStatus', $frm).val(item.statusCode); sax.clearControlErrors(); sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation); @@ -206,6 +208,7 @@ $('.sax-panel-filter .sax-action.sax-item-create').on('click', function () { sax.createItem(); }); $('.sax-panel-filter .sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); }); $('.sax-input').on('input', function () { sax.clearControlError(this); }); + $('.sax-select').on('change', function () { sax.clearControlError(this); }); sax.$frm.filter = $('#frmOrganisationFilter'); $('.FilterOrganisation', sax.$frm.filter).on('input', function () { sax.refreshResults(250); }); diff --git a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx index 81ced20..0e5de54 100644 --- a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx +++ b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx @@ -198,7 +198,7 @@ Article - + Calendar @@ -462,12 +462,15 @@ Update Opportunity + + Request Organisation + + + Select Organisation + Organisations - - Select Organisation - Privacy diff --git a/SaxoniteCoreWebOnline/Online/Controllers/ActivityController-Ajax.cs b/SaxoniteCoreWebOnline/Online/Controllers/ActivityController-Ajax.cs index 768545f..4f1bd86 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/ActivityController-Ajax.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/ActivityController-Ajax.cs @@ -37,6 +37,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers public short ItemType { get; set; } public String ItemTypeClass { get; set; } public long ItemIdx { get; set; } + public String Organisation { get; set; } + public String Author { get; set; } public String Caption { get; set; } public String Blurb { get; set; } public String Sport { get; set; } @@ -49,6 +51,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers { public ActivityResponseData_Article(SaxController_Online controller, SaxModel_Online model, SaxJournalistArticle article) { + Author = model.GetUserAccountDisplayName(article.UserAccountIdJournalist); Headline = article.Headline; Summary = article.Summary; Sport = model.GetSportCaption(article.SportIdPrimary); @@ -58,6 +61,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers foreach (SaxJournalistArticle.ContentData.SegmentData segment in content.Segments) Content.Segments.Add(new ContentData.SegmentData(controller, segment)); } + public String Organisation { get; set; } + public String Author { get; set; } public String Headline { get; set; } public String Summary { get; set; } public String Sport { get; set; } @@ -100,12 +105,15 @@ namespace Saxonite.Net.Core.Web.Online.Controllers { public ActivityResponseData_Opportunity(SaxModel_Online model, SaxOrganisationOpportunity opportunity) { + Organisation = model.GetOrganisationName(opportunity.OrganisationId); Position = opportunity.Position; Outline = opportunity.Outline; Sport = model.GetSportCaption(opportunity.SportIdPrimary); Region = model.GetRegionCaption(opportunity.RegionIdPrimary); PublishedOnFmt = model.Localiser.FormatDate(opportunity.PublishedAt); } + public String Organisation { get; set; } + public String Author { get; set; } public String Position { get; set; } public String Outline { get; set; } public String Sport { get; set; } diff --git a/SaxoniteCoreWebOnline/Online/Controllers/ReferenceController-Ajax.cs b/SaxoniteCoreWebOnline/Online/Controllers/ReferenceController-Ajax.cs index 2064921..41a7a8c 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/ReferenceController-Ajax.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/ReferenceController-Ajax.cs @@ -26,38 +26,6 @@ namespace Saxonite.Net.Core.Web.Online.Controllers base(localiser, logger) {} - //------------------------------------------------------------------- - // Regions - //------------------------------------------------------------------- - private class AjaxResponse_RegionList : AjaxResponse_Base - { - public List Regions { get; } = new List(); - } - //------------------------------------------------------------------- - [HttpPost] - [Route("Reference/Ajax/GetRegions")] - public IActionResult Ajax_GetRegionList(Model_Reference model) - { - String fn = GetType().Name + ".Ajax_GetRegionList"; - String messageTitle = Localiser["reference.caption.regions"]; - AjaxResponse_RegionList responseData = new AjaxResponse_RegionList(); - - // Validate session and referrer. - if (!ValidReferer) - return Forbid(); - if (!ValidUserSession) - return GetAjaxResult_InvalidSession(responseData); - - // Populate regions. - foreach (SaxModel_Online.RegionData regionData in model.GetRegionDataList_Active()) - responseData.Regions.Add(regionData); - - // Complete response. - responseData.Success = true; - - return Json(responseData); - } - //------------------------------------------------------------------- // Sports //------------------------------------------------------------------- @@ -77,8 +45,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers // Validate session and referrer. if (!ValidReferer) return Forbid(); - if (!ValidUserSession) - return GetAjaxResult_InvalidSession(responseData); + // User doesn't have to be logged in, eg. to register organisation. + //if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); // Populate sports. foreach (SaxModel_Online.SportData sportData in model.GetSportDataList_Active()) @@ -90,6 +58,38 @@ namespace Saxonite.Net.Core.Web.Online.Controllers return Json(responseData); } + //------------------------------------------------------------------- + // Regions + //------------------------------------------------------------------- + private class AjaxResponse_RegionList : AjaxResponse_Base + { + public List Regions { get; } = new List(); + } + //------------------------------------------------------------------- + [HttpPost] + [Route("Reference/Ajax/GetRegions")] + public IActionResult Ajax_GetRegionList(Model_Reference model) + { + String fn = GetType().Name + ".Ajax_GetRegionList"; + String messageTitle = Localiser["reference.caption.regions"]; + AjaxResponse_RegionList responseData = new AjaxResponse_RegionList(); + + // Validate session and referrer. + if (!ValidReferer) + return Forbid(); + // User doesn't have to be logged in, eg. to register organisation. + //if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + + // Populate regions. + foreach (SaxModel_Online.RegionData regionData in model.GetRegionDataList_Active()) + responseData.Regions.Add(regionData); + + // Complete response. + responseData.Success = true; + + return Json(responseData); + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaxoniteCoreWebOnline/Online/Models/Model_Organisation.cs b/SaxoniteCoreWebOnline/Online/Models/Model_Organisation.cs index 335dfa0..b4258ab 100644 --- a/SaxoniteCoreWebOnline/Online/Models/Model_Organisation.cs +++ b/SaxoniteCoreWebOnline/Online/Models/Model_Organisation.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Utils; using Saxonite.Base.App; using Saxonite.Net.Core.Web.Base.App; using Saxonite.Net.Core.Web.Base.Controllers; +using Saxonite.Net.Standard.Base.App; using Saxonite.Net.Standard.Base.Bus; using System; using System.Collections.Generic; @@ -37,6 +38,13 @@ namespace Saxonite.Net.Core.Web.Online.Models //------------------------------------------------------------------- // Organisation properties. + public String OrganisationName { get; set; } + public String OrganisationTypeValue { get; set; } + public Sax.OrganisationType OrganisationType { get { return (Sax.OrganisationType)OrganisationTypeCodes.GetTypeForCode(OrganisationTypeValue); } } + public String OrganisationCategoryValue { get; set; } + public Sax.OrganisationCategory OrganisationCategory { get { return (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(OrganisationCategoryValue); } } + public String OrganisationSportId { get; set; } + public String OrganisationRegionId { get; set; } //------------------------------------------------------------------- // Validation. diff --git a/SaxoniteCoreWebOnline/Views/Account/Profile.cshtml b/SaxoniteCoreWebOnline/Views/Account/Profile.cshtml index a8f9909..4830148 100644 --- a/SaxoniteCoreWebOnline/Views/Account/Profile.cshtml +++ b/SaxoniteCoreWebOnline/Views/Account/Profile.cshtml @@ -34,7 +34,7 @@ sax.dlg.title.selectRegion = '@Localiser.GetJavascriptText("reference.caption.region.select")'; sax.dlg.title.selectSport = '@Localiser.GetJavascriptText("reference.caption.sport.select")'; - - + +
diff --git a/SaxoniteCoreWebOnline/Views/Common/OrganisationRequest.cshtml b/SaxoniteCoreWebOnline/Views/Common/OrganisationRequest.cshtml new file mode 100644 index 0000000..0bb88f8 --- /dev/null +++ b/SaxoniteCoreWebOnline/Views/Common/OrganisationRequest.cshtml @@ -0,0 +1,79 @@ +@model SaxModel_Online +@inject SaxLocaliser Localiser + + + +
+ + @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmOrganisationRequest", @class = "sax-form", @onSubmit = "return false;" })) + { + + @* Organisation name *@ +
+
+ +
+
+ +
+
+
+ + @* Organisation type *@ +
+
+ +
+
+ @Html.DropDownList("", Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "cbOrganisationType", @name = "OrganisationTypeValue", @class = "OrganisationType sax-select" }) +
+
+
+ + @* Organisation category *@ +
+
+ +
+
+ @Html.DropDownList("", Model.OrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "cbOrganisationCategory", @name = "OrganisationCategoryValue", @class = "OrganisationCategory sax-select" }) +
+
+
+ + @* Organisation sport *@ +
+
+ +
+
+ +
+
+
+
+
+ + @* Organisation region *@ +
+
+ +
+
+ +
+
+
+
+
+ + } + +
+ + + + diff --git a/SaxoniteCoreWebOnline/Views/Common/SelectOrganisation.cshtml b/SaxoniteCoreWebOnline/Views/Common/OrganisationSelect.cshtml similarity index 84% rename from SaxoniteCoreWebOnline/Views/Common/SelectOrganisation.cshtml rename to SaxoniteCoreWebOnline/Views/Common/OrganisationSelect.cshtml index 40ac921..51b6b48 100644 --- a/SaxoniteCoreWebOnline/Views/Common/SelectOrganisation.cshtml +++ b/SaxoniteCoreWebOnline/Views/Common/OrganisationSelect.cshtml @@ -1,10 +1,10 @@ @model SaxModel_Online @inject SaxLocaliser Localiser - - +
@@ -44,3 +44,5 @@
+ + diff --git a/SaxoniteCoreWebOnline/Views/Common/SelectRegion.cshtml b/SaxoniteCoreWebOnline/Views/Common/RegionSelect.cshtml similarity index 85% rename from SaxoniteCoreWebOnline/Views/Common/SelectRegion.cshtml rename to SaxoniteCoreWebOnline/Views/Common/RegionSelect.cshtml index ebbb577..836b0d7 100644 --- a/SaxoniteCoreWebOnline/Views/Common/SelectRegion.cshtml +++ b/SaxoniteCoreWebOnline/Views/Common/RegionSelect.cshtml @@ -1,7 +1,10 @@ @model SaxModel_Online @inject SaxLocaliser Localiser - + +
@@ -44,6 +47,6 @@
- - + + diff --git a/SaxoniteCoreWebOnline/Views/Common/SelectSport.cshtml b/SaxoniteCoreWebOnline/Views/Common/SportSelect.cshtml similarity index 77% rename from SaxoniteCoreWebOnline/Views/Common/SelectSport.cshtml rename to SaxoniteCoreWebOnline/Views/Common/SportSelect.cshtml index 07c7418..ed4794d 100644 --- a/SaxoniteCoreWebOnline/Views/Common/SelectSport.cshtml +++ b/SaxoniteCoreWebOnline/Views/Common/SportSelect.cshtml @@ -1,7 +1,10 @@ @model SaxModel_Online @inject SaxLocaliser Localiser - + +
@@ -38,12 +41,12 @@
-
-
-
-
+
+
+
- - -
+ +
+ + diff --git a/SaxoniteCoreWebOnline/Views/Home/Index.cshtml b/SaxoniteCoreWebOnline/Views/Home/Index.cshtml index 8ab23bc..73b2dd1 100644 --- a/SaxoniteCoreWebOnline/Views/Home/Index.cshtml +++ b/SaxoniteCoreWebOnline/Views/Home/Index.cshtml @@ -6,12 +6,30 @@ @if (Model.AwaitingLogin) { + @* No user session *@

@Localiser["home.caption.welcome"]

+
+ + @* Register Organisation *@ + @if (false) + { +
+
+
Do you belong to a club or association that would benefit from participating on this platform?
+
Sign-up now with a few details and we'll let you know when you can login and get going.
+
Register Your Organisation
+
+
+ + } } else { + @* User logged in *@ + + @* Activity filter *@
@Localiser["home.caption.activities"]
@@ -29,6 +47,7 @@ else
+ @* Activities *@
@@ -79,6 +98,7 @@ else
+
diff --git a/SaxoniteCoreWebOnline/Views/Journalist/Panel-ArticleDialog.cshtml b/SaxoniteCoreWebOnline/Views/Journalist/Panel-ArticleDialog.cshtml index c8859ee..e903d9f 100644 --- a/SaxoniteCoreWebOnline/Views/Journalist/Panel-ArticleDialog.cshtml +++ b/SaxoniteCoreWebOnline/Views/Journalist/Panel-ArticleDialog.cshtml @@ -74,21 +74,21 @@
@* Publication *@ -
-
- -
-
-
-
@Html.CheckBoxFor(model => model.ArticlePublish, new { @id = "chkArticlePublish", @class = "ArticlePublish" }) @Localiser["label.publish"]
-
@Html.TextBoxFor(model => model.ArticlePublishOn, new { @id = "ifArticlePublishOn", @class = "sax-input sax-calendar ArticlePublishOn", @readonly = "readonly" })
+
+
+
- -
-
@@ -164,7 +164,7 @@ sax.msg.uploadFileTypeInvalid = '@Localiser.GetJavascriptText("msg.upload.file.type.invalid","{0}")'; sax.msg.uploadingFile = '@Localiser.GetJavascriptText("msg.upload.file.uploading","{0}")'; - - + +
diff --git a/SaxoniteCoreWebOnline/Views/Organisation/Opportunities.cshtml b/SaxoniteCoreWebOnline/Views/Organisation/Opportunities.cshtml index a45ed63..3128b2d 100644 --- a/SaxoniteCoreWebOnline/Views/Organisation/Opportunities.cshtml +++ b/SaxoniteCoreWebOnline/Views/Organisation/Opportunities.cshtml @@ -65,5 +65,5 @@
- + diff --git a/SaxoniteCoreWebOnline/Views/Organisation/Panel-OpportunityDialog.cshtml b/SaxoniteCoreWebOnline/Views/Organisation/Panel-OpportunityDialog.cshtml index 52a23d7..18795fd 100644 --- a/SaxoniteCoreWebOnline/Views/Organisation/Panel-OpportunityDialog.cshtml +++ b/SaxoniteCoreWebOnline/Views/Organisation/Panel-OpportunityDialog.cshtml @@ -83,7 +83,7 @@ } - - + +
diff --git a/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml b/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml index 32721b8..15424c7 100644 --- a/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml +++ b/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml @@ -62,7 +62,7 @@ sax.links.facebook = '@Model.Links.Facebook'; sax.links.linkedin = '@Model.Links.LinkedIn'; sax.form.calendarDateFormat = '@(Model.CalendarDateFormat)'; - sax.lbl.calendar='@Localiser.GetJavascriptText("label.Calendar")'; + sax.lbl.calendar='@Localiser.GetJavascriptText("label.calendar")'; sax.dlg.title.alert = '@Localiser.GetJavascriptText("dialog.title.alert")'; sax.dlg.title.confirm = '@Localiser.GetJavascriptText("dialog.title.confirm")'; sax.dlg.title.progress = '@Localiser.GetJavascriptText("dialog.title.progress")'; diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css index e0fd9bc..052d555 100644 --- a/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css +++ b/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css @@ -89,7 +89,7 @@ { margin: 2px 1px 0 1px; background-color: #a0a0a0; - opacity:0.8; + opacity: 0.8; box-shadow: 0 0 0 1px #40404080 inset; } diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-home.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-home.css index ddb97da..c27a3d6 100644 --- a/SaxoniteCoreWebOnline/wwwroot/css/sax-home.css +++ b/SaxoniteCoreWebOnline/wwwroot/css/sax-home.css @@ -47,36 +47,46 @@ #dlgActivity .sax-panel-item.Article .ArticleHeadline, #dlgActivity .sax-panel-item.Opportunity .OpportunityOrganisation { - margin: 0 0 8px 0; - padding: 0 0 8px 0; + margin: 0; + padding: 8px 8px; font-size: 2rem; font-weight: bold; border-bottom: 1px solid #b0b0b0; } #dlgActivity .sax-panel-item.Article .ArticleSummary, +#dlgActivity .sax-panel-item.Article .ArticleAuthor, +#dlgActivity .sax-panel-item.Opportunity .OpportunityOrganisation, #dlgActivity .sax-panel-item.Opportunity .OpportunityPosition, #dlgActivity .sax-panel-item.Opportunity .OpportunityOutline { - margin: 0 0 8px 0; - padding: 0 0 8px 0; + margin: 0; + padding: 8px 8px; font-size: 1.5rem; font-weight: bold; border-bottom: 1px solid #b0b0b0; } +#dlgActivity .sax-panel-item.Article .ArticleAuthor +{ + padding: 4px 8px; + font-size: .9rem; + background-color: #f8f8f8; +} + #dlgActivity .sax-panel-item.Opportunity { } #dlgActivity .sax-panel-item.Article .ArticleContentSegment { + margin:4px 0; } #dlgActivity .sax-panel-item.Article .ArticleContentSegmentImage img { - max-width:75%; - max-height:400px; + max-width: 75%; + max-height: 400px; } .ui-dialog.sax-dialog-activity button.ActivityReaction diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-main.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-main.css index eda7998..2bb3fee 100644 --- a/SaxoniteCoreWebOnline/wwwroot/css/sax-main.css +++ b/SaxoniteCoreWebOnline/wwwroot/css/sax-main.css @@ -113,6 +113,13 @@ button.accept-policy line-height: inherit; } +/* Information */ + +.sax-para +{ + margin: 8px 0; +} + /* Actions */ a, a:hover diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-selectOrganisation.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-org-sel.css similarity index 100% rename from SaxoniteCoreWebOnline/wwwroot/css/sax-selectOrganisation.css rename to SaxoniteCoreWebOnline/wwwroot/css/sax-org-sel.css diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-selectRegion.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-reg-sel.css similarity index 100% rename from SaxoniteCoreWebOnline/wwwroot/css/sax-selectRegion.css rename to SaxoniteCoreWebOnline/wwwroot/css/sax-reg-sel.css diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-selectSport.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-spt-sel.css similarity index 100% rename from SaxoniteCoreWebOnline/wwwroot/css/sax-selectSport.css rename to SaxoniteCoreWebOnline/wwwroot/css/sax-spt-sel.css diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-home.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-home.js index 5128c77..67c8da9 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-home.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-home.js @@ -84,6 +84,7 @@ let $segs = $('.ArticleContentSegments', $itm); $('.ArticleHeadline', $itm).text(item.headline); $('.ArticleSummary', $itm).text(item.summary).toggle(!!item.summary); + $('.ArticleAuthor', $itm).text(item.author).toggle(!!item.author); let segs = item.content.segments; for (let segIdx = 0; segIdx < segs.length; segIdx++) { diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-jrn-art.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-jrn-art.js index a085c30..9f56353 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-jrn-art.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-jrn-art.js @@ -311,7 +311,7 @@ } sax.onUpdateItem = function (response) { - sax.debug('onUpdateItem', response); + //sax.debug('onUpdateItem', response); sax.clearItem(); if (!response.success) return; let $frm = sax.$frm.article; @@ -347,17 +347,6 @@ $('.sax-article').removeClass('ArticleHeader').addClass('ArticleContent'); } - //-------------------------------------------------------------- - sax.selectRegion = function () - { - sax.data.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifArticleRegionId').val(), fnCallback: sax.onSelectRegion }) - } - sax.onSelectRegion = function (region) - { - sax.clearControlError($('#ifArticleRegionId').val(region.id)); - $('#ifArticleRegionCaption').val(region ? region.name : ''); - } - //-------------------------------------------------------------- sax.selectSport = function () { @@ -369,6 +358,17 @@ $('#ifArticleSportCaption').val(sport ? sport.name : ''); } + //-------------------------------------------------------------- + sax.selectRegion = function () + { + sax.data.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifArticleRegionId').val(), fnCallback: sax.onSelectRegion }) + } + sax.onSelectRegion = function (region) + { + sax.clearControlError($('#ifArticleRegionId').val(region.id)); + $('#ifArticleRegionCaption').val(region ? region.name : ''); + } + //-------------------------------------------------------------- sax.storeItem = function () { @@ -377,7 +377,7 @@ } sax.onStoreItem = function (response) { - sax.debug('onStoreItem', response); + //sax.debug('onStoreItem', response); sax.refreshControlValues(response.controlValues); if (!response.success) return; sax.$dlg.article.dialog('close'); diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-org-req.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-org-req.js new file mode 100644 index 0000000..d93e37a --- /dev/null +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-org-req.js @@ -0,0 +1,69 @@ +/* + * Organisation Request. + */ + +(function (win, doc, undef) +{ + "use strict"; + let or = sax.orgReq; + or.fn = {}; or.ajax = {}; + + //-------------------------------------------------------------- + or.fn.requestOrganisation = function () + { + or.fn.init(); + sax.openDialog(or.$dlg, 640, 760); + } + or.fn.storeOrganisation = function () + { + //sax.debug('refreshResults'); + or.ajax.registerOrg = or.ajax.registerOrg || { url: sax.url.base + 'Organisation/Ajax/requestOrganisation', formId: 'frmOrganisationRequest', callbackFn: or.fn.handleRequestOrganisationResponse }; + sax.doAjaxRequest(or.ajax.registerOrg, 50); + } + or.fn.handleRequestOrganisationResponse = function (response) + { + sax.debug('or.handleRequestOrganisationResponse', response); + if (!response.success) return; + + } + or.fn.cleanUp = function () + { + } + + //-------------------------------------------------------------- + sax.selectOrgSport = function () + { + sax.data.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.OrganisationSportId', or.$frm).val(), fnCallback: sax.onSelectOrgSport }) + } + sax.onSelectOrgSport = function (sport) + { + sax.clearControlError($('.OrganisationSportId', or.$frm).val(sport.id)); + $('.OrganisationSportCaption', or.$frm).val(sport ? sport.name : ''); + } + + //-------------------------------------------------------------- + sax.selectOrgRegion = function () + { + sax.data.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.OrganisationRegionId', or.$frm).val(), typesInc:[30], fnCallback: sax.onSelectOrgRegion }) + } + sax.onSelectOrgRegion = function (region) + { + sax.clearControlError($('.OrganisationRegionId', or.$frm).val(region.id)); + $('.OrganisationRegionCaption', or.$frm).val(region ? region.name : ''); + } + + //-------------------------------------------------------------- + or.fn.init = function () + { + if (or.$dlg) return; + var opt = sax.dlgOpts(); + opt.title = sax.orgReq.dlgTitleRequestOrganisation; + opt.buttons[sax.dlg.btn.ok] = function () { or.fn.storeOrganisation(); }; + opt.buttons[sax.dlg.btn.cancel] = function () { or.fn.cleanUp(); $(this).dialog('close'); }; + or.$dlg = $('#dlgOrganisationRequest').dialog(opt); + or.$frm = $('#frmOrganisationRequest', or.$dlg); + } + +}(window, window.document)); + +/* The End */ \ No newline at end of file diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-selectOrganisation.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-org-sel.js similarity index 94% rename from SaxoniteCoreWebOnline/wwwroot/js/sax-selectOrganisation.js rename to SaxoniteCoreWebOnline/wwwroot/js/sax-org-sel.js index 4ea4bdd..45691e1 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-selectOrganisation.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-org-sel.js @@ -1,11 +1,12 @@ /* - * Admin - User page scripts. + * Organisation selection. */ (function (win, doc, undef) { "use strict"; - let so = sax.selectOrganisation = sax.selectOrganisation || { data: {}, fn: {}, $dlg: {}, itemIdPrefix: 'Org_' }; + let so = sax.selectOrganisation; + so.data = {}; so.fn = {}; so.itemIdPrefix = 'Org_'; //-------------------------------------------------------------- /* @@ -92,6 +93,7 @@ so.fn.cleanUp = function () { //sax.debug('confirmSelection', so.data.item); + $('.sax-input.FilterOrganisation', so.$filter).val(''); so.$results.empty(); delete so.cfg; delete so.data.item; @@ -101,7 +103,7 @@ //-------------------------------------------------------------- so.fn.init = function () { - if (!so.$dlg) return; + if (so.$dlg) return; var opt = sax.dlgOpts(); opt.open = function () { so.fn.refreshResults(200); }; opt.buttons[sax.dlg.btn.ok] = function () { so.fn.confirmSelection(); }; diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-selectRegion.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-reg-sel.js similarity index 87% rename from SaxoniteCoreWebOnline/wwwroot/js/sax-selectRegion.js rename to SaxoniteCoreWebOnline/wwwroot/js/sax-reg-sel.js index 92f06d3..f1a604b 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-selectRegion.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-reg-sel.js @@ -5,13 +5,16 @@ (function (win, doc, undef) { "use strict"; - let sr = sax.data.selectRegion = sax.data.selectRegion || { regions: {}, fn: {}, $dlg: {}, itemIdPrefix: 'Rgn_' }; + let sr = sax.data.selectRegion; + sr.regions = {}; sr.fn = {}; sr.ajax = {}; sr.itemIdPrefix = 'Rgn_'; //-------------------------------------------------------------- /* * Region selection config: * - caption - dialog title. * - regionId - currently selected region. + * - typesInc[] - included region types. + * - typesExc[] - excluded region types. * - fnCallback - method to call on completion to store selected region. */ sr.fn.selectRegion = function (cfg) @@ -22,14 +25,15 @@ if (sr.regions.length) sr.fn.showSelectRegion(); else { - sax.ajaxRegions = sax.ajaxRegions || { url: sax.url.base + 'Reference/Ajax/GetRegions', formId: 'frmNavigate', callbackFn: sr.fn.refreshRegionsAndSelect }; - sax.doAjaxRequest(sax.ajaxRegions, 20); + sr.ajax.regions = sr.ajax.regions || { url: sax.url.base + 'Reference/Ajax/GetRegions', formId: 'frmNavigate', callbackFn: sr.fn.refreshRegionsAndSelect }; + sax.doAjaxRequest(sr.ajax.regions, 20); } } sr.fn.refreshRegionsAndSelect = function (response) { if (!response || !response.success) return; sr.regions = response.regions; + sax.debug(sr.cfg); sr.fn.showSelectRegion(); } sr.fn.showSelectRegion = function () @@ -57,12 +61,16 @@ let $regionsAvail = $('.sax-selectRegion-regions.AvailableRegions', sr.$dlg).empty(); let $regionTmpl = $('.sax-panel-item-template .sax-panel-item.Region', sr.$dlg); let regions = [...sr.regions]; + let typesInc = sr.cfg.typesInc||[]; + let typesExc = sr.cfg.typesExc||[]; regions.sort(sr.fn.compareRegions); for (let rgnIdx = 0; rgnIdx < regions.length; rgnIdx++) { let region = regions[rgnIdx]; let id = region.id; if (filter && !region.name.match(reFilter)) continue; + if (typesInc.length && !typesInc.includes(region.regionType)) continue; + if (typesExc.length && typesExc.includes(region.regionType)) continue; let $region = $regionTmpl.clone(); $region.prop('id', sr.itemIdPrefix + id).on('click', function () { sr.fn.onClickRegion(id); }).on('dblclick', function () { sr.fn.onDblClickRegion(id); }).find('.RegionName').text(region.name).end(); if (id == sr.regionId) $region.addClass('sel'); @@ -120,7 +128,7 @@ //-------------------------------------------------------------- sr.fn.init = function () { - if (!sr.$dlg) return; + if (sr.$dlg) return; var opt = sax.dlgOpts(); opt.open = function (evt, ui) { sr.fn.onDlgSize(); }; opt.resize = function (evt, ui) { sr.fn.onDlgSize(); }; diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-resultsPaging.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-resultsPaging.js index 009c074..2b24264 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-resultsPaging.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-resultsPaging.js @@ -15,8 +15,8 @@ rp.paging = paging = paging || {}; rp.$rp.toggle(paging.paged); $('.sax-paging-info', rp.$rp).text(sax.resultsPaging.msg.pageInfo.format(paging.pageNo, paging.pageCount)); - $('.sax-paging-first,.sax-paging-prev', rp.$rp).toggle(paging.pageNo > 1); - $('.sax-paging-next,.sax-paging-last', rp.$rp).toggle(paging.pageNo < paging.pageCount); + //$('.sax-paging-first,.sax-paging-prev', rp.$rp).toggle(paging.pageNo > 1); + //$('.sax-paging-next,.sax-paging-last', rp.$rp).toggle(paging.pageNo < paging.pageCount); } //-------------------------------------------------------------- diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-selectSport.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-spt-sel.js similarity index 94% rename from SaxoniteCoreWebOnline/wwwroot/js/sax-selectSport.js rename to SaxoniteCoreWebOnline/wwwroot/js/sax-spt-sel.js index ea9241d..64fd336 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-selectSport.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-spt-sel.js @@ -5,7 +5,8 @@ (function (win, doc, undef) { "use strict"; - let ss = sax.data.selectSport = sax.data.selectSport || { sports: {}, fn: {}, $dlg: {}, itemIdPrefix: 'Spt_' }; + let ss = sax.data.selectSport; + ss.sports = {}; ss.fn = {}; ss.ajax = {}; ss.itemIdPrefix = 'Spt_'; //-------------------------------------------------------------- /* @@ -23,8 +24,8 @@ if (ss.sports.length) ss.fn.showSelectSport(); else { - sax.ajaxSports = sax.ajaxSports || { url: sax.url.base + 'Reference/Ajax/GetSports', formId: 'frmNavigate', callbackFn: ss.fn.refreshSportsAndSelect }; - sax.doAjaxRequest(sax.ajaxSports, 20); + ss.ajax.sports = ss.ajax.sports || { url: sax.url.base + 'Reference/Ajax/GetSports', formId: 'frmNavigate', callbackFn: ss.fn.refreshSportsAndSelect }; + sax.doAjaxRequest(ss.ajax.sports, 20); } } ss.fn.refreshSportsAndSelect = function (response) @@ -122,7 +123,7 @@ //-------------------------------------------------------------- ss.fn.init = function () { - if (!ss.$dlg) return; + if (ss.$dlg) return; var opt = sax.dlgOpts(); opt.open = function (evt, ui) { ss.fn.onDlgSize(); }; opt.resize = function (evt, ui) { ss.fn.onDlgSize(); }; diff --git a/SaxoniteStandardBase/Base/App/Sax-Version.cs b/SaxoniteStandardBase/Base/App/Sax-Version.cs index 69db157..7138226 100644 --- a/SaxoniteStandardBase/Base/App/Sax-Version.cs +++ b/SaxoniteStandardBase/Base/App/Sax-Version.cs @@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App //------------------------------------------------------------------- public static class Version { - private static String version { get; } = "1.1.0.0"; + private static String version { get; } = "1.1.1.0"; // Retrieve version. public static String GetFullVersion () { return version; } public static String GetAppVersion () @@ -40,6 +40,11 @@ namespace Saxonite.Net.Standard.Base.App //------------------------------------------------------------------- // Version history. //------------------------------------------------------------------- + // 1.1.2 ??-Jul-2021 Organisation Request. + // - Online Organisation Request. + // 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. diff --git a/SaxoniteStandardBase/Base/App/Sax.cs b/SaxoniteStandardBase/Base/App/Sax.cs index 75ce080..f678f10 100644 --- a/SaxoniteStandardBase/Base/App/Sax.cs +++ b/SaxoniteStandardBase/Base/App/Sax.cs @@ -98,6 +98,7 @@ namespace Saxonite.Net.Standard.Base.App OrganisationType, OrganisationCategory, OrganisationRole, + AddressType, OpportunityType, ActivityReaction, }; @@ -149,6 +150,7 @@ namespace Saxonite.Net.Standard.Base.App OrganisationEvent = 225, // Item link components. ItemImage = 400, + ItemAddress = 405, ItemSport = 420, } @@ -279,6 +281,17 @@ namespace Saxonite.Net.Standard.Base.App OpportunityAdmin, } + //------------------------------------------------------------------- + public enum AddressType + { + Unknown = 0, + /* Do not change the numeric values - tied to database. */ + Location = 10, + Home = 20, + Office = 50, + Delivery = 60, + } + //------------------------------------------------------------------- /// Opportunity Type public enum OpportunityType diff --git a/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs b/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs index 2d3186e..b3a2b4c 100644 --- a/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs +++ b/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Base.App { @@ -18,6 +18,7 @@ namespace Saxonite.Base.App { Unknown = 0, ActivityIndex, + ItemAddress, ItemImage, ItemSport, JournalistArticle, @@ -52,6 +53,38 @@ namespace Saxonite.Base.App ActivityIndex_UpdateOn, ActivityIndex_UpdateBy, ActivityIndex_UpdateHost, + ItemAddress_Id, + ItemAddress_ItemType, + ItemAddress_ItemId, + ItemAddress_AddressType, + ItemAddress_Caption, + ItemAddress_Line1, + ItemAddress_Line2, + ItemAddress_Line3, + ItemAddress_Town, + ItemAddress_Province, + ItemAddress_RegionIdProvince, + ItemAddress_Country, + ItemAddress_RegionIdCountry, + ItemAddress_PostalCode, + ItemAddress_PhoneMain, + ItemAddress_LocationSource, + ItemAddress_LocationStoredAt, + ItemAddress_LocationUpdateRequired, + ItemAddress_LocationData, + ItemAddress_LocationFormattedAddress, + ItemAddress_LocationLatitude, + ItemAddress_LocationLongitude, + ItemAddress_LocationAltitude, + ItemAddress_Notes, + ItemAddress_Flags, + ItemAddress_Status, + ItemAddress_CreateOn, + ItemAddress_CreateBy, + ItemAddress_CreateHost, + ItemAddress_UpdateOn, + ItemAddress_UpdateBy, + ItemAddress_UpdateHost, ItemImage_Id, ItemImage_ItemType, ItemImage_ItemId, @@ -270,8 +303,8 @@ namespace Saxonite.Base.App //------------------------------------------------------------------- // Data members. - private static readonly int tableCount = 14; - private static readonly int columnCount = 228; + private static readonly int tableCount = 15; + private static readonly int columnCount = 260; private static ulong maxTextLen = 0; //------------------------------------------------------------------- @@ -418,6 +451,7 @@ namespace Saxonite.Base.App private static readonly String[] tables = { "ActivityIndex", + "ItemAddress", "ItemImage", "ItemSport", "JournalistArticle", @@ -474,30 +508,48 @@ namespace Saxonite.Base.App new ColumnDfn(2,"Id",5,-5,true,19), new ColumnDfn(2,"ItemType",3,5,false,5), new ColumnDfn(2,"ItemId",4,4,false,10), - new ColumnDfn(2,"ImageType",3,5,false,5), - new ColumnDfn(2,"ImageSeq",2,-6,false,3), - new ColumnDfn(2,"SessionUid",5,-5,false,19), - new ColumnDfn(2,"ImageUid",4,4,false,10), - new ColumnDfn(2,"Filename",0,-9,false,1024), - new ColumnDfn(2,"Mime",0,12,false,64), - new ColumnDfn(2,"ContentType",0,12,false,128), - new ColumnDfn(2,"Width",4,4,false,10), - new ColumnDfn(2,"Height",4,4,false,10), - new ColumnDfn(2,"ImageData",10,-3,false,0), + new ColumnDfn(2,"AddressType",3,5,false,5), + new ColumnDfn(2,"Caption",0,-9,false,200), + new ColumnDfn(2,"Line1",0,-9,false,200), + new ColumnDfn(2,"Line2",0,-9,false,200), + new ColumnDfn(2,"Line3",0,-9,false,200), + new ColumnDfn(2,"Town",0,-9,false,100), + new ColumnDfn(2,"Province",0,-9,false,100), + new ColumnDfn(2,"RegionIdProvince",4,4,false,10), + new ColumnDfn(2,"Country",0,-9,false,100), + new ColumnDfn(2,"RegionIdCountry",4,4,false,10), + new ColumnDfn(2,"PostalCode",0,-9,false,32), + new ColumnDfn(2,"PhoneMain",0,-9,false,100), + new ColumnDfn(2,"LocationSource",0,12,false,100), + new ColumnDfn(2,"LocationStoredAt",9,93,false,16), + new ColumnDfn(2,"LocationUpdateRequired",1,-7,false,1), + new ColumnDfn(2,"LocationData",0,-9,false,4000), + new ColumnDfn(2,"LocationFormattedAddress",0,-9,false,4000), + new ColumnDfn(2,"LocationLatitude",8,3,false,9), + new ColumnDfn(2,"LocationLongitude",8,3,false,9), + new ColumnDfn(2,"LocationAltitude",8,3,false,9), 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,"Status",0,1,false,3), new ColumnDfn(2,"CreateOn",9,93,false,23), new ColumnDfn(2,"CreateBy",4,4,false,10), new ColumnDfn(2,"CreateHost",0,12,false,100), new ColumnDfn(2,"UpdateOn",9,93,false,23), new ColumnDfn(2,"UpdateBy",4,4,false,10), new ColumnDfn(2,"UpdateHost",0,12,false,100), - new ColumnDfn(3,"Id",4,4,true,10), + new ColumnDfn(3,"Id",5,-5,true,19), new ColumnDfn(3,"ItemType",3,5,false,5), new ColumnDfn(3,"ItemId",4,4,false,10), - new ColumnDfn(3,"SportId",4,4,false,10), - new ColumnDfn(3,"ItemSportData",0,-9,false,0), + new ColumnDfn(3,"ImageType",3,5,false,5), + new ColumnDfn(3,"ImageSeq",2,-6,false,3), + new ColumnDfn(3,"SessionUid",5,-5,false,19), + new ColumnDfn(3,"ImageUid",4,4,false,10), + new ColumnDfn(3,"Filename",0,-9,false,1024), + new ColumnDfn(3,"Mime",0,12,false,64), + new ColumnDfn(3,"ContentType",0,12,false,128), + new ColumnDfn(3,"Width",4,4,false,10), + new ColumnDfn(3,"Height",4,4,false,10), + new ColumnDfn(3,"ImageData",10,-3,false,0), new ColumnDfn(3,"Notes",0,-9,false,2000), new ColumnDfn(3,"Flags",3,5,false,5), new ColumnDfn(3,"Status",0,12,false,3), @@ -508,13 +560,10 @@ namespace Saxonite.Base.App new ColumnDfn(3,"UpdateBy",4,4,false,10), new ColumnDfn(3,"UpdateHost",0,12,false,100), new ColumnDfn(4,"Id",4,4,true,10), - new ColumnDfn(4,"UserAccountIdJournalist",4,4,false,10), - new ColumnDfn(4,"SportIdPrimary",4,4,false,10), - new ColumnDfn(4,"RegionIdPrimary",4,4,false,10), - new ColumnDfn(4,"Headline",0,-9,false,200), - new ColumnDfn(4,"Summary",0,-9,false,2000), - new ColumnDfn(4,"BodyData",0,-9,false,0), - new ColumnDfn(4,"PublishedAt",9,93,false,16), + new ColumnDfn(4,"ItemType",3,5,false,5), + new ColumnDfn(4,"ItemId",4,4,false,10), + new ColumnDfn(4,"SportId",4,4,false,10), + new ColumnDfn(4,"ItemSportData",0,-9,false,0), new ColumnDfn(4,"Notes",0,-9,false,2000), new ColumnDfn(4,"Flags",3,5,false,5), new ColumnDfn(4,"Status",0,12,false,3), @@ -525,14 +574,13 @@ namespace Saxonite.Base.App new ColumnDfn(4,"UpdateBy",4,4,false,10), new ColumnDfn(4,"UpdateHost",0,12,false,100), new ColumnDfn(5,"Id",4,4,true,10), - new ColumnDfn(5,"Name",0,-9,false,100), - new ColumnDfn(5,"OrganisationType",0,12,false,3), - new ColumnDfn(5,"OrganisationCategory",0,12,false,3), + new ColumnDfn(5,"UserAccountIdJournalist",4,4,false,10), new ColumnDfn(5,"SportIdPrimary",4,4,false,10), new ColumnDfn(5,"RegionIdPrimary",4,4,false,10), - new ColumnDfn(5,"CountryIso2Code",0,12,false,2), - new ColumnDfn(5,"PhoneMain",0,-9,false,50), - new ColumnDfn(5,"PhoneAlt",0,-9,false,50), + new ColumnDfn(5,"Headline",0,-9,false,200), + new ColumnDfn(5,"Summary",0,-9,false,2000), + new ColumnDfn(5,"BodyData",0,-9,false,0), + new ColumnDfn(5,"PublishedAt",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), @@ -543,15 +591,14 @@ namespace Saxonite.Base.App new ColumnDfn(5,"UpdateBy",4,4,false,10), new ColumnDfn(5,"UpdateHost",0,12,false,100), new ColumnDfn(6,"Id",4,4,true,10), - new ColumnDfn(6,"OrganisationId",4,4,false,10), + new ColumnDfn(6,"Name",0,-9,false,100), + new ColumnDfn(6,"OrganisationType",0,12,false,3), + new ColumnDfn(6,"OrganisationCategory",0,12,false,3), new ColumnDfn(6,"SportIdPrimary",4,4,false,10), new ColumnDfn(6,"RegionIdPrimary",4,4,false,10), - new ColumnDfn(6,"OpportunityTypeCode",0,12,false,3), - new ColumnDfn(6,"Position",0,-9,false,200), - new ColumnDfn(6,"Outline",0,-9,false,2000), - new ColumnDfn(6,"OpportunityData",0,-9,false,0), - new ColumnDfn(6,"PublishedAt",9,93,false,16), - new ColumnDfn(6,"ExpiresAt",9,93,false,16), + new ColumnDfn(6,"CountryIso2Code",0,12,false,2), + new ColumnDfn(6,"PhoneMain",0,-9,false,50), + new ColumnDfn(6,"PhoneAlt",0,-9,false,50), new ColumnDfn(6,"Notes",0,-9,false,2000), new ColumnDfn(6,"Flags",3,5,false,5), new ColumnDfn(6,"Status",0,12,false,3), @@ -562,12 +609,15 @@ namespace Saxonite.Base.App new ColumnDfn(6,"UpdateBy",4,4,false,10), new ColumnDfn(6,"UpdateHost",0,12,false,100), new ColumnDfn(7,"Id",4,4,true,10), - new ColumnDfn(7,"RegionType",3,5,false,5), - new ColumnDfn(7,"CountryIso2Code",0,12,false,2), - new ColumnDfn(7,"Name",0,-9,false,100), - new ColumnDfn(7,"Latitude",8,3,false,9), - new ColumnDfn(7,"Longitude",8,3,false,9), - new ColumnDfn(7,"RegionIdParent",4,4,false,10), + new ColumnDfn(7,"OrganisationId",4,4,false,10), + new ColumnDfn(7,"SportIdPrimary",4,4,false,10), + new ColumnDfn(7,"RegionIdPrimary",4,4,false,10), + new ColumnDfn(7,"OpportunityTypeCode",0,12,false,3), + new ColumnDfn(7,"Position",0,-9,false,200), + new ColumnDfn(7,"Outline",0,-9,false,2000), + new ColumnDfn(7,"OpportunityData",0,-9,false,0), + new ColumnDfn(7,"PublishedAt",9,93,false,16), + new ColumnDfn(7,"ExpiresAt",9,93,false,16), new ColumnDfn(7,"Notes",0,-9,false,2000), new ColumnDfn(7,"Flags",3,5,false,5), new ColumnDfn(7,"Status",0,12,false,3), @@ -578,7 +628,12 @@ namespace Saxonite.Base.App new ColumnDfn(7,"UpdateBy",4,4,false,10), new ColumnDfn(7,"UpdateHost",0,12,false,100), new ColumnDfn(8,"Id",4,4,true,10), + new ColumnDfn(8,"RegionType",3,5,false,5), + new ColumnDfn(8,"CountryIso2Code",0,12,false,2), new ColumnDfn(8,"Name",0,-9,false,100), + new ColumnDfn(8,"Latitude",8,3,false,9), + new ColumnDfn(8,"Longitude",8,3,false,9), + new ColumnDfn(8,"RegionIdParent",4,4,false,10), new ColumnDfn(8,"Notes",0,-9,false,2000), new ColumnDfn(8,"Flags",3,5,false,5), new ColumnDfn(8,"Status",0,12,false,3), @@ -589,24 +644,7 @@ namespace Saxonite.Base.App new ColumnDfn(8,"UpdateBy",4,4,false,10), new ColumnDfn(8,"UpdateHost",0,12,false,100), new ColumnDfn(9,"Id",4,4,true,10), - new ColumnDfn(9,"EmailAddress",0,-9,false,200), - new ColumnDfn(9,"Title",0,-9,false,20), - new ColumnDfn(9,"FirstName",0,-9,false,100), - new ColumnDfn(9,"Initials",0,-9,false,10), - new ColumnDfn(9,"LastName",0,-9,false,100), - new ColumnDfn(9,"PhoneMain",0,-9,false,50), - new ColumnDfn(9,"PhoneMobile",0,-9,false,50), - new ColumnDfn(9,"PhoneAlt",0,-9,false,50), - new ColumnDfn(9,"DateOfBirth",9,93,false,16), - new ColumnDfn(9,"RegionIdCountry",4,4,false,10), - new ColumnDfn(9,"RegionIdProvince",4,4,false,10), - new ColumnDfn(9,"PasswordToken",0,12,false,32), - new ColumnDfn(9,"PasswordHashed",0,-9,false,100), - new ColumnDfn(9,"PasswordHistory",0,-9,false,0), - new ColumnDfn(9,"PasswordChangedAt",9,93,false,16), - new ColumnDfn(9,"LastLoginAt",9,93,false,16), - new ColumnDfn(9,"LastInvalidLoginAt",9,93,false,16), - new ColumnDfn(9,"InvalidLoginCount",3,5,false,5), + new ColumnDfn(9,"Name",0,-9,false,100), new ColumnDfn(9,"Notes",0,-9,false,2000), new ColumnDfn(9,"Flags",3,5,false,5), new ColumnDfn(9,"Status",0,12,false,3), @@ -616,19 +654,25 @@ namespace Saxonite.Base.App new ColumnDfn(9,"UpdateOn",9,93,false,23), new ColumnDfn(9,"UpdateBy",4,4,false,10), new ColumnDfn(9,"UpdateHost",0,12,false,100), - new ColumnDfn(10,"Id",5,-5,true,19), - new ColumnDfn(10,"UserAccountId",4,4,false,10), - new ColumnDfn(10,"ItemType",3,5,false,5), - new ColumnDfn(10,"ItemId",5,-5,false,19), - new ColumnDfn(10,"CurrentlyListed",1,-7,false,1), - new ColumnDfn(10,"ListedAtFirst",9,93,false,16), - new ColumnDfn(10,"ListedAtLast",9,93,false,16), - new ColumnDfn(10,"ViewedAtFirst",9,93,false,16), - new ColumnDfn(10,"ViewedAtLast",9,93,false,16), - new ColumnDfn(10,"Reaction",3,5,false,5), - new ColumnDfn(10,"ReactedAtFirst",9,93,false,16), - new ColumnDfn(10,"ReactedAtLast",9,93,false,16), - new ColumnDfn(10,"UserActivityData",0,-9,false,0), + new ColumnDfn(10,"Id",4,4,true,10), + new ColumnDfn(10,"EmailAddress",0,-9,false,200), + new ColumnDfn(10,"Title",0,-9,false,20), + new ColumnDfn(10,"FirstName",0,-9,false,100), + new ColumnDfn(10,"Initials",0,-9,false,10), + new ColumnDfn(10,"LastName",0,-9,false,100), + new ColumnDfn(10,"PhoneMain",0,-9,false,50), + new ColumnDfn(10,"PhoneMobile",0,-9,false,50), + new ColumnDfn(10,"PhoneAlt",0,-9,false,50), + new ColumnDfn(10,"DateOfBirth",9,93,false,16), + new ColumnDfn(10,"RegionIdCountry",4,4,false,10), + new ColumnDfn(10,"RegionIdProvince",4,4,false,10), + new ColumnDfn(10,"PasswordToken",0,12,false,32), + new ColumnDfn(10,"PasswordHashed",0,-9,false,100), + new ColumnDfn(10,"PasswordHistory",0,-9,false,0), + new ColumnDfn(10,"PasswordChangedAt",9,93,false,16), + new ColumnDfn(10,"LastLoginAt",9,93,false,16), + new ColumnDfn(10,"LastInvalidLoginAt",9,93,false,16), + new ColumnDfn(10,"InvalidLoginCount",3,5,false,5), new ColumnDfn(10,"Notes",0,-9,false,2000), new ColumnDfn(10,"Flags",3,5,false,5), new ColumnDfn(10,"Status",0,12,false,3), @@ -640,9 +684,17 @@ namespace Saxonite.Base.App new ColumnDfn(10,"UpdateHost",0,12,false,100), new ColumnDfn(11,"Id",5,-5,true,19), new ColumnDfn(11,"UserAccountId",4,4,false,10), - new ColumnDfn(11,"OrganisationId",4,4,false,10), - new ColumnDfn(11,"OrganisationRoleCodes",0,12,false,256), - new ColumnDfn(11,"OrganisationRoleCount",2,-6,false,3), + new ColumnDfn(11,"ItemType",3,5,false,5), + new ColumnDfn(11,"ItemId",5,-5,false,19), + new ColumnDfn(11,"CurrentlyListed",1,-7,false,1), + new ColumnDfn(11,"ListedAtFirst",9,93,false,16), + new ColumnDfn(11,"ListedAtLast",9,93,false,16), + new ColumnDfn(11,"ViewedAtFirst",9,93,false,16), + new ColumnDfn(11,"ViewedAtLast",9,93,false,16), + new ColumnDfn(11,"Reaction",3,5,false,5), + new ColumnDfn(11,"ReactedAtFirst",9,93,false,16), + new ColumnDfn(11,"ReactedAtLast",9,93,false,16), + new ColumnDfn(11,"UserActivityData",0,-9,false,0), new ColumnDfn(11,"Notes",0,-9,false,2000), new ColumnDfn(11,"Flags",3,5,false,5), new ColumnDfn(11,"Status",0,12,false,3), @@ -654,7 +706,9 @@ namespace Saxonite.Base.App new ColumnDfn(11,"UpdateHost",0,12,false,100), new ColumnDfn(12,"Id",5,-5,true,19), new ColumnDfn(12,"UserAccountId",4,4,false,10), - new ColumnDfn(12,"UserRoleCode",0,12,false,16), + new ColumnDfn(12,"OrganisationId",4,4,false,10), + new ColumnDfn(12,"OrganisationRoleCodes",0,12,false,256), + new ColumnDfn(12,"OrganisationRoleCount",2,-6,false,3), new ColumnDfn(12,"Notes",0,-9,false,2000), new ColumnDfn(12,"Flags",3,5,false,5), new ColumnDfn(12,"Status",0,12,false,3), @@ -664,27 +718,39 @@ namespace Saxonite.Base.App new ColumnDfn(12,"UpdateOn",9,93,false,23), new ColumnDfn(12,"UpdateBy",4,4,false,10), new ColumnDfn(12,"UpdateHost",0,12,false,100), + new ColumnDfn(13,"Id",5,-5,true,19), new ColumnDfn(13,"UserAccountId",4,4,false,10), - new ColumnDfn(13,"ActivityIndexIds",0,-9,false,0), - new ColumnDfn(13,"UserSessionData",0,-9,false,0), + new ColumnDfn(13,"UserRoleCode",0,12,false,16), + new ColumnDfn(13,"Notes",0,-9,false,2000), new ColumnDfn(13,"Flags",3,5,false,5), + new ColumnDfn(13,"Status",0,12,false,3), new ColumnDfn(13,"CreateOn",9,93,false,23), + new ColumnDfn(13,"CreateBy",4,4,false,10), + new ColumnDfn(13,"CreateHost",0,12,false,100), new ColumnDfn(13,"UpdateOn",9,93,false,23), - new ColumnDfn(14,"Id",4,4,true,10), + new ColumnDfn(13,"UpdateBy",4,4,false,10), + new ColumnDfn(13,"UpdateHost",0,12,false,100), new ColumnDfn(14,"UserAccountId",4,4,false,10), - new ColumnDfn(14,"SportId",4,4,false,10), - new ColumnDfn(14,"Participation",3,5,false,5), - new ColumnDfn(14,"Officiating",3,5,false,5), - new ColumnDfn(14,"UserSportData",0,-9,false,0), - new ColumnDfn(14,"Notes",0,-9,false,2000), + new ColumnDfn(14,"ActivityIndexIds",0,-9,false,0), + new ColumnDfn(14,"UserSessionData",0,-9,false,0), new ColumnDfn(14,"Flags",3,5,false,5), - new ColumnDfn(14,"Status",0,12,false,3), new ColumnDfn(14,"CreateOn",9,93,false,23), - new ColumnDfn(14,"CreateBy",4,4,false,10), - new ColumnDfn(14,"CreateHost",0,12,false,100), new ColumnDfn(14,"UpdateOn",9,93,false,23), - new ColumnDfn(14,"UpdateBy",4,4,false,10), - new ColumnDfn(14,"UpdateHost",0,12,false,100), + new ColumnDfn(15,"Id",4,4,true,10), + new ColumnDfn(15,"UserAccountId",4,4,false,10), + new ColumnDfn(15,"SportId",4,4,false,10), + new ColumnDfn(15,"Participation",3,5,false,5), + new ColumnDfn(15,"Officiating",3,5,false,5), + new ColumnDfn(15,"UserSportData",0,-9,false,0), + new ColumnDfn(15,"Notes",0,-9,false,2000), + new ColumnDfn(15,"Flags",3,5,false,5), + new ColumnDfn(15,"Status",0,12,false,3), + new ColumnDfn(15,"CreateOn",9,93,false,23), + new ColumnDfn(15,"CreateBy",4,4,false,10), + new ColumnDfn(15,"CreateHost",0,12,false,100), + new ColumnDfn(15,"UpdateOn",9,93,false,23), + new ColumnDfn(15,"UpdateBy",4,4,false,10), + new ColumnDfn(15,"UpdateHost",0,12,false,100), }; //------------------------------------------------------------------- diff --git a/SaxoniteStandardBase/Base/App/SaxInternals.cs b/SaxoniteStandardBase/Base/App/SaxInternals.cs index 09a5aac..2652aa4 100644 --- a/SaxoniteStandardBase/Base/App/SaxInternals.cs +++ b/SaxoniteStandardBase/Base/App/SaxInternals.cs @@ -95,6 +95,7 @@ namespace Saxonite.Net.Standard.Base.App public List OrganisationTypeCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationType); } } public List OrganisationCategoryCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationCategory); } } public List OrganisationRoleCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationRole); } } + public List AddressTypeCodes { get { return GetCodesOfType(Sax.CodeType.AddressType); } } public List OpportunityTypeCodes { get { return GetCodesOfType(Sax.CodeType.OpportunityType); } } public List ActivityReactionCodes { get { return GetCodesOfType(Sax.CodeType.ActivityReaction); } } public List GetCodesOfType(Sax.CodeType codeType) @@ -210,6 +211,7 @@ namespace Saxonite.Net.Standard.Base.App QueryRegionsToCache(regionIds); foreach (SysId regionId in regionIds) { + if (!SysId.IsValid(regionId)) continue; SaxRegion region = GetRegion(regionCache.GetValue(regionId, null)); if (region != null) regions.Add(region); @@ -284,6 +286,7 @@ namespace Saxonite.Net.Standard.Base.App QuerySportsToCache(sportIds); foreach (SysId sportId in sportIds) { + if (!SysId.IsValid(sportId)) continue; SaxSport sport = GetSport(sportCache.GetValue(sportId, null)); if (sport != null) sports.Add(sport); @@ -298,6 +301,50 @@ namespace Saxonite.Net.Standard.Base.App return sport; } + //------------------------------------------------------------------- + // Common Data Components + //------------------------------------------------------------------- + // User Accounts. + private readonly Dictionary userAccountCache = new Dictionary(); + 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 organisationCache = new Dictionary(); + 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(); + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaxoniteStandardBase/Base/App/SaxSystem-Statics.cs b/SaxoniteStandardBase/Base/App/SaxSystem-Statics.cs index 676682a..a41d966 100644 --- a/SaxoniteStandardBase/Base/App/SaxSystem-Statics.cs +++ b/SaxoniteStandardBase/Base/App/SaxSystem-Statics.cs @@ -25,6 +25,7 @@ namespace Saxonite.Net.Standard.Base.App private static readonly List organisationTypeCodes = new List(); private static readonly List organisationCategoryCodes = new List(); private static readonly List organisationRoleCodes = new List(); + private static readonly List addressTypeCodes = new List(); private static readonly List opportunityTypeCodes = new List(); private static readonly List activityReactionCodes = new List(); @@ -140,7 +141,14 @@ namespace Saxonite.Net.Standard.Base.App opportunityTypeCodes.Add(Sax.OpportunityType.Board, "BRD", "Board"); //--------------------------------------------------------------- - // Opportunity types. + // 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"); + + //--------------------------------------------------------------- + // Activity Reactions. activityReactionCodes.Add(Sax.ActivityReaction.Good, "Good", "Good"); activityReactionCodes.Add(Sax.ActivityReaction.VeryGood, "VeryGood", "Very Good"); activityReactionCodes.Add(Sax.ActivityReaction.Exceptional, "Exceptional", "Exceptional"); diff --git a/SaxoniteStandardBase/Base/App/SaxSystem.cs b/SaxoniteStandardBase/Base/App/SaxSystem.cs index 40c9f10..af8e678 100644 --- a/SaxoniteStandardBase/Base/App/SaxSystem.cs +++ b/SaxoniteStandardBase/Base/App/SaxSystem.cs @@ -58,6 +58,8 @@ namespace Saxonite.Net.Standard.Base.App return new List(organisationCategoryCodes); case Sax.CodeType.OrganisationRole: return new List(organisationRoleCodes); + case Sax.CodeType.AddressType: + return new List(addressTypeCodes); case Sax.CodeType.OpportunityType: return new List(opportunityTypeCodes); case Sax.CodeType.ActivityReaction: diff --git a/SaxoniteStandardBase/Base/Bus/SaxItemAddress.cs b/SaxoniteStandardBase/Base/Bus/SaxItemAddress.cs new file mode 100644 index 0000000..ee2aaf1 --- /dev/null +++ b/SaxoniteStandardBase/Base/Bus/SaxItemAddress.cs @@ -0,0 +1,471 @@ +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Saxonite.Net.Standard.Base.App; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Saxonite.Net.Standard.Base.Bus +{ + //======================================================================= + // ItemAddress. + //======================================================================= + public abstract class SaxItemAddress : SacsHierarchyItem + { + //------------------------------------------------------------------- + // 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, + } + + //------------------------------------------------------------------- + /// Properties other than common. + public class DataProperties + { + public ItemId ItemId { get; set; } + 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; } + public bool LocationUpdateRequired { get; set; } + public String LocationData { get; set; } + public String LocationFormattedAddress { get; set; } + public Decimal LocationLatitude { get; set; } + public Decimal LocationLongitude { get; set; } + public Decimal LocationAltitude { 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.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 { CheckChanged(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 { CheckChanged(data.LocationLatitude, value); data.LocationLatitude = value; } + } + public Decimal LocationLongitude + { + get { return data.LocationLongitude; } + set { CheckChanged(data.LocationLongitude, value); data.LocationLongitude = value; } + } + public Decimal LocationAltitude + { + get { return data.LocationAltitude; } + set { CheckChanged(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 validStatuses = new List() + { + SaStatus.Active, + SaStatus.Inactive, + SaStatus.Deleted, + }; + public static SaStatus DefaultStatus { get { return SaStatus.Active; } } + public static List ValidStatuses { get { return new List(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); + } + + //------------------------------------------------------------------- + // Properties. + public Data GetData() { return data.Clone(); } + public void SetData(Data data) + { + String fn = GetType().Name + ".SetData"; + // Properties that cannot be changed if previously specified. + if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) + throw new NotSupportedException(fn + " Id cannot be changed"); + if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id)) + throw new NotSupportedException(fn + " Item Id cannot be changed"); + if (SysId.IsValid(RegionIdProvince) && SysId.ToInt(RegionIdProvince) != SysId.ToInt(data.RegionIdProvince)) + throw new NotSupportedException(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, + NotDeleted, + ActiveOnly, + InctiveOnly, + } + /// + /// Item list parameters. + /// + public new class Params : SacsHierarchyItem.Params + { + // List filtering. + public List IdsIncluded { get; } = new List(); + public List IdsExcluded { get; } = new List(); + public List ItemIdsIncluded { get; } = new List(); + public String AddressPartial { get; set; } + public String NotesPartial { get; set; } + public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; + } + + //------------------------------------------------------------------- + } + //======================================================================= + // Item list extension methods. + public static class SaxItemAddressList + { + } + + //======================================================================= +} diff --git a/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-Organisation.cs b/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-Organisation.cs index cdd2cb5..1f7169b 100644 --- a/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-Organisation.cs +++ b/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-Organisation.cs @@ -155,7 +155,7 @@ namespace Saxonite.Net.Standard.Base.Mgr { if (!ReferenceMgr.SportExistsById(data.SportIdPrimary)) { - errField.Status = SacsHierarchyItem.ValidValue.Invalid; + errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid; return SetErrorState("Invalid sport specified"); } } @@ -163,11 +163,34 @@ namespace Saxonite.Net.Standard.Base.Mgr // Region. if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary)) { - if (!ReferenceMgr.RegionExistsById(data.RegionIdPrimary)) + SaxRegion region = ReferenceMgr.GetRegionById(data.RegionIdPrimary); + if (region == null) { - errField.Status = SacsHierarchyItem.ValidValue.Invalid; + errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid; return SetErrorState("Invalid region specified"); } + if (region.RegionType != App.Sax.RegionType.Country) + { + errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid; + return SetErrorState("Region must be a country"); + } + } + + // 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"); + } } } diff --git a/SaxoniteStandardBase/Base/Mgr/SaxItemDataMgr-ItemAddress.cs b/SaxoniteStandardBase/Base/Mgr/SaxItemDataMgr-ItemAddress.cs new file mode 100644 index 0000000..c0ac32c --- /dev/null +++ b/SaxoniteStandardBase/Base/Mgr/SaxItemDataMgr-ItemAddress.cs @@ -0,0 +1,259 @@ +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); + } + + //------------------------------------------------------------------- + // 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(); + + //--------------------------------------------------------------- + // 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), true)) + { + 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), true)) + { + 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.Status != SaStatus.Deleted) + { + // 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 GetItemAddressQueryFilter(SaxItemAddress.Params prmItemAddress); + public abstract long GetItemAddressCount(SaxItemAddress.Params prmItemAddress); + public abstract List GetItemAddressList(SaxItemAddress.Params prmItemAddress); + public abstract DbResultSet ExecuteItemAddressQuery(List columns, SaxItemAddress.Params prmItemAddress); + + //------------------------------------------------------------------- + /// + /// Extract and format result set data value where specific handling is required. + /// Where response is an invalid data value, format value using column.FormatValue(values). + /// + 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; + + //----------------------------------------------------------- + } + return value; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs b/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs index ef51915..4e20120 100644 --- a/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs +++ b/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs @@ -74,6 +74,7 @@ namespace Saxonite.Net.Standard.Base.Mgr public List OrganisationTypeCodes { get { return Internals.OrganisationTypeCodes; } } public List OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } } public List OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } } + public List AddressTypeCodes { get { return Internals.AddressTypeCodes; } } public List OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } } public List ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } } diff --git a/SaxoniteStandardDbas/Dbas/Bus/SaxItemAddress_Dbas.cs b/SaxoniteStandardDbas/Dbas/Bus/SaxItemAddress_Dbas.cs new file mode 100644 index 0000000..72b44c1 --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Bus/SaxItemAddress_Dbas.cs @@ -0,0 +1,33 @@ +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Dbas; +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.Dbas.Bus +{ + //======================================================================= + public class SaxItemAddress_Dbas : SaxItemAddress + { + //------------------------------------------------------------------- + // Data members. + private ISacsDatabase database; + + //------------------------------------------------------------------- + // Construction. + public SaxItemAddress_Dbas(ISacsDatabase database, SysId id, ItemId itemId, Sax.AddressType addressType, UInt16 flags) : + base(id, itemId, addressType) + { + this.database = database; + Flags = flags; + } + + //------------------------------------------------------------------- + // Associated data. + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardDbas/Dbas/Internal/ActivityIndex_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ActivityIndex_Db.cs index 6096ba5..0616da3 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ActivityIndex_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ActivityIndex_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/ItemAddress_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ItemAddress_Db.cs new file mode 100644 index 0000000..d6db65b --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Internal/ItemAddress_Db.cs @@ -0,0 +1,332 @@ +using Microsoft.Data.SqlClient; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Utils; +using Saxonite.Net.Standard.Dbas.Data; +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Linq; + +//--------------------------------------------------------------------------- +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 +//--------------------------------------------------------------------------- +namespace Saxonite.Net.Standard.Dbas.Internal +{ + internal class ItemAddress_Db : SaxDbDataItem + { + //------------------------------------------------------------------- + // Column definitions. + public class ColumnsData + { + public ColumnDataInt64 _Id { get; } = new ColumnDataInt64("Id", true); + public ColumnDataInt16 _ItemType { get; } = new ColumnDataInt16("ItemType"); + public ColumnDataInt32 _ItemId { get; } = new ColumnDataInt32("ItemId"); + public ColumnDataInt16 _AddressType { get; } = new ColumnDataInt16("AddressType"); + public ColumnDataString _Caption { get; } = new ColumnDataString("Caption"); + public ColumnDataString _Line1 { get; } = new ColumnDataString("Line1"); + public ColumnDataString _Line2 { get; } = new ColumnDataString("Line2"); + public ColumnDataString _Line3 { get; } = new ColumnDataString("Line3"); + public ColumnDataString _Town { get; } = new ColumnDataString("Town"); + public ColumnDataString _Province { get; } = new ColumnDataString("Province"); + public ColumnDataInt32 _RegionIdProvince { get; } = new ColumnDataInt32("RegionIdProvince"); + public ColumnDataString _Country { get; } = new ColumnDataString("Country"); + public ColumnDataInt32 _RegionIdCountry { get; } = new ColumnDataInt32("RegionIdCountry"); + public ColumnDataString _PostalCode { get; } = new ColumnDataString("PostalCode"); + public ColumnDataString _PhoneMain { get; } = new ColumnDataString("PhoneMain"); + public ColumnDataString _LocationSource { get; } = new ColumnDataString("LocationSource"); + public ColumnDataDateTime _LocationStoredAt { get; } = new ColumnDataDateTime("LocationStoredAt"); + public ColumnDataBoolean _LocationUpdateRequired { get; } = new ColumnDataBoolean("LocationUpdateRequired"); + public ColumnDataString _LocationData { get; } = new ColumnDataString("LocationData"); + public ColumnDataString _LocationFormattedAddress { get; } = new ColumnDataString("LocationFormattedAddress"); + public ColumnDataDecimal _LocationLatitude { get; } = new ColumnDataDecimal("LocationLatitude"); + public ColumnDataDecimal _LocationLongitude { get; } = new ColumnDataDecimal("LocationLongitude"); + public ColumnDataDecimal _LocationAltitude { get; } = new ColumnDataDecimal("LocationAltitude"); + public ColumnDataString _Notes { get; } = new ColumnDataString("Notes"); + public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags"); + public ColumnDataString _Status { get; } = new ColumnDataString("Status"); + public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn"); + public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy"); + public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost"); + public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn"); + public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy"); + public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost"); + } + + //------------------------------------------------------------------- + // Data members. + protected static List fields { get; } = new List() + { + "Id", + "ItemType", + "ItemId", + "AddressType", + "Caption", + "Line1", + "Line2", + "Line3", + "Town", + "Province", + "RegionIdProvince", + "Country", + "RegionIdCountry", + "PostalCode", + "PhoneMain", + "LocationSource", + "LocationStoredAt", + "LocationUpdateRequired", + "LocationData", + "LocationFormattedAddress", + "LocationLatitude", + "LocationLongitude", + "LocationAltitude", + "Notes", + "Flags", + "Status", + "CreateOn", + "CreateBy", + "CreateHost", + "UpdateOn", + "UpdateBy", + "UpdateHost", + }; + protected static List fieldsId { get; } = new List() + { + "Id", + }; + protected static List fieldsPrimary { get; } = new List() + { + "Id", + }; + protected static List fieldsIgnoreOnUpdate { get; } = new List() + { + "CreateOn", + "CreateBy", + "CreateHost", + }; + + //------------------------------------------------------------------- + // Construction. + internal ItemAddress_Db (IDatabaseInfo dbInfo) : base(dbInfo) + { + } + + //------------------------------------------------------------------- + // Properties. + public override String SchemaName { get; } = "dbo"; + public override String TableName { get; } = "ItemAddress"; + public String TableNameFmt { get { return (!String.IsNullOrEmpty(SchemaName) ? "[" + SchemaName + "]." : "") + "[" + TableName + "]"; } } + public static List Fields { get { return new List(fields); } } + public static List FieldsId { get { return new List(fieldsId); } } + public static List FieldsNonId { get { return fields.FindAll(item => !fieldsId.ContainsCI(item)); } } + // Columns. + public ColumnsData Cols { get; } = new ColumnsData(); + public Int64 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } } + public Int16 _ItemType { get { return Cols._ItemType.Value; } set { Cols._ItemType.Value = value; } } + public Int32 _ItemId { get { return Cols._ItemId.Value; } set { Cols._ItemId.Value = value; } } + public Int16 _AddressType { get { return Cols._AddressType.Value; } set { Cols._AddressType.Value = value; } } + public String _Caption { get { return Cols._Caption.Value; } set { Cols._Caption.Value = value; } } + public String _Line1 { get { return Cols._Line1.Value; } set { Cols._Line1.Value = value; } } + public String _Line2 { get { return Cols._Line2.Value; } set { Cols._Line2.Value = value; } } + public String _Line3 { get { return Cols._Line3.Value; } set { Cols._Line3.Value = value; } } + public String _Town { get { return Cols._Town.Value; } set { Cols._Town.Value = value; } } + public String _Province { get { return Cols._Province.Value; } set { Cols._Province.Value = value; } } + public Int32 _RegionIdProvince { get { return Cols._RegionIdProvince.Value; } set { Cols._RegionIdProvince.Value = value; } } + public String _Country { get { return Cols._Country.Value; } set { Cols._Country.Value = value; } } + public Int32 _RegionIdCountry { get { return Cols._RegionIdCountry.Value; } set { Cols._RegionIdCountry.Value = value; } } + public String _PostalCode { get { return Cols._PostalCode.Value; } set { Cols._PostalCode.Value = value; } } + public String _PhoneMain { get { return Cols._PhoneMain.Value; } set { Cols._PhoneMain.Value = value; } } + public String _LocationSource { get { return Cols._LocationSource.Value; } set { Cols._LocationSource.Value = value; } } + public DateTime _LocationStoredAt { get { return Cols._LocationStoredAt.Value; } set { Cols._LocationStoredAt.Value = value; } } + public Boolean _LocationUpdateRequired { get { return Cols._LocationUpdateRequired.Value; } set { Cols._LocationUpdateRequired.Value = value; } } + public String _LocationData { get { return Cols._LocationData.Value; } set { Cols._LocationData.Value = value; } } + public String _LocationFormattedAddress { get { return Cols._LocationFormattedAddress.Value; } set { Cols._LocationFormattedAddress.Value = value; } } + public Decimal _LocationLatitude { get { return Cols._LocationLatitude.Value; } set { Cols._LocationLatitude.Value = value; } } + public Decimal _LocationLongitude { get { return Cols._LocationLongitude.Value; } set { Cols._LocationLongitude.Value = value; } } + public Decimal _LocationAltitude { get { return Cols._LocationAltitude.Value; } set { Cols._LocationAltitude.Value = value; } } + public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } } + public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } } + public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } } + public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } } + public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } } + public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } } + public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } } + public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } } + public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } } + // Existing columns - confirmed on database if table exists. + public List ExistingColumnNames { get { return GetExistingColumnNames(Fields); } } + public List ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } } + + //------------------------------------------------------------------- + // Population. + public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter) + { + dbCommand.CommandText = + "SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " + + "FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " + + (!String.IsNullOrEmpty(filter) ? "WHERE " + filter : ""); + Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText); + using (DbDataReader dbDataReader = dbCommand.ExecuteReader()) + { + dbDataReader.Read(); + PopulateFrom(dbDataReader); + } + } + public override void PopulateFrom (DbDataReader dbDataReader) + { + _Id = GetFieldInt64(dbDataReader, "Id", _Id); + _ItemType = GetFieldInt16(dbDataReader, "ItemType", _ItemType); + _ItemId = GetFieldInt32(dbDataReader, "ItemId", _ItemId); + _AddressType = GetFieldInt16(dbDataReader, "AddressType", _AddressType); + _Caption = GetFieldString(dbDataReader, "Caption", _Caption); + _Line1 = GetFieldString(dbDataReader, "Line1", _Line1); + _Line2 = GetFieldString(dbDataReader, "Line2", _Line2); + _Line3 = GetFieldString(dbDataReader, "Line3", _Line3); + _Town = GetFieldString(dbDataReader, "Town", _Town); + _Province = GetFieldString(dbDataReader, "Province", _Province); + _RegionIdProvince = GetFieldInt32(dbDataReader, "RegionIdProvince", _RegionIdProvince); + _Country = GetFieldString(dbDataReader, "Country", _Country); + _RegionIdCountry = GetFieldInt32(dbDataReader, "RegionIdCountry", _RegionIdCountry); + _PostalCode = GetFieldString(dbDataReader, "PostalCode", _PostalCode); + _PhoneMain = GetFieldString(dbDataReader, "PhoneMain", _PhoneMain); + _LocationSource = GetFieldString(dbDataReader, "LocationSource", _LocationSource); + _LocationStoredAt = GetFieldDateTime(dbDataReader, "LocationStoredAt", _LocationStoredAt); + _LocationUpdateRequired = GetFieldBoolean(dbDataReader, "LocationUpdateRequired", _LocationUpdateRequired); + _LocationData = GetFieldString(dbDataReader, "LocationData", _LocationData); + _LocationFormattedAddress = GetFieldString(dbDataReader, "LocationFormattedAddress", _LocationFormattedAddress); + _LocationLatitude = GetFieldDecimal(dbDataReader, "LocationLatitude", _LocationLatitude); + _LocationLongitude = GetFieldDecimal(dbDataReader, "LocationLongitude", _LocationLongitude); + _LocationAltitude = GetFieldDecimal(dbDataReader, "LocationAltitude", _LocationAltitude); + _Notes = GetFieldString(dbDataReader, "Notes", _Notes); + _Flags = GetFieldInt16(dbDataReader, "Flags", _Flags); + _Status = GetFieldString(dbDataReader, "Status", _Status); + _CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn); + _CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy); + _CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost); + _UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn); + _UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy); + _UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost); + } + + //------------------------------------------------------------------- + // Insert command. + public override bool ExecuteInsertCommand (DbCommand dbCommand) + { + List columnNames = ExistingColumnNamesNonId; + // Avoid insert if Identity field is already valid. + if (_Id != 0) throw new Exception("Invalid for Insert - item already has a valid Id"); + // Construct query. + String query = + "INSERT INTO " + TableNameFmt + " " + + "("+columnNames.Concat(",","[","]")+") "; + query += "Output Inserted.Id "; + if (dbCommand is SqlCommand) + query += "VALUES (" + columnNames.Concat(",", "@", "") + ") "; + else query += "VALUES (" + StringListUtil.CreateList("?", columnNames.Count).Concat(",") + ") "; + dbCommand.CommandText = query; + Log(GetType().Name + ".ExecuteInsertCommand", dbCommand.CommandText); + // Populate parameters. + dbCommand.Parameters.Clear(); + if (columnNames.ContainsCI("ItemType")) AddCommandParameter(dbCommand, "@ItemType", _ItemType); + if (columnNames.ContainsCI("ItemId")) AddCommandParameter(dbCommand, "@ItemId", _ItemId); + if (columnNames.ContainsCI("AddressType")) AddCommandParameter(dbCommand, "@AddressType", _AddressType); + if (columnNames.ContainsCI("Caption")) AddCommandParameter(dbCommand, "@Caption", _Caption); + if (columnNames.ContainsCI("Line1")) AddCommandParameter(dbCommand, "@Line1", _Line1); + if (columnNames.ContainsCI("Line2")) AddCommandParameter(dbCommand, "@Line2", _Line2); + if (columnNames.ContainsCI("Line3")) AddCommandParameter(dbCommand, "@Line3", _Line3); + if (columnNames.ContainsCI("Town")) AddCommandParameter(dbCommand, "@Town", _Town); + if (columnNames.ContainsCI("Province")) AddCommandParameter(dbCommand, "@Province", _Province); + if (columnNames.ContainsCI("RegionIdProvince")) AddCommandParameter(dbCommand, "@RegionIdProvince", _RegionIdProvince); + if (columnNames.ContainsCI("Country")) AddCommandParameter(dbCommand, "@Country", _Country); + if (columnNames.ContainsCI("RegionIdCountry")) AddCommandParameter(dbCommand, "@RegionIdCountry", _RegionIdCountry); + if (columnNames.ContainsCI("PostalCode")) AddCommandParameter(dbCommand, "@PostalCode", _PostalCode); + if (columnNames.ContainsCI("PhoneMain")) AddCommandParameter(dbCommand, "@PhoneMain", _PhoneMain); + if (columnNames.ContainsCI("LocationSource")) AddCommandParameter(dbCommand, "@LocationSource", _LocationSource); + if (columnNames.ContainsCI("LocationStoredAt")) AddCommandParameter(dbCommand, "@LocationStoredAt", _LocationStoredAt); + if (columnNames.ContainsCI("LocationUpdateRequired")) AddCommandParameter(dbCommand, "@LocationUpdateRequired", _LocationUpdateRequired); + if (columnNames.ContainsCI("LocationData")) AddCommandParameter(dbCommand, "@LocationData", _LocationData); + if (columnNames.ContainsCI("LocationFormattedAddress")) AddCommandParameter(dbCommand, "@LocationFormattedAddress", _LocationFormattedAddress); + if (columnNames.ContainsCI("LocationLatitude")) AddCommandParameter(dbCommand, "@LocationLatitude", _LocationLatitude); + if (columnNames.ContainsCI("LocationLongitude")) AddCommandParameter(dbCommand, "@LocationLongitude", _LocationLongitude); + if (columnNames.ContainsCI("LocationAltitude")) AddCommandParameter(dbCommand, "@LocationAltitude", _LocationAltitude); + if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes); + if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags); + if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status); + if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn); + if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy); + if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost); + if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn); + if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy); + if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost); + // Execute insert command. + bool commandSuccess = false; + int executeNonQuery = dbCommand.ExecuteNonQuery(); + if (executeNonQuery == 1) + { + dbCommand.CommandText = "SELECT Max(Id) FROM " + TableNameFmt + ";"; + _Id = Convert.ToInt64(dbCommand.ExecuteScalar()); + commandSuccess = (_Id > 0); + } + return commandSuccess; + } + + //------------------------------------------------------------------- + // Update command. + public override bool ExecuteUpdateCommand (DbCommand dbCommand) + { + // Avoid update if Identity field isn't valid. + if (_Id == 0) throw new Exception("Invalid for Update - item has an invalid Id"); + // Columns to update. + List columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); + // Construct query. + String query = "UPDATE " + TableNameFmt + " SET "; + if (dbCommand is SqlCommand) + { + query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " "; + query += "WHERE Id=@Id;"; + } + else + { + query += columnNames.Concat(", ", "", "=?") + " "; + query += "WHERE Id=?;"; + } + dbCommand.CommandText = query; + Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText); + // Populate parameters. + dbCommand.Parameters.Clear(); + if (columnNames.ContainsCI("ItemType")) AddCommandParameter(dbCommand, "@ItemType", _ItemType); + if (columnNames.ContainsCI("ItemId")) AddCommandParameter(dbCommand, "@ItemId", _ItemId); + if (columnNames.ContainsCI("AddressType")) AddCommandParameter(dbCommand, "@AddressType", _AddressType); + if (columnNames.ContainsCI("Caption")) AddCommandParameter(dbCommand, "@Caption", _Caption); + if (columnNames.ContainsCI("Line1")) AddCommandParameter(dbCommand, "@Line1", _Line1); + if (columnNames.ContainsCI("Line2")) AddCommandParameter(dbCommand, "@Line2", _Line2); + if (columnNames.ContainsCI("Line3")) AddCommandParameter(dbCommand, "@Line3", _Line3); + if (columnNames.ContainsCI("Town")) AddCommandParameter(dbCommand, "@Town", _Town); + if (columnNames.ContainsCI("Province")) AddCommandParameter(dbCommand, "@Province", _Province); + if (columnNames.ContainsCI("RegionIdProvince")) AddCommandParameter(dbCommand, "@RegionIdProvince", _RegionIdProvince); + if (columnNames.ContainsCI("Country")) AddCommandParameter(dbCommand, "@Country", _Country); + if (columnNames.ContainsCI("RegionIdCountry")) AddCommandParameter(dbCommand, "@RegionIdCountry", _RegionIdCountry); + if (columnNames.ContainsCI("PostalCode")) AddCommandParameter(dbCommand, "@PostalCode", _PostalCode); + if (columnNames.ContainsCI("PhoneMain")) AddCommandParameter(dbCommand, "@PhoneMain", _PhoneMain); + if (columnNames.ContainsCI("LocationSource")) AddCommandParameter(dbCommand, "@LocationSource", _LocationSource); + if (columnNames.ContainsCI("LocationStoredAt")) AddCommandParameter(dbCommand, "@LocationStoredAt", _LocationStoredAt); + if (columnNames.ContainsCI("LocationUpdateRequired")) AddCommandParameter(dbCommand, "@LocationUpdateRequired", _LocationUpdateRequired); + if (columnNames.ContainsCI("LocationData")) AddCommandParameter(dbCommand, "@LocationData", _LocationData); + if (columnNames.ContainsCI("LocationFormattedAddress")) AddCommandParameter(dbCommand, "@LocationFormattedAddress", _LocationFormattedAddress); + if (columnNames.ContainsCI("LocationLatitude")) AddCommandParameter(dbCommand, "@LocationLatitude", _LocationLatitude); + if (columnNames.ContainsCI("LocationLongitude")) AddCommandParameter(dbCommand, "@LocationLongitude", _LocationLongitude); + if (columnNames.ContainsCI("LocationAltitude")) AddCommandParameter(dbCommand, "@LocationAltitude", _LocationAltitude); + if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes); + if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags); + if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status); + if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn); + if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy); + if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost); + AddCommandParameter(dbCommand, "@Id", _Id); + int executeNonQueryResult = dbCommand.ExecuteNonQuery(); + return (executeNonQueryResult == 1); + } + + //------------------------------------------------------------------- + } +} diff --git a/SaxoniteStandardDbas/Dbas/Internal/ItemImage_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ItemImage_Db.cs index db07298..a180d4e 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ItemImage_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ItemImage_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/ItemSport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ItemSport_Db.cs index b44fee5..86b86c7 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ItemSport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ItemSport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/JournalistArticle_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/JournalistArticle_Db.cs index 7b347a3..8ea7ff7 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/JournalistArticle_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/JournalistArticle_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/OrganisationOpportunity_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/OrganisationOpportunity_Db.cs index 9c9b334..1b1b171 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/OrganisationOpportunity_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/OrganisationOpportunity_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Organisation_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Organisation_Db.cs index f0fb41e..47e86ad 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Organisation_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Organisation_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Region_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Region_Db.cs index 2b52b7e..725fc0e 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Region_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Region_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Sport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Sport_Db.cs index e57d044..2736a33 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Sport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Sport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserAccount_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserAccount_Db.cs index 89042fa..3e27bd9 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserAccount_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserAccount_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserActivity_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserActivity_Db.cs index a8fa07d..d266aec 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserActivity_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserActivity_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserOrganisation_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserOrganisation_Db.cs index a863ec2..47321ac 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserOrganisation_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserOrganisation_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserRole_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserRole_Db.cs index 02bffe4..4365f5a 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserRole_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserRole_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserSession_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserSession_Db.cs index 13af9b5..7c5c541 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserSession_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserSession_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserSport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserSport_Db.cs index 229f99a..778d508 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserSport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserSport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Tue 22-Jun-2021 08:56:11 +// Code generated by Sarand Database Utilities Fri 2-Jul-2021 07:46:23 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Mgr/SaxItemDataMgr_Dbas-ItemAddress.cs b/SaxoniteStandardDbas/Dbas/Mgr/SaxItemDataMgr_Dbas-ItemAddress.cs new file mode 100644 index 0000000..f828b17 --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Mgr/SaxItemDataMgr_Dbas-ItemAddress.cs @@ -0,0 +1,598 @@ +using Sarand.Net.Standard.Dbas.Data; +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.Dbas.Bus; +using Saxonite.Net.Standard.Dbas.Internal; +using Saxonite.Net.Standard.Base.Bus; +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Text; +using Saxonite.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Utils; + +namespace Saxonite.Net.Standard.Dbas.Mgr +{ + //======================================================================= + partial class SaxItemDataMgr_Dbas + { + //******************************************************************* + // Item Data Mgr - Item Address + //******************************************************************* + // Utilities. + private List GetLogProperties(SaxItemAddress itemAddress) + { + return new List() + { + new StringPair("Id",SysId.ToString(itemAddress.Id)), + new StringPair("ItemId", (Sax.DataItemType)itemAddress.ItemId.Type + ": " + itemAddress.ItemId.Id), + new StringPair("Town",itemAddress.Town), + new StringPair("PostalCode",itemAddress.PostalCode), + new StringPair("Status",itemAddress.StatusCode) + }; + } + + //------------------------------------------------------------------- + // Create item. + public override SaxItemAddress CreateItemAddress(ItemId itemId, Sax.AddressType addressType) + { + ClearErrorState(); + return new SaxItemAddress_Dbas(CoreDatabase, null, itemId, addressType, 0); + } + private SaxItemAddress_Dbas CreateItemAddress(ItemAddress_Db dbItemAddress) + { + ClearErrorState(); + ItemId itemId = new ItemId(dbItemAddress._ItemType, new SysId(dbItemAddress._ItemId)); + SaxItemAddress_Dbas itemAddress = new SaxItemAddress_Dbas(CoreDatabase, new SysId(dbItemAddress._Id), itemId, (Sax.AddressType)dbItemAddress._AddressType, (ushort)dbItemAddress._Flags); + PopulateFrom(dbItemAddress, itemAddress); + return itemAddress; + } + + //------------------------------------------------------------------- + // Get item. + public override SaxItemAddress GetItemAddress(SaxItemAddress.Params prm) + { + ClearErrorState(); + return GetItemAddress(GetItemAddressQueryFilter(prm).Concat(" And ", "(", ")")); + } + private SaxItemAddress GetItemAddress(String filter) + { + ClearErrorState(); + long count = GetItemAddressCount(filter); + if (count == 0) return null; + if (count != 1) + { + SetErrorState("Multiple items found"); + return null; + } + SaxItemAddress itemAddress = null; + // Query data. + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + dbConnection.Open(); + ItemAddress_Db dbItemAddress = new ItemAddress_Db(CoreDbInfo); + dbItemAddress.PopulateFrom(dbCommand, aliasItemAddress, filter); + itemAddress = CreateItemAddress(dbItemAddress); + } + catch (Exception exc) + { + SetErrorState("Database query exception"); + SaLogger.Warn(GetType().Name + ".GetItemAddress\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc)); + } + } + return itemAddress; + } + + //------------------------------------------------------------------- + // Validate item. + public override bool IsValidItemAddressData(SaxItemAddress.Data data, SaxItemAddress.ErrField errField) + { + ClearErrorState(); + if (!base.IsValidItemAddressData(data, errField)) return false; + return true; + } + + //------------------------------------------------------------------- + // Insert item. + public override bool InsertItemAddress(SaxItemAddress itemAddress, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".InsertItemAddress"; + ClearErrorState(); + if (!IsValidItemAddress(itemAddress)) return false; + if (SysId.IsValid(itemAddress.Id)) return SetErrorState(ErrorMessage.ValiditemId); + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + dbConnection.Open(); + ItemAddress_Db dbItemAddress = new ItemAddress_Db(CoreDbInfo); + PopulateTo(dbItemAddress, itemAddress, dbUpdateInfo); + if (ItemAddress_Db.FieldsNonId.Contains("Id")) + { + // Generate next Id. + dbItemAddress._Id = CoreDatabase.GetNextIdFromTable("ItemAddress"); + } + dbItemAddress.ExecuteInsertCommand(dbCommand); + itemAddress.Id = new SysId(dbItemAddress._Id); + itemAddress.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(itemAddress).Concat(": ").Concat("", "\n\t")); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Update item. + public override bool UpdateItemAddress(SaxItemAddress itemAddress, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".UpdateItemAddress"; + ClearErrorState(); + if (!IsValidItemAddress(itemAddress)) return false; + if (!SysId.IsValid(itemAddress.Id)) return SetErrorState(ErrorMessage.InvalidItemId); + if (!itemAddress.Changed) + { + if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(itemAddress).Concat(": ").Concat("", "\n\t")); + return true; + } + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + // Retrieve item. + dbConnection.Open(); + ItemAddress_Db dbItemAddress = new ItemAddress_Db(CoreDbInfo); + dbItemAddress.PopulateFrom(dbCommand, aliasItemAddress, "Id=" + SysId.ToString(itemAddress.Id)); + // ToDo SaxUpdateLogItemMonitor_ItemAddress updateLogMonitor = new SaxUpdateLogItemMonitor_ItemAddress(SessionContext, CreateItemAddress(dbItemAddress), dbUpdateInfo); + // Update properties. + PopulateTo(dbItemAddress, itemAddress, dbUpdateInfo); + dbItemAddress.ExecuteUpdateCommand(dbCommand); + itemAddress.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(itemAddress).Concat(": ").Concat("", "\n\t")); + // Record updates. + // ToDo updateLogMonitor.RecordUpdatedValues(itemAddress); + // ToDo updateLogMonitor.LogUpdates(); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Delete item. + public override bool ItemAddressCanBeDeleted(SaxItemAddress itemAddress) + { + ClearErrorState(); + if (!base.ItemAddressCanBeDeleted(itemAddress)) return false; + return true; + } + public override bool DeleteItemAddress(SaxItemAddress itemAddress, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".DeleteItemAddress"; + ClearErrorState(); + if (!ItemAddressCanBeDeleted(itemAddress)) return false; + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + // Retrieve itemAddress. + dbConnection.Open(); + ItemAddress_Db dbItemAddress = new ItemAddress_Db(CoreDbInfo); + dbItemAddress.PopulateFrom(dbCommand, aliasItemAddress, "Id=" + itemAddress.Id.ToString()); + // Delete itemAddress. + dbCommand.CommandType = System.Data.CommandType.Text; + dbCommand.CommandText = "DELETE FROM " + SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.ItemAddress) + " WHERE Id=" + SysId.ToString(itemAddress.Id) + ";"; + dbCommand.ExecuteNonQuery(); + itemAddress.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(itemAddress).Concat(": ").Concat("", "\n\t")); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Copy data properties to and from database. + private void PopulateTo(ItemAddress_Db dbItemAddress, SaxItemAddress itemAddress, DbUpdateInfo dbUpdateInfo) + { + dbItemAddress._Id = SysId.ToLong(itemAddress.Id); + dbItemAddress._ItemType = itemAddress.ItemId.Type; + dbItemAddress._ItemId = SysId.ToInt(itemAddress.ItemId.Id); + dbItemAddress._AddressType = (short)itemAddress.AddressType; + dbItemAddress._Caption = itemAddress.Caption; + dbItemAddress._Line1 = itemAddress.Line1; + dbItemAddress._Line2 = itemAddress.Line2; + dbItemAddress._Line3 = itemAddress.Line3; + dbItemAddress._Town = itemAddress.Town; + dbItemAddress._Province = itemAddress.Province; + dbItemAddress._RegionIdProvince = SysId.ToInt(itemAddress.RegionIdProvince); + dbItemAddress._Country = itemAddress.Country; + dbItemAddress._RegionIdCountry = SysId.ToInt(itemAddress.RegionIdCountry); + // Location. + dbItemAddress._LocationSource = itemAddress.LocationSource; + dbItemAddress._LocationStoredAt = itemAddress.LocationStoredAt; + dbItemAddress._LocationUpdateRequired = itemAddress.LocationUpdateRequired; + dbItemAddress._LocationData = itemAddress.LocationData; + dbItemAddress._LocationFormattedAddress = itemAddress.LocationFormattedAddress; + dbItemAddress._LocationLatitude = itemAddress.LocationLatitude; + dbItemAddress._LocationLongitude = itemAddress.LocationLongitude; + dbItemAddress._LocationAltitude = itemAddress.LocationAltitude; + // Common. + dbItemAddress._Notes = itemAddress.Notes; + dbItemAddress._Status = SacsSystem.GetStatusCode(itemAddress.Status); + dbItemAddress._Flags = (short)itemAddress.Flags; + if (!SysId.IsValid(itemAddress.Id)) + { + dbItemAddress._CreateOn = DateTime.Now; + dbItemAddress._CreateBy = dbUpdateInfo.UserId.ToInt(); + dbItemAddress._CreateHost = dbUpdateInfo.Host; + } + dbItemAddress._UpdateOn = DateTime.Now; + dbItemAddress._UpdateBy = dbUpdateInfo.UserId.ToInt(); + dbItemAddress._UpdateHost = dbUpdateInfo.Host; + } + private void PopulateFrom(ItemAddress_Db dbItemAddress, SaxItemAddress itemAddress) + { + //itemAddress.Id = new SysId(dbItemAddress._Id); + //itemAddress.ItemId = new ItemId(dbItemAddress._ItemType, new SysId(dbItemAddress._ItemId)); + itemAddress.AddressType = (Sax.AddressType)dbItemAddress._AddressType; + itemAddress.Caption = dbItemAddress._Caption; + itemAddress.Line1 = dbItemAddress._Line1; + itemAddress.Line2 = dbItemAddress._Line2; + itemAddress.Line3 = dbItemAddress._Line3; + itemAddress.Town = dbItemAddress._Town; + itemAddress.Province = dbItemAddress._Province; + itemAddress.RegionIdProvince = new SysId(dbItemAddress._RegionIdProvince); + itemAddress.Country = dbItemAddress._Country; + itemAddress.RegionIdCountry = new SysId(dbItemAddress._RegionIdCountry); + // Location. + itemAddress.LocationSource = dbItemAddress._LocationSource; + itemAddress.LocationStoredAt = dbItemAddress._LocationStoredAt; + itemAddress.LocationUpdateRequired = dbItemAddress._LocationUpdateRequired; + itemAddress.LocationData = dbItemAddress._LocationData; + itemAddress.LocationFormattedAddress = dbItemAddress._LocationFormattedAddress; + itemAddress.LocationLatitude = dbItemAddress._LocationLatitude; + itemAddress.LocationLongitude = dbItemAddress._LocationLongitude; + itemAddress.LocationAltitude = dbItemAddress._LocationAltitude; + // Common. + itemAddress.Notes = dbItemAddress._Notes; + itemAddress.Status = SacsSystem.GetStatusForCode(dbItemAddress._Status); + itemAddress.SetCreateStamp(dbItemAddress._CreateOn, new SysId(dbItemAddress._CreateBy), dbItemAddress._CreateHost); + itemAddress.SetUpdateStamp(dbItemAddress._UpdateOn, new SysId(dbItemAddress._UpdateBy), dbItemAddress._UpdateHost); + itemAddress.AcceptChanges(); + } + + //------------------------------------------------------------------- + // Item column definitions. + private static readonly String aliasItemAddress = "ItmSpt"; + private void SetItemAddressColDfn + (ColumnDfn col, String caption, int width, SaxDbDfn_Core.ColumnIdx dbCol, + ColumnAlignment align = ColumnAlignment.Default, DataValue.DataType dataType = DataValue.DataType.String, + String alias = "", String prefix = "") + { + if (String.IsNullOrEmpty(alias) && SaxDbDfn_Core.GetTableForColumn(dbCol) == SaxDbDfn_Core.TableIdx.ItemAddress) + alias = aliasItemAddress; + col.Set(caption, width, (int)dbCol, prefix + SaxDbDfn_Core.GetColumnName(dbCol, false), SaxDbDfn_Core.GetColumnNameQual(dbCol, alias), dataType, align); + if (dataType == DataValue.DataType.String && dbCol != SaxDbDfn_Core.ColumnIdx.Unknown) + col.MaxLength = (int)SaxDbDfn_Core.GetColTextLen(dbCol); + } + public override ColumnDfn GetItemAddressColumnDfn(SaxItemAddress.Column columnId, string caption = "", int width = 0) + { + ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width); + switch (columnId) + { + //----------------------------------------------------------- + case SaxItemAddress.Column.Pos: + SetItemAddressColDfn(columnDfn, "Pos", 60, SaxDbDfn_Core.ColumnIdx.Unknown, ColumnAlignment.Right); + columnDfn.SortMode = ColumnDfn.ColumnSortMode.Off; + columnDfn.ReadOnly = true; + columnDfn.Resizable = false; + break; + case SaxItemAddress.Column.Id: + SetItemAddressColDfn(columnDfn, "Id", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_Id, ColumnAlignment.Right, DataValue.DataType.Long); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.ItemType: + SetItemAddressColDfn(columnDfn, "Item type", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_ItemType, ColumnAlignment.Center, DataValue.DataType.Long); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.ItemType_Code: + SetItemAddressColDfn(columnDfn, "Item type", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_ItemType, ColumnAlignment.Center); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.ItemType_Desc: + SetItemAddressColDfn(columnDfn, "Item type", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_ItemType, ColumnAlignment.Center); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.ItemId: + SetItemAddressColDfn(columnDfn, "Item Id", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_ItemId, ColumnAlignment.Right, DataValue.DataType.Long); + columnDfn.ReadOnly = true; + break; + + //----------------------------------------------------------- + // Address properties. + case SaxItemAddress.Column.Caption: + SetItemAddressColDfn(columnDfn, "Caption", 120, SaxDbDfn_Core.ColumnIdx.ItemAddress_Caption, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.Line1: + SetItemAddressColDfn(columnDfn, "Line1", 120, SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.Line2: + SetItemAddressColDfn(columnDfn, "Line2", 120, SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.Line3: + SetItemAddressColDfn(columnDfn, "Line3", 120, SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.Town: + SetItemAddressColDfn(columnDfn, "Town", 100, SaxDbDfn_Core.ColumnIdx.ItemAddress_Town, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.Province: + SetItemAddressColDfn(columnDfn, "Province", 100, SaxDbDfn_Core.ColumnIdx.ItemAddress_Province, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.Country: + SetItemAddressColDfn(columnDfn, "Country", 100, SaxDbDfn_Core.ColumnIdx.ItemAddress_Country, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.PostalCode: + SetItemAddressColDfn(columnDfn, "PostalCode", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.PhoneMain: + SetItemAddressColDfn(columnDfn, "PhoneMain", 100, SaxDbDfn_Core.ColumnIdx.ItemAddress_PhoneMain, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + + //----------------------------------------------------------- + // Location. + + //----------------------------------------------------------- + // Derived properties. + + //----------------------------------------------------------- + // Common properties. + case SaxItemAddress.Column.Notes: + SetItemAddressColDfn(columnDfn, "Notes", 240, SaxDbDfn_Core.ColumnIdx.ItemAddress_Notes); + break; + case SaxItemAddress.Column.Flags: + SetItemAddressColDfn(columnDfn, "Flags", 60, SaxDbDfn_Core.ColumnIdx.ItemAddress_Flags, ColumnAlignment.Center, DataValue.DataType.Long); + break; + case SaxItemAddress.Column.Status: + SetItemAddressColDfn(columnDfn, "Status", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_Status, ColumnAlignment.Center); + break; + case SaxItemAddress.Column.Status_Desc: + SetItemAddressColDfn(columnDfn, "Status", 90, SaxDbDfn_Core.ColumnIdx.ItemAddress_Status, ColumnAlignment.Center); + break; + case SaxItemAddress.Column.Status_Ind: + SetItemAddressColDfn(columnDfn, "Status", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_Status, ColumnAlignment.Center, DataValue.DataType.TriState); + columnDfn.TriStateFormat = ColumnTriStateFormat.Lights; + break; + case SaxItemAddress.Column.CreateOn_Date: + SetItemAddressColDfn(columnDfn, "Created", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_CreateOn, ColumnAlignment.Center, DataValue.DataType.Date); + columnDfn.ReadOnly = true; + break; + case SaxItemAddress.Column.UpdateOn_Date: + SetItemAddressColDfn(columnDfn, "Updated", 80, SaxDbDfn_Core.ColumnIdx.ItemAddress_UpdateOn, ColumnAlignment.Center, DataValue.DataType.Date); + columnDfn.ReadOnly = true; + break; + //----------------------------------------------------------- + } + if (!String.IsNullOrEmpty(caption)) + columnDfn.Caption = caption; + if (width > 0) + columnDfn.Width = width; + return columnDfn; + } + + //------------------------------------------------------------------- + // Item query filter. + public override List GetItemAddressQueryFilter(SaxItemAddress.Params prm) + { + List filter = new List(); + + // Item Ids. + String idsIncluded = prm.IdsIncluded.Concat(","); + if (!idsIncluded.IsEmpty()) + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Id, aliasItemAddress) + " IN (" + idsIncluded + ")"); + String idsExcluded = prm.IdsExcluded.Concat(","); + if (!idsExcluded.IsEmpty()) + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Id, aliasItemAddress) + " NOT IN (" + idsExcluded + ")"); + + // Item Ids. + if (!prm.ItemIdsIncluded.IsEmpty()) + { + List itemIdFilters = new List(); + foreach (ItemId itemId in prm.ItemIdsIncluded) + { + if (!ItemId.IsValid(itemId)) continue; + String itemIdFilter = + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_ItemType, aliasItemAddress) + "=" + itemId.Type + + " AND " + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_ItemId, aliasItemAddress) + "=" + SysId.ToInt(itemId.Id); + itemIdFilters.Add(itemIdFilter); + } + if (!itemIdFilters.IsEmpty()) + filter.Add(itemIdFilters.Concat(" OR ", "(", ")")); + } + + // Notes. + if (!StringUtil.IsEmpty(prm.NotesPartial)) + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Notes, aliasItemAddress) + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'"); + + // Status. + if (prm.StatusCat == SaxItemAddress.StatusCat.ActiveOnly) + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Status, aliasItemAddress) + "='" + SacsSystem.GetStatusCode(SaStatus.Active) + "'"); + else if (prm.StatusCat == SaxItemAddress.StatusCat.NotDeleted) + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Status, aliasItemAddress) + "!='" + SacsSystem.GetStatusCode(SaStatus.Deleted) + "'"); + + if (filter.Count < 1) filter.Add("1=1"); + return filter; + } + // Item sort columns. + public List GetItemAddressSortColumns(SaxItemAddress.Params prm) + { + // Sort sequence: + List sortColumnNames = new List(); + foreach (var columnDfn in prm.SortColumns) + { + // Need to ensure correct alias used for ItemAddress columns in case of conflict. + String sortCol = String.Empty; + if (SaxDbDfn_Core.GetTableForColumn((SaxDbDfn_Core.ColumnIdx)columnDfn.DbColumn) == SaxDbDfn_Core.TableIdx.ItemAddress) + { + sortCol = SaxDbDfn_Core.GetColumnNameQual((SaxDbDfn_Core.ColumnIdx)columnDfn.DbColumn, aliasItemAddress); + } + else + { + sortCol = columnDfn.DataName; + if (!StringUtil.IsEmpty(columnDfn.SortDataName)) + sortCol = columnDfn.SortDataName; + } + if (!sortCol.IsEmpty()) + { + DbOrderByNullMode orderByNullMode = DbOrderByNullMode.Default; // eSaOrderByDemoteNulls, eSaOrderByPromoteNulls + sortColumnNames.Add(DbQuery.FormatForOrderBy(sortCol, columnDfn.SortAscending, orderByNullMode).Concat(", ")); + } + } + sortColumnNames.RemoveBlanks(); + if (sortColumnNames.IsEmpty()) + { + // Default sort columns. + sortColumnNames.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Id, aliasItemAddress) + " ASC"); + } + return sortColumnNames; + } + + //------------------------------------------------------------------- + // Item count. + private long GetItemAddressCount(String filter) + { + ClearErrorState(); + return CoreDatabase.GetRowCount(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.ItemAddress) + " As " + aliasItemAddress, filter); + } + public override long GetItemAddressCount(SaxItemAddress.Params prm) + { + ClearErrorState(); + return GetItemAddressCount(GetItemAddressQueryFilter(prm).Concat(" AND ", "(", ")")); + } + + //------------------------------------------------------------------- + // Item list. + public override List GetItemAddressList(SaxItemAddress.Params prm) + { + List itemAddresss = new List(); + DbQuery qry = new DbQuery(CoreDatabase.DbmsType); + qry.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.ItemAddress), aliasItemAddress); + ItemAddress_Db dbItemAddress = new ItemAddress_Db(CoreDbInfo); + qry.Columns.AddRange(dbItemAddress.ExistingColumnNames); + qry.Filters.AddRange(GetItemAddressQueryFilter(prm)); + qry.OrderBy.AddRange(GetItemAddressSortColumns(prm)); + // Query data. + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + dbConnection.Open(); + dbCommand.CommandText = qry.BuildQuery(prm.ResultsPaging); + using (DbDataReader dbDataReader = dbCommand.ExecuteReader()) + { + while (dbDataReader.Read()) + { + dbItemAddress = new ItemAddress_Db(CoreDbInfo); + dbItemAddress.PopulateFrom(dbDataReader); + itemAddresss.Add(CreateItemAddress(dbItemAddress)); + } + } + } + catch (Exception exc) + { + SaLogger.Warn(GetType().Name + ".GetItemAddressList\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc)); + } + } + return itemAddresss; + } + + //------------------------------------------------------------------- + // Item query execution. + public override DbResultSet ExecuteItemAddressQuery(List columns, SaxItemAddress.Params prm) + { + ClearErrorState(); + + //--------------------------------------------------------------------- + // Construct query. + DbQuery query = new DbQuery(CoreDatabase.DbmsType); + query.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.ItemAddress), aliasItemAddress); + + // Add columns as defined in query list. + if (columns.HasId(SaxItemAddress.Column.Id)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Id, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.ItemType) || columns.HasId(SaxItemAddress.Column.ItemType_Code) || columns.HasId(SaxItemAddress.Column.ItemType_Desc)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_ItemType, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.ItemId)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_ItemId, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.AddressType) || columns.HasId(SaxItemAddress.Column.AddressType_Code) || columns.HasId(SaxItemAddress.Column.AddressType_Desc)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_AddressType, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Caption)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Caption, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Line1)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Line2)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Line3)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Town)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Province)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Country)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Country, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.PostalCode)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.PhoneMain)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_PhoneMain, aliasItemAddress)); + // ToDo Address Location columns. + // Common properties. + if (columns.HasId(SaxItemAddress.Column.Notes)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Notes, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Flags)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Flags, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.Status) || columns.HasId(SaxItemAddress.Column.Status_Desc) || columns.HasId(SaxItemAddress.Column.Status_Ind)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_Status, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.CreateOn_Date)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_CreateOn, aliasItemAddress)); + if (columns.HasId(SaxItemAddress.Column.UpdateOn_Date)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemAddress_UpdateOn, aliasItemAddress)); + + //--------------------------------------------------------------------- + // Populate filter. + query.Filters.AddRange(GetItemAddressQueryFilter(prm)); + + if (prm.IdsIncluded.Count != 1) + { + // Configure sort sequence. + foreach (String sortColumn in GetItemAddressSortColumns(prm)) + query.OrderBy.Add(sortColumn); + } + + //--------------------------------------------------------------------- + //return new DbResultSet_DataTableReader(db, query.BuildQuery(prm.ResultsPaging)); + return DbResultSet_DataReader.ExecuteQuery(CoreDatabase, query.BuildQuery(prm.ResultsPaging)); + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Core.xml b/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Core.xml index 87e189d..ba40bf4 100644 --- a/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Core.xml +++ b/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Core.xml @@ -256,7 +256,7 @@ false false 1 - 10 + 6 false @@ -343,6 +343,604 @@ + + dbo + ItemAddress + + + + dbo + ItemAddress
+ 1 + Id + BigInt + + -5 + bigint + true + 19 + 8 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 2 + ItemType + SmallInt + + 5 + smallint + false + 5 + 2 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 3 + ItemId + Int + + 4 + int + false + 10 + 4 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 4 + AddressType + SmallInt + + 5 + smallint + false + 5 + 2 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 5 + Caption + VarChar + + -9 + nvarchar + false + 200 + 400 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 6 + Line1 + VarChar + + -9 + nvarchar + false + 200 + 400 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 7 + Line2 + VarChar + + -9 + nvarchar + false + 200 + 400 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 8 + Line3 + VarChar + + -9 + nvarchar + false + 200 + 400 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 9 + Town + VarChar + + -9 + nvarchar + false + 100 + 200 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 10 + Province + VarChar + + -9 + nvarchar + false + 100 + 200 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 11 + RegionIdProvince + Int + + 4 + int + false + 10 + 4 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 12 + Country + VarChar + + -9 + nvarchar + false + 100 + 200 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 13 + RegionIdCountry + Int + + 4 + int + false + 10 + 4 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 14 + PostalCode + VarChar + + -9 + nvarchar + false + 32 + 64 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 15 + PhoneMain + VarChar + + -9 + nvarchar + false + 100 + 200 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 16 + LocationSource + VarChar + + 12 + varchar + false + 100 + 100 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 17 + LocationStoredAt + DateTime + + 93 + smalldatetime + false + 16 + 16 + 0 + Nullable + true + +
+ + dbo + ItemAddress
+ 18 + LocationUpdateRequired + Bit + + -7 + bit + false + 1 + 1 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 19 + LocationData + VarChar + + -9 + nvarchar + false + 4000 + 8000 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 20 + LocationFormattedAddress + VarChar + + -9 + nvarchar + false + 4000 + 8000 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 21 + LocationLatitude + Decimal + + 3 + decimal + false + 9 + 11 + 6 + Nullable + true + +
+ + dbo + ItemAddress
+ 22 + LocationLongitude + Decimal + + 3 + decimal + false + 9 + 11 + 6 + Nullable + true + +
+ + dbo + ItemAddress
+ 23 + LocationAltitude + Decimal + + 3 + decimal + false + 9 + 11 + 2 + Nullable + true + +
+ + dbo + ItemAddress
+ 24 + Notes + VarChar + + -9 + nvarchar + false + 2000 + 4000 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 25 + Flags + SmallInt + + 5 + smallint + false + 5 + 2 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 26 + Status + VarChar + + 1 + char + false + 3 + 3 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 27 + CreateOn + DateTime + + 93 + datetime + false + 23 + 16 + 3 + NoNulls + false + +
+ + dbo + ItemAddress
+ 28 + CreateBy + Int + + 4 + int + false + 10 + 4 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 29 + CreateHost + VarChar + + 12 + varchar + false + 100 + 100 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 30 + UpdateOn + DateTime + + 93 + datetime + false + 23 + 16 + 3 + NoNulls + false + +
+ + dbo + ItemAddress
+ 31 + UpdateBy + Int + + 4 + int + false + 10 + 4 + 0 + NoNulls + false + +
+ + dbo + ItemAddress
+ 32 + UpdateHost + VarChar + + 12 + varchar + false + 100 + 100 + 0 + NoNulls + false + +
+
+ + + dbo + ItemAddress
+ PK_ItemAddress + 1 + true + false + false + false + 0 + 0 + false + + + 1 + Id + true + + +
+ + dbo + ItemAddress
+ IDX_ItemAddress_Item + 3 + false + false + false + false + 0 + 0 + false + + + 1 + ItemType + true + + + 2 + ItemId + true + + +
+
+
dbo ItemImage @@ -734,7 +1332,7 @@ false false 1 - 5 + 7 false @@ -1449,7 +2047,7 @@ false false 1 - 7 + 8 false @@ -1844,6 +2442,31 @@ + + dbo + Organisation
+ IDX_Organisation_Region_Name + 3 + true + false + false + false + 0 + 0 + false + + + 1 + Name + true + + + 2 + RegionIdPrimary + true + + +
dbo Organisation
@@ -2586,8 +3209,8 @@ false false false - 4 - 267 + 5 + 269 false @@ -3851,7 +4474,7 @@ false false 1 - 8 + 9 false