private void button2_Click(object sender, EventArgs e) { try { ProcessXmlHandler.ProcessXmlHandler client = new ProcessXmlHandler.ProcessXmlHandler(); pdf_stamper_request request = new pdf_stamper_request(); request.pdf_template_list = new template[] { Interfaces.template.Obrazac1 }; string json = JsonConvert.SerializeObject(GetTestData(), new Serialization.DataTableConverter()); //request.data = GetTestData().SerializeXml(); request.data = json; request.read_only = false; request.debug_mode = false; request.merge_output = false; //string request_string = request.SerializeXml(); string request_string = JsonConvert.SerializeObject(request); string response_string = client.ProcessRequestJson(request_string); //pdf_stamper_response response = response_string.DeserializeXml2<pdf_stamper_response>(); pdf_stamper_response response = JsonConvert.DeserializeObject <pdf_stamper_response>(response_string); ProcessResponse(response); } catch (Exception ex) { string message = Logging.CreateExceptionMessage(ex); Logging.Singleton.WriteDebug(message); MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public string ProcessRequest(string request_string) { try { Logging.Singleton.WriteDebug(request_string); pdf_stamper_request request = request_string.DeserializeXml2 <pdf_stamper_request>(); //pdf_stamper_request request = JsonConvert.DeserializeObject<pdf_stamper_request>(request_string); pdf_stamper_response response = new pdf_stamper_response(); //ovo je neophodno samo inicijalno, da se napravi mapping za sve fajlove //PdfFormEditor.InitMappings(Global.TemplateRootPath, Global.MappingRootPath, Global.OutputRootPath); DataTable data = request.data.DeserializeXml2 <DataTable>(); string output_root_path = Global.OutputRootPath; bool force_unc = false; if (request.output_root_path != string.Empty) { output_root_path = request.output_root_path; force_unc = true; } response.response_items = PdfFormEditor.FillForm(request, Global.MappingRootPath, Global.TemplateRootPath, output_root_path, data, Global.FontsRootPath, force_unc); string response_string = response.SerializeXml(); //Logging.Singleton.WriteDebug(response_string); //string response_string = JsonConvert.SerializeObject(response); return(response_string); } catch (Exception ex) { //logging string message = Logging.CreateExceptionMessage(ex); Logging.Singleton.WriteDebug(message); return("Error"); } }
private static void ProcessResponse2(pdf_stamper_response response) { if (response.response_items != null && response.response_items.Count() > 0) { foreach (var item in response.response_items) { Process.Start(item.unc_path); } } }
private static void ProcessResponse(pdf_stamper_response response) { if (response.response_items != null && response.response_items.Count() > 0) { foreach (var item in response.response_items) { SaveFileDialog d = new SaveFileDialog(); d.FileName = Path.Combine(@"D:\", string.Format("{0}.pdf", item.pdf_template)); d.Filter = "Pdf files|*.pdf"; var res = d.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { string path = d.FileName; File.WriteAllBytes(path, Convert.FromBase64String(item.data)); Process.Start(path); } } } }