diff --git a/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs b/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs index 2f34a6a..91d13f4 100644 --- a/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs +++ b/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs @@ -309,6 +309,15 @@ namespace Saxonite.Net.Core.Web.Base.App return GetCodeTypeCaption(Sax.CodeType.OpportunityType, opportunityType); } + //------------------------------------------------------------------- + // Support. + + // User Report Type. + public String GetUserReportTypeCaption(Sax.UserReportType reportType) + { + return GetCodeTypeCaption(Sax.CodeType.UserReportType, reportType); + } + //------------------------------------------------------------------- // Region. public String GetRegionName(SaxRegion.Data region) diff --git a/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs b/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs index 8e321e4..28de7d5 100644 --- a/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs +++ b/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs @@ -20,6 +20,7 @@ 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 Saxonite.Net.Standard.Base.Mgr.Support; using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -111,6 +112,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers public SaxAccountMgr AccountMgr { get { return Internals.AccountMgr; } } public SaxActivityMgr ActivityMgr { get { return Internals.ActivityMgr; } } public SaxItemDataMgr ItemDataMgr { get { return Internals.ItemDataMgr; } } + public SaxSupportMgr SupportMgr { get { return Internals.SupportMgr; } } // System codes. public List DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } } public List SportSpecialityLabelCodes { get { return Internals.SportSpecialityLabelCodes; } } @@ -130,6 +132,8 @@ namespace Saxonite.Net.Core.Web.Base.Controllers public List EventTypeCodes { get { return Internals.EventTypeCodes; } } public List OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } } public List ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } } + // Support. + public List UserReportTypeCodes { get { return Internals.UserReportTypeCodes; } } // Email. public SaEmailConfig EmailConfig { get { return App.EmailConfig; } } public SaxEmailConsole EmailConsole { get { return Internals.EmailConsole; } } diff --git a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs index ef94589..77f0893 100644 --- a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs +++ b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs @@ -13,6 +13,7 @@ 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 Saxonite.Net.Standard.Base.Mgr.Support; using System; using System.Collections.Generic; using System.Globalization; @@ -87,6 +88,7 @@ namespace Saxonite.Net.Core.Web.Base.Models public SaxAccountMgr AccountMgr { get { return Internals.AccountMgr; } } public SaxActivityMgr ActivityMgr { get { return Internals.ActivityMgr; } } public SaxItemDataMgr ItemDataMgr { get { return Internals.ItemDataMgr; } } + public SaxSupportMgr SupportMgr { get { return Internals.SupportMgr; } } // System codes. public List DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } } public List YesNoCodes { get { return Internals.YesNoCodes; } } @@ -107,6 +109,8 @@ namespace Saxonite.Net.Core.Web.Base.Models public List EventTypeCodes { get { return Internals.EventTypeCodes; } } public List OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } } public List ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } } + // Support. + public List UserReportTypeCodes { get { return Internals.UserReportTypeCodes; } } //------------------------------------------------------------------- // Common data components. @@ -274,6 +278,22 @@ namespace Saxonite.Net.Core.Web.Base.Models return maxLength; } + /// + /// Form control value max length - support database. + /// In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted. + /// Hence, several cases where the value entered in the control isn't allowed the full database length. + /// + public int GetControlMaxLength(SaxDbDfn_Support.ColumnIdx column) + { + int maxLength = (int)SaxDbDfn_Support.GetColTextLen(column); + switch (column) + { + case SaxDbDfn_Support.ColumnIdx.UserReport_Title: + break; + } + return maxLength; + } + //------------------------------------------------------------------- // Display data - Dates. public String FormatDateForDisplay(DateTime value) diff --git a/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand602.json b/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand602.json new file mode 100644 index 0000000..4a14b71 --- /dev/null +++ b/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand602.json @@ -0,0 +1,72 @@ +{ + "AppConfigs": { + "SAX-Prod": { + "Environments": [ "Production" ], + "Instance": "", + "URLs": { + "Online": { + "Root": "https://sportierre.com/" + } + }, + "Databases": { + "Core": { + "Location": "MsSql:.\\SQL2016Exp.Saxonite_Core_Demo", + "User": "sax-demo-user", + "Password": "sax-demo-202105" + }, + "Support": { + "Location": "MsSql:.\\SQL2016Exp.Saxonite_Support_Demo", + "User": "sax-demo-user", + "Password": "sax-demo-202105" + } + }, + "Security": { + "Password": { + "MinLength": 9 + }, + "SignIn": { + "KeepLoggedIn": { + "Allowed": true, + "CookieExpiresDays": 5 + }, + "PasswordRequest": { + "LinkExpiresMins": 30 + } + } + }, + "Email": { + "Context": "SAX-SF-Prod", + "ContactUs": { + "AddressesTo": [], + "AddressesBcc": [ "info@sportierre.com" ] + }, + "Signup": { + "Activate": { + "AddressesBcc": [ "info@sportierre.com" ] + }, + "Welcome": { + "AddressesBcc": [ "info@sportierre.com" ] + } + } + }, + "Documents": { + "RootFolder": "C:\\Sarand\\Saxonite\\Demo\\Admin\\Docs" + }, + "Logging": { + "RootFolder": "C:\\Sarand\\Saxonite\\Demo\\Admin\\Logs" + }, + "Variants": [ + { + "ApplicationRootFolder": "C:\\Sarand\\Saxonite\\Demo\\Admin\\App", + "Instance": "Demo", + "Documents": { + "RootFolder": "C:\\Sarand\\Saxonite\\Demo\\Admin\\Docs" + }, + "Logging": { + "RootFolder": "C:\\Sarand\\Saxonite\\Demo\\Admin\\Logs" + } + } + ] + } + } +} diff --git a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx index fa2a015..0d2a927 100644 --- a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx +++ b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx @@ -633,6 +633,9 @@ Summary + + Support + Team @@ -887,4 +890,10 @@ You will then be able to publicise your sporting activities. Your session has expired. + + User Report + + + User Reports + \ No newline at end of file diff --git a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Organisations.cs b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Organisations.cs index 6172e87..387a527 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Organisations.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Organisations.cs @@ -185,6 +185,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers ColumnDfn colOpportunityCount = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Opportunity_Count); ColumnDfn colStatus = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Status); ColumnDfn colCreatedOn = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.CreateOn_Date); + ColumnDfn colLogoCount = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_LogoImage_Count); ColumnDfn colRoleCodes = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationRoleCodes); List columns = new List() { @@ -192,7 +193,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers colOrganisationSportName, colOrganisationRegionName, colMemberCount, colOpportunityCount, colStatus, colStatus, colCreatedOn, - colRoleCodes + colLogoCount, colRoleCodes }; // Sort columns. @@ -205,11 +206,12 @@ namespace Saxonite.Net.Core.Web.Online.Controllers while (resultSet != null && resultSet.HasRows && resultSet.NextRecord()) { NamedValue.Map values = resultSet.GetRecordValues(); + SysId organisationId = new SysId(values.GetLong(colId.DataName)); Sax.OrganisationCategory organisationCategory = (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(values.GetString(colOrganisationCategory.DataName)); Sax.OrganisationType organisationType = (Sax.OrganisationType)OrganisationTypeCodes.GetTypeForCode(values.GetString(colOrganisationType.DataName)); ProfileOrganisationListData organisationData = new ProfileOrganisationListData() { - Id = model.EncryptId(new SysId(values.GetLong(colId.DataName))), + Id = model.EncryptId(organisationId), Name = values.GetString(colOrganisationName.DataName), CategoryDesc = Localiser.GetOrganisationCategoryCaption(organisationCategory), TypeDesc = Localiser.GetOrganisationTypeCaption(organisationType), @@ -219,6 +221,9 @@ namespace Saxonite.Net.Core.Web.Online.Controllers }; // Primary region. organisationData.RegionPrimary.Name = values.GetString(colOrganisationRegionName.DataName); + // Logo. + if (values.GetLong(colLogoCount.DataName) > 0) + organisationData.LogoUrl = GetOrganisationLogoLink(organisationId, false); // Roles. List roleCodes = StringListUtil.Split(values.GetString(colRoleCodes.DataName), SaxUserOrganisation.UserOrgnisationRoleDelim); if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.Admin))) diff --git a/SaxoniteCoreWebOnline/Online/Controllers/SupportController-Ajax-Feedback.cs b/SaxoniteCoreWebOnline/Online/Controllers/SupportController-Ajax-Feedback.cs new file mode 100644 index 0000000..6a6d990 --- /dev/null +++ b/SaxoniteCoreWebOnline/Online/Controllers/SupportController-Ajax-Feedback.cs @@ -0,0 +1,358 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Saxonite.Net.Core.Web.Online.Models; +using Saxonite.Net.Core.Web.Base.App; +using Saxonite.Net.Core.Web.Base.Controllers; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Saxonite.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Utils; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Net.Standard.Base.App; +using static Saxonite.Net.Standard.Base.App.Sax.Config; +using static Saxonite.Net.Standard.Base.Bus.SaxArticle; +using Saxonite.Net.Standard.Base.Bus.Support; +using static Saxonite.Net.Standard.Base.App.Sax; + +namespace Saxonite.Net.Core.Web.Online.Controllers +{ + //======================================================================= + // Online Support Controller - Feedback - Ajax actions. + //======================================================================= + partial class SupportController + { + //------------------------------------------------------------------- + // Data definitions. + private class UserReportResponseListData : AjaxResponse_Data.ItemData_Base + { + // Account Id only populated while account names are being queried, then nulled. + public long? UserAccountId { get; set; } + public String UserDisplayName { get; set; } + public String ReportType { get; set; } + public String ReportTitle { get; set; } + public String RecordedOn { get; set; } + } + private class UserReportResponseItemData : UserReportResponseListData + { + public String Report { get; set; } + } + private void PopulateUserReportResponseListData(Model_Support model, SaxUserReport userReport, SaxUserAccount userAccount, UserReportResponseListData data) + { + data.Id = model.EncryptId(userReport.Id); + data.UserDisplayName = userAccount.GetDisplayName(); + data.ReportType = Localiser.GetUserReportTypeCaption(userReport.ReportType); + data.ReportTitle = userReport.Title; + data.RecordedOn = model.FormatDateForDisplay(userReport.RecordedOn); + } + private void PopulateUserReportResponseItemData(Model_Support model, SaxUserReport userReport, SaxUserAccount userAccount, UserReportResponseItemData data) + { + PopulateUserReportResponseListData(model, userReport, userAccount, data); + data.Report = userReport.Report; + data.CreatedOnFmt = model.FormatDateForDisplay(userReport.CreateStamp.On); + data.StatusCode = userReport.StatusCode; + data.StatusDesc = userReport.StatusDesc; + } + + //------------------------------------------------------------------- + // Support - Get User Reports. + //------------------------------------------------------------------- + private class AjaxResponse_UserReportsData : AjaxResponse_Data + { + // Construction. + public AjaxResponse_UserReportsData(SaxModel_Online model) : base(model) { } + // Reference data. + public List ReportTypes { get; } = new List(); + // User Report list. + public List Reports { get; } = new List(); + } + // Ajax request. + [HttpPost] + [Route("Support/Ajax/GetUserReports")] + public IActionResult GetUserReports(Model_Support model) + { + String fn = GetType().Name + ".GetUserReports"; + AjaxResponse_UserReportsData responseData = new AjaxResponse_UserReportsData(model); + String messageTitle = Localiser["support.caption.user.reports"]; + + // Validate session and referrer. + if (!ValidReferer) return Forbid(); + if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + RefreshModel(model); + + // Reference data - Report types. + List validReportTypes = new List(EnumUtil.GetValues()); + foreach (TypeCodeDesc reportType in UserReportTypeCodes) + { + if (!validReportTypes.Contains((Sax.UserReportType)reportType.Type)) continue; + responseData.ReportTypes.Add(new AjaxResponse_Data.ItemCodeDesc() { Code = reportType.Code, Desc = Localiser.GetUserReportTypeCaption((Sax.UserReportType)reportType.Type) }); + } + + // Item filter. + SaxUserReport.Params prmUserReport = new SaxUserReport.Params(); + prmUserReport.UserAccountIdsIncluded.Add(SessionUserAccountId); + prmUserReport.StatusCat = SaxUserReport.StatusCat.NotDeleted; + model.Paging.ItemTotal = (ulong)SupportMgr.GetUserReportCount(prmUserReport); + model.PopulatePagingTo(prmUserReport.ResultsPaging); + + // Item columns. + ColumnDfn colId = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.Id); + ColumnDfn colUserAccountId = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.UserAccountId); + ColumnDfn colReportType = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.ReportType); + ColumnDfn colReportTitle = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.Title); + ColumnDfn colRecordedOn = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.RecordedOn); + ColumnDfn colStatus = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.Status); + List columns = new List() + { + colId, + colUserAccountId, colReportType, colReportTitle,colRecordedOn, + colStatus, + }; + + // Sort columns. + prmUserReport.SortColumns.Add(colRecordedOn); + + // User account details must be queried separately - different database! + HashSet userAccountIds = new HashSet(); + + // Query items. + using (DbResultSet resultSet = SupportMgr.ExecuteUserReportQuery(columns, prmUserReport)) + { + while (resultSet != null && resultSet.HasRows && resultSet.NextRecord()) + { + NamedValue.Map values = resultSet.GetRecordValues(); + SysId userAccountId = new SysId(values.GetLong(colUserAccountId.DataName)); + userAccountIds.Add(userAccountId); + Sax.UserReportType reportType = (Sax.UserReportType)values.GetLong(colReportType.DataName); + UserReportResponseListData userReportData = new UserReportResponseListData() + { + Id = model.EncryptId(new SysId(values.GetLong(colId.DataName))), + UserAccountId = SysId.ToLong(userAccountId), + ReportType = values.GetString(colReportType.DataName), + ReportTitle = values.GetString(colReportTitle.DataName), + RecordedOn = model.FormatDateForDisplay(values.GetDate(colRecordedOn.DataName)), + StatusCode = values.GetString(colStatus.DataName), + StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)) + }; + responseData.Reports.Add(userReportData); + } + } + if (model.Paging.IsPaged) + model.Paging.ItemCount = (ushort)responseData.Reports.Count; + + // Query and populate User Account details. + if (userAccountIds.Any()) + { + // User Account columns. + ColumnDfn colUserAccount_Id = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.Id); + ColumnDfn colUserAccount_Title = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.Title); + ColumnDfn colUserAccount_FirstName = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.FirstName); + ColumnDfn colUserAccount_LastName = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.LastName); + List userAccountCols = new List() { colUserAccount_Id, colUserAccount_Title, colUserAccount_FirstName, colUserAccount_LastName }; + // User Account filter. + SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params(); + prmUserAccount.IdsIncluded.AddRange(userAccountIds); + prmUserAccount.StatusCat = SaxUserAccount.StatusCat.Any; + // Query user accounts and populate properties to report list. + using (DbResultSet resultSet = AccountMgr.ExecuteUserAccountQuery(columns, prmUserAccount)) + { + while (resultSet != null && resultSet.HasRows && resultSet.NextRecord()) + { + NamedValue.Map values = resultSet.GetRecordValues(); + SysId userAccountId = new SysId(values.GetLong(colUserAccount_Id.DataName)); + String title = values.GetString(colUserAccount_Title.DataName); + String firstName = values.GetString(colUserAccount_FirstName.DataName); + String lastName = values.GetString(colUserAccount_LastName.DataName); + foreach (UserReportResponseListData userReportData in responseData.Reports.FindAll(item => item.UserAccountId.Equals(userAccountId))) + { + userReportData.UserDisplayName = SaxUserAccount.GetDisplayName(title, firstName, lastName); + userReportData.UserAccountId = null; + } + } + } + // Clear any remaining User Account Ids. + foreach (UserReportResponseListData userReportData in responseData.Reports.FindAll(item => item.UserAccountId != null)) + userReportData.UserAccountId = null; + } + + // Complete response. + responseData.SetPaging(model); + responseData.Success = true; + return Json(responseData); + } + + //------------------------------------------------------------------- + // Get User Report ajax request. + //------------------------------------------------------------------- + private class AjaxResponse_UserReport : AjaxResponse_Data + { + // Construction. + public AjaxResponse_UserReport(SaxModel_Online model) : base(model) { } + // Sport details. + public UserReportResponseItemData Report { get; } = new UserReportResponseItemData(); + } + //------------------------------------------------------------------- + [HttpPost] + [Route("Support/Ajax/GetUserReport")] + public IActionResult Ajax_GetUserReport(Model_Support model) + { + String fn = GetType().Name + ".Ajax_GetUserReport"; + String messageTitle = Localiser["support.caption.user.report"]; + AjaxResponse_UserReport responseData = new AjaxResponse_UserReport(model); + + // Validate session and referrer. + if (!ValidReferer) return Forbid(); + if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + RefreshModel(model); + + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposableItems = new DisposableCollection()) + { + + // Identify item. + SysId userReportId = model.ExtractSysId(model.UserReport.Id); + if (!SysId.IsValid(userReportId)) + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"])); + + // Retrieve item. + SaxUserReport userReport = SupportMgr.GetUserReportById(userReportId); + disposableItems.Add(userReport); + if (userReport == null) + { + SaLogger.Warn(fn + " Failed to retrieve User Report for Id: '" + model.UserReport.Id + "'"); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"])); + } + + // Retrieve user. + SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userReport.UserAccountId); + disposableItems.Add(userAccount); + if (userAccount == null) + { + SaLogger.Warn(fn + " Failed to retrieve User Account for Id: '" + userReport.UserAccountId + "'"); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"])); + } + + // Construct response. + PopulateUserReportResponseItemData(model, userReport, userAccount, responseData.Report); + responseData.Success = true; + } + return Json(responseData); + } + + //------------------------------------------------------------------- + // Store User Report ajax request. + //------------------------------------------------------------------- + [HttpPost] + [Route("Support/Ajax/StoreUserReport")] + public IActionResult Ajax_StoreUserReport(Model_Support model) + { + String fn = GetType().Name + ".Ajax_StoreUserReport"; + String messageTitle = Localiser["support.caption.user.report"]; + AjaxResponse_UserReport responseData = new AjaxResponse_UserReport(model); + + // Validate session and referrer. + if (!ValidReferer) return Forbid(); + if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + if (!SessionData_Online.User.Roles.Exists(item => item.Role == Sax.UserRole.SystemReviewer)) return Forbid(); + RefreshModel(model); + + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposableItems = new DisposableCollection()) + { + + // Validate item properties. + model.ValidateUserReportData(responseData); + if (responseData.HasControlErrors()) + return Json(responseData); + + // Validate User Report Id against 'Exists' flag. + SysId userReportId = model.ExtractSysId(model.UserReport.Id); + bool userReportExists = StringUtil.ToBool(model.UserReport.Exists); + if (userReportExists && !SysId.IsValid(userReportId)) + { + SaLogger.Warn(fn + " Id not specified for existing User Report."); + return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); + } + if (!userReportExists && SysId.IsValid(userReportId)) + { + SaLogger.Warn(fn + " Id specified for new User Report: '" + model.UserReport.Id + "'"); + return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); + } + + // Retrieve user. + SysId userAccountId = SessionUserAccountId; + SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userAccountId); + disposableItems.Add(userAccount); + if (userAccount == null) + { + SaLogger.Warn(fn + " Failed to retrieve User Account for Id: '" + userAccountId + "'"); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"])); + } + + // Retrieve existing item. + SaxUserReport userReport = SupportMgr.GetUserReportById(userReportId); + disposableItems.Add(userReport); + if (userReport == null && SysId.IsValid(userReportId)) + { + SaLogger.Warn(fn + " Failed to retrieve User Report for Id: '" + model.UserReport.Id + "'"); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"])); + } + // Validate User Report properties. + if (userReport != null) + { + if (!userReport.UserAccountId.Equals(userAccountId)) + { + SaLogger.Warn(fn + " Inconsistent User Account Id specified for User Report. Expected: " + userReport.UserAccountId + ". Found: " + userAccountId); + return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); + } + } + + // If User Report doesn't exist, create a new one. + if (userReport == null) + { + userReport = SupportMgr.CreateUserReport(userAccountId); + disposableItems.Add(userReport); + } + + // Populate item properties. + if (model.UserReport.ReportType != null) + userReport.ReportType = model.GetReportType(); + if (model.UserReport.Title != null) + userReport.Title = model.UserReport.Title; + if (model.UserReport.Report != null) + userReport.Report = model.UserReport.Report; + + // Store item. + if (!SysId.IsValid(userReport.Id)) + { + if (!SupportMgr.InsertUserReport(userReport, DbUpdateInfo)) + { + SaLogger.Warn(fn + " Failed to insert user report: " + SupportMgr.ErrorStateMessage); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"])); + } + } + else + { + if (!SupportMgr.UpdateUserReport(userReport, DbUpdateInfo)) + { + SaLogger.Warn(fn + " Failed to update user report [Id:" + SysId.ToString(userReport.Id) + "]: " + SupportMgr.ErrorStateMessage); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"])); + } + } + + // Construct response. + PopulateUserReportResponseItemData(model, userReport, userAccount, responseData.Report); + responseData.Success = true; + } + return Json(responseData); + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteCoreWebOnline/Online/Controllers/ApplicationController.cs b/SaxoniteCoreWebOnline/Online/Controllers/SupportController.cs similarity index 78% rename from SaxoniteCoreWebOnline/Online/Controllers/ApplicationController.cs rename to SaxoniteCoreWebOnline/Online/Controllers/SupportController.cs index f37c9c2..27c48a0 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/ApplicationController.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/SupportController.cs @@ -16,13 +16,13 @@ using System.Threading.Tasks; namespace Saxonite.Net.Core.Web.Online.Controllers { //======================================================================= - // Online Application Controller. + // Online Support Controller. //======================================================================= - public partial class ApplicationController : SaxController_Online + public partial class SupportController : SaxController_Online { //------------------------------------------------------------------- // Construction. - public ApplicationController(SaxLocaliser localiser, ILogger logger) : + public SupportController(SaxLocaliser localiser, ILogger logger) : base(localiser, logger) { } @@ -35,7 +35,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers if (!ValidUserSession) return RedirectToAction("", ""); - // No Application index page. + // No Support index page. return RedirectToAction("", ""); } @@ -46,13 +46,13 @@ namespace Saxonite.Net.Core.Web.Online.Controllers // Validate session. if (!ValidUserSession) return RedirectToAction("", ""); + Model_Support model = new Model_Support(Localiser); // User must be a member of the 'Reviewers' role. - if (!SessionData_Online.User.Roles.Exists(item => item.Role == Sax.UserRole.SystemReviewer)) + if (!SessionData_Online.User.SupportMenuAllowed) return RedirectToAction("", ""); // Applincation index page. - Model_Application model = new Model_Application(Localiser); model.ProhibitCache = false; return View(model); } @@ -64,13 +64,13 @@ namespace Saxonite.Net.Core.Web.Online.Controllers // Validate session. if (!ValidUserSession) return RedirectToAction("", ""); + Model_Support model = new Model_Support(Localiser); // User must be a member of the 'Reviewers' role. - if (!SessionData_Online.User.Roles.Exists(item => item.Role == Sax.UserRole.SystemReviewer)) + if (!SessionData_Online.User.SupportMenuAllowed) return RedirectToAction("", ""); // Applincation index page. - Model_Application model = new Model_Application(Localiser); model.ProhibitCache = false; return View(model); } diff --git a/SaxoniteCoreWebOnline/Online/Models/Model_Application.cs b/SaxoniteCoreWebOnline/Online/Models/Model_Application.cs deleted file mode 100644 index 91f783f..0000000 --- a/SaxoniteCoreWebOnline/Online/Models/Model_Application.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Saxonite.Net.Core.Web.Base.App; -using Saxonite.Net.Core.Web.Base.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Saxonite.Net.Core.Web.Online.Models -{ - //======================================================================= - public class Model_Application : SaxModel_Online - { - //------------------------------------------------------------------- - // Construction. - public Model_Application(SaxLocaliser localiser) : - base(localiser) - { - AdditionalFiles_CSS.Add("css/sax-appl.css"); - AdditionalFiles_JS.Add("js/sax-appl.js"); - } - - //------------------------------------------------------------------- - } - //======================================================================= -} diff --git a/SaxoniteCoreWebOnline/Online/Models/Model_Support.cs b/SaxoniteCoreWebOnline/Online/Models/Model_Support.cs new file mode 100644 index 0000000..dd785e0 --- /dev/null +++ b/SaxoniteCoreWebOnline/Online/Models/Model_Support.cs @@ -0,0 +1,69 @@ +using Sarand.Net.Standard.Base.Core; +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.Core.Web.Base.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using static Saxonite.Net.Standard.Base.App.Sax.Config; + +namespace Saxonite.Net.Core.Web.Online.Models +{ + //======================================================================= + public class Model_Support : SaxModel_Online + { + //------------------------------------------------------------------- + // Construction. + public Model_Support(SaxLocaliser localiser) : + base(localiser) + { + AdditionalFiles_CSS.Add("css/sax-appl.css"); + AdditionalFiles_JS.Add("js/sax-appl.js"); + } + + //------------------------------------------------------------------- + // User Report proerties. + public class UserReportData + { + public String Id { get; set; } + public String Exists { get; set; } + public String ReportType { get; set; } + public String Title { get; set; } + public String Report { get; set; } + // Filter. + public class UserReportFilterData + { + public String User { get; set; } + public String Report { get; set; } + } + public UserReportFilterData Filter { get; } = new UserReportFilterData(); + } + public UserReportData UserReport { get; } = new UserReportData(); + public Standard.Base.App.Sax.UserReportType GetReportType() { return (Standard.Base.App.Sax.UserReportType)(UserReportTypeCodes.GetTypeForCode(UserReport.ReportType)); } + + //------------------------------------------------------------------- + // Validate User Report data. + public bool ValidateUserReportData(SaxController_Base.AjaxResponse_Data responseData) + { + + // Report Title. + String controlName = "UserReportTitle"; + if (UserReport.Title != null) + { + responseData.SetControlValue(controlName, UserReport.Title); + if (StringUtil.IsEmpty(UserReport.Title)) + responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]); + else if (StringUtil.GetLength(UserReport.Title) > GetControlMaxLength(SaxDbDfn_Support.ColumnIdx.UserReport_Title)) + responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Support.ColumnIdx.UserReport_Title)]); + } + + return !responseData.HasControlErrors(); + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteCoreWebOnline/Online/Models/SaxModel_Online.cs b/SaxoniteCoreWebOnline/Online/Models/SaxModel_Online.cs index 71f7b96..5193217 100644 --- a/SaxoniteCoreWebOnline/Online/Models/SaxModel_Online.cs +++ b/SaxoniteCoreWebOnline/Online/Models/SaxModel_Online.cs @@ -50,8 +50,8 @@ namespace Saxonite.Net.Core.Web.Online.Models public bool ArticlesAllowed { get { return UserIsJournalist || UserCanManageOrganisationArticles; } } public bool OrganisationOpportunitiesAllowed { get { return UserCanManageOrganisationOpportunities; } } public bool OrganisationEventsAllowed { get { return UserCanManageOrganisationSchedule; } } - // Application menu is for admin reviewers only. - public bool ApplicationMenuAllowed { get { return SessionData_Online?.User.Roles.Exists(item => item.Role == Sax.UserRole.SystemReviewer) ?? false; } } + // Support menu is for admin reviewers only. + public bool SupportMenuAllowed { get { return SessionData_Online?.User.SupportMenuAllowed ?? false; } } //------------------------------------------------------------------- // Security profile. diff --git a/SaxoniteCoreWebOnline/SaxoniteCoreWebOnline.csproj b/SaxoniteCoreWebOnline/SaxoniteCoreWebOnline.csproj index 080d053..1158bc2 100644 --- a/SaxoniteCoreWebOnline/SaxoniteCoreWebOnline.csproj +++ b/SaxoniteCoreWebOnline/SaxoniteCoreWebOnline.csproj @@ -29,6 +29,11 @@ + + PreserveNewest + true + PreserveNewest + PreserveNewest true diff --git a/SaxoniteCoreWebOnline/Views/Account/Profile-Organisations.cshtml b/SaxoniteCoreWebOnline/Views/Account/Profile-Organisations.cshtml index 29e7cb0..d6fdec3 100644 --- a/SaxoniteCoreWebOnline/Views/Account/Profile-Organisations.cshtml +++ b/SaxoniteCoreWebOnline/Views/Account/Profile-Organisations.cshtml @@ -39,33 +39,42 @@
@* Profile Organisations list *@ -
+
@* Item templates *@
@* Organisation template *@
-
-
-
- @* Burger menu *@ - -
-
-
-
-
-
-
-
-
@Localiser["label.members"]: 
-
@Localiser["label.opportunities"]: 
+
+
+
+
+
+ @* Burger menu *@ + +
+
+
+
+
+
+
+
+
+
+
@Localiser["label.members"]: 
+
@Localiser["label.opportunities"]: 
+
+
+
+
+
diff --git a/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml b/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml index 5bcb1ca..35972c6 100644 --- a/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml +++ b/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml @@ -160,15 +160,15 @@
- @if (Model.ApplicationMenuAllowed) + @if (Model.SupportMenuAllowed) { } diff --git a/SaxoniteCoreWebOnline/Views/Application/Feedback.cshtml b/SaxoniteCoreWebOnline/Views/Support/Feedback.cshtml similarity index 71% rename from SaxoniteCoreWebOnline/Views/Application/Feedback.cshtml rename to SaxoniteCoreWebOnline/Views/Support/Feedback.cshtml index 680ff47..00ec5ce 100644 --- a/SaxoniteCoreWebOnline/Views/Application/Feedback.cshtml +++ b/SaxoniteCoreWebOnline/Views/Support/Feedback.cshtml @@ -1,8 +1,8 @@ -@model Model_Application +@model Model_Support @inject SaxLocaliser Localiser @{ - // Online - Application - Index. - ViewData["Title"] = "Application"; + // Online - Support - Feedback. + ViewData["Title"] = "Support - Feedback"; }
diff --git a/SaxoniteCoreWebOnline/Views/Application/Versions.cshtml b/SaxoniteCoreWebOnline/Views/Support/Versions.cshtml similarity index 71% rename from SaxoniteCoreWebOnline/Views/Application/Versions.cshtml rename to SaxoniteCoreWebOnline/Views/Support/Versions.cshtml index 8e3b9b7..b6672dd 100644 --- a/SaxoniteCoreWebOnline/Views/Application/Versions.cshtml +++ b/SaxoniteCoreWebOnline/Views/Support/Versions.cshtml @@ -1,8 +1,8 @@ -@model Model_Application +@model Model_Support @inject SaxLocaliser Localiser @{ - // Online - Application - Index. - ViewData["Title"] = "Application"; + // Online - Support - Versions. + ViewData["Title"] = "Support - Versions"; }
diff --git a/SaxoniteCoreWebOnline/appsettings.Machine.Sarand602.json b/SaxoniteCoreWebOnline/appsettings.Machine.Sarand602.json new file mode 100644 index 0000000..c7e2acd --- /dev/null +++ b/SaxoniteCoreWebOnline/appsettings.Machine.Sarand602.json @@ -0,0 +1,67 @@ +{ + "AppConfigs": { + "SAX-Prod": { + "Environments": [ "Production" ], + "Instance": "", + "Databases": { + "Core": { + "Location": "MsSql:.\\SQL2016Exp.Saxonite_Core_Demo", + "User": "sax-demo-user", + "Password": "sax-demo-202105" + }, + "Support": { + "Location": "MsSql:.\\SQL2016Exp.Saxonite_Support_Demo", + "User": "sax-demo-user", + "Password": "sax-demo-202105" + } + }, + "Security": { + "Password": { + "MinLength": 8 + }, + "SignIn": { + "KeepLoggedIn": { + "Allowed": true, + "CookieExpiresDays": 30 + }, + "PasswordRequest": { + "LinkExpiresMins": 60 + } + } + }, + "Email": { + "Context": "SAX-SF-Prod", + "ContactUs": { + "AddressesTo": [], + "AddressesBcc": [ "info@sportierre.com" ] + }, + "Signup": { + "Activate": { + "AddressesBcc": [ "info@sportierre.com" ] + }, + "Welcome": { + "AddressesBcc": [ "info@sportierre.com" ] + } + } + }, + "Documents": { + "RootFolder": "C:\\Sarand\\Saxonite\\Demo\\Online\\Docs" + }, + "Logging": { + "RootFolder": "C:\\Sarand\\Saxonite\\Demo\\Online\\Logs" + }, + "Variants": [ + { + "ApplicationRootFolder": "C:\\Sarand\\Saxonite\\Demo\\Online\\App", + "Instance": "Demo", + "Documents": { + "RootFolder": "C:\\Sarand\\Saxonite\\Demo\\Online\\Docs" + }, + "Logging": { + "RootFolder": "C:\\Sarand\\Saxonite\\Demo\\Online\\Logs" + } + } + ] + } + } +} diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css index 33d78f0..f3c1b88 100644 --- a/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css +++ b/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css @@ -219,7 +219,8 @@ color: #606060; background-color: #fff; border: 1px solid #989898; - border-bottom-right-radius: 8px; + border-radius: 3px; + border-top-right-radius: 8px; overflow: auto; } diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-org.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-org.js index 1f58575..76a76ac 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-org.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-org.js @@ -44,7 +44,8 @@ $('.OrganisationSport', $item).text(item.sportName); $('.OrganisationRegionPrimary', $item).text(item.regionPrimary.name); $('.OrganisationMemberCount', $item).toggle(!!item.memberCount).find('.MemberCount').text(item.memberCount); - $('.OrganisationOpportunityCount', $item).toggle(!!item.opportunityCount).find('.MemberCount').text(item.opportunityCount); + $('.OrganisationOpportunityCount', $item).toggle(!!item.opportunityCount).find('.OpportunityCount').text(item.opportunityCount); + $('img.OrganisationLogo', $item).prop('src', item.logoUrl).toggle(!!item.logoUrl); let $bgr = $('.sax-burger', $item); let $mnu = $('ul.sax-dropdown-menu', $bgr).empty(); diff --git a/SaxoniteStandardBase/Base/App/Sax-Version.cs b/SaxoniteStandardBase/Base/App/Sax-Version.cs index 13b67d0..acf307b 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.2.10.2"; + private static String version { get; } = "1.2.10.3"; // Retrieve version. public static String GetFullVersion () { return version; } public static String GetAppVersion () diff --git a/SaxoniteStandardBase/Base/App/Sax.cs b/SaxoniteStandardBase/Base/App/Sax.cs index 92c57c1..88a6946 100644 --- a/SaxoniteStandardBase/Base/App/Sax.cs +++ b/SaxoniteStandardBase/Base/App/Sax.cs @@ -38,6 +38,8 @@ namespace Saxonite.Net.Standard.Base.App EventType, OpportunityType, ActivityReaction, + // Support. + UserReportType, }; //------------------------------------------------------------------- @@ -100,6 +102,8 @@ namespace Saxonite.Net.Standard.Base.App ItemAddress = 405, ItemAssociation = 410, ItemSport = 420, + // Support. + UserReport = 1010, } //------------------------------------------------------------------- @@ -395,6 +399,19 @@ namespace Saxonite.Net.Standard.Base.App Exceptional = 5, } + //------------------------------------------------------------------- + // Support. + //------------------------------------------------------------------- + /// User Report Type + public enum UserReportType + { + Unknown = 0, + /* Do not change the values or codes - tied to database. */ + Enhancement= 10, + Information = 20, + Bug = 30, + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs b/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs index c70619c..9147052 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 Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Base.App { diff --git a/SaxoniteStandardBase/Base/App/SaxDbDfn_Support.cs b/SaxoniteStandardBase/Base/App/SaxDbDfn_Support.cs index 1fd6b85..4bb88d6 100644 --- a/SaxoniteStandardBase/Base/App/SaxDbDfn_Support.cs +++ b/SaxoniteStandardBase/Base/App/SaxDbDfn_Support.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Base.App { @@ -29,6 +29,7 @@ namespace Saxonite.Base.App UserReport_Id, UserReport_UserAccountId, UserReport_ReportType, + UserReport_Title, UserReport_Report, UserReport_RecordedOn, UserReport_ReportData, @@ -60,7 +61,7 @@ namespace Saxonite.Base.App //------------------------------------------------------------------- // Data members. private static readonly int tableCount = 2; - private static readonly int columnCount = 29; + private static readonly int columnCount = 30; private static ulong maxTextLen = 0; //------------------------------------------------------------------- @@ -237,6 +238,7 @@ namespace Saxonite.Base.App new ColumnDfn(1,"Id",5,-5,true,19), new ColumnDfn(1,"UserAccountId",4,4,false,10), new ColumnDfn(1,"ReportType",3,5,false,5), + new ColumnDfn(1,"Title",0,-9,false,1000), new ColumnDfn(1,"Report",0,-9,false,4000), new ColumnDfn(1,"RecordedOn",9,93,false,16), new ColumnDfn(1,"ReportData",0,-9,false,0), diff --git a/SaxoniteStandardBase/Base/App/SaxInternals.cs b/SaxoniteStandardBase/Base/App/SaxInternals.cs index 8a8d54e..2e07d5e 100644 --- a/SaxoniteStandardBase/Base/App/SaxInternals.cs +++ b/SaxoniteStandardBase/Base/App/SaxInternals.cs @@ -10,6 +10,7 @@ using Saxonite.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Utils; +using Saxonite.Net.Standard.Base.Mgr.Support; namespace Saxonite.Net.Standard.Base.App { @@ -29,6 +30,7 @@ namespace Saxonite.Net.Standard.Base.App public SaxAccountMgr accountMgr = null; public SaxActivityMgr activityMgr = null; public SaxItemDataMgr itemDataMgr = null; + public SaxSupportMgr supportMgr = null; } private readonly Managers mgr = new Managers(); private class Consoles @@ -70,6 +72,7 @@ namespace Saxonite.Net.Standard.Base.App if (mgr.accountMgr != null) mgr.accountMgr.Dispose(); mgr.accountMgr = null; if (mgr.activityMgr != null) mgr.activityMgr.Dispose(); mgr.activityMgr = null; if (mgr.itemDataMgr != null) mgr.itemDataMgr.Dispose(); mgr.itemDataMgr = null; + if (mgr.supportMgr != null) mgr.supportMgr.Dispose(); mgr.supportMgr = null; if (con.activityConsole != null) con.activityConsole.Dispose(); con.activityConsole = null; } } @@ -88,6 +91,12 @@ namespace Saxonite.Net.Standard.Base.App //------------------------------------------------------------------- // System codes. private readonly Dictionary> codeTypes = new Dictionary>(); + public List GetCodesOfType(Sax.CodeType codeType) + { + if (!codeTypes.ContainsKey(codeType)) + codeTypes.Add(codeType, SaxSystem.GetCodesOfType(codeType)); + return new List(codeTypes[codeType]); + } public List DataItemTypeCodes { get { return GetCodesOfType(Sax.CodeType.DataItemType); } } public List YesNoCodes { get { return GetCodesOfType(Sax.CodeType.YesNo); } } public List GenderCodes { get { return GetCodesOfType(Sax.CodeType.Gender); } } @@ -108,12 +117,8 @@ namespace Saxonite.Net.Standard.Base.App public List EventTypeCodes { get { return GetCodesOfType(Sax.CodeType.EventType); } } public List OpportunityTypeCodes { get { return GetCodesOfType(Sax.CodeType.OpportunityType); } } public List ActivityReactionCodes { get { return GetCodesOfType(Sax.CodeType.ActivityReaction); } } - public List GetCodesOfType(Sax.CodeType codeType) - { - if (!codeTypes.ContainsKey(codeType)) - codeTypes.Add(codeType, SaxSystem.GetCodesOfType(codeType)); - return new List(codeTypes[codeType]); - } + // Support. + public List UserReportTypeCodes { get { return GetCodesOfType(Sax.CodeType.UserReportType); } } //------------------------------------------------------------------- // Consoles. @@ -161,6 +166,15 @@ namespace Saxonite.Net.Standard.Base.App return mgr.itemDataMgr; } } + public SaxSupportMgr SupportMgr + { + get + { + if (mgr.supportMgr == null) + mgr.supportMgr = System.CreateSupportMgr(SessionContext, this); + return mgr.supportMgr; + } + } //------------------------------------------------------------------- // Regions. diff --git a/SaxoniteStandardBase/Base/App/SaxSessionData.cs b/SaxoniteStandardBase/Base/App/SaxSessionData.cs index 72058af..f442abd 100644 --- a/SaxoniteStandardBase/Base/App/SaxSessionData.cs +++ b/SaxoniteStandardBase/Base/App/SaxSessionData.cs @@ -149,6 +149,12 @@ namespace Saxonite.Net.Standard.Base.App private readonly List roles = new List(); public List Roles { get { return new List(roles); } protected set { roles.Clear(); roles.AddRange(value); } } [JsonIgnore] + public bool IsSystemAdmin { get { return roles?.Exists(item => item.Role == Sax.UserRole.SystemAdmin) ?? false; } } + [JsonIgnore] + public bool IsSystemReviewer { get { return roles?.Exists(item => item.Role == Sax.UserRole.SystemReviewer) ?? false; } } + [JsonIgnore] + public bool SupportMenuAllowed { get { return roles?.Exists(item => item.Role == Sax.UserRole.SystemAdmin || item.Role == Sax.UserRole.SystemReviewer) ?? false; } } + [JsonIgnore] public bool IsJournalist { get { return roles?.Exists(item => item.Role == Sax.UserRole.Journalist) ?? false; } } } protected abstract UserData CreateUserData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List userRoles); diff --git a/SaxoniteStandardBase/Base/App/SaxSystem-CodeTypes.cs b/SaxoniteStandardBase/Base/App/SaxSystem-CodeTypes.cs index 1b6ec95..2f532c7 100644 --- a/SaxoniteStandardBase/Base/App/SaxSystem-CodeTypes.cs +++ b/SaxoniteStandardBase/Base/App/SaxSystem-CodeTypes.cs @@ -35,6 +35,8 @@ namespace Saxonite.Net.Standard.Base.App private static readonly List eventTypeCodes = new List(); private static readonly List opportunityTypeCodes = new List(); private static readonly List activityReactionCodes = new List(); + // Support. + private static readonly List userReportTypeCodes = new List(); //------------------------------------------------------------------- // C o d e T y p e s @@ -89,6 +91,10 @@ namespace Saxonite.Net.Standard.Base.App case Sax.CodeType.ActivityReaction: return new List(activityReactionCodes); + // Support. + case Sax.CodeType.UserReportType: + return new List(userReportTypeCodes); + default: throw new NotSupportedException(nameof(SaxSystem) + ".GetCodesOfType Unexpected code type: " + codeType.ToString()); } @@ -289,6 +295,14 @@ namespace Saxonite.Net.Standard.Base.App activityReactionCodes.Add(Sax.ActivityReaction.VeryGood, "VeryGood", "Very Good"); activityReactionCodes.Add(Sax.ActivityReaction.Exceptional, "Exceptional", "Exceptional"); + //--------------------------------------------------------------- + // Support. + + // User Report Types. + userReportTypeCodes.Add(Sax.UserReportType.Enhancement, "Enhancement", "Enhancement request"); + userReportTypeCodes.Add(Sax.UserReportType.Information, "Information", "Information request"); + userReportTypeCodes.Add(Sax.UserReportType.Bug, "Bug", "Bug report"); + //--------------------------------------------------------------- } diff --git a/SaxoniteStandardBase/Base/App/SaxSystem.cs b/SaxoniteStandardBase/Base/App/SaxSystem.cs index b060e5a..5e0a845 100644 --- a/SaxoniteStandardBase/Base/App/SaxSystem.cs +++ b/SaxoniteStandardBase/Base/App/SaxSystem.cs @@ -5,6 +5,7 @@ using Saxonite.Net.Standard.Base.App; using System; using System.Collections.Generic; using System.Text; +using Saxonite.Net.Standard.Base.Mgr.Support; namespace Saxonite.Net.Standard.Base.App { @@ -27,6 +28,7 @@ namespace Saxonite.Net.Standard.Base.App public abstract SaxAccountMgr CreateAccountMgr(SaxSessionContext sessionContext, SaxInternals internals); public abstract SaxItemDataMgr CreateItemDataMgr(SaxSessionContext sessionContext, SaxInternals internals); public abstract SaxActivityMgr CreateActivityMgr(SaxSessionContext sessionContext, SaxInternals internals); + public abstract SaxSupportMgr CreateSupportMgr(SaxSessionContext sessionContext, SaxInternals internals); //------------------------------------------------------------------- } diff --git a/SaxoniteStandardBase/Base/Bus/SaxUserOrganisation.cs b/SaxoniteStandardBase/Base/Bus/SaxUserOrganisation.cs index 5ed8a9f..4d7ebad 100644 --- a/SaxoniteStandardBase/Base/Bus/SaxUserOrganisation.cs +++ b/SaxoniteStandardBase/Base/Bus/SaxUserOrganisation.cs @@ -44,6 +44,7 @@ namespace Saxonite.Net.Standard.Base.Bus Organisation_Sport_Name, Organisation_Member_Count, Organisation_Opportunity_Count, + Organisation_LogoImage_Count, // Properties. AdminComment, // Associated data. diff --git a/SaxoniteStandardBase/Base/Bus/Support/SaxUserReport.cs b/SaxoniteStandardBase/Base/Bus/Support/SaxUserReport.cs new file mode 100644 index 0000000..d54b766 --- /dev/null +++ b/SaxoniteStandardBase/Base/Bus/Support/SaxUserReport.cs @@ -0,0 +1,271 @@ +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; +using static Sarand.Net.Standard.Base.Bus.SacsHierarchyItem; + +namespace Saxonite.Net.Standard.Base.Bus.Support +{ + //======================================================================= + // UserReport. + //======================================================================= + public abstract class SaxUserReport : SacsHierarchyItem + { + //------------------------------------------------------------------- + // Columns. + public enum Column + { + Pos, + Id, + UserAccountId, + ReportType, + ReportType_Desc, + Title, + Report, + RecordedOn, + // Associated data. + // Common. + Notes, + Flags, + Status, + Status_Desc, + Status_Ind, + CreateOn_Date, + UpdateOn_Date, + } + + //------------------------------------------------------------------- + /// Properties other than common. + public class DataProperties + { + public SysId UserAccountId { get; set; } + public Sax.UserReportType ReportType { get; set; } + public String Title { get; set; } = String.Empty; + public String Report { get; set; } = String.Empty; + public DateTime RecordedOn { get; set; } + public String ReportData { get; set; } = String.Empty; + } + + //------------------------------------------------------------------- + // Data. + public new class Data : SacsHierarchyItem.Data + { + // Data members. + private readonly DataProperties data = new DataProperties(); + // Construction. + public Data() + { + Status = DefaultStatus; + } + // Properties. + public SysId UserAccountId + { + get { return data.UserAccountId; } + set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; } + } + public Sax.UserReportType ReportType + { + get { return data.ReportType; } + set { CheckChanged((short)data.ReportType, (short)value); data.ReportType = value; } + } + public String Title + { + get { return data.Title; } + set { CheckChanged(data.Title, value); data.Title = value; } + } + public String Report + { + get { return data.Report; } + set { CheckChanged(data.Report, value); data.Report = value; } + } + public DateTime RecordedOn + { + get { return data.RecordedOn; } + set { CheckChanged(data.RecordedOn, value); data.RecordedOn = value; } + } + public String ReportData + { + get { return data.ReportData; } + set { CheckChanged(data.ReportData, value); data.ReportData = value; } + } + // Population. + internal void PopulateFrom(Data data) + { + UserAccountId = data.UserAccountId; + ReportType = data.ReportType; + Title = data.Title; + Report = data.Report; + RecordedOn = data.RecordedOn; + ReportData = data.ReportData; + base.PopulateFrom(data); + } + public Data Clone() + { + Data data = new Data(); + data.PopulateFrom(this); + return data; + } + } + + //------------------------------------------------------------------- + // Error field - identify properties with validation error. + public new class ErrField : SacsHierarchyItem.ErrField + { + // Identifies the field that has invalid data. + public ValidValue UserAccountId { get; set; } = ValidValue.Valid; + public ValidValue ReportType { get; set; } = ValidValue.Valid; + public ValidValue Title { get; set; } = ValidValue.Valid; + public ValidValue Report { get; set; } = ValidValue.Valid; + public ValidValue RecordedOn { get; set; } = ValidValue.Valid; + public ValidValue ReportData { get; set; } = ValidValue.Valid; + } + + //------------------------------------------------------------------- + // Data members. + private readonly Data data = new Data(); + + //------------------------------------------------------------------- + // Construction. + protected SaxUserReport(SysId id, SysId userAccountId) : base(id) + { + base.SetData(data); + this.UserAccountId = userAccountId; + Status = DefaultStatus; + } + + //------------------------------------------------------------------- + // Status. + private static readonly List validStatuses = new List() + { + SaStatus.Preparation, + SaStatus.InProgress, + SaStatus.Cancelled, + SaStatus.Closed, + SaStatus.Deleted, + }; + public static SaStatus DefaultStatus { get { return SaStatus.Preparation; } } + public static List ValidStatuses { get { return new List(validStatuses); } } + public static DataValue.TriStateType GetStatusTriState(SaStatus status) + { + if (status == SaStatus.Preparation) return DataValue.TriStateType.Yellow; + if (status == SaStatus.InProgress) return DataValue.TriStateType.Green; + if (status == SaStatus.Completed) return DataValue.TriStateType.Blue; + if (status == SaStatus.Cancelled) return DataValue.TriStateType.Red; + if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple; + return DataValue.TriStateType.Unknown; + } + + //------------------------------------------------------------------- + // Utilities. + public ItemId GetItemId() + { + return new ItemId((short)Sax.DataItemType.UserReport, Id); + } + + //------------------------------------------------------------------- + // Properties. + public Data GetData() { return data.Clone(); } + public void SetData(Data data) + { + String fn = GetType().Name + ".SetData"; + // Properties that cannot be changed if previously specified. + if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) + throw new NotSupportedException(fn + " Id cannot be changed"); + if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId)) + throw new NotSupportedException(fn + " UserAccountId cannot be changed"); + this.data.PopulateFrom(data); + } + public SysId UserAccountId + { + get { return data.UserAccountId; } + protected set { data.UserAccountId = value; } + } + public Sax.UserReportType ReportType + { + get { return data.ReportType; } + set { data.ReportType = value; } + } + public String Title + { + get { return data.Title; } + set { data.Title = value; } + } + public String Report + { + get { return data.Report; } + set { data.Report = value; } + } + public DateTime RecordedOn + { + get { return data.RecordedOn; } + set { data.RecordedOn = value; } + } + public String ReportData + { + get { return data.ReportData; } + set { data.ReportData = value; } + } + + //------------------------------------------------------------------- + // Flags - positions 1-16 available. + + //------------------------------------------------------------------- + // A s s o c i a t e d D a t a + //------------------------------------------------------------------- + + //------------------------------------------------------------------- + // P a r a m s + //------------------------------------------------------------------- + // List parameters. + public enum StatusCat + { + Any, + Preparation, + Open, + Completed, + Cancelled, + Closed, + NotDeleted, + Deleted, + } + /// + /// 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 UserAccountIdsIncluded { get; } = new List(); + public List ReportTypesIncluded { get; } = new List(); + /// Generic filter - caption, report, or other matching value (tbd). + public String UserReportFilter { get; set; } + public String TitlePartial { get; set; } + public String ReportPartial { get; set; } + // Common properties. + public String NotesPartial { get; set; } + public StatusCat StatusCat { get; set; } = StatusCat.Open; + } + + //------------------------------------------------------------------- + } + //======================================================================= + // Item list extension methods. + public static class SaxUserReportList + { + //------------------------------------------------------------------- + public static SaxUserReport GetUserReportById(this IEnumerable values, SysId userReportId) + { + if (!SysId.IsValid(userReportId)) return null; + foreach (SaxUserReport userReport in values) + if (userReport.Id.Equals(userReportId)) return userReport; + return null; + } + + //------------------------------------------------------------------- + } + + //======================================================================= +} diff --git a/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs b/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs index 548d93b..abaae85 100644 --- a/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs +++ b/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs @@ -17,7 +17,7 @@ namespace Saxonite.Net.Standard.Base.Mgr // Data members. private class DataMembers { - public SaxInternals internals; + public SaxInternals internals = null; public bool internalsCreatedHere = false; } private DataMembers data = new DataMembers(); diff --git a/SaxoniteStandardBase/Base/Mgr/Support/SaxItemMgr_Support.cs b/SaxoniteStandardBase/Base/Mgr/Support/SaxItemMgr_Support.cs new file mode 100644 index 0000000..0f58ab6 --- /dev/null +++ b/SaxoniteStandardBase/Base/Mgr/Support/SaxItemMgr_Support.cs @@ -0,0 +1,42 @@ +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Net.Standard.Base.App; +using Saxonite.Net.Standard.Base.Consoles; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Saxonite.Net.Standard.Base.Mgr.Support +{ + //======================================================================= + public class SaxItemMgr_Support : SaxItemMgr + { + //------------------------------------------------------------------- + // Data members. + + //------------------------------------------------------------------- + protected SaxItemMgr_Support(SaxSessionContext sessionContext, SaxInternals internals) : + base (sessionContext, internals) + { + } + protected override void Dispose(bool disposing) + { + if (disposing) + { + } + base.Dispose(disposing); + } + + //------------------------------------------------------------------- + // Properties. + public ISacsDatabase SupportDatabase { get { return SaxGlobals.App.GetDatabase(SessionContext, Sax.Database.Support); } } + public IDatabaseInfo SupportDbInfo() { return SaxGlobals.App.CreateDbInfo(SessionContext, Sax.Database.Support); } + // Support. + public List UserReportTypeCodes { get { return Internals.UserReportTypeCodes; } } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardBase/Base/Mgr/Support/SaxSupportMgr-UserReport.cs b/SaxoniteStandardBase/Base/Mgr/Support/SaxSupportMgr-UserReport.cs new file mode 100644 index 0000000..5f0d1e3 --- /dev/null +++ b/SaxoniteStandardBase/Base/Mgr/Support/SaxSupportMgr-UserReport.cs @@ -0,0 +1,190 @@ +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Utils; +using Saxonite.Base.App; +using Saxonite.Net.Standard.Base.App; +using Saxonite.Net.Standard.Base.Bus; +using Saxonite.Net.Standard.Base.Bus.Support; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Saxonite.Net.Standard.Base.Mgr.Support +{ + //======================================================================= + partial class SaxSupportMgr + { + //******************************************************************* + // Support Mgr - User Report + //******************************************************************* + // Utilities. + + //------------------------------------------------------------------- + // Create item. + public abstract SaxUserReport CreateUserReport(SysId userAccountId); + + //------------------------------------------------------------------- + // Item exists. + public bool UserReportExistsById(SysId id) + { + ClearErrorState(); + if (!SysId.IsValid(id)) return false; + SaxUserReport.Params prmUserReport = new SaxUserReport.Params(); + prmUserReport.IdsIncluded.Add(id); + prmUserReport.StatusCat = SaxUserReport.StatusCat.Any; + return GetUserReportCount(prmUserReport) == 1; + } + + //------------------------------------------------------------------- + // Retrieve individual items. + public abstract SaxUserReport GetUserReport(SaxUserReport.Params prmUserReport); + public SaxUserReport GetUserReportById(SysId id) + { + ClearErrorState(); + if (!SysId.IsValid(id)) return null; + SaxUserReport.Params prmUserReport = new SaxUserReport.Params(); + prmUserReport.IdsIncluded.Add(id); + prmUserReport.StatusCat = SaxUserReport.StatusCat.Any; + return GetUserReport(prmUserReport); + } + + //------------------------------------------------------------------- + // Validate item data. + public bool IsValidUserReport(SaxUserReport userReport) + { + ClearErrorState(); + if (userReport == null) return SetErrorState(ErrorMessage.ItemNotSpecified); + return IsValidUserReportData(userReport.GetData(), new SaxUserReport.ErrField()); + } + public virtual bool IsValidUserReportData(SaxUserReport.Data data, SaxUserReport.ErrField errField) + { + ClearErrorState(); + + // User Account. + if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UserAccountId)) + { + errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid; + return SetErrorState("User Account Id must be specified"); + } + // Report Type. + if (errField.ReportType != SacsHierarchyItem.ValidValue.Ignore && (int)data.ReportType < 1) + { + errField.ReportType = SacsHierarchyItem.ValidValue.Invalid; + return SetErrorState("Report type must be specified"); + } + // Title. + if (errField.Title != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Title, "title", (long)SaxDbDfn_Support.GetColTextLen(SaxDbDfn_Support.ColumnIdx.UserReport_Title), true)) + { + errField.Title = SacsHierarchyItem.ValidValue.Invalid; + return false; + } + // Report. + if (errField.Report != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Report, "report", (long)SaxDbDfn_Support.GetColTextLen(SaxDbDfn_Support.ColumnIdx.UserReport_Report))) + { + errField.Report = SacsHierarchyItem.ValidValue.Invalid; + return false; + } + // Recorded On. + if (errField.RecordedOn != SacsHierarchyItem.ValidValue.Ignore && !DateUtil.IsValid(data.RecordedOn)) + { + errField.RecordedOn = SacsHierarchyItem.ValidValue.Invalid; + return SetErrorState("Recorded on date must be specified"); + } + + //--------------------------------------------------------------- + // Common properties. + if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Support.GetColTextLen(SaxDbDfn_Support.ColumnIdx.UserReport_Notes))) + { + errField.Notes = SacsHierarchyItem.ValidValue.Invalid; + return false; + } + if (errField.Status != SacsHierarchyItem.ValidValue.Ignore) + { + if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Support.GetColTextLen(SaxDbDfn_Support.ColumnIdx.UserReport_Status), true, true)) + { + errField.Status = SacsHierarchyItem.ValidValue.Invalid; + return false; + } + if (!SaxUserReport.ValidStatuses.Contains(data.Status)) + { + errField.Status = SacsHierarchyItem.ValidValue.Invalid; + return SetErrorState(ErrorMessage.InvalidStatus); + } + } + + //--------------------------------------------------------------- + return true; + } + + //------------------------------------------------------------------- + // Item database interface. + public abstract bool InsertUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo); + public abstract bool UpdateUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo); + public virtual bool UserReportCanBeDeleted(SaxUserReport userReport) + { + ClearErrorState(); + return true; + } + public abstract bool DeleteUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo); + + //------------------------------------------------------------------- + // Item list. + public abstract ColumnDfn GetUserReportColumnDfn(SaxUserReport.Column columnId, String caption = "", int width = 0); + public abstract List GetUserReportQueryFilter(SaxUserReport.Params prmUserReport); + public abstract long GetUserReportCount(SaxUserReport.Params prmUserReport); + public abstract List GetUserReportList(SaxUserReport.Params prmUserReport); + public abstract DbResultSet ExecuteUserReportQuery(List columns, SaxUserReport.Params prmUserReport); + + //------------------------------------------------------------------- + /// + /// 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 GetUserReportDataValue(ColumnDfn column, NamedValue.Map values) + { + DataValue value = new DataValue(); + switch ((SaxUserReport.Column)column.Id) + { + //----------------------------------------------------------- + // Report Type. + case SaxUserReport.Column.ReportType_Desc: + { + Sax.UserReportType userReportType = (Sax.UserReportType)values.GetValue(column.DataName).AsLong(); + value = new DataValue(UserReportTypeCodes.GetDescForType(userReportType)); + } + break; + + //----------------------------------------------------------- + // Notes. + case SaxUserReport.Column.Notes: + { + value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); + } + break; + + //----------------------------------------------------------- + // Status. + case SaxUserReport.Column.Status_Desc: + case SaxUserReport.Column.Status_Ind: + { + String statusCode = values.GetValue(column.DataName).ToString(); + SaStatus status = SacsSystem.GetStatusForCode(statusCode); + if (column.Id == (int)SaxUserReport.Column.Status_Desc) + value = new DataValue(SacsSystem.GetStatusDesc(status)); + else if (column.Id == (int)SaxUserReport.Column.Status_Ind) + value = new DataValue(SaxUserReport.GetStatusTriState(status)); + } + break; + + //----------------------------------------------------------- + } + return value; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardBase/Base/Mgr/Support/SaxSupportMgr.cs b/SaxoniteStandardBase/Base/Mgr/Support/SaxSupportMgr.cs new file mode 100644 index 0000000..5a5792f --- /dev/null +++ b/SaxoniteStandardBase/Base/Mgr/Support/SaxSupportMgr.cs @@ -0,0 +1,20 @@ +using Saxonite.Net.Standard.Base.App; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Saxonite.Net.Standard.Base.Mgr.Support +{ + //======================================================================= + public abstract partial class SaxSupportMgr : SaxItemMgr_Support + { + //------------------------------------------------------------------- + protected SaxSupportMgr(SaxSessionContext sessionContext, SaxInternals internals) : + base(sessionContext, internals) + { + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardDbas/Dbas/App/SaxSystem_Dbas.cs b/SaxoniteStandardDbas/Dbas/App/SaxSystem_Dbas.cs index aff35cf..2bfc751 100644 --- a/SaxoniteStandardDbas/Dbas/App/SaxSystem_Dbas.cs +++ b/SaxoniteStandardDbas/Dbas/App/SaxSystem_Dbas.cs @@ -1,6 +1,8 @@ using Saxonite.Net.Standard.Base.App; using Saxonite.Net.Standard.Base.Mgr; +using Saxonite.Net.Standard.Base.Mgr.Support; using Saxonite.Net.Standard.Dbas.Mgr; +using Saxonite.Net.Standard.Dbas.Mgr.Support; using System; using System.Collections.Generic; using System.Text; @@ -35,6 +37,10 @@ namespace Saxonite.Net.Standard.Dbas.App { return new SaxItemDataMgr_Dbas(sessionContext, internals); } + public override SaxSupportMgr CreateSupportMgr(SaxSessionContext sessionContext, SaxInternals internals) + { + return new SaxSupportMgr_Dbas(sessionContext, internals); + } //------------------------------------------------------------------- } diff --git a/SaxoniteStandardDbas/Dbas/Bus/Support/SaxUserReport_Dbas.cs b/SaxoniteStandardDbas/Dbas/Bus/Support/SaxUserReport_Dbas.cs new file mode 100644 index 0000000..88681fd --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Bus/Support/SaxUserReport_Dbas.cs @@ -0,0 +1,33 @@ +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Net.Standard.Base.Bus; +using Saxonite.Net.Standard.Base.Bus.Support; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Saxonite.Net.Standard.Dbas.Bus.Support +{ + //======================================================================= + public class SaxUserReport_Dbas : SaxUserReport + { + //------------------------------------------------------------------- + // Data members. + private ISacsDatabase database; + + //------------------------------------------------------------------- + // Construction. + public SaxUserReport_Dbas(ISacsDatabase database, SysId id, SysId userAccountId, UInt16 flags) : + base(id, userAccountId) + { + this.database = database; + Flags = flags; + } + + //------------------------------------------------------------------- + // Associated data. + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/ActivityFeedback_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/ActivityFeedback_Db.cs index c4fa9cb..d146528 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/ActivityFeedback_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/ActivityFeedback_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/ActivityIndex_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/ActivityIndex_Db.cs index 11f5b1e..7bbf2ad 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/ActivityIndex_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/ActivityIndex_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/Article_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/Article_Db.cs index 58b0f28..3776969 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/Article_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/Article_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/ItemAddress_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/ItemAddress_Db.cs index aca55a6..9e48368 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/ItemAddress_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/ItemAddress_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/ItemAssociation_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/ItemAssociation_Db.cs index 99b39d5..810ef5d 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/ItemAssociation_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/ItemAssociation_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/ItemImage_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/ItemImage_Db.cs index 11a4475..db92204 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/ItemImage_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/ItemImage_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/ItemSport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/ItemSport_Db.cs index 99b0681..3b64afc 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/ItemSport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/ItemSport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/OrganisationEvent_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/OrganisationEvent_Db.cs index b7e901e..f3885bb 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/OrganisationEvent_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/OrganisationEvent_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/OrganisationOpportunity_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/OrganisationOpportunity_Db.cs index d29ddf4..3d7cc1c 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/OrganisationOpportunity_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/OrganisationOpportunity_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/Organisation_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/Organisation_Db.cs index 1dfe933..d56b92b 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/Organisation_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/Organisation_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/Region_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/Region_Db.cs index 9209595..32fbc7b 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/Region_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/Region_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/Sport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/Sport_Db.cs index a280b34..86c50e5 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/Sport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/Sport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserAccount_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserAccount_Db.cs index fc3972d..eae3711 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserAccount_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserAccount_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserActivity_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserActivity_Db.cs index 3083daf..e18984a 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserActivity_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserActivity_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserConfig_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserConfig_Db.cs index d74cfde..41ddf33 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserConfig_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserConfig_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserEligibility_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserEligibility_Db.cs index f24dbe2..0af5773 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserEligibility_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserEligibility_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserOnline_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserOnline_Db.cs index 26b8896..ef14fa8 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserOnline_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserOnline_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserOrganisation_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserOrganisation_Db.cs index 257ba70..fd951bb 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserOrganisation_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserOrganisation_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserRole_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserRole_Db.cs index 4189b1c..7238732 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserRole_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserRole_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserSession_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserSession_Db.cs index db6546d..36e6d8e 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserSession_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserSession_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserSportExperience_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserSportExperience_Db.cs index 6e1c59b..641b015 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserSportExperience_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserSportExperience_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Core/UserSport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Core/UserSport_Db.cs index ac9e3cc..c943922 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Core/UserSport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Core/UserSport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Core { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Support/UserReportComment_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Support/UserReportComment_Db.cs index 725a292..6be8beb 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Support/UserReportComment_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Support/UserReportComment_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Support { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Support/UserReport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Support/UserReport_Db.cs index 293a303..0c52b05 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Support/UserReport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Support/UserReport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Mon 12-Dec-2022 13:20:42 +// Code generated by Sarand Database Utilities Sat 14-Jan-2023 12:13:03 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal.Support { @@ -22,6 +22,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal.Support public ColumnDataInt64 _Id { get; } = new ColumnDataInt64("Id", true); public ColumnDataInt32 _UserAccountId { get; } = new ColumnDataInt32("UserAccountId"); public ColumnDataInt16 _ReportType { get; } = new ColumnDataInt16("ReportType"); + public ColumnDataString _Title { get; } = new ColumnDataString("Title"); public ColumnDataString _Report { get; } = new ColumnDataString("Report"); public ColumnDataDateTime _RecordedOn { get; } = new ColumnDataDateTime("RecordedOn"); public ColumnDataString _ReportData { get; } = new ColumnDataString("ReportData"); @@ -43,6 +44,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal.Support "Id", "UserAccountId", "ReportType", + "Title", "Report", "RecordedOn", "ReportData", @@ -90,6 +92,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal.Support public Int64 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } } public Int32 _UserAccountId { get { return Cols._UserAccountId.Value; } set { Cols._UserAccountId.Value = value; } } public Int16 _ReportType { get { return Cols._ReportType.Value; } set { Cols._ReportType.Value = value; } } + public String _Title { get { return Cols._Title.Value; } set { Cols._Title.Value = value; } } public String _Report { get { return Cols._Report.Value; } set { Cols._Report.Value = value; } } public DateTime _RecordedOn { get { return Cols._RecordedOn.Value; } set { Cols._RecordedOn.Value = value; } } public String _ReportData { get { return Cols._ReportData.Value; } set { Cols._ReportData.Value = value; } } @@ -126,6 +129,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal.Support _Id = GetFieldInt64(dbDataReader, "Id", _Id); _UserAccountId = GetFieldInt32(dbDataReader, "UserAccountId", _UserAccountId); _ReportType = GetFieldInt16(dbDataReader, "ReportType", _ReportType); + _Title = GetFieldString(dbDataReader, "Title", _Title); _Report = GetFieldString(dbDataReader, "Report", _Report); _RecordedOn = GetFieldDateTime(dbDataReader, "RecordedOn", _RecordedOn); _ReportData = GetFieldString(dbDataReader, "ReportData", _ReportData); @@ -161,6 +165,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal.Support dbCommand.Parameters.Clear(); if (columnNames.ContainsCI("UserAccountId")) AddCommandParameter(dbCommand, "@UserAccountId", _UserAccountId); if (columnNames.ContainsCI("ReportType")) AddCommandParameter(dbCommand, "@ReportType", _ReportType); + if (columnNames.ContainsCI("Title")) AddCommandParameter(dbCommand, "@Title", _Title); if (columnNames.ContainsCI("Report")) AddCommandParameter(dbCommand, "@Report", _Report); if (columnNames.ContainsCI("RecordedOn")) AddCommandParameter(dbCommand, "@RecordedOn", _RecordedOn); if (columnNames.ContainsCI("ReportData")) AddCommandParameter(dbCommand, "@ReportData", _ReportData); @@ -211,6 +216,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal.Support dbCommand.Parameters.Clear(); if (columnNames.ContainsCI("UserAccountId")) AddCommandParameter(dbCommand, "@UserAccountId", _UserAccountId); if (columnNames.ContainsCI("ReportType")) AddCommandParameter(dbCommand, "@ReportType", _ReportType); + if (columnNames.ContainsCI("Title")) AddCommandParameter(dbCommand, "@Title", _Title); if (columnNames.ContainsCI("Report")) AddCommandParameter(dbCommand, "@Report", _Report); if (columnNames.ContainsCI("RecordedOn")) AddCommandParameter(dbCommand, "@RecordedOn", _RecordedOn); if (columnNames.ContainsCI("ReportData")) AddCommandParameter(dbCommand, "@ReportData", _ReportData); diff --git a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs index 9ac0eba..2bb3fd4 100644 --- a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs +++ b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs @@ -261,6 +261,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr private static readonly String prefixUserOrganisation_Organisation_Sport = "UsrOrg_Org_Spt_"; private static readonly String dataName_UserOrganisation_Organisation_Member_Count = "UsrOrg_Org_Mbr_Count"; private static readonly String dataName_UserOrganisation_Organisation_Opportunity_Count = "UsrOrg_Org_Opp_Count"; + private static readonly String dataName_UserOrganisation_Organisation_LogoImage_Count = "UsrOrg_Org_Logo_Count"; private void SetUserOrganisationColDfn (ColumnDfn col, String caption, int width, SaxDbDfn_Core.ColumnIdx dbCol, ColumnAlignment align = ColumnAlignment.Default, DataValue.DataType dataType = DataValue.DataType.String, @@ -385,6 +386,10 @@ namespace Saxonite.Net.Standard.Dbas.Mgr columnDfn.DataName = dataName_UserOrganisation_Organisation_Opportunity_Count; columnDfn.ReadOnly = true; break; + case SaxUserOrganisation.Column.Organisation_LogoImage_Count: + SetOrganisationColDfn(columnDfn, "Logos", 76, SaxDbDfn_Core.ColumnIdx.Unknown, ColumnAlignment.Center, DataValue.DataType.Long); + columnDfn.DataName = dataName_UserOrganisation_Organisation_LogoImage_Count; + break; //----------------------------------------------------------- // Properties. @@ -787,6 +792,22 @@ namespace Saxonite.Net.Standard.Dbas.Mgr query.Columns.Add("(" + qryOrgOpp.BuildQuery() + ")", dataName_UserOrganisation_Organisation_Opportunity_Count); } + //--------------------------------------------------------------------- + // Organisation Logo Image count. + if (columns.HasId(SaxUserOrganisation.Column.Organisation_LogoImage_Count)) + { + String aliasLogoCount = "Img_Org_Logo"; + DbQuery queryLogoCount = new DbQuery(CoreDatabase.DbmsType); + queryLogoCount.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.ItemImage), aliasLogoCount); + queryLogoCount.Columns.Add("Count(*)"); + queryLogoCount.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemImage_ItemType, aliasLogoCount) + "=" + (int)Sax.DataItemType.Organisation); + queryLogoCount.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemImage_ItemId, aliasLogoCount) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_OrganisationId, aliasUserOrganisation)); + queryLogoCount.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemImage_ImageType, aliasLogoCount) + "=" + (int)Sax.ImageType.OrganisationLogo); + queryLogoCount.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ItemImage_Status, aliasLogoCount) + "='" + SacsSystem.GetStatusCode(SaStatus.Active) + "'"); + // Construct sub-query. + query.Columns.Add("(" + queryLogoCount.BuildQuery() + ")", dataName_UserOrganisation_Organisation_LogoImage_Count); + } + //--------------------------------------------------------------------- // Populate filter. query.Filters.AddRange(GetUserOrganisationQueryFilter(prm)); diff --git a/SaxoniteStandardDbas/Dbas/Mgr/Support/SaxSupportMgr_Dbas-UserReport.cs b/SaxoniteStandardDbas/Dbas/Mgr/Support/SaxSupportMgr_Dbas-UserReport.cs new file mode 100644 index 0000000..ac98758 --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Mgr/Support/SaxSupportMgr_Dbas-UserReport.cs @@ -0,0 +1,563 @@ +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 System; +using System.Collections.Generic; +using System.Data.Common; +using System.Text; +using Saxonite.Net.Standard.Base.App; +using System.Linq; +using Sarand.Net.Standard.Base.Utils; +using Saxonite.Net.Standard.Dbas.Internal.Core; +using Saxonite.Net.Standard.Base.Bus.Support; +using Saxonite.Net.Standard.Dbas.Bus.Support; +using Saxonite.Net.Standard.Dbas.Internal.Support; + +namespace Saxonite.Net.Standard.Dbas.Mgr.Support +{ + //======================================================================= + partial class SaxSupportMgr_Dbas + { + //******************************************************************* + // Support Mgr - User Report + //******************************************************************* + // Utilities. + private List GetLogProperties(SaxUserReport userReport) + { + return new List() + { + new StringPair("Id",SysId.ToString(userReport.Id)), + new StringPair("UserAccountId",SysId.ToString(userReport.UserAccountId)), + new StringPair("ReportType",userReport.ReportType.ToString()), + new StringPair("Status",userReport.StatusCode) + }; + } + + //------------------------------------------------------------------- + // Create item. + public override SaxUserReport CreateUserReport(SysId userAccountId) + { + ClearErrorState(); + return new SaxUserReport_Dbas(CoreDatabase, null, userAccountId, 0); + } + private SaxUserReport_Dbas CreateUserReport(UserReport_Db dbUserReport) + { + ClearErrorState(); + SaxUserReport_Dbas userReport = new SaxUserReport_Dbas(CoreDatabase, new SysId(dbUserReport._Id), new SysId(dbUserReport._UserAccountId), (ushort)dbUserReport._Flags); + PopulateFrom(dbUserReport, userReport); + return userReport; + } + + //------------------------------------------------------------------- + // Get item. + public override SaxUserReport GetUserReport(SaxUserReport.Params prm) + { + ClearErrorState(); + return GetUserReport(GetUserReportQueryFilter(prm).Concat(" And ", "(", ")")); + } + private SaxUserReport GetUserReport(String filter) + { + ClearErrorState(); + long count = GetUserReportCount(filter); + if (count == 0) return null; + if (count != 1) + { + SetErrorState("Multiple items found"); + return null; + } + SaxUserReport userReport = null; + // Query data. + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + dbConnection.Open(); + UserReport_Db dbUserReport = new UserReport_Db(CoreDbInfo); + dbUserReport.PopulateFrom(dbCommand, aliasUserReport, filter); + userReport = CreateUserReport(dbUserReport); + } + catch (Exception exc) + { + SetErrorState("Database query exception"); + SaLogger.Warn(GetType().Name + ".GetUserReport\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc)); + } + } + return userReport; + } + + //------------------------------------------------------------------- + // Validate item. + public override bool IsValidUserReportData(SaxUserReport.Data data, SaxUserReport.ErrField errField) + { + ClearErrorState(); + if (!base.IsValidUserReportData(data, errField)) return false; + return true; + } + + //------------------------------------------------------------------- + // Insert item. + public override bool InsertUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".InsertUserReport"; + ClearErrorState(); + if (!IsValidUserReport(userReport)) return false; + if (SysId.IsValid(userReport.Id)) return SetErrorState(ErrorMessage.ValiditemId); + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + dbConnection.Open(); + UserReport_Db dbUserReport = new UserReport_Db(CoreDbInfo); + PopulateTo(dbUserReport, userReport, dbUpdateInfo); + if (UserReport_Db.FieldsNonId.Contains("Id")) + { + // Generate next Id. + dbUserReport._Id = CoreDatabase.GetNextIdFromTable("UserReport"); + } + dbUserReport.ExecuteInsertCommand(dbCommand); + userReport.Id = new SysId(dbUserReport._Id); + userReport.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(userReport).Concat(": ").Concat("", "\n\t")); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Update item. + public override bool UpdateUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".UpdateUserReport"; + ClearErrorState(); + if (!IsValidUserReport(userReport)) return false; + if (!SysId.IsValid(userReport.Id)) return SetErrorState(ErrorMessage.InvalidItemId); + if (!userReport.Changed) + { + if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(userReport).Concat(": ").Concat("", "\n\t")); + return true; + } + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + // Retrieve item. + dbConnection.Open(); + UserReport_Db dbUserReport = new UserReport_Db(CoreDbInfo); + dbUserReport.PopulateFrom(dbCommand, aliasUserReport, "Id=" + SysId.ToString(userReport.Id)); + // ToDo SaxUpdateLogItemMonitor_UserReport updateLogMonitor = new SaxUpdateLogItemMonitor_UserReport(SessionContext, CreateUserReport(dbUserReport), dbUpdateInfo); + // Update item. + PopulateTo(dbUserReport, userReport, dbUpdateInfo); + dbUserReport.ExecuteUpdateCommand(dbCommand); + userReport.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(userReport).Concat(": ").Concat("", "\n\t")); + // Record updates. + // ToDo updateLogMonitor.RecordUpdatedValues(userReport); + // ToDo updateLogMonitor.LogUpdates(); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Delete item. + public override bool UserReportCanBeDeleted(SaxUserReport userReport) + { + ClearErrorState(); + if (!base.UserReportCanBeDeleted(userReport)) return false; + return true; + } + public override bool DeleteUserReport(SaxUserReport userReport, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".DeleteUserReport"; + ClearErrorState(); + if (!UserReportCanBeDeleted(userReport)) return false; + + // User Roles are logically deleted by changing the status. + userReport.Status = SaStatus.Deleted; + return UpdateUserReport(userReport, dbUpdateInfo); + + /* + * Physical deletion. + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + // Retrieve item. + dbConnection.Open(); + UserReport_Db dbUserReport = new UserReport_Db(CoreDbInfo); + dbUserReport.PopulateFrom(dbCommand, aliasUserReport, "Id=" + userReport.Id.ToString()); + // Delete item. + dbCommand.CommandType = System.Data.CommandType.Text; + dbCommand.CommandText = "DELETE FROM " + SaxDbDfn_Support.GetTableName(SaxDbDfn_Support.TableIdx.UserReport) + " WHERE Id=" + SysId.ToString(userReport.Id) + ";"; + dbCommand.ExecuteNonQuery(); + userReport.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(userReport).Concat(": ").Concat("", "\n\t")); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + */ + } + + //------------------------------------------------------------------- + // Copy data properties to and from database. + private void PopulateTo(UserReport_Db dbUserReport, SaxUserReport userReport, DbUpdateInfo dbUpdateInfo) + { + dbUserReport._Id = SysId.ToLong(userReport.Id); + dbUserReport._UserAccountId = SysId.ToInt(userReport.UserAccountId); + dbUserReport._ReportType = (short)userReport.ReportType; + dbUserReport._Title = userReport.Title; + dbUserReport._Report = userReport.Report; + dbUserReport._ReportData = userReport.ReportData; + dbUserReport._RecordedOn = userReport.RecordedOn; + // Common. + dbUserReport._Notes = userReport.Notes; + dbUserReport._Status = SacsSystem.GetStatusCode(userReport.Status); + dbUserReport._Flags = (short)userReport.Flags; + if (!SysId.IsValid(userReport.Id)) + { + dbUserReport._CreateOn = DateTime.Now; + dbUserReport._CreateBy = dbUpdateInfo.UserId.ToInt(); + dbUserReport._CreateHost = dbUpdateInfo.Host; + } + dbUserReport._UpdateOn = DateTime.Now; + dbUserReport._UpdateBy = dbUpdateInfo.UserId.ToInt(); + dbUserReport._UpdateHost = dbUpdateInfo.Host; + } + private void PopulateFrom(UserReport_Db dbUserReport, SaxUserReport userReport) + { + //userReport.Id = new SysId(dbUserReport._Id); + //userReport.UserAccountId = new SysId(dbUserReport._UserAccountId); + userReport.ReportType = (Sax.UserReportType)dbUserReport._ReportType; + userReport.Title = dbUserReport._Title; + userReport.Report = dbUserReport._Report; + userReport.ReportData = dbUserReport._ReportData; + userReport.RecordedOn = dbUserReport._RecordedOn; + // Common. + userReport.Notes = dbUserReport._Notes; + userReport.Status = SacsSystem.GetStatusForCode(dbUserReport._Status); + userReport.SetCreateStamp(dbUserReport._CreateOn, new SysId(dbUserReport._CreateBy), dbUserReport._CreateHost); + userReport.SetUpdateStamp(dbUserReport._UpdateOn, new SysId(dbUserReport._UpdateBy), dbUserReport._UpdateHost); + userReport.AcceptChanges(); + } + + //------------------------------------------------------------------- + // Item column definitions. + private static readonly String aliasUserReport = "UsrRpt"; + private static readonly String aliasUserReport_UserAccount = "UsrRpt_Usr"; + private static readonly String prefixUserReport_UserAccount = aliasUserReport_UserAccount + "_"; + private void SetUserReportColDfn + (ColumnDfn col, String caption, int width, SaxDbDfn_Support.ColumnIdx dbCol, + ColumnAlignment align = ColumnAlignment.Default, DataValue.DataType dataType = DataValue.DataType.String, + String alias = "", String prefix = "") + { + if (String.IsNullOrEmpty(alias) && SaxDbDfn_Support.GetTableForColumn(dbCol) == SaxDbDfn_Support.TableIdx.UserReport) + alias = aliasUserReport; + col.Set(caption, width, (int)dbCol, prefix + SaxDbDfn_Support.GetColumnName(dbCol, false), SaxDbDfn_Support.GetColumnNameQual(dbCol, alias), dataType, align); + if (dataType == DataValue.DataType.String && dbCol != SaxDbDfn_Support.ColumnIdx.Unknown) + col.MaxLength = (int)SaxDbDfn_Support.GetColTextLen(dbCol); + } + public override ColumnDfn GetUserReportColumnDfn(SaxUserReport.Column columnId, string caption = "", int width = 0) + { + ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width); + switch (columnId) + { + //----------------------------------------------------------- + case SaxUserReport.Column.Pos: + SetUserReportColDfn(columnDfn, "Pos", 60, SaxDbDfn_Support.ColumnIdx.Unknown, ColumnAlignment.Right); + columnDfn.SortMode = ColumnDfn.ColumnSortMode.Off; + columnDfn.ReadOnly = true; + columnDfn.Resizable = false; + break; + case SaxUserReport.Column.UserAccountId: + SetUserReportColDfn(columnDfn, "User Id", 80, SaxDbDfn_Support.ColumnIdx.UserReport_UserAccountId, ColumnAlignment.Right, DataValue.DataType.Long); + columnDfn.ReadOnly = true; + break; + case SaxUserReport.Column.Id: + SetUserReportColDfn(columnDfn, "Id", 80, SaxDbDfn_Support.ColumnIdx.UserReport_Id, ColumnAlignment.Right, DataValue.DataType.Long); + columnDfn.ReadOnly = true; + break; + + //------------------------------------------------------- + case SaxUserReport.Column.ReportType: + SetUserReportColDfn(columnDfn, "Type", 80, SaxDbDfn_Support.ColumnIdx.UserReport_ReportType, ColumnAlignment.Center, DataValue.DataType.Long); + columnDfn.ReadOnly = true; + break; + case SaxUserReport.Column.ReportType_Desc: + SetUserReportColDfn(columnDfn, "Type", 120, SaxDbDfn_Support.ColumnIdx.UserReport_ReportType, ColumnAlignment.Center); + columnDfn.ReadOnly = true; + break; + case SaxUserReport.Column.Title: + SetUserReportColDfn(columnDfn, "Title", 120, SaxDbDfn_Support.ColumnIdx.UserReport_Title); + break; + case SaxUserReport.Column.Report: + SetUserReportColDfn(columnDfn, "Report", 120, SaxDbDfn_Support.ColumnIdx.UserReport_Report); + break; + case SaxUserReport.Column.RecordedOn: + SetUserReportColDfn(columnDfn, "Recorded", 100, SaxDbDfn_Support.ColumnIdx.UserReport_RecordedOn, ColumnAlignment.Center, DataValue.DataType.Date); + columnDfn.ReadOnly = true; + break; + + //----------------------------------------------------------- + // Derived properties. + + //----------------------------------------------------------- + // Common properties. + case SaxUserReport.Column.Notes: + SetUserReportColDfn(columnDfn, "Notes", 240, SaxDbDfn_Support.ColumnIdx.UserReport_Notes); + break; + case SaxUserReport.Column.Flags: + SetUserReportColDfn(columnDfn, "Flags", 60, SaxDbDfn_Support.ColumnIdx.UserReport_Flags, ColumnAlignment.Center, DataValue.DataType.Long); + break; + case SaxUserReport.Column.Status: + SetUserReportColDfn(columnDfn, "Status", 80, SaxDbDfn_Support.ColumnIdx.UserReport_Status, ColumnAlignment.Center); + break; + case SaxUserReport.Column.Status_Desc: + SetUserReportColDfn(columnDfn, "Status", 90, SaxDbDfn_Support.ColumnIdx.UserReport_Status, ColumnAlignment.Center); + break; + case SaxUserReport.Column.Status_Ind: + SetUserReportColDfn(columnDfn, "Status", 80, SaxDbDfn_Support.ColumnIdx.UserReport_Status, ColumnAlignment.Center, DataValue.DataType.TriState); + columnDfn.TriStateFormat = ColumnTriStateFormat.Lights; + break; + case SaxUserReport.Column.CreateOn_Date: + SetUserReportColDfn(columnDfn, "Created", 80, SaxDbDfn_Support.ColumnIdx.UserReport_CreateOn, ColumnAlignment.Center, DataValue.DataType.Date); + columnDfn.ReadOnly = true; + break; + case SaxUserReport.Column.UpdateOn_Date: + SetUserReportColDfn(columnDfn, "Updated", 80, SaxDbDfn_Support.ColumnIdx.UserReport_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 GetUserReportQueryFilter(SaxUserReport.Params prm) + { + List filter = new List(); + + // Item Ids. + String idsIncluded = prm.IdsIncluded.Concat(","); + if (!idsIncluded.IsEmpty()) + filter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Id, aliasUserReport) + " IN (" + idsIncluded + ")"); + String idsxcluded = prm.IdsExcluded.Concat(","); + if (!idsxcluded.IsEmpty()) + filter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Id, aliasUserReport) + " NOT IN (" + idsxcluded + ")"); + + // User accounts. + String userAccountIdsIncluded = prm.UserAccountIdsIncluded.Concat(","); + if (!userAccountIdsIncluded.IsEmpty()) + filter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_UserAccountId, aliasUserReport) + " IN (" + userAccountIdsIncluded + ")"); + + // Report Types. + String reportTypes = prm.ReportTypesIncluded.Select(item => ((int)item).ToString()).Concat(",", "'", "'", true, true); + if (!reportTypes.IsEmpty()) + filter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_ReportType, aliasUserReport) + " IN (" + reportTypes + ")"); + + if (StringUtil.IsBlank(prm.UserReportFilter)) + { + // Split filter into words. + List filterWords = prm.UserReportFilter.Split((char[])null).ToList(); + filterWords.RemoveDuplicatesCI(); + filterWords.RemoveBlanks(); + foreach (String filterWord in filterWords) + { + List articleFilter = new List(); + articleFilter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Title, aliasUserReport) + " Like '%" + DbQuery.FormatForLike(filterWord, true) + "%'"); + articleFilter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Report, aliasUserReport) + " Like '%" + DbQuery.FormatForLike(filterWord, true) + "%'"); + filter.Add(articleFilter.Concat(" OR ", "(", ")")); + } + } + + // Title. + if (!StringUtil.IsEmpty(prm.TitlePartial)) + filter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Title, aliasUserReport) + " LIKE '%" + DbQuery.FormatForLike(prm.TitlePartial) + "%'"); + + // Report. + if (!StringUtil.IsEmpty(prm.ReportPartial)) + filter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Report, aliasUserReport) + " LIKE '%" + DbQuery.FormatForLike(prm.ReportPartial) + "%'"); + + // Notes. + if (!StringUtil.IsEmpty(prm.NotesPartial)) + filter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Notes, aliasUserReport) + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'"); + + // Status. + if (prm.StatusCat != SaxUserReport.StatusCat.Any) + filter.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Status, aliasUserReport) + GetUserReportStatusCatFilterCondition(prm.StatusCat)); + + if (filter.Count < 1) filter.Add("1=1"); + return filter; + } + internal static String GetUserReportStatusCatFilterCondition(SaxUserReport.StatusCat statusCat) + { + if (statusCat == SaxUserReport.StatusCat.Preparation) + return "='" + SacsSystem.GetStatusCode(SaStatus.Preparation) + "'"; + if (statusCat == SaxUserReport.StatusCat.Open) + return "='" + SacsSystem.GetStatusCode(SaStatus.InProgress) + "'"; + if (statusCat == SaxUserReport.StatusCat.Completed) + return "='" + SacsSystem.GetStatusCode(SaStatus.Completed) + "'"; + if (statusCat == SaxUserReport.StatusCat.Cancelled) + return "='" + SacsSystem.GetStatusCode(SaStatus.Cancelled) + "'"; + if (statusCat == SaxUserReport.StatusCat.Closed) + return " IN ('" + SacsSystem.GetStatusCode(SaStatus.Completed) + "','" + SacsSystem.GetStatusCode(SaStatus.Cancelled) + "')"; + if (statusCat == SaxUserReport.StatusCat.NotDeleted) + return "!='" + SacsSystem.GetStatusCode(SaStatus.Deleted) + "'"; + if (statusCat == SaxUserReport.StatusCat.Deleted) + return "='" + SacsSystem.GetStatusCode(SaStatus.Deleted) + "'"; + return ""; + } + // Item sort columns. + public List GetUserReportSortColumns(SaxUserReport.Params prm) + { + // Sort sequence: + List sortColumnNames = new List(); + foreach (var columnDfn in prm.SortColumns) + { + // Need to ensure correct alias used for UserReport columns in case of conflict. + String sortCol = String.Empty; + if (SaxDbDfn_Support.GetTableForColumn((SaxDbDfn_Support.ColumnIdx)columnDfn.DbColumn) == SaxDbDfn_Support.TableIdx.UserReport) + { + sortCol = SaxDbDfn_Support.GetColumnNameQual((SaxDbDfn_Support.ColumnIdx)columnDfn.DbColumn, aliasUserReport); + } + 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_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Id, aliasUserReport) + " ASC"); + } + return sortColumnNames; + } + + //------------------------------------------------------------------- + // Item count. + private long GetUserReportCount(String filter) + { + ClearErrorState(); + return CoreDatabase.GetRowCount(SaxDbDfn_Support.GetTableName(SaxDbDfn_Support.TableIdx.UserReport) + " As " + aliasUserReport, filter); + } + public override long GetUserReportCount(SaxUserReport.Params prm) + { + ClearErrorState(); + return GetUserReportCount(GetUserReportQueryFilter(prm).Concat(" AND ", "(", ")")); + } + + //------------------------------------------------------------------- + // Item list. + public override List GetUserReportList(SaxUserReport.Params prm) + { + List userRoles = new List(); + DbQuery qry = new DbQuery(CoreDatabase.DbmsType); + qry.Tables.Add(SaxDbDfn_Support.GetTableName(SaxDbDfn_Support.TableIdx.UserReport), aliasUserReport); + UserReport_Db dbUserReport = new UserReport_Db(CoreDbInfo); + qry.Columns.AddRange(dbUserReport.ExistingColumnNames); + qry.Filters.AddRange(GetUserReportQueryFilter(prm)); + qry.OrderBy.AddRange(GetUserReportSortColumns(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()) + { + dbUserReport = new UserReport_Db(CoreDbInfo); + dbUserReport.PopulateFrom(dbDataReader); + userRoles.Add(CreateUserReport(dbUserReport)); + } + } + } + catch (Exception exc) + { + SaLogger.Warn(GetType().Name + ".GetUserReportList\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc)); + } + } + return userRoles; + } + + //------------------------------------------------------------------- + // Item query execution. + public override DbResultSet ExecuteUserReportQuery(List columns, SaxUserReport.Params prm) + { + ClearErrorState(); + + //--------------------------------------------------------------------- + // Construct query. + DbQuery query = new DbQuery(CoreDatabase.DbmsType); + query.Tables.Add(SaxDbDfn_Support.GetTableName(SaxDbDfn_Support.TableIdx.UserReport), aliasUserReport); + + // Add columns as defined in query list. + if (columns.HasId(SaxUserReport.Column.Id)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Id, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.UserAccountId)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_UserAccountId, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.ReportType) || columns.HasId(SaxUserReport.Column.ReportType_Desc)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_ReportType, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.Title)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Title, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.Report)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Report, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.RecordedOn)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_RecordedOn, aliasUserReport)); + // Common properties. + if (columns.HasId(SaxUserReport.Column.Notes)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Notes, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.Flags)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Flags, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.Status) || columns.HasId(SaxUserReport.Column.Status_Desc) || columns.HasId(SaxUserReport.Column.Status_Ind)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_Status, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.CreateOn_Date)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_CreateOn, aliasUserReport)); + if (columns.HasId(SaxUserReport.Column.UpdateOn_Date)) + query.Columns.Add(SaxDbDfn_Support.GetColumnNameQual(SaxDbDfn_Support.ColumnIdx.UserReport_UpdateOn, aliasUserReport)); + + //--------------------------------------------------------------------- + // Populate filter. + query.Filters.AddRange(GetUserReportQueryFilter(prm)); + + if (prm.IdsIncluded.Count != 1) + { + // Configure sort sequence. + foreach (String sortColumn in GetUserReportSortColumns(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/Dbas/Mgr/Support/SaxSupportMgr_Dbas.cs b/SaxoniteStandardDbas/Dbas/Mgr/Support/SaxSupportMgr_Dbas.cs new file mode 100644 index 0000000..cf58ee2 --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Mgr/Support/SaxSupportMgr_Dbas.cs @@ -0,0 +1,30 @@ +using Saxonite.Net.Standard.Base.App; +using Saxonite.Net.Standard.Base.Mgr.Support; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Saxonite.Net.Standard.Dbas.Mgr.Support +{ + //======================================================================= + public partial class SaxSupportMgr_Dbas : SaxSupportMgr + { + //------------------------------------------------------------------- + // Data members. + + //------------------------------------------------------------------- + // Construction. + public SaxSupportMgr_Dbas(SaxSessionContext sessionContext, SaxInternals internals) : + base (sessionContext, internals) + { + } + + //------------------------------------------------------------------- + // Properties. + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Support.xml b/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Support.xml index dedb1f4..11ed40b 100644 --- a/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Support.xml +++ b/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Support.xml @@ -61,6 +61,23 @@ dbo UserReport
4 + Title + VarChar + + -9 + nvarchar + false + 1000 + 2000 + 0 + NoNulls + false + + + + dbo + UserReport
+ 5 Report VarChar @@ -77,7 +94,7 @@ dbo UserReport
- 5 + 6 RecordedOn DateTime @@ -94,7 +111,7 @@ dbo UserReport
- 6 + 7 ReportData VarChar @@ -111,7 +128,7 @@ dbo UserReport
- 7 + 8 Notes VarChar @@ -128,7 +145,7 @@ dbo UserReport
- 8 + 9 Flags SmallInt @@ -145,7 +162,7 @@ dbo UserReport
- 9 + 10 Status VarChar @@ -162,7 +179,7 @@ dbo UserReport
- 10 + 11 CreateOn DateTime @@ -179,7 +196,7 @@ dbo UserReport
- 11 + 12 CreateBy Int @@ -196,7 +213,7 @@ dbo UserReport
- 12 + 13 CreateHost VarChar @@ -213,7 +230,7 @@ dbo UserReport
- 13 + 14 UpdateOn DateTime @@ -230,7 +247,7 @@ dbo UserReport
- 14 + 15 UpdateBy Int @@ -247,7 +264,7 @@ dbo UserReport
- 15 + 16 UpdateHost VarChar