update 20250324
This commit is contained in:
@@ -78,115 +78,124 @@ namespace OnDoc.Klassen
|
||||
bool excel = false;
|
||||
bool pdf = false;
|
||||
bool found = false;
|
||||
//watchtimer.Enabled = false;
|
||||
watchtimer.Enabled = false;
|
||||
found = false;
|
||||
Logging.Logging.Debug("Start Watch_Process:"+ DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "OnDoc.Processwatch","" );
|
||||
|
||||
foreach (FileToCheck fc in FilestoCheck)
|
||||
try
|
||||
{
|
||||
if (fc.filedatetime < DateTime.Now.AddSeconds(-5))
|
||||
foreach (FileToCheck fc in FilestoCheck)
|
||||
{
|
||||
found = false;
|
||||
word = false;
|
||||
excel = false;
|
||||
pdf = 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)
|
||||
if (fc.filedatetime < DateTime.Now.AddSeconds(-5))
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
Process[] localByName = Process.GetProcessesByName("WINWORD");
|
||||
found = false;
|
||||
word = false;
|
||||
excel = false;
|
||||
pdf = false;
|
||||
|
||||
foreach (Process p in localByName)
|
||||
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)
|
||||
{
|
||||
string owner = GetProcessOwner(p.Id);
|
||||
owner = owner.ToUpper();
|
||||
Logging.Logging.Debug(AppParams.systemtgnummer+"/"+AppParams.currenttgnummer+"/"+owner+"/"+fc.dokumentid + "/" + p.MainWindowTitle, "", "");
|
||||
if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1 ||
|
||||
(p.MainWindowTitle.Trim() == "" && owner.Contains(AppParams.systemtgnummer.ToUpper())))
|
||||
Thread.Sleep(200);
|
||||
Process[] localByName = Process.GetProcessesByName("WINWORD");
|
||||
|
||||
foreach (Process p in localByName)
|
||||
{
|
||||
if (p.MainWindowTitle.Trim() != "") { fc.Lastfound = DateTime.Now; }
|
||||
found = true;
|
||||
save_to_db(fc);
|
||||
|
||||
string owner = GetProcessOwner(p.Id);
|
||||
owner = owner.ToUpper();
|
||||
Logging.Logging.Debug(AppParams.systemtgnummer + "/" + AppParams.currenttgnummer + "/" + owner + "/" + fc.dokumentid + "/" + p.MainWindowTitle, "", "");
|
||||
if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1 ||
|
||||
(p.MainWindowTitle.Trim() == "" && owner.Contains(AppParams.systemtgnummer.ToUpper())))
|
||||
{
|
||||
if (p.MainWindowTitle.Trim() != "") { fc.Lastfound = DateTime.Now; }
|
||||
found = true;
|
||||
save_to_db(fc);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//foreach (Process p in localByName)
|
||||
//{
|
||||
// Logging.Logging.Debug(fc.dokumentid + "/" + p.MainWindowTitle, "", "");
|
||||
// if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1 || p.MainWindowTitle.Trim() == "")
|
||||
|
||||
// {
|
||||
// if (p.MainWindowTitle.Trim() != "") { fc.Lastfound = DateTime.Now; }
|
||||
// found = true;
|
||||
// save_to_db(fc);
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
//foreach (Process p in localByName)
|
||||
//{
|
||||
// Logging.Logging.Debug(fc.dokumentid + "/" + p.MainWindowTitle, "", "");
|
||||
// if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1 || p.MainWindowTitle.Trim() == "")
|
||||
|
||||
// {
|
||||
// if (p.MainWindowTitle.Trim() != "") { fc.Lastfound = DateTime.Now; }
|
||||
// found = true;
|
||||
// save_to_db(fc);
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
if (excel)
|
||||
{
|
||||
Process[] localByName = Process.GetProcessesByName("EXCEL");
|
||||
foreach (Process p in localByName)
|
||||
if (excel)
|
||||
{
|
||||
string owner = GetProcessOwner(p.Id);
|
||||
owner = owner.ToUpper();
|
||||
if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1 ||
|
||||
(p.MainWindowTitle.Trim() == "" && owner.Contains(AppParams.systemtgnummer.ToUpper())))
|
||||
Process[] localByName = Process.GetProcessesByName("EXCEL");
|
||||
foreach (Process p in localByName)
|
||||
{
|
||||
if (p.MainWindowTitle.Trim() != "") { fc.Lastfound = DateTime.Now; }
|
||||
found = true;
|
||||
save_to_db(fc);
|
||||
string owner = GetProcessOwner(p.Id);
|
||||
owner = owner.ToUpper();
|
||||
if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1 ||
|
||||
(p.MainWindowTitle.Trim() == "" && owner.Contains(AppParams.systemtgnummer.ToUpper())))
|
||||
{
|
||||
if (p.MainWindowTitle.Trim() != "") { fc.Lastfound = DateTime.Now; }
|
||||
found = true;
|
||||
save_to_db(fc);
|
||||
}
|
||||
|
||||
}
|
||||
//Process[] localByName = Process.GetProcessesByName("EXCEL");
|
||||
//foreach (Process p in localByName)
|
||||
//{
|
||||
// if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1 || p.MainWindowTitle.Trim() == "")
|
||||
// {
|
||||
// if (p.MainWindowTitle.Trim() != "") { fc.Lastfound = DateTime.Now; }
|
||||
// found = true;
|
||||
// save_to_db(fc);
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
//Process[] localByName = Process.GetProcessesByName("EXCEL");
|
||||
//foreach (Process p in localByName)
|
||||
//{
|
||||
// if (p.MainWindowTitle.IndexOf(fc.dokumentid) > -1 || p.MainWindowTitle.Trim() == "")
|
||||
// {
|
||||
// if (p.MainWindowTitle.Trim() != "") { fc.Lastfound = DateTime.Now; }
|
||||
// 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)
|
||||
{
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
watchtimer.Enabled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Logging.Debug("Error Processwatch", "OnDoc", ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
watchtimer.Enabled = true ;
|
||||
}
|
||||
//watchtimer.Enabled = true;
|
||||
|
||||
}
|
||||
private static void Remove_Dok_in_Bearbeitung(string dokumentid)
|
||||
{
|
||||
@@ -245,7 +254,13 @@ namespace OnDoc.Klassen
|
||||
private static bool Check_Modified(FileToCheck fc)
|
||||
{
|
||||
DateTime lwt = System.IO.File.GetLastWriteTime(fc.filename);
|
||||
if (lwt.Year < DateTime.Now.Year)
|
||||
{
|
||||
lwt = fc.filedatetime;
|
||||
lwt = fc.filedatetime.AddSeconds(+5);
|
||||
}
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user