inital
This commit is contained in:
146
FasdDesktopUi/Config/C4IT.FASD.CustomDialogConfig.cs
Normal file
146
FasdDesktopUi/Config/C4IT.FASD.CustomDialogConfig.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.XML;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Config
|
||||
{
|
||||
public class cF4SDCustomDialogConfig : cFasdBaseConfig, IXmlConfigNode
|
||||
{
|
||||
private const string constFileNameFasdConfig = "F4SD-CustomDialog-Configuration.xml";
|
||||
private const string constFileNameFasdConfigSchema = "F4SD-CustomDialog-Configuration.xsd";
|
||||
private const string constConfigRootElement = "F4SD-CustomDialog-Configuration";
|
||||
|
||||
public static cF4SDCustomDialogConfig Instance { get; set; }
|
||||
|
||||
public IXmlConfigNode ParentNode { get; set; }
|
||||
|
||||
public Dictionary<string, cHealthCardComputationBase> GlobalComputations { get; set; } = new Dictionary<string, cHealthCardComputationBase>();
|
||||
public Dictionary<string, cHealthCardStateContainer> CustomDialogContainers { get; set; } = new Dictionary<string, cHealthCardStateContainer>();
|
||||
|
||||
public cF4SDCustomDialogConfig()
|
||||
: base(constFileNameFasdConfig, constFileNameFasdConfigSchema, constConfigRootElement)
|
||||
{ }
|
||||
|
||||
public override bool InstantiateProperties(XmlElement RootElement, cXmlParser Parser)
|
||||
{
|
||||
bool output = false;
|
||||
try
|
||||
{
|
||||
if (RootElement is null || Parser is null)
|
||||
return false;
|
||||
|
||||
GlobalComputations = cF4SDHealthCardConfig.GetComputationsOfNode(RootElement, Parser, "Global-Computations");
|
||||
|
||||
var customDialogsNode = RootElement.SelectSingleNode("CustomDialogs");
|
||||
|
||||
if (customDialogsNode != null && customDialogsNode is XmlElement customDialogsElement)
|
||||
{
|
||||
Parser.EnterElement("CustomDialogs");
|
||||
|
||||
var stateContainerNodes = customDialogsElement.SelectNodes("State-Container");
|
||||
if (stateContainerNodes != null)
|
||||
{
|
||||
Parser.EnterElement("State-Container");
|
||||
|
||||
foreach (var stateContainerNode in stateContainerNodes)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(stateContainerNode is XmlElement stateContainerElement))
|
||||
continue;
|
||||
|
||||
var tempStateContainer = new cHealthCardStateContainer(stateContainerElement, Parser, this);
|
||||
|
||||
if (tempStateContainer is null || tempStateContainer.IsValid is false)
|
||||
continue;
|
||||
|
||||
if(string.IsNullOrEmpty(tempStateContainer.Name))
|
||||
{
|
||||
Parser.AddInvalidAttribute(stateContainerElement, null, "Name", C4IT.Logging.LogLevels.Warning);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CustomDialogContainers.ContainsKey(tempStateContainer.Name))
|
||||
Parser.AddDuplicateName(stateContainerElement, tempStateContainer.Name, C4IT.Logging.LogLevels.Warning);
|
||||
else
|
||||
CustomDialogContainers.Add(tempStateContainer.Name, tempStateContainer);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Parser.SelectElementNext();
|
||||
}
|
||||
}
|
||||
Parser.LeaveElement("State-Container");
|
||||
}
|
||||
|
||||
Parser.LeaveElement("CustomDialogs");
|
||||
}
|
||||
|
||||
output = true;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public HashSet<string> GetRequiredTables(List<enumFasdInformationClass> informationClasses)
|
||||
{
|
||||
HashSet<string> output = new HashSet<string>();
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var customDialog in CustomDialogContainers.Values
|
||||
.Where(dialog => dialog.InformationClasses?.Count == 0
|
||||
|| informationClasses.All(informationClass => dialog.InformationClasses.Contains(informationClass))))
|
||||
{
|
||||
foreach (var state in customDialog.StateContainerElements)
|
||||
{
|
||||
state.GetRequiredTables().ForEach(table => output.Add(table));
|
||||
}
|
||||
}
|
||||
|
||||
//Get all tables which are required for computations
|
||||
string computationPrefix = "Computation_";
|
||||
while (output.Any(tableName => tableName.StartsWith(computationPrefix)))
|
||||
{
|
||||
string tableName = output.First(name => name.StartsWith(computationPrefix));
|
||||
|
||||
string computationName = tableName.Substring(computationPrefix.Length);
|
||||
var computation = cF4SDHealthCardConfig.GetComputationsWithName(this, computationName);
|
||||
|
||||
if (computation?.Values?.Length > 0)
|
||||
{
|
||||
foreach (var computationValue in computation.Values)
|
||||
{
|
||||
if (computationValue.ValueTable != null)
|
||||
output.Add(computationValue.ValueTable);
|
||||
}
|
||||
}
|
||||
|
||||
output.Remove(tableName);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
FasdDesktopUi/Config/F4SD-CustomDialog-Configuration.xml
Normal file
33
FasdDesktopUi/Config/F4SD-CustomDialog-Configuration.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<F4SD-CustomDialog-Configuration>
|
||||
<Global-Computations>
|
||||
<Computation-Constant Name="ForwardTicket" Value="Forward ticket">
|
||||
<Value Lang="DE">Ticket weiterleiten</Value>
|
||||
</Computation-Constant>
|
||||
</Global-Computations>
|
||||
|
||||
<CustomDialogs>
|
||||
|
||||
<!--<State-Container Name="ForwardTicket" InformationClass="Ticket">
|
||||
<State-Stylable ValueTable="Computation_ForwardTicket" ValueColumn="default" />
|
||||
|
||||
<State-Editable ValueTable="M42Wpm-Ticket" ValueColumn="ResponsibleRole" Name="Responsible role">
|
||||
<Name Lang="DE">Verantwortliche Rolle</Name>
|
||||
<Editable-Selection SelectionTable="M42Wpm-Ticket-Fields" SelectionRawValueColumn="Role" />
|
||||
</State-Editable>
|
||||
|
||||
<State-Editable ValueTable="M42Wpm-Ticket" ValueColumn="ResponsiblePerson" Name="Responsible person">
|
||||
<Name Lang="DE">Verantwortliche Person</Name>
|
||||
<Editable-Selection SelectionTable="M42Wpm-Ticket-Fields" SelectionRawValueColumn="Person" />
|
||||
</State-Editable>
|
||||
|
||||
<State-Container-Content>
|
||||
<State-Editable ValueTable="M42Wpm-Ticket-History" ValueColumn="Description" Name="Notes">
|
||||
<Name Lang="DE">Notizen</Name>
|
||||
<Editable-Text ValueTable="M42Wpm-Ticket-History" SelectionRawValueColumn="Description" />
|
||||
</State-Editable>
|
||||
</State-Container-Content>
|
||||
</State-Container>-->
|
||||
|
||||
</CustomDialogs>
|
||||
</F4SD-CustomDialog-Configuration>
|
||||
1681
FasdDesktopUi/Config/LanguageDefinitions.xml
Normal file
1681
FasdDesktopUi/Config/LanguageDefinitions.xml
Normal file
File diff suppressed because it is too large
Load Diff
58
FasdDesktopUi/Config/LanguageDefinitions.xsd
Normal file
58
FasdDesktopUi/Config/LanguageDefinitions.xsd
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
||||
|
||||
<xs:simpleType name="LanguageId">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[A-Z]{2}|[.]" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:element name="UILanguage">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="UIImage" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element ref="UISubstitution" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element ref="UIItem" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="UIImage">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="Lang" type="LanguageId" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="UISubstitution">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="Language" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="Lang" type="LanguageId" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="UIItem">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="Language" minOccurs="1" maxOccurs="unbounded" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="Name" type="xs:NCName" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="Language">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="Lang" type="LanguageId" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
</xs:schema>
|
||||
Reference in New Issue
Block a user