update 20250202

This commit is contained in:
Stefan Hutter
2025-02-02 18:07:10 +01:00
parent f1f74f8cc5
commit 293b615547
133 changed files with 333088 additions and 333 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -23,6 +23,7 @@ using Microsoft.VisualBasic;
using System.Net.NetworkInformation;
using System.Net;
using Microsoft.VisualBasic.CompilerServices;
using Database;
namespace OnDocOffice
@@ -657,6 +658,12 @@ namespace OnDocOffice
}
catch
{ }
if (docdata.remove_signature)
{
word_signature ws = new word_signature();
ws.remove_unterschriften(ref word, dokumentid);
ws = null;
}
VBOffice.VBOffice vbo = new VBOffice.VBOffice();
@@ -664,6 +671,35 @@ namespace OnDocOffice
vbo = null;
Logging.Logging.Debug("VB Fill Ende", "OnDoc", dokumentid);
if (docdata.sign == true)
{
string unterschriftlinks = "";
string unterschriftrechts = "";
string path_unterschriftlinks = "";
string path_unterschriftrechts = "";
if (docdata.Unterschrift_Links != "-1")
{
unterschriftlinks = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(docdata.Unterschrift_Links));
Helper.clsFileHelper clsFileHelper = new Helper.clsFileHelper();
path_unterschriftlinks = tempdir + dokumentid + "UL.png";
clsFileHelper.SaveBase64ToFile(unterschriftlinks, path_unterschriftlinks);
}
if (docdata.Unterschrift_Rechts != "-1")
{
unterschriftrechts = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(docdata.Unterschrift_Links));
Helper.clsFileHelper clsFileHelper = new Helper.clsFileHelper();
path_unterschriftrechts = tempdir + dokumentid + "UR.png";
clsFileHelper.SaveBase64ToFile(unterschriftrechts,path_unterschriftrechts);
}
word_signature word_Signature = new word_signature();
word_Signature.sign_doc(ref word, path_unterschriftlinks, path_unterschriftrechts, dokumentid);
if (System.IO.File.Exists(path_unterschriftlinks)){ System.IO.File.Delete(tempdir + dokumentid + "UL.png"); };
if (System.IO.File.Exists(path_unterschriftrechts)){ System.IO.File.Delete(tempdir + dokumentid + "UR.png"); }
}
bool cursorpositionieren = false;
//if (docdata.Kopfzeile_generieren == true)
@@ -1493,7 +1529,186 @@ namespace OnDocOffice
return;
}
public bool insert_signature(string dokumentid, string unterschriftlinks, string unterschriftrechts, string tempdir)
{
DB db = new DB(this.connectstring);
System.Data.DataTable dt = new System.Data.DataTable();
System.Data.DataTable dt2 = new System.Data.DataTable();
string Apptype = "";
string Extension = "";
dt = db.Get_Vorlage_By_DokumentID(dokumentid, true, tempdir, true);
db.dsdaten.Tables.Clear();
dt2 = db.Get_ApplicationType_from_Vorlage(Convert.ToInt32(dt.Rows[0]["nr"].ToString()));
Apptype = dt2.Rows[0][0].ToString();
Extension = dt2.Rows[0][1].ToString();
switch (Apptype.ToUpper())
{
case "DOCX":
case "DOCM":
case "DOC":
case "DOT":
case "WORD":
case "DOTM":
string filename = tempdir + dokumentid + ".sig";
Helper.clsFileHelper fh = new Helper.clsFileHelper();
fh.SaveBase64ToFile(dt.Rows[0][0].ToString(), filename);
Start_Application();
word.Visible = true;
word.Documents.Open(filename);
string path_unterschriftlinks = "";
string path_unterschriftrechts = "";
if ( unterschriftlinks != "-1")
{
unterschriftlinks = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(unterschriftlinks));
Helper.clsFileHelper clsFileHelper = new Helper.clsFileHelper();
path_unterschriftlinks = tempdir + dokumentid + "UL.png";
clsFileHelper.SaveBase64ToFile(unterschriftlinks, path_unterschriftlinks);
}
if (unterschriftrechts != "-1")
{
unterschriftrechts = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(unterschriftrechts));
Helper.clsFileHelper clsFileHelper = new Helper.clsFileHelper();
path_unterschriftrechts = tempdir + dokumentid + "UR.png";
clsFileHelper.SaveBase64ToFile(unterschriftrechts, path_unterschriftrechts);
}
word_signature word_Signature = new word_signature();
word_Signature.sign_doc(ref word, path_unterschriftlinks, path_unterschriftrechts, dokumentid);
if (System.IO.File.Exists(path_unterschriftlinks)) { System.IO.File.Delete(tempdir + dokumentid + "UL.png"); };
if (System.IO.File.Exists(path_unterschriftrechts)) { System.IO.File.Delete(tempdir + dokumentid + "UR.png"); }
word.ActiveDocument.Save();
word.ActiveDocument.Close();
word.Quit(false);
db.Save_To_DB(dokumentid, filename, "", 0);
System.IO.File.Delete(filename);
return true;
break;
default:
break;
}
return true;
}
}
public class word_signature
{
Microsoft.Office.Interop.Word.Document docWord;
public bool sign_doc(ref Microsoft.Office.Interop.Word.Application word, string imagepath_ul, string imagepath_ur, string dokumentid)
{
docWord = word.ActiveDocument;
try
{
foreach (Microsoft.Office.Interop.Word.Bookmark bm in docWord.Bookmarks)
{
if (bm.Name.Contains("TGEDKVornameNameLinks") || bm.Name.Contains("TGEDKUnterschriftLinks"))
{
insert_unterschrift(bm.Name, imagepath_ul);
}
if (bm.Name.Contains("TGEDKVornameNameRechts") || bm.Name.Contains("TGEDKUnterschriftRechts"))
{
insert_unterschrift(bm.Name, imagepath_ur);
}
}
//docword = docWord; ;
return true;
}
catch (Exception ex)
{
Logging.DocLog.Error("Signaturen konnten nicht eingefügt werden", "OnDocOffe", dokumentid,"",ex.Message);
return false;
}
}
public void insert_unterschrift(string bookmark, string imagepath)
{
if (imagepath == "") return;
object missing = Type.Missing;
Microsoft.Office.Interop.Word.Range myRange = docWord.Bookmarks[bookmark].Range;
Microsoft.Office.Interop.Word.Bookmark bm = docWord.Bookmarks[bookmark];
float vertical = bm.Range.Information[Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage];
float horizontal = bm.Range.Information[Microsoft.Office.Interop.Word.WdInformation.wdHorizontalPositionRelativeToPage];
vertical = vertical - 50;
docWord.Bookmarks[bookmark].Select();
Microsoft.Office.Interop.Word.Shape myshape1 = docWord.Shapes.AddShape(1, horizontal, vertical, 120, 50);
myshape1.Fill.UserPicture(imagepath);
//myshape1.Line.Weight = -2;
myshape1.Name = "Unterschrift" + "_" + bookmark;
myshape1.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
//object missing = Type.Missing;
//Microsoft.Office.Interop.Word.Range myRange = docWord.Bookmarks[bookmark].Range;
//Microsoft.Office.Interop.Word.Bookmark bm = docWord.Bookmarks[bookmark];
//float vertical = bm.Range.Information[Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage];
//float horizontal = bm.Range.Information[Microsoft.Office.Interop.Word.WdInformation.wdHorizontalPositionRelativeToPage];
//vertical = vertical - 50;
//Microsoft.Office.Interop.Word.Shape myshape = docWord.Shapes.AddTextbox(Microsoft.Office.Core
//.MsoTextOrientation.msoTextOrientationHorizontal, (float)horizontal,
//(float)vertical, 120, 50,bm);
//myshape.Name = "Unterschrift" + "_" + bookmark;
//myshape.TextFrame.ContainingRange.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone;
//myshape.TextFrame.ContainingRange.Borders.InsideLineStyle = WdLineStyle.wdLineStyleNone;
//myshape.Fill.UserPicture(imagepath);
////myshape.Fill.UserPicture(@"E:\Software-Projekte\OnDoc\Unterschriften\1.jpg");
//myshape.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;
//myshape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
}
public bool remove_unterschriften_synfusion(string filename)
{
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
word.Documents.Open(filename);
remove_unterschriften(ref word, filename);
word.ActiveDocument.Save();
word.ActiveDocument.Close();
Thread.Sleep(500);
word.Quit(false);
word = null;
Thread.Sleep(500);
return true;
}
public bool remove_unterschriften(ref Microsoft.Office.Interop.Word.Application word, string dokumentid)
{
try
{
bool found = true;
int i = 1;
while (word.ActiveDocument.Shapes.Count > 0 && found == true)
{
found = false;
if (word.ActiveDocument.Shapes[i].Name.Contains("Unterschrift_"))
{
word.ActiveDocument.Shapes[i].Delete();
found = true;
}
}
return true;
}
catch (Exception ex)
{
Logging.DocLog.Error("Unterschriften entfernen fehlgeschalgen", "OnDocOffice", dokumentid, "", ex.Message);
return false;
}
}
}