Merge branch 'feature_rene_18_ai' # Conflicts: # BeWo/BeWo.csproj # BeWo/BeWoApp.xaml.cs # BeWo/ServiceProxy/GeneratedCustomerService.cs # BeWo/ServiceProxy/GeneratedEmployeeService.cs # BeWo/ServiceProxy/GeneratedOperationsService.cs # BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs # BeWo/View/Detail/EmployeeView.xaml # BeWo/app.config # BeWoAllReports.sln # BeWoPlanerMobil.sln # Data/Access/SearchDAO.cs # Data/Data.csproj # Data/Security/UserRightHelper.cs # Server/Components/AICore/Prompt/SystemPrompts/Examples/TranscriptionService.cs # Service/DCEntityMapper/GkvAbrechnungDC_GkvAbrechnung.cs # Service/ServiceImplementations/EmployeeServiceImp.cs # Shared/BeWoEntityEnums.cs # Shared/Core/EnumTranslations.cs # Shared/Core/GkvValidator.cs # Shared/Core/ValidatorExtended.cs # Shared/Shared.csproj
139 lines
4.5 KiB
C#
139 lines
4.5 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraRichEdit;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace BeWo.Service.Dokumentverwaltung
|
|
{
|
|
public class PlaceholderManager
|
|
{
|
|
|
|
public virtual List<PlatzhalterDC> GetPlatzhalter()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public virtual string ReplacePlaceholdersInTemplate(DokumentvorlageDC template, long? objectOid, TableID tid)
|
|
{
|
|
//Nur für abgeleitete Klassen
|
|
return null;
|
|
}
|
|
|
|
public virtual void ReplacePlaceholderInText(RichEditDocumentServer rtfServer, PlatzhalterDC ph, Object obj)
|
|
{
|
|
if (!String.IsNullOrEmpty(ph.Platzhalter))
|
|
{
|
|
String platzhalter = String.Format("[{0}]", ph.Platzhalter);
|
|
|
|
String platzhalterWert = GetPlaceholderValue(ph, obj);
|
|
|
|
//var doc = rtfServer.Document as DevExpress.XtraRichEdit.API.Native.Implementation.NativeDocument;
|
|
|
|
//var list = rtfServer.Document.FindAll("blablubb", DevExpress.XtraRichEdit.API.Native.SearchOptions.None);
|
|
if (platzhalterWert == null)
|
|
{
|
|
platzhalterWert = String.Empty;
|
|
}
|
|
foreach (var shape in rtfServer.Document.Shapes)
|
|
{
|
|
var subdoc = shape.ShapeFormat?.TextBox?.Document;
|
|
if (subdoc != null)
|
|
{
|
|
subdoc.ReplaceAll(platzhalter, platzhalterWert, DevExpress.XtraRichEdit.API.Native.SearchOptions.CaseSensitive);
|
|
}
|
|
|
|
|
|
}
|
|
//var list = rtfServer.MailMerge( sd.FindAll(platzhalter1, DevExpress.XtraRichEdit.API.Native.SearchOptions.CaseSensitive);
|
|
|
|
rtfServer.Document.ReplaceAll(platzhalter, platzhalterWert, DevExpress.XtraRichEdit.API.Native.SearchOptions.CaseSensitive);
|
|
//sd.ReplaceAll(platzhalter1, GetPlaceholderValue(ph, obj), DevExpress.XtraRichEdit.API.Native.SearchOptions.CaseSensitive);
|
|
//if (text.Contains(platzhalter1))
|
|
//{
|
|
// int test = 0;
|
|
//}
|
|
|
|
//if (text.Contains(platzhalter1) || text.Contains(platzhalter2) || text.Contains(platzhalter3))
|
|
//{
|
|
// return text.Replace(ph.Platzhalter, GetPlaceholderValue(ph, obj));
|
|
//}
|
|
}
|
|
}
|
|
|
|
public virtual String GetPlaceholderValue(PlatzhalterDC ph, Object obj)
|
|
{
|
|
if (!String.IsNullOrEmpty(ph.FieldName))
|
|
{
|
|
var returnObj = GetPlaceholderValue(ph.FieldName, obj);
|
|
if (returnObj != null)
|
|
{
|
|
if (!String.IsNullOrEmpty(ph.Format))
|
|
{
|
|
return String.Format("{0:" + ph.Format + "}", returnObj);
|
|
}
|
|
return returnObj.ToString();
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
public virtual Object GetPlaceholderValue(String fieldName, Object obj)
|
|
{
|
|
var names = fieldName.Split('.');
|
|
|
|
if (names.Length > 0)
|
|
{
|
|
var name = names[0];
|
|
|
|
var prop = obj.GetType().GetProperty(names[0]);
|
|
|
|
if (prop != null)
|
|
{
|
|
Object newObj = prop.GetValue(obj);
|
|
|
|
|
|
if (names.Length > 1 && newObj != null)
|
|
{
|
|
String newFieldname = "";
|
|
|
|
for (int i = 1; i < names.Length; i++)
|
|
{
|
|
if (newFieldname.Length > 0)
|
|
{
|
|
newFieldname += ".";
|
|
}
|
|
newFieldname += names[i];
|
|
}
|
|
|
|
return GetPlaceholderValue(newFieldname, newObj);
|
|
}
|
|
if (newObj != null)
|
|
{
|
|
return newObj;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
}
|
|
|
|
public virtual Object GetEntityObject(long oid)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|