update 20250219

This commit is contained in:
Stefan Hutter
2025-02-19 18:10:21 +01:00
parent d0d96c0732
commit 8bd079b635
82 changed files with 921 additions and 158 deletions

View File

@@ -13,6 +13,7 @@ using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using Database;
namespace OnDoc.Klassen
@@ -59,6 +60,7 @@ namespace OnDoc.Klassen
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; }
@@ -95,8 +97,19 @@ namespace OnDoc.Klassen
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:

View File

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Timers;
using Database;
using Syncfusion.Windows.Forms.Tools;
using Syncfusion.WinForms.Input.Enums;
namespace OnDoc.Klassen
{
@@ -54,54 +55,61 @@ namespace OnDoc.Klassen
bool excel = false;
bool pdf = false;
bool found = false;
watchtimer.Enabled = false;
found= false;
foreach (FileToCheck fc in FilestoCheck)
{
Logging.Logging.Debug("FileChek "+fc.filename+" / " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "OnDoc.Processwatch", fc.dokumentid);
if (fc.application == "Word") { word = true; }
if (fc.application == "Excel") { excel = true; }
if (fc.application == "PDF") { pdf = true; }
if (fc.filedatetime < DateTime.Now.AddSeconds(-5))
{
found = false;
Logging.Logging.Debug(fc.application + " / FileChek " + fc.filename + " / " + fc.filedatetime.ToString("yyyy-MM-dd hh:mm:ss") + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "OnDoc.Processwatch", fc.dokumentid);
if (fc.application == "Word") { word = true; }
if (fc.application == "Excel") { excel = true; }
if (fc.application == "PDF") { pdf = true; }
if (word)
{
Process[] localByName = Process.GetProcessesByName("WINWORD");
foreach (Process p in localByName)
if (word)
{
if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1) { found = true; }
Process[] localByName = Process.GetProcessesByName("WINWORD");
foreach (Process p in localByName)
{
if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1) { found = true; }
save_to_db(fc);
}
}
}
if (excel)
{
Process[] localByName = Process.GetProcessesByName("EXCEL");
foreach (Process p in localByName)
if (excel)
{
if (p.MainWindowTitle.IndexOf(fc.dokumentid) > 0) { found = true; }
Process[] localByName = Process.GetProcessesByName("EXCEL");
foreach (Process p in localByName)
{
if (p.MainWindowTitle.IndexOf(fc.dokumentid) > 0) { found = true; }
save_to_db(fc);
}
}
}
if (!found)
{
Logging.Logging.Debug("Not Found "+fc.filename+" / "+ DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "OnDoc.Processwatch", fc.dokumentid);
if (Check_Modified(fc) == true)
if (!found)
{
Save_File(fc.dokumentid, fc.filename);
Logging.DocLog.Info("Dokument gespeichert und geschlossen", "Processwatch", fc.dokumentid, "", fc.filename);
RemoveFromList(fc.dokumentid);
Remove_Dok_in_Bearbeitung(fc.dokumentid);
Remove_Dokumentbearbeitung_Zwingend(fc.dokumentid);
Remove_Approvals(fc.dokumentid);
return;
Logging.Logging.Debug("Not Found " + fc.filename + " / " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "OnDoc.Processwatch", fc.dokumentid);
if (Check_Modified(fc) == true)
{
Save_File(fc.dokumentid, fc.filename);
Logging.DocLog.Info("Dokument gespeichert und geschlossen", "Processwatch", fc.dokumentid, "", fc.filename);
RemoveFromList(fc.dokumentid);
Remove_Dok_in_Bearbeitung(fc.dokumentid);
Remove_Dokumentbearbeitung_Zwingend(fc.dokumentid);
Remove_Approvals(fc.dokumentid);
return;
}
else
{
Logging.DocLog.Info("Dokument ohne speichern geschlossen", "Processwatch", fc.dokumentid, "", fc.filename);
RemoveFromList(fc.dokumentid);
Remove_Dok_in_Bearbeitung(fc.dokumentid);
return;
};
}
else
{
Logging.DocLog.Info("Dokument ohne speichern geschlossen", "Processwatch", fc.dokumentid, "", fc.filename);
RemoveFromList(fc.dokumentid);
Remove_Dok_in_Bearbeitung(fc.dokumentid);
return;
};
}
}
watchtimer.Enabled = true;
}
private static void Remove_Dok_in_Bearbeitung(string dokumentid)
@@ -124,6 +132,28 @@ namespace OnDoc.Klassen
db = null;
}
private static void save_to_db(FileToCheck fc)
{
if (Check_Modified(fc))
{
try
{
System.IO.File.Copy(fc.filename, fc.filename + ".tmp");
Save_File(fc.dokumentid, fc.filename + ".tmp");
fc.filedatetime = DateTime.Now;
System.IO.File.Delete(fc.filename + ".tmp");
Logging.Logging.Debug(fc.application + " / save_to_db " + fc.filename + " / " + fc.filedatetime.ToString("yyyy-MM-dd hh:mm:ss") + "/"+DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "OnDoc.Processwatch", fc.dokumentid);
}
catch
{
Logging.Logging.Debug(fc.application + " / save_to_db faild " + fc.filename + " / " + fc.filedatetime.ToString("yyyy-MM-dd hh:mm:ss") +"/"+ DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "OnDoc.Processwatch", fc.dokumentid);
}
}
}
private static void Save_File(string dokumentid, string filename)
{
DB db = new DB(AppParams.connectionstring);
@@ -139,8 +169,11 @@ namespace OnDoc.Klassen
private static bool Check_Modified(FileToCheck fc)
{
DateTime lwt = System.IO.File.GetLastWriteTime(fc.filename);
Logging.DocLog.Debug("Prozesswatch - Check Modified: " + lwt.ToString() + "," + fc.filedatetime.ToString(), "Processwatch", fc.dokumentid, "", fc.filename);
if ((lwt- fc.filedatetime).Seconds > 2)
int secdiff = (int)((lwt - fc.filedatetime).TotalSeconds);
Logging.Logging.Debug("Prozesswatch - Check Modified: " + lwt.ToString() + "," + fc.filedatetime.ToString(), "OnDoc", fc.dokumentid);
//Logging.DocLog.Debug("Prozesswatch - Check Modified: " + lwt.ToString() + "," + fc.filedatetime.ToString(), "Processwatch", fc.dokumentid, "", fc.filename);
//if ((lwt- fc.filedatetime).Seconds > 2)
if (secdiff > 2)
{
return true;
}
@@ -150,6 +183,11 @@ namespace OnDoc.Klassen
}
}
public static int check_open_files()
{
return FilestoCheck.Count;
}
}
public class FileToCheck
{
@@ -165,7 +203,8 @@ namespace OnDoc.Klassen
this.filename = filename;
this.application = application;
this.filedatetime = DateTime.Now;
Logging.DocLog.Debug("Add Processwatch: " + DateTime.Now.ToString(), "New FileToCheck", dokumentid, "", "Add Processwatch");
//Logging.DocLog.Debug("Add Processwatch: " + DateTime.Now.ToString(), "New FileToCheck", dokumentid, "", "Add Processwatch");
Logging.Logging.Debug("Add Processwatch: " + DateTime.Now.ToString(),"OnDoc",this.dokumentid);
}
}

View File

@@ -32,6 +32,7 @@ namespace OnDoc.Klassen
{
try
{
//word = Interaction.CreateObject("Word.Application")
word = new Microsoft.Office.Interop.Word.Application();
return true;
}