3.0.0.1 Demo repository registration
This commit is contained in:
@@ -51,66 +51,34 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
|
||||
{
|
||||
return new SbmAccountMgr_Dbas(internals);
|
||||
}
|
||||
public override SbmAccountMgr CreateAccountMgr(ISbmUserOrganisationContext userContext)
|
||||
{
|
||||
return new SbmAccountMgr_Dbas(userContext);
|
||||
}
|
||||
public override SbmAssetMgr CreateAssetMgr(SbmInternals internals)
|
||||
{
|
||||
return new SbmAssetMgr_Dbas(internals);
|
||||
}
|
||||
public override SbmAssetMgr CreateAssetMgr(ISbmUserOrganisationContext userContext)
|
||||
{
|
||||
return new SbmAssetMgr_Dbas(userContext);
|
||||
}
|
||||
public override SbmCommodityMgr CreateCommodityMgr(SbmInternals internals)
|
||||
{
|
||||
return new SbmCommodityMgr_Dbas(internals);
|
||||
}
|
||||
public override SbmCommodityMgr CreateCommodityMgr(ISbmUserOrganisationContext userContext)
|
||||
{
|
||||
return new SbmCommodityMgr_Dbas(userContext);
|
||||
}
|
||||
public override SbmPriceMgr CreatePriceMgr(SbmInternals internals)
|
||||
{
|
||||
return new SbmPriceMgr_Dbas(internals);
|
||||
}
|
||||
public override SbmPriceMgr CreatePriceMgr(ISbmUserOrganisationContext userContext)
|
||||
{
|
||||
return new SbmPriceMgr_Dbas(userContext);
|
||||
}
|
||||
public override SbmDataItemMgr CreateDataItemMgr(SbmInternals internals)
|
||||
{
|
||||
return new SbmDataItemMgr_Dbas(internals);
|
||||
}
|
||||
public override SbmDataItemMgr CreateDataItemMgr(ISbmUserOrganisationContext userContext)
|
||||
{
|
||||
return new SbmDataItemMgr_Dbas(userContext);
|
||||
}
|
||||
public override SbmProcessMgr CreateProcessMgr(SbmInternals internals)
|
||||
{
|
||||
return new SbmProcessMgr_Dbas(internals);
|
||||
}
|
||||
public override SbmProcessMgr CreateProcessMgr(ISbmUserOrganisationContext userContext)
|
||||
{
|
||||
return new SbmProcessMgr_Dbas(userContext);
|
||||
}
|
||||
public override SbmStockMgr CreateStockMgr(SbmInternals internals)
|
||||
{
|
||||
return new SbmStockMgr_Dbas(internals);
|
||||
}
|
||||
public override SbmStockMgr CreateStockMgr(ISbmUserOrganisationContext userContext)
|
||||
{
|
||||
return new SbmStockMgr_Dbas(userContext);
|
||||
}
|
||||
public override SbmTransactionMgr CreateTransactionMgr(SbmInternals internals)
|
||||
{
|
||||
return new SbmTransactionMgr_Dbas(internals);
|
||||
}
|
||||
public override SbmTransactionMgr CreateTransactionMgr(ISbmUserOrganisationContext userContext)
|
||||
{
|
||||
return new SbmTransactionMgr_Dbas(userContext);
|
||||
}
|
||||
|
||||
// Control.
|
||||
public override SbmcAccountMgr CreateControlAccountMgr()
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control
|
||||
{
|
||||
//=======================================================================
|
||||
internal class SbmcAccountRegistration_Dbas : SbmcAccountRegistration
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmcAccountRegistration_Dbas(SysId id, string emailAddress, Guid registerAccountToken, ushort flags) :
|
||||
base(id, emailAddress, registerAccountToken)
|
||||
{
|
||||
Flags = flags;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -22,13 +22,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control
|
||||
{
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -22,13 +22,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control
|
||||
{
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -22,13 +22,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control
|
||||
{
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -22,13 +22,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control
|
||||
{
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
}
|
||||
}
|
||||
else SetErrorState("database is unavailable");
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
}
|
||||
}
|
||||
else SetErrorState("database is unavailable");
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using Sarand.Net.Standard.Dbas.CodeTypes;
|
||||
@@ -9,16 +10,31 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
public abstract class SbmCodeTypeConsole_Dbas : SaCodeTypeConsole_Dbas
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmCodeTypeConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
// Data members.
|
||||
private class DataMembers
|
||||
{
|
||||
UserContext = userContext;
|
||||
public DataMembers (SbmInternals internalsSupplied)
|
||||
{
|
||||
this.InternalsSupplied = internalsSupplied;
|
||||
}
|
||||
public SbmInternals InternalsSupplied { get; }
|
||||
}
|
||||
private DataMembers mbr {get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmCodeTypeConsole_Dbas(SbmInternals internals) : base(internals.BusMgrDatabase)
|
||||
{
|
||||
mbr = new DataMembers(internals);
|
||||
SbmSystem.RegisterCodeTypes(SessionConsole, this);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISbmUserOrganisationContext UserContext { get; }
|
||||
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
|
||||
private SbmInternals Internals { get { return mbr.InternalsSupplied; } }
|
||||
private SbmSessionContext SessionContext { get { return Internals.SessionContext; } }
|
||||
private ISbmUserOrganisationContext UserContext { get { return Internals.UserContext; } }
|
||||
private SbmSessionConsole SessionConsole { get{ return Internals.SessionConsole; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
public abstract class SbmCoreInstanceConsole_Dbas : SbmCoreInstanceConsole
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmCoreInstanceConsole_Dbas()
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
public static SacsDatabaseConsole.OdbcConfig GetRepositoryOdbcConfig(SbmcRepository repository)
|
||||
{
|
||||
SacsDatabaseConsole.OdbcConfig config = new SacsDatabaseConsole.OdbcConfig();
|
||||
config.Location = $"MsSql:{repository.ServerName}\\{repository.InstanceName}.{repository.DatabaseName}";
|
||||
config.User = repository.UserName;
|
||||
config.Password = repository.Password;
|
||||
return config;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
@@ -9,36 +14,549 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmSessionContext sessionContext;
|
||||
private class DataMembers
|
||||
{
|
||||
public DataMembers(SbmSessionContext sessionContext)
|
||||
{
|
||||
this.SessionContext = sessionContext;
|
||||
}
|
||||
public SbmSessionContext SessionContext { get; }
|
||||
public ISacsDatabase Database { get; set; }
|
||||
}
|
||||
private DataMembers mbr { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmDatabaseConsole(SbmSessionContext sessionContext)
|
||||
{
|
||||
this.sessionContext = sessionContext;
|
||||
this.mbr = new DataMembers(sessionContext);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
private SbmSessionContext SessionContext { get { return mbr.SessionContext; } }
|
||||
private ISacsDatabase Database { get { if (mbr.Database == null) { mbr.Database = SbmGlobals.Application.GetBusMgrDatabase(SessionContext); } return mbr.Database; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D a t a b a s e I n d i c e s
|
||||
// Database Indices.
|
||||
//-------------------------------------------------------------------
|
||||
public bool CreateDbIndices(IndexStats indexStats)
|
||||
public bool InstallDbIndices(IndexStats indexStats)
|
||||
{
|
||||
ClearErrorState();
|
||||
ISacsDatabase database = SbmGlobals.Application.GetBusMgrDatabase(sessionContext);
|
||||
if (database == null || database.DbmsType != DbmsType.MsSql) return SetErrorState("");
|
||||
if (Database == null || Database.DbmsType != DbmsType.MsSql) return SetErrorState("");
|
||||
|
||||
// Turn off database exceptions.
|
||||
bool displayDbExceptionsPrev = database.DisplayErrors;
|
||||
database.DisplayErrors = false;
|
||||
bool displayDbExceptionsPrev = Database.DisplayErrors;
|
||||
Database.DisplayErrors = false;
|
||||
|
||||
// ToDo SbmDatabaseConsole Create database indices.
|
||||
//---------------------------------------------------------------
|
||||
// Common tables.
|
||||
|
||||
// NextId table:
|
||||
CreatePrimaryDbIndex("NextId", "Object");
|
||||
|
||||
// Attribute Update table:
|
||||
CreatePrimaryDbIndex("SaAttrUpdate", "Logged,ItemType,ItemId,Attribute");
|
||||
CreateDbIndex("SaAttrUpdate", "IDX_SaAttrUpdate_Item", "ItemType,ItemId,Logged,Attribute");
|
||||
CreateDbIndex("SaAttrUpdate", "IDX_SaAttrUpdate_ItemAttr", "ItemType,ItemId,Attribute,Logged");
|
||||
|
||||
// Code table:
|
||||
CreatePrimaryDbIndex("SaCode", "Id");
|
||||
CreateDbIndex("SaCode", "IDX_SaCode_Status", "Status");
|
||||
CreateDbIndex("SaCode", "IDX_SaCode_Type", "CodeTypeId");
|
||||
CreateDbIndex("SaCode", "IDX_SaCode_TypeCode", "CodeTypeId,Code", "", true);
|
||||
CreateDbIndex("SaCode", "IDX_SaCode_TypeSeq", "CodeTypeId,Seq");
|
||||
|
||||
// Code Type table:
|
||||
CreatePrimaryDbIndex("SaCodeType", "Id");
|
||||
CreateDbIndex("SaCodeType", "IDX_SaCodeType_Code", "Code", "", true);
|
||||
|
||||
// Diary Entry table:
|
||||
CreatePrimaryDbIndex("SaDiaryEntry", "Id");
|
||||
CreateDbIndex("SaDiaryEntry", "IDX_SaDiaryEntry_Finish", "Finish");
|
||||
CreateDbIndex("SaDiaryEntry", "IDX_SaDiaryEntry_Start", "Start");
|
||||
|
||||
// Diary Link table:
|
||||
CreatePrimaryDbIndex("SaDiaryLink", "EntryId,ItemType,ItemId");
|
||||
|
||||
// Item Data table:
|
||||
CreatePrimaryDbIndex("SaItemData", "Id");
|
||||
CreateDbIndex("SaItemData", "IDX_SaItemData_DataTypeItem", "DataType,ItemType,ItemId");
|
||||
CreateDbIndex("SaItemData", "IDX_SaItemData_Item", "ItemType,ItemId");
|
||||
CreateDbIndex("SaItemData", "IDX_SaItemData_ItemTypeDataType", "ItemType,DataType");
|
||||
|
||||
// Item Document table:
|
||||
CreatePrimaryDbIndex("SaItemDoc", "Id");
|
||||
CreateDbIndex("SaItemDoc", "IDX_SaItemDoc_Item", "ItemType,ItemId");
|
||||
|
||||
// Item Named Value table:
|
||||
CreatePrimaryDbIndex("SaItemNamedValue", "ItemType,ItemId,Name,Seq");
|
||||
CreateDbIndex("SaItemNamedValue", "IDX_SaItemNamedValue_Item", "ItemType,ItemId");
|
||||
CreateDbIndex("SaItemNamedValue", "IDX_SaItemNamedValue_ItemName", "ItemType,ItemId,Name");
|
||||
CreateDbIndex("SaItemNamedValue", "IDX_SaItemNamedValue_Name", "Name");
|
||||
|
||||
// Item Option table:
|
||||
CreatePrimaryDbIndex("SaItemOption", "ItemType,ItemId,Name,Context");
|
||||
CreateDbIndex("SaItemOption", "IDX_SaItemOption_Item", "ItemType,ItemId");
|
||||
CreateDbIndex("SaItemOption", "IDX_SaItemOption_ItemName", "ItemType,ItemId,Name");
|
||||
CreateDbIndex("SaItemOption", "IDX_SaItemOption_Name", "Name");
|
||||
|
||||
// Security Item table:
|
||||
CreatePrimaryDbIndex("SaSecItem", "Id");
|
||||
CreateDbIndex("SaSecItem", "IDX_SaSecItem_Code", "Code");
|
||||
CreateDbIndex("SaSecItem", "IDX_SaSecItem_Desc", "Description");
|
||||
CreateDbIndex("SaSecItem", "IDX_SaSecItem_TypeCode", "Type,Code", "", true);
|
||||
|
||||
// Security Link table:
|
||||
CreatePrimaryDbIndex("SaSecLink", "ItemOwner,ItemTarget,ItemContext");
|
||||
CreateDbIndex("SaSecLink", "IDX_SaSecLink_ItemContext", "ItemContext");
|
||||
CreateDbIndex("SaSecLink", "IDX_SaSecLink_ItemOwner", "ItemOwner");
|
||||
CreateDbIndex("SaSecLink", "IDX_SaSecLink_ItemTarget", "ItemTarget");
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// I n t e r f a c e s
|
||||
//---------------------------------------------------------------------
|
||||
// Interface table:
|
||||
CreatePrimaryDbIndex("Interface", "Id");
|
||||
CreateDbIndex("Interface", "IDX_Interface_ContextCategoryType", "Context,Category,Type");
|
||||
CreateDbIndex("Interface", "IDX_Interface_ContextCode", "Context,Code", "", true);
|
||||
|
||||
// Interface Data Item table:
|
||||
CreatePrimaryDbIndex("InterfaceDataItem", "Id");
|
||||
CreateDbIndex("InterfaceDataItem", "IDX_InterfaceDataItem_InterfaceDirectionItemRef", "InterfaceId,Direction,ItemType,ExternalRef");
|
||||
CreateDbIndex("InterfaceDataItem", "IDX_InterfaceDataItem_InterfaceItemRef", "InterfaceId,Direction,ItemType,ItemId,ExternalRef", "", true);
|
||||
CreateDbIndex("InterfaceDataItem", "IDX_InterfaceDataItem_InterfaceStatusItemRef", "InterfaceId,Direction,ProcessStatus,ItemType,ItemId,ExternalRef", "", true);
|
||||
CreateDbIndex("InterfaceDataItem", "IDX_InterfaceDataItem_Item", "ItemType,ItemId");
|
||||
CreateDbIndex("InterfaceDataItem", "IDX_InterfaceDataItem_ItemExternal", "ItemType,ExternalRef");
|
||||
|
||||
// Interface Process table:
|
||||
CreatePrimaryDbIndex("InterfaceProcess", "Id");
|
||||
CreateDbIndex("InterfaceProcess", "IDX_InterfaceProcess_IntDirSeq", "InterfaceId,Direction,ProcSeq", "", true);
|
||||
CreateDbIndex("InterfaceProcess", "IDX_InterfaceProcess_IntProc", "InterfaceId,ProcRef");
|
||||
CreateDbIndex("InterfaceProcess", "IDX_InterfaceProcess_IntProcDate", "InterfaceId,ProcDate,ProcTime");
|
||||
|
||||
// Interface Process Data Item table:
|
||||
CreatePrimaryDbIndex("InterfaceProcessDataItem", "ProcessId,InterfaceDataItemId");
|
||||
CreateDbIndex("InterfaceProcessDataItem", "IDX_InterfaceProcessDataItem_Item", "InterfaceDataItemId");
|
||||
CreateDbIndex("InterfaceProcessDataItem", "IDX_InterfaceProcessDataItem_ProcItemData", "ProcessId,ItemData");
|
||||
|
||||
// InterfaceProcessMessage table:
|
||||
CreatePrimaryDbIndex("InterfaceProcessMessage", "Id");
|
||||
CreateDbIndex("InterfaceProcessMessage", "IDX_InterfaceProcessMessage_Process", "ProcessId");
|
||||
CreateDbIndex("InterfaceProcessMessage", "IDX_InterfaceProcessMessage_ProcMsgType", "ProcessId,MsgType");
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// B u s i n e s s M a n a g e r
|
||||
//---------------------------------------------------------------------
|
||||
// Address table:
|
||||
CreatePrimaryDbIndex("Address", "Id");
|
||||
CreateDbIndex("Address", "IDX_Address_CityRgn", "CityRgn");
|
||||
CreateDbIndex("Address", "IDX_Address_CountryRgn", "CountryRgn");
|
||||
CreateDbIndex("Address", "IDX_Address_Flags", "Flags");
|
||||
CreateDbIndex("Address", "IDX_Address_Item", "ItemType,ItemId");
|
||||
CreateDbIndex("Address", "IDX_Address_Line1", "Line1");
|
||||
CreateDbIndex("Address", "IDX_Address_Owner", "AffIdOwner");
|
||||
CreateDbIndex("Address", "IDX_Address_Postcode", "Postcode");
|
||||
CreateDbIndex("Address", "IDX_Address_PostcodeFmt", "PostcodeFmt");
|
||||
CreateDbIndex("Address", "IDX_Address_ProvinceRgn", "ProvinceRgn");
|
||||
CreateDbIndex("Address", "IDX_Address_RefAddress", "AddIdRef");
|
||||
CreateDbIndex("Address", "IDX_Address_Status", "Status");
|
||||
CreateDbIndex("Address", "IDX_Address_Type", "Type");
|
||||
|
||||
// Affiliate table:
|
||||
CreatePrimaryDbIndex("Affiliate", "Id");
|
||||
CreateDbIndex("Affiliate", "IDX_Affiliate_Name", "Name");
|
||||
CreateDbIndex("Affiliate", "IDX_Affiliate_Status", "Status");
|
||||
CreateDbIndex("Affiliate", "IDX_Affiliate_Type", "Type");
|
||||
CreateDbIndex("Affiliate", "IDX_Affiliate_UserId", "UserId");
|
||||
|
||||
// Association table:
|
||||
CreatePrimaryDbIndex("Association", "Id");
|
||||
CreateDbIndex("Association", "IDX_Association_Code", "Code");
|
||||
CreateDbIndex("Association", "IDX_Association_ExtRef", "ExtRef");
|
||||
CreateDbIndex("Association", "IDX_Association_Owner", "AffIdOwner");
|
||||
CreateDbIndex("Association", "IDX_Association_OwnerTargetType", "AffIdOwner,AffIdTarget,Type", "", true);
|
||||
CreateDbIndex("Association", "IDX_Association_OwnerTypeCode", "AffIdOwner,Type,Code");
|
||||
CreateDbIndex("Association", "IDX_Association_PriceSet", "PriceSetId");
|
||||
CreateDbIndex("Association", "IDX_Association_Target", "AffIdTarget");
|
||||
CreateDbIndex("Association", "IDX_Association_TaxCode", "TaxCodeId");
|
||||
|
||||
// Commodity table:
|
||||
CreatePrimaryDbIndex("Commodity", "Id");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_AssetCat", "AssetCatId");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_CodeIssue", "Code,DrawingIssue");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Colour", "ColourCode");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Customer", "AssIdCustomer");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Delivery", "DeliveryCode");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Description", "DescBrief");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Finish", "FinishCode");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Handling", "HandlingCode");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Material", "MaterialCode");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Owner", "AffIdOwner");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Range", "RangeCode");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_SalesProjCommodity", "CommodityIdSalesProj");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Source", "SourceCode");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_Supplier", "AssIdSupplier");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_SupplyMethod", "SupplyMethodCode");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_TaxCode", "TaxCodeId");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_UomBox", "UomIdBox");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_UomDensity", "UomIdDensity");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_UomLength", "UomIdLength");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_UomSale", "UomIdSale");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_UomTimeProd", "UomIdTimeProd");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_UomVolume", "UomIdVolume");
|
||||
CreateDbIndex("Commodity", "IDX_Commodity_UomWeight", "UomIdWeight");
|
||||
|
||||
// Commodity Customer table:
|
||||
CreatePrimaryDbIndex("CommodityCustomer", "CommodityId,AssocIdCustomer");
|
||||
CreateDbIndex("CommodityCustomer", "IDX_CommodityCustomer_Currency", "CurrencyIdRetail");
|
||||
CreateDbIndex("CommodityCustomer", "IDX_CommodityCustomer_Customer", "AssocIdCustomer");
|
||||
|
||||
// Commodity Supplier table:
|
||||
CreatePrimaryDbIndex("CommoditySupplier", "CommodityId,AssocIdSupplier");
|
||||
CreateDbIndex("CommoditySupplier", "IDX_CommoditySupplier_Currency", "CurrencyIdCost");
|
||||
CreateDbIndex("CommoditySupplier", "IDX_CommoditySupplier_Supplier", "AssocIdSupplier");
|
||||
|
||||
// Constituent table:
|
||||
CreatePrimaryDbIndex("Constituent", "Id");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Asset", "AssetId");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Assoc", "AssocId");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Const", "ConstId");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Contractor", "AssocIdContractor");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Effective", "Effective");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Owner", "AffIdOwner");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Process", "ProcessId");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Reqnt", "ReqntId");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Target", "AffIdTarget");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_TaxCode", "TaxCodeId");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Trans", "TransId");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Type", "Type");
|
||||
CreateDbIndex("Constituent", "IDX_Constituent_Uom", "UomId");
|
||||
|
||||
// Container table:
|
||||
CreatePrimaryDbIndex("Container", "Id");
|
||||
CreateDbIndex("Container", "IDX_Container_Customer", "AssIdCustomer");
|
||||
CreateDbIndex("Container", "IDX_Container_OwnerRef", "AffIdOwner,Reference");
|
||||
CreateDbIndex("Container", "IDX_Container_OwnerType", "AffIdOwner,Type");
|
||||
CreateDbIndex("Container", "IDX_Container_Supplier", "AssIdSupplier");
|
||||
CreateDbIndex("Container", "IDX_Container_TagId", "TagId");
|
||||
|
||||
// Container Item table:
|
||||
CreatePrimaryDbIndex("ContainerItem", "ContainerId,ItemSeq,ItemType,ItemId");
|
||||
CreateDbIndex("ContainerItem", "IDX_ContainerItem_ContainerSeq", "ContainerId,ItemSeq");
|
||||
CreateDbIndex("ContainerItem", "IDX_ContainerItem_Item", "ItemType,ItemId");
|
||||
CreateDbIndex("ContainerItem", "IDX_ContainerItem_SourceItem", "ItemTypeSource,ItemIdSource");
|
||||
|
||||
// Item Link table:
|
||||
//CreatePrimaryDbIndex ("ItemLink","Type,ItemTypeFrom,ItemIdFrom,ItemTypeTo,ItemIdTo,Seq");
|
||||
CreateDbIndex("ItemLink", "IDX_ItemLink_ItemFrom", "ItemTypeFrom,ItemIdFrom");
|
||||
CreateDbIndex("ItemLink", "IDX_ItemLink_ItemTo", "ItemTypeTo,ItemIdTo");
|
||||
CreateDbIndex("ItemLink", "IDX_ItemLink_TypeItemFromStatus", "Type,ItemTypeFrom,ItemIdFrom,Status");
|
||||
CreateDbIndex("ItemLink", "IDX_ItemLink_Type_ItemTypeFrom_ItemTypeTo", "Type,ItemTypeFrom,ItemTypeTo", "ItemIdFrom,ItemIdTo");
|
||||
|
||||
// Location table:
|
||||
CreatePrimaryDbIndex("Location", "Id");
|
||||
CreateDbIndex("Location", "IDX_Location_Owner", "AffIdOwner");
|
||||
CreateDbIndex("Location", "IDX_Location_OwnerCat", "AffIdOwner,Category");
|
||||
CreateDbIndex("Location", "IDX_Location_OwnerCode", "AffIdOwner,Code");
|
||||
|
||||
// Movement table:
|
||||
CreatePrimaryDbIndex("Movement", "Id");
|
||||
CreateDbIndex("Movement", "IDX_Movement_Item", "ItemType,ItemId");
|
||||
CreateDbIndex("Movement", "IDX_Movement_ItemTypeMovement", "ItemType,ItemId,Type,Movement");
|
||||
CreateDbIndex("Movement", "IDX_Movement_LocationFrom", "LocationIdFrom");
|
||||
CreateDbIndex("Movement", "IDX_Movement_LocationTo", "LocationIdTo");
|
||||
CreateDbIndex("Movement", "IDX_Movement_Movement", "Movement");
|
||||
CreateDbIndex("Movement", "IDX_Movement_SourceItem", "ItemTypeSource,ItemIdSource");
|
||||
CreateDbIndex("Movement", "IDX_Movement_SourceMovement", "MovementIdSource");
|
||||
|
||||
// PortfolioItem table:
|
||||
CreatePrimaryDbIndex("PortfolioItem", "Id");
|
||||
CreateDbIndex("PortfolioItem", "IDX_PortfolioItem_Commodity", "CommodityId");
|
||||
CreateDbIndex("PortfolioItem", "IDX_PortfolioItem_Owner", "AffIdOwner");
|
||||
CreateDbIndex("PortfolioItem", "IDX_PortfolioItem_OwnerParentCode", "AffIdOwner,ItemIdParent,Code");
|
||||
CreateDbIndex("PortfolioItem", "IDX_PortfolioItem_OwnerParentType", "AffIdOwner,ItemIdParent,Type");
|
||||
CreateDbIndex("PortfolioItem", "IDX_PortfolioItem_ParentItem", "ItemIdParent");
|
||||
CreateDbIndex("PortfolioItem", "IDX_PortfolioItem_ParentSeq", "ItemIdParent,Seq");
|
||||
CreateDbIndex("PortfolioItem", "IDX_PortfolioItem_RefItem", "ItemIdRef");
|
||||
CreateDbIndex("PortfolioItem", "IDX_PortfolioItem_ShortCut", "ShortCut");
|
||||
|
||||
// Process table:
|
||||
CreatePrimaryDbIndex("Process", "Id");
|
||||
CreateDbIndex("Process", "IDX_Process_OwnerCategory", "AffIdOwner,Category");
|
||||
CreateDbIndex("Process", "IDX_Process_OwnerSeq", "AffIdOwner,Seq");
|
||||
CreateDbIndex("Process", "IDX_Process_OwnerType", "AffIdOwner,Type");
|
||||
|
||||
// Requirement table:
|
||||
CreatePrimaryDbIndex("Requirement", "Id");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_Reqnt_Trans", "Id,TransId", "ReqntIdSource", true);
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_Reqnt_Trans_ReqntSource", "Id,TransId,ReqntIdSource", "", true);
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_AffilOwner", "AffIdOwner");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_Asset", "AssetId");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_Assoc", "AssocId");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_AssocContract", "AssIdSubcontract");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_Commodity", "CommodityId");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_MaterialSource", "MaterialSourceCode");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_ProductCode", "ProductCode");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_ReqntSource", "ReqntIdSource");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_StockLocation", "LocationIdStock");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_TaxCode", "TaxCodeId");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_Trans", "TransId");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_TransCommodityStatus", "TransId,CommodityId,Status");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_TransSeq", "TransId,Seq");
|
||||
CreateDbIndex("Requirement", "IDX_Requirement_Uom", "UomId");
|
||||
|
||||
// Asset table:
|
||||
CreatePrimaryDbIndex("SaAsset", "Id");
|
||||
CreateDbIndex("SaAsset", "IDX_SaAsset_CategorySerial", "AssetCategoryId,SerialFmt", "", true);
|
||||
CreateDbIndex("SaAsset", "IDX_SaAsset_Customer", "AssocIdCustomer,Id", "", true);
|
||||
CreateDbIndex("SaAsset", "IDX_SaAsset_Item", "ItemType,ItemId");
|
||||
CreateDbIndex("SaAsset", "IDX_SaAsset_Supplier", "AssocIdSupplier,Id", "", true);
|
||||
|
||||
// Asset Category table:
|
||||
CreatePrimaryDbIndex("SaAssetCategory", "Id");
|
||||
CreateDbIndex("SaAssetCategory", "IDX_SaAssetCategory_Customer", "AssocIdCustomer,Id", "", true);
|
||||
CreateDbIndex("SaAssetCategory", "IDX_SaAssetCategory_OwnerType", "AffIdOwner,AssetType,Code", "", true);
|
||||
CreateDbIndex("SaAssetCategory", "IDX_SaAssetCategory_Supplier", "AssocIdSupplier,Id", "", true);
|
||||
|
||||
// Asset Process table:
|
||||
CreatePrimaryDbIndex("SaAssetProcess", "Id");
|
||||
|
||||
// Price table:
|
||||
CreatePrimaryDbIndex("SaPrice", "PriceSetId,CommodityId");
|
||||
CreateDbIndex("SaPrice", "IDX_SaPrice_Commodity", "CommodityId");
|
||||
CreateDbIndex("SaPrice", "IDX_SaPrice_PriceSet", "PriceSetId");
|
||||
|
||||
// Price Set table:
|
||||
CreatePrimaryDbIndex("SaPriceSet", "Id");
|
||||
CreateDbIndex("SaPriceSet", "IDX_SaPriceSet_AffOwner", "AffIdOwner");
|
||||
CreateDbIndex("SaPriceSet", "IDX_SaPriceSet_Currency", "CurrencyId");
|
||||
CreateDbIndex("SaPriceSet", "IDX_SaPriceSet_Name", "Name");
|
||||
CreateDbIndex("SaPriceSet", "IDX_SaPriceSet_OwnerRef", "AffIdOwner,Ref", "", true);
|
||||
|
||||
// Vehicle table:
|
||||
CreatePrimaryDbIndex("SaVehicle", "Id");
|
||||
CreateDbIndex("SaVehicle", "IDX_SaVehicle_CapCode", "CapCode,Id", "", true);
|
||||
CreateDbIndex("SaVehicle", "IDX_SaVehicle_KeyLocation", "KeyLocation,Id", "", true);
|
||||
CreateDbIndex("SaVehicle", "IDX_SaVehicle_RegNumber", "RegNumber", "", true);
|
||||
CreateDbIndex("SaVehicle", "IDX_SaVehicle_VehicleClass", "VehicleClassId,Id", "", true);
|
||||
|
||||
// Vehicle Class table:
|
||||
CreatePrimaryDbIndex("SaVehicleClass", "Id");
|
||||
CreateDbIndex("SaVehicleClass", "IDX_SaVehicleClass_Category", "VehicleCategoryCode");
|
||||
CreateDbIndex("SaVehicleClass", "IDX_SaVehicleClass_Make", "MakeCode,Id", "", true);
|
||||
|
||||
// Vehicle Event table:
|
||||
CreatePrimaryDbIndex("SaVehicleEvent", "Id");
|
||||
CreateDbIndex("SaVehicleEvent", "IDX_SaVehicleEvent_TaxCode", "TaxCodeId");
|
||||
CreateDbIndex("SaVehicleEvent", "IDX_SaVehicleEvent_VehicleStart", "VehicleId,StartOn", "", true);
|
||||
|
||||
// Vehicle Feature table:
|
||||
CreatePrimaryDbIndex("SaVehicleFeature", "VehicleId,Source,Type,CategoryCode,FeatureCode");
|
||||
|
||||
// Stock Level table:
|
||||
CreatePrimaryDbIndex("StockLevel", "Id");
|
||||
CreateDbIndex("StockLevel", "IDX_StockLevel_Commodity", "CommodityId");
|
||||
CreateDbIndex("StockLevel", "IDX_StockLevel_CommodityRecorded", "CommodityId,Recorded");
|
||||
CreateDbIndex("StockLevel", "IDX_StockLevel_CommodityType", "CommodityId,Type");
|
||||
CreateDbIndex("StockLevel", "IDX_StockLevel_Location", "LocationId");
|
||||
CreateDbIndex("StockLevel", "IDX_StockLevel_Recorded", "Recorded");
|
||||
CreateDbIndex("StockLevel", "IDX_StockLevel_Type", "Type");
|
||||
|
||||
// System Account table:
|
||||
CreatePrimaryDbIndex("SystemAccount", "Id");
|
||||
CreateDbIndex("SystemAccount", "IDX_SystemAccount_AffIdOwner", "AffIdOwner");
|
||||
CreateDbIndex("SystemAccount", "IDX_SystemAccount_Association", "AssocId");
|
||||
CreateDbIndex("SystemAccount", "IDX_SystemAccount_Interface", "InterfaceId");
|
||||
|
||||
// System Account User table:
|
||||
CreatePrimaryDbIndex("SystemAccountUser", "AccountId,UserId");
|
||||
CreateDbIndex("SystemAccountUser", "IDX_SystemAccountUser_User", "UserId");
|
||||
|
||||
// System User table:
|
||||
CreatePrimaryDbIndex("SystemUser", "Id");
|
||||
CreateDbIndex("SystemUser", "IDX_SystemUser_AffiliateId", "AffiliateId");
|
||||
CreateDbIndex("SystemUser", "IDX_SystemUser_Interface", "InterfaceId");
|
||||
CreateDbIndex("SystemUser", "IDX_SystemUser_OwnerCode", "AffIdOwner,Code", "", true);
|
||||
|
||||
// Transaction table:
|
||||
CreatePrimaryDbIndex("Transaction", "Id");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_AffilRaise", "AffIdRaise");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_AffilRefer", "AffIdRefer");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_Assoc", "AssocId");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_AssocContract", "AssocIdContract");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_AssocOffice", "AssocIdOffice");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_AssocType", "AssocId,Type");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_Currency", "CurrencyId");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_OwnerRef", "AffIdOwner,Ref");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_OwnerRefExt", "AffIdOwner,RefExt");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_OwnerTypeRaised", "AffIdOwner,Type,Raised");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_Postcode", "Postcode");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_StatusCat", "StatusCat");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_StockLocation", "LocationIdStock");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_TaxCode", "TaxCodeId");
|
||||
CreateDbIndex("Transaction", "IDX_Transaction_TransSource", "TransIdSource");
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// R e f e r e n c e D a t a
|
||||
//---------------------------------------------------------------------
|
||||
// Currency table:
|
||||
CreatePrimaryDbIndex("Currency", "Id");
|
||||
CreateDbIndex("Currency", "IDX_Currency_Code", "Code", "", true);
|
||||
CreateDbIndex("Currency", "IDX_Currency_Region", "Region");
|
||||
|
||||
// Language table:
|
||||
CreatePrimaryDbIndex("Language", "Id");
|
||||
CreateDbIndex("Language", "IDX_Language_Code", "Code", "", true);
|
||||
|
||||
// Region table:
|
||||
CreatePrimaryDbIndex("Region", "Id");
|
||||
CreateDbIndex("Region", "IDX_Region_ParentTypeName", "Parent,Type,Name");
|
||||
CreateDbIndex("Region", "IDX_Region_TypeName", "Type,Name", "", true);
|
||||
|
||||
// SysParam table:
|
||||
CreatePrimaryDbIndex("SysParam", "Id");
|
||||
CreateDbIndex("SysParam", "IDX_SysParam_CatAssName", "Cat,AssocId,Name");
|
||||
CreateDbIndex("SysParam", "IDX_SysParam_CatName", "Cat,Name");
|
||||
CreateDbIndex("SysParam", "IDX_SysParam_CatOrgName", "Cat,AffIdTarget,Name");
|
||||
CreateDbIndex("SysParam", "IDX_SysParam_CatPerName", "Cat,AffIdOwner,Name");
|
||||
|
||||
// TaxCode table:
|
||||
CreatePrimaryDbIndex("TaxCode", "Id");
|
||||
CreateDbIndex("TaxCode", "IdX_TaxCode_Code", "Code");
|
||||
CreateDbIndex("TaxCode", "IdX_TaxCode_CodeAlt1", "CodeAlt1");
|
||||
CreateDbIndex("TaxCode", "IdX_TaxCode_CodeAlt2", "CodeAlt2");
|
||||
|
||||
// Unit of Measure table:
|
||||
CreatePrimaryDbIndex("UnitMeasure", "Id");
|
||||
CreateDbIndex("UnitMeasure", "IDX_UnitMeasure_Code", "Code", "", true);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Clean-up.
|
||||
database.DisplayErrors = displayDbExceptionsPrev;
|
||||
return !HasErrorState();
|
||||
Database.DisplayErrors = displayDbExceptionsPrev;
|
||||
return OK;
|
||||
}
|
||||
|
||||
private bool CreatePrimaryDbIndex(String tableName, String columns, bool dropIndicesIfNotExist = false)
|
||||
{
|
||||
if (HasErrorState()) return false;
|
||||
if (!Database.TableExists(tableName)) return true;
|
||||
List<String> columnNames = new List<String>(Regex.Split(columns, "[\\s,;\\-+]+"));
|
||||
DbDfnTable dfnTbl = Database.GetTableDfn(tableName);
|
||||
String indexName = "PK_" + tableName;
|
||||
if (!dfnTbl.HasIndexByName(indexName))
|
||||
{
|
||||
// Primary index does not exist on table.
|
||||
if (dropIndicesIfNotExist)
|
||||
{
|
||||
// All existing indices are dropped
|
||||
foreach (DbDfnIndex index in dfnTbl.Indices)
|
||||
DropDbIndex(tableName, index.Name);
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
// Examples:
|
||||
// MS Access: ALTER TABLE <table> ADD PRIMARY KEY (<ColumnList>)
|
||||
// 1. ALTER TABLE Customer ADD PRIMARY KEY (SID);
|
||||
// 2. ALTER TABLE [Sales].[Individual]
|
||||
// ADD CONSTRAINT [PK_Individual_CustomerID]
|
||||
// PRIMARY KEY CLUSTERED
|
||||
// ([CustomerID] ASC)
|
||||
String query = "ALTER TABLE [" + tableName + "] ADD CONSTRAINT [" + indexName + "] PRIMARY KEY (" + columnNames.Concat(",", "[", "]") + ")";
|
||||
if (Database.DbmsType == DbmsType.MsSql)
|
||||
query = "ALTER TABLE [" + tableName + "] ADD CONSTRAINT [" + indexName + "] PRIMARY KEY CLUSTERED (" + columnNames.Concat(",", "[", "]") + ")";
|
||||
SaLogger.Info($"{SysUtil.Fn} Query:\n\t" + query);
|
||||
if (!query.IsEmpty()) Database.ExecuteNonQuery(query);
|
||||
if (Database.HasErrorState())
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: {tableName}. Index: {indexName}. Exception: {Database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
#endif
|
||||
SetErrorState($"Failed to create primary index {indexName} on {tableName} - {Database.ErrorStateMessage}");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
private bool CreateDbIndex(String tableName, String indexName, String columns, String includeColumns = "", bool unique = false)
|
||||
{
|
||||
if (HasErrorState()) return false;
|
||||
if (!Database.TableExists(tableName)) return true;
|
||||
List<String> columnNames = new List<String>(Regex.Split(columns, "[\\s,;\\-+]+"));
|
||||
List<String> includeColumnNames = new List<String>(Regex.Split(includeColumns, "[\\s,;\\-+]+"));
|
||||
DbDfnTable dfnTbl = Database.GetTableDfn(tableName);
|
||||
if (!dfnTbl.HasIndexByName(indexName)) // ToDo Should also check the columns and their sequence in the index.
|
||||
{
|
||||
String query = "CREATE " + (unique ? "UNIQUE " : "") + "INDEX ";
|
||||
query += "[" + indexName + "] ON [" + tableName + "] (" + columnNames.Concat(",", "[", "]") + ")";
|
||||
if (!includeColumnNames.IsEmpty())
|
||||
query += " INCLUDE (" + includeColumnNames.Concat(",", "[", "]") + ")";
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: {tableName}. Index: {indexName}.");
|
||||
SaLogger.Debug("\tQuery: {query}");
|
||||
#endif
|
||||
SaLogger.Info($"{SysUtil.Fn} Query:\n\t" + query);
|
||||
if (!query.IsEmpty()) Database.ExecuteNonQuery(query);
|
||||
if (Database.HasErrorState())
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"\tException: {Database.ErrorStateMessage}");
|
||||
#endif
|
||||
SetErrorState($"Failed to create index {indexName} on {tableName} - {Database.ErrorStateMessage}");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
private bool DropDbIndex(String tableName, String indexName)
|
||||
{
|
||||
if (HasErrorState()) return false;
|
||||
if (!Database.TableExists(tableName)) return true;
|
||||
DbDfnTable dfnTbl = Database.GetTableDfn(tableName);
|
||||
if (!dfnTbl.HasIndexByName(indexName)) // ToDo Should also check the columns and their sequence in the index.
|
||||
{
|
||||
// Drop index:
|
||||
// MS Access: DROP INDEX index_name ON table_name
|
||||
// MS SQL Server: DROP INDEX table_name.index_name
|
||||
// DB2/Oracle: DROP INDEX index_name
|
||||
// MySQL: ALTER TABLE table_name DROP INDEX index_name
|
||||
String query = "DROP INDEX [" + indexName + "] ON [" + tableName + "]";
|
||||
SaLogger.Info("SapphireDbConsole_Odbc::DropDbIndex");
|
||||
SaLogger.Info("Query: " + query);
|
||||
if (Database.DbmsType == DbmsType.MsSql)
|
||||
query = "DROP INDEX [" + tableName + "].[" + indexName + "]";
|
||||
if (!query.IsEmpty()) Database.ExecuteNonQuery(query);
|
||||
if (Database.HasErrorState())
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: {tableName}. Index: {indexName}. Exception: {Database.ErrorStateMessage}");
|
||||
#endif
|
||||
SetErrorState($"Failed to drop index {indexName} on {tableName} - {Database.ErrorStateMessage}");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume this is the Primary Key:
|
||||
String query = "ALTER TABLE [" + tableName + "] DROP CONSTRAINT [" + indexName + "]";
|
||||
SaLogger.Info($"{SysUtil.Fn}");
|
||||
SaLogger.Info("Query: " + query);
|
||||
//if (Database.DbmsType == eSaDbmsMsSql)
|
||||
// sQry = (String)"DROP INDEX ["+sTable+"].["+sIndex+"]";
|
||||
if (!query.IsEmpty()) Database.ExecuteNonQuery(query);
|
||||
if (Database.HasErrorState())
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} Table: {tableName}. Index: {indexName}. Exception: {Database.ErrorStateMessage}");
|
||||
#endif
|
||||
SetErrorState($"Failed to drop primary key {indexName} on {tableName} - {Database.ErrorStateMessage}");
|
||||
SaLogger.Error(ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -19,15 +19,23 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
private class DataMembers
|
||||
{
|
||||
public DataMembers(SbmInternals internalsSupplied)
|
||||
{
|
||||
this.InternalsSupplied = internalsSupplied;
|
||||
}
|
||||
public SbmInternals InternalsSupplied { get; }
|
||||
}
|
||||
private DataMembers mbr { get; }
|
||||
private readonly List<TypeCodeDesc> dataItemTypes;
|
||||
private readonly List<TypeCodeDesc> interfaceDataTypes;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmInterfaceConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
protected SbmInterfaceConsole_Dbas(SbmInternals internals) : base(internals.BusMgrDatabase)
|
||||
{
|
||||
UserContext = userContext;
|
||||
mbr = new DataMembers(internals);
|
||||
dataItemTypes = Internals.GetSystemCodes(Sbm.SystemCode.ItemType);
|
||||
interfaceDataTypes = internals.GetSystemCodes(Sbm.SystemCode.InterfaceDataType);
|
||||
}
|
||||
@@ -35,19 +43,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (internals != null) internals.Dispose(); internals = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISbmUserOrganisationContext UserContext { get; }
|
||||
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
|
||||
private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } }
|
||||
protected SbmInternals Internals { get { return mbr.InternalsSupplied; } }
|
||||
protected ISbmUserOrganisationContext UserContext { get { return Internals.UserContext; } }
|
||||
protected SbmSessionContext SessionContext { get { return Internals.SessionContext; } }
|
||||
public override short InterfaceDataType { get { return (short)Sbm.ItemType.Interface; } }
|
||||
// Consoles.
|
||||
private SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } }
|
||||
protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } }
|
||||
public override SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
public override SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
||||
|
||||
@@ -68,13 +75,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
private List<TypeCodeDesc> GetInterfaceTypesForCategory(SaInterfaceCategory interfaceCategory)
|
||||
{
|
||||
if (interfaceCategory == SaInterfaceCategory.Website)
|
||||
return internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_Website);
|
||||
return Internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_Website);
|
||||
if (interfaceCategory == SaInterfaceCategory.Accounts)
|
||||
return internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_Accounts);
|
||||
return Internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_Accounts);
|
||||
if (interfaceCategory == SaInterfaceCategory.System)
|
||||
return internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_System);
|
||||
return Internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_System);
|
||||
if (interfaceCategory == SaInterfaceCategory.File)
|
||||
return internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_File);
|
||||
return Internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_File);
|
||||
return new List<TypeCodeDesc>();
|
||||
}
|
||||
public void RegisterInterfaces(String context)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.UpdateLog;
|
||||
@@ -16,32 +17,38 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
private class DataMembers
|
||||
{
|
||||
public DataMembers(SbmInternals internalsSupplied)
|
||||
{
|
||||
this.InternalsSupplied = internalsSupplied;
|
||||
}
|
||||
public SbmInternals InternalsSupplied { get; }
|
||||
}
|
||||
private DataMembers mbr { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmItemOptionConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
protected SbmItemOptionConsole_Dbas(SbmInternals internals) : base(internals.BusMgrDatabase)
|
||||
{
|
||||
UserContext = userContext;
|
||||
mbr = new DataMembers(internals);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (internals != null) internals.Dispose(); internals = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISbmUserOrganisationContext UserContext { get; set; }
|
||||
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
|
||||
private SbmInternals Internals { get { if (internals == null) { internals = new SbmInternals(UserContext); } return internals; } }
|
||||
public override short ItemOptionDataType { get { return (short)Sbm.ItemType.ItemOption; } }
|
||||
private SbmInternals Internals { get { return mbr.InternalsSupplied; } }
|
||||
private ISbmUserOrganisationContext UserContext { get { return Internals.UserContext; } }
|
||||
private SbmSessionContext SessionContext { get { return Internals.SessionContext; } }
|
||||
private SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
||||
// Consoles.
|
||||
public SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } }
|
||||
private SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } }
|
||||
public override SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.UpdateLog;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using Sarand.Net.Standard.Dbas.ReferenceData;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
@@ -11,29 +13,36 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
private class DataMembers
|
||||
{
|
||||
public DataMembers(SbmInternals internalsSupplied)
|
||||
{
|
||||
this.InternalsSupplied = internalsSupplied;
|
||||
}
|
||||
public SbmInternals InternalsSupplied { get; }
|
||||
}
|
||||
private DataMembers mbr { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmReferenceDataConsole_Dbas(ISbmUserOrganisationContext userContext) :
|
||||
base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
protected SbmReferenceDataConsole_Dbas(SbmInternals internals) :
|
||||
base(internals.BusMgrDatabase)
|
||||
{
|
||||
UserContext = userContext;
|
||||
mbr = new DataMembers(internals);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (internals != null) internals.Dispose(); internals = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISbmUserOrganisationContext UserContext { get; }
|
||||
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
|
||||
private SbmInternals Internals { get { if (internals == null) { internals = new SbmInternals(UserContext); } return internals; } }
|
||||
private SbmInternals Internals { get { return mbr.InternalsSupplied; } }
|
||||
private ISbmUserOrganisationContext UserContext { get { return Internals.UserContext; } }
|
||||
private SbmSessionContext SessionContext { get { return Internals.SessionContext; } }
|
||||
// Item types.
|
||||
public override short LanguageItemType { get { return (short)Sbm.ItemDataType.Unknown; } }
|
||||
public override short RegionItemType { get { return (short)Sbm.ItemDataType.Region; } }
|
||||
|
||||
@@ -20,31 +20,38 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
private List<TypeCodeDesc> securityRights;
|
||||
private class DataMembers
|
||||
{
|
||||
public DataMembers(SbmInternals internalsSupplied)
|
||||
{
|
||||
this.InternalsSupplied = internalsSupplied;
|
||||
}
|
||||
public SbmInternals InternalsSupplied { get; }
|
||||
public List<TypeCodeDesc> SecurityRights { get; set; }
|
||||
}
|
||||
private DataMembers mbr { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmSecurityConsole_Dbas(ISbmUserOrganisationContext userContext) :
|
||||
base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
protected SbmSecurityConsole_Dbas(SbmInternals internals) :
|
||||
base(internals.BusMgrDatabase)
|
||||
{
|
||||
UserContext = userContext;
|
||||
mbr = new DataMembers(internals);
|
||||
RegisterSecurityRights();
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (internals != null) internals.Dispose(); internals = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISbmUserOrganisationContext UserContext { get; }
|
||||
public ISbmUserOrganisationContext UserContext { get { return Internals.UserContext; } }
|
||||
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
|
||||
private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } }
|
||||
private SbmInternals Internals { get { return mbr.InternalsSupplied; } }
|
||||
public override short SecurityItemDataType { get { return (short)Sbm.ItemType.SecurityItem; } }
|
||||
public override short SecurityLinkDataType { get { return (short)Sbm.ItemType.SecurityLink; } }
|
||||
// Consoles.
|
||||
@@ -59,60 +66,60 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
//-------------------------------------------------------------------
|
||||
protected List<TypeCodeDesc> GetSecurityRights()
|
||||
{
|
||||
if (securityRights == null)
|
||||
if (mbr.SecurityRights == null)
|
||||
{
|
||||
securityRights = new List<TypeCodeDesc>();
|
||||
mbr.SecurityRights = new List<TypeCodeDesc>();
|
||||
if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Contacts))
|
||||
{
|
||||
securityRights.Add(Sbm.SecurityRight.Affiliate_Create, "AffIns", "Affiliates - Create");
|
||||
securityRights.Add(Sbm.SecurityRight.Affiliate_Update, "AffUpd", "Affiliates - Update");
|
||||
securityRights.Add(Sbm.SecurityRight.Association_Create, "AssIns", "Associations - Create");
|
||||
securityRights.Add(Sbm.SecurityRight.Association_Update, "AssUpd", "Associations - Update");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Affiliate_Create, "AffIns", "Affiliates - Create");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Affiliate_Update, "AffUpd", "Affiliates - Update");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Association_Create, "AssIns", "Associations - Create");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Association_Update, "AssUpd", "Associations - Update");
|
||||
}
|
||||
if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Commodities))
|
||||
{
|
||||
securityRights.Add(Sbm.SecurityRight.Commodity_Create, "CmdIns", "Commodities - Create");
|
||||
securityRights.Add(Sbm.SecurityRight.Commodity_Update, "CmdUpd", "Commodities - Update");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Commodity_Create, "CmdIns", "Commodities - Create");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Commodity_Update, "CmdUpd", "Commodities - Update");
|
||||
if (SessionConsole.GetStockControlConfig().AllowStockControl())
|
||||
{
|
||||
securityRights.Add(Sbm.SecurityRight.StockTake, "CmdStkTak", "Commodities - Stock Take");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.StockTake, "CmdStkTak", "Commodities - Stock Take");
|
||||
}
|
||||
}
|
||||
if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Assets))
|
||||
{
|
||||
securityRights.Add(Sbm.SecurityRight.Asset_Create, "AssetIns", "Assets - Create");
|
||||
securityRights.Add(Sbm.SecurityRight.Asset_Update, "AssetUpd", "Assets - Update");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Asset_Create, "AssetIns", "Assets - Create");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Asset_Update, "AssetUpd", "Assets - Update");
|
||||
}
|
||||
if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Transactions))
|
||||
{
|
||||
securityRights.Add(Sbm.SecurityRight.Transaction_Create, "TraIns", "Transactions - Create");
|
||||
securityRights.Add(Sbm.SecurityRight.Transaction_Update, "TraUpd", "Transactions - Update");
|
||||
securityRights.Add(Sbm.SecurityRight.Transaction_Remove, "TraRem", "Transactions - Remove");
|
||||
securityRights.Add(Sbm.SecurityRight.Transaction_ByType, "TransType", "Transactions - Allow by type");
|
||||
securityRights.Add(Sbm.SecurityRight.Transaction_UpdateByTypeStatus, "UpdTransTypeStat", "Transactions - Update by type and status");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Transaction_Create, "TraIns", "Transactions - Create");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Transaction_Update, "TraUpd", "Transactions - Update");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Transaction_Remove, "TraRem", "Transactions - Remove");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Transaction_ByType, "TransType", "Transactions - Allow by type");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Transaction_UpdateByTypeStatus, "UpdTransTypeStat", "Transactions - Update by type and status");
|
||||
}
|
||||
securityRights.Add(Sbm.SecurityRight.Security_Admin, "SecAdm", "Admin - Security");
|
||||
securityRights.Add(Sbm.SecurityRight.Database_Admin, "DbAdm", "Admin - Database");
|
||||
securityRights.Add(Sbm.SecurityRight.ReferenceData_Admin, "RefAdm", "Admin - Reference data");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Security_Admin, "SecAdm", "Admin - Security");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Database_Admin, "DbAdm", "Admin - Database");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.ReferenceData_Admin, "RefAdm", "Admin - Reference data");
|
||||
if (SessionConsole != null && SessionConsole.AllowInterfaces())
|
||||
{
|
||||
securityRights.Add(Sbm.SecurityRight.InterfaceConfig, "IntCfg", "Interfaces - Configuration");
|
||||
securityRights.Add(Sbm.SecurityRight.InterfaceByCategory, "IntCategory", "Interfaces - Allow by category");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.InterfaceConfig, "IntCfg", "Interfaces - Configuration");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.InterfaceByCategory, "IntCategory", "Interfaces - Allow by category");
|
||||
}
|
||||
securityRights.Add(Sbm.SecurityRight.Financial_Update, "FinUpd", "Financials - Update");
|
||||
securityRights.Add(Sbm.SecurityRight.Financial_View, "FinLst", "Financials - View");
|
||||
securityRights.Add(Sbm.SecurityRight.Financial_ViewByType, "FinType", "Financials - View by type");
|
||||
securityRights.Add(Sbm.SecurityRight.Financial_UpdateByType, "FinTypeUpd", "Financials - Update by type");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Financial_Update, "FinUpd", "Financials - Update");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Financial_View, "FinLst", "Financials - View");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Financial_ViewByType, "FinType", "Financials - View by type");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.Financial_UpdateByType, "FinTypeUpd", "Financials - Update by type");
|
||||
if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.TimeRecording))
|
||||
{
|
||||
securityRights.Add(Sbm.SecurityRight.TimesheetManager, "TimMgr", "Manage - Timesheets");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.TimesheetManager, "TimMgr", "Manage - Timesheets");
|
||||
}
|
||||
if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Tasks))
|
||||
{
|
||||
securityRights.Add(Sbm.SecurityRight.TaskManager, "TskMgr", "Manage - Tasks");
|
||||
mbr.SecurityRights.Add(Sbm.SecurityRight.TaskManager, "TskMgr", "Manage - Tasks");
|
||||
}
|
||||
}
|
||||
return securityRights;
|
||||
return mbr.SecurityRights;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -122,7 +129,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
// Construct list of transaction types and statuses to use in security rights.
|
||||
List<SysIdString> transactionTypesStatus = new List<SysIdString>();
|
||||
foreach (TypeCodeDesc transactionType in internals.GetSystemCodes(Sbm.SystemCode.TransactionType))
|
||||
foreach (TypeCodeDesc transactionType in Internals.GetSystemCodes(Sbm.SystemCode.TransactionType))
|
||||
{
|
||||
Sbm.TransactionType transType = (Sbm.TransactionType)transactionType.Type;
|
||||
// Only interested in sales quotes and orders for now.
|
||||
@@ -201,7 +208,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
// Transaction types:
|
||||
List<SysIdString> transactionTypesDesc = new List<SysIdString>();
|
||||
List<SysIdString> transactionTypesDescAllowed = new List<SysIdString>();
|
||||
foreach (TypeCodeDesc transactionType in internals.GetSystemCodes(Sbm.SystemCode.TransactionType))
|
||||
foreach (TypeCodeDesc transactionType in Internals.GetSystemCodes(Sbm.SystemCode.TransactionType))
|
||||
{
|
||||
if (SessionConsole.AllowTransactionType((Sbm.TransactionType)transactionType.Type))
|
||||
transactionTypesDescAllowed.Add(new SysId(transactionType.Type), transactionType.Desc);
|
||||
@@ -228,7 +235,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
// Financial types:
|
||||
List<SysIdString> financialTypesDesc = new List<SysIdString>();
|
||||
List<SysIdString> financialTypesDescAllowed = new List<SysIdString>();
|
||||
foreach (TypeCodeDesc financialType in internals.GetSystemCodes(Sbm.SystemCode.FinancialType))
|
||||
foreach (TypeCodeDesc financialType in Internals.GetSystemCodes(Sbm.SystemCode.FinancialType))
|
||||
{
|
||||
financialTypesDescAllowed.Add(new SysId(financialType.Type), financialType.Desc);
|
||||
financialTypesDesc.Add(new SysId(financialType.Type), financialType.Desc);
|
||||
@@ -241,7 +248,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
|
||||
CodeDesc GetSecurityRight(Sbm.SecurityRight securityRight)
|
||||
{
|
||||
return securityRights.GetCodeDescForType(securityRight);
|
||||
return mbr.SecurityRights.GetCodeDescForType(securityRight);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -14,31 +14,38 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
private class DataMembers
|
||||
{
|
||||
public DataMembers(SbmInternals internalsSupplied)
|
||||
{
|
||||
this.InternalsSupplied = internalsSupplied;
|
||||
}
|
||||
public SbmInternals InternalsSupplied { get; }
|
||||
}
|
||||
private DataMembers mbr { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmUpdateLogConsole_Dbas(ISbmUserOrganisationContext userContext) :
|
||||
base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
protected SbmUpdateLogConsole_Dbas(SbmInternals internals) :
|
||||
base(internals.BusMgrDatabase)
|
||||
{
|
||||
UserContext = userContext;
|
||||
mbr = new DataMembers(internals);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (internals != null) internals.Dispose(); internals = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISbmUserOrganisationContext UserContext { get; }
|
||||
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
|
||||
private SbmInternals Internals { get { if (internals == null) { internals = new SbmInternals(UserContext); } return internals; } }
|
||||
protected SbmInternals Internals { get { return mbr.InternalsSupplied; } }
|
||||
protected ISbmUserOrganisationContext UserContext { get { return Internals.UserContext; } }
|
||||
protected SbmSessionContext SessionContext { get { return Internals.SessionContext; } }
|
||||
// Consoles.
|
||||
public SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
||||
protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get name for User Id.
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:19
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
|
||||
{
|
||||
internal class AccountRegistration_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id", true);
|
||||
public ColumnDataString _EmailAddress { get; } = new ColumnDataString("EmailAddress");
|
||||
public ColumnDataString _FirstName { get; } = new ColumnDataString("FirstName");
|
||||
public ColumnDataString _LastName { get; } = new ColumnDataString("LastName");
|
||||
public ColumnDataString _PhoneMain { get; } = new ColumnDataString("PhoneMain");
|
||||
public ColumnDataString _PhoneAlt { get; } = new ColumnDataString("PhoneAlt");
|
||||
public ColumnDataString _InstanceContext { get; } = new ColumnDataString("InstanceContext");
|
||||
public ColumnDataDateTime _RequestAccountAt { get; } = new ColumnDataDateTime("RequestAccountAt");
|
||||
public ColumnDataGuid _RegisterAccountToken { get; } = new ColumnDataGuid("RegisterAccountToken");
|
||||
public ColumnDataDateTimeNullable _RegisterAccountAt { get; } = new ColumnDataDateTimeNullable("RegisterAccountAt");
|
||||
public ColumnDataString _AccountPasswordSalt { get; } = new ColumnDataString("AccountPasswordSalt");
|
||||
public ColumnDataString _AccountPasswordHash { get; } = new ColumnDataString("AccountPasswordHash");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
|
||||
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
|
||||
public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"EmailAddress",
|
||||
"FirstName",
|
||||
"LastName",
|
||||
"PhoneMain",
|
||||
"PhoneAlt",
|
||||
"InstanceContext",
|
||||
"RequestAccountAt",
|
||||
"RegisterAccountToken",
|
||||
"RegisterAccountAt",
|
||||
"AccountPasswordSalt",
|
||||
"AccountPasswordHash",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"PhoneMain",
|
||||
"PhoneAlt",
|
||||
"RegisterAccountAt",
|
||||
"AccountPasswordSalt",
|
||||
"AccountPasswordHash",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal AccountRegistration_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "AccountRegistration";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public String _EmailAddress { get { return Cols._EmailAddress.Value; } set { Cols._EmailAddress.Value = value; } }
|
||||
public String _FirstName { get { return Cols._FirstName.Value; } set { Cols._FirstName.Value = value; } }
|
||||
public String _LastName { get { return Cols._LastName.Value; } set { Cols._LastName.Value = value; } }
|
||||
public String _PhoneMain { get { return Cols._PhoneMain.Value; } set { Cols._PhoneMain.Value = value; } }
|
||||
public String _PhoneAlt { get { return Cols._PhoneAlt.Value; } set { Cols._PhoneAlt.Value = value; } }
|
||||
public String _InstanceContext { get { return Cols._InstanceContext.Value; } set { Cols._InstanceContext.Value = value; } }
|
||||
public DateTime _RequestAccountAt { get { return Cols._RequestAccountAt.Value; } set { Cols._RequestAccountAt.Value = value; } }
|
||||
public Guid _RegisterAccountToken { get { return Cols._RegisterAccountToken.Value; } set { Cols._RegisterAccountToken.Value = value; } }
|
||||
public DateTime? _RegisterAccountAt { get { return Cols._RegisterAccountAt.Value; } set { Cols._RegisterAccountAt.Value = value; } }
|
||||
public String _AccountPasswordSalt { get { return Cols._AccountPasswordSalt.Value; } set { Cols._AccountPasswordSalt.Value = value; } }
|
||||
public String _AccountPasswordHash { get { return Cols._AccountPasswordHash.Value; } set { Cols._AccountPasswordHash.Value = value; } }
|
||||
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
|
||||
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_EmailAddress = GetFieldString(dbDataReader, "EmailAddress", _EmailAddress);
|
||||
_FirstName = GetFieldString(dbDataReader, "FirstName", _FirstName);
|
||||
_LastName = GetFieldString(dbDataReader, "LastName", _LastName);
|
||||
_PhoneMain = GetFieldString(dbDataReader, "PhoneMain", _PhoneMain);
|
||||
_PhoneAlt = GetFieldString(dbDataReader, "PhoneAlt", _PhoneAlt);
|
||||
_InstanceContext = GetFieldString(dbDataReader, "InstanceContext", _InstanceContext);
|
||||
_RequestAccountAt = GetFieldDateTime(dbDataReader, "RequestAccountAt", _RequestAccountAt);
|
||||
_RegisterAccountToken = GetFieldGuid(dbDataReader, "RegisterAccountToken", _RegisterAccountToken);
|
||||
_RegisterAccountAt = GetFieldDateTimeNullable(dbDataReader, "RegisterAccountAt", _RegisterAccountAt);
|
||||
_AccountPasswordSalt = GetFieldString(dbDataReader, "AccountPasswordSalt", _AccountPasswordSalt);
|
||||
_AccountPasswordHash = GetFieldString(dbDataReader, "AccountPasswordHash", _AccountPasswordHash);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert command.
|
||||
public override bool ExecuteInsertCommand (DbCommand dbCommand)
|
||||
{
|
||||
List<String> columnNames = ExistingColumnNamesNonId;
|
||||
// Avoid insert if Identity field is already valid.
|
||||
if (_Id != 0) throw new Exception("Invalid for Insert - item already has a valid Id");
|
||||
// Construct query.
|
||||
String query =
|
||||
"INSERT INTO " + TableNameFmt + " " +
|
||||
"("+columnNames.Concat(",","[","]")+") ";
|
||||
query += "Output Inserted.Id ";
|
||||
if (dbCommand is SqlCommand)
|
||||
query += "VALUES (" + columnNames.Concat(",", "@", "") + ") ";
|
||||
else query += "VALUES (" + StringListUtil.CreateList("?", columnNames.Count).Concat(",") + ") ";
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteInsertCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("EmailAddress")) AddCommandParameter(dbCommand, "@EmailAddress", _EmailAddress);
|
||||
if (columnNames.ContainsCI("FirstName")) AddCommandParameter(dbCommand, "@FirstName", _FirstName);
|
||||
if (columnNames.ContainsCI("LastName")) AddCommandParameter(dbCommand, "@LastName", _LastName);
|
||||
if (columnNames.ContainsCI("PhoneMain")) AddCommandParameter(dbCommand, "@PhoneMain", _PhoneMain);
|
||||
if (columnNames.ContainsCI("PhoneAlt")) AddCommandParameter(dbCommand, "@PhoneAlt", _PhoneAlt);
|
||||
if (columnNames.ContainsCI("InstanceContext")) AddCommandParameter(dbCommand, "@InstanceContext", _InstanceContext);
|
||||
if (columnNames.ContainsCI("RequestAccountAt")) AddCommandParameter(dbCommand, "@RequestAccountAt", _RequestAccountAt);
|
||||
if (columnNames.ContainsCI("RegisterAccountToken")) AddCommandParameter(dbCommand, "@RegisterAccountToken", _RegisterAccountToken);
|
||||
if (columnNames.ContainsCI("RegisterAccountAt")) AddCommandParameter(dbCommand, "@RegisterAccountAt", _RegisterAccountAt);
|
||||
if (columnNames.ContainsCI("AccountPasswordSalt")) AddCommandParameter(dbCommand, "@AccountPasswordSalt", _AccountPasswordSalt);
|
||||
if (columnNames.ContainsCI("AccountPasswordHash")) AddCommandParameter(dbCommand, "@AccountPasswordHash", _AccountPasswordHash);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
dbCommand.CommandText = "SELECT Max(Id) FROM " + TableNameFmt + ";";
|
||||
_Id = (Int32)Convert.ToInt64(dbCommand.ExecuteScalar());
|
||||
commandSuccess = (_Id > 0);
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Avoid update if Identity field isn't valid.
|
||||
if (_Id == 0) throw new Exception("Invalid for Update - item has an invalid Id");
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("EmailAddress")) AddCommandParameter(dbCommand, "@EmailAddress", _EmailAddress);
|
||||
if (columnNames.ContainsCI("FirstName")) AddCommandParameter(dbCommand, "@FirstName", _FirstName);
|
||||
if (columnNames.ContainsCI("LastName")) AddCommandParameter(dbCommand, "@LastName", _LastName);
|
||||
if (columnNames.ContainsCI("PhoneMain")) AddCommandParameter(dbCommand, "@PhoneMain", _PhoneMain);
|
||||
if (columnNames.ContainsCI("PhoneAlt")) AddCommandParameter(dbCommand, "@PhoneAlt", _PhoneAlt);
|
||||
if (columnNames.ContainsCI("InstanceContext")) AddCommandParameter(dbCommand, "@InstanceContext", _InstanceContext);
|
||||
if (columnNames.ContainsCI("RequestAccountAt")) AddCommandParameter(dbCommand, "@RequestAccountAt", _RequestAccountAt);
|
||||
if (columnNames.ContainsCI("RegisterAccountToken")) AddCommandParameter(dbCommand, "@RegisterAccountToken", _RegisterAccountToken);
|
||||
if (columnNames.ContainsCI("RegisterAccountAt")) AddCommandParameter(dbCommand, "@RegisterAccountAt", _RegisterAccountAt);
|
||||
if (columnNames.ContainsCI("AccountPasswordSalt")) AddCommandParameter(dbCommand, "@AccountPasswordSalt", _AccountPasswordSalt);
|
||||
if (columnNames.ContainsCI("AccountPasswordHash")) AddCommandParameter(dbCommand, "@AccountPasswordHash", _AccountPasswordHash);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 4-Dec-2024 12:38:20
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:19
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 4-Dec-2024 12:38:20
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:19
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 4-Dec-2024 12:38:20
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:19
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 4-Dec-2024 12:38:20
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:19
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
|
||||
{
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class Currency_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataString _Code { get; } = new ColumnDataString("Code");
|
||||
public ColumnDataString _Name { get; } = new ColumnDataString("Name");
|
||||
public ColumnDataInt32Nullable _Primary { get; } = new ColumnDataInt32Nullable("Primary");
|
||||
public ColumnDataString _Division { get; } = new ColumnDataString("Division");
|
||||
public ColumnDataInt32Nullable _Region { get; } = new ColumnDataInt32Nullable("Region");
|
||||
public ColumnDataString _Symbol { get; } = new ColumnDataString("Symbol");
|
||||
public ColumnDataBoolean _Suffix { get; } = new ColumnDataBoolean("Suffix");
|
||||
public ColumnDataBoolean _IncSpace { get; } = new ColumnDataBoolean("IncSpace");
|
||||
public ColumnDataInt16Nullable _Decimals { get; } = new ColumnDataInt16Nullable("Decimals");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"Code",
|
||||
"Name",
|
||||
"Primary",
|
||||
"Division",
|
||||
"Region",
|
||||
"Symbol",
|
||||
"Suffix",
|
||||
"IncSpace",
|
||||
"Decimals",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"Code",
|
||||
"Name",
|
||||
"Primary",
|
||||
"Division",
|
||||
"Region",
|
||||
"Symbol",
|
||||
"Decimals",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal Currency_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "Currency";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public String _Code { get { return Cols._Code.Value; } set { Cols._Code.Value = value; } }
|
||||
public String _Name { get { return Cols._Name.Value; } set { Cols._Name.Value = value; } }
|
||||
public Int32? _Primary { get { return Cols._Primary.Value; } set { Cols._Primary.Value = value; } }
|
||||
public String _Division { get { return Cols._Division.Value; } set { Cols._Division.Value = value; } }
|
||||
public Int32? _Region { get { return Cols._Region.Value; } set { Cols._Region.Value = value; } }
|
||||
public String _Symbol { get { return Cols._Symbol.Value; } set { Cols._Symbol.Value = value; } }
|
||||
public Boolean _Suffix { get { return Cols._Suffix.Value; } set { Cols._Suffix.Value = value; } }
|
||||
public Boolean _IncSpace { get { return Cols._IncSpace.Value; } set { Cols._IncSpace.Value = value; } }
|
||||
public Int16? _Decimals { get { return Cols._Decimals.Value; } set { Cols._Decimals.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_Code = GetFieldString(dbDataReader, "Code", _Code);
|
||||
_Name = GetFieldString(dbDataReader, "Name", _Name);
|
||||
_Primary = GetFieldInt32Nullable(dbDataReader, "Primary", _Primary);
|
||||
_Division = GetFieldString(dbDataReader, "Division", _Division);
|
||||
_Region = GetFieldInt32Nullable(dbDataReader, "Region", _Region);
|
||||
_Symbol = GetFieldString(dbDataReader, "Symbol", _Symbol);
|
||||
_Suffix = GetFieldBoolean(dbDataReader, "Suffix", _Suffix);
|
||||
_IncSpace = GetFieldBoolean(dbDataReader, "IncSpace", _IncSpace);
|
||||
_Decimals = GetFieldInt16Nullable(dbDataReader, "Decimals", _Decimals);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("Name")) AddCommandParameter(dbCommand, "@Name", _Name);
|
||||
if (columnNames.ContainsCI("Primary")) AddCommandParameter(dbCommand, "@Primary", _Primary);
|
||||
if (columnNames.ContainsCI("Division")) AddCommandParameter(dbCommand, "@Division", _Division);
|
||||
if (columnNames.ContainsCI("Region")) AddCommandParameter(dbCommand, "@Region", _Region);
|
||||
if (columnNames.ContainsCI("Symbol")) AddCommandParameter(dbCommand, "@Symbol", _Symbol);
|
||||
if (columnNames.ContainsCI("Suffix")) AddCommandParameter(dbCommand, "@Suffix", _Suffix);
|
||||
if (columnNames.ContainsCI("IncSpace")) AddCommandParameter(dbCommand, "@IncSpace", _IncSpace);
|
||||
if (columnNames.ContainsCI("Decimals")) AddCommandParameter(dbCommand, "@Decimals", _Decimals);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("Name")) AddCommandParameter(dbCommand, "@Name", _Name);
|
||||
if (columnNames.ContainsCI("Primary")) AddCommandParameter(dbCommand, "@Primary", _Primary);
|
||||
if (columnNames.ContainsCI("Division")) AddCommandParameter(dbCommand, "@Division", _Division);
|
||||
if (columnNames.ContainsCI("Region")) AddCommandParameter(dbCommand, "@Region", _Region);
|
||||
if (columnNames.ContainsCI("Symbol")) AddCommandParameter(dbCommand, "@Symbol", _Symbol);
|
||||
if (columnNames.ContainsCI("Suffix")) AddCommandParameter(dbCommand, "@Suffix", _Suffix);
|
||||
if (columnNames.ContainsCI("IncSpace")) AddCommandParameter(dbCommand, "@IncSpace", _IncSpace);
|
||||
if (columnNames.ContainsCI("Decimals")) AddCommandParameter(dbCommand, "@Decimals", _Decimals);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class IndexDefragLog_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _IndexDefragId { get; } = new ColumnDataInt32("IndexDefragId", true);
|
||||
public ColumnDataInt32 _DatabaseID { get; } = new ColumnDataInt32("DatabaseID");
|
||||
public ColumnDataString _DatabaseName { get; } = new ColumnDataString("DatabaseName");
|
||||
public ColumnDataInt32 _ObjectID { get; } = new ColumnDataInt32("ObjectID");
|
||||
public ColumnDataString _ObjectName { get; } = new ColumnDataString("ObjectName");
|
||||
public ColumnDataInt32 _IndexID { get; } = new ColumnDataInt32("IndexID");
|
||||
public ColumnDataString _IndexName { get; } = new ColumnDataString("IndexName");
|
||||
public ColumnDataInt16 _PartitionNumber { get; } = new ColumnDataInt16("PartitionNumber");
|
||||
public ColumnDataDecimal _Fragmentation { get; } = new ColumnDataDecimal("Fragmentation");
|
||||
public ColumnDataInt32 _PageCount { get; } = new ColumnDataInt32("PageCount");
|
||||
public ColumnDataDateTime _DateTimeStart { get; } = new ColumnDataDateTime("DateTimeStart");
|
||||
public ColumnDataInt32 _DurationSeconds { get; } = new ColumnDataInt32("DurationSeconds");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"IndexDefragId",
|
||||
"DatabaseID",
|
||||
"DatabaseName",
|
||||
"ObjectID",
|
||||
"ObjectName",
|
||||
"IndexID",
|
||||
"IndexName",
|
||||
"PartitionNumber",
|
||||
"Fragmentation",
|
||||
"PageCount",
|
||||
"DateTimeStart",
|
||||
"DurationSeconds",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
"IndexDefragId",
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"IndexDefragId",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal IndexDefragLog_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "IndexDefragLog";
|
||||
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 _IndexDefragId { get { return Cols._IndexDefragId.Value; } set { Cols._IndexDefragId.Value = value; } }
|
||||
public Int32 _DatabaseID { get { return Cols._DatabaseID.Value; } set { Cols._DatabaseID.Value = value; } }
|
||||
public String _DatabaseName { get { return Cols._DatabaseName.Value; } set { Cols._DatabaseName.Value = value; } }
|
||||
public Int32 _ObjectID { get { return Cols._ObjectID.Value; } set { Cols._ObjectID.Value = value; } }
|
||||
public String _ObjectName { get { return Cols._ObjectName.Value; } set { Cols._ObjectName.Value = value; } }
|
||||
public Int32 _IndexID { get { return Cols._IndexID.Value; } set { Cols._IndexID.Value = value; } }
|
||||
public String _IndexName { get { return Cols._IndexName.Value; } set { Cols._IndexName.Value = value; } }
|
||||
public Int16 _PartitionNumber { get { return Cols._PartitionNumber.Value; } set { Cols._PartitionNumber.Value = value; } }
|
||||
public Decimal _Fragmentation { get { return Cols._Fragmentation.Value; } set { Cols._Fragmentation.Value = value; } }
|
||||
public Int32 _PageCount { get { return Cols._PageCount.Value; } set { Cols._PageCount.Value = value; } }
|
||||
public DateTime _DateTimeStart { get { return Cols._DateTimeStart.Value; } set { Cols._DateTimeStart.Value = value; } }
|
||||
public Int32 _DurationSeconds { get { return Cols._DurationSeconds.Value; } set { Cols._DurationSeconds.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); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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)
|
||||
{
|
||||
_IndexDefragId = GetFieldInt32(dbDataReader, "IndexDefragId", _IndexDefragId);
|
||||
_DatabaseID = GetFieldInt32(dbDataReader, "DatabaseID", _DatabaseID);
|
||||
_DatabaseName = GetFieldString(dbDataReader, "DatabaseName", _DatabaseName);
|
||||
_ObjectID = GetFieldInt32(dbDataReader, "ObjectID", _ObjectID);
|
||||
_ObjectName = GetFieldString(dbDataReader, "ObjectName", _ObjectName);
|
||||
_IndexID = GetFieldInt32(dbDataReader, "IndexID", _IndexID);
|
||||
_IndexName = GetFieldString(dbDataReader, "IndexName", _IndexName);
|
||||
_PartitionNumber = GetFieldInt16(dbDataReader, "PartitionNumber", _PartitionNumber);
|
||||
_Fragmentation = GetFieldDecimal(dbDataReader, "Fragmentation", _Fragmentation);
|
||||
_PageCount = GetFieldInt32(dbDataReader, "PageCount", _PageCount);
|
||||
_DateTimeStart = GetFieldDateTime(dbDataReader, "DateTimeStart", _DateTimeStart);
|
||||
_DurationSeconds = GetFieldInt32(dbDataReader, "DurationSeconds", _DurationSeconds);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert command.
|
||||
public override bool ExecuteInsertCommand (DbCommand dbCommand)
|
||||
{
|
||||
List<String> columnNames = ExistingColumnNamesNonId;
|
||||
// Avoid insert if Identity field is already valid.
|
||||
if (_IndexDefragId != 0) throw new Exception("Invalid for Insert - item already has a valid Id");
|
||||
// Construct query.
|
||||
String query =
|
||||
"INSERT INTO " + TableNameFmt + " " +
|
||||
"("+columnNames.Concat(",","[","]")+") ";
|
||||
query += "Output Inserted.IndexDefragId ";
|
||||
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("DatabaseID")) AddCommandParameter(dbCommand, "@DatabaseID", _DatabaseID);
|
||||
if (columnNames.ContainsCI("DatabaseName")) AddCommandParameter(dbCommand, "@DatabaseName", _DatabaseName);
|
||||
if (columnNames.ContainsCI("ObjectID")) AddCommandParameter(dbCommand, "@ObjectID", _ObjectID);
|
||||
if (columnNames.ContainsCI("ObjectName")) AddCommandParameter(dbCommand, "@ObjectName", _ObjectName);
|
||||
if (columnNames.ContainsCI("IndexID")) AddCommandParameter(dbCommand, "@IndexID", _IndexID);
|
||||
if (columnNames.ContainsCI("IndexName")) AddCommandParameter(dbCommand, "@IndexName", _IndexName);
|
||||
if (columnNames.ContainsCI("PartitionNumber")) AddCommandParameter(dbCommand, "@PartitionNumber", _PartitionNumber);
|
||||
if (columnNames.ContainsCI("Fragmentation")) AddCommandParameter(dbCommand, "@Fragmentation", _Fragmentation);
|
||||
if (columnNames.ContainsCI("PageCount")) AddCommandParameter(dbCommand, "@PageCount", _PageCount);
|
||||
if (columnNames.ContainsCI("DateTimeStart")) AddCommandParameter(dbCommand, "@DateTimeStart", _DateTimeStart);
|
||||
if (columnNames.ContainsCI("DurationSeconds")) AddCommandParameter(dbCommand, "@DurationSeconds", _DurationSeconds);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
dbCommand.CommandText = "SELECT Max(IndexDefragId) FROM " + TableNameFmt + ";";
|
||||
_IndexDefragId = (Int32)Convert.ToInt64(dbCommand.ExecuteScalar());
|
||||
commandSuccess = (_IndexDefragId > 0);
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Avoid update if Identity field isn't valid.
|
||||
if (_IndexDefragId == 0) throw new Exception("Invalid for Update - item has an invalid Id");
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE IndexDefragId=@IndexDefragId;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE IndexDefragId=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("DatabaseID")) AddCommandParameter(dbCommand, "@DatabaseID", _DatabaseID);
|
||||
if (columnNames.ContainsCI("DatabaseName")) AddCommandParameter(dbCommand, "@DatabaseName", _DatabaseName);
|
||||
if (columnNames.ContainsCI("ObjectID")) AddCommandParameter(dbCommand, "@ObjectID", _ObjectID);
|
||||
if (columnNames.ContainsCI("ObjectName")) AddCommandParameter(dbCommand, "@ObjectName", _ObjectName);
|
||||
if (columnNames.ContainsCI("IndexID")) AddCommandParameter(dbCommand, "@IndexID", _IndexID);
|
||||
if (columnNames.ContainsCI("IndexName")) AddCommandParameter(dbCommand, "@IndexName", _IndexName);
|
||||
if (columnNames.ContainsCI("PartitionNumber")) AddCommandParameter(dbCommand, "@PartitionNumber", _PartitionNumber);
|
||||
if (columnNames.ContainsCI("Fragmentation")) AddCommandParameter(dbCommand, "@Fragmentation", _Fragmentation);
|
||||
if (columnNames.ContainsCI("PageCount")) AddCommandParameter(dbCommand, "@PageCount", _PageCount);
|
||||
if (columnNames.ContainsCI("DateTimeStart")) AddCommandParameter(dbCommand, "@DateTimeStart", _DateTimeStart);
|
||||
if (columnNames.ContainsCI("DurationSeconds")) AddCommandParameter(dbCommand, "@DurationSeconds", _DurationSeconds);
|
||||
AddCommandParameter(dbCommand, "@IndexDefragId", _IndexDefragId);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class InterfaceDataItem_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataInt32 _InterfaceId { get; } = new ColumnDataInt32("InterfaceId");
|
||||
public ColumnDataInt16 _Direction { get; } = new ColumnDataInt16("Direction");
|
||||
public ColumnDataString _ExternalRef { get; } = new ColumnDataString("ExternalRef");
|
||||
public ColumnDataInt16 _ItemType { get; } = new ColumnDataInt16("ItemType");
|
||||
public ColumnDataInt32 _ItemId { get; } = new ColumnDataInt32("ItemId");
|
||||
public ColumnDataString _ProcessStatus { get; } = new ColumnDataString("ProcessStatus");
|
||||
public ColumnDataInt32Nullable _ProcessStatusBy { get; } = new ColumnDataInt32Nullable("ProcessStatusBy");
|
||||
public ColumnDataInt32Nullable _ProcessStatusOn { get; } = new ColumnDataInt32Nullable("ProcessStatusOn");
|
||||
public ColumnDataString _ItemStatus { get; } = new ColumnDataString("ItemStatus");
|
||||
public ColumnDataInt32Nullable _ItemStatusBy { get; } = new ColumnDataInt32Nullable("ItemStatusBy");
|
||||
public ColumnDataInt32Nullable _ItemStatusOn { get; } = new ColumnDataInt32Nullable("ItemStatusOn");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"InterfaceId",
|
||||
"Direction",
|
||||
"ExternalRef",
|
||||
"ItemType",
|
||||
"ItemId",
|
||||
"ProcessStatus",
|
||||
"ProcessStatusBy",
|
||||
"ProcessStatusOn",
|
||||
"ItemStatus",
|
||||
"ItemStatusBy",
|
||||
"ItemStatusOn",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"ExternalRef",
|
||||
"ProcessStatus",
|
||||
"ProcessStatusBy",
|
||||
"ProcessStatusOn",
|
||||
"ItemStatus",
|
||||
"ItemStatusBy",
|
||||
"ItemStatusOn",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal InterfaceDataItem_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "InterfaceDataItem";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public Int32 _InterfaceId { get { return Cols._InterfaceId.Value; } set { Cols._InterfaceId.Value = value; } }
|
||||
public Int16 _Direction { get { return Cols._Direction.Value; } set { Cols._Direction.Value = value; } }
|
||||
public String _ExternalRef { get { return Cols._ExternalRef.Value; } set { Cols._ExternalRef.Value = value; } }
|
||||
public Int16 _ItemType { get { return Cols._ItemType.Value; } set { Cols._ItemType.Value = value; } }
|
||||
public Int32 _ItemId { get { return Cols._ItemId.Value; } set { Cols._ItemId.Value = value; } }
|
||||
public String _ProcessStatus { get { return Cols._ProcessStatus.Value; } set { Cols._ProcessStatus.Value = value; } }
|
||||
public Int32? _ProcessStatusBy { get { return Cols._ProcessStatusBy.Value; } set { Cols._ProcessStatusBy.Value = value; } }
|
||||
public Int32? _ProcessStatusOn { get { return Cols._ProcessStatusOn.Value; } set { Cols._ProcessStatusOn.Value = value; } }
|
||||
public String _ItemStatus { get { return Cols._ItemStatus.Value; } set { Cols._ItemStatus.Value = value; } }
|
||||
public Int32? _ItemStatusBy { get { return Cols._ItemStatusBy.Value; } set { Cols._ItemStatusBy.Value = value; } }
|
||||
public Int32? _ItemStatusOn { get { return Cols._ItemStatusOn.Value; } set { Cols._ItemStatusOn.Value = value; } }
|
||||
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_InterfaceId = GetFieldInt32(dbDataReader, "InterfaceId", _InterfaceId);
|
||||
_Direction = GetFieldInt16(dbDataReader, "Direction", _Direction);
|
||||
_ExternalRef = GetFieldString(dbDataReader, "ExternalRef", _ExternalRef);
|
||||
_ItemType = GetFieldInt16(dbDataReader, "ItemType", _ItemType);
|
||||
_ItemId = GetFieldInt32(dbDataReader, "ItemId", _ItemId);
|
||||
_ProcessStatus = GetFieldString(dbDataReader, "ProcessStatus", _ProcessStatus);
|
||||
_ProcessStatusBy = GetFieldInt32Nullable(dbDataReader, "ProcessStatusBy", _ProcessStatusBy);
|
||||
_ProcessStatusOn = GetFieldInt32Nullable(dbDataReader, "ProcessStatusOn", _ProcessStatusOn);
|
||||
_ItemStatus = GetFieldString(dbDataReader, "ItemStatus", _ItemStatus);
|
||||
_ItemStatusBy = GetFieldInt32Nullable(dbDataReader, "ItemStatusBy", _ItemStatusBy);
|
||||
_ItemStatusOn = GetFieldInt32Nullable(dbDataReader, "ItemStatusOn", _ItemStatusOn);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("InterfaceId")) AddCommandParameter(dbCommand, "@InterfaceId", _InterfaceId);
|
||||
if (columnNames.ContainsCI("Direction")) AddCommandParameter(dbCommand, "@Direction", _Direction);
|
||||
if (columnNames.ContainsCI("ExternalRef")) AddCommandParameter(dbCommand, "@ExternalRef", _ExternalRef);
|
||||
if (columnNames.ContainsCI("ItemType")) AddCommandParameter(dbCommand, "@ItemType", _ItemType);
|
||||
if (columnNames.ContainsCI("ItemId")) AddCommandParameter(dbCommand, "@ItemId", _ItemId);
|
||||
if (columnNames.ContainsCI("ProcessStatus")) AddCommandParameter(dbCommand, "@ProcessStatus", _ProcessStatus);
|
||||
if (columnNames.ContainsCI("ProcessStatusBy")) AddCommandParameter(dbCommand, "@ProcessStatusBy", _ProcessStatusBy);
|
||||
if (columnNames.ContainsCI("ProcessStatusOn")) AddCommandParameter(dbCommand, "@ProcessStatusOn", _ProcessStatusOn);
|
||||
if (columnNames.ContainsCI("ItemStatus")) AddCommandParameter(dbCommand, "@ItemStatus", _ItemStatus);
|
||||
if (columnNames.ContainsCI("ItemStatusBy")) AddCommandParameter(dbCommand, "@ItemStatusBy", _ItemStatusBy);
|
||||
if (columnNames.ContainsCI("ItemStatusOn")) AddCommandParameter(dbCommand, "@ItemStatusOn", _ItemStatusOn);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("InterfaceId")) AddCommandParameter(dbCommand, "@InterfaceId", _InterfaceId);
|
||||
if (columnNames.ContainsCI("Direction")) AddCommandParameter(dbCommand, "@Direction", _Direction);
|
||||
if (columnNames.ContainsCI("ExternalRef")) AddCommandParameter(dbCommand, "@ExternalRef", _ExternalRef);
|
||||
if (columnNames.ContainsCI("ItemType")) AddCommandParameter(dbCommand, "@ItemType", _ItemType);
|
||||
if (columnNames.ContainsCI("ItemId")) AddCommandParameter(dbCommand, "@ItemId", _ItemId);
|
||||
if (columnNames.ContainsCI("ProcessStatus")) AddCommandParameter(dbCommand, "@ProcessStatus", _ProcessStatus);
|
||||
if (columnNames.ContainsCI("ProcessStatusBy")) AddCommandParameter(dbCommand, "@ProcessStatusBy", _ProcessStatusBy);
|
||||
if (columnNames.ContainsCI("ProcessStatusOn")) AddCommandParameter(dbCommand, "@ProcessStatusOn", _ProcessStatusOn);
|
||||
if (columnNames.ContainsCI("ItemStatus")) AddCommandParameter(dbCommand, "@ItemStatus", _ItemStatus);
|
||||
if (columnNames.ContainsCI("ItemStatusBy")) AddCommandParameter(dbCommand, "@ItemStatusBy", _ItemStatusBy);
|
||||
if (columnNames.ContainsCI("ItemStatusOn")) AddCommandParameter(dbCommand, "@ItemStatusOn", _ItemStatusOn);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class InterfaceProcessDataItem_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _ProcessId { get; } = new ColumnDataInt32("ProcessId");
|
||||
public ColumnDataInt32 _InterfaceDataItemId { get; } = new ColumnDataInt32("InterfaceDataItemId");
|
||||
public ColumnDataString _ItemData { get; } = new ColumnDataString("ItemData");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"ProcessId",
|
||||
"InterfaceDataItemId",
|
||||
"ItemData",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"ProcessId",
|
||||
"InterfaceDataItemId",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"ItemData",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal InterfaceProcessDataItem_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "InterfaceProcessDataItem";
|
||||
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 _ProcessId { get { return Cols._ProcessId.Value; } set { Cols._ProcessId.Value = value; } }
|
||||
public Int32 _InterfaceDataItemId { get { return Cols._InterfaceDataItemId.Value; } set { Cols._InterfaceDataItemId.Value = value; } }
|
||||
public String _ItemData { get { return Cols._ItemData.Value; } set { Cols._ItemData.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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)
|
||||
{
|
||||
_ProcessId = GetFieldInt32(dbDataReader, "ProcessId", _ProcessId);
|
||||
_InterfaceDataItemId = GetFieldInt32(dbDataReader, "InterfaceDataItemId", _InterfaceDataItemId);
|
||||
_ItemData = GetFieldString(dbDataReader, "ItemData", _ItemData);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("ProcessId")) AddCommandParameter(dbCommand, "@ProcessId", _ProcessId);
|
||||
if (columnNames.ContainsCI("InterfaceDataItemId")) AddCommandParameter(dbCommand, "@InterfaceDataItemId", _InterfaceDataItemId);
|
||||
if (columnNames.ContainsCI("ItemData")) AddCommandParameter(dbCommand, "@ItemData", _ItemData);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE ProcessId=@ProcessId AND InterfaceDataItemId=@InterfaceDataItemId;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE ProcessId=? AND InterfaceDataItemId=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("ItemData")) AddCommandParameter(dbCommand, "@ItemData", _ItemData);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@ProcessId", _ProcessId);
|
||||
AddCommandParameter(dbCommand, "@InterfaceDataItemId", _InterfaceDataItemId);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class InterfaceProcessMessage_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataInt32 _ProcessId { get; } = new ColumnDataInt32("ProcessId");
|
||||
public ColumnDataString _MsgType { get; } = new ColumnDataString("MsgType");
|
||||
public ColumnDataString _Msg { get; } = new ColumnDataString("Msg");
|
||||
public ColumnDataString _FileName { get; } = new ColumnDataString("FileName");
|
||||
public ColumnDataInt32Nullable _LineNumber { get; } = new ColumnDataInt32Nullable("LineNumber");
|
||||
public ColumnDataInt16Nullable _ItemType { get; } = new ColumnDataInt16Nullable("ItemType");
|
||||
public ColumnDataInt32Nullable _ItemId { get; } = new ColumnDataInt32Nullable("ItemId");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"ProcessId",
|
||||
"MsgType",
|
||||
"Msg",
|
||||
"FileName",
|
||||
"LineNumber",
|
||||
"ItemType",
|
||||
"ItemId",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"MsgType",
|
||||
"Msg",
|
||||
"FileName",
|
||||
"LineNumber",
|
||||
"ItemType",
|
||||
"ItemId",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal InterfaceProcessMessage_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "InterfaceProcessMessage";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public Int32 _ProcessId { get { return Cols._ProcessId.Value; } set { Cols._ProcessId.Value = value; } }
|
||||
public String _MsgType { get { return Cols._MsgType.Value; } set { Cols._MsgType.Value = value; } }
|
||||
public String _Msg { get { return Cols._Msg.Value; } set { Cols._Msg.Value = value; } }
|
||||
public String _FileName { get { return Cols._FileName.Value; } set { Cols._FileName.Value = value; } }
|
||||
public Int32? _LineNumber { get { return Cols._LineNumber.Value; } set { Cols._LineNumber.Value = value; } }
|
||||
public Int16? _ItemType { get { return Cols._ItemType.Value; } set { Cols._ItemType.Value = value; } }
|
||||
public Int32? _ItemId { get { return Cols._ItemId.Value; } set { Cols._ItemId.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_ProcessId = GetFieldInt32(dbDataReader, "ProcessId", _ProcessId);
|
||||
_MsgType = GetFieldString(dbDataReader, "MsgType", _MsgType);
|
||||
_Msg = GetFieldString(dbDataReader, "Msg", _Msg);
|
||||
_FileName = GetFieldString(dbDataReader, "FileName", _FileName);
|
||||
_LineNumber = GetFieldInt32Nullable(dbDataReader, "LineNumber", _LineNumber);
|
||||
_ItemType = GetFieldInt16Nullable(dbDataReader, "ItemType", _ItemType);
|
||||
_ItemId = GetFieldInt32Nullable(dbDataReader, "ItemId", _ItemId);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("ProcessId")) AddCommandParameter(dbCommand, "@ProcessId", _ProcessId);
|
||||
if (columnNames.ContainsCI("MsgType")) AddCommandParameter(dbCommand, "@MsgType", _MsgType);
|
||||
if (columnNames.ContainsCI("Msg")) AddCommandParameter(dbCommand, "@Msg", _Msg);
|
||||
if (columnNames.ContainsCI("FileName")) AddCommandParameter(dbCommand, "@FileName", _FileName);
|
||||
if (columnNames.ContainsCI("LineNumber")) AddCommandParameter(dbCommand, "@LineNumber", _LineNumber);
|
||||
if (columnNames.ContainsCI("ItemType")) AddCommandParameter(dbCommand, "@ItemType", _ItemType);
|
||||
if (columnNames.ContainsCI("ItemId")) AddCommandParameter(dbCommand, "@ItemId", _ItemId);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("ProcessId")) AddCommandParameter(dbCommand, "@ProcessId", _ProcessId);
|
||||
if (columnNames.ContainsCI("MsgType")) AddCommandParameter(dbCommand, "@MsgType", _MsgType);
|
||||
if (columnNames.ContainsCI("Msg")) AddCommandParameter(dbCommand, "@Msg", _Msg);
|
||||
if (columnNames.ContainsCI("FileName")) AddCommandParameter(dbCommand, "@FileName", _FileName);
|
||||
if (columnNames.ContainsCI("LineNumber")) AddCommandParameter(dbCommand, "@LineNumber", _LineNumber);
|
||||
if (columnNames.ContainsCI("ItemType")) AddCommandParameter(dbCommand, "@ItemType", _ItemType);
|
||||
if (columnNames.ContainsCI("ItemId")) AddCommandParameter(dbCommand, "@ItemId", _ItemId);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -1,273 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class InterfaceProcess_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataInt32 _InterfaceId { get; } = new ColumnDataInt32("InterfaceId");
|
||||
public ColumnDataInt16 _Direction { get; } = new ColumnDataInt16("Direction");
|
||||
public ColumnDataString _ProcRef { get; } = new ColumnDataString("ProcRef");
|
||||
public ColumnDataInt32Nullable _ProcSeq { get; } = new ColumnDataInt32Nullable("ProcSeq");
|
||||
public ColumnDataInt32Nullable _ProcDate { get; } = new ColumnDataInt32Nullable("ProcDate");
|
||||
public ColumnDataInt32Nullable _ProcTime { get; } = new ColumnDataInt32Nullable("ProcTime");
|
||||
public ColumnDataInt32Nullable _BatchDate { get; } = new ColumnDataInt32Nullable("BatchDate");
|
||||
public ColumnDataInt32Nullable _BatchTime { get; } = new ColumnDataInt32Nullable("BatchTime");
|
||||
public ColumnDataInt32Nullable _ElapseSecs { get; } = new ColumnDataInt32Nullable("ElapseSecs");
|
||||
public ColumnDataInt32Nullable _ItemCount { get; } = new ColumnDataInt32Nullable("ItemCount");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"InterfaceId",
|
||||
"Direction",
|
||||
"ProcRef",
|
||||
"ProcSeq",
|
||||
"ProcDate",
|
||||
"ProcTime",
|
||||
"BatchDate",
|
||||
"BatchTime",
|
||||
"ElapseSecs",
|
||||
"ItemCount",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"ProcRef",
|
||||
"ProcSeq",
|
||||
"ProcDate",
|
||||
"ProcTime",
|
||||
"BatchDate",
|
||||
"BatchTime",
|
||||
"ElapseSecs",
|
||||
"ItemCount",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal InterfaceProcess_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "InterfaceProcess";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public Int32 _InterfaceId { get { return Cols._InterfaceId.Value; } set { Cols._InterfaceId.Value = value; } }
|
||||
public Int16 _Direction { get { return Cols._Direction.Value; } set { Cols._Direction.Value = value; } }
|
||||
public String _ProcRef { get { return Cols._ProcRef.Value; } set { Cols._ProcRef.Value = value; } }
|
||||
public Int32? _ProcSeq { get { return Cols._ProcSeq.Value; } set { Cols._ProcSeq.Value = value; } }
|
||||
public Int32? _ProcDate { get { return Cols._ProcDate.Value; } set { Cols._ProcDate.Value = value; } }
|
||||
public Int32? _ProcTime { get { return Cols._ProcTime.Value; } set { Cols._ProcTime.Value = value; } }
|
||||
public Int32? _BatchDate { get { return Cols._BatchDate.Value; } set { Cols._BatchDate.Value = value; } }
|
||||
public Int32? _BatchTime { get { return Cols._BatchTime.Value; } set { Cols._BatchTime.Value = value; } }
|
||||
public Int32? _ElapseSecs { get { return Cols._ElapseSecs.Value; } set { Cols._ElapseSecs.Value = value; } }
|
||||
public Int32? _ItemCount { get { return Cols._ItemCount.Value; } set { Cols._ItemCount.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_InterfaceId = GetFieldInt32(dbDataReader, "InterfaceId", _InterfaceId);
|
||||
_Direction = GetFieldInt16(dbDataReader, "Direction", _Direction);
|
||||
_ProcRef = GetFieldString(dbDataReader, "ProcRef", _ProcRef);
|
||||
_ProcSeq = GetFieldInt32Nullable(dbDataReader, "ProcSeq", _ProcSeq);
|
||||
_ProcDate = GetFieldInt32Nullable(dbDataReader, "ProcDate", _ProcDate);
|
||||
_ProcTime = GetFieldInt32Nullable(dbDataReader, "ProcTime", _ProcTime);
|
||||
_BatchDate = GetFieldInt32Nullable(dbDataReader, "BatchDate", _BatchDate);
|
||||
_BatchTime = GetFieldInt32Nullable(dbDataReader, "BatchTime", _BatchTime);
|
||||
_ElapseSecs = GetFieldInt32Nullable(dbDataReader, "ElapseSecs", _ElapseSecs);
|
||||
_ItemCount = GetFieldInt32Nullable(dbDataReader, "ItemCount", _ItemCount);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("InterfaceId")) AddCommandParameter(dbCommand, "@InterfaceId", _InterfaceId);
|
||||
if (columnNames.ContainsCI("Direction")) AddCommandParameter(dbCommand, "@Direction", _Direction);
|
||||
if (columnNames.ContainsCI("ProcRef")) AddCommandParameter(dbCommand, "@ProcRef", _ProcRef);
|
||||
if (columnNames.ContainsCI("ProcSeq")) AddCommandParameter(dbCommand, "@ProcSeq", _ProcSeq);
|
||||
if (columnNames.ContainsCI("ProcDate")) AddCommandParameter(dbCommand, "@ProcDate", _ProcDate);
|
||||
if (columnNames.ContainsCI("ProcTime")) AddCommandParameter(dbCommand, "@ProcTime", _ProcTime);
|
||||
if (columnNames.ContainsCI("BatchDate")) AddCommandParameter(dbCommand, "@BatchDate", _BatchDate);
|
||||
if (columnNames.ContainsCI("BatchTime")) AddCommandParameter(dbCommand, "@BatchTime", _BatchTime);
|
||||
if (columnNames.ContainsCI("ElapseSecs")) AddCommandParameter(dbCommand, "@ElapseSecs", _ElapseSecs);
|
||||
if (columnNames.ContainsCI("ItemCount")) AddCommandParameter(dbCommand, "@ItemCount", _ItemCount);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("InterfaceId")) AddCommandParameter(dbCommand, "@InterfaceId", _InterfaceId);
|
||||
if (columnNames.ContainsCI("Direction")) AddCommandParameter(dbCommand, "@Direction", _Direction);
|
||||
if (columnNames.ContainsCI("ProcRef")) AddCommandParameter(dbCommand, "@ProcRef", _ProcRef);
|
||||
if (columnNames.ContainsCI("ProcSeq")) AddCommandParameter(dbCommand, "@ProcSeq", _ProcSeq);
|
||||
if (columnNames.ContainsCI("ProcDate")) AddCommandParameter(dbCommand, "@ProcDate", _ProcDate);
|
||||
if (columnNames.ContainsCI("ProcTime")) AddCommandParameter(dbCommand, "@ProcTime", _ProcTime);
|
||||
if (columnNames.ContainsCI("BatchDate")) AddCommandParameter(dbCommand, "@BatchDate", _BatchDate);
|
||||
if (columnNames.ContainsCI("BatchTime")) AddCommandParameter(dbCommand, "@BatchTime", _BatchTime);
|
||||
if (columnNames.ContainsCI("ElapseSecs")) AddCommandParameter(dbCommand, "@ElapseSecs", _ElapseSecs);
|
||||
if (columnNames.ContainsCI("ItemCount")) AddCommandParameter(dbCommand, "@ItemCount", _ItemCount);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class Interface_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataString _Context { get; } = new ColumnDataString("Context");
|
||||
public ColumnDataString _Code { get; } = new ColumnDataString("Code");
|
||||
public ColumnDataInt16Nullable _Category { get; } = new ColumnDataInt16Nullable("Category");
|
||||
public ColumnDataInt16Nullable _Type { get; } = new ColumnDataInt16Nullable("Type");
|
||||
public ColumnDataString _Caption { get; } = new ColumnDataString("Caption");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"Context",
|
||||
"Code",
|
||||
"Category",
|
||||
"Type",
|
||||
"Caption",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"Context",
|
||||
"Category",
|
||||
"Type",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal Interface_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "Interface";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public String _Context { get { return Cols._Context.Value; } set { Cols._Context.Value = value; } }
|
||||
public String _Code { get { return Cols._Code.Value; } set { Cols._Code.Value = value; } }
|
||||
public Int16? _Category { get { return Cols._Category.Value; } set { Cols._Category.Value = value; } }
|
||||
public Int16? _Type { get { return Cols._Type.Value; } set { Cols._Type.Value = value; } }
|
||||
public String _Caption { get { return Cols._Caption.Value; } set { Cols._Caption.Value = value; } }
|
||||
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_Context = GetFieldString(dbDataReader, "Context", _Context);
|
||||
_Code = GetFieldString(dbDataReader, "Code", _Code);
|
||||
_Category = GetFieldInt16Nullable(dbDataReader, "Category", _Category);
|
||||
_Type = GetFieldInt16Nullable(dbDataReader, "Type", _Type);
|
||||
_Caption = GetFieldString(dbDataReader, "Caption", _Caption);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("Context")) AddCommandParameter(dbCommand, "@Context", _Context);
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("Category")) AddCommandParameter(dbCommand, "@Category", _Category);
|
||||
if (columnNames.ContainsCI("Type")) AddCommandParameter(dbCommand, "@Type", _Type);
|
||||
if (columnNames.ContainsCI("Caption")) AddCommandParameter(dbCommand, "@Caption", _Caption);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("Context")) AddCommandParameter(dbCommand, "@Context", _Context);
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("Category")) AddCommandParameter(dbCommand, "@Category", _Category);
|
||||
if (columnNames.ContainsCI("Type")) AddCommandParameter(dbCommand, "@Type", _Type);
|
||||
if (columnNames.ContainsCI("Caption")) AddCommandParameter(dbCommand, "@Caption", _Caption);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class Language_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataString _Code { get; } = new ColumnDataString("Code");
|
||||
public ColumnDataString _Name { get; } = new ColumnDataString("Name");
|
||||
public ColumnDataInt32Nullable _Primary { get; } = new ColumnDataInt32Nullable("Primary");
|
||||
public ColumnDataBoolean _Unicode { get; } = new ColumnDataBoolean("Unicode");
|
||||
public ColumnDataBoolean _Translation { get; } = new ColumnDataBoolean("Translation");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"Code",
|
||||
"Name",
|
||||
"Primary",
|
||||
"Unicode",
|
||||
"Translation",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"Primary",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal Language_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "Language";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public String _Code { get { return Cols._Code.Value; } set { Cols._Code.Value = value; } }
|
||||
public String _Name { get { return Cols._Name.Value; } set { Cols._Name.Value = value; } }
|
||||
public Int32? _Primary { get { return Cols._Primary.Value; } set { Cols._Primary.Value = value; } }
|
||||
public Boolean _Unicode { get { return Cols._Unicode.Value; } set { Cols._Unicode.Value = value; } }
|
||||
public Boolean _Translation { get { return Cols._Translation.Value; } set { Cols._Translation.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_Code = GetFieldString(dbDataReader, "Code", _Code);
|
||||
_Name = GetFieldString(dbDataReader, "Name", _Name);
|
||||
_Primary = GetFieldInt32Nullable(dbDataReader, "Primary", _Primary);
|
||||
_Unicode = GetFieldBoolean(dbDataReader, "Unicode", _Unicode);
|
||||
_Translation = GetFieldBoolean(dbDataReader, "Translation", _Translation);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("Name")) AddCommandParameter(dbCommand, "@Name", _Name);
|
||||
if (columnNames.ContainsCI("Primary")) AddCommandParameter(dbCommand, "@Primary", _Primary);
|
||||
if (columnNames.ContainsCI("Unicode")) AddCommandParameter(dbCommand, "@Unicode", _Unicode);
|
||||
if (columnNames.ContainsCI("Translation")) AddCommandParameter(dbCommand, "@Translation", _Translation);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("Name")) AddCommandParameter(dbCommand, "@Name", _Name);
|
||||
if (columnNames.ContainsCI("Primary")) AddCommandParameter(dbCommand, "@Primary", _Primary);
|
||||
if (columnNames.ContainsCI("Unicode")) AddCommandParameter(dbCommand, "@Unicode", _Unicode);
|
||||
if (columnNames.ContainsCI("Translation")) AddCommandParameter(dbCommand, "@Translation", _Translation);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class Region_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataString _Type { get; } = new ColumnDataString("Type");
|
||||
public ColumnDataString _Name { get; } = new ColumnDataString("Name");
|
||||
public ColumnDataInt32Nullable _Parent { get; } = new ColumnDataInt32Nullable("Parent");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"Type",
|
||||
"Name",
|
||||
"Parent",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"Name",
|
||||
"Parent",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal Region_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "Region";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public String _Type { get { return Cols._Type.Value; } set { Cols._Type.Value = value; } }
|
||||
public String _Name { get { return Cols._Name.Value; } set { Cols._Name.Value = value; } }
|
||||
public Int32? _Parent { get { return Cols._Parent.Value; } set { Cols._Parent.Value = value; } }
|
||||
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_Type = GetFieldString(dbDataReader, "Type", _Type);
|
||||
_Name = GetFieldString(dbDataReader, "Name", _Name);
|
||||
_Parent = GetFieldInt32Nullable(dbDataReader, "Parent", _Parent);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("Type")) AddCommandParameter(dbCommand, "@Type", _Type);
|
||||
if (columnNames.ContainsCI("Name")) AddCommandParameter(dbCommand, "@Name", _Name);
|
||||
if (columnNames.ContainsCI("Parent")) AddCommandParameter(dbCommand, "@Parent", _Parent);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("Type")) AddCommandParameter(dbCommand, "@Type", _Type);
|
||||
if (columnNames.ContainsCI("Name")) AddCommandParameter(dbCommand, "@Name", _Name);
|
||||
if (columnNames.ContainsCI("Parent")) AddCommandParameter(dbCommand, "@Parent", _Parent);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -1,282 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class TaxCode_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataString _Code { get; } = new ColumnDataString("Code");
|
||||
public ColumnDataString _CodeAlt1 { get; } = new ColumnDataString("CodeAlt1");
|
||||
public ColumnDataString _CodeAlt2 { get; } = new ColumnDataString("CodeAlt2");
|
||||
public ColumnDataString _Description { get; } = new ColumnDataString("Description");
|
||||
public ColumnDataInt32Nullable _RegionId { get; } = new ColumnDataInt32Nullable("RegionId");
|
||||
public ColumnDataDateTimeNullable _EffectFrom { get; } = new ColumnDataDateTimeNullable("EffectFrom");
|
||||
public ColumnDataDateTimeNullable _EffectTo { get; } = new ColumnDataDateTimeNullable("EffectTo");
|
||||
public ColumnDataDecimalNullable _TaxRate { get; } = new ColumnDataDecimalNullable("TaxRate");
|
||||
public ColumnDataDecimalNullable _TaxRatePrev { get; } = new ColumnDataDecimalNullable("TaxRatePrev");
|
||||
public ColumnDataInt32Nullable _TaxCodeIdLink { get; } = new ColumnDataInt32Nullable("TaxCodeIdLink");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"Code",
|
||||
"CodeAlt1",
|
||||
"CodeAlt2",
|
||||
"Description",
|
||||
"RegionId",
|
||||
"EffectFrom",
|
||||
"EffectTo",
|
||||
"TaxRate",
|
||||
"TaxRatePrev",
|
||||
"TaxCodeIdLink",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"Code",
|
||||
"CodeAlt1",
|
||||
"CodeAlt2",
|
||||
"Description",
|
||||
"RegionId",
|
||||
"EffectFrom",
|
||||
"EffectTo",
|
||||
"TaxRate",
|
||||
"TaxRatePrev",
|
||||
"TaxCodeIdLink",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal TaxCode_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "TaxCode";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public String _Code { get { return Cols._Code.Value; } set { Cols._Code.Value = value; } }
|
||||
public String _CodeAlt1 { get { return Cols._CodeAlt1.Value; } set { Cols._CodeAlt1.Value = value; } }
|
||||
public String _CodeAlt2 { get { return Cols._CodeAlt2.Value; } set { Cols._CodeAlt2.Value = value; } }
|
||||
public String _Description { get { return Cols._Description.Value; } set { Cols._Description.Value = value; } }
|
||||
public Int32? _RegionId { get { return Cols._RegionId.Value; } set { Cols._RegionId.Value = value; } }
|
||||
public DateTime? _EffectFrom { get { return Cols._EffectFrom.Value; } set { Cols._EffectFrom.Value = value; } }
|
||||
public DateTime? _EffectTo { get { return Cols._EffectTo.Value; } set { Cols._EffectTo.Value = value; } }
|
||||
public Decimal? _TaxRate { get { return Cols._TaxRate.Value; } set { Cols._TaxRate.Value = value; } }
|
||||
public Decimal? _TaxRatePrev { get { return Cols._TaxRatePrev.Value; } set { Cols._TaxRatePrev.Value = value; } }
|
||||
public Int32? _TaxCodeIdLink { get { return Cols._TaxCodeIdLink.Value; } set { Cols._TaxCodeIdLink.Value = value; } }
|
||||
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_Code = GetFieldString(dbDataReader, "Code", _Code);
|
||||
_CodeAlt1 = GetFieldString(dbDataReader, "CodeAlt1", _CodeAlt1);
|
||||
_CodeAlt2 = GetFieldString(dbDataReader, "CodeAlt2", _CodeAlt2);
|
||||
_Description = GetFieldString(dbDataReader, "Description", _Description);
|
||||
_RegionId = GetFieldInt32Nullable(dbDataReader, "RegionId", _RegionId);
|
||||
_EffectFrom = GetFieldDateTimeNullable(dbDataReader, "EffectFrom", _EffectFrom);
|
||||
_EffectTo = GetFieldDateTimeNullable(dbDataReader, "EffectTo", _EffectTo);
|
||||
_TaxRate = GetFieldDecimalNullable(dbDataReader, "TaxRate", _TaxRate);
|
||||
_TaxRatePrev = GetFieldDecimalNullable(dbDataReader, "TaxRatePrev", _TaxRatePrev);
|
||||
_TaxCodeIdLink = GetFieldInt32Nullable(dbDataReader, "TaxCodeIdLink", _TaxCodeIdLink);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("CodeAlt1")) AddCommandParameter(dbCommand, "@CodeAlt1", _CodeAlt1);
|
||||
if (columnNames.ContainsCI("CodeAlt2")) AddCommandParameter(dbCommand, "@CodeAlt2", _CodeAlt2);
|
||||
if (columnNames.ContainsCI("Description")) AddCommandParameter(dbCommand, "@Description", _Description);
|
||||
if (columnNames.ContainsCI("RegionId")) AddCommandParameter(dbCommand, "@RegionId", _RegionId);
|
||||
if (columnNames.ContainsCI("EffectFrom")) AddCommandParameter(dbCommand, "@EffectFrom", _EffectFrom);
|
||||
if (columnNames.ContainsCI("EffectTo")) AddCommandParameter(dbCommand, "@EffectTo", _EffectTo);
|
||||
if (columnNames.ContainsCI("TaxRate")) AddCommandParameter(dbCommand, "@TaxRate", _TaxRate);
|
||||
if (columnNames.ContainsCI("TaxRatePrev")) AddCommandParameter(dbCommand, "@TaxRatePrev", _TaxRatePrev);
|
||||
if (columnNames.ContainsCI("TaxCodeIdLink")) AddCommandParameter(dbCommand, "@TaxCodeIdLink", _TaxCodeIdLink);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("CodeAlt1")) AddCommandParameter(dbCommand, "@CodeAlt1", _CodeAlt1);
|
||||
if (columnNames.ContainsCI("CodeAlt2")) AddCommandParameter(dbCommand, "@CodeAlt2", _CodeAlt2);
|
||||
if (columnNames.ContainsCI("Description")) AddCommandParameter(dbCommand, "@Description", _Description);
|
||||
if (columnNames.ContainsCI("RegionId")) AddCommandParameter(dbCommand, "@RegionId", _RegionId);
|
||||
if (columnNames.ContainsCI("EffectFrom")) AddCommandParameter(dbCommand, "@EffectFrom", _EffectFrom);
|
||||
if (columnNames.ContainsCI("EffectTo")) AddCommandParameter(dbCommand, "@EffectTo", _EffectTo);
|
||||
if (columnNames.ContainsCI("TaxRate")) AddCommandParameter(dbCommand, "@TaxRate", _TaxRate);
|
||||
if (columnNames.ContainsCI("TaxRatePrev")) AddCommandParameter(dbCommand, "@TaxRatePrev", _TaxRatePrev);
|
||||
if (columnNames.ContainsCI("TaxCodeIdLink")) AddCommandParameter(dbCommand, "@TaxCodeIdLink", _TaxCodeIdLink);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
// Code generated by Sarand Database Utilities Thu 6-Feb-2025 13:02:20
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
|
||||
@@ -1,302 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
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.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
internal class UnitMeasure_Db : SbmDbDataItem
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Column definitions.
|
||||
public class ColumnsData
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataInt16Nullable _Category { get; } = new ColumnDataInt16Nullable("Category");
|
||||
public ColumnDataInt16Nullable _Type { get; } = new ColumnDataInt16Nullable("Type");
|
||||
public ColumnDataInt16Nullable _UnitType { get; } = new ColumnDataInt16Nullable("UnitType");
|
||||
public ColumnDataString _Code { get; } = new ColumnDataString("Code");
|
||||
public ColumnDataString _Abbr { get; } = new ColumnDataString("Abbr");
|
||||
public ColumnDataString _Single { get; } = new ColumnDataString("Single");
|
||||
public ColumnDataString _Multiple { get; } = new ColumnDataString("Multiple");
|
||||
public ColumnDataDecimalNullable _EquValue { get; } = new ColumnDataDecimalNullable("EquValue");
|
||||
public ColumnDataInt32Nullable _UomIdEqu { get; } = new ColumnDataInt32Nullable("UomIdEqu");
|
||||
public ColumnDataInt32Nullable _EquAlgorythm { get; } = new ColumnDataInt32Nullable("EquAlgorythm");
|
||||
public ColumnDataInt32Nullable _UomIdRef1 { get; } = new ColumnDataInt32Nullable("UomIdRef1");
|
||||
public ColumnDataInt32Nullable _UomIdRef2 { get; } = new ColumnDataInt32Nullable("UomIdRef2");
|
||||
public ColumnDataInt32Nullable _UomIdRef3 { get; } = new ColumnDataInt32Nullable("UomIdRef3");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
protected static List<String> fields { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
"Category",
|
||||
"Type",
|
||||
"UnitType",
|
||||
"Code",
|
||||
"Abbr",
|
||||
"Single",
|
||||
"Multiple",
|
||||
"EquValue",
|
||||
"UomIdEqu",
|
||||
"EquAlgorythm",
|
||||
"UomIdRef1",
|
||||
"UomIdRef2",
|
||||
"UomIdRef3",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsId { get; } = new List<String>()
|
||||
{
|
||||
};
|
||||
protected static List<String> fieldsPrimary { get; } = new List<String>()
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"Category",
|
||||
"Type",
|
||||
"UnitType",
|
||||
"Abbr",
|
||||
"Single",
|
||||
"Multiple",
|
||||
"EquValue",
|
||||
"UomIdEqu",
|
||||
"EquAlgorythm",
|
||||
"UomIdRef1",
|
||||
"UomIdRef2",
|
||||
"UomIdRef3",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
internal UnitMeasure_Db (IDatabaseInfo dbInfo) : base(dbInfo)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override String SchemaName { get; } = "dbo";
|
||||
public override String TableName { get; } = "UnitMeasure";
|
||||
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 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public Int16? _Category { get { return Cols._Category.Value; } set { Cols._Category.Value = value; } }
|
||||
public Int16? _Type { get { return Cols._Type.Value; } set { Cols._Type.Value = value; } }
|
||||
public Int16? _UnitType { get { return Cols._UnitType.Value; } set { Cols._UnitType.Value = value; } }
|
||||
public String _Code { get { return Cols._Code.Value; } set { Cols._Code.Value = value; } }
|
||||
public String _Abbr { get { return Cols._Abbr.Value; } set { Cols._Abbr.Value = value; } }
|
||||
public String _Single { get { return Cols._Single.Value; } set { Cols._Single.Value = value; } }
|
||||
public String _Multiple { get { return Cols._Multiple.Value; } set { Cols._Multiple.Value = value; } }
|
||||
public Decimal? _EquValue { get { return Cols._EquValue.Value; } set { Cols._EquValue.Value = value; } }
|
||||
public Int32? _UomIdEqu { get { return Cols._UomIdEqu.Value; } set { Cols._UomIdEqu.Value = value; } }
|
||||
public Int32? _EquAlgorythm { get { return Cols._EquAlgorythm.Value; } set { Cols._EquAlgorythm.Value = value; } }
|
||||
public Int32? _UomIdRef1 { get { return Cols._UomIdRef1.Value; } set { Cols._UomIdRef1.Value = value; } }
|
||||
public Int32? _UomIdRef2 { get { return Cols._UomIdRef2.Value; } set { Cols._UomIdRef2.Value = value; } }
|
||||
public Int32? _UomIdRef3 { get { return Cols._UomIdRef3.Value; } set { Cols._UomIdRef3.Value = value; } }
|
||||
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter)
|
||||
{
|
||||
dbCommand.CommandText =
|
||||
"SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " +
|
||||
"FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " +
|
||||
(!String.IsNullOrEmpty(filter) ? "WHERE " + filter : "");
|
||||
Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
dbDataReader.Read();
|
||||
PopulateFrom(dbDataReader);
|
||||
}
|
||||
}
|
||||
public override void PopulateFrom (DbDataReader dbDataReader)
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_Category = GetFieldInt16Nullable(dbDataReader, "Category", _Category);
|
||||
_Type = GetFieldInt16Nullable(dbDataReader, "Type", _Type);
|
||||
_UnitType = GetFieldInt16Nullable(dbDataReader, "UnitType", _UnitType);
|
||||
_Code = GetFieldString(dbDataReader, "Code", _Code);
|
||||
_Abbr = GetFieldString(dbDataReader, "Abbr", _Abbr);
|
||||
_Single = GetFieldString(dbDataReader, "Single", _Single);
|
||||
_Multiple = GetFieldString(dbDataReader, "Multiple", _Multiple);
|
||||
_EquValue = GetFieldDecimalNullable(dbDataReader, "EquValue", _EquValue);
|
||||
_UomIdEqu = GetFieldInt32Nullable(dbDataReader, "UomIdEqu", _UomIdEqu);
|
||||
_EquAlgorythm = GetFieldInt32Nullable(dbDataReader, "EquAlgorythm", _EquAlgorythm);
|
||||
_UomIdRef1 = GetFieldInt32Nullable(dbDataReader, "UomIdRef1", _UomIdRef1);
|
||||
_UomIdRef2 = GetFieldInt32Nullable(dbDataReader, "UomIdRef2", _UomIdRef2);
|
||||
_UomIdRef3 = GetFieldInt32Nullable(dbDataReader, "UomIdRef3", _UomIdRef3);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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("Id")) AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
if (columnNames.ContainsCI("Category")) AddCommandParameter(dbCommand, "@Category", _Category);
|
||||
if (columnNames.ContainsCI("Type")) AddCommandParameter(dbCommand, "@Type", _Type);
|
||||
if (columnNames.ContainsCI("UnitType")) AddCommandParameter(dbCommand, "@UnitType", _UnitType);
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("Abbr")) AddCommandParameter(dbCommand, "@Abbr", _Abbr);
|
||||
if (columnNames.ContainsCI("Single")) AddCommandParameter(dbCommand, "@Single", _Single);
|
||||
if (columnNames.ContainsCI("Multiple")) AddCommandParameter(dbCommand, "@Multiple", _Multiple);
|
||||
if (columnNames.ContainsCI("EquValue")) AddCommandParameter(dbCommand, "@EquValue", _EquValue);
|
||||
if (columnNames.ContainsCI("UomIdEqu")) AddCommandParameter(dbCommand, "@UomIdEqu", _UomIdEqu);
|
||||
if (columnNames.ContainsCI("EquAlgorythm")) AddCommandParameter(dbCommand, "@EquAlgorythm", _EquAlgorythm);
|
||||
if (columnNames.ContainsCI("UomIdRef1")) AddCommandParameter(dbCommand, "@UomIdRef1", _UomIdRef1);
|
||||
if (columnNames.ContainsCI("UomIdRef2")) AddCommandParameter(dbCommand, "@UomIdRef2", _UomIdRef2);
|
||||
if (columnNames.ContainsCI("UomIdRef3")) AddCommandParameter(dbCommand, "@UomIdRef3", _UomIdRef3);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
|
||||
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
|
||||
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
// Execute insert command.
|
||||
bool commandSuccess = false;
|
||||
int executeNonQuery = dbCommand.ExecuteNonQuery();
|
||||
if (executeNonQuery == 1)
|
||||
{
|
||||
commandSuccess = true;
|
||||
}
|
||||
return commandSuccess;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
{
|
||||
query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " ";
|
||||
query += "WHERE Id=@Id;";
|
||||
}
|
||||
else
|
||||
{
|
||||
query += columnNames.Concat(", ", "", "=?") + " ";
|
||||
query += "WHERE Id=?;";
|
||||
}
|
||||
dbCommand.CommandText = query;
|
||||
Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText);
|
||||
// Populate parameters.
|
||||
dbCommand.Parameters.Clear();
|
||||
if (columnNames.ContainsCI("Category")) AddCommandParameter(dbCommand, "@Category", _Category);
|
||||
if (columnNames.ContainsCI("Type")) AddCommandParameter(dbCommand, "@Type", _Type);
|
||||
if (columnNames.ContainsCI("UnitType")) AddCommandParameter(dbCommand, "@UnitType", _UnitType);
|
||||
if (columnNames.ContainsCI("Code")) AddCommandParameter(dbCommand, "@Code", _Code);
|
||||
if (columnNames.ContainsCI("Abbr")) AddCommandParameter(dbCommand, "@Abbr", _Abbr);
|
||||
if (columnNames.ContainsCI("Single")) AddCommandParameter(dbCommand, "@Single", _Single);
|
||||
if (columnNames.ContainsCI("Multiple")) AddCommandParameter(dbCommand, "@Multiple", _Multiple);
|
||||
if (columnNames.ContainsCI("EquValue")) AddCommandParameter(dbCommand, "@EquValue", _EquValue);
|
||||
if (columnNames.ContainsCI("UomIdEqu")) AddCommandParameter(dbCommand, "@UomIdEqu", _UomIdEqu);
|
||||
if (columnNames.ContainsCI("EquAlgorythm")) AddCommandParameter(dbCommand, "@EquAlgorythm", _EquAlgorythm);
|
||||
if (columnNames.ContainsCI("UomIdRef1")) AddCommandParameter(dbCommand, "@UomIdRef1", _UomIdRef1);
|
||||
if (columnNames.ContainsCI("UomIdRef2")) AddCommandParameter(dbCommand, "@UomIdRef2", _UomIdRef2);
|
||||
if (columnNames.ContainsCI("UomIdRef3")) AddCommandParameter(dbCommand, "@UomIdRef3", _UomIdRef3);
|
||||
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
|
||||
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
|
||||
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
|
||||
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
|
||||
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
|
||||
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
|
||||
AddCommandParameter(dbCommand, "@Id", _Id);
|
||||
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
|
||||
return (executeNonQueryResult == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,580 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Control - Account Manager - Account Registrations.
|
||||
//=======================================================================
|
||||
partial class SbmcAccountMgr_Dbas
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
private List<StringPair> GetLogProperties(SbmcAccountRegistration accountRegistration)
|
||||
{
|
||||
return new List<StringPair>()
|
||||
{
|
||||
new StringPair("Id",SysId.ToString(accountRegistration.Id)),
|
||||
new StringPair("Email",accountRegistration.EmailAddress),
|
||||
new StringPair("Token",accountRegistration.RegisterAccountToken.ToString()),
|
||||
new StringPair("Status",accountRegistration.StatusCode)
|
||||
};
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create Item.
|
||||
public override SbmcAccountRegistration CreateAccountRegistration(String emailAddress, Guid registerAccountToken)
|
||||
{
|
||||
return new SbmcAccountRegistration_Dbas(null, emailAddress, registerAccountToken, 0);
|
||||
}
|
||||
private SbmcAccountRegistration_Dbas CreateAccountRegistration(AccountRegistration_Db dbAccountRegistration)
|
||||
{
|
||||
ClearErrorState();
|
||||
SbmcAccountRegistration_Dbas accountRegistration = new SbmcAccountRegistration_Dbas(new SysId(dbAccountRegistration._Id), dbAccountRegistration._EmailAddress, dbAccountRegistration._RegisterAccountToken, (ushort)dbAccountRegistration._Flags);
|
||||
PopulateFrom(dbAccountRegistration, accountRegistration);
|
||||
return accountRegistration;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Item.
|
||||
public override SbmcAccountRegistration GetAccountRegistration(SbmcAccountRegistration.Params prm)
|
||||
{
|
||||
return GetAccountRegistration(GetAccountRegistrationQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
}
|
||||
private SbmcAccountRegistration GetAccountRegistration(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
long count = GetAccountRegistrationCount(filter);
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmcAccountRegistration accountRegistration = null;
|
||||
// Query data.
|
||||
using (var dbConnection = db.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbConnection.Open();
|
||||
AccountRegistration_Db dbAccountRegistration = new AccountRegistration_Db(DbInfo);
|
||||
dbAccountRegistration.PopulateFrom(dbCommand, aliasAccountRegistration, filter);
|
||||
accountRegistration = CreateAccountRegistration(dbAccountRegistration);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
return accountRegistration;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate Item.
|
||||
public override bool IsValidAccountRegistrationData(SbmcAccountRegistration.Data data, SbmcAccountRegistration.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!base.IsValidAccountRegistrationData(data, errField)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert Item.
|
||||
public override bool InsertAccountRegistration(SbmcAccountRegistration accountRegistration, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!IsValidAccountRegistration(accountRegistration)) return false;
|
||||
if (SysId.IsValid(accountRegistration.Id)) return SetErrorState(ErrorMessage.ValiditemId);
|
||||
using (var dbConnection = db.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbConnection.Open();
|
||||
AccountRegistration_Db dbAccountRegistration = new AccountRegistration_Db(DbInfo);
|
||||
PopulateTo(dbAccountRegistration, accountRegistration, dbUpdateInfo);
|
||||
if (AccountRegistration_Db.FieldsNonId.Contains("Id"))
|
||||
{
|
||||
// Generate next Id.
|
||||
dbAccountRegistration._Id = SysId.ToInt(db.GetNextId("AccountRegistration", dbUpdateInfo));
|
||||
}
|
||||
dbAccountRegistration.ExecuteInsertCommand(dbCommand);
|
||||
accountRegistration.Id = new SysId(dbAccountRegistration._Id);
|
||||
accountRegistration.Changed = false;
|
||||
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. {GetLogProperties(accountRegistration).Concat(": ").Concat("", "\n\t")}");
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update Item.
|
||||
public override bool UpdateAccountRegistration(SbmcAccountRegistration accountRegistration, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!IsValidAccountRegistration(accountRegistration)) return false;
|
||||
if (!SysId.IsValid(accountRegistration.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
|
||||
if (!accountRegistration.Changed)
|
||||
{
|
||||
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(accountRegistration).Concat(": ").Concat("", "\n\t")}");
|
||||
return true;
|
||||
}
|
||||
using (var dbConnection = db.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Retrieve AccountRegistration.
|
||||
dbConnection.Open();
|
||||
AccountRegistration_Db dbAccountRegistration = new AccountRegistration_Db(DbInfo);
|
||||
dbAccountRegistration.PopulateFrom(dbCommand, aliasAccountRegistration, $"Id={SysId.ToString(accountRegistration.Id)}");
|
||||
//SbmUpdateLogItemMonitor_AccountRegistration updateLogMonitor = new SbmUpdateLogItemMonitor_AccountRegistration(Internals, CreateAccountRegistration(dbAccountRegistration));
|
||||
|
||||
// Update properties.
|
||||
PopulateTo(dbAccountRegistration, accountRegistration, dbUpdateInfo);
|
||||
dbAccountRegistration.ExecuteUpdateCommand(dbCommand);
|
||||
accountRegistration.Changed = false;
|
||||
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. {GetLogProperties(accountRegistration).Concat(": ").Concat("", "\n\t")}");
|
||||
|
||||
// Record updates.
|
||||
//updateLogMonitor.RecordUpdatedValues(accountRegistration);
|
||||
//updateLogMonitor.LogUpdates();
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Delete Item.
|
||||
public override bool AccountRegistrationCanBeDeleted(SbmcAccountRegistration accountRegistration)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!base.AccountRegistrationCanBeDeleted(accountRegistration)) return false;
|
||||
return true;
|
||||
}
|
||||
public override bool DeleteAccountRegistration(SbmcAccountRegistration accountRegistration, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!AccountRegistrationCanBeDeleted(accountRegistration)) return false;
|
||||
using (var dbConnection = db.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Retrieve AccountRegistration.
|
||||
dbConnection.Open();
|
||||
AccountRegistration_Db dbAccountRegistration = new AccountRegistration_Db(DbInfo);
|
||||
dbAccountRegistration.PopulateFrom(dbCommand, aliasAccountRegistration, "Id=" + accountRegistration.Id.ToString());
|
||||
// Delete AccountRegistration.
|
||||
dbCommand.CommandType = System.Data.CommandType.Text;
|
||||
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn_Control.GetTableName(SbmDbDfn_Control.TableIdx.AccountRegistration) + " WHERE Id=" + SysId.ToString(accountRegistration.Id) + ";";
|
||||
dbCommand.ExecuteNonQuery();
|
||||
accountRegistration.Changed = false;
|
||||
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. {GetLogProperties(accountRegistration).Concat(": ").Concat("", "\n\t")}");
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copy data properties to and from Item.
|
||||
private void PopulateTo(AccountRegistration_Db dbAccountRegistration, SbmcAccountRegistration accountRegistration, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
// Properties.
|
||||
dbAccountRegistration._Id = accountRegistration.Id.ToInt();
|
||||
dbAccountRegistration._EmailAddress = accountRegistration.EmailAddress;
|
||||
dbAccountRegistration._FirstName = accountRegistration.FirstName;
|
||||
dbAccountRegistration._LastName = accountRegistration.LastName;
|
||||
dbAccountRegistration._PhoneMain = accountRegistration.PhoneMain;
|
||||
dbAccountRegistration._PhoneAlt = accountRegistration.PhoneAlt;
|
||||
// Registration.
|
||||
dbAccountRegistration._InstanceContext = accountRegistration.InstanceContext;
|
||||
dbAccountRegistration._RequestAccountAt = accountRegistration.RequestAccountAt;
|
||||
dbAccountRegistration._RegisterAccountToken = accountRegistration.RegisterAccountToken;
|
||||
dbAccountRegistration._RegisterAccountAt = accountRegistration.RegisterAccountAt;
|
||||
// Security.
|
||||
dbAccountRegistration._AccountPasswordSalt = accountRegistration.AccountPasswordSalt;
|
||||
dbAccountRegistration._AccountPasswordHash = accountRegistration.AccountPasswordHash;
|
||||
// Common.
|
||||
dbAccountRegistration._Notes = accountRegistration.Notes;
|
||||
dbAccountRegistration._Status = SacsSystem.GetStatusCode(accountRegistration.Status);
|
||||
dbAccountRegistration._Flags = (short)accountRegistration.Flags;
|
||||
if (!SysId.IsValid(accountRegistration.Id))
|
||||
{
|
||||
dbAccountRegistration._CreateOn = DateTime.UtcNow;
|
||||
dbAccountRegistration._CreateBy = dbUpdateInfo.UserId.ToInt();
|
||||
dbAccountRegistration._CreateHost = dbUpdateInfo.Host;
|
||||
}
|
||||
dbAccountRegistration._UpdateOn = DateTime.UtcNow;
|
||||
dbAccountRegistration._UpdateBy = dbUpdateInfo.UserId.ToInt();
|
||||
dbAccountRegistration._UpdateHost = dbUpdateInfo.Host;
|
||||
}
|
||||
private void PopulateFrom(AccountRegistration_Db dbAccountRegistration, SbmcAccountRegistration accountRegistration)
|
||||
{
|
||||
// Properties.
|
||||
//accountRegistration.Id = new SysId(dbAccountRegistration._Id);
|
||||
//accountRegistration.EmailAddress = dbAccountRegistration._EmailAddress;
|
||||
accountRegistration.FirstName = dbAccountRegistration._FirstName;
|
||||
accountRegistration.LastName = dbAccountRegistration._LastName;
|
||||
accountRegistration.PhoneMain = dbAccountRegistration._PhoneMain;
|
||||
accountRegistration.PhoneAlt = dbAccountRegistration._PhoneAlt;
|
||||
// Registration.
|
||||
accountRegistration.InstanceContext = dbAccountRegistration._InstanceContext;
|
||||
accountRegistration.RequestAccountAt = dbAccountRegistration._RequestAccountAt;
|
||||
//accountRegistration.RegisterAccountToken = dbAccountRegistration._RegisterAccountToken;
|
||||
accountRegistration.RegisterAccountAt = dbAccountRegistration._RegisterAccountAt;
|
||||
// Security.
|
||||
accountRegistration.AccountPasswordSalt = dbAccountRegistration._AccountPasswordSalt;
|
||||
accountRegistration.AccountPasswordHash = dbAccountRegistration._AccountPasswordHash;
|
||||
// Common.
|
||||
accountRegistration.Notes = dbAccountRegistration._Notes;
|
||||
accountRegistration.Status = SacsSystem.GetStatusForCode(dbAccountRegistration._Status);
|
||||
accountRegistration.SetCreateStamp(dbAccountRegistration._CreateOn, new SysId(dbAccountRegistration._CreateBy), dbAccountRegistration._CreateHost);
|
||||
accountRegistration.SetUpdateStamp(dbAccountRegistration._UpdateOn, new SysId(dbAccountRegistration._UpdateBy), dbAccountRegistration._UpdateHost);
|
||||
accountRegistration.AcceptChanges();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item column definitions.
|
||||
private static readonly String aliasAccountRegistration = "Acr";
|
||||
private void SetAccountRegistrationColDfn
|
||||
(ColumnDfn col, String caption, int width, SbmDbDfn_Control.ColumnIdx dbCol,
|
||||
ColumnAlignment align = ColumnAlignment.Default, DataValue.DataType dataType = DataValue.DataType.String,
|
||||
String alias = "", String prefix = "")
|
||||
{
|
||||
if (String.IsNullOrEmpty(alias) && SbmDbDfn_Control.GetTableForColumn(dbCol) == SbmDbDfn_Control.TableIdx.AccountRegistration)
|
||||
alias = aliasAccountRegistration;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn_Control.GetColumnName(dbCol, false), SbmDbDfn_Control.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn_Control.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn_Control.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Item column definition.
|
||||
public override ColumnDfn GetAccountRegistrationColumnDfn(SbmcAccountRegistration.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
|
||||
switch (columnId)
|
||||
{
|
||||
case SbmcAccountRegistration.Column.Pos:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Pos", 45, SbmDbDfn_Control.ColumnIdx.Unknown, ColumnAlignment.Right);
|
||||
columnDfn.SortMode = ColumnDfn.ColumnSortMode.Off;
|
||||
columnDfn.ReadOnly = true;
|
||||
columnDfn.Resizable = false;
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.Id:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Id", 60, SbmDbDfn_Control.ColumnIdx.AccountRegistration_Id, ColumnAlignment.Right, DataValue.DataType.Long);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
|
||||
// AccountRegistration Properties.
|
||||
case SbmcAccountRegistration.Column.EmailAddress:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Email", 120, SbmDbDfn_Control.ColumnIdx.AccountRegistration_EmailAddress);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.FirstName:
|
||||
SetAccountRegistrationColDfn(columnDfn, "FirstName", 100, SbmDbDfn_Control.ColumnIdx.AccountRegistration_FirstName);
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.LastName:
|
||||
SetAccountRegistrationColDfn(columnDfn, "LastName", 100, SbmDbDfn_Control.ColumnIdx.AccountRegistration_LastName);
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.PhoneMain:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Phone main", 100, SbmDbDfn_Control.ColumnIdx.AccountRegistration_PhoneMain);
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.PhoneAlt:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Phone alt", 100, SbmDbDfn_Control.ColumnIdx.AccountRegistration_PhoneAlt);
|
||||
break;
|
||||
|
||||
// Registration.
|
||||
case SbmcAccountRegistration.Column.InstanceContext:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Instance context", 100, SbmDbDfn_Control.ColumnIdx.AccountRegistration_InstanceContext);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.RequestAccountAt:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Account requested", 120, SbmDbDfn_Control.ColumnIdx.AccountRegistration_RequestAccountAt, ColumnAlignment.Center, DataValue.DataType.DateTime);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.RegisterAccountToken:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Registration token", 120, SbmDbDfn_Control.ColumnIdx.AccountRegistration_RegisterAccountToken);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.RegisterAccountAt:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Account registered", 120, SbmDbDfn_Control.ColumnIdx.AccountRegistration_RegisterAccountAt, ColumnAlignment.Center, DataValue.DataType.DateTime);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
|
||||
// Common.
|
||||
case SbmcAccountRegistration.Column.Notes:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Notes", 200, SbmDbDfn_Control.ColumnIdx.AccountRegistration_Notes);
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.Status:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Status", 50, SbmDbDfn_Control.ColumnIdx.AccountRegistration_Status, ColumnAlignment.Center);
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.Status_Desc:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Status", 50, SbmDbDfn_Control.ColumnIdx.AccountRegistration_Status, ColumnAlignment.Center);
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.Status_Ind:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Status", 50, SbmDbDfn_Control.ColumnIdx.AccountRegistration_Status, ColumnAlignment.Center, DataValue.DataType.TriState);
|
||||
columnDfn.TriStateFormat = ColumnTriStateFormat.Lights;
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.CreateOn_Date:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Created", 65, SbmDbDfn_Control.ColumnIdx.AccountRegistration_CreateOn, ColumnAlignment.Center, DataValue.DataType.Date);
|
||||
columnDfn.ReadOnly = true;
|
||||
break;
|
||||
case SbmcAccountRegistration.Column.UpdateOn_Date:
|
||||
SetAccountRegistrationColDfn(columnDfn, "Updated", 65, SbmDbDfn_Control.ColumnIdx.AccountRegistration_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> GetAccountRegistrationQueryFilter(SbmcAccountRegistration.Params prm)
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
String colId = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_Id, aliasAccountRegistration);
|
||||
String colEmail = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_EmailAddress, aliasAccountRegistration);
|
||||
|
||||
// AccountRegistration Id.
|
||||
if (prm.IdsIncluded.HasValidIds())
|
||||
filter.Add($"{colId} IN ({prm.IdsIncluded.Concat(",")})");
|
||||
if (prm.IdsExcluded.HasValidIds())
|
||||
filter.Add($"{colId} NOT IN ({prm.IdsExcluded.Concat(",")})");
|
||||
|
||||
// Generic search.
|
||||
if (!StringUtil.IsBlank(prm.Search))
|
||||
{
|
||||
String colFirstName = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_FirstName, aliasAccountRegistration);
|
||||
String colLastName = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_LastName, aliasAccountRegistration);
|
||||
String colPhoneMain = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_PhoneMain, aliasAccountRegistration);
|
||||
String colPhoneAlt = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_PhoneAlt, aliasAccountRegistration);
|
||||
foreach (String search in Regex.Split(prm.Search, "[\\s,;\\-+]+"))
|
||||
{
|
||||
if (StringUtil.IsBlank(search)) continue;
|
||||
String searchForLike = DbQuery.FormatForLike(search, true);
|
||||
List<String> searchFilter = new List<string>();
|
||||
searchFilter.Add($"{colEmail} LIKE '%{searchForLike}%'");
|
||||
searchFilter.Add($"{colFirstName} LIKE '%{searchForLike}%'");
|
||||
searchFilter.Add($"{colLastName} LIKE '%{searchForLike}%'");
|
||||
searchFilter.Add($"{colPhoneMain} LIKE '%{searchForLike}%'");
|
||||
searchFilter.Add($"{colPhoneAlt} LIKE '%{searchForLike}%'");
|
||||
filter.Add(searchFilter.Concat(" OR ", "(", ")"));
|
||||
}
|
||||
}
|
||||
|
||||
// Email.
|
||||
if (!StringUtil.IsBlank(prm.EmailAddress))
|
||||
filter.Add($"{colEmail}='{DbQuery.FormatForCondition(prm.EmailAddress)}'");
|
||||
|
||||
// Token.
|
||||
if (prm.RegisterAccountToken != Guid.Empty)
|
||||
{
|
||||
String colToken = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_RegisterAccountToken, aliasAccountRegistration);
|
||||
filter.Add($"{colToken}='{prm.RegisterAccountToken.ToString()}'");
|
||||
}
|
||||
|
||||
// Common Properties.
|
||||
|
||||
// Notes.
|
||||
if (!StringUtil.IsEmpty(prm.NotesPartial))
|
||||
filter.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_Notes, aliasAccountRegistration) + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'");
|
||||
|
||||
// Status.
|
||||
String statusFilter = GetAccountRegistrationStatusCatFilterCondition(prm.StatusCat);
|
||||
if (!StringUtil.IsBlank(statusFilter))
|
||||
filter.Add($"{SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_Status, aliasAccountRegistration)}{statusFilter}");
|
||||
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
}
|
||||
internal static String GetAccountRegistrationStatusCatFilterCondition(SbmcAccountRegistration.StatusCat statusCat)
|
||||
{
|
||||
if (statusCat == SbmcAccountRegistration.StatusCat.AwaitingOnly)
|
||||
return $"='{SacsSystem.GetStatusCode(SaStatus.Awaiting)}'";
|
||||
if (statusCat == SbmcAccountRegistration.StatusCat.CompletedOnly)
|
||||
return $"='{SacsSystem.GetStatusCode(SaStatus.Completed)}'";
|
||||
if (statusCat == SbmcAccountRegistration.StatusCat.CancelledOnly)
|
||||
return $"='{SacsSystem.GetStatusCode(SaStatus.Cancelled)}'";
|
||||
if (statusCat == SbmcAccountRegistration.StatusCat.NotDeleted)
|
||||
return $"!='{SacsSystem.GetStatusCode(SaStatus.Deleted)}'";
|
||||
if (statusCat == SbmcAccountRegistration.StatusCat.DeletedOnly)
|
||||
return $"='{SacsSystem.GetStatusCode(SaStatus.Deleted)}'";
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item sort columns.
|
||||
public List<String> GetAccountRegistrationSortColumns(SbmcAccountRegistration.Params prm)
|
||||
{
|
||||
// Sort sequence:
|
||||
List<String> sortColumnNames = new List<String>();
|
||||
foreach (var columnDfn in prm.SortColumns)
|
||||
{
|
||||
// Need to ensure correct alias used for AccountRegistration columns in case of conflict.
|
||||
String sortCol = String.Empty;
|
||||
if (SbmDbDfn_Control.GetTableForColumn((SbmDbDfn_Control.ColumnIdx)columnDfn.DbColumn) == SbmDbDfn_Control.TableIdx.AccountRegistration)
|
||||
{
|
||||
sortCol = SbmDbDfn_Control.GetColumnNameQual((SbmDbDfn_Control.ColumnIdx)columnDfn.DbColumn, aliasAccountRegistration);
|
||||
}
|
||||
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(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_Id, aliasAccountRegistration) + " DESC");
|
||||
}
|
||||
return sortColumnNames;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item count.
|
||||
private long GetAccountRegistrationCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
return db.GetRowCount(SbmDbDfn_Control.GetTableName(SbmDbDfn_Control.TableIdx.AccountRegistration) + " As " + aliasAccountRegistration, filter);
|
||||
}
|
||||
public override long GetAccountRegistrationCount(SbmcAccountRegistration.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
return GetAccountRegistrationCount(GetAccountRegistrationQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public override List<SbmcAccountRegistration> GetAccountRegistrationList(SbmcAccountRegistration.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
List<SbmcAccountRegistration> addresses = new List<SbmcAccountRegistration>();
|
||||
DbQuery qry = new DbQuery(db.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn_Control.GetTableName(SbmDbDfn_Control.TableIdx.AccountRegistration), aliasAccountRegistration);
|
||||
AccountRegistration_Db dbAccountRegistration = new AccountRegistration_Db(DbInfo);
|
||||
qry.Columns.AddRange(dbAccountRegistration.ExistingColumnNames);
|
||||
qry.Filters.AddRange(GetAccountRegistrationQueryFilter(prm));
|
||||
qry.OrderBy.AddRange(GetAccountRegistrationSortColumns(prm));
|
||||
// Query data.
|
||||
using (var dbConnection = db.CreateConnection())
|
||||
using (var dbCommand = dbConnection.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbConnection.Open();
|
||||
dbCommand.CommandText = qry.BuildQuery(prm.ResultsPaging);
|
||||
using (DbDataReader dbDataReader = dbCommand.ExecuteReader())
|
||||
{
|
||||
while (dbDataReader.Read())
|
||||
{
|
||||
dbAccountRegistration = new AccountRegistration_Db(DbInfo);
|
||||
dbAccountRegistration.PopulateFrom(dbDataReader);
|
||||
addresses.Add(CreateAccountRegistration(dbAccountRegistration));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item query execution.
|
||||
public override DbResultSet ExecuteAccountRegistrationQuery(List<ColumnDfn> columns, SbmcAccountRegistration.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Construct query.
|
||||
DbQuery query = new DbQuery(db.DbmsType);
|
||||
query.Tables.Add(SbmDbDfn_Control.GetTableName(SbmDbDfn_Control.TableIdx.AccountRegistration), aliasAccountRegistration);
|
||||
|
||||
// AccountRegistration Properties - add columns as defined in query list.
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.Id))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_Id, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.EmailAddress))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_EmailAddress, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.FirstName))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_FirstName, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.LastName))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_LastName, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.PhoneMain))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_PhoneMain, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.PhoneAlt))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_PhoneAlt, aliasAccountRegistration));
|
||||
|
||||
// Registration.
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.InstanceContext))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_InstanceContext, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.RequestAccountAt))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_RequestAccountAt, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.RegisterAccountToken))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_RegisterAccountToken, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.RegisterAccountAt))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_RegisterAccountAt, aliasAccountRegistration));
|
||||
|
||||
// Common.
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.Notes))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_Notes, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.Status) || columns.HasId(SbmcAccountRegistration.Column.Status_Desc) || columns.HasId(SbmcAccountRegistration.Column.Status_Ind))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_Status, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.CreateOn_Date))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_CreateOn, aliasAccountRegistration));
|
||||
if (columns.HasId(SbmcAccountRegistration.Column.UpdateOn_Date))
|
||||
query.Columns.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.AccountRegistration_UpdateOn, aliasAccountRegistration));
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Populate filter.
|
||||
query.Filters.AddRange(GetAccountRegistrationQueryFilter(prm));
|
||||
|
||||
if (prm.IdsIncluded.Count != 1)
|
||||
{
|
||||
// Configure sort sequence.
|
||||
foreach (String sortColumn in GetAccountRegistrationSortColumns(prm))
|
||||
query.OrderBy.Add(sortColumn);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
|
||||
return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -1,13 +1,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -23,7 +17,7 @@ using System.Text.RegularExpressions;
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Control - Account Manager - UserAccounts.
|
||||
// Control - Account Manager - User Accounts.
|
||||
//=======================================================================
|
||||
partial class SbmcAccountMgr_Dbas
|
||||
{
|
||||
@@ -40,7 +34,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create UserAccount.
|
||||
// Create Item.
|
||||
public override SbmcUserAccount CreateUserAccount()
|
||||
{
|
||||
return new SbmcUserAccount_Dbas(null, 0);
|
||||
@@ -54,7 +48,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get UserAccount.
|
||||
// Get Item.
|
||||
public override SbmcUserAccount GetUserAccount(SbmcUserAccount.Params prm)
|
||||
{
|
||||
return GetUserAccount(GetUserAccountQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
@@ -66,7 +60,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple UserAccountes found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmcUserAccount userAccount = null;
|
||||
@@ -83,7 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("UserAccount query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -91,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate UserAccount.
|
||||
// Validate Item.
|
||||
public override bool IsValidUserAccountData(SbmcUserAccount.Data data, SbmcUserAccount.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -100,7 +94,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert UserAccount.
|
||||
// Insert UserAItemccount.
|
||||
public override bool InsertUserAccount(SbmcUserAccount userAccount, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -126,11 +120,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update UserAccount.
|
||||
// Update Item.
|
||||
public override bool UpdateUserAccount(SbmcUserAccount userAccount, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -164,11 +158,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Delete UserAccount.
|
||||
// Delete Item.
|
||||
public override bool UserAccountCanBeDeleted(SbmcUserAccount userAccount)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -197,11 +191,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copy data properties to and from userAccount.
|
||||
// Copy data properties to and from Item.
|
||||
private void PopulateTo(UserAccount_Db dbUserAccount, SbmcUserAccount userAccount, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
dbUserAccount._Id = userAccount.Id.ToInt();
|
||||
@@ -266,7 +260,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UserAccount column definitions.
|
||||
// Item column definitions.
|
||||
private static readonly String aliasUserAccount = "Uac";
|
||||
private void SetUserAccountColDfn
|
||||
(ColumnDfn col, String caption, int width, SbmDbDfn_Control.ColumnIdx dbCol,
|
||||
@@ -280,7 +274,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
col.MaxLength = (int)SbmDbDfn_Control.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmUserAccount column definition.
|
||||
// Item column definition.
|
||||
public override ColumnDfn GetUserAccountColumnDfn(SbmcUserAccount.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
|
||||
@@ -377,7 +371,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UserAccount query filter.
|
||||
// Item query filter.
|
||||
public override List<string> GetUserAccountQueryFilter(SbmcUserAccount.Params prm)
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
@@ -424,8 +418,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
filter.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.UserAccount_Notes, aliasUserAccount) + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'");
|
||||
|
||||
// Status.
|
||||
if (prm.StatusCat == SbmcUserAccount.StatusCat.ActiveOnly)
|
||||
filter.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.UserAccount_Status, aliasUserAccount) + " = '" + StatusActive + "'");
|
||||
String statusFilter = GetUserAccountStatusCatFilterCondition(prm.StatusCat);
|
||||
if (!StringUtil.IsBlank(statusFilter))
|
||||
filter.Add($"{SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.UserAccount_Status, aliasUserAccount)}{statusFilter}");
|
||||
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
@@ -444,7 +439,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UserAccount sort columns.
|
||||
// Item sort columns.
|
||||
public List<String> GetUserAccountSortColumns(SbmcUserAccount.Params prm)
|
||||
{
|
||||
// Sort sequence:
|
||||
@@ -479,7 +474,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UserAccount count.
|
||||
// Item count.
|
||||
private long GetUserAccountCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -492,7 +487,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UserAccount list.
|
||||
// Item list.
|
||||
public override List<SbmcUserAccount> GetUserAccountList(SbmcUserAccount.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -523,7 +518,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("UserAccount query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -531,7 +526,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// UserAccount query execution.
|
||||
// Item query execution.
|
||||
public override DbResultSet ExecuteUserAccountQuery(List<ColumnDfn> columns, SbmcUserAccount.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -40,7 +34,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create Owner.
|
||||
// Create Item.
|
||||
public override SbmcOwner CreateOwner()
|
||||
{
|
||||
return new SbmcOwner_Dbas(null, 0);
|
||||
@@ -54,7 +48,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Owner.
|
||||
// Get Item.
|
||||
public override SbmcOwner GetOwner(SbmcOwner.Params prm)
|
||||
{
|
||||
return GetOwner(GetOwnerQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
@@ -66,7 +60,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Owneres found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmcOwner owner = null;
|
||||
@@ -83,7 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Owner query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -91,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate Owner.
|
||||
// Validate Item.
|
||||
public override bool IsValidOwnerData(SbmcOwner.Data data, SbmcOwner.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -100,7 +94,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert Owner.
|
||||
// Insert Item.
|
||||
public override bool InsertOwner(SbmcOwner owner, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -126,11 +120,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update Owner.
|
||||
// Update Item.
|
||||
public override bool UpdateOwner(SbmcOwner owner, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -146,7 +140,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
try
|
||||
{
|
||||
// Retrieve Owner.
|
||||
// Retrieve Item.
|
||||
dbConnection.Open();
|
||||
Owner_Db dbOwner = new Owner_Db(DbInfo);
|
||||
dbOwner.PopulateFrom(dbCommand, aliasOwner, $"Id={SysId.ToString(owner.Id)}");
|
||||
@@ -164,11 +158,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Delete Owner.
|
||||
// Delete Item.
|
||||
public override bool OwnerCanBeDeleted(SbmcOwner owner)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -197,11 +191,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copy data properties to and from owner.
|
||||
// Copy data properties to and from Item.
|
||||
private void PopulateTo(Owner_Db dbOwner, SbmcOwner owner, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
dbOwner._Id = owner.Id.ToInt();
|
||||
@@ -241,7 +235,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Owner column definitions.
|
||||
// Item column definitions.
|
||||
private static readonly String aliasOwner = "Onr";
|
||||
private static readonly String colOwner_Repository_Count = "Onr_Rpo_Count";
|
||||
private void SetOwnerColDfn
|
||||
@@ -256,7 +250,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
col.MaxLength = (int)SbmDbDfn_Control.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmOwner column definition.
|
||||
// Item column definition.
|
||||
public override ColumnDfn GetOwnerColumnDfn(SbmcOwner.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
|
||||
@@ -327,7 +321,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Owner query filter.
|
||||
// Item query filter.
|
||||
public override List<string> GetOwnerQueryFilter(SbmcOwner.Params prm)
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
@@ -363,8 +357,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
filter.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.Owner_Notes, aliasOwner) + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'");
|
||||
|
||||
// Status.
|
||||
if (prm.StatusCat == SbmcOwner.StatusCat.ActiveOnly)
|
||||
filter.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.Owner_Status, aliasOwner) + " = '" + StatusActive + "'");
|
||||
String statusFilter = GetOwnerStatusCatFilterCondition(prm.StatusCat);
|
||||
if (!StringUtil.IsBlank(statusFilter))
|
||||
filter.Add($"{SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.Owner_Status, aliasOwner)}{statusFilter}");
|
||||
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
@@ -385,7 +380,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Owner sort columns.
|
||||
// Item sort columns.
|
||||
public List<String> GetOwnerSortColumns(SbmcOwner.Params prm)
|
||||
{
|
||||
// Sort sequence:
|
||||
@@ -420,7 +415,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Owner count.
|
||||
// Item count.
|
||||
private long GetOwnerCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -433,7 +428,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Owner list.
|
||||
// Item list.
|
||||
public override List<SbmcOwner> GetOwnerList(SbmcOwner.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -464,7 +459,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Owner query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -472,7 +467,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Owner query execution.
|
||||
// Item query execution.
|
||||
public override DbResultSet ExecuteOwnerQuery(List<ColumnDfn> columns, SbmcOwner.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -40,7 +34,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create Repository.
|
||||
// Create Item.
|
||||
public override SbmcRepository CreateRepository()
|
||||
{
|
||||
return new SbmcRepository_Dbas(null, 0);
|
||||
@@ -54,7 +48,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Repository.
|
||||
// Get Item.
|
||||
public override SbmcRepository GetRepository(SbmcRepository.Params prm)
|
||||
{
|
||||
return GetRepository(GetRepositoryQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
@@ -66,7 +60,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Repositories found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmcRepository repository = null;
|
||||
@@ -83,7 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Repository query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -91,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate Repository.
|
||||
// Validate Item.
|
||||
public override bool IsValidRepositoryData(SbmcRepository.Data data, SbmcRepository.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -100,7 +94,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert Repository.
|
||||
// Insert Item.
|
||||
public override bool InsertRepository(SbmcRepository repository, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -126,11 +120,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update Repository.
|
||||
// Update Item.
|
||||
public override bool UpdateRepository(SbmcRepository repository, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -164,11 +158,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Delete Repository.
|
||||
// Delete Item.
|
||||
public override bool RepositoryCanBeDeleted(SbmcRepository repository)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -197,11 +191,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copy data properties to and from repository.
|
||||
// Copy data properties to and from Item.
|
||||
private void PopulateTo(Repository_Db dbRepository, SbmcRepository repository, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
dbRepository._Id = repository.Id.ToInt();
|
||||
@@ -245,7 +239,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Repository column definitions.
|
||||
// Item column definitions.
|
||||
private static readonly String aliasRepository = "Rpo";
|
||||
private static readonly String aliasRepository_Owner = "Rpo_Onr";
|
||||
private static readonly String prefixRepository_Owner = aliasRepository_Owner + "_";
|
||||
@@ -261,7 +255,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
col.MaxLength = (int)SbmDbDfn_Control.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmRepository column definition.
|
||||
// Item column definition.
|
||||
public override ColumnDfn GetRepositoryColumnDfn(SbmcRepository.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
|
||||
@@ -351,7 +345,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Repository query filter.
|
||||
// Item query filter.
|
||||
public override List<string> GetRepositoryQueryFilter(SbmcRepository.Params prm)
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
@@ -399,8 +393,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
filter.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.Repository_Notes, aliasRepository) + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'");
|
||||
|
||||
// Status.
|
||||
if (prm.StatusCat == SbmcRepository.StatusCat.ActiveOnly)
|
||||
filter.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.Repository_Status, aliasRepository) + " = '" + StatusActive + "'");
|
||||
String statusFilter = GetRepositoryStatusCatFilterCondition(prm.StatusCat);
|
||||
if (!StringUtil.IsBlank(statusFilter))
|
||||
filter.Add($"{SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.Repository_Status, aliasRepository)}{statusFilter}");
|
||||
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
@@ -421,7 +416,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Repository sort columns.
|
||||
// Item sort columns.
|
||||
public List<String> GetRepositorySortColumns(SbmcRepository.Params prm)
|
||||
{
|
||||
// Sort sequence:
|
||||
@@ -456,7 +451,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Repository count.
|
||||
// Item count.
|
||||
private long GetRepositoryCount(String filter)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -469,7 +464,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Repository list.
|
||||
// Item list.
|
||||
public override List<SbmcRepository> GetRepositoryList(SbmcRepository.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -500,7 +495,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Repository query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -508,7 +503,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Repository query execution.
|
||||
// Item query execution.
|
||||
public override DbResultSet ExecuteRepositoryQuery(List<ColumnDfn> columns, SbmcRepository.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -23,7 +17,7 @@ using System.Text.RegularExpressions;
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Control - Item Manager - ItemParams.
|
||||
// Control - Item Manager - Item Params.
|
||||
//=======================================================================
|
||||
partial class SbmcItemMgr_Dbas
|
||||
{
|
||||
@@ -42,7 +36,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
// Create Item.
|
||||
public override SbmcItemParam CreateItemParam(ItemId itemId)
|
||||
{
|
||||
return new SbmcItemParam_Dbas(null, itemId, 0);
|
||||
@@ -56,7 +50,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get item.
|
||||
// Get Item.
|
||||
public override SbmcItemParam GetItemParam(SbmcItemParam.Params prm)
|
||||
{
|
||||
return GetItemParam(GetItemParamQueryFilter(prm).Concat(" AND ", "(", ")"));
|
||||
@@ -68,7 +62,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple ItemParames found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmcItemParam itemParam = null;
|
||||
@@ -85,7 +79,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("ItemParam query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -93,7 +87,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item.
|
||||
// Validate Item.
|
||||
public override bool IsValidItemParamData(SbmcItemParam.Data data, SbmcItemParam.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -102,7 +96,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Insert item.
|
||||
// Insert Item.
|
||||
public override bool InsertItemParam(SbmcItemParam itemParam, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -128,11 +122,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update item.
|
||||
// Update Item.
|
||||
public override bool UpdateItemParam(SbmcItemParam itemParam, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -166,11 +160,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Delete item.
|
||||
// Delete Item.
|
||||
public override bool ItemParamCanBeDeleted(SbmcItemParam itemParam)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -199,11 +193,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copy data properties to and from item.
|
||||
// Copy data properties to and from Item.
|
||||
private void PopulateTo(ItemParam_Db dbItemParam, SbmcItemParam itemParam, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
dbItemParam._Id = itemParam.Id.ToInt();
|
||||
@@ -494,7 +488,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("ItemParam query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
// Check that this is the only primary address for the item.
|
||||
ClearErrorState();
|
||||
if (addressPrimary == null) return SetErrorState("item not specified");
|
||||
if (addressPrimary == null) return SetErrorState(Msg_ItemNotSpecified);
|
||||
if (!SysId.IsValid(addressPrimary.Id)) return SetErrorState("invalid item id");
|
||||
if (!addressPrimary.IsPrimary) return SetErrorState("address is not primary");
|
||||
if (Database == null) return SetErrorState("database not available");
|
||||
@@ -71,7 +71,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
}
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -115,7 +115,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
else SetErrorState("Data item manager is not available");
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -158,7 +158,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Addresses found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmAddress address = null;
|
||||
@@ -175,7 +175,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -256,7 +256,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -289,7 +289,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -393,7 +393,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasAddress;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmAddress column definition.
|
||||
@@ -750,7 +750,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Org.BouncyCastle.Asn1.Cmp;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal;
|
||||
@@ -149,7 +151,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
else SetErrorState("Data item manager is not available");
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -179,7 +181,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Contacts found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmAffiliate affiliate = null;
|
||||
@@ -196,7 +198,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -313,7 +315,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -351,7 +353,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -384,7 +386,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -498,7 +500,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasAffiliate;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmAffiliate column definition.
|
||||
@@ -916,23 +918,27 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
filter.Add($"{colAffiliate_Notes} LIKE '%{DbQuery.FormatForLike(prm.NotesPartial)}%'");
|
||||
|
||||
// Status.
|
||||
if (prm.StatusCat != SbmAffiliate.StatusCat.Any)
|
||||
{
|
||||
String colStatus = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Status, aliasAffiliate);
|
||||
if (prm.StatusCat == SbmAffiliate.StatusCat.CurrentOnly)
|
||||
filter.Add($"{colStatus}='{StatusCurrent}'");
|
||||
else if (prm.StatusCat == SbmAffiliate.StatusCat.OnHoldOnly)
|
||||
filter.Add($"{colStatus}='{SacsSystem.GetStatusCode(SaStatus.OnHold)}'");
|
||||
else if (prm.StatusCat == SbmAffiliate.StatusCat.NotDeleted)
|
||||
filter.Add($"{colStatus}!='{SacsSystem.GetStatusCode(SaStatus.Deleted)}'");
|
||||
else if (prm.StatusCat == SbmAffiliate.StatusCat.DeletedOnly)
|
||||
filter.Add($"{colStatus}='{SacsSystem.GetStatusCode(SaStatus.Deleted)}'");
|
||||
}
|
||||
String statusCatCondition = GetAffiliateStatusCatFilterCondition(prm.StatusCat);
|
||||
if (!StringUtil.IsBlank(statusCatCondition))
|
||||
filter.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Status, aliasAffiliate)}{statusCatCondition}");
|
||||
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
}
|
||||
|
||||
internal static String GetAffiliateStatusCatFilterCondition(SbmAffiliate.StatusCat statusCat)
|
||||
{
|
||||
if (statusCat == SbmAffiliate.StatusCat.CurrentOnly)
|
||||
return $"='{StatusCurrent}'";
|
||||
else if (statusCat == SbmAffiliate.StatusCat.OnHoldOnly)
|
||||
return $"='{StatusOnHold}'";
|
||||
else if (statusCat == SbmAffiliate.StatusCat.NotDeleted)
|
||||
return $"!='{StatusDeleted}'";
|
||||
else if (statusCat == SbmAffiliate.StatusCat.DeletedOnly)
|
||||
return $"='{StatusDeleted}'";
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Affiliate sort columns.
|
||||
public List<String> GetAffiliateSortColumns(SbmAffiliate.Params prm)
|
||||
@@ -1029,7 +1035,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.ItemDocs;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - Associations - Utilities.
|
||||
//=======================================================================
|
||||
partial class SbmAccountMgr_Dbas
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
private List<StringPair> GetLogProperties(SbmAssociation association)
|
||||
{
|
||||
return new List<StringPair>()
|
||||
{
|
||||
new StringPair("Id",SysId.ToString(association.Id)),
|
||||
new StringPair("Code",association.Code),
|
||||
new StringPair("Status",association.StatusCode)
|
||||
};
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Association types in use.
|
||||
public override List<Sbm.AssociationType> GetAssociationTypesInUse()
|
||||
{
|
||||
List<Sbm.AssociationType> types = new List<Sbm.AssociationType>();
|
||||
String colAssociation_Type = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Association_Type);
|
||||
// Construct the query.
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association));
|
||||
qry.Columns.Add("DISTINCT " + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type), colAssociation_Type);
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + AffiliateId_Owner.ToString());
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery()))
|
||||
{
|
||||
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
types.Add((Sbm.AssociationType)values.GetValue(colAssociation_Type).AsLong());
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Internal associations.
|
||||
public override HashSet<SysId> GetInternalAssociationAffiliateIdsOwner()
|
||||
{
|
||||
ClearErrorState();
|
||||
HashSet<SysId> affiliateIdsOwner = new HashSet<SysId>();
|
||||
String colAffIdOwner = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Association_AffIdOwner);
|
||||
SbmAssociation.Params prmAssociation = new SbmAssociation.Params();
|
||||
prmAssociation.AssociationType = AssociationType.Internal;
|
||||
prmAssociation.StatusCat = SbmAssociation.StatusCat.Active;
|
||||
// Construct the query.
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasAssociation);
|
||||
qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type, aliasAssociation), colAffIdOwner);
|
||||
qry.Filters.AddRange(GetAssociationQueryFilter(prmAssociation));
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery()))
|
||||
{
|
||||
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
SysId affiliteIdOwner = new SysId(values.GetValue(colAffIdOwner).AsLong());
|
||||
if (SysId.IsValid(affiliteIdOwner))
|
||||
affiliateIdsOwner.Add(affiliteIdOwner);
|
||||
}
|
||||
}
|
||||
return affiliateIdsOwner;
|
||||
}
|
||||
|
||||
public override List<SysId> GetMemberTargetIds(SysId affiliateIdOwner)
|
||||
{
|
||||
List<SysId> affiliateIncludeIds = new List<SysId>();
|
||||
List<SysId> affiliateExcludeIds = new List<SysId>();
|
||||
return GetTargetIds(affiliateIdOwner, Sbm.AssociationType.Member, affiliateIncludeIds, affiliateExcludeIds);
|
||||
}
|
||||
public override List<SysId> GetCustomerTargetIds(List<SysId> affiliateIncludeIds, List<SysId> affiliateExcludeIds)
|
||||
{
|
||||
return GetTargetIds(AffiliateId_Owner, Sbm.AssociationType.Customer, affiliateIncludeIds, affiliateExcludeIds);
|
||||
}
|
||||
public List<SysId> GetTargetIds(SysId affiliateIdOwner, Sbm.AssociationType associationType, List<SysId> affiliateIncludeIds, List<SysId> affiliateExcludeIds)
|
||||
{
|
||||
List<SysId> affiliateIdsTarget = new List<SysId>();
|
||||
if (Database == null) return affiliateIdsTarget;
|
||||
bool validConfig = true;
|
||||
if (!SysId.IsValid(affiliateIdOwner) || (int)associationType < 1)
|
||||
{
|
||||
#if _DEBUG
|
||||
SATRACE("SapAssociationMgr_Odbc::GetTargetIds Invalid owner or association type.\n");
|
||||
#endif
|
||||
validConfig = false;
|
||||
}
|
||||
else if (associationType == Sbm.AssociationType.Customer || associationType == Sbm.AssociationType.Supplier)
|
||||
{
|
||||
if (affiliateIdOwner != AffiliateId_Owner)
|
||||
{
|
||||
#if _DEBUG
|
||||
SATRACE("SapAssociationMgr_Odbc::GetTargetIds Invalid customer/supplier owner.\n");
|
||||
#endif
|
||||
validConfig = false;
|
||||
}
|
||||
}
|
||||
if (validConfig)
|
||||
{
|
||||
String colAffiliateIdTarget = "AffIdTgt";
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association));
|
||||
qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget), colAffiliateIdTarget);
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + affiliateIdOwner.ToString());
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type) + "=" + ((int)associationType).ToString());
|
||||
if (affiliateIncludeIds.Count > 0)
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget) + " IN(" + affiliateIncludeIds.Concat(",") + ")");
|
||||
if (affiliateExcludeIds.Count > 0)
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget) + " NOT IN(" + affiliateExcludeIds.Concat(",") + ")");
|
||||
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString()))
|
||||
{
|
||||
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
affiliateIdsTarget.Add(new SysId(StringUtil.ToInt(values.GetValue(colAffiliateIdTarget))));
|
||||
}
|
||||
}
|
||||
}
|
||||
return affiliateIdsTarget;
|
||||
}
|
||||
public override List<SysId> GetCustomerAssocIdsForTargets(List<SysId> affiliateIdsTarget)
|
||||
{
|
||||
return GetAssocIdsForTargets(AffiliateId_Owner, Sbm.AssociationType.Customer, affiliateIdsTarget);
|
||||
}
|
||||
public override List<SysId> GetAssocIdsForTargets(SysId affiliateIdOwner, Sbm.AssociationType associationType, List<SysId> affiliateIdsTarget)
|
||||
{
|
||||
List<SysId> associations = new List<SysId>();
|
||||
if (Database == null) return associations;
|
||||
bool validConfig = true;
|
||||
if (!SysId.IsValid(affiliateIdOwner) || (int)associationType < 1)
|
||||
{
|
||||
#if _DEBUG
|
||||
SATRACE("SapAssociationMgr_Odbc::GetAssocIdsForTargets Invalid owner or association type.\n");
|
||||
#endif
|
||||
validConfig = false;
|
||||
}
|
||||
else if (associationType == Sbm.AssociationType.Customer || associationType == Sbm.AssociationType.Supplier)
|
||||
{
|
||||
if (affiliateIdOwner != AffiliateId_Owner)
|
||||
{
|
||||
#if _DEBUG
|
||||
SATRACE("SapAssociationMgr_Odbc::GetAssocIdsForTargets Invalid customer/supplier owner.\n");
|
||||
#endif
|
||||
validConfig = false;
|
||||
}
|
||||
}
|
||||
if (validConfig)
|
||||
{
|
||||
String colAssociationId = "AssocId";
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association));
|
||||
qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id), colAssociationId);
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + affiliateIdOwner.ToString());
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type) + "=" + ((int)associationType).ToString());
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget) + " IN " + affiliateIdsTarget.Concat(","));
|
||||
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString()))
|
||||
{
|
||||
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
associations.Add(new SysId(StringUtil.ToInt(values.GetValue(colAssociationId))));
|
||||
}
|
||||
}
|
||||
}
|
||||
return associations;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool AssociationHasTransactions(SysId associationId)
|
||||
{
|
||||
if (!SysId.IsValid(associationId)) return false;
|
||||
String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_AssocId)}={associationId}";
|
||||
return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), filter) > 0;
|
||||
}
|
||||
public override bool AssociationHasRequirements(SysId associationId)
|
||||
{
|
||||
if (!SysId.IsValid(associationId)) return false;
|
||||
String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_AssocId)}={associationId}";
|
||||
return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filter) > 0;
|
||||
}
|
||||
public override bool AssociationHasConstituents(SysId associationId)
|
||||
{
|
||||
if (!SysId.IsValid(associationId)) return false;
|
||||
String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_AssocId)}={associationId}";
|
||||
return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filter) > 0;
|
||||
}
|
||||
public override bool AssociationIsDeliveryContractor(SysId associationId)
|
||||
{
|
||||
// Is associated with transaction for delivery.
|
||||
if (!SysId.IsValid(associationId)) return false;
|
||||
String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_AssIdDeliver)}={associationId}";
|
||||
return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), filter) > 0;
|
||||
}
|
||||
public override bool ClearAssociationDependentData(SbmAssociation association, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (association == null || !SysId.IsValid(association.Id)) return false;
|
||||
|
||||
// Delete interface data items.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
if (InterfaceConsole != null)
|
||||
{
|
||||
if (!InterfaceConsole.ClearInterfaceDataItems(association.GetItemId(), DbUpdateInfo))
|
||||
SetErrorState("Failed to clear interface data items - " + InterfaceConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("failed to initialise interface console");
|
||||
}
|
||||
// Remove document references
|
||||
if (!HasErrorState())
|
||||
{
|
||||
if (ItemDocConsole != null)
|
||||
{
|
||||
if (!ItemDocConsole.ClearItemDocs(association.GetItemId(), DbUpdateInfo))
|
||||
SetErrorState(ItemDocConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item document console");
|
||||
}
|
||||
// Remove data item references.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
if (!DataItemMgr.ClearDataItem(association.GetItemId(), dbUpdateInfo))
|
||||
SetErrorState(DataItemMgr.ErrorStateMessage);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -16,6 +16,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
@@ -25,202 +26,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
partial class SbmAccountMgr_Dbas
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities - Association List Target.
|
||||
private List<StringPair> GetLogProperties(SbmAssociation association)
|
||||
{
|
||||
return new List<StringPair>()
|
||||
{
|
||||
new StringPair("Id",SysId.ToString(association.Id)),
|
||||
new StringPair("Code",association.Code),
|
||||
new StringPair("Status",association.StatusCode)
|
||||
};
|
||||
}
|
||||
|
||||
public override List<Sbm.AssociationType> GetAssociationTypesInUse()
|
||||
{
|
||||
List<Sbm.AssociationType> types = new List<Sbm.AssociationType>();
|
||||
// Construct the query.
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association));
|
||||
qry.Columns.Add("DISTINCT " + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type));
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + AffiliateId_Owner.ToString());
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString()))
|
||||
{
|
||||
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
types.Add((Sbm.AssociationType)values.GetValue(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Association_Type)).AsLong());
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
public override List<SysId> GetMemberTargetIds(SysId affiliateIdOwner)
|
||||
{
|
||||
List<SysId> affiliateIncludeIds = new List<SysId>();
|
||||
List<SysId> affiliateExcludeIds = new List<SysId>();
|
||||
return GetTargetIds(affiliateIdOwner, Sbm.AssociationType.Member, affiliateIncludeIds, affiliateExcludeIds);
|
||||
}
|
||||
public override List<SysId> GetCustomerTargetIds(List<SysId> affiliateIncludeIds, List<SysId> affiliateExcludeIds)
|
||||
{
|
||||
return GetTargetIds(AffiliateId_Owner, Sbm.AssociationType.Customer, affiliateIncludeIds, affiliateExcludeIds);
|
||||
}
|
||||
public List<SysId> GetTargetIds(SysId affiliateIdOwner, Sbm.AssociationType associationType, List<SysId> affiliateIncludeIds, List<SysId> affiliateExcludeIds)
|
||||
{
|
||||
List<SysId> affiliateIdsTarget = new List<SysId>();
|
||||
if (Database == null) return affiliateIdsTarget;
|
||||
bool validConfig = true;
|
||||
if (!SysId.IsValid(affiliateIdOwner) || (int)associationType < 1)
|
||||
{
|
||||
#if _DEBUG
|
||||
SATRACE("SapAssociationMgr_Odbc::GetTargetIds Invalid owner or association type.\n");
|
||||
#endif
|
||||
validConfig = false;
|
||||
}
|
||||
else if (associationType == Sbm.AssociationType.Customer || associationType == Sbm.AssociationType.Supplier)
|
||||
{
|
||||
if (affiliateIdOwner != AffiliateId_Owner)
|
||||
{
|
||||
#if _DEBUG
|
||||
SATRACE("SapAssociationMgr_Odbc::GetTargetIds Invalid customer/supplier owner.\n");
|
||||
#endif
|
||||
validConfig = false;
|
||||
}
|
||||
}
|
||||
if (validConfig)
|
||||
{
|
||||
String colAffiliateIdTarget = "AffIdTgt";
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association));
|
||||
qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget), colAffiliateIdTarget);
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + affiliateIdOwner.ToString());
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type) + "=" + ((int)associationType).ToString());
|
||||
if (affiliateIncludeIds.Count > 0)
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget) + " IN(" + affiliateIncludeIds.Concat(",") + ")");
|
||||
if (affiliateExcludeIds.Count > 0)
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget) + " NOT IN(" + affiliateExcludeIds.Concat(",") + ")");
|
||||
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString()))
|
||||
{
|
||||
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
affiliateIdsTarget.Add(new SysId(StringUtil.ToInt(values.GetValue(colAffiliateIdTarget))));
|
||||
}
|
||||
}
|
||||
}
|
||||
return affiliateIdsTarget;
|
||||
}
|
||||
public override List<SysId> GetCustomerAssocIdsForTargets(List<SysId> affiliateIdsTarget)
|
||||
{
|
||||
return GetAssocIdsForTargets(AffiliateId_Owner, Sbm.AssociationType.Customer, affiliateIdsTarget);
|
||||
}
|
||||
public override List<SysId> GetAssocIdsForTargets(SysId affiliateIdOwner, Sbm.AssociationType associationType, List<SysId> affiliateIdsTarget)
|
||||
{
|
||||
List<SysId> associations = new List<SysId>();
|
||||
if (Database == null) return associations;
|
||||
bool validConfig = true;
|
||||
if (!SysId.IsValid(affiliateIdOwner) || (int)associationType < 1)
|
||||
{
|
||||
#if _DEBUG
|
||||
SATRACE("SapAssociationMgr_Odbc::GetAssocIdsForTargets Invalid owner or association type.\n");
|
||||
#endif
|
||||
validConfig = false;
|
||||
}
|
||||
else if (associationType == Sbm.AssociationType.Customer || associationType == Sbm.AssociationType.Supplier)
|
||||
{
|
||||
if (affiliateIdOwner != AffiliateId_Owner)
|
||||
{
|
||||
#if _DEBUG
|
||||
SATRACE("SapAssociationMgr_Odbc::GetAssocIdsForTargets Invalid customer/supplier owner.\n");
|
||||
#endif
|
||||
validConfig = false;
|
||||
}
|
||||
}
|
||||
if (validConfig)
|
||||
{
|
||||
String colAssociationId = "AssocId";
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association));
|
||||
qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id), colAssociationId);
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + affiliateIdOwner.ToString());
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type) + "=" + ((int)associationType).ToString());
|
||||
qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget) + " IN " + affiliateIdsTarget.Concat(","));
|
||||
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString()))
|
||||
{
|
||||
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
associations.Add(new SysId(StringUtil.ToInt(values.GetValue(colAssociationId))));
|
||||
}
|
||||
}
|
||||
}
|
||||
return associations;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool AssociationHasTransactions(SysId associationId)
|
||||
{
|
||||
if (!SysId.IsValid(associationId)) return false;
|
||||
String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_AssocId)}={associationId}";
|
||||
return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), filter) > 0;
|
||||
}
|
||||
public override bool AssociationHasRequirements(SysId associationId)
|
||||
{
|
||||
if (!SysId.IsValid(associationId)) return false;
|
||||
String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_AssocId)}={associationId}";
|
||||
return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filter) > 0;
|
||||
}
|
||||
public override bool AssociationHasConstituents(SysId associationId)
|
||||
{
|
||||
if (!SysId.IsValid(associationId)) return false;
|
||||
String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_AssocId)}={associationId}";
|
||||
return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filter) > 0;
|
||||
}
|
||||
public override bool AssociationIsDeliveryContractor(SysId associationId)
|
||||
{
|
||||
// Is associated with transaction for delivery.
|
||||
if (!SysId.IsValid(associationId)) return false;
|
||||
String filter = $"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_AssIdDeliver)}={associationId}";
|
||||
return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), filter) > 0;
|
||||
}
|
||||
public override bool ClearAssociationDependentData(SbmAssociation association, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (association == null || !SysId.IsValid(association.Id)) return false;
|
||||
|
||||
// Delete interface data items.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
if (InterfaceConsole != null)
|
||||
{
|
||||
if (!InterfaceConsole.ClearInterfaceDataItems(association.GetItemId(), DbUpdateInfo))
|
||||
SetErrorState("Failed to clear interface data items - " + InterfaceConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("failed to initialise interface console");
|
||||
}
|
||||
// Remove document references
|
||||
if (!HasErrorState())
|
||||
{
|
||||
if (ItemDocConsole != null)
|
||||
{
|
||||
if (!ItemDocConsole.ClearItemDocs(association.GetItemId(), DbUpdateInfo))
|
||||
SetErrorState(ItemDocConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item document console");
|
||||
}
|
||||
// Remove data item references.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
if (!DataItemMgr.ClearDataItem(association.GetItemId(), dbUpdateInfo))
|
||||
SetErrorState(DataItemMgr.ErrorStateMessage);
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create Association.
|
||||
// Create Item.
|
||||
public override SbmAssociation CreateAssociation(SysId affiliateIdOwner, Sbm.AssociationType associationType, SysId affiliateIdTarget)
|
||||
{
|
||||
return new SbmAssociation_Dbas(null, affiliateIdOwner, associationType, affiliateIdTarget, 0);
|
||||
@@ -246,7 +52,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Associations found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmAssociation association = null;
|
||||
@@ -263,7 +69,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -365,7 +171,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -403,7 +209,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -436,7 +242,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -747,7 +553,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasAssociation;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmAssociation column definition.
|
||||
@@ -1789,20 +1595,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
filterTrans.Add(colTransaction_InProgress + "<" + DbQuery.FormatDateForCondition(DateUtil.IncrementDate(prm.TransactionActiveTo, 1)));
|
||||
}
|
||||
}
|
||||
// Check whether a Transaction status has been specified:
|
||||
String transtatuscatPending = TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Pending);
|
||||
String transtatuscatOpen = TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Open);
|
||||
String transtatuscatClosed = TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Closed);
|
||||
if (prm.TransactionStatusCat == SbmTransaction.StatusCat.NotDeleted)
|
||||
filterTrans.Add(colTransaction_Status + "<>'" + StatusDeleted + "'");
|
||||
else if (prm.TransactionStatusCat == SbmTransaction.StatusCat.Completed)
|
||||
filterTrans.Add(colTransaction_Status + "='" + TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Completed) + "'");
|
||||
else if (prm.TransactionStatusCat == SbmTransaction.StatusCat.NotClosed)
|
||||
filterTrans.Add(colTransaction_StatusCat + "<>'" + TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Closed) + "'");
|
||||
else if (prm.TransactionStatusCat == SbmTransaction.StatusCat.NotCancelled)
|
||||
filterTrans.Add(colTransaction_Status + "<>'" + StatusCancelled + "'");
|
||||
else if (!StringUtil.IsEmpty(TransactionStatusCats.GetCodeForType(prm.TransactionStatusCat)))
|
||||
filterTrans.Add(colTransaction_StatusCat + "='" + TransactionStatusCats.GetCodeForType(prm.TransactionStatusCat) + "'");
|
||||
// Transaction status.
|
||||
filterTrans.Add(SbmTransactionMgr_Dbas.GetTransactionStatusCatFilter(prm.TransactionStatusCat, "", TransactionStatusCats));
|
||||
filterTrans.RemoveBlanks();
|
||||
filterTrans.RemoveDuplicatesCI();
|
||||
if (!filterTrans.IsEmpty())
|
||||
{
|
||||
@@ -1864,12 +1659,32 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
|
||||
// Status.
|
||||
if (prm.StatusCat == SbmAssociation.StatusCat.Active)
|
||||
filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Status, aliasAssociation) + " = '" + StatusActive + "'");
|
||||
String statusCatCondition = GetAssociationStatusCatFilterCondition(prm.StatusCat);
|
||||
if (!StringUtil.IsBlank(statusCatCondition))
|
||||
filter.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Status, aliasAssociation)}{statusCatCondition}");
|
||||
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
}
|
||||
|
||||
internal static String GetAssociationStatusCatFilterCondition(SbmAssociation.StatusCat statusCat)
|
||||
{
|
||||
if (statusCat == SbmAssociation.StatusCat.CurrentOnly)
|
||||
return $"='{StatusCurrent}'";
|
||||
else if (statusCat == SbmAssociation.StatusCat.OnHoldOnly)
|
||||
return $"='{StatusOnHold}'";
|
||||
else if (statusCat == SbmAssociation.StatusCat.Active)
|
||||
return $" In('{StatusCurrent}','{StatusOnHold}')";
|
||||
else if (statusCat == SbmAssociation.StatusCat.DisabledOnly)
|
||||
return $"='{StatusDisabled}'";
|
||||
else if (statusCat == SbmAssociation.StatusCat.NotDeleted)
|
||||
return $"!='{StatusDeleted}'";
|
||||
else if (statusCat == SbmAssociation.StatusCat.DeletedOnly)
|
||||
return $"='{StatusDeleted}'";
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Association sort columns.
|
||||
public List<String> GetAssociationSortColumns(SbmAssociation.Params prm)
|
||||
{
|
||||
@@ -1927,7 +1742,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasAssociation);
|
||||
Association_Db dbAssociation = new Association_Db(DbInfo);
|
||||
qry.Columns.AddRange(dbAssociation.ExistingColumnNames);
|
||||
qry.Columns.AddRange(dbAssociation.ExistingColumnNames.Select(col => $"[{col}]"));
|
||||
qry.Filters.AddRange(GetAssociationQueryFilter(prm));
|
||||
qry.OrderBy.AddRange(GetAssociationSortColumns(prm));
|
||||
// Query data.
|
||||
@@ -1950,7 +1765,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Sys Params found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmSysParam sysParam = null;
|
||||
@@ -77,7 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -158,7 +158,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -191,7 +191,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -202,9 +202,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
dbSysParam._Cat = (short)sysparam.Category;
|
||||
dbSysParam._Name = sysparam.Name;
|
||||
dbSysParam._Value = sysparam.Value;
|
||||
dbSysParam._AffIdOwner = sysparam.AffiliateIdOwner.ToInt();
|
||||
dbSysParam._AffIdTarget = sysparam.AffiliateIdTarget.ToInt();
|
||||
dbSysParam._AssocId = sysparam.AssociationId.ToInt();
|
||||
dbSysParam._AffIdOwner = SysId.ToInt(sysparam.AffiliateIdOwner);
|
||||
dbSysParam._AffIdTarget = SysId.ToInt(sysparam.AffiliateIdTarget);
|
||||
dbSysParam._AssocId = SysId.ToInt(sysparam.AssociationId);
|
||||
// Common properties.
|
||||
//dbSysParam._Notes = sysparam.Notes;
|
||||
dbSysParam._Status = SacsSystem.GetStatusCode(sysparam.Status);
|
||||
@@ -250,7 +250,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasSysParam;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmSysParam column definition.
|
||||
@@ -455,7 +455,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple System Accounts found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmSystemAccount systemAccount = null;
|
||||
@@ -100,7 +100,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -181,7 +181,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -214,7 +214,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -282,7 +282,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasSystemAccount;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting SystemAccount column definition.
|
||||
@@ -504,7 +504,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple System Account Users found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmSystemAccountUser SystemAccountUser = null;
|
||||
@@ -77,7 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -153,7 +153,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -186,7 +186,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -242,7 +242,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasSystemAccountUser;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting SystemAccountUser column definition.
|
||||
@@ -475,7 +475,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple System Users found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmSystemUser SystemUser = null;
|
||||
@@ -80,7 +80,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -161,7 +161,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -194,7 +194,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -259,7 +259,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasSystemUser;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting SystemUser column definition.
|
||||
@@ -485,7 +485,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
else SetErrorState("Failed to retrieve interface console");
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -137,7 +137,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
}
|
||||
SetErrorState(ProcessMgr.ErrorStateMessage);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
public override bool PopulateAssetDefaultProcesses(SbmAsset asset)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
|
||||
// Store this list of processes against this asset.
|
||||
if (!HasErrorState()) StoreAssetProcesses(asset, itemProcesses);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -210,7 +210,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Store these details.
|
||||
if (!DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.ItemPrice, asset.GetItemId(), itemLinks, DbUpdateInfo))
|
||||
SetErrorState("Failed to save asset price item links - " + DataItemMgr.ErrorStateMessage);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -226,7 +226,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Assets found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmAsset asset = null;
|
||||
@@ -243,7 +243,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -305,7 +305,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -343,7 +343,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -376,7 +376,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -503,7 +503,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasAsset;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataCategoryId, align);
|
||||
if (dataCategoryId == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -798,7 +798,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
else SetErrorState("Failed to retrieve interface console");
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -96,7 +96,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
ClearErrorState();
|
||||
if (!ProcessMgr.UpdateProcessesForItem(assetCategory.GetItemId(), itemProcesses, dbUpdateInfo))
|
||||
SetErrorState(ProcessMgr.ErrorStateMessage);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -112,7 +112,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Asset Categories found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmAssetCategory assetCategory = null;
|
||||
@@ -129,7 +129,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -232,7 +232,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -270,7 +270,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -303,7 +303,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -382,7 +382,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = AliasAssetCategory;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmAssetCategory column definition.
|
||||
@@ -596,7 +596,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Asset Processes found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmAssetProcess assetProcess = null;
|
||||
@@ -66,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -166,7 +166,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -199,7 +199,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -256,7 +256,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasAssetProcess;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prmAssetProcess column definition.
|
||||
@@ -428,7 +428,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Vehicles found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmVehicle vehicle = null;
|
||||
@@ -67,7 +67,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -164,7 +164,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -197,7 +197,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -304,7 +304,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasVehicle;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prm column definition.
|
||||
@@ -647,7 +647,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Vehicle Classes found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmVehicleClass vehicleClass = null;
|
||||
@@ -145,7 +145,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -216,7 +216,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -254,7 +254,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -287,7 +287,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -372,7 +372,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasVehicleClass;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -648,7 +648,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Vehicle Events found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmVehicleEvent vehicleEvent = null;
|
||||
@@ -66,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -166,7 +166,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -199,7 +199,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -274,7 +274,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasVehicleEvent;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prm column definition.
|
||||
@@ -499,7 +499,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Vehicle Features found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmVehicleFeature vehicleFeature = null;
|
||||
@@ -160,7 +160,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -256,7 +256,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -289,7 +289,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -348,7 +348,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasVehicleFeature;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting prm column definition.
|
||||
@@ -548,7 +548,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,8 +199,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ProductCode), commodity.Code, true);
|
||||
Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filter.Concat(" And ", "(", ")"));
|
||||
if (Database.HasErrorState())
|
||||
SetErrorState($"{Database.ErrorStateMessage}.");
|
||||
return !HasErrorState();
|
||||
SetErrorState($"{Database.ErrorStateMessage.TrimEnd('.')}.");
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -279,7 +279,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (itemLinks != null)
|
||||
itemLinks.Clear();
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -315,7 +315,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (commodity.ItemProcesses != null) commodity.ItemProcesses.Clear();
|
||||
// Copy all items from the specified list.
|
||||
commodity.ItemProcesses = itemProcessesNew.Clone();
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
public override bool CommitCommodityProcesses(SbmCommodity commodity)
|
||||
{
|
||||
@@ -323,7 +323,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (commodity.ItemProcesses == null) return true;
|
||||
if (!ProcessMgr.StoreItemProcesses(commodity.GetItemId(), commodity.ItemProcesses, DbUpdateInfo))
|
||||
SetErrorState(ProcessMgr.ErrorStateMessage);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
public override bool UpdateReferencesToSalesTemplate(SbmCommodity commodity)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (commodity == null) return SetErrorState("item not specified");
|
||||
if (commodity == null) return SetErrorState(Msg_ItemNotSpecified);
|
||||
|
||||
// Build update query to refresh all commodities that refer to this template.
|
||||
List<String> filters = new List<String>();
|
||||
@@ -189,7 +189,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (Database.HasErrorState())
|
||||
SetErrorState($"{Database.ErrorStateMessage}");
|
||||
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -575,7 +575,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Commodities found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmCommodity commodity = null;
|
||||
@@ -592,7 +592,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -649,7 +649,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -687,7 +687,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -720,7 +720,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -1066,7 +1066,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasCommodity;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting Commodity column definition.
|
||||
@@ -2691,7 +2691,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
}
|
||||
else SetErrorState(msg_UnableToManageCommodityCustomers);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
public override bool StoreCommodityCustomersForCommodity(SysId commodityId, List<SbmCommodityCustomer> commodityCustomers)
|
||||
@@ -68,7 +68,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
List<SbmCommodityCustomer> commodityCustomersCopy = commodityCustomers;
|
||||
}
|
||||
else SetErrorState(msg_UnableToManageCommodityCustomers);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
public override bool StoreCommodityCustomersForCustomer(SysId assocIdCustomer, List<SbmCommodityCustomer> commodityCustomers)
|
||||
@@ -81,7 +81,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
List<SbmCommodityCustomer> commodityCustomersCopy = commodityCustomers;
|
||||
}
|
||||
else SetErrorState(msg_UnableToManageCommodityCustomers);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
public override bool Store(SbmCommodityCustomer commodityCustomer)
|
||||
@@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
}
|
||||
else SetErrorState(msg_UnableToManageCommodityCustomers);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
public override bool ClearCustomersForCommodity(SysId commodityId)
|
||||
@@ -126,7 +126,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
}
|
||||
else SetErrorState(msg_UnableToManageCommodityCustomers);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
public override bool ClearCommoditiesForCustomer(SysId assocCustomerId)
|
||||
@@ -143,7 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
}
|
||||
else SetErrorState(msg_UnableToManageCommodityCustomers);
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -159,7 +159,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Commodity Customer found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmCommodityCustomer prmCommodityCustomer = null;
|
||||
@@ -176,7 +176,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -265,7 +265,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -298,7 +298,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -365,7 +365,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasCommodityCustomer;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
public override ColumnDfn GetCommodityCustomerColumnDfn(SbmCommodityCustomer.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
@@ -614,7 +614,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Commodity Suppliers found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmCommoditySupplier commoditySupplier = null;
|
||||
@@ -69,7 +69,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
foreach (SbmCommoditySupplier commoditySupplier in commoditySuppliers)
|
||||
{
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
public override bool Store(SbmCommoditySupplier commoditySupplier)
|
||||
@@ -118,7 +118,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (Database != null && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier)))
|
||||
{
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -142,7 +142,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -180,7 +180,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -213,7 +213,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -276,7 +276,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasCommoditySupplier;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
public override ColumnDfn GetCommoditySupplierColumnDfn(SbmCommoditySupplier.Column columnId, string caption = "", int width = 0)
|
||||
{
|
||||
@@ -515,7 +515,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Container found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmContainer container = null;
|
||||
@@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -203,7 +203,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -236,7 +236,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -310,7 +310,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasContainer;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting Container column definition.
|
||||
@@ -602,7 +602,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple ContainerItem found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmContainerItem containerItem = null;
|
||||
@@ -101,7 +101,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -190,7 +190,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -223,7 +223,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -300,7 +300,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasContainerItem;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting ContainerItem column definition.
|
||||
@@ -684,7 +684,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Internal;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog;
|
||||
@@ -16,7 +15,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
{
|
||||
@@ -236,7 +234,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (!UpdatePortfolioItem(portfolioItem, DbUpdateInfo))
|
||||
SetErrorState(ErrorStateMessage);
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -297,7 +295,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (Database.HasErrorState())
|
||||
return SetErrorState(Database.ErrorStateMessage);
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -327,7 +325,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Portfolio Items found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmPortfolioItem portfolioItem = null;
|
||||
@@ -344,7 +342,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -390,7 +388,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -431,7 +429,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -507,7 +505,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Update the item's sequence.
|
||||
portfolioItem.Sequence = sequencePrev;
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
public override bool MoveItemDown(SbmPortfolioItem portfolioItem, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
@@ -563,7 +561,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Update the item's sequence.
|
||||
portfolioItem.Sequence = sequenceNext;
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -599,7 +597,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -671,7 +669,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasPortfolioItem;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting PortfolioItem column definition.
|
||||
@@ -986,7 +984,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Item Batches found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmItemBatch itemBatch = null;
|
||||
@@ -63,7 +63,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -163,7 +163,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -196,7 +196,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -255,7 +255,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasItemBatch;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -443,7 +443,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
SATRACE("\nSapDataItemMgr_Odbc::DoDbCleanup\n\tParent items found: " + String(iParentItemsFound) + "\n\tRows modified: " + String(iRowsModified) + "\n\n");
|
||||
//---------------------------------------------------------------
|
||||
}*/
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -145,7 +145,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
return SetErrorState($"Failed to store associated items - {DataItemMgr.ErrorStateMessage}");
|
||||
}
|
||||
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
if (count == 0) return null;
|
||||
if (count != 1)
|
||||
{
|
||||
SetErrorState("Multiple Item Links found");
|
||||
SetErrorState(Msg_MultipleItemsFound);
|
||||
return null;
|
||||
}
|
||||
SbmItemLink itemLink = null;
|
||||
@@ -51,7 +51,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -161,7 +161,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -222,7 +222,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
else SetErrorState("failed to add link");
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
public override bool StoreToItemLinks(Sbm.ItemLinkType itemLinkType, ItemId itemIdTo, List<SbmItemLink> itemLinks, DbUpdateInfo dbUpdateInfo)
|
||||
@@ -274,7 +274,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
else SetErrorState("failed to add link");
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -307,7 +307,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc) { SetErrorState(exc.Message); }
|
||||
}
|
||||
return !HasErrorState();
|
||||
return OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -370,7 +370,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
alias = aliasItemLink;
|
||||
col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align);
|
||||
if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown)
|
||||
col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol);
|
||||
col.MaxLength = (int)Internals.GetColTextLen(dbCol);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Getting ItemLink column definition.
|
||||
@@ -567,7 +567,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SetErrorState("Database query exception");
|
||||
SetErrorState(Msg_DatabaseQueryException);
|
||||
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user