Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created August 22, 2022 16:06
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/fc7cc7f525ed0a6adf140ee3b0476050 to your computer and use it in GitHub Desktop.
Save bjoerntx/fc7cc7f525ed0a6adf140ee3b0476050 to your computer and use it in GitHub Desktop.
public class TextControlProcessing {
public static void Merge(ProcessingRequest request) {
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
// simulate long process
Thread.Sleep(3000);
// create document or use MailMerge to generate larger document
tx.Text = "My created document.";
byte[] data;
tx.Save(out data, TXTextControl.BinaryStreamType.AdobePDF);
request.StoreDocument(data);
}
request.Processed = true;
request.Update();
Task.Run(() => FireAndForgetWebHook(request));
}
private static void FireAndForgetWebHook(ProcessingRequest request) {
HttpClient client = new HttpClient();
var json = JsonConvert.SerializeObject(request);
var data = new StringContent(json, Encoding.UTF8, "application/json");
client.PostAsync(request.WebHookUrl, data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment