107 lines
3.7 KiB
C#
107 lines
3.7 KiB
C#
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.Core;
|
|
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.ItemOptions;
|
|
using Sarand.Net.Standard.Base.ReferenceData;
|
|
using Sarand.Net.Standard.Base.Security;
|
|
using Sarand.Net.Standard.Base.UpdateLog;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control
|
|
{
|
|
//=======================================================================
|
|
public abstract class SbmcControlMgr : SbmItemMgr
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private SbmInternals_Control internals = null;
|
|
|
|
//-------------------------------------------------------------------
|
|
// Static initialisation.
|
|
static SbmcControlMgr()
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SbmcControlMgr()
|
|
{
|
|
}
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
if (internals != null) internals.Dispose();
|
|
internals = null;
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
protected SbmInternals_Control Internals_Control { get { if (internals == null) internals = new SbmInternals_Control(); return internals; } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Control managers.
|
|
protected SbmcAccountMgr ControlAccountMgr { get { return Internals_Control.ControlAccountMgr; } }
|
|
protected SbmcInstanceMgr ControlInstanceMgr { get { return Internals_Control.ControlInstanceMgr; } }
|
|
protected SbmcItemMgr ControlItemMgr { get { return Internals_Control.ControlItemMgr; } }
|
|
|
|
//-------------------------------------------------------------------
|
|
/// <summary>
|
|
/// Get suitable display test to identity Control data item.
|
|
/// </summary>
|
|
/// <param name="itemId"></param>
|
|
/// <returns></returns>
|
|
public String GetItemCaption(ItemId itemId)
|
|
{
|
|
if (ItemId.IsValid(itemId))
|
|
{
|
|
// Record disposable items as they are created so all can be disposed when needed.
|
|
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
|
{
|
|
if (itemId.Type == (short)SbmcHierarchyItem.ItemType.UserAccount)
|
|
{
|
|
SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountById(itemId.Id);
|
|
disposables.Add(userAccount);
|
|
if (userAccount != null)
|
|
return userAccount.GetDisplayName();
|
|
return $"UserAccount #{itemId.Id}";
|
|
}
|
|
if (itemId.Type == (short)SbmcHierarchyItem.ItemType.Owner)
|
|
{
|
|
SbmcOwner owner = ControlInstanceMgr.GetOwnerById(itemId.Id);
|
|
disposables.Add(owner);
|
|
if (owner != null)
|
|
return owner.Name;
|
|
return $"Owner #{itemId.Id}";
|
|
}
|
|
if (itemId.Type == (short)SbmcHierarchyItem.ItemType.Repository)
|
|
{
|
|
SbmcRepository repository = ControlInstanceMgr.GetRepositoryById(itemId.Id);
|
|
disposables.Add(repository);
|
|
if (repository != null)
|
|
return repository.Context;
|
|
return $"Repository #{itemId.Id}";
|
|
}
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|