Initial Comit
This commit is contained in:
1
DOCGEN/.vs/DOCGEN.csproj.dtbcache.json
Normal file
1
DOCGEN/.vs/DOCGEN.csproj.dtbcache.json
Normal file
File diff suppressed because one or more lines are too long
2
DOCGEN/ClassDiagram1.cd
Normal file
2
DOCGEN/ClassDiagram1.cd
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram />
|
||||
102
DOCGEN/DOCGEN.csproj
Normal file
102
DOCGEN/DOCGEN.csproj
Normal file
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{820F669A-5881-4145-B202-32B53A62989B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DOCGEN</RootNamespace>
|
||||
<AssemblyName>DOCGEN</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.5.3.2\lib\net46\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog.Database, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.Database.5.3.2\lib\net46\NLog.Database.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Syncfusion.Compression.Base, Version=25.2462.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Syncfusion.Compression.Base.25.2.5\lib\net462\Syncfusion.Compression.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Syncfusion.DocIO.Base, Version=25.2462.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Syncfusion.DocIO.WinForms.25.2.5\lib\net462\Syncfusion.DocIO.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Syncfusion.DocToPdfConverter.Base, Version=25.2462.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Syncfusion.DocToPDFConverter.WinForms.25.2.5\lib\net462\Syncfusion.DocToPdfConverter.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Syncfusion.Licensing, Version=25.2462.5.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Syncfusion.Licensing.25.2.5\lib\net462\Syncfusion.Licensing.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Syncfusion.OfficeChart.Base, Version=25.2462.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Syncfusion.OfficeChart.Base.25.2.5\lib\net462\Syncfusion.OfficeChart.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Syncfusion.Pdf.Base, Version=25.2462.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Syncfusion.Pdf.WinForms.25.2.5\lib\net462\Syncfusion.Pdf.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Syncfusion.XlsIO.Base, Version=25.2462.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Syncfusion.XlsIO.WinForms.25.2.5\lib\net462\Syncfusion.XlsIO.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="clsDocGen.cs" />
|
||||
<Compile Include="clsDocGet.cs" />
|
||||
<Compile Include="Klassen\DocGenerator_from_EDOKA.cs" />
|
||||
<Compile Include="Klassen\SyncFPDF.cs" />
|
||||
<Compile Include="Klassen\SyndFExcel.cs" />
|
||||
<Compile Include="Klassen\SynFWord.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Klassendiagramm.cd" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Database\EDOKA_Database.csproj">
|
||||
<Project>{98ffa7f4-2784-4815-a2ea-83dfc1adbea1}</Project>
|
||||
<Name>EDOKA_Database</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Helper\Helper.csproj">
|
||||
<Project>{216c1660-5ad5-4a5e-80e4-150ccf673cbc}</Project>
|
||||
<Name>Helper</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Model\Model.csproj">
|
||||
<Project>{a1fd0973-89a7-4588-877d-373835d6e00c}</Project>
|
||||
<Name>Model</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
95
DOCGEN/Klassen/DocGenerator_from_EDOKA.cs
Normal file
95
DOCGEN/Klassen/DocGenerator_from_EDOKA.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using edoka_dms;
|
||||
using DOCGEN.Klassen;
|
||||
using EDOKA_Database;
|
||||
using System.Data;
|
||||
using Model;
|
||||
using System.Diagnostics;
|
||||
using NLog;
|
||||
|
||||
namespace DOCGEN.Generator
|
||||
{
|
||||
|
||||
public class DocGenerator_from_EDOKA
|
||||
{
|
||||
public string connectionstring;
|
||||
public string DokumentID;
|
||||
public string tempdir;
|
||||
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
public DocGenerator_from_EDOKA(string connectionstring)
|
||||
{
|
||||
this.connectionstring = connectionstring;
|
||||
}
|
||||
|
||||
public DocGenerator_from_EDOKA(string connectionstring, string tempdir)
|
||||
{
|
||||
this.connectionstring = connectionstring;
|
||||
this.tempdir = tempdir;
|
||||
}
|
||||
|
||||
public string Generate_Doc_EDOKA(string dokumentid)
|
||||
{
|
||||
EDOKA_DB db = new EDOKA_DB(connectionstring);
|
||||
DataTable dt = new DataTable();
|
||||
string Apptype = "";
|
||||
dt = db.Get_Vorlage_By_DokumentID(DokumentID);
|
||||
db.dsdaten.Tables.Clear();
|
||||
Apptype = db.Get_ApplicationType_from_Vorlage(Convert.ToInt32(dt.Rows[0]["nr"].ToString()));
|
||||
switch(Apptype.ToUpper())
|
||||
{
|
||||
case "DOCX": case "DOCM": case "DOC": case "DOT": case "Word":
|
||||
SynFWord sfword = new SynFWord();
|
||||
clsDocData docdata = new clsDocData();
|
||||
docdata.PartnerNr = "1234";
|
||||
generate_docdata(dokumentid, ref docdata);
|
||||
string doc = sfword.Generate_Word(dt.Rows[0][0].ToString(),docdata);
|
||||
return doc;
|
||||
//System.IO.File.WriteAllBytes(tempdir + @"\" + dokumentid + ".docx", Convert.FromBase64String(doc));
|
||||
//Process.Start(tempdir + @"\" + dokumentid + ".docx");
|
||||
//break;
|
||||
case "XLSM": case "XLSX": case "XLST": case "XLS": case "XLT":
|
||||
return "";
|
||||
//break;
|
||||
case "PDF": case "ACROBAT": case "FORMULAR": case "DOKUMENT":
|
||||
string pdf = dt.Rows[0][0].ToString();
|
||||
return pdf;
|
||||
//break ;
|
||||
default:
|
||||
Logger.Info("DocGenerator_from_EDOKA: FileType unknown"+ Apptype);
|
||||
return "";
|
||||
//break;
|
||||
}
|
||||
|
||||
//db.get_vorlage_to_file(db.dsdaten.Tables[0].Rows[0][1].ToString(),tempdir,dokumentid );
|
||||
}
|
||||
|
||||
public void generate_docdata(string dokumentid, ref clsDocData docdata)
|
||||
{
|
||||
List<clsDocValue> docValues = new List<clsDocValue>();
|
||||
EDOKA_Database.EDOKA_DB db = new EDOKA_Database.EDOKA_DB(connectionstring);
|
||||
db.Get_Tabledata("exec sp_dokumentwerte '" + dokumentid + "',0", false, true);
|
||||
foreach (DataRow r in db.dsdaten.Tables[0].Rows)
|
||||
{
|
||||
clsDocValue dv = new clsDocValue();
|
||||
dv.TMBeginn = r["beginntextmarke"].ToString();
|
||||
dv.TMEnd = r["endetextmarke"].ToString();
|
||||
dv.FieldName = r["feldname"].ToString();
|
||||
dv.Value = r["xvalue"].ToString();
|
||||
docValues.Add(dv);
|
||||
}
|
||||
clsDocValue dv1 = new clsDocValue();
|
||||
dv1.TMBeginn = "";
|
||||
dv1.TMEnd = "";
|
||||
dv1.FieldName = "Text1";
|
||||
dv1.Value = "Das ist der Text, welcher automatisch in die Briefvorlage kopiert wird. " + "\r\n"+
|
||||
"Mit einem Zeilenumbruch";
|
||||
docValues.Add(dv1);
|
||||
docdata.As_Faksimile = "True";
|
||||
docdata.DocValues = docValues;
|
||||
}
|
||||
}
|
||||
}
|
||||
308
DOCGEN/Klassen/SynFWord.cs
Normal file
308
DOCGEN/Klassen/SynFWord.cs
Normal file
@@ -0,0 +1,308 @@
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using Syncfusion.DocIO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Syncfusion.Calculate;
|
||||
using Helper;
|
||||
using System.Data;
|
||||
using Model;
|
||||
using System.Linq.Expressions;
|
||||
using NLog;
|
||||
using Syncfusion.XlsIO.Implementation.XmlSerialization;
|
||||
using System.Security.Authentication.ExtendedProtection;
|
||||
using System.Drawing;
|
||||
using Syncfusion.XPS;
|
||||
using System.Xml.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace DOCGEN.Klassen
|
||||
{
|
||||
public class SynFWord
|
||||
{
|
||||
public string Generate_Word(string base64, clsDocData docdata)
|
||||
{
|
||||
|
||||
string formattype = "";
|
||||
MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(base64));
|
||||
WordDocument document = new WordDocument(ms, FormatType.Doc);
|
||||
formattype = document.ActualFormatType.ToString();
|
||||
var formattype_original = document.ActualFormatType;
|
||||
|
||||
foreach (clsDocValue dv in docdata.DocValues)
|
||||
{
|
||||
if (dv.TMBeginn.ToString() != "" && dv.TMEnd.ToString() == "")
|
||||
{
|
||||
try
|
||||
{
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
if ((dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99" || dv.TMBeginn.ToString() == "TGEDKVornameNameRechtsB99") && docdata.As_Faksimile == "True")
|
||||
{
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
IWParagraph paragraph = new WParagraph(document);
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
System.Drawing.Image image = System.Drawing.Image.FromFile(@"x:\docdemo\unterschriften\kube1.png");
|
||||
paragraph.AppendPicture(image);
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
paragraph.AppendText(dv.Value.ToString());
|
||||
bookmarkNavigator.InsertParagraph(paragraph);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
bookmarkNavigator.InsertText(dv.Value.ToString());
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
if (dv.TMBeginn.ToString() != "" && dv.TMEnd.ToString() != "")
|
||||
{
|
||||
try
|
||||
{
|
||||
ReplaceBookmarkContent(document, dv.TMBeginn.ToString(), dv.TMEnd.ToString(), dv.Value.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (dv.FieldName.ToString() != "")
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (WSection section in document.Sections)
|
||||
//Iterates through section child elements
|
||||
foreach (WTextBody textBody in section.ChildEntities)
|
||||
{
|
||||
//Iterates through form fields
|
||||
foreach (WFormField formField in textBody.FormFields)
|
||||
{
|
||||
if (formField.Name == dv.FieldName.ToString())
|
||||
{
|
||||
formField.Text = dv.Value.ToString();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
}
|
||||
if (docdata.As_Faksimile == "True")
|
||||
{
|
||||
|
||||
TextSelection[] textSelections = document.FindAll("Thurgauer Kantonalbank", false, true);
|
||||
foreach (TextSelection selection in textSelections)
|
||||
{
|
||||
WTextRange textRange = selection.GetAsOneRange();
|
||||
WTextBody ownerTextBody = textRange.OwnerParagraph.OwnerTextBody;
|
||||
//Get the index of the paragraph with specified text
|
||||
int ownerParaIndex = ownerTextBody.ChildEntities.IndexOf(textRange.OwnerParagraph);
|
||||
//Check whether the previous and next paragraphs are empty and remove them
|
||||
if (ownerParaIndex > 0 && ownerTextBody.ChildEntities[ownerParaIndex - 1] is WParagraph &&
|
||||
(ownerTextBody.ChildEntities[ownerParaIndex - 1] as WParagraph).Items.Count == 0)
|
||||
{
|
||||
ownerTextBody.ChildEntities.RemoveAt(ownerParaIndex - 1);
|
||||
}
|
||||
if (ownerParaIndex + 1 < ownerTextBody.ChildEntities.Count &&
|
||||
ownerTextBody.ChildEntities[ownerParaIndex + 1] is WParagraph &&
|
||||
(ownerTextBody.ChildEntities[ownerParaIndex + 1] as WParagraph).Items.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
try
|
||||
{
|
||||
ownerTextBody.ChildEntities.RemoveAt(ownerParaIndex + 1);
|
||||
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
document.Save(@"x:\docdemo\unterschriften\gaga.docx");
|
||||
document.Save(ms, formattype_original);
|
||||
document.Close();
|
||||
byte[] imageArray = ms.ToArray();
|
||||
return Convert.ToBase64String(imageArray);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void ReplaceBookmarkText(WordDocument document, string bookmarkName, string textToFind, string textToReplace)
|
||||
{
|
||||
//Check whether the bookmark name is valid.
|
||||
if (string.IsNullOrEmpty(bookmarkName) || document.Bookmarks.FindByName(bookmarkName) == null)
|
||||
return;
|
||||
//Move to the virtual cursor before the bookmark end location of the bookmark.
|
||||
BookmarksNavigator bookmarksNavigator = new BookmarksNavigator(document);
|
||||
bookmarksNavigator.MoveToBookmark(bookmarkName);
|
||||
//Replace the bookmark content with new text.
|
||||
TextBodyPart textBodyPart = bookmarksNavigator.GetBookmarkContent();
|
||||
//Get paragraph from the textBody part.
|
||||
foreach (TextBodyItem item in textBodyPart.BodyItems)
|
||||
{
|
||||
IterateTextBody(item, textToFind, textToReplace);
|
||||
}
|
||||
//Replace the bookmark content with text body part.
|
||||
bookmarksNavigator.ReplaceBookmarkContent(textBodyPart);
|
||||
}
|
||||
public static void IterateTextBody(TextBodyItem item, string textToFind, string textToReplace)
|
||||
{
|
||||
switch (item.EntityType)
|
||||
{
|
||||
case EntityType.Paragraph:
|
||||
WParagraph paragraph = (WParagraph)item;
|
||||
//Replace a text in the bookmark content.
|
||||
paragraph.Replace(new System.Text.RegularExpressions.Regex(textToFind), textToReplace);
|
||||
break;
|
||||
case EntityType.Table:
|
||||
WTable table = (WTable)item;
|
||||
foreach (WTableRow row in table.Rows)
|
||||
{
|
||||
foreach (WTableCell cell in row.Cells)
|
||||
{
|
||||
foreach (TextBodyItem bodyItem in cell.ChildEntities)
|
||||
{
|
||||
IterateTextBody(bodyItem, textToFind, textToReplace);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EntityType.BlockContentControl:
|
||||
WTextBody body = (item as IBlockContentControl).TextBody;
|
||||
foreach (TextBodyItem bodyitem in body.ChildEntities)
|
||||
IterateTextBody(bodyitem, textToFind, textToReplace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReplaceBookmarkContent(WordDocument document, String bookmark1, String bookmark2, String replacementContent)
|
||||
{
|
||||
//Temp Bookmark.
|
||||
String tempBookmarkName = "tempBookmark";
|
||||
|
||||
#region Insert bookmark start after bookmark1.
|
||||
//Get the bookmark instance by using FindByName method of BookmarkCollection with bookmark name.
|
||||
Bookmark firstBookmark = document.Bookmarks.FindByName(bookmark1);
|
||||
//Access the bookmark end’s owner paragraph by using bookmark.
|
||||
WParagraph firstBookmarkOwnerPara = firstBookmark.BookmarkEnd.OwnerParagraph;
|
||||
//Get the index of bookmark end of bookmark1.
|
||||
int index = firstBookmarkOwnerPara.Items.IndexOf(firstBookmark.BookmarkEnd);
|
||||
//Create and add new bookmark start after bookmark1.
|
||||
BookmarkStart newBookmarkStart = new BookmarkStart(document, tempBookmarkName);
|
||||
firstBookmarkOwnerPara.ChildEntities.Insert(index + 1, newBookmarkStart);
|
||||
#endregion
|
||||
|
||||
#region Insert bookmark end before bookmark2.
|
||||
//Get the bookmark instance by using FindByName method of BookmarkCollection with bookmark name.
|
||||
Bookmark secondBookmark = document.Bookmarks.FindByName(bookmark2);
|
||||
//Access the bookmark start’s owner paragraph by using bookmark.
|
||||
WParagraph secondBookmarkOwnerPara = secondBookmark.BookmarkStart.OwnerParagraph;
|
||||
//Get the index of bookmark start of bookmark2.
|
||||
index = secondBookmarkOwnerPara.Items.IndexOf(secondBookmark.BookmarkStart);
|
||||
//Create and add new bookmark end before bookmark2.
|
||||
BookmarkEnd newBookmarkEnd = new BookmarkEnd(document, tempBookmarkName);
|
||||
secondBookmarkOwnerPara.ChildEntities.Insert(index, newBookmarkEnd);
|
||||
#endregion
|
||||
|
||||
#region Select bookmark content and replace.
|
||||
//Create the bookmark navigator instance to access the newly created bookmark.
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
//Move the virtual cursor to the location of the temp bookmark.
|
||||
bookmarkNavigator.MoveToBookmark(tempBookmarkName);
|
||||
//Replace the bookmark content.
|
||||
bookmarkNavigator.ReplaceBookmarkContent(replacementContent, true);
|
||||
#endregion
|
||||
|
||||
#region Remove that temporary bookmark.
|
||||
//Get the bookmark instance by using FindByName method of BookmarkCollection with bookmark name.
|
||||
Bookmark bookmark = document.Bookmarks.FindByName(tempBookmarkName);
|
||||
//Remove the temp bookmark named from Word document.
|
||||
document.Bookmarks.Remove(bookmark);
|
||||
#endregion
|
||||
}
|
||||
private void RemoveEmptyParagraph(IWSection curSection)
|
||||
{
|
||||
int j = 0;
|
||||
int paraCount = 0;
|
||||
while (j < curSection.Body.ChildEntities.Count)
|
||||
{
|
||||
//Read the section text body
|
||||
WTextBody textBody = curSection.Body;
|
||||
|
||||
//Read all the body items collection
|
||||
BodyItemCollection textbodycollection = textBody.ChildEntities as BodyItemCollection;
|
||||
if (textbodycollection[j].EntityType == EntityType.Paragraph)
|
||||
{
|
||||
IWParagraph paragraph = textbodycollection[j] as IWParagraph;
|
||||
if (paragraph.Items.Count == 0)
|
||||
{
|
||||
//Remove the empty paragraph to the Section
|
||||
curSection.Paragraphs.RemoveAt(paraCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
paraCount++;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private static Entity GetOwnerEntity(BookmarkStart bookmarkStart)
|
||||
{
|
||||
Entity baseEntity = bookmarkStart.Owner;
|
||||
|
||||
while (!(baseEntity is WSection))
|
||||
{
|
||||
if (baseEntity is null)
|
||||
return baseEntity;
|
||||
baseEntity = baseEntity.Owner;
|
||||
}
|
||||
return baseEntity;
|
||||
}
|
||||
public Image resizeImage(Image imgToResize, Size size)
|
||||
{
|
||||
return (Image)(new Bitmap(imgToResize, size));
|
||||
}
|
||||
private static void FindAndReplaceInTable(WTable table, TextSelection textSelection)
|
||||
{
|
||||
//Iterate through the rows of table.
|
||||
foreach (WTableRow row in table.Rows)
|
||||
{
|
||||
//Iterate through the cells of rows.
|
||||
foreach (WTableCell cell in row.Cells)
|
||||
{
|
||||
//Iterates through the items in cell.
|
||||
foreach (Entity entity in cell.ChildEntities)
|
||||
{
|
||||
if (entity.EntityType == EntityType.Paragraph)
|
||||
{
|
||||
WParagraph paragraph = entity as WParagraph;
|
||||
//Replace the specified regular expression with a TextSelection in the paragraph.
|
||||
paragraph.Replace(new Regex("<<(.*)>>"), textSelection);
|
||||
}
|
||||
else if (entity.EntityType == EntityType.Table)
|
||||
{
|
||||
FindAndReplaceInTable(entity as WTable, textSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
DOCGEN/Klassen/SyncFPDF.cs
Normal file
13
DOCGEN/Klassen/SyncFPDF.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOCGEN.Klassen
|
||||
{
|
||||
public class SyncFPDF
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
12
DOCGEN/Klassen/SyndFExcel.cs
Normal file
12
DOCGEN/Klassen/SyndFExcel.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOCGEN.Klassen
|
||||
{
|
||||
internal class SyndFExcel
|
||||
{
|
||||
}
|
||||
}
|
||||
46
DOCGEN/Klassendiagramm.cd
Normal file
46
DOCGEN/Klassendiagramm.cd
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Class Name="DOCGEN.DocGen" Collapsed="true">
|
||||
<Position X="1.25" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ACAAAACAAAI4AAAAIAAAAACAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>clsDocGen.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DOCGEN.clsGetDoc" Collapsed="true">
|
||||
<Position X="1.25" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ACAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAACAAAAA=</HashCode>
|
||||
<FileName>clsDocGet.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DOCGEN.Generator.DocGenerator_from_EDOKA" Collapsed="true">
|
||||
<Position X="4" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ACAAAAAAAAIIAAAAAAgAAIAAAAAAAAAAAAACAAAAAAA=</HashCode>
|
||||
<FileName>Klassen\DocGenerator_from_EDOKA.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DOCGEN.Klassen.SyncFPDF" Collapsed="true">
|
||||
<Position X="7.5" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Klassen\SyncFPDF.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DOCGEN.Klassen.SyndFExcel" Collapsed="true">
|
||||
<Position X="7.5" Y="2.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Klassen\SyndFExcel.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DOCGEN.Klassen.SynFWord" Collapsed="true">
|
||||
<Position X="7.5" Y="3" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AABAAAAAAABAAAAAAAAAAAABAAAIAAAAAAAhAAAAAkA=</HashCode>
|
||||
<FileName>Klassen\SynFWord.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Font Name="Segoe UI" Size="9" />
|
||||
</ClassDiagram>
|
||||
36
DOCGEN/Properties/AssemblyInfo.cs
Normal file
36
DOCGEN/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("DOCGEN")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("HP Inc.")]
|
||||
[assembly: AssemblyProduct("DOCGEN")]
|
||||
[assembly: AssemblyCopyright("Copyright © HP Inc. 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("820f669a-5881-4145-b202-32b53a62989b")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// indem Sie "*" wie unten gezeigt eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
56
DOCGEN/clsDocGen.cs
Normal file
56
DOCGEN/clsDocGen.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using DOCGEN.Klassen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using edoka_dms;
|
||||
using Syncfusion.XlsIO.Parser.Biff_Records;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Model;
|
||||
using EDOKA_Database;
|
||||
|
||||
namespace DOCGEN
|
||||
{
|
||||
|
||||
public class DocGen
|
||||
{
|
||||
public edoka_dms.clsConnectionProvider conn_edoka = new edoka_dms.clsConnectionProvider();
|
||||
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
public string DokumentID = "";
|
||||
public string connectionstring = "";
|
||||
public clsDocData DocData = new clsDocData();
|
||||
EDOKA_DB db = new EDOKA_DB();
|
||||
|
||||
|
||||
public void Lic()
|
||||
{
|
||||
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Ngo9BigBOggjHTQxAR8/V1NBaF5cXmZCf1FpRmJGdld5fUVHYVZUTXxaS00DNHVRdkdnWXxccXVWR2VdUUZ3VkM=");
|
||||
}
|
||||
public DocGen() {
|
||||
Lic();
|
||||
}
|
||||
public DocGen(string Connectionstring)
|
||||
{
|
||||
this.connectionstring = Connectionstring;
|
||||
this.DocData = DocData;
|
||||
db.connectionstring = this.connectionstring;
|
||||
Lic();
|
||||
}
|
||||
|
||||
public void GenDoc(clsDocData docdata)
|
||||
{
|
||||
this.DocData = docdata;
|
||||
if (DocData.UseEDOKA_Values.ToUpper() == "TRUE")
|
||||
{
|
||||
DokumentID=db.Create_EDOKA_Doc(this.DocData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
38
DOCGEN/clsDocGet.cs
Normal file
38
DOCGEN/clsDocGet.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using EDOKA_Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOCGEN
|
||||
{
|
||||
public class clsGetDoc
|
||||
{
|
||||
private string connectionstring = "";
|
||||
public clsGetDoc(string Connectionstring)
|
||||
{
|
||||
this.connectionstring = Connectionstring;
|
||||
}
|
||||
public string GetDocAsPDF(string Docid)
|
||||
{
|
||||
string doc = GetDoc(Docid);
|
||||
return "";
|
||||
}
|
||||
public string GetDoc(string Docid)
|
||||
{
|
||||
EDOKA_DB db = new EDOKA_DB(connectionstring);
|
||||
db.GetDocumentAsBase64(Docid);
|
||||
if (Docid != "")
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
|
||||
BIN
DOCGEN/obj/Debug/DOCGEN.csproj.AssemblyReference.cache
Normal file
BIN
DOCGEN/obj/Debug/DOCGEN.csproj.AssemblyReference.cache
Normal file
Binary file not shown.
1
DOCGEN/obj/Debug/DOCGEN.csproj.CoreCompileInputs.cache
Normal file
1
DOCGEN/obj/Debug/DOCGEN.csproj.CoreCompileInputs.cache
Normal file
@@ -0,0 +1 @@
|
||||
56e83e04fa964d745c98ff832d51c070d351ad7d3f1071a104d9bb7cec1212a1
|
||||
32
DOCGEN/obj/Debug/DOCGEN.csproj.FileListAbsolute.txt
Normal file
32
DOCGEN/obj/Debug/DOCGEN.csproj.FileListAbsolute.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\DOCGEN.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\DOCGEN.pdb
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Database.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Model.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.Compression.Base.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.DocIO.Base.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.DocToPdfConverter.Base.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.Licensing.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.OfficeChart.Base.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.Pdf.Base.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.XlsIO.Base.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Helper.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Database.pdb
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Model.pdb
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.Compression.Base.xml
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.DocIO.Base.xml
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.DocToPdfConverter.Base.xml
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.OfficeChart.Base.xml
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.Pdf.Base.xml
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Syncfusion.XlsIO.Base.xml
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\Helper.pdb
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\obj\Debug\DOCGEN.csproj.AssemblyReference.cache
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\obj\Debug\DOCGEN.csproj.CoreCompileInputs.cache
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\obj\Debug\DOCGEN.csproj.Up2Date
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\obj\Debug\DOCGEN.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\obj\Debug\DOCGEN.pdb
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\NLog.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\NLog.xml
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\NLog.Database.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\NLog.Database.xml
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\EDOKA_Logging.dll
|
||||
X:\docdemo\EDOKA_2024\DOCGEN\bin\Debug\EDOKA_Logging.pdb
|
||||
BIN
DOCGEN/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Normal file
BIN
DOCGEN/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Normal file
Binary file not shown.
BIN
DOCGEN/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Normal file
BIN
DOCGEN/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Normal file
Binary file not shown.
12
DOCGEN/packages.config
Normal file
12
DOCGEN/packages.config
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="5.3.2" targetFramework="net481" />
|
||||
<package id="NLog.Database" version="5.3.2" targetFramework="net481" />
|
||||
<package id="Syncfusion.Compression.Base" version="25.2.5" targetFramework="net481" />
|
||||
<package id="Syncfusion.DocIO.WinForms" version="25.2.5" targetFramework="net481" />
|
||||
<package id="Syncfusion.DocToPDFConverter.WinForms" version="25.2.5" targetFramework="net481" />
|
||||
<package id="Syncfusion.Licensing" version="25.2.5" targetFramework="net481" />
|
||||
<package id="Syncfusion.OfficeChart.Base" version="25.2.5" targetFramework="net481" />
|
||||
<package id="Syncfusion.Pdf.WinForms" version="25.2.5" targetFramework="net481" />
|
||||
<package id="Syncfusion.XlsIO.WinForms" version="25.2.5" targetFramework="net481" />
|
||||
</packages>
|
||||
1
DOCGEN/testclass.cs
Normal file
1
DOCGEN/testclass.cs
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user