v1.0.6.2
This commit is contained in:
@@ -231,41 +231,41 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
|
||||
IndexStatsData stats = new IndexStatsData();
|
||||
|
||||
// Index entries required for activity.
|
||||
List<IndexEntryData> indexEntries = GetEntriesForIndex(indexData);
|
||||
List<IndexEntryData> indexEntryDataList = GetEntriesForIndex(indexData);
|
||||
|
||||
// Retrieve existing index entries for the item.
|
||||
List<SaxActivityIndex> itemIndexEntries = internals.ActivityMgr.GetActivityIndexListForItem(indexData.ItemId);
|
||||
foreach (SaxActivityIndex itemIndexEntry in itemIndexEntries)
|
||||
List<SaxActivityIndex> indexEntries = internals.ActivityMgr.GetActivityIndexListForItem(indexData.ItemId);
|
||||
foreach (SaxActivityIndex indexEntry in indexEntries)
|
||||
{
|
||||
// Is the index entry still required.
|
||||
// Logic only compares the Ids (item, sport, region) and then updates the effective date if a match is found.
|
||||
// Based on the fact that and change in the effective date will impact all entries in the index for the item
|
||||
// and this approach minimises the number of updates required as Ids can't be changed in code (protected setters).
|
||||
IndexEntryData indexEntry = indexEntries.Find(item => item.MatchesIds(itemIndexEntry));
|
||||
if (indexEntry != null)
|
||||
IndexEntryData indexEntrydata = indexEntryDataList.Find(item => item.MatchesIds(indexEntry));
|
||||
if (indexEntrydata != null)
|
||||
{
|
||||
// Match found - if the effective date differs, update it.
|
||||
if (!itemIndexEntry.EffectiveOn.Equals(indexEntry.EffectiveOn))
|
||||
if (!indexEntry.EffectiveOn.Equals(indexEntrydata.EffectiveOn))
|
||||
{
|
||||
itemIndexEntry.EffectiveOn = indexEntry.EffectiveOn;
|
||||
if (internals.ActivityMgr.UpdateActivityIndex(itemIndexEntry, dbUpdateInfo))
|
||||
indexEntry.EffectiveOn = indexEntrydata.EffectiveOn;
|
||||
if (internals.ActivityMgr.UpdateActivityIndex(indexEntry, dbUpdateInfo))
|
||||
stats.EntriesUpdated++;
|
||||
else SaLogger.Warn(fn + " Failed to update Activity Index - " + internals.ActivityMgr.ErrorStateMessage);
|
||||
}
|
||||
// Remove the entry from the 'required' list.
|
||||
// Entries remaining in this list will be created.
|
||||
indexEntries.Remove(indexEntry);
|
||||
indexEntryDataList.Remove(indexEntrydata);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Index entry no longer required.
|
||||
if (internals.ActivityMgr.DeleteActivityIndex(itemIndexEntry, dbUpdateInfo))
|
||||
if (internals.ActivityMgr.DeleteActivityIndex(indexEntry, dbUpdateInfo))
|
||||
stats.EntriesDeleted++;
|
||||
else SaLogger.Warn(fn + " Failed to delete Activity Index - " + internals.ActivityMgr.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
// The remaining required Index entries will be created.
|
||||
foreach (IndexEntryData indexEntry in indexEntries)
|
||||
foreach (IndexEntryData indexEntry in indexEntryDataList)
|
||||
{
|
||||
SaxActivityIndex itemIndexEntry = internals.ActivityMgr.CreateActivityIndex(indexEntry.ItemId, indexEntry.SportId, indexEntry.RegionId, indexEntry.EffectiveOn);
|
||||
if (internals.ActivityMgr.InsertActivityIndex(itemIndexEntry, dbUpdateInfo))
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Saxonite.Net.Core.Web.Admin.App
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private bool generateDatabaseDefinitions = false;
|
||||
private bool generateDatabaseDefinitions = true;
|
||||
private bool populateRegions = false;
|
||||
private Dictionary<String, SaxSessionConfig> sessionConfigs = new Dictionary<string, SaxSessionConfig>();
|
||||
private Dictionary<String, SaxEmailConfig> emailConfigs = new Dictionary<string, SaxEmailConfig>();
|
||||
|
||||
@@ -145,6 +145,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
|
||||
SaDbProcess_CompareDatabaseSchemas.Config cfgSchemaCompare = new SaDbProcess_CompareDatabaseSchemas.Config(tables, db);
|
||||
cfgSchemaCompare.HideIdenticalObjects = true;
|
||||
cfgSchemaCompare.IgnorePosition = true;
|
||||
SaDbProcess_CompareDatabaseSchemas procSchemaCompare = new SaDbProcess_CompareDatabaseSchemas(cfgSchemaCompare);
|
||||
procSchemaCompare.ProcessNotifier = this;
|
||||
procSchemaCompare.RunProcess();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
<div class="SchemaIndex">@(Localiser["label.index"]): <span class="IndexName"></span></div>
|
||||
<div class="SChemColumn">@(Localiser["label.column"]): <span class="ColumnName"></span></div>
|
||||
<div class="SchemaColumn">@(Localiser["label.column"]): <span class="ColumnName"></span></div>
|
||||
<div class=""><span class="Comment"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 sax-note">@Localiser["label.participation"]: <span class="SportParticipation"></span></div>
|
||||
<div class="col-sm-6 sax-note">@Localiser["label.officiating"]: <span class="SportOfficiating"></span></div>
|
||||
<div class="col-sm-6 SportParticipation sax-note">@Localiser["label.participation"]: <span class="SportParticipationValue"></span></div>
|
||||
<div class="col-sm-6 SportOfficiating sax-note">@Localiser["label.officiating"]: <span class="SportOfficiatingValue"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -126,7 +126,10 @@
|
||||
let $item = $tmpl.clone().prop('id', 'ProSpt_' + item.id);
|
||||
$('.sax-header .sax-action.sax-edit', $item).on('click', function (evt) { sax.updateProfileSport(item.id); });
|
||||
$('.SportName', $item).text(item.sportName);
|
||||
$('.SportParticipation', $item).text(item.sportParticipation);
|
||||
$('.SportParticipationValue', $item).text(item.sportParticipation);
|
||||
$('.SportParticipation', $item).toggle(!!item.sportParticipation);
|
||||
$('.SportOfficiatingValue', $item).text(item.sportOfficiating);
|
||||
$('.SportOfficiating', $item).toggle(!!item.sportOfficiating);
|
||||
$items.append($item);
|
||||
}
|
||||
$items.show();
|
||||
@@ -151,7 +154,7 @@
|
||||
}
|
||||
sax.doUpdateProfileSport = function (response)
|
||||
{
|
||||
//sax.debug('doUpdateProfileSport', response);
|
||||
sax.debug('doUpdateProfileSport', response);
|
||||
let $dlg = sax.$dlg.profileSport;
|
||||
let item = response.sport;
|
||||
$('.UserSportId', $dlg).val(item.id);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
public static class Version
|
||||
{
|
||||
private static String version { get; } = "1.0.6.0";
|
||||
private static String version { get; } = "1.0.6.2";
|
||||
// Retrieve version.
|
||||
public static String GetFullVersion () { return version; }
|
||||
public static String GetAppVersion ()
|
||||
@@ -40,8 +40,9 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Version history.
|
||||
//-------------------------------------------------------------------
|
||||
// 1.0.6 ?-Jun-2021 ???
|
||||
// - ?.
|
||||
// 1.0.6 2-Jun-2021 Online Profile
|
||||
// - Refresh Online Session with profile region and sport changes.
|
||||
// - Profile Sport - participation and officiating dropdowns.
|
||||
// 1.0.5 31-May-2021 Activity Index
|
||||
// - Admin Database Schema (Home) and Tables page.
|
||||
// - Online Account country, Home activities.
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Base.App
|
||||
{
|
||||
@@ -27,6 +27,7 @@ namespace Saxonite.Base.App
|
||||
UserAccount,
|
||||
UserOrganisation,
|
||||
UserRole,
|
||||
UserSession,
|
||||
UserSport,
|
||||
}
|
||||
|
||||
@@ -198,6 +199,12 @@ namespace Saxonite.Base.App
|
||||
UserRole_UpdateOn,
|
||||
UserRole_UpdateBy,
|
||||
UserRole_UpdateHost,
|
||||
UserSession_UserAccountId,
|
||||
UserSession_ActivityIndexIds,
|
||||
UserSession_UserSessionData,
|
||||
UserSession_Flags,
|
||||
UserSession_CreateOn,
|
||||
UserSession_UpdateOn,
|
||||
UserSport_Id,
|
||||
UserSport_UserAccountId,
|
||||
UserSport_SportId,
|
||||
@@ -217,8 +224,8 @@ namespace Saxonite.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 11;
|
||||
private static readonly int columnCount = 178;
|
||||
private static readonly int tableCount = 12;
|
||||
private static readonly int columnCount = 184;
|
||||
private static ulong maxTextLen = 0;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -374,6 +381,7 @@ namespace Saxonite.Base.App
|
||||
"UserAccount",
|
||||
"UserOrganisation",
|
||||
"UserRole",
|
||||
"UserSession",
|
||||
"UserSport",
|
||||
};
|
||||
|
||||
@@ -552,7 +560,7 @@ namespace Saxonite.Base.App
|
||||
new ColumnDfn(9,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(9,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(9,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(10,"Id",4,4,true,10),
|
||||
new ColumnDfn(10,"Id",5,-5,true,19),
|
||||
new ColumnDfn(10,"UserAccountId",4,4,false,10),
|
||||
new ColumnDfn(10,"UserRoleCode",0,12,false,16),
|
||||
new ColumnDfn(10,"Notes",0,-9,false,2000),
|
||||
@@ -564,21 +572,27 @@ namespace Saxonite.Base.App
|
||||
new ColumnDfn(10,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(10,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(10,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(11,"Id",4,4,true,10),
|
||||
new ColumnDfn(11,"UserAccountId",4,4,false,10),
|
||||
new ColumnDfn(11,"SportId",4,4,false,10),
|
||||
new ColumnDfn(11,"Participation",3,5,false,5),
|
||||
new ColumnDfn(11,"Officiating",3,5,false,5),
|
||||
new ColumnDfn(11,"UserSportData",0,-9,false,0),
|
||||
new ColumnDfn(11,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(11,"ActivityIndexIds",0,-9,false,0),
|
||||
new ColumnDfn(11,"UserSessionData",0,-9,false,0),
|
||||
new ColumnDfn(11,"Flags",3,5,false,5),
|
||||
new ColumnDfn(11,"Status",0,12,false,3),
|
||||
new ColumnDfn(11,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(11,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(11,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(11,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(11,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(11,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(12,"Id",4,4,true,10),
|
||||
new ColumnDfn(12,"UserAccountId",4,4,false,10),
|
||||
new ColumnDfn(12,"SportId",4,4,false,10),
|
||||
new ColumnDfn(12,"Participation",3,5,false,5),
|
||||
new ColumnDfn(12,"Officiating",3,5,false,5),
|
||||
new ColumnDfn(12,"UserSportData",0,-9,false,0),
|
||||
new ColumnDfn(12,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(12,"Flags",3,5,false,5),
|
||||
new ColumnDfn(12,"Status",0,12,false,3),
|
||||
new ColumnDfn(12,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(12,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(12,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(12,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(12,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(12,"UpdateHost",0,12,false,100),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxActivityIndexList
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxItemSportList
|
||||
{
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxJournalistArticleList
|
||||
{
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxOrganisationList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxOrganisationOpportunityList
|
||||
{
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxRegionList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxSportList
|
||||
{
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxUserAccountList
|
||||
{
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxUserOrganisationList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxUserRoleList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
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.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
// User Session.
|
||||
//=======================================================================
|
||||
/// <summary>
|
||||
/// User Session - persistent properties from the user's session.
|
||||
/// </summary>
|
||||
public abstract class SaxUserSession : SacsHierarchyItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Columns.
|
||||
public enum Column
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
// User.
|
||||
UserAccountId,
|
||||
User_EmailAddress,
|
||||
User_DisplayName,
|
||||
User_Title,
|
||||
User_FirstName,
|
||||
User_LastName,
|
||||
// Session data.
|
||||
// Associated data.
|
||||
// Common.
|
||||
Flags,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Properties other than common.</summary>
|
||||
public class DataProperties
|
||||
{
|
||||
public SysId UserAccountId { get; set; }
|
||||
public List<SysId> ActivityIndexIds { get; } = new List<SysId>();
|
||||
public String UserSessionData { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
// Data members.
|
||||
private readonly DataProperties data = new DataProperties();
|
||||
// Construction.
|
||||
public Data()
|
||||
{
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; }
|
||||
}
|
||||
public List<SysId> ActivityIndexIds
|
||||
{
|
||||
get { return data.ActivityIndexIds.ToList(); }
|
||||
set { CheckChanged(data.ActivityIndexIds, value); data.ActivityIndexIds.Clear(); data.ActivityIndexIds.AddRange(value); }
|
||||
}
|
||||
public String UserSessionData
|
||||
{
|
||||
get { return data.UserSessionData; }
|
||||
set { CheckChanged(data.UserSessionData, value); data.UserSessionData = value; }
|
||||
}
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
UserAccountId = data.UserAccountId;
|
||||
ActivityIndexIds = data.ActivityIndexIds;
|
||||
UserSessionData = data.UserSessionData;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Error field - identify properties with validation error.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ActivityIndexIds { get; set; } = ValidValue.Valid;
|
||||
public ValidValue UserSessionData { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxUserSession(SysId userAccountId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
UserAccountId = userAccountId;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId => false;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public static String ActivityIndexDelim { get; } = ",";
|
||||
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(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId))
|
||||
throw new NotSupportedException(fn + " User Account Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
public SysId UserAccountId
|
||||
{
|
||||
get { return data.UserAccountId; }
|
||||
protected set { data.UserAccountId = value; }
|
||||
}
|
||||
public List<SysId> ActivityIndexIds
|
||||
{
|
||||
get { return data.ActivityIndexIds; }
|
||||
set { data.ActivityIndexIds = value; }
|
||||
}
|
||||
public String UserSessionData
|
||||
{
|
||||
get { return data.UserSessionData; }
|
||||
set { data.UserSessionData = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags - positions 1-16 available.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
// List parameters.
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
// List filtering.
|
||||
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Item list extension methods.
|
||||
public static class SaxUserSessionList
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -238,7 +238,7 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
// Company list methods.
|
||||
// Item list extension methods.
|
||||
public static class SaxUserSportList
|
||||
{
|
||||
}
|
||||
|
||||
@@ -145,26 +145,34 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
|
||||
// Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
if (!ReferenceMgr.SportExistsById(data.SportIdPrimary))
|
||||
|
||||
// Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
if (!ReferenceMgr.RegionExistsById(data.RegionIdPrimary))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
if (!ReferenceMgr.SportExistsById(data.SportIdPrimary))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
if (!ReferenceMgr.RegionExistsById(data.RegionIdPrimary))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,6 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Email Address must be unique.
|
||||
if (errField.EmailAddress != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
@@ -184,22 +183,28 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Regions.
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore || errField.RegionIdProvince != SacsHierarchyItem.ValidValue.Ignore)
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
List<SaxRegion> regions = Internals.GetRegions(new List<SysId>() { data.RegionIdCountry, data.RegionIdProvince });
|
||||
SaxRegion regionCountry = regions.GetRegionById(data.RegionIdCountry);
|
||||
SaxRegion regionProvince = regions.GetRegionById(data.RegionIdProvince);
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore)
|
||||
|
||||
// Regions.
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore || errField.RegionIdProvince != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.RegionIdCountry) && regionCountry == null)
|
||||
return SetErrorState("Invalid country specified");
|
||||
}
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.RegionIdCountry) && regionCountry == null)
|
||||
return SetErrorState("Invalid country specified");
|
||||
List<SaxRegion> regions = Internals.GetRegions(new List<SysId>() { data.RegionIdCountry, data.RegionIdProvince });
|
||||
SaxRegion regionCountry = regions.GetRegionById(data.RegionIdCountry);
|
||||
SaxRegion regionProvince = regions.GetRegionById(data.RegionIdProvince);
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.RegionIdCountry) && regionCountry == null)
|
||||
return SetErrorState("Invalid country specified");
|
||||
}
|
||||
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.RegionIdCountry) && regionCountry == null)
|
||||
return SetErrorState("Invalid country specified");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
@@ -153,6 +153,7 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,8 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Account Mgr - User Session
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxUserSession CreateUserSession(SysId userAccountId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UserSessionExists(SysId userAccountId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId)) return false;
|
||||
SaxUserSession.Params prmUserSession = new SaxUserSession.Params();
|
||||
prmUserSession.UserAccountIdsIncluded.Add(userAccountId);
|
||||
return GetUserSessionCount(prmUserSession) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxUserSession GetUserSession(SaxUserSession.Params prmUserSession);
|
||||
public SaxUserSession GetUserSession(SysId userAccountId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(userAccountId)) return null;
|
||||
SaxUserSession.Params prmUserSession = new SaxUserSession.Params();
|
||||
prmUserSession.UserAccountIdsIncluded.Add(userAccountId);
|
||||
return GetUserSession(prmUserSession);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUserSession(SaxUserSession userSession)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (userSession == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUserSessionData(userSession.GetData(), new SaxUserSession.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUserSessionData(SaxUserSession.Data data, SaxUserSession.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// User Account.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UserAccountId))
|
||||
{
|
||||
errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User Account Id must be specified");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UserSessionCanBeDeleted(SaxUserSession userSession)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUserSessionColumnDfn(SaxUserSession.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUserSessionQueryFilter(SaxUserSession.Params prmUserSession);
|
||||
public abstract long GetUserSessionCount(SaxUserSession.Params prmUserSession);
|
||||
public abstract List<SaxUserSession> GetUserSessionList(SaxUserSession.Params prmUserSession);
|
||||
public abstract DbResultSet ExecuteUserSessionQuery(List<ColumnDfn> columns, SaxUserSession.Params prmUserSession);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUserSessionDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxUserSession.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// User Display Name.
|
||||
case SaxUserSession.Column.User_DisplayName:
|
||||
{
|
||||
String userTitle = values.GetValue(GetUserSessionColumnDfn(SaxUserSession.Column.User_Title).DataName).ToString();
|
||||
String userFirstName = values.GetValue(GetUserSessionColumnDfn(SaxUserSession.Column.User_FirstName).DataName).ToString();
|
||||
String userLastName = values.GetValue(GetUserSessionColumnDfn(SaxUserSession.Column.User_LastName).DataName).ToString();
|
||||
value = new DataValue(SaxUserAccount.GetDisplayName(userTitle, userFirstName, userLastName));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -113,45 +113,6 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// User must exist.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.UserAccountId))
|
||||
{
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmUserAccount.IdsExcluded.Add(data.Id);
|
||||
prmUserAccount.IdsIncluded.Add(data.UserAccountId);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.Any;
|
||||
if (GetUserAccountCount(prmUserAccount) < 1)
|
||||
{
|
||||
errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid user specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport must exist.
|
||||
if (errField.SportId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.SportId))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
if (SysId.IsValid(data.Id))
|
||||
prmSport.IdsExcluded.Add(data.Id);
|
||||
prmSport.IdsIncluded.Add(data.SportId);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.Any;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid sport specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// User & Sport combination must be unique.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && errField.SportId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
@@ -171,6 +132,47 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// User must exist.
|
||||
if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.UserAccountId))
|
||||
{
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(data.UserAccountId);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.NotDeleted;
|
||||
if (GetUserAccountCount(prmUserAccount) < 1)
|
||||
{
|
||||
errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid user specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sport must exist.
|
||||
if (errField.SportId != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (SysId.IsValid(data.SportId))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportId);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid sport specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
|
||||
// NB Associated data items aren't validated as these should be valid on the 'parent' object.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,48 +112,53 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
|
||||
// Associated data.
|
||||
|
||||
// User Account - Journalist.
|
||||
if (errField.UserAccountIdJournalist != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.UserAccountIdJournalist))
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(data.UserAccountIdJournalist);
|
||||
prmUserAccount.ActiveRoles.Add(App.Sax.UserRole.Journalist);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.ActiveOnly;
|
||||
if (AccountMgr.GetUserAccountCount(prmUserAccount) < 1)
|
||||
|
||||
// User Account - Journalist.
|
||||
if (errField.UserAccountIdJournalist != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.UserAccountIdJournalist))
|
||||
{
|
||||
errField.UserAccountIdJournalist = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User must be active Journalist");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportIdPrimary);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.ActiveOnly;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.Add(data.RegionIdPrimary);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.ActiveOnly;
|
||||
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.Add(data.UserAccountIdJournalist);
|
||||
prmUserAccount.ActiveRoles.Add(App.Sax.UserRole.Journalist);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.NotDeleted;
|
||||
if (AccountMgr.GetUserAccountCount(prmUserAccount) < 1)
|
||||
{
|
||||
errField.UserAccountIdJournalist = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("User must be active Journalist");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportIdPrimary);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.Add(data.RegionIdPrimary);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,47 +118,52 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
|
||||
// Associated data.
|
||||
|
||||
// Organisation.
|
||||
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.OrganisationId))
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.IdsIncluded.Add(data.OrganisationId);
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.ActiveOnly;
|
||||
if (AccountMgr.GetOrganisationCount(prmOrganisation) < 1)
|
||||
|
||||
// Organisation.
|
||||
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.OrganisationId))
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid organisation specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportIdPrimary);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.ActiveOnly;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.Add(data.RegionIdPrimary);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.ActiveOnly;
|
||||
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.IdsIncluded.Add(data.OrganisationId);
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.NotDeleted;
|
||||
if (AccountMgr.GetOrganisationCount(prmOrganisation) < 1)
|
||||
{
|
||||
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid organisation specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Sport.
|
||||
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
|
||||
{
|
||||
SaxSport.Params prmSport = new SaxSport.Params();
|
||||
prmSport.IdsIncluded.Add(data.SportIdPrimary);
|
||||
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetSportCount(prmSport) < 1)
|
||||
{
|
||||
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid sport specified");
|
||||
}
|
||||
}
|
||||
|
||||
// Primary Region.
|
||||
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
|
||||
{
|
||||
SaxRegion.Params prmRegion = new SaxRegion.Params();
|
||||
prmRegion.IdsIncluded.Add(data.RegionIdPrimary);
|
||||
prmRegion.StatusCat = SaxRegion.StatusCat.NotDeleted;
|
||||
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
|
||||
{
|
||||
errField.RegionIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid region specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,8 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,14 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
// ToDo Parent region.
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
public virtual bool IsValidSportData (SaxSport.Data data, SaxSport.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Name.
|
||||
if (errField.Name != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Name, "name", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.Sport_Name), true))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Saxonite.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxUserSession_Dbas : SaxUserSession
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private ISacsDatabase database;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaxUserSession_Dbas(ISacsDatabase database, SysId userAccountId, UInt16 flags) :
|
||||
base(userAccountId)
|
||||
{
|
||||
this.database = database;
|
||||
Flags = flags;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id", true);
|
||||
public ColumnDataInt64 _Id { get; } = new ColumnDataInt64("Id", true);
|
||||
public ColumnDataInt32 _UserAccountId { get; } = new ColumnDataInt32("UserAccountId");
|
||||
public ColumnDataString _UserRoleCode { get; } = new ColumnDataString("UserRoleCode");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
@@ -81,7 +81,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
public static List<String> FieldsNonId { get { return fields.FindAll(item => !fieldsId.ContainsCI(item)); } }
|
||||
// Columns.
|
||||
public ColumnsData Cols { get; } = new ColumnsData();
|
||||
public Int32 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
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 String _UserRoleCode { get { return Cols._UserRoleCode.Value; } set { Cols._UserRoleCode.Value = value; } }
|
||||
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
|
||||
@@ -114,7 +114,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_Id = GetFieldInt64(dbDataReader, "Id", _Id);
|
||||
_UserAccountId = GetFieldInt32(dbDataReader, "UserAccountId", _UserAccountId);
|
||||
_UserRoleCode = GetFieldString(dbDataReader, "UserRoleCode", _UserRoleCode);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
@@ -164,7 +164,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
dbCommand.CommandText = "SELECT Max(Id) FROM " + TableNameFmt + ";";
|
||||
_Id = (Int32)Convert.ToInt64(dbCommand.ExecuteScalar());
|
||||
_Id = Convert.ToInt64(dbCommand.ExecuteScalar());
|
||||
commandSuccess = (_Id > 0);
|
||||
}
|
||||
return commandSuccess;
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class UserSession_Db : SaxDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _UserAccountId { get; } = new ColumnDataInt32("UserAccountId");
|
||||
public ColumnDataString _ActivityIndexIds { get; } = new ColumnDataString("ActivityIndexIds");
|
||||
public ColumnDataString _UserSessionData { get; } = new ColumnDataString("UserSessionData");
|
||||
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
|
||||
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
|
||||
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"UserAccountId",
|
||||
"ActivityIndexIds",
|
||||
"UserSessionData",
|
||||
"Flags",
|
||||
"CreateOn",
|
||||
"UpdateOn",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"UserAccountId",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal UserSession_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "UserSession";
|
||||
public String TableNameFmt { get { return (!String.IsNullOrEmpty(SchemaName) ? "[" + SchemaName + "]." : "") + "[" + TableName + "]"; } }
|
||||
public static List<String> Fields { get { return new List<String>(fields); } }
|
||||
public static List<String> FieldsId { get { return new List<String>(fieldsId); } }
|
||||
public static List<String> FieldsNonId { get { return fields.FindAll(item => !fieldsId.ContainsCI(item)); } }
|
||||
// Columns.
|
||||
public ColumnsData Cols { get; } = new ColumnsData();
|
||||
public Int32 _UserAccountId { get { return Cols._UserAccountId.Value; } set { Cols._UserAccountId.Value = value; } }
|
||||
public String _ActivityIndexIds { get { return Cols._ActivityIndexIds.Value; } set { Cols._ActivityIndexIds.Value = value; } }
|
||||
public String _UserSessionData { get { return Cols._UserSessionData.Value; } set { Cols._UserSessionData.Value = value; } }
|
||||
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_UserAccountId = GetFieldInt32(dbDataReader, "UserAccountId", _UserAccountId);
|
||||
_ActivityIndexIds = GetFieldString(dbDataReader, "ActivityIndexIds", _ActivityIndexIds);
|
||||
_UserSessionData = GetFieldString(dbDataReader, "UserSessionData", _UserSessionData);
|
||||
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
|
||||
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
|
||||
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert command.
|
||||
public override bool ExecuteInsertCommand (DbCommand dbCommand)
|
||||
{
|
||||
List<String> columnNames = ExistingColumnNamesNonId;
|
||||
// Construct query.
|
||||
String query =
|
||||
"INSERT INTO " + TableNameFmt + " " +
|
||||
"("+columnNames.Concat(",","[","]")+") ";
|
||||
if (dbCommand is SqlCommand)
|
||||
query += "VALUES (" + columnNames.Concat(",", "@", "") + ") ";
|
||||
else query += "VALUES (" + StringListUtil.CreateList("?", columnNames.Count).Concat(",") + ") ";
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteInsertCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("UserAccountId")) AddCommandParameter(dbCommand, "@UserAccountId", _UserAccountId);
|
||||
if (columnNames.ContainsCI("ActivityIndexIds")) AddCommandParameter(dbCommand, "@ActivityIndexIds", _ActivityIndexIds);
|
||||
if (columnNames.ContainsCI("UserSessionData")) AddCommandParameter(dbCommand, "@UserSessionData", _UserSessionData);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList();
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE UserAccountId=@UserAccountId;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE UserAccountId=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("ActivityIndexIds")) AddCommandParameter(dbCommand, "@ActivityIndexIds", _ActivityIndexIds);
|
||||
if (columnNames.ContainsCI("UserSessionData")) AddCommandParameter(dbCommand, "@UserSessionData", _UserSessionData);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
AddCommandParameter(dbCommand, "@UserAccountId", _UserAccountId);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 17:55:46
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserOrganisation.Column.User_Title:
|
||||
SetUserOrganisationColDfn(columnDfn, "TItle", 80, SaxDbDfn_Core.ColumnIdx.UserAccount_Title, ColumnAlignment.Left, DataValue.DataType.String, aliasUserOrganisation_UserAccount, prefixUserOrganisation_UserAccount);
|
||||
SetUserOrganisationColDfn(columnDfn, "Title", 80, SaxDbDfn_Core.ColumnIdx.UserAccount_Title, ColumnAlignment.Left, DataValue.DataType.String, aliasUserOrganisation_UserAccount, prefixUserOrganisation_UserAccount);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserOrganisation.Column.User_FirstName:
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
|
||||
// Copy data properties to and from database.
|
||||
private void PopulateTo(UserRole_Db dbUserRole, SaxUserRole userRole, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
dbUserRole._Id = SysId.ToInt(userRole.Id);
|
||||
dbUserRole._Id = SysId.ToLong(userRole.Id);
|
||||
dbUserRole._UserAccountId = SysId.ToInt(userRole.UserAccountId);
|
||||
dbUserRole._UserRoleCode = UserRoleCodes.GetCodeForType(userRole.UserRole);
|
||||
// Common.
|
||||
@@ -285,7 +285,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserRole.Column.User_Title:
|
||||
SetUserRoleColDfn(columnDfn, "TItle", 80, SaxDbDfn_Core.ColumnIdx.UserAccount_Title, ColumnAlignment.Left, DataValue.DataType.String, aliasUserRole_UserAccount, prefixUserRole_UserAccount);
|
||||
SetUserRoleColDfn(columnDfn, "Title", 80, SaxDbDfn_Core.ColumnIdx.UserAccount_Title, ColumnAlignment.Left, DataValue.DataType.String, aliasUserRole_UserAccount, prefixUserRole_UserAccount);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserRole.Column.User_FirstName:
|
||||
|
||||
@@ -0,0 +1,459 @@
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Dbas.Bus;
|
||||
using Saxonite.Net.Standard.Dbas.Internal;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Saxonite.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxAccountMgr_Dbas
|
||||
{
|
||||
//*******************************************************************
|
||||
// Account Mgr - User Session
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
private List<StringPair> GetLogProperties(SaxUserSession userSession)
|
||||
{
|
||||
return new List<StringPair>()
|
||||
{
|
||||
new StringPair("UserAccountId",SysId.ToString(userSession.UserAccountId)),
|
||||
};
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public override SaxUserSession CreateUserSession(SysId userAccountId)
|
||||
{
|
||||
ClearErrorState();
|
||||
return new SaxUserSession_Dbas(CoreDatabase, userAccountId, 0);
|
||||
}
|
||||
private SaxUserSession_Dbas CreateUserSession(UserSession_Db dbUserSession)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaxUserSession_Dbas userSession = new SaxUserSession_Dbas(CoreDatabase, new SysId(dbUserSession._UserAccountId), (ushort)dbUserSession._Flags);
|
||||
PopulateFrom(dbUserSession, userSession);
|
||||
return userSession;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get item.
|
||||
public override SaxUserSession GetUserSession(SaxUserSession.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
return GetUserSession(GetUserSessionQueryFilter(prm).Concat(" And ", "(", ")"));
|
||||
}
|
||||
private SaxUserSession GetUserSession(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
long count = GetUserSessionCount(filter);
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple items found");
|
||||
return null;
|
||||
}
|
||||
SaxUserSession userSession = null;
|
||||
// Query data.
|
||||
using (var dbConnection = CoreDatabase.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbConnection.Open();
|
||||
UserSession_Db dbUserSession = new UserSession_Db(CoreDbInfo);
|
||||
dbUserSession.PopulateFrom(dbCommand, aliasUserSession, filter);
|
||||
userSession = CreateUserSession(dbUserSession);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SaLogger.Warn(GetType().Name + ".GetUserSession\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
}
|
||||
return userSession;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item.
|
||||
public override bool IsValidUserSessionData(SaxUserSession.Data data, SaxUserSession.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!base.IsValidUserSessionData(data, errField)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert item.
|
||||
public override bool InsertUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
String fn = GetType().Name + ".InsertUserSession";
|
||||
ClearErrorState();
|
||||
if (!IsValidUserSession(userSession)) return false;
|
||||
if (SysId.IsValid(userSession.Id)) return SetErrorState(ErrorMessage.ValiditemId);
|
||||
using (var dbConnection = CoreDatabase.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbConnection.Open();
|
||||
UserSession_Db dbUserSession = new UserSession_Db(CoreDbInfo);
|
||||
PopulateTo(dbUserSession, userSession, dbUpdateInfo);
|
||||
if (UserSession_Db.FieldsNonId.Contains("Id"))
|
||||
{
|
||||
// Generate next Id.
|
||||
//dbUserSession._Id = CoreDatabase.GetNextIdFromTable("UserSession");
|
||||
}
|
||||
dbUserSession.ExecuteInsertCommand(dbCommand);
|
||||
//userSession.Id = new SysId(dbUserSession._Id);
|
||||
userSession.Changed = false;
|
||||
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(userSession).Concat(": ").Concat("", "\n\t"));
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update item.
|
||||
public override bool UpdateUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
String fn = GetType().Name + ".UpdateUserSession";
|
||||
ClearErrorState();
|
||||
if (!IsValidUserSession(userSession)) return false;
|
||||
if (!SysId.IsValid(userSession.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
|
||||
if (!userSession.Changed)
|
||||
{
|
||||
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(userSession).Concat(": ").Concat("", "\n\t"));
|
||||
return true;
|
||||
}
|
||||
using (var dbConnection = CoreDatabase.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Retrieve item.
|
||||
dbConnection.Open();
|
||||
UserSession_Db dbUserSession = new UserSession_Db(CoreDbInfo);
|
||||
dbUserSession.PopulateFrom(dbCommand, aliasUserSession, "UserAccountId=" + SysId.ToString(userSession.UserAccountId));
|
||||
// Update properties.
|
||||
PopulateTo(dbUserSession, userSession, dbUpdateInfo);
|
||||
dbUserSession.ExecuteUpdateCommand(dbCommand);
|
||||
userSession.Changed = false;
|
||||
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(userSession).Concat(": ").Concat("", "\n\t"));
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Delete item.
|
||||
public override bool UserSessionCanBeDeleted(SaxUserSession userSession)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!base.UserSessionCanBeDeleted(userSession)) return false;
|
||||
return true;
|
||||
}
|
||||
public override bool DeleteUserSession(SaxUserSession userSession, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
String fn = GetType().Name + ".DeleteUserSession";
|
||||
ClearErrorState();
|
||||
if (!UserSessionCanBeDeleted(userSession)) return false;
|
||||
using (var dbConnection = CoreDatabase.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Retrieve userSession.
|
||||
dbConnection.Open();
|
||||
UserSession_Db dbUserSession = new UserSession_Db(CoreDbInfo);
|
||||
dbUserSession.PopulateFrom(dbCommand, aliasUserSession, "UserAccountId=" + SysId.ToString(userSession.UserAccountId));
|
||||
// Delete userSession.
|
||||
dbCommand.CommandType = System.Data.CommandType.Text;
|
||||
dbCommand.CommandText = "DELETE FROM " + SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserSession) + " WHERE UserAccountId=" + SysId.ToString(userSession.UserAccountId) + ";";
|
||||
dbCommand.ExecuteNonQuery();
|
||||
userSession.Changed = false;
|
||||
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(userSession).Concat(": ").Concat("", "\n\t"));
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copy data properties to and from database.
|
||||
private void PopulateTo(UserSession_Db dbUserSession, SaxUserSession userSession, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
dbUserSession._UserAccountId = SysId.ToInt(userSession.UserAccountId);
|
||||
dbUserSession._ActivityIndexIds= SysIdList.Concat(userSession.ActivityIndexIds, SaxUserSession.ActivityIndexDelim);
|
||||
dbUserSession._UserSessionData = userSession.UserSessionData;
|
||||
// Common.
|
||||
dbUserSession._Flags = (short)userSession.Flags;
|
||||
if (!DateUtil.IsValid(dbUserSession._CreateOn))
|
||||
{
|
||||
dbUserSession._CreateOn = DateTime.Now;
|
||||
}
|
||||
dbUserSession._UpdateOn = DateTime.Now;
|
||||
}
|
||||
private void PopulateFrom(UserSession_Db dbUserSession, SaxUserSession userSession)
|
||||
{
|
||||
//userSession.UserAccountId = new SysId(dbUserSession._UserAccountId);
|
||||
userSession.ActivityIndexIds = StringListUtil.Split(dbUserSession._ActivityIndexIds, SaxUserSession.ActivityIndexDelim).Select(item => item.ToSysId()).ToList();
|
||||
userSession.UserSessionData = dbUserSession._UserSessionData;
|
||||
// Common.
|
||||
userSession.SetCreateStamp(dbUserSession._CreateOn, new SysId(), "");
|
||||
userSession.SetUpdateStamp(dbUserSession._UpdateOn, new SysId(), "");
|
||||
userSession.AcceptChanges();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item column definitions.
|
||||
private static readonly String aliasUserSession = "UsrSes";
|
||||
private static readonly String aliasUserSession_UserAccount = "UsrSes_Usr";
|
||||
private static readonly String prefixUserSession_UserAccount = "UsrSes_Usr_";
|
||||
private void SetUserSessionColDfn
|
||||
(ColumnDfn col, String caption, int width, SaxDbDfn_Core.ColumnIdx dbCol,
|
||||
ColumnAlignment align = ColumnAlignment.Default, DataValue.DataType dataType = DataValue.DataType.String,
|
||||
String alias = "", String prefix = "")
|
||||
{
|
||||
if (String.IsNullOrEmpty(alias) && SaxDbDfn_Core.GetTableForColumn(dbCol) == SaxDbDfn_Core.TableIdx.UserSession)
|
||||
alias = aliasUserSession;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SaxDbDfn_Core.GetColumnName(dbCol, false), SaxDbDfn_Core.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SaxDbDfn_Core.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SaxDbDfn_Core.GetColTextLen(dbCol);
|
||||
}
|
||||
public override ColumnDfn GetUserSessionColumnDfn(SaxUserSession.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
|
||||
switch (columnId)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
case SaxUserSession.Column.Pos:
|
||||
SetUserSessionColDfn(columnDfn, "Pos", 60, SaxDbDfn_Core.ColumnIdx.Unknown, ColumnAlignment.Right);
|
||||
columnDfn.SortMode = ColumnDfn.ColumnSortMode.Off;
|
||||
columnDfn.ReadOnly = true;
|
||||
columnDfn.Resizable = false;
|
||||
break;
|
||||
case SaxUserSession.Column.UserAccountId:
|
||||
SetUserSessionColDfn(columnDfn, "User Id", 80, SaxDbDfn_Core.ColumnIdx.UserSession_UserAccountId, ColumnAlignment.Right, DataValue.DataType.Long);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
|
||||
//-------------------------------------------------------
|
||||
// User.
|
||||
case SaxUserSession.Column.User_EmailAddress:
|
||||
SetUserSessionColDfn(columnDfn, "Email address", 160, SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress, ColumnAlignment.Left, DataValue.DataType.String, aliasUserSession_UserAccount, prefixUserSession_UserAccount);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserSession.Column.User_DisplayName:
|
||||
SetUserSessionColDfn(columnDfn, "User", 160, SaxDbDfn_Core.ColumnIdx.Unknown, ColumnAlignment.Left, DataValue.DataType.String);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserSession.Column.User_Title:
|
||||
SetUserSessionColDfn(columnDfn, "Title", 80, SaxDbDfn_Core.ColumnIdx.UserAccount_Title, ColumnAlignment.Left, DataValue.DataType.String, aliasUserSession_UserAccount, prefixUserSession_UserAccount);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserSession.Column.User_FirstName:
|
||||
SetUserSessionColDfn(columnDfn, "First name", 120, SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName, ColumnAlignment.Left, DataValue.DataType.String, aliasUserSession_UserAccount, prefixUserSession_UserAccount);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserSession.Column.User_LastName:
|
||||
SetUserSessionColDfn(columnDfn, "Last name", 120, SaxDbDfn_Core.ColumnIdx.UserAccount_LastName, ColumnAlignment.Left, DataValue.DataType.String, aliasUserSession_UserAccount, prefixUserSession_UserAccount);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Derived properties.
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Common properties.
|
||||
case SaxUserSession.Column.Flags:
|
||||
SetUserSessionColDfn(columnDfn, "Flags", 60, SaxDbDfn_Core.ColumnIdx.UserSession_Flags, ColumnAlignment.Center, DataValue.DataType.Long);
|
||||
break;
|
||||
case SaxUserSession.Column.CreateOn_Date:
|
||||
SetUserSessionColDfn(columnDfn, "Created", 80, SaxDbDfn_Core.ColumnIdx.UserSession_CreateOn, ColumnAlignment.Center, DataValue.DataType.Date);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserSession.Column.UpdateOn_Date:
|
||||
SetUserSessionColDfn(columnDfn, "Updated", 80, SaxDbDfn_Core.ColumnIdx.UserSession_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<string> GetUserSessionQueryFilter(SaxUserSession.Params prm)
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
|
||||
// User accounts.
|
||||
String userAccountIdsIncluded = prm.UserAccountIdsIncluded.Concat(",");
|
||||
if (!userAccountIdsIncluded.IsEmpty())
|
||||
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSession_UserAccountId, aliasUserSession) + " IN (" + userAccountIdsIncluded + ")");
|
||||
|
||||
if (filter.Count < 1) filter.Add("1=1");
|
||||
return filter;
|
||||
}
|
||||
// Item sort columns.
|
||||
public List<String> GetUserSessionSortColumns(SaxUserSession.Params prm)
|
||||
{
|
||||
// Sort sequence:
|
||||
List<String> sortColumnNames = new List<String>();
|
||||
foreach (var columnDfn in prm.SortColumns)
|
||||
{
|
||||
// Need to ensure correct alias used for UserSession columns in case of conflict.
|
||||
String sortCol = String.Empty;
|
||||
if (SaxDbDfn_Core.GetTableForColumn((SaxDbDfn_Core.ColumnIdx)columnDfn.DbColumn) == SaxDbDfn_Core.TableIdx.UserSession)
|
||||
{
|
||||
sortCol = SaxDbDfn_Core.GetColumnNameQual((SaxDbDfn_Core.ColumnIdx)columnDfn.DbColumn, aliasUserSession);
|
||||
}
|
||||
else
|
||||
{
|
||||
sortCol = columnDfn.DataName;
|
||||
if (!StringUtil.IsEmpty(columnDfn.SortDataName))
|
||||
sortCol = columnDfn.SortDataName;
|
||||
}
|
||||
if (!sortCol.IsEmpty())
|
||||
{
|
||||
DbOrderByNullMode orderByNullMode = DbOrderByNullMode.Default; // eSaOrderByDemoteNulls, eSaOrderByPromoteNulls
|
||||
sortColumnNames.Add(DbQuery.FormatForOrderBy(sortCol, columnDfn.SortAscending, orderByNullMode).Concat(", "));
|
||||
}
|
||||
}
|
||||
sortColumnNames.RemoveBlanks();
|
||||
if (sortColumnNames.IsEmpty())
|
||||
{
|
||||
// Default sort columns.
|
||||
sortColumnNames.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSession_UserAccountId, aliasUserSession) + " ASC");
|
||||
}
|
||||
return sortColumnNames;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item count.
|
||||
private long GetUserSessionCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
return CoreDatabase.GetRowCount(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserSession) + " As " + aliasUserSession, filter);
|
||||
}
|
||||
public override long GetUserSessionCount(SaxUserSession.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
return GetUserSessionCount(GetUserSessionQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public override List<SaxUserSession> GetUserSessionList(SaxUserSession.Params prm)
|
||||
{
|
||||
List<SaxUserSession> userSessions = new List<SaxUserSession>();
|
||||
DbQuery qry = new DbQuery(CoreDatabase.DbmsType);
|
||||
qry.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserSession), aliasUserSession);
|
||||
UserSession_Db dbUserSession = new UserSession_Db(CoreDbInfo);
|
||||
qry.Columns.AddRange(dbUserSession.ExistingColumnNames);
|
||||
qry.Filters.AddRange(GetUserSessionQueryFilter(prm));
|
||||
qry.OrderBy.AddRange(GetUserSessionSortColumns(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())
|
||||
{
|
||||
dbUserSession = new UserSession_Db(CoreDbInfo);
|
||||
dbUserSession.PopulateFrom(dbDataReader);
|
||||
userSessions.Add(CreateUserSession(dbUserSession));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn(GetType().Name + ".GetUserSessionList\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc));
|
||||
}
|
||||
}
|
||||
return userSessions;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item query execution.
|
||||
public override DbResultSet ExecuteUserSessionQuery(List<ColumnDfn> columns, SaxUserSession.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Construct query.
|
||||
DbQuery query = new DbQuery(CoreDatabase.DbmsType);
|
||||
query.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserSession), aliasUserSession);
|
||||
|
||||
// Add columns as defined in query list.
|
||||
bool hasUserAccountCols = (columns.HasId(SaxUserSession.Column.User_EmailAddress) || columns.HasId(SaxUserSession.Column.User_DisplayName) || columns.HasId(SaxUserSession.Column.User_Title) || columns.HasId(SaxUserSession.Column.User_FirstName) || columns.HasId(SaxUserSession.Column.User_LastName));
|
||||
if (columns.HasId(SaxUserSession.Column.UserAccountId) || hasUserAccountCols)
|
||||
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSession_UserAccountId, aliasUserSession));
|
||||
// Common properties.
|
||||
if (columns.HasId(SaxUserSession.Column.Flags))
|
||||
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSession_Flags, aliasUserSession));
|
||||
if (columns.HasId(SaxUserSession.Column.CreateOn_Date))
|
||||
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSession_CreateOn, aliasUserSession));
|
||||
if (columns.HasId(SaxUserSession.Column.UpdateOn_Date))
|
||||
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSession_UpdateOn, aliasUserSession));
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// User Account.
|
||||
if (hasUserAccountCols)
|
||||
{
|
||||
DbQueryJoin joinUserAccount = new DbQueryJoin(DbJoinType.LeftOuter);
|
||||
joinUserAccount.Table = new StringPair(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserAccount), aliasUserSession_UserAccount);
|
||||
joinUserAccount.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserSession_UserAccount) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSession_UserAccountId, aliasUserSession));
|
||||
query.Joins.Add(joinUserAccount);
|
||||
List<SaxDbDfn_Core.ColumnIdx> cols = new List<SaxDbDfn_Core.ColumnIdx>();
|
||||
cols.Add(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress);
|
||||
cols.Add(SaxDbDfn_Core.ColumnIdx.UserAccount_Title);
|
||||
cols.Add(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName);
|
||||
cols.Add(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName);
|
||||
foreach (var col in cols)
|
||||
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(col, aliasUserSession_UserAccount), prefixUserSession_UserAccount + SaxDbDfn_Core.GetColumnName(col, false));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Populate filter.
|
||||
query.Filters.AddRange(GetUserSessionQueryFilter(prm));
|
||||
|
||||
if (prm.UserAccountIdsIncluded.Count != 1)
|
||||
{
|
||||
// Configure sort sequence.
|
||||
foreach (String sortColumn in GetUserSessionSortColumns(prm))
|
||||
query.OrderBy.Add(sortColumn);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//return new DbResultSet_DataTableReader(db, query.BuildQuery(prm.ResultsPaging));
|
||||
return DbResultSet_DataReader.ExecuteQuery(CoreDatabase, query.BuildQuery(prm.ResultsPaging));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -229,7 +229,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
|
||||
//userSport.UserAccountId = new SysId(dbUserSport._UserAccountId);
|
||||
//userSport.SportId = new SysId(dbUserSport._SportId);
|
||||
userSport.Participation = (Sax.SportParticipation)dbUserSport._Participation;
|
||||
userSport.Officiating = (Sax.SportOfficiating)dbUserSport._Participation;
|
||||
userSport.Officiating = (Sax.SportOfficiating)dbUserSport._Officiating;
|
||||
userSport.UserSportData = dbUserSport._UserSportData;
|
||||
// Common.
|
||||
userSport.Notes = dbUserSport._Notes;
|
||||
@@ -289,7 +289,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserSport.Column.User_Title:
|
||||
SetUserSportColDfn(columnDfn, "TItle", 80, SaxDbDfn_Core.ColumnIdx.UserAccount_Title, ColumnAlignment.Left, DataValue.DataType.String, aliasUserSport_UserAccount, prefixUserSport_UserAccount);
|
||||
SetUserSportColDfn(columnDfn, "Title", 80, SaxDbDfn_Core.ColumnIdx.UserAccount_Title, ColumnAlignment.Left, DataValue.DataType.String, aliasUserSport_UserAccount, prefixUserSport_UserAccount);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SaxUserSport.Column.User_FirstName:
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
|
||||
dbActivityIndex.PopulateFrom(dbCommand, aliasActivityIndex, filter);
|
||||
// Delete item.
|
||||
dbCommand.CommandType = System.Data.CommandType.Text;
|
||||
dbCommand.CommandText = "DELETE FROM " + SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.ActivityIndex) + " '" + aliasActivityIndex + "' WHERE " + filter + ";";
|
||||
dbCommand.CommandText = "DELETE " + aliasActivityIndex + " FROM " + SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.ActivityIndex) + " As " + aliasActivityIndex + " WHERE " + filter + ";";
|
||||
dbCommand.ExecuteNonQuery();
|
||||
activityIndex.Changed = false;
|
||||
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(activityIndex).Concat(": ").Concat("", "\n\t"));
|
||||
|
||||
@@ -3369,13 +3369,13 @@
|
||||
<Table>UserRole</Table>
|
||||
<Pos>1</Pos>
|
||||
<Name>Id</Name>
|
||||
<DataType>Int</DataType>
|
||||
<DataType>BigInt</DataType>
|
||||
<DataTypeName />
|
||||
<DataTypeNative>4</DataTypeNative>
|
||||
<DataTypeNameNative>int</DataTypeNameNative>
|
||||
<DataTypeNative>-5</DataTypeNative>
|
||||
<DataTypeNameNative>bigint</DataTypeNameNative>
|
||||
<IsIdentity>true</IsIdentity>
|
||||
<Size>10</Size>
|
||||
<BufferLen>4</BufferLen>
|
||||
<Size>19</Size>
|
||||
<BufferLen>8</BufferLen>
|
||||
<DecimalDigits>0</DecimalDigits>
|
||||
<Nullable>NoNulls</Nullable>
|
||||
<IsNullable>false</IsNullable>
|
||||
@@ -3637,6 +3637,137 @@
|
||||
</DbDfnIndex>
|
||||
</Indices>
|
||||
</DbDfnTable>
|
||||
<DbDfnTable>
|
||||
<Schema>dbo</Schema>
|
||||
<Name>UserSession</Name>
|
||||
<Remarks />
|
||||
<Columns>
|
||||
<DbDfnColumn>
|
||||
<Schema>dbo</Schema>
|
||||
<Table>UserSession</Table>
|
||||
<Pos>1</Pos>
|
||||
<Name>UserAccountId</Name>
|
||||
<DataType>Int</DataType>
|
||||
<DataTypeName />
|
||||
<DataTypeNative>4</DataTypeNative>
|
||||
<DataTypeNameNative>int</DataTypeNameNative>
|
||||
<IsIdentity>false</IsIdentity>
|
||||
<Size>10</Size>
|
||||
<BufferLen>4</BufferLen>
|
||||
<DecimalDigits>0</DecimalDigits>
|
||||
<Nullable>NoNulls</Nullable>
|
||||
<IsNullable>false</IsNullable>
|
||||
<Remarks />
|
||||
</DbDfnColumn>
|
||||
<DbDfnColumn>
|
||||
<Schema>dbo</Schema>
|
||||
<Table>UserSession</Table>
|
||||
<Pos>2</Pos>
|
||||
<Name>ActivityIndexIds</Name>
|
||||
<DataType>VarChar</DataType>
|
||||
<DataTypeName />
|
||||
<DataTypeNative>-9</DataTypeNative>
|
||||
<DataTypeNameNative>nvarchar</DataTypeNameNative>
|
||||
<IsIdentity>false</IsIdentity>
|
||||
<Size>0</Size>
|
||||
<BufferLen>0</BufferLen>
|
||||
<DecimalDigits>0</DecimalDigits>
|
||||
<Nullable>Nullable</Nullable>
|
||||
<IsNullable>true</IsNullable>
|
||||
<Remarks />
|
||||
</DbDfnColumn>
|
||||
<DbDfnColumn>
|
||||
<Schema>dbo</Schema>
|
||||
<Table>UserSession</Table>
|
||||
<Pos>3</Pos>
|
||||
<Name>UserSessionData</Name>
|
||||
<DataType>VarChar</DataType>
|
||||
<DataTypeName />
|
||||
<DataTypeNative>-9</DataTypeNative>
|
||||
<DataTypeNameNative>nvarchar</DataTypeNameNative>
|
||||
<IsIdentity>false</IsIdentity>
|
||||
<Size>0</Size>
|
||||
<BufferLen>0</BufferLen>
|
||||
<DecimalDigits>0</DecimalDigits>
|
||||
<Nullable>Nullable</Nullable>
|
||||
<IsNullable>true</IsNullable>
|
||||
<Remarks />
|
||||
</DbDfnColumn>
|
||||
<DbDfnColumn>
|
||||
<Schema>dbo</Schema>
|
||||
<Table>UserSession</Table>
|
||||
<Pos>4</Pos>
|
||||
<Name>Flags</Name>
|
||||
<DataType>SmallInt</DataType>
|
||||
<DataTypeName />
|
||||
<DataTypeNative>5</DataTypeNative>
|
||||
<DataTypeNameNative>smallint</DataTypeNameNative>
|
||||
<IsIdentity>false</IsIdentity>
|
||||
<Size>5</Size>
|
||||
<BufferLen>2</BufferLen>
|
||||
<DecimalDigits>0</DecimalDigits>
|
||||
<Nullable>NoNulls</Nullable>
|
||||
<IsNullable>false</IsNullable>
|
||||
<Remarks />
|
||||
</DbDfnColumn>
|
||||
<DbDfnColumn>
|
||||
<Schema>dbo</Schema>
|
||||
<Table>UserSession</Table>
|
||||
<Pos>5</Pos>
|
||||
<Name>CreateOn</Name>
|
||||
<DataType>DateTime</DataType>
|
||||
<DataTypeName />
|
||||
<DataTypeNative>93</DataTypeNative>
|
||||
<DataTypeNameNative>datetime</DataTypeNameNative>
|
||||
<IsIdentity>false</IsIdentity>
|
||||
<Size>23</Size>
|
||||
<BufferLen>16</BufferLen>
|
||||
<DecimalDigits>3</DecimalDigits>
|
||||
<Nullable>NoNulls</Nullable>
|
||||
<IsNullable>false</IsNullable>
|
||||
<Remarks />
|
||||
</DbDfnColumn>
|
||||
<DbDfnColumn>
|
||||
<Schema>dbo</Schema>
|
||||
<Table>UserSession</Table>
|
||||
<Pos>6</Pos>
|
||||
<Name>UpdateOn</Name>
|
||||
<DataType>DateTime</DataType>
|
||||
<DataTypeName />
|
||||
<DataTypeNative>93</DataTypeNative>
|
||||
<DataTypeNameNative>datetime</DataTypeNameNative>
|
||||
<IsIdentity>false</IsIdentity>
|
||||
<Size>23</Size>
|
||||
<BufferLen>16</BufferLen>
|
||||
<DecimalDigits>3</DecimalDigits>
|
||||
<Nullable>NoNulls</Nullable>
|
||||
<IsNullable>false</IsNullable>
|
||||
<Remarks />
|
||||
</DbDfnColumn>
|
||||
</Columns>
|
||||
<Indices>
|
||||
<DbDfnIndex>
|
||||
<Schema>dbo</Schema>
|
||||
<Table>UserSession</Table>
|
||||
<Name>PK_UserSession</Name>
|
||||
<IndexType>1</IndexType>
|
||||
<Unique>true</Unique>
|
||||
<Primary>false</Primary>
|
||||
<Clustered>false</Clustered>
|
||||
<Nullable>false</Nullable>
|
||||
<Pages>0</Pages>
|
||||
<UniqueValues>0</UniqueValues>
|
||||
<HasColumns>false</HasColumns>
|
||||
<Columns>
|
||||
<DbDfnIndexColumn>
|
||||
<Seq>1</Seq>
|
||||
<Name>UserAccountId</Name>
|
||||
<Ascend>true</Ascend>
|
||||
</DbDfnIndexColumn>
|
||||
</Columns>
|
||||
</DbDfnIndex>
|
||||
</Indices>
|
||||
</DbDfnTable>
|
||||
<DbDfnTable>
|
||||
<Schema>dbo</Schema>
|
||||
<Name>UserSport</Name>
|
||||
@@ -3909,7 +4040,7 @@
|
||||
<Clustered>false</Clustered>
|
||||
<Nullable>false</Nullable>
|
||||
<Pages>1</Pages>
|
||||
<UniqueValues>3</UniqueValues>
|
||||
<UniqueValues>4</UniqueValues>
|
||||
<HasColumns>false</HasColumns>
|
||||
<Columns>
|
||||
<DbDfnIndexColumn>
|
||||
|
||||
Reference in New Issue
Block a user