update 20250111
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -21,6 +21,7 @@ using Syncfusion.DocIO.DLS;
|
||||
using System.IO;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net;
|
||||
|
||||
|
||||
namespace OnDocOffice
|
||||
@@ -34,6 +35,8 @@ namespace OnDocOffice
|
||||
Microsoft.Office.Interop.Excel.Application excel;
|
||||
Workbook workBook = null;
|
||||
|
||||
public string resturi = "";
|
||||
public string apikey = "";
|
||||
|
||||
public clsExcelEdit(string connectstring, string filename, string dokumentid)
|
||||
{
|
||||
@@ -218,23 +221,23 @@ namespace OnDocOffice
|
||||
int i2 = 0;
|
||||
for (i1 = 1; i1 < workBook.Names.Count; i1++)
|
||||
{
|
||||
|
||||
string na = workBook.Names.Item(i1).NameLocal;
|
||||
if (na.Substring(0, 7) == "TGEDKBC")
|
||||
{
|
||||
excel.Range[excel.Names.Item(na).NameLocal].Select();
|
||||
excel.ActiveCell.FormulaR1C1 = barcode;
|
||||
|
||||
string na = workBook.Names.Item(i1).NameLocal;
|
||||
if (na.Substring(0, 7) == "TGEDKBC")
|
||||
{
|
||||
excel.Range[excel.Names.Item(na).NameLocal].Select();
|
||||
excel.ActiveCell.FormulaR1C1 = barcode;
|
||||
try
|
||||
{
|
||||
excel.Selection.Characters.Font.Name = docdata.barcode_font;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
if (na.Substring(0, 7) == "TGEDKAR")
|
||||
{
|
||||
excel.Range[excel.Names.Item(na).NameLocal].Select();
|
||||
excel.ActiveCell.FormulaR1C1 = convert_excel(docdata.barcode_zusatz);
|
||||
}
|
||||
}
|
||||
if (na.Substring(0, 7) == "TGEDKAR")
|
||||
{
|
||||
excel.Range[excel.Names.Item(na).NameLocal].Select();
|
||||
excel.ActiveCell.FormulaR1C1 = convert_excel(docdata.barcode_zusatz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +248,7 @@ namespace OnDocOffice
|
||||
|
||||
string b64 = fh.Base64FromFile(filename);
|
||||
excel.Workbooks.Open(filename);
|
||||
excel.Visible= true;
|
||||
excel.Visible = true;
|
||||
excel = null;
|
||||
Logging.Logging.Debug("Generierung abgeschlossen", "clsOffice", dokumentid);
|
||||
return b64;
|
||||
@@ -266,13 +269,17 @@ namespace OnDocOffice
|
||||
Microsoft.Office.Interop.Word.Document worddoc;
|
||||
Document doc = null;
|
||||
|
||||
public string resturi = "";
|
||||
public string apikey = "";
|
||||
|
||||
public clsWordEdit(string connectstring, string filename, string dokumentid)
|
||||
|
||||
public clsWordEdit(string connectstring, string filename, string dokumentid, string resturi, string apikey)
|
||||
{
|
||||
this.connectstring = connectstring;
|
||||
this.filename = filename;
|
||||
this.dokumentid = dokumentid;
|
||||
|
||||
this.resturi = resturi;
|
||||
this.apikey = apikey;
|
||||
}
|
||||
public bool Start_Application()
|
||||
{
|
||||
@@ -284,8 +291,8 @@ namespace OnDocOffice
|
||||
|
||||
word = (Microsoft.Office.Interop.Word.Application)Interaction.CreateObject("Word.Application");
|
||||
//word = new Microsoft.Office.Interop.Word.Application();
|
||||
word.Run("Autoexec");
|
||||
word.NormalTemplate.Saved = true;
|
||||
word.Run("Autoexec");
|
||||
word.NormalTemplate.Saved = true;
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
@@ -294,7 +301,7 @@ namespace OnDocOffice
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Edit_Document(bool runmacros)
|
||||
{
|
||||
Start_Application();
|
||||
@@ -346,23 +353,24 @@ namespace OnDocOffice
|
||||
if (db.dsdaten.Tables[0].Rows.Count > 0) { word.Visible = true; word.Activate(); }
|
||||
foreach (DataRow dr in db.dsdaten.Tables[0].Rows)
|
||||
{
|
||||
try {
|
||||
if (dr[0].ToString() == "DokumentSchuetzen")
|
||||
{
|
||||
worddoc.Range(0, 0).Select();
|
||||
worddoc.Protect(Type: Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields, NoReset: true, Password: "Australia");
|
||||
}
|
||||
try
|
||||
{
|
||||
word.Run(dr[0].ToString());
|
||||
}
|
||||
catch (Exception e) { string a = e.Message; }
|
||||
if (dr[0].ToString() == "DokumentSchuetzen")
|
||||
{
|
||||
worddoc.Range(0, 0).Select();
|
||||
worddoc.Protect(Type: Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields, NoReset: true, Password: "Australia");
|
||||
}
|
||||
try
|
||||
{
|
||||
word.Run(dr[0].ToString());
|
||||
}
|
||||
catch (Exception e) { string a = e.Message; }
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
public void Word_Compatibility_Mode (ref WordDocument wd)
|
||||
public void Word_Compatibility_Mode(ref WordDocument wd)
|
||||
{
|
||||
CompatibilityMode compatibilityMode = wd.Settings.CompatibilityMode;
|
||||
var formattype_original = wd.ActualFormatType;
|
||||
@@ -375,11 +383,12 @@ namespace OnDocOffice
|
||||
wd.Settings.CompatibilityMode = CompatibilityMode.Word2013;
|
||||
break;
|
||||
default:
|
||||
// wd.Settings.CompatibilityMode = CompatibilityMode.Word2003;
|
||||
// wd.Settings.CompatibilityMode = CompatibilityMode.Word2003;
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void get_bookmakrs(string file, ref clsDocData ddata) {
|
||||
private void get_bookmakrs(string file, ref clsDocData ddata)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(file));
|
||||
WordDocument document = new WordDocument(ms, FormatType.Automatic);
|
||||
//List<Syncfusion.DocIO.DLS.Bookmark> bookmarks = new List<Syncfusion.DocIO.DLS.Bookmark>();
|
||||
@@ -406,7 +415,7 @@ namespace OnDocOffice
|
||||
//}
|
||||
ms = null;
|
||||
}
|
||||
private string set_cmode(string file)
|
||||
private string set_cmode(string file)
|
||||
{
|
||||
string formattype = "";
|
||||
MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(file));
|
||||
@@ -428,7 +437,7 @@ namespace OnDocOffice
|
||||
// break;
|
||||
//}
|
||||
MemoryStream destms = new MemoryStream();
|
||||
document.Save(destms,formattype_original);
|
||||
document.Save(destms, formattype_original);
|
||||
|
||||
document.Close();
|
||||
document.Dispose();
|
||||
@@ -459,16 +468,16 @@ namespace OnDocOffice
|
||||
|
||||
}
|
||||
Helper.clsFileHelper fh = new Helper.clsFileHelper();
|
||||
|
||||
|
||||
//vorlage = fh.Base64FromFile(filename);
|
||||
//vorlage = set_cmode(vorlage);
|
||||
|
||||
fh.SaveBase64ToFile(vorlage, filename);
|
||||
get_bookmakrs(fh.Base64FromFile(filename),ref docdata);
|
||||
get_bookmakrs(fh.Base64FromFile(filename), ref docdata);
|
||||
Logging.Logging.Debug("Generate_Word_in_Office", "clsOffice", dokumentid);
|
||||
dialogGenerate.set_progress(20);
|
||||
Start_Application();
|
||||
|
||||
|
||||
|
||||
// Thread.Sleep(OfficeSleep);
|
||||
worddoc = word.Documents.Open(filename);
|
||||
@@ -581,7 +590,7 @@ namespace OnDocOffice
|
||||
Kopfzeile_generieren();
|
||||
}
|
||||
//word.Visible = false;
|
||||
dialogGenerate.set_progress(40);
|
||||
dialogGenerate.set_progress(40);
|
||||
//word.ScreenUpdating = false;
|
||||
if (bookmarks_docio == 1)
|
||||
{
|
||||
@@ -592,28 +601,28 @@ namespace OnDocOffice
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
float progressstep = 1;
|
||||
try
|
||||
{
|
||||
float b = 60;
|
||||
progressstep = b/ (float)docdata.DocValues.Count();
|
||||
progressstep = b / (float)docdata.DocValues.Count();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
foreach (clsDocValue dv in docdata.DocValues)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (dv.TMBeginn.ToString() == "TGEDKCursor" || dv.TMBeginn.ToString() == "TGEDKCursorB" ||
|
||||
dv.FieldName.ToString() == "TGEDKCursor" || dv.FieldName.ToString() == "TGEDKCursorB") { cursorpositionieren = true; }
|
||||
}
|
||||
catch { }
|
||||
// Logging.Logging.Debug(dv.TMBeginn.ToString() + " / " + dv.TMEnd.ToString(), dv.Value.ToString(), dokumentid);
|
||||
// Logging.Logging.Debug(dv.TMBeginn.ToString() + " / " + dv.TMEnd.ToString(), dv.Value.ToString(), dokumentid);
|
||||
dialogGenerate.add_progress((int)progressstep);
|
||||
if (dv.TMBeginn.ToString() != "" && dv.TMEnd.ToString() == "")
|
||||
{
|
||||
@@ -621,7 +630,7 @@ namespace OnDocOffice
|
||||
try
|
||||
{
|
||||
|
||||
//Logging.Logging.Debug(dv.TMBeginn.ToString() ,"Select" , dokumentid);
|
||||
Logging.Logging.Debug(dv.TMBeginn.ToString(), "Select", dokumentid);
|
||||
worddoc.Bookmarks[dv.TMBeginn.ToString()].Select();
|
||||
//Logging.Logging.Debug(dv.TMBeginn.ToString(), "Select-End", dokumentid);
|
||||
word.Selection.Text = dv.Value.ToString();
|
||||
@@ -629,7 +638,7 @@ namespace OnDocOffice
|
||||
|
||||
//pos = worddoc.Bookmarks[dv.TMBeginn.ToString()].Start;
|
||||
//pos2 = word.Selection.End;
|
||||
// Logging.Logging.Debug(dv.TMBeginn.ToString(), "Selection-End", dokumentid);
|
||||
// Logging.Logging.Debug(dv.TMBeginn.ToString(), "Selection-End", dokumentid);
|
||||
|
||||
//------------------------------
|
||||
if (dv.TMBeginn.ToString().Substring(0, 19) == "XTGEDKDirektTelefonB" ||
|
||||
@@ -727,10 +736,11 @@ namespace OnDocOffice
|
||||
catch { }
|
||||
}
|
||||
word.Visible = true;
|
||||
word.Activate();
|
||||
Logging.Logging.Debug("Start Macros", "clsOffice", dokumentid);
|
||||
|
||||
run_macros(ref docdata, connectionstring);
|
||||
|
||||
|
||||
worddoc.Save();
|
||||
Logging.Logging.Debug("Word Saved", "clsOffice", dokumentid);
|
||||
|
||||
@@ -748,7 +758,7 @@ namespace OnDocOffice
|
||||
dialogGenerate.Close();
|
||||
dialogGenerate.Dispose();
|
||||
return b64;
|
||||
|
||||
|
||||
//return fh.Base64FromFile(filename);
|
||||
}
|
||||
|
||||
@@ -897,9 +907,9 @@ namespace OnDocOffice
|
||||
}
|
||||
private void Generate_Barcodes(ref clsDocData docdata, string tempdir)
|
||||
{
|
||||
Logging.Logging.Debug("Barcode genererien start","OnDoc clsOffice",dokumentid);
|
||||
Logging.Logging.Debug("Barcode genererien start", "OnDoc clsOffice", dokumentid);
|
||||
vbBarcodes.vbarcodes vbcode = new vbBarcodes.vbarcodes();
|
||||
vbcode.GenerateBarcodes(ref word, ref docdata, connectstring,tempdir);
|
||||
vbcode.GenerateBarcodes(ref word, ref docdata, connectstring, tempdir);
|
||||
vbcode = null;
|
||||
Logging.Logging.Debug("Barcode genererien Ende", "OnDoc clsOffice", dokumentid);
|
||||
return;
|
||||
@@ -919,7 +929,8 @@ namespace OnDocOffice
|
||||
{
|
||||
word.Selection.GoTo(What: Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage, xname);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging.Logging.Debug("Word GotoPage " + xname + " " + e.Message, "OnDoc clsOffice", dokumentid);
|
||||
}
|
||||
HeaderFooterAnzeigen();
|
||||
@@ -946,7 +957,7 @@ namespace OnDocOffice
|
||||
//return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
word.Selection.HeaderFooter.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, docdata.barcode_left, docdata.barcode_top, docdata.barcode_width, docdata.barcode_height).Select();
|
||||
|
||||
@@ -1041,7 +1052,34 @@ namespace OnDocOffice
|
||||
|
||||
public string get_unterschrift(string input)
|
||||
{
|
||||
return "";
|
||||
|
||||
string URL = resturi + "API/GetUnterschriftAsBase64ByMitarbeiternr?MaNr=" + input;
|
||||
|
||||
HttpWebRequest webRequest = HttpWebRequest.Create(URL) as HttpWebRequest;
|
||||
webRequest.Method = WebRequestMethods.Http.Get;
|
||||
webRequest.Headers["Authorization"] = "Bearer " + apikey;
|
||||
try
|
||||
{
|
||||
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
|
||||
{
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
StreamReader reader = new StreamReader(response.GetResponseStream());
|
||||
string responseContent = reader.ReadToEnd();
|
||||
|
||||
return responseContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Logging.Error(URL + ": " + response.StatusCode.ToString() + " / " + response.StatusDescription, "Clinet - DokList GetDocument", "");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public void Replace_Text(ref WordDocument wordDocument, string TextToReplace, string NewText)
|
||||
{
|
||||
@@ -1119,12 +1157,21 @@ namespace OnDocOffice
|
||||
{
|
||||
if (docdata.Form_ohne_Unterschrift == "True")
|
||||
{
|
||||
|
||||
foreach (clsDocValue dv2 in docdata.DocValues)
|
||||
{
|
||||
if (dv2.TMBeginn.ToString() == "TGEDKVornameNameLinksB99") { dv2.Value = ""; }
|
||||
if (dv2.TMBeginn.ToString() == "TGEDKVornameNameRechtsB99") { dv2.Value = ""; }
|
||||
if (dv2.TMBeginn.ToString() == "TGEDKFunktionLinksB99") { dv2.Value = ""; }
|
||||
if (dv2.TMBeginn.ToString() == "TGEDKFunktionRechtsB99") { dv2.Value = ""; }
|
||||
if (dv2.TMBeginn.ToString().Contains("VornameNameLinks")) { dv2.Value = ""; }
|
||||
if (dv2.TMBeginn.ToString().Contains("VornameNameRechts")) { dv2.Value = ""; }
|
||||
if (dv2.TMBeginn.ToString().Contains("TGEDKFunktionLinks")) { dv2.Value = ""; }
|
||||
if (dv2.TMBeginn.ToString().Contains("FunktionRechts")) { dv2.Value = ""; }
|
||||
//clsNameVOrnameTM tm = docdata.VornameNameTextmarken.Find(x => x.TM == dv2.TMBeginn.ToString());
|
||||
//if (tm != null) {
|
||||
// dv2.Value = "";
|
||||
// }
|
||||
//if (dv2.TMBeginn.ToString() == "TGEDKVornameNameLinksB99") { dv2.Value = ""; }
|
||||
//if (dv2.TMBeginn.ToString() == "TGEDKVornameNameRechtsB99") { dv2.Value = ""; }
|
||||
//if (dv2.TMBeginn.ToString() == "TGEDKFunktionLinksB99") { dv2.Value = ""; }
|
||||
//if (dv2.TMBeginn.ToString() == "TGEDKFunktionRechtsB99") { dv2.Value = ""; }
|
||||
}
|
||||
}
|
||||
if (dv.TMBeginn.ToString() != "" && dv.TMEnd.ToString() == "")
|
||||
@@ -1132,20 +1179,27 @@ namespace OnDocOffice
|
||||
try
|
||||
{
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
if ((dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99" || dv.TMBeginn.ToString() == "TGEDKVornameNameRechtsB99") && docdata.As_Faksimile == "True")
|
||||
|
||||
|
||||
// if ((dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99" || dv.TMBeginn.ToString() == "TGEDKVornameNameRechtsB99") && docdata.As_Faksimile == "True")
|
||||
if ((dv.TMBeginn.ToString().Contains("VornameNameLinks") || dv.TMBeginn.ToString().Contains("VornameNameRechts")) && docdata.As_Faksimile == "True")
|
||||
{
|
||||
Logging.Logging.Debug(dv.TMBeginn.ToString() + " / " + dv.Value.ToString(), "clsOffice", "");
|
||||
string funktionlinks = "";
|
||||
string funktionrechts = "";
|
||||
foreach (clsDocValue dv2 in docdata.DocValues)
|
||||
{
|
||||
if (dv2.TMBeginn.ToString() == "TGEDKFunktionLinksB99") { funktionlinks = dv2.Value.ToString(); }
|
||||
if (dv2.TMBeginn.ToString() == "TGEDKFunktionRechtsB99") { funktionrechts = dv2.Value.ToString(); }
|
||||
//if (dv2.TMBeginn.ToString() == "TGEDKFunktionLinksB99") { funktionlinks = dv2.Value.ToString(); }
|
||||
//if (dv2.TMBeginn.ToString() == "TGEDKFunktionRechtsB99") { funktionrechts = dv2.Value.ToString(); }
|
||||
if (dv2.TMBeginn.ToString().Contains("FunktionLinks")) { funktionlinks = dv2.Value.ToString(); }
|
||||
if (dv2.TMBeginn.ToString().Contains("FunktionRecht")) { funktionrechts = dv2.Value.ToString(); }
|
||||
}
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
IWParagraph paragraph = new WParagraph(document);
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
|
||||
if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
// if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
if (dv.TMBeginn.ToString().Contains("VornameNameLinks"))
|
||||
{
|
||||
string unterschrift = "";
|
||||
if (img_UL != "") { unterschrift = img_UL.ToString(); }
|
||||
@@ -1184,7 +1238,8 @@ namespace OnDocOffice
|
||||
//paragraph.AppendPicture(image);
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
paragraph.AppendText(dv.Value.ToString());
|
||||
if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
//if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
if (dv.TMBeginn.ToString().Contains("VornameNameLinks"))
|
||||
{
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
paragraph.AppendText(funktionlinks);
|
||||
@@ -1202,7 +1257,8 @@ namespace OnDocOffice
|
||||
}
|
||||
else
|
||||
{
|
||||
if (docdata.As_Faksimile == "True" && (dv.TMBeginn.ToString() == "TGEDKFunktionLinksB99" || dv.TMBeginn.ToString() == "TGEDKFunktionRechtsB99"))
|
||||
// if (docdata.As_Faksimile == "True" && (dv.TMBeginn.ToString() == "TGEDKFunktionLinksB99" || dv.TMBeginn.ToString() == "TGEDKFunktionRechtsB99"))
|
||||
if (docdata.As_Faksimile == "True" && (dv.TMBeginn.ToString().Contains("FunktionLinks") || dv.TMBeginn.ToString().Contains("FunktionRechts")))
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1212,13 +1268,13 @@ namespace OnDocOffice
|
||||
bookmark = document.Bookmarks.FindByName(dv.TMBeginn.ToString());
|
||||
if (bookmark != null)
|
||||
{
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString(),true,false);
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString(), true, false);
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
bookmarkNavigator.InsertText(dv.Value.ToString());
|
||||
bookmarkNavigator.ReplaceBookmarkContent(dv.Value.ToString(),true);
|
||||
bookmarkNavigator.ReplaceBookmarkContent(dv.Value.ToString(), true);
|
||||
//TextBodyPart bookmarkContent = bookmarkNavigator.GetBookmarkContent();
|
||||
//string bookmarkText = ((Syncfusion.DocIO.DLS.WParagraph)bookmarkContent.BodyItems.FirstItem).Text;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user