Add project files.
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
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.Interfaces;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
class SbmAssetCategory_Dbas : SbmAssetCategory
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmUserContext userContext;
|
||||
private SbmProcessMgr processMgr;
|
||||
private List<SbmItemProcess> itemProcesses = new List<SbmItemProcess>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmAssetCategory_Dbas(SbmUserContext userContext, SysId id, SysId affIdOwner, Sbm.AssetType assetType, ushort flags) :
|
||||
base(userContext, id)
|
||||
{
|
||||
this.userContext = userContext;
|
||||
Id = id;
|
||||
AffIdOwner = affIdOwner;
|
||||
AssetType = assetType;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (processMgr != null) processMgr.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Internal Processing.
|
||||
public bool InitProcMgr()
|
||||
{
|
||||
if (processMgr == null)
|
||||
processMgr = SbmGlobals.System.CreateProcessMgr(userContext);
|
||||
return (processMgr != null);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool HasProcesses()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return SetErrorState("invalid item");
|
||||
if (processMgr == null) return SetErrorState("process manager not available");
|
||||
return false;// processMgr.ItemHasProcesses(Sbm.ItemType.Asset, Id);
|
||||
}
|
||||
|
||||
public override bool HasAssets()
|
||||
{
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = SbmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||
if (db != null)
|
||||
{
|
||||
String tableAsset = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset);
|
||||
if (db.TableExists(tableAsset))
|
||||
{
|
||||
String columnSaAsset_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAsset_Id);
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId) + "=" + Id.ToString());
|
||||
if (db.GetRowCount(tableAsset, filter.Concat(" AND ", "(", ")")) > 0) return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool ClearDependentData()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (this == null || !SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = SbmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||
if (db != null && !HasErrorState())
|
||||
{
|
||||
if (!HasErrorState())
|
||||
{
|
||||
/* ToDo SaItemDocConsole for Remove document references:
|
||||
SaItemDocConsole itemDocConsole = SbmGlobals.Application.GetItemDocConsole(SessionContext);
|
||||
if (itemDocConsole != null)
|
||||
{
|
||||
if (!itemDocConsole.ClearItemDocs(Sbm.ItemType.AssetCategory, Id))
|
||||
SetErrorState(itemDocConsole.Exception());
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item document console");
|
||||
itemDocConsole = null;*/ // Do not delete this global object.
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
/* ToDo SaItemDataConsole for Remove Item Data:
|
||||
SaItemDataConsole itemDataConsole = SbmGlobals.Application.GetItemDataConsole(SessionContext);
|
||||
if (itemDataConsole != null)
|
||||
{
|
||||
if (!itemDataConsole.ClearItemData(Sbm.ItemType.AssetCategory, Id, ""))
|
||||
SetErrorState(itemDataConsole.Exception());
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item Dataument console");
|
||||
itemDataConsole = null;*/ // Do not delete this global object.
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
// Remove interface data items:
|
||||
SaInterfaceConsole interfaceConsole = SbmGlobals.Application.GetInterfaceConsole(userContext);
|
||||
//DbUpdateInfo dbUpdateInfo = userContext.DbUpdateInfo;
|
||||
if (interfaceConsole != null)
|
||||
{
|
||||
if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.AssetCategory, Id), userContext.DbUpdateInfo))
|
||||
SetErrorState(interfaceConsole.ErrorState.ToString());
|
||||
}
|
||||
else SetErrorState("Failed to retrieve interface console");
|
||||
interfaceConsole = null; // Do not delete this global object.
|
||||
}
|
||||
}
|
||||
else SetErrorState("database is unavailable");
|
||||
return !HasErrorState();
|
||||
}
|
||||
// AssetCategory processes.
|
||||
public override List<SbmItemProcess> GetProcesses(bool activeOnly)
|
||||
{
|
||||
ClearErrorState();
|
||||
List<SbmItemProcess> itemProcesesCopy = null;
|
||||
if (activeOnly)
|
||||
{
|
||||
// Retrieve the list of 'active' processes for this item.
|
||||
processMgr.GetProcessesForItem(Sbm.ItemType.AssetCategory, Id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Full list required - check whether the internal list has been populated yet.
|
||||
if (itemProcesses == null && SysId.IsValid(Id) && processMgr != null)
|
||||
{
|
||||
// Get the list of processes:
|
||||
processMgr.GetProcessesForItem(Sbm.ItemType.AssetCategory, Id, false);
|
||||
}
|
||||
// Clone the list.
|
||||
itemProcesesCopy = itemProcesses.Clone();
|
||||
}
|
||||
if (itemProcesesCopy != null) itemProcesesCopy.Sort();
|
||||
return itemProcesesCopy;
|
||||
}
|
||||
public override bool SetProcesses(List<SbmItemProcess> itemProcessesNew)
|
||||
{
|
||||
ClearErrorState();// Clear the existing list.
|
||||
if (itemProcesses != null) itemProcesses.Clear();
|
||||
// Copy all items from the specified list.
|
||||
itemProcesses = itemProcessesNew.Clone();
|
||||
return !HasErrorState();
|
||||
}
|
||||
public override bool CommitProcesses()
|
||||
{
|
||||
ClearErrorState();
|
||||
/*if (!processMgr.UpdateProcessesForItem(Sbm.ItemType.AssetCategory, Id, itemProcesses))
|
||||
SetErrorState(processMgr.ErrorState.ToString());*/
|
||||
return !HasErrorState();
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user