Portal application - initial.
This commit is contained in:
@@ -16,75 +16,32 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmUserContext userContext;
|
||||
private class Managers
|
||||
{
|
||||
public SbmDataItemMgr DataItemMgr { get; set; }
|
||||
public SbmProcessMgr ProcessMgr { get; set; }
|
||||
public SbmStockMgr StockMgr { get; set; }
|
||||
public SbmTransactionMgr TransactionMgr { get; set; }
|
||||
}
|
||||
private readonly Managers mgrs = new Managers();
|
||||
private readonly SbmInternals internals;
|
||||
private readonly String statusCancelled = SacsSystem.GetStatusCode(SaStatus.Cancelled);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmRequirement_Dbas(SbmUserContext userContext, SysId id, SysId affIdOwner, SysId assocId, SysId transId, Sbm.RequirementType requirementType, ushort flags) :
|
||||
base(userContext, id, affIdOwner, assocId, transId, requirementType)
|
||||
public SbmRequirement_Dbas(SbmInternals internals, SysId id, SysId affIdOwner, SysId assocId, SysId transId, Sbm.RequirementType requirementType, ushort flags) :
|
||||
base(internals.UserContext, id, affIdOwner, assocId, transId, requirementType)
|
||||
{
|
||||
this.userContext = userContext;
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (mgrs.StockMgr != null) mgrs.StockMgr.Dispose();
|
||||
if (mgrs.TransactionMgr != null) mgrs.TransactionMgr.Dispose();
|
||||
if (mgrs.ProcessMgr != null) mgrs.ProcessMgr.Dispose();
|
||||
if (mgrs.DataItemMgr != null) mgrs.DataItemMgr.Dispose();
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
private SbmTransactionMgr TransactionMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgrs.TransactionMgr == null)
|
||||
mgrs.TransactionMgr = SbmGlobals.System.CreateTransactionMgr(userContext);
|
||||
return mgrs.TransactionMgr;
|
||||
}
|
||||
}
|
||||
private SbmDataItemMgr DataItemMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgrs.DataItemMgr == null)
|
||||
mgrs.DataItemMgr = SbmGlobals.System.CreateDataItemMgr(userContext);
|
||||
return mgrs.DataItemMgr;
|
||||
}
|
||||
}
|
||||
private SbmProcessMgr ProcessMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgrs.ProcessMgr == null)
|
||||
mgrs.ProcessMgr = SbmGlobals.System.CreateProcessMgr(userContext);
|
||||
return mgrs.ProcessMgr;
|
||||
}
|
||||
}
|
||||
private SbmStockMgr StockMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgrs.StockMgr == null)
|
||||
mgrs.StockMgr = SbmGlobals.System.CreateStockMgr(userContext);
|
||||
return mgrs.StockMgr;
|
||||
}
|
||||
}
|
||||
private SbmTransactionMgr TransactionMgr { get { return internals.TransactionMgr; } }
|
||||
private SbmDataItemMgr DataItemMgr { get { return internals.DataItemMgr; } }
|
||||
private SbmProcessMgr ProcessMgr { get { return internals.ProcessMgr; } }
|
||||
private SbmStockMgr StockMgr { get { return internals.StockMgr; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
@@ -148,7 +105,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
}
|
||||
public override decimal GetQuantityDispatched(SysId transIdExclude)
|
||||
{
|
||||
ISacsDatabase db = SbmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (SysId.IsValid(Id))
|
||||
{
|
||||
// Build query to sum associated dispatch item quantities.
|
||||
@@ -179,7 +136,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
//-------------------------------------------------------------------
|
||||
public override decimal GetQuantityInvoiced(SysId transIdExclude)
|
||||
{
|
||||
ISacsDatabase db = SbmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (SysId.IsValid(Id))
|
||||
{
|
||||
// Build query to sum associated dispatch item quantities.
|
||||
@@ -263,7 +220,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
}
|
||||
}
|
||||
// Store these details.
|
||||
if (!DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.Requirement_CostEstimate, Sbm.ItemType.Requirement, Id, itemLinks, userContext.DbUpdateInfo))
|
||||
if (!DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.Requirement_CostEstimate, Sbm.ItemType.Requirement, Id, itemLinks, internals.DbUpdateInfo))
|
||||
SetErrorState("Failed to save cost estimate item links - " + DataItemMgr.ErrorState);
|
||||
if (itemLinks != null)
|
||||
itemLinks.Clear();
|
||||
@@ -319,7 +276,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
// Update the details.
|
||||
CopyFrom(itemProcessLocal, constituent);
|
||||
if (TransactionMgr.UpdateConstituent(constituent, userContext.DbUpdateInfo))
|
||||
if (TransactionMgr.UpdateConstituent(constituent, internals.DbUpdateInfo))
|
||||
itemProcessLocal.Changed = false;
|
||||
else SetErrorState("failed to update process constituent");
|
||||
}
|
||||
@@ -330,7 +287,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
// Process no longer required.
|
||||
constituent.Status = SaStatus.Cancelled;
|
||||
if (!TransactionMgr.DeleteConstituent(constituent, userContext.DbUpdateInfo))
|
||||
if (!TransactionMgr.DeleteConstituent(constituent, internals.DbUpdateInfo))
|
||||
SetErrorState("failed to delete process constituent");
|
||||
}
|
||||
}
|
||||
@@ -347,7 +304,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
constituent.RequirementId = Id;
|
||||
CopyFrom(itemprocess, constituent);
|
||||
// Add it to the database:
|
||||
if (TransactionMgr.InsertConstituent(constituent, userContext.DbUpdateInfo))
|
||||
if (TransactionMgr.InsertConstituent(constituent, internals.DbUpdateInfo))
|
||||
itemprocess.Changed = false;
|
||||
else SetErrorState("failed to add constituent - " + TransactionMgr.ErrorState);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user