83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
///
|
|
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Common
|
|
{
|
|
/// <summary>
|
|
/// Contains a procedure name and procedure selection source specification
|
|
/// (local/shared/order from Oracle/order from tracing DB)
|
|
/// </summary>
|
|
public class ProcedureInfo
|
|
{
|
|
public readonly ProcedureSelection Source;
|
|
public int ItemNr;
|
|
public readonly string Name;
|
|
public readonly string Signature;
|
|
public string Variant;
|
|
public IOrderInfo OrderInfo;
|
|
public string Workflow;
|
|
public string LaserMarking;
|
|
public bool IsNative;
|
|
public ProcedureSelection ResolvedSource; /// ProcedureSelection.FromLocalDB or ProcedureSelection.FromSharedDB when Resolved==true
|
|
public string ResolvedName;
|
|
|
|
public ProcedureInfo(ProcedureSelection source, int itemNr, string name, string signature = null,
|
|
string variant = null, IOrderInfo orderInfo = null, string workflow = null, string laserMarking = null)
|
|
{
|
|
Source = source;
|
|
ItemNr = itemNr;
|
|
Name = name;
|
|
Signature = (signature == null) ? string.Empty : signature;
|
|
Variant = (variant == null) ? string.Empty : variant;
|
|
OrderInfo = orderInfo;
|
|
Workflow = workflow;
|
|
LaserMarking = laserMarking;
|
|
|
|
if (source == ProcedureSelection.FromLocalDB || source == ProcedureSelection.FromSharedDB)
|
|
{
|
|
IsNative = true;
|
|
ResolvedSource = source;
|
|
ResolvedName = name;
|
|
}
|
|
else
|
|
{
|
|
IsNative = false;
|
|
ResolvedSource = ProcedureSelection.None;
|
|
ResolvedName = string.Empty;
|
|
}
|
|
}
|
|
|
|
public static string GetSignature(ProcedureSelection source, ICollection<ProcedureSelection> allSources)
|
|
{
|
|
return (source == ProcedureSelection.OrderFromOracleDB) ? ""
|
|
: (source == ProcedureSelection.OrderFromTracingDB) ? ""
|
|
: (source == ProcedureSelection.FromSharedDB) ? "R"
|
|
: (allSources != null && allSources.Contains(ProcedureSelection.FromSharedDB)) ? "L" : "";
|
|
}
|
|
|
|
public bool IsValid
|
|
{
|
|
get {
|
|
return (ResolvedSource != ProcedureSelection.None) && !string.IsNullOrEmpty(ResolvedName);
|
|
}
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
switch (Source)
|
|
{
|
|
case ProcedureSelection.OrderFromOracleDB:
|
|
case ProcedureSelection.OrderFromTracingDB:
|
|
return Name;
|
|
case ProcedureSelection.FromSharedDB:
|
|
case ProcedureSelection.FromLocalDB:
|
|
default:
|
|
return string.Format("{0}{1} {2}", Signature, ItemNr, Name);
|
|
}
|
|
}
|
|
}
|
|
}
|