update 20250102
This commit is contained in:
@@ -22,6 +22,7 @@ using System.IO;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
|
||||
namespace OnDocOffice
|
||||
{
|
||||
public class clsExcelEdit
|
||||
@@ -168,6 +169,7 @@ namespace OnDocOffice
|
||||
}
|
||||
public string Generate_Excel_in_Office(ref clsDocData docdata, ref clsdok dok, string vorlage, string connectionstring, string tempdir, string dokumentid, string apptype, string extension, int OfficeSleep, int bookmarks_docio)
|
||||
{
|
||||
this.connectstring = connectionstring;
|
||||
this.dokumentid = docdata.Dokumentid;
|
||||
string filename = tempdir + dokumentid + "." + extension;
|
||||
bool cursor = false;
|
||||
@@ -377,6 +379,33 @@ namespace OnDocOffice
|
||||
break;
|
||||
}
|
||||
}
|
||||
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>();
|
||||
BookmarkCollection bookmarks = document.Bookmarks;
|
||||
foreach (clsDocValue dv in ddata.DocValues)
|
||||
|
||||
{
|
||||
dv.used = 0;
|
||||
foreach (Syncfusion.DocIO.DLS.Bookmark bm in bookmarks)
|
||||
{
|
||||
dv.used = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//foreach (Syncfusion.DocIO.DLS.Bookmark bm in bookmarks)
|
||||
//{
|
||||
// foreach (clsDocValue dv in ddata.DocValues)
|
||||
// {
|
||||
// if (dv.TMBeginn==bm.Name || dv.TMEnd == bm.Name)
|
||||
// {
|
||||
// dv.used = 1;
|
||||
// } else { dv.used = 0; }
|
||||
// }
|
||||
//}
|
||||
ms = null;
|
||||
}
|
||||
private string set_cmode(string file)
|
||||
{
|
||||
string formattype = "";
|
||||
@@ -407,24 +436,37 @@ namespace OnDocOffice
|
||||
|
||||
return Convert.ToBase64String(imageArray);
|
||||
}
|
||||
public string Generate_Word_in_Office(ref clsDocData docdata, ref clsdok dok, string vorlage, string connectionstring, string tempdir, string dokumentid, string apptype, string extension, int OfficeSleep, int bookmarks_docio)
|
||||
public string Generate_Word_in_Office(ref clsDocData docdata, ref clsdok dok, string vorlage, string connectionstring, string tempdir, string dokumentid, string apptype, string extension, int OfficeSleep, int bookmarks_docio, bool vbfilemanagment)
|
||||
{
|
||||
connectstring = connectionstring;
|
||||
DialogGenerate dialogGenerate = new DialogGenerate(docdata.Bezeichnung.ToString());
|
||||
dialogGenerate.Show();
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
dialogGenerate.set_progress(10);
|
||||
|
||||
this.dokumentid = docdata.Dokumentid;
|
||||
string filename = tempdir + dokumentid + "." + extension;
|
||||
int pos = 0;
|
||||
int pos2 = 0;
|
||||
|
||||
VBFileManagement.VBFileManagement vb = new VBFileManagement.VBFileManagement();
|
||||
vb.Get_From_DB(Convert.ToInt32(docdata.VorlageNr), filename, connectionstring, false);
|
||||
if (vbfilemanagment)
|
||||
{
|
||||
VBFileManagement.VBFileManagement vb = new VBFileManagement.VBFileManagement();
|
||||
vb.Get_From_DB(Convert.ToInt32(docdata.VorlageNr), filename, connectionstring, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
Helper.clsFileHelper fh = new Helper.clsFileHelper();
|
||||
|
||||
//vorlage = fh.Base64FromFile(filename);
|
||||
//vorlage = set_cmode(vorlage);
|
||||
|
||||
//fh.SaveBase64ToFile(vorlage, filename);
|
||||
|
||||
fh.SaveBase64ToFile(vorlage, filename);
|
||||
get_bookmakrs(fh.Base64FromFile(filename),ref docdata);
|
||||
Logging.Logging.Debug("Generate_Word_in_Office", "clsOffice", dokumentid);
|
||||
|
||||
dialogGenerate.set_progress(20);
|
||||
Start_Application();
|
||||
|
||||
|
||||
@@ -451,8 +493,11 @@ namespace OnDocOffice
|
||||
|
||||
|
||||
//}
|
||||
|
||||
switch (word.ActiveDocument.CompatibilityMode)
|
||||
int cmode = 0;
|
||||
cmode = word.ActiveDocument.CompatibilityMode;
|
||||
if (docdata.CompatibilityMode == "Word 2010") { cmode = 14; }
|
||||
if (docdata.CompatibilityMode == "Word 2013") { cmode = 14; }
|
||||
switch (cmode)
|
||||
{
|
||||
case 11:
|
||||
case 12:
|
||||
@@ -515,7 +560,10 @@ namespace OnDocOffice
|
||||
|
||||
}
|
||||
|
||||
worddoc = word.ActiveDocument;
|
||||
worddoc.Save();
|
||||
word.NormalTemplate.Saved = true;
|
||||
dialogGenerate.set_progress(30);
|
||||
//word.ActiveDocument.Close(false);
|
||||
Thread.Sleep(OfficeSleep);
|
||||
//worddoc = word.Documents.Open(filename);
|
||||
@@ -535,7 +583,8 @@ namespace OnDocOffice
|
||||
Kopfzeile_generieren();
|
||||
}
|
||||
//word.Visible = false;
|
||||
word.ScreenUpdating = false;
|
||||
dialogGenerate.set_progress(40);
|
||||
//word.ScreenUpdating = false;
|
||||
if (bookmarks_docio == 1)
|
||||
{
|
||||
worddoc.Save();
|
||||
@@ -545,9 +594,21 @@ namespace OnDocOffice
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
float progressstep = 1;
|
||||
try
|
||||
{
|
||||
float b = 60;
|
||||
progressstep = b/ (float)docdata.DocValues.Count();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
foreach (clsDocValue dv in docdata.DocValues)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (dv.TMBeginn.ToString() == "TGEDKCursor" || dv.TMBeginn.ToString() == "TGEDKCursorB" ||
|
||||
@@ -555,6 +616,7 @@ namespace OnDocOffice
|
||||
}
|
||||
catch { }
|
||||
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() == "")
|
||||
{
|
||||
|
||||
@@ -652,7 +714,7 @@ namespace OnDocOffice
|
||||
}
|
||||
}
|
||||
}
|
||||
word.ScreenUpdating = true;
|
||||
//word.ScreenUpdating = true;
|
||||
Logging.Logging.Debug("Word Befüllen Ende", "clsOffice", dokumentid);
|
||||
|
||||
if (docdata.Barcode == true) { Generate_Barcodes(ref docdata); }
|
||||
@@ -684,7 +746,10 @@ namespace OnDocOffice
|
||||
worddoc = null;
|
||||
word = null;
|
||||
Logging.Logging.Debug("Generierung abgeschlossen", "clsOffice", dokumentid);
|
||||
dialogGenerate.Close();
|
||||
dialogGenerate.Dispose();
|
||||
return b64;
|
||||
|
||||
//return fh.Base64FromFile(filename);
|
||||
}
|
||||
|
||||
@@ -833,6 +898,13 @@ namespace OnDocOffice
|
||||
}
|
||||
private void Generate_Barcodes(ref clsDocData docdata)
|
||||
{
|
||||
Logging.Logging.Debug("Barcode genererien start","OnDoc clsOffice",dokumentid);
|
||||
vbBarcodes.vbarcodes vbcode = new vbBarcodes.vbarcodes();
|
||||
vbcode.GenerateBarcodes(ref word, ref docdata, connectstring);
|
||||
vbcode = null;
|
||||
Logging.Logging.Debug("Barcode genererien Ende", "OnDoc clsOffice", dokumentid);
|
||||
return;
|
||||
|
||||
float left = 360;
|
||||
float top = 793;
|
||||
float width = 200;
|
||||
@@ -848,7 +920,9 @@ namespace OnDocOffice
|
||||
{
|
||||
word.Selection.GoTo(What: Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage, xname);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception e) {
|
||||
Logging.Logging.Debug("Word GotoPage " + xname + " " + e.Message, "OnDoc clsOffice", dokumentid);
|
||||
}
|
||||
HeaderFooterAnzeigen();
|
||||
if (docdata.barcode_type == "1")
|
||||
{
|
||||
@@ -873,6 +947,8 @@ 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();
|
||||
|
||||
word.Selection.ShapeRange.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
|
||||
|
||||
Reference in New Issue
Block a user