Files
OperationsMgr-CSharp/SaOperationsMgrWeb/Web/Consoles/OpnInterfaceConsole_Web.cs
T
2020-03-06 16:07:06 +00:00

143 lines
5.3 KiB
C#

using Sarand.Core.Base;
using Sarand.Core.Bus;
using Sarand.Core.Dbas.Base;
using Sarand.Core.Interfaces;
using Sarand.Core.ItemOptions;
using Sarand.Core.Procs;
using Sarand.OperationsMgr.App.Consoles;
using Sarand.OperationsMgr.Core.App;
using Sarand.OperationsMgr.Win.Consoles;
using Sarand.OperationsMgr.Win.Interfaces;
using Sarand.Win.Dbas.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Sarand.OperationsMgr.Web.Consoles
{
//=======================================================================
public class OpnInterfaceConsole_Web : OpnInterfaceConsole_Dbas
{
//-------------------------------------------------------------------
// Data members.
//private List<TypeCodeDesc> dataItemTypes = OpnSystem.GetCodesOfType(Opn.SystemCode.DataItemType);
//-------------------------------------------------------------------
// Construction.
public OpnInterfaceConsole_Web (OpnSessionContext sessionContext, SacsDatabase database) :
base(null)
{
Database = database;
}
//-------------------------------------------------------------------
// Properties.
internal Opn.Instance Instance { get { return SessionContext.Instance; } }
internal SacsDatabase Database { get; }
//-------------------------------------------------------------------
// Method to display Interface management form.
protected override MaintainInterfacesFunction MaintainInterfacesFn
{
get
{
return null;
}
}
//---------------------------------------------------------------
// Interface item option definitions.
public override List<SaItemOptionDfn> GetInterfaceItemOptionDfns (SaInterfaceCategory interfaceCategory, short interfaceType)
{
return OpnProcessConsole.GetInterfaceItemOptionDfns(interfaceCategory, interfaceType);
}
public override List<SaItemOptionDfn> GetInterfaceItemOptionDfns (SysId interfaceId)
{
SaInterface interfaceObj = GetInterfaceById(interfaceId);
if (interfaceObj != null)
return OpnProcessConsole.GetInterfaceItemOptionDfns(interfaceObj.Category, interfaceObj.Type);
return new List<SaItemOptionDfn>();
}
//-------------------------------------------------------------------
// I n t e r f a c e A c c e s s C o n t r o l
//-------------------------------------------------------------------
//---------------------------------------------------------------
// P r o c e s s i n g O p t i o n s
//---------------------------------------------------------------
private List<SacsProcess.GroupData> GetProcessingOptions (SaInterface interfaceObj)
{
if (interfaceObj != null && SysId.IsValid(interfaceObj.Id))
{
switch (interfaceObj.Category)
{
case SaInterfaceCategory.System:
return GetProcessingOptions_System(interfaceObj);
}
}
return new List<SacsProcess.GroupData>();
}
private List<SacsProcess.GroupData> GetProcessingOptions_System (SaInterface interfaceObj)
{
if (interfaceObj.Category != SaInterfaceCategory.System) throw new NotSupportedException("Invalid interface category: " + interfaceObj.Category.ToString() + ". Expected: System");
List<SacsProcess.GroupData> optionGroups = null;
//switch ((Opn.InterfaceType)interfaceObj.Type)
//{
//}
return optionGroups ?? new List<SacsProcess.GroupData>();
}
//---------------------------------------------------------------
// P r o c e s s I n t e r f a c e
//---------------------------------------------------------------
/// <summary>
/// Interface can only be 'processed' if it defines processing options.
/// </summary>
/// <param name="interfaceObj"></param>
/// <returns></returns>
public override bool CanProcessInterface (SaInterface interfaceObj)
{
return (GetProcessingOptions(interfaceObj).Count > 0);
}
/// <summary>
/// Popup form to select options for processing interface.
/// </summary>
/// <param name="interfaceObj"></param>
/// <returns></returns>
public override bool ProcessInterface (SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
{
return false;
}
private OpnInterfaceProcess ConfigureProcess (SaInterface interfaceObj, SacsProcess.GroupData processGroup, DbUpdateInfo dbUpdateInfo)
{
switch (interfaceObj.Category)
{
case SaInterfaceCategory.System:
return ConfigureProcess_System(interfaceObj, processGroup, dbUpdateInfo);
}
return null;
}
private OpnInterfaceProcess ConfigureProcess_System (SaInterface interfaceObj, SacsProcess.GroupData processGroup, DbUpdateInfo dbUpdateInfo)
{
if (interfaceObj.Category != SaInterfaceCategory.System) throw new NotSupportedException("Invalid interface category: " + interfaceObj.Category.ToString() + ". Expected: System");
//switch ((Opn.InterfaceType)interfaceObj.Type)
//{
//}
return null;
}
public override bool AreMultipleInterfaceInstancesAllowed (string context, SaInterfaceCategory interfaceCategory, short interfaceType)
{
throw new NotImplementedException();
}
public override bool AreMultipleActiveInterfacesAllowed (string context, SaInterfaceCategory interfaceCategory)
{
throw new NotImplementedException();
}
//-------------------------------------------------------------------
}
//=======================================================================
}