update 20251113
This commit is contained in:
234
Client - Kopie/Klassen/EDKFile.cs
Normal file
234
Client - Kopie/Klassen/EDKFile.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Syncfusion.Windows.Forms.Tools.Win32API;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using Database;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace OnDoc.Klassen
|
||||
{
|
||||
public enum EDK_ActionType
|
||||
{
|
||||
AnzeigePartnerdossier = 1,
|
||||
DokumentAnzeige = 2,
|
||||
DokumentErstellung = 3,
|
||||
DokumentBearbeitung = 4,
|
||||
Statusmutation = 5,
|
||||
HostDokumentAnzeige = 6,
|
||||
UVMDokumentanzeige = 7,
|
||||
ZVDokumentanzeige = 8,
|
||||
DokLoeschung = 9,
|
||||
AusHyperlink = 10
|
||||
}
|
||||
|
||||
public class EDK_Parameters
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string value { get; set; }
|
||||
|
||||
public EDK_Parameters(string name, string value)
|
||||
{
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public class EDK_Dokumentwerte
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string value { get; set; }
|
||||
|
||||
public EDK_Dokumentwerte(string name, string value)
|
||||
{
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class EDK_Data
|
||||
{
|
||||
public static EDK_ActionType action { get; set; }
|
||||
public static string sourceApplication { get; set; }
|
||||
public static string creatortg { get; set; }
|
||||
public static string source { get; set; }
|
||||
public static bool executed { get; set; }
|
||||
public static bool toexecute { get; set; }
|
||||
public static string verantwortlich { get; set; }
|
||||
public static string unterschrift_links { get; set; }
|
||||
public static string unterschrift_rechts { get; set; }
|
||||
|
||||
public static string AnzeigePartnernr { get; set; }
|
||||
|
||||
public static List<EDK_Parameters> parameters { get; set; }
|
||||
public static List<EDK_Dokumentwerte> dokumentwerte { get; set; }
|
||||
|
||||
|
||||
|
||||
public static void Load_EDK_File(string filename)
|
||||
{
|
||||
//XmlSerializer serializer = new XmlSerializer(typeof(Action));
|
||||
//using (StringReader reader = new StringReader(filename))
|
||||
//{
|
||||
// var test = (Action)serializer.Deserialize(reader);
|
||||
//}
|
||||
|
||||
|
||||
var doc = new XmlDocument();
|
||||
try
|
||||
{
|
||||
doc.Load(filename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Logging.Debug("Fehlerhafte EDK-Datei: " + filename, "OnDoc-EDK", "");
|
||||
System.IO.File.Delete(filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// read header elements
|
||||
action = (EDK_ActionType)Enum.Parse(typeof(EDK_ActionType), doc.SelectSingleNode("action/actionId").InnerText, true);
|
||||
sourceApplication = doc.SelectSingleNode("action/sourceApplication").InnerText;
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
db.Get_Tabledata("Select count(*) from Avaloq_SourceApplication where AvaloqSourceApplication='" + sourceApplication + "'", false, true);
|
||||
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][0]) == 0)
|
||||
{
|
||||
Logging.Logging.Debug("EDK-Datei für fehlerhafte Instanz:" + source, "EDK-Verarbeitung", filename);
|
||||
System.IO.File.Delete(filename);
|
||||
MessageBox.Show("Der EDK-Aufruf ist ungültig, da dieser nciht für die richtige DB-Instanz ist: " + sourceApplication, "EDK-Aufruf", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
switch (action)
|
||||
{
|
||||
case EDK_ActionType.AnzeigePartnerdossier:
|
||||
AnzeigePartnernr = doc.SelectSingleNode("action/PartnerNr").InnerText;
|
||||
executed = false;
|
||||
toexecute = true;
|
||||
break;
|
||||
case EDK_ActionType.DokumentErstellung:
|
||||
|
||||
creatortg = doc.SelectSingleNode("action/creatorTg").InnerText;
|
||||
source = doc.SelectSingleNode("action/sourceApplication").InnerText;
|
||||
verantwortlich = "";
|
||||
try
|
||||
{
|
||||
verantwortlich = doc.SelectSingleNode("action/Verantwortlich").InnerText;
|
||||
}
|
||||
catch { }
|
||||
unterschrift_links = "";
|
||||
unterschrift_rechts = "";
|
||||
try { unterschrift_links = doc.SelectSingleNode("action/uslinks").InnerText; } catch { }
|
||||
try { unterschrift_rechts = doc.SelectSingleNode("action/usrechts").InnerText; } catch { }
|
||||
|
||||
|
||||
XmlElement RootNode = doc.DocumentElement;
|
||||
XmlNodeList nodeList = RootNode.ChildNodes;
|
||||
XmlNodeList dokwerte = RootNode.LastChild.ChildNodes;
|
||||
List<EDK_Parameters> Params = new List<EDK_Parameters>();
|
||||
List<EDK_Dokumentwerte> Dokwerte = new List<EDK_Dokumentwerte>();
|
||||
if (nodeList.Count > 0)
|
||||
{
|
||||
|
||||
string value;
|
||||
string name;
|
||||
var loopTo = nodeList.Count - 1;
|
||||
for (int i = 0; i < nodeList.Count - 1; i++)
|
||||
{
|
||||
value = nodeList.Item(i).InnerText;
|
||||
name = nodeList.Item(i).LocalName;
|
||||
Params.Add(new EDK_Parameters(name, value));
|
||||
|
||||
}
|
||||
}
|
||||
parameters = Params;
|
||||
|
||||
if (dokwerte.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < dokwerte.Count ; i++)
|
||||
{
|
||||
XmlNodeList XNode = dokwerte[i].ChildNodes;
|
||||
string value;
|
||||
string name;
|
||||
try { value = XNode[1].InnerText; } catch { value = ""; }
|
||||
try { name = XNode[0].InnerText; } catch { name = ""; }
|
||||
|
||||
Dokwerte.Add(new EDK_Dokumentwerte(name, value));
|
||||
|
||||
}
|
||||
dokumentwerte = Dokwerte;
|
||||
var json = JsonConvert.SerializeObject(dokumentwerte);
|
||||
// System.IO.File.WriteAllText(@"H:\dokwerte.txt", json);
|
||||
if (parameters.Count > 0)
|
||||
{
|
||||
executed = false;
|
||||
toexecute = true;
|
||||
} else
|
||||
{
|
||||
executed = false;
|
||||
toexecute = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
executed = false;
|
||||
toexecute = true;
|
||||
break;
|
||||
default:
|
||||
System.IO.File.Delete(filename);
|
||||
MessageBox.Show("Der Aufruf mit Action " + action.ToString() + " ist für OnDoc ungültig.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetAVQ_Value(string name, string techname)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
for (int i = 0; i < dokumentwerte.Count; i++)
|
||||
{
|
||||
EDK_Dokumentwerte d = dokumentwerte[i];
|
||||
// System.IO.File.AppendAllText(@"h:\edklog.txt", Environment.NewLine + dokumentwerte[i].name);
|
||||
|
||||
if (dokumentwerte[i].name == name || (dokumentwerte[i].name == techname && dokumentwerte[i].name.ToString()!=""))
|
||||
{
|
||||
|
||||
// System.IO.File.AppendAllText(@"h:\edklog.txt", Environment.NewLine + dokumentwerte[i].value);
|
||||
return dokumentwerte[i].value;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
catch { return ""; }
|
||||
}
|
||||
|
||||
public static string GetAVQ_Parameter(string name)
|
||||
{
|
||||
for (int i = 0; i < parameters.Count+1; i++)
|
||||
{
|
||||
if (parameters[i].name.ToUpper() == name.ToUpper())
|
||||
{
|
||||
return parameters[i].value;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user