Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created January 14, 2021 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/732202ae58a6a937fb8ca30441c1dbd2 to your computer and use it in GitHub Desktop.
Save bjoerntx/732202ae58a6a937fb8ca30441c1dbd2 to your computer and use it in GitHub Desktop.
public static string MergeWorkorder(Workorder workorder) {
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
// load the work order template
tx.Load(HttpContext.Current.Server.MapPath(
"~/App_Data/workorder.tx"),
TXTextControl.StreamType.InternalUnicodeFormat);
MailMerge mm = new MailMerge() {
TextComponent = tx
};
// merge the data into the template
mm.MergeObject(workorder);
// generate a unique filename and save the work order
var sFileName = Helpers.GenerateUID(5);
tx.Save(HttpContext.Current.Server.MapPath("~/App_Data/" + sFileName + ".tx"),
TXTextControl.StreamType.InternalUnicodeFormat);
return sFileName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment