Portal password request - in progress.
This commit is contained in:
@@ -41,14 +41,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Online
|
||||
public class Portal
|
||||
{
|
||||
public static class Session
|
||||
{
|
||||
public static class Cookie
|
||||
{
|
||||
/// <summary>Default cookie name: '.AspNetCore.Session'</summary>
|
||||
public static String Name { get; } = "BusinessMgr.Online.Session";
|
||||
public static String Name { get; } = "BusinessMgr.Portal.Session";
|
||||
public static bool HttpOnly { get; } = true;
|
||||
public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(60);
|
||||
public static long RememberMeTimeoutMilis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds;
|
||||
@@ -63,14 +63,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Admin
|
||||
public class Control
|
||||
{
|
||||
public static class Session
|
||||
{
|
||||
public static class Cookie
|
||||
{
|
||||
/// <summary>Default cookie name: '.AspNetCore.Session'</summary>
|
||||
public static String Name { get; } = "BusinessMgr.Admin.Session";
|
||||
public static String Name { get; } = "BusinessMgr.Control.Session";
|
||||
public static bool HttpOnly { get; } = true;
|
||||
public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(15);
|
||||
public static long KeepLoggedInTimeoutMillis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using System;
|
||||
|
||||
@@ -228,8 +229,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
if (interfaceConsole == null || !interfaceConsole.DatabaseIsValid) return false;
|
||||
// System Account & User tables must be available.
|
||||
if (!SbmGlobals.Application.BusMgrTableExists(userContext.SessionContext, SbmDbDfn.TableIdx.SystemAccount)) return false;
|
||||
if (!SbmGlobals.Application.BusMgrTableExists(userContext.SessionContext, SbmDbDfn.TableIdx.SystemUser)) return false;
|
||||
ISacsDatabase busMgrDb = SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext);
|
||||
if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemAccount)) return false;
|
||||
if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemUser)) return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -290,7 +292,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Actions.
|
||||
case Sbm.MenuOption.Timesheet:
|
||||
return configConsole.AllowOption(userContext, Sbm.ConfigOption.TimeRecording);
|
||||
//-----------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
}
|
||||
SaLogger.Warn(fn + " Unsupport menu option - " + menuOption.ToString());
|
||||
return false;
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Construction.
|
||||
protected SbmApplication(PropertySet properties)
|
||||
{
|
||||
SbmGlobals.Application = this;
|
||||
this.properties = properties;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
@@ -45,17 +46,29 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public abstract SbmSystem System { get; }
|
||||
// Database.
|
||||
public abstract ISacsDatabase GetBusMgrDatabase(SbmSessionContext sessionContext);
|
||||
public abstract IDatabaseInfo CreateBusMgrDbInfo(SbmSessionContext sessionContext);
|
||||
public bool BusMgrTableExists(SbmSessionContext sessionContext, SbmDbDfn.TableIdx tableIdx)
|
||||
// Control Database.
|
||||
public abstract ISacsDatabase GetControlDatabase(SbmSessionContext sessionContext);
|
||||
public IDatabaseInfo CreateControlDbInfo(SbmSessionContext sessionContext)
|
||||
{
|
||||
return GetControlDatabase(sessionContext).CreateDbInfo();
|
||||
}
|
||||
// Business Mgr Database.
|
||||
public abstract ISacsDatabase GetBusMgrDatabase(SbmSessionContext sessionContext);
|
||||
public IDatabaseInfo CreateBusMgrDbInfo(SbmSessionContext sessionContext)
|
||||
{
|
||||
return GetBusMgrDatabase(sessionContext).CreateDbInfo();
|
||||
}
|
||||
// Database utilities.
|
||||
public IDatabaseInfo CreateDbInfo(ISacsDatabase db)
|
||||
{
|
||||
return db?.CreateDbInfo() ?? null;
|
||||
}
|
||||
public bool DbTableExists(ISacsDatabase db, SbmDbDfn.TableIdx tableIdx)
|
||||
{
|
||||
ISacsDatabase db = GetBusMgrDatabase(sessionContext);
|
||||
return db?.TableExists(SbmDbDfn.GetTableName(tableIdx)) ?? false;
|
||||
}
|
||||
public bool BusMgrColumnExists(SbmSessionContext sessionContext, SbmDbDfn.ColumnIdx columnIdx)
|
||||
public bool DbColumnExists(ISacsDatabase db, SbmDbDfn.ColumnIdx columnIdx)
|
||||
{
|
||||
ISacsDatabase db = GetBusMgrDatabase(sessionContext);
|
||||
return db?.ColumnExists(SbmDbDfn.GetTableName(SbmDbDfn.GetTableForColumn(columnIdx)), SbmDbDfn.GetColumnName(columnIdx, false)) ?? false;
|
||||
}
|
||||
// Application instance.
|
||||
|
||||
@@ -428,10 +428,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11:
|
||||
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12:
|
||||
return userContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual);
|
||||
default: // Sep-08: Session profile should be able to handle all fields now (rather than just those that are controled)
|
||||
default: // Sep-08: Session profile should be able to handle all fields now (rather than just those that are controlled)
|
||||
return userContext.GetOwnerOption_ShowField(column);
|
||||
}
|
||||
return true;
|
||||
//return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
@@ -5,7 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Mon 8-Jun-2020 16:53:26
|
||||
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
@@ -1144,17 +1145,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 44;
|
||||
private static readonly int tableCount = 44;
|
||||
private static readonly int columnCount = 1073;
|
||||
private static ulong maxTextLen = 0;
|
||||
private static ulong maxTextLen = 0;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve Table details (eg. name: 'Company').
|
||||
public static int GetTableCount()
|
||||
public static int GetTableCount ()
|
||||
{
|
||||
return tableCount;
|
||||
}
|
||||
public static String GetTableName(TableIdx table, bool delimitReservedWords = true)
|
||||
public static String GetTableName (TableIdx table, bool delimitReservedWords = true)
|
||||
{
|
||||
int tableIdx = (int)table - 1;
|
||||
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
|
||||
@@ -1165,7 +1166,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Identify the table that corresponds with the specified column.
|
||||
public static TableIdx GetTableForColumn(ColumnIdx column)
|
||||
public static TableIdx GetTableForColumn (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return TableIdx.Unknown;
|
||||
@@ -1174,7 +1175,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve the specified Column's name (Qualified include table name: '(<Table>.Column>)').
|
||||
public static String GetColumnName(ColumnIdx column, bool delimitReservedWords = true)
|
||||
public static String GetColumnName (ColumnIdx column, bool delimitReservedWords = true)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return String.Empty;
|
||||
@@ -1182,7 +1183,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
if (delimitReservedWords) columnName = DelimitReservedWord(columnName);
|
||||
return columnName;
|
||||
}
|
||||
public static String GetColumnNameQual(ColumnIdx column, String tableAlias = "", bool braces = false)
|
||||
public static String GetColumnNameQual (ColumnIdx column, String tableAlias = "", bool braces = false)
|
||||
{
|
||||
String columnName = GetColumnName(column);
|
||||
if (!String.IsNullOrEmpty(columnName))
|
||||
@@ -1199,17 +1200,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Reserved words.
|
||||
private static DbReservedWordDelim reservedWordDelim = DbReservedWordDelim.SquareBrackets;
|
||||
public static void SetReservedWordDelim(DbReservedWordDelim reservedWordDelim)
|
||||
public static void SetReservedWordDelim (DbReservedWordDelim reservedWordDelim)
|
||||
{
|
||||
SbmDbDfn.reservedWordDelim = reservedWordDelim;
|
||||
}
|
||||
public static bool IsReservedWord(String word)
|
||||
public static bool IsReservedWord (String word)
|
||||
{
|
||||
if (String.IsNullOrEmpty(word)) return false;
|
||||
if (reservedWords.Contains(word, StringComparer.OrdinalIgnoreCase)) return true;
|
||||
return false;
|
||||
}
|
||||
public static String DelimitReservedWord(String word)
|
||||
public static String DelimitReservedWord (String word)
|
||||
{
|
||||
if (!IsReservedWord(word)) return word;
|
||||
switch (reservedWordDelim)
|
||||
@@ -1217,11 +1218,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
case DbReservedWordDelim.None:
|
||||
break;
|
||||
case DbReservedWordDelim.DoubleQuotes:
|
||||
word = "\"" + word + "\"";
|
||||
word = "\"" + word + "\"";
|
||||
break;
|
||||
case DbReservedWordDelim.SquareBrackets:
|
||||
default:
|
||||
word = "[" + word + "]";
|
||||
word = "[" + word + "]";
|
||||
break;
|
||||
}
|
||||
return word;
|
||||
@@ -1229,29 +1230,29 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve information about the specified Column.
|
||||
public static DbColumnDataType GetColDataType(ColumnIdx column)
|
||||
public static DbColumnDataType GetColDataType (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return DbColumnDataType.Unknown;
|
||||
return columns[columnIdx].DataType;
|
||||
}
|
||||
public static short GetColNativeDataType(ColumnIdx column)
|
||||
public static short GetColNativeDataType (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
|
||||
return columns[columnIdx].NativeDataType;
|
||||
}
|
||||
public static void SetMaxTextLen(ulong maxTextLen)
|
||||
public static void SetMaxTextLen (ulong maxTextLen)
|
||||
{
|
||||
SbmDbDfn.maxTextLen = maxTextLen;
|
||||
}
|
||||
public static bool IsColFmtText(ColumnIdx column)
|
||||
public static bool IsColFmtText (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
return (columns[columnIdx].DataType == DbColumnDataType.VarChar);
|
||||
}
|
||||
public static ulong GetColTextLen(ColumnIdx column)
|
||||
public static ulong GetColTextLen (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
|
||||
@@ -1263,13 +1264,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static bool IsColFmtBool(ColumnIdx column)
|
||||
public static bool IsColFmtBool (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
return (columns[columnIdx].DataType == DbColumnDataType.Bit);
|
||||
}
|
||||
public static bool IsColFmtNumeric(ColumnIdx column)
|
||||
public static bool IsColFmtNumeric (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
@@ -1291,55 +1292,55 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Table definitions.
|
||||
private static readonly String[] tables =
|
||||
{
|
||||
"Address",
|
||||
"Affiliate",
|
||||
"Association",
|
||||
"Commodity",
|
||||
"CommodityCustomer",
|
||||
"CommoditySupplier",
|
||||
"Constituent",
|
||||
"Container",
|
||||
"ContainerItem",
|
||||
"Currency",
|
||||
"IndexDefragLog",
|
||||
"Interface",
|
||||
"InterfaceDataItem",
|
||||
"InterfaceProcess",
|
||||
"InterfaceProcessDataItem",
|
||||
"InterfaceProcessMessage",
|
||||
"ItemBatch",
|
||||
"ItemLink",
|
||||
"Language",
|
||||
"Location",
|
||||
"Movement",
|
||||
"PortfolioItem",
|
||||
"Process",
|
||||
"Region",
|
||||
"Requirement",
|
||||
"SaAsset",
|
||||
"SaAssetCategory",
|
||||
"SaAssetProcess",
|
||||
"SaDiaryEntry",
|
||||
"SaDiaryLink",
|
||||
"SaPrice",
|
||||
"SaPriceSet",
|
||||
"SaVehicle",
|
||||
"SaVehicleClass",
|
||||
"SaVehicleEvent",
|
||||
"SaVehicleFeature",
|
||||
"StockLevel",
|
||||
"SysParam",
|
||||
"SystemAccount",
|
||||
"SystemAccountUser",
|
||||
"SystemUser",
|
||||
"TaxCode",
|
||||
"Transaction",
|
||||
"UnitMeasure",
|
||||
"Address",
|
||||
"Affiliate",
|
||||
"Association",
|
||||
"Commodity",
|
||||
"CommodityCustomer",
|
||||
"CommoditySupplier",
|
||||
"Constituent",
|
||||
"Container",
|
||||
"ContainerItem",
|
||||
"Currency",
|
||||
"IndexDefragLog",
|
||||
"Interface",
|
||||
"InterfaceDataItem",
|
||||
"InterfaceProcess",
|
||||
"InterfaceProcessDataItem",
|
||||
"InterfaceProcessMessage",
|
||||
"ItemBatch",
|
||||
"ItemLink",
|
||||
"Language",
|
||||
"Location",
|
||||
"Movement",
|
||||
"PortfolioItem",
|
||||
"Process",
|
||||
"Region",
|
||||
"Requirement",
|
||||
"SaAsset",
|
||||
"SaAssetCategory",
|
||||
"SaAssetProcess",
|
||||
"SaDiaryEntry",
|
||||
"SaDiaryLink",
|
||||
"SaPrice",
|
||||
"SaPriceSet",
|
||||
"SaVehicle",
|
||||
"SaVehicleClass",
|
||||
"SaVehicleEvent",
|
||||
"SaVehicleFeature",
|
||||
"StockLevel",
|
||||
"SysParam",
|
||||
"SystemAccount",
|
||||
"SystemAccountUser",
|
||||
"SystemUser",
|
||||
"TaxCode",
|
||||
"Transaction",
|
||||
"UnitMeasure",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Table column definitions.
|
||||
internal class ColumnDfn
|
||||
private class ColumnDfn
|
||||
{
|
||||
internal TableIdx TableIdx { get; set; }
|
||||
internal String Name { get; set; }
|
||||
@@ -1347,7 +1348,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
internal short NativeDataType { get; set; }
|
||||
internal bool IsIdentity { get; set; }
|
||||
internal ulong DataLen { get; set; }
|
||||
internal ColumnDfn(int tableIdx, String name, int dataType, short nativeDataType, bool isIdentity, ulong dataLen)
|
||||
internal ColumnDfn (int tableIdx, String name, int dataType, short nativeDataType, bool isIdentity, ulong dataLen)
|
||||
{
|
||||
this.TableIdx = (TableIdx)tableIdx;
|
||||
this.Name = name;
|
||||
@@ -2440,80 +2441,80 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Reserved words.
|
||||
private static readonly List<String> reservedWords = new List<String>()
|
||||
{
|
||||
"ADD",
|
||||
"ALL",
|
||||
"ALTER",
|
||||
"AND",
|
||||
"ANY",
|
||||
"AS",
|
||||
"ASC",
|
||||
"AVG",
|
||||
"BEGIN",
|
||||
"BETWEEN",
|
||||
"BY",
|
||||
"CASE",
|
||||
"CAST",
|
||||
"COLUMN",
|
||||
"COMMIT",
|
||||
"CONSTRAINT",
|
||||
"CONVERT",
|
||||
"COUNT",
|
||||
"CREATE",
|
||||
"CURRENCY",
|
||||
"DEFAULT",
|
||||
"DELETE",
|
||||
"DESC",
|
||||
"DISTINCT",
|
||||
"DROP",
|
||||
"ELSE",
|
||||
"END",
|
||||
"EXECUTE",
|
||||
"EXISTS",
|
||||
"FALSE",
|
||||
"FROM",
|
||||
"GRANT",
|
||||
"GROUP",
|
||||
"HAVING",
|
||||
"IN",
|
||||
"INDEX",
|
||||
"INNER",
|
||||
"INSERT",
|
||||
"INTO",
|
||||
"IS",
|
||||
"JOIN",
|
||||
"KEY",
|
||||
"LEFT",
|
||||
"LIKE",
|
||||
"MAX",
|
||||
"MIN",
|
||||
"NOT",
|
||||
"NULL",
|
||||
"ON",
|
||||
"OR",
|
||||
"ORDER",
|
||||
"OUTER",
|
||||
"OUTPUT",
|
||||
"PRIMARY",
|
||||
"PROCEDURE",
|
||||
"REVOKE",
|
||||
"ROLLBACK",
|
||||
"ROWCOUNT",
|
||||
"SELECT",
|
||||
"SET",
|
||||
"SQL",
|
||||
"SUM",
|
||||
"TABLE",
|
||||
"THEN",
|
||||
"TRANSACTION",
|
||||
"TRUE",
|
||||
"UNION",
|
||||
"UNIQUE",
|
||||
"UPDATE",
|
||||
"USER",
|
||||
"VALUES",
|
||||
"VIEW",
|
||||
"WHEN",
|
||||
"WHERE",
|
||||
"ADD",
|
||||
"ALL",
|
||||
"ALTER",
|
||||
"AND",
|
||||
"ANY",
|
||||
"AS",
|
||||
"ASC",
|
||||
"AVG",
|
||||
"BEGIN",
|
||||
"BETWEEN",
|
||||
"BY",
|
||||
"CASE",
|
||||
"CAST",
|
||||
"COLUMN",
|
||||
"COMMIT",
|
||||
"CONSTRAINT",
|
||||
"CONVERT",
|
||||
"COUNT",
|
||||
"CREATE",
|
||||
"CURRENCY",
|
||||
"DEFAULT",
|
||||
"DELETE",
|
||||
"DESC",
|
||||
"DISTINCT",
|
||||
"DROP",
|
||||
"ELSE",
|
||||
"END",
|
||||
"EXECUTE",
|
||||
"EXISTS",
|
||||
"FALSE",
|
||||
"FROM",
|
||||
"GRANT",
|
||||
"GROUP",
|
||||
"HAVING",
|
||||
"IN",
|
||||
"INDEX",
|
||||
"INNER",
|
||||
"INSERT",
|
||||
"INTO",
|
||||
"IS",
|
||||
"JOIN",
|
||||
"KEY",
|
||||
"LEFT",
|
||||
"LIKE",
|
||||
"MAX",
|
||||
"MIN",
|
||||
"NOT",
|
||||
"NULL",
|
||||
"ON",
|
||||
"OR",
|
||||
"ORDER",
|
||||
"OUTER",
|
||||
"OUTPUT",
|
||||
"PRIMARY",
|
||||
"PROCEDURE",
|
||||
"REVOKE",
|
||||
"ROLLBACK",
|
||||
"ROWCOUNT",
|
||||
"SELECT",
|
||||
"SET",
|
||||
"SQL",
|
||||
"SUM",
|
||||
"TABLE",
|
||||
"THEN",
|
||||
"TRANSACTION",
|
||||
"TRUE",
|
||||
"UNION",
|
||||
"UNIQUE",
|
||||
"UPDATE",
|
||||
"USER",
|
||||
"VALUES",
|
||||
"VIEW",
|
||||
"WHEN",
|
||||
"WHERE",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:28
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
public class SbmDbDfn_Control
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Table identifiers.
|
||||
public enum TableIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
Database,
|
||||
DatabaseAccount,
|
||||
UserAccount,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Column identifiers.
|
||||
public enum ColumnIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
Database_Id,
|
||||
Database_ServerName,
|
||||
Database_InstanceName,
|
||||
Database_DatabaseName,
|
||||
Database_UserName,
|
||||
Database_Password,
|
||||
Database_OrganisationName,
|
||||
Database_Notes,
|
||||
Database_Flags,
|
||||
Database_Status,
|
||||
Database_CreateOn,
|
||||
Database_CreateBy,
|
||||
Database_CreateHost,
|
||||
Database_UpdateOn,
|
||||
Database_UpdateBy,
|
||||
Database_UpdateHost,
|
||||
DatabaseAccount_Id,
|
||||
DatabaseAccount_DatabaseId,
|
||||
DatabaseAccount_EmailAddress,
|
||||
DatabaseAccount_Notes,
|
||||
DatabaseAccount_Flags,
|
||||
DatabaseAccount_Status,
|
||||
DatabaseAccount_CreateOn,
|
||||
DatabaseAccount_CreateBy,
|
||||
DatabaseAccount_CreateHost,
|
||||
DatabaseAccount_UpdateOn,
|
||||
DatabaseAccount_UpdateBy,
|
||||
DatabaseAccount_UpdateHost,
|
||||
UserAccount_Id,
|
||||
UserAccount_EmailAddress,
|
||||
UserAccount_Title,
|
||||
UserAccount_FirstName,
|
||||
UserAccount_Initials,
|
||||
UserAccount_LastName,
|
||||
UserAccount_PhoneMain,
|
||||
UserAccount_PhoneMobile,
|
||||
UserAccount_PhoneAlt,
|
||||
UserAccount_PasswordToken,
|
||||
UserAccount_PasswordHashed,
|
||||
UserAccount_PasswordHistory,
|
||||
UserAccount_PasswordChangedAt,
|
||||
UserAccount_LastLoginAt,
|
||||
UserAccount_LastInvalidLoginAt,
|
||||
UserAccount_InvalidLoginCount,
|
||||
UserAccount_Notes,
|
||||
UserAccount_Flags,
|
||||
UserAccount_Status,
|
||||
UserAccount_CreateOn,
|
||||
UserAccount_CreateBy,
|
||||
UserAccount_CreateHost,
|
||||
UserAccount_UpdateOn,
|
||||
UserAccount_UpdateBy,
|
||||
UserAccount_UpdateHost,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 3;
|
||||
private static readonly int columnCount = 53;
|
||||
private static ulong maxTextLen = 0;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve Table details (eg. name: 'Company').
|
||||
public static int GetTableCount ()
|
||||
{
|
||||
return tableCount;
|
||||
}
|
||||
public static String GetTableName (TableIdx table, bool delimitReservedWords = true)
|
||||
{
|
||||
int tableIdx = (int)table - 1;
|
||||
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
|
||||
String tableName = tables[(int)tableIdx];
|
||||
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
|
||||
return tableName;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Identify the table that corresponds with the specified column.
|
||||
public static TableIdx GetTableForColumn (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return TableIdx.Unknown;
|
||||
return columns[columnIdx].TableIdx;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve the specified Column's name (Qualified include table name: '(<Table>.Column>)').
|
||||
public static String GetColumnName (ColumnIdx column, bool delimitReservedWords = true)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return String.Empty;
|
||||
String columnName = columns[columnIdx].Name;
|
||||
if (delimitReservedWords) columnName = DelimitReservedWord(columnName);
|
||||
return columnName;
|
||||
}
|
||||
public static String GetColumnNameQual (ColumnIdx column, String tableAlias = "", bool braces = false)
|
||||
{
|
||||
String columnName = GetColumnName(column);
|
||||
if (!String.IsNullOrEmpty(columnName))
|
||||
{
|
||||
String tableName = StringUtil.EmptyOnNull(tableAlias);
|
||||
if (tableName.IsEmpty()) tableName = GetTableName(GetTableForColumn(column));
|
||||
columnName = tableName + (tableName.Length > 0 ? "." : "") + columnName;
|
||||
if (braces)
|
||||
columnName = "(" + columnName + ")";
|
||||
}
|
||||
return columnName;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Reserved words.
|
||||
private static DbReservedWordDelim reservedWordDelim = DbReservedWordDelim.SquareBrackets;
|
||||
public static void SetReservedWordDelim (DbReservedWordDelim reservedWordDelim)
|
||||
{
|
||||
SbmDbDfn_Control.reservedWordDelim = reservedWordDelim;
|
||||
}
|
||||
public static bool IsReservedWord (String word)
|
||||
{
|
||||
if (String.IsNullOrEmpty(word)) return false;
|
||||
if (reservedWords.Contains(word, StringComparer.OrdinalIgnoreCase)) return true;
|
||||
return false;
|
||||
}
|
||||
public static String DelimitReservedWord (String word)
|
||||
{
|
||||
if (!IsReservedWord(word)) return word;
|
||||
switch (reservedWordDelim)
|
||||
{
|
||||
case DbReservedWordDelim.None:
|
||||
break;
|
||||
case DbReservedWordDelim.DoubleQuotes:
|
||||
word = "\"" + word + "\"";
|
||||
break;
|
||||
case DbReservedWordDelim.SquareBrackets:
|
||||
default:
|
||||
word = "[" + word + "]";
|
||||
break;
|
||||
}
|
||||
return word;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve information about the specified Column.
|
||||
public static DbColumnDataType GetColDataType (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return DbColumnDataType.Unknown;
|
||||
return columns[columnIdx].DataType;
|
||||
}
|
||||
public static short GetColNativeDataType (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
|
||||
return columns[columnIdx].NativeDataType;
|
||||
}
|
||||
public static void SetMaxTextLen (ulong maxTextLen)
|
||||
{
|
||||
SbmDbDfn_Control.maxTextLen = maxTextLen;
|
||||
}
|
||||
public static bool IsColFmtText (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
return (columns[columnIdx].DataType == DbColumnDataType.VarChar);
|
||||
}
|
||||
public static ulong GetColTextLen (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
|
||||
if (columns[columnIdx].DataType == DbColumnDataType.VarChar)
|
||||
{
|
||||
ulong textLen = columns[columnIdx].DataLen;
|
||||
if (maxTextLen > 0 && textLen > maxTextLen) textLen = maxTextLen;
|
||||
return textLen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static bool IsColFmtBool (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
return (columns[columnIdx].DataType == DbColumnDataType.Bit);
|
||||
}
|
||||
public static bool IsColFmtNumeric (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
switch (columns[columnIdx].DataType)
|
||||
{
|
||||
case DbColumnDataType.TinyInt:
|
||||
case DbColumnDataType.SmallInt:
|
||||
case DbColumnDataType.Int:
|
||||
case DbColumnDataType.BigInt:
|
||||
case DbColumnDataType.Single:
|
||||
case DbColumnDataType.Double:
|
||||
case DbColumnDataType.Decimal:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Table definitions.
|
||||
private static readonly String[] tables =
|
||||
{
|
||||
"Database",
|
||||
"DatabaseAccount",
|
||||
"UserAccount",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Table column definitions.
|
||||
private class ColumnDfn
|
||||
{
|
||||
internal TableIdx TableIdx { get; set; }
|
||||
internal String Name { get; set; }
|
||||
internal DbColumnDataType DataType { get; set; }
|
||||
internal short NativeDataType { get; set; }
|
||||
internal bool IsIdentity { get; set; }
|
||||
internal ulong DataLen { get; set; }
|
||||
internal ColumnDfn (int tableIdx, String name, int dataType, short nativeDataType, bool isIdentity, ulong dataLen)
|
||||
{
|
||||
this.TableIdx = (TableIdx)tableIdx;
|
||||
this.Name = name;
|
||||
this.DataType = (DbColumnDataType)dataType;
|
||||
this.NativeDataType = nativeDataType;
|
||||
this.IsIdentity = isIdentity;
|
||||
this.DataLen = dataLen;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private static readonly ColumnDfn[] columns =
|
||||
{
|
||||
new ColumnDfn(1,"Id",4,4,true,10),
|
||||
new ColumnDfn(1,"ServerName",0,-9,false,200),
|
||||
new ColumnDfn(1,"InstanceName",0,-9,false,200),
|
||||
new ColumnDfn(1,"DatabaseName",0,-9,false,200),
|
||||
new ColumnDfn(1,"UserName",0,-9,false,100),
|
||||
new ColumnDfn(1,"Password",0,-9,false,100),
|
||||
new ColumnDfn(1,"OrganisationName",0,-9,false,200),
|
||||
new ColumnDfn(1,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(1,"Flags",3,5,false,5),
|
||||
new ColumnDfn(1,"Status",0,12,false,3),
|
||||
new ColumnDfn(1,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(1,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(1,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(1,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(1,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(1,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(2,"Id",4,4,true,10),
|
||||
new ColumnDfn(2,"DatabaseId",4,4,false,10),
|
||||
new ColumnDfn(2,"EmailAddress",0,-9,false,200),
|
||||
new ColumnDfn(2,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(2,"Flags",3,5,false,5),
|
||||
new ColumnDfn(2,"Status",0,12,false,3),
|
||||
new ColumnDfn(2,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(2,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(2,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(2,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(2,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(2,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(3,"Id",4,4,true,10),
|
||||
new ColumnDfn(3,"EmailAddress",0,-9,false,200),
|
||||
new ColumnDfn(3,"Title",0,-9,false,20),
|
||||
new ColumnDfn(3,"FirstName",0,-9,false,100),
|
||||
new ColumnDfn(3,"Initials",0,-9,false,10),
|
||||
new ColumnDfn(3,"LastName",0,-9,false,100),
|
||||
new ColumnDfn(3,"PhoneMain",0,-9,false,50),
|
||||
new ColumnDfn(3,"PhoneMobile",0,-9,false,50),
|
||||
new ColumnDfn(3,"PhoneAlt",0,-9,false,50),
|
||||
new ColumnDfn(3,"PasswordToken",0,12,false,32),
|
||||
new ColumnDfn(3,"PasswordHashed",0,-9,false,100),
|
||||
new ColumnDfn(3,"PasswordHistory",0,-9,false,0),
|
||||
new ColumnDfn(3,"PasswordChangedAt",9,93,false,16),
|
||||
new ColumnDfn(3,"LastLoginAt",9,93,false,16),
|
||||
new ColumnDfn(3,"LastInvalidLoginAt",9,93,false,16),
|
||||
new ColumnDfn(3,"InvalidLoginCount",3,5,false,5),
|
||||
new ColumnDfn(3,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(3,"Flags",3,5,false,5),
|
||||
new ColumnDfn(3,"Status",0,12,false,3),
|
||||
new ColumnDfn(3,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(3,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(3,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(3,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(3,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(3,"UpdateHost",0,12,false,100),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Reserved words.
|
||||
private static readonly List<String> reservedWords = new List<String>()
|
||||
{
|
||||
"ADD",
|
||||
"ALL",
|
||||
"ALTER",
|
||||
"AND",
|
||||
"ANY",
|
||||
"AS",
|
||||
"ASC",
|
||||
"AVG",
|
||||
"BEGIN",
|
||||
"BETWEEN",
|
||||
"BY",
|
||||
"CASE",
|
||||
"CAST",
|
||||
"COLUMN",
|
||||
"COMMIT",
|
||||
"CONSTRAINT",
|
||||
"CONVERT",
|
||||
"COUNT",
|
||||
"CREATE",
|
||||
"CURRENCY",
|
||||
"DEFAULT",
|
||||
"DELETE",
|
||||
"DESC",
|
||||
"DISTINCT",
|
||||
"DROP",
|
||||
"ELSE",
|
||||
"END",
|
||||
"EXECUTE",
|
||||
"EXISTS",
|
||||
"FALSE",
|
||||
"FROM",
|
||||
"GRANT",
|
||||
"GROUP",
|
||||
"HAVING",
|
||||
"IN",
|
||||
"INDEX",
|
||||
"INNER",
|
||||
"INSERT",
|
||||
"INTO",
|
||||
"IS",
|
||||
"JOIN",
|
||||
"KEY",
|
||||
"LEFT",
|
||||
"LIKE",
|
||||
"MAX",
|
||||
"MIN",
|
||||
"NOT",
|
||||
"NULL",
|
||||
"ON",
|
||||
"OR",
|
||||
"ORDER",
|
||||
"OUTER",
|
||||
"OUTPUT",
|
||||
"PRIMARY",
|
||||
"PROCEDURE",
|
||||
"REVOKE",
|
||||
"ROLLBACK",
|
||||
"ROWCOUNT",
|
||||
"SELECT",
|
||||
"SET",
|
||||
"SQL",
|
||||
"SUM",
|
||||
"TABLE",
|
||||
"THEN",
|
||||
"TRANSACTION",
|
||||
"TRUE",
|
||||
"UNION",
|
||||
"UNIQUE",
|
||||
"UPDATE",
|
||||
"USER",
|
||||
"VALUES",
|
||||
"VIEW",
|
||||
"WHEN",
|
||||
"WHERE",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
// Tag replacement is expanded to avoid reading Footer resource unless required.
|
||||
ReplaceDynamicEmailTag(emailData, EmailTag_Footer, SbmResourceHelper.GetTextResource(SbmResourceHelper.TextResource.Email_Footer_Html));
|
||||
}
|
||||
|
||||
// Session data is optional.
|
||||
if (sessionData != null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -20,9 +20,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
|
||||
Email_Header_Html,
|
||||
Email_Footer_Html,
|
||||
// Email templates.
|
||||
Email_ContactUs_Html,
|
||||
Email_Signup_Activate_Html,
|
||||
Email_Signup_Welcome_Html,
|
||||
Email_RequestPassword_Html,
|
||||
// Data - CSV files etc.
|
||||
}
|
||||
@@ -41,27 +38,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
|
||||
{
|
||||
// Email stylesheet.
|
||||
case TextResource.Email_Main_Css:
|
||||
resourceFilename = "sax-email-main.css";
|
||||
resourceFilename = "sbm-email-main.css";
|
||||
break;
|
||||
// Email partial content.
|
||||
case TextResource.Email_Header_Html:
|
||||
resourceFilename = "sax-email-header.html";
|
||||
resourceFilename = "sbm-email-header.html";
|
||||
break;
|
||||
case TextResource.Email_Footer_Html:
|
||||
resourceFilename = "sax-email-footer.html";
|
||||
resourceFilename = "sbm-email-footer.html";
|
||||
break;
|
||||
// Email templates.
|
||||
case TextResource.Email_ContactUs_Html:
|
||||
resourceFilename = "sax-email-contact-us.html";
|
||||
break;
|
||||
case TextResource.Email_Signup_Activate_Html:
|
||||
resourceFilename = "sax-email-signup-activate.html";
|
||||
break;
|
||||
case TextResource.Email_Signup_Welcome_Html:
|
||||
resourceFilename = "sax-email-signup-welcome.html";
|
||||
break;
|
||||
case TextResource.Email_RequestPassword_Html:
|
||||
resourceFilename = "sax-email-request-password.html";
|
||||
resourceFilename = "sbm-email-request-password.html";
|
||||
break;
|
||||
// Data.
|
||||
}
|
||||
|
||||
@@ -232,14 +232,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
SbmApplication application = SbmGlobals.Application;
|
||||
if (application != null)
|
||||
return application.BusMgrTableExists(SessionContext, tableIdx);
|
||||
{
|
||||
ISacsDatabase busMgrDb = application.GetBusMgrDatabase(SessionContext);
|
||||
return application.DbTableExists(busMgrDb, tableIdx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool ColumnExists(SbmDbDfn.ColumnIdx columnIdx)
|
||||
{
|
||||
SbmApplication application = SbmGlobals.Application;
|
||||
if (application != null)
|
||||
return application.BusMgrColumnExists(SessionContext, columnIdx);
|
||||
{
|
||||
ISacsDatabase busMgrDb = application.GetBusMgrDatabase(SessionContext);
|
||||
return application.DbColumnExists(busMgrDb, columnIdx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user