From 321482e78d50954a0f5ac64ca943e1733d901407 Mon Sep 17 00:00:00 2001 From: Kavitha Muralitharan <98306850+KAVITHAMURALITHARAN@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:03:46 +0530 Subject: [PATCH 1/4] MailMerge-Subitem --- .../Controllers/DocumentEditorController.cs | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index 83557e5..8750167 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -136,7 +136,83 @@ public class UploadDocument public string DocumentName { get; set; } } + [AcceptVerbs("Post")] + [HttpPost] + [EnableCors("AllowAllOrigins")] + [Route("FindReplace")] + public string FindReplace([FromBody] ExportData exportData) + { + + Byte[] data = Convert.FromBase64String(exportData.documentData.Split(',')[1]); + MemoryStream stream = new MemoryStream(); + stream.Write(data, 0, data.Length); + stream.Position = 0; + try + { + Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx); + foreach (KeyValuePair item in GetData()) + { + document.Replace(item.Key.ToString(), item.Value.ToString(), true, true); + } + document.Save(stream, Syncfusion.DocIO.FormatType.Docx); + } + catch (Exception ex) + { } + string sfdtText = ""; + Syncfusion.EJ2.DocumentEditor.WordDocument document1 = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx); + document1.OptimizeSfdt = false; + sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(document1); + document1.Dispose(); + return sfdtText; + } + [AcceptVerbs("Post")] + [HttpPost] + [EnableCors("AllowAllOrigins")] + [Route("Back")] + public string Back([FromBody] ExportData exportData) + { + + Byte[] data = Convert.FromBase64String(exportData.documentData.Split(',')[1]); + MemoryStream stream = new MemoryStream(); + stream.Write(data, 0, data.Length); + stream.Position = 0; + try + { + Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx); + foreach (KeyValuePair item in GetData()) + { + document.Replace(item.Value.ToString(), item.Key.ToString(), true, true); + } + document.Save(stream, Syncfusion.DocIO.FormatType.Docx); + } + catch (Exception ex) + { } + string sfdtText = ""; + Syncfusion.EJ2.DocumentEditor.WordDocument document1 = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx); + document1.OptimizeSfdt = false; + sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(document1); + document1.Dispose(); + return sfdtText; + } + /// + /// Get the datas to perform find and replace. + /// + /// public class CustomerDataModel + + private Dictionary GetData() + { + Dictionary data = new Dictionary(); + data.Add("<>", "$11000"); + data.Add("<>", "$12000"); + data.Add("<>", "$13000"); + data.Add("<>", "$14000"); + data.Add("<>", "$15000"); + data.Add("<>", "$16000"); + data.Add("<>", "$17000"); + data.Add("<>", "$18000"); + return data; + } [AcceptVerbs("Post")] [HttpPost] [EnableCors("AllowAllOrigins")] From b91a868343a177fe7d0f6103ab96ee03caf498d4 Mon Sep 17 00:00:00 2001 From: Kavitha Muralitharan <98306850+KAVITHAMURALITHARAN@users.noreply.github.com> Date: Wed, 19 Apr 2023 17:58:29 +0530 Subject: [PATCH 2/4] MailMerge_Subitem --- ASP.NET Core/src/Controllers/DocumentEditorController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index 8750167..9ac018c 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -152,7 +152,7 @@ public string FindReplace([FromBody] ExportData exportData) Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx); foreach (KeyValuePair item in GetData()) { - document.Replace(item.Key.ToString(), item.Value.ToString(), true, true); + document.Replace(item.Key.ToString(), item.Value.ToString(), true, false); } document.Save(stream, Syncfusion.DocIO.FormatType.Docx); } @@ -182,7 +182,7 @@ public string Back([FromBody] ExportData exportData) Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx); foreach (KeyValuePair item in GetData()) { - document.Replace(item.Value.ToString(), item.Key.ToString(), true, true); + document.Replace(item.Value.ToString(), item.Key.ToString(), true, false); } document.Save(stream, Syncfusion.DocIO.FormatType.Docx); } From 3ac0958bc548022c833c16bfa089e89ff9428c4c Mon Sep 17 00:00:00 2001 From: Kavitha Muralitharan <98306850+KAVITHAMURALITHARAN@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:16:57 +0530 Subject: [PATCH 3/4] DocumentEditorController.cs updated for number of list view for mail merge --- .../Controllers/DocumentEditorController.cs | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index 9ac018c..55574d3 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -245,18 +245,18 @@ public class CustomerDataModel public static List GetAllRecords() { List customers = new List(); - customers.Add(new Customer("9072379", "50%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "2000", "19072379", "Folk och fä HB", "100000", "440", "32.34", "472.34", "28023", "12000", "2020-11-07 00:00:00", "2020-12-07 00:00:00")); - customers.Add(new Customer("9072378", "20%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "", "2", "19072369", "Maersk", "140000", "245", "20", "265", "28024", "12400", "2020-11-31 00:00:00", "2020-12-22300:00:00")); - customers.Add(new Customer("9072377", "30%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "100", "19072879", "Mediterranean Shipping Company", "104000", "434", "50.43", "484.43", "28025", "10000", "2020-11-07 00:00:00", "2020-12-02 00:00:00")); - customers.Add(new Customer("9072393", "10%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "2050", "19072378", "China Ocean Shipping Company", "175000", "500", "32", "532", "28026", "17000", "2020-09-23 00:00:00", "2020-10-09 00:00:00")); - customers.Add(new Customer("9072377", "14%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "2568", "19072380", "CGM", "155000", "655", "20.54", "675.54", "28027", "13000", "2020-10-11 00:00:00", "2020-11-17 00:00:00")); - customers.Add(new Customer("9072376", "0%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "1532", "19072345", " Hapag-Lloyd", "106500", "344", "30", "374", "28028", "14500", "2020-06-17 00:00:00", "2020-07-07 00:00:00")); - customers.Add(new Customer("9072369", "05%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "4462", "190723452", "Ocean Network Express", "100054", "541", "50", "591", "28029", "16500", "2020-04-07 00:00:00", "2020-05-07 00:00:00")); - customers.Add(new Customer("9072359", "4%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "27547", "190723713", "Evergreen Line", "124000", "800", "10.23", "810.23", "28030", "12500", "2020-03-07 00:00:00", "2020-04-07 00:00:00")); - customers.Add(new Customer("9072380", "20%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "7582", "19072312", "Yang Ming Marine Transport", "1046000", "290", "10", "300", "27631", "12670", "2020-11-10 00:00:00", "2020-12-13 00:00:00")); - customers.Add(new Customer("9072381", "42%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "862", "19072354", "Hyundai Merchant Marine", "145000", "800", "10.23", "810.23", "28032", "45000", "2020-10-17 00:00:00", "2020-12-23 00:00:00")); - customers.Add(new Customer("9072391", "84%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "82", "19072364", "Pacific International Line", "10094677", "344", "30", "374", "28033", "16500", "2020-11-14 00:00:00", "2020-12-21 00:00:00")); - customers.Add(new Customer("9072392", "92%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "82", "19072385", "Österreichischer Lloyd", "104270", "500", "32", "532", "28034", "156500", "2020-06-07 00:00:00", "2020-07-07 00:00:00")); + customers.Add(new Customer("9072379", "50%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "2000", "19072379", "Folk och fä HB", "100000", "440", "32.34", "472.34", "28023", "12000", "2020-11-07 00:00:00", "2020-12-07 00:00:00", "Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072378", "20%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "", "2", "19072369", "Maersk", "140000", "245", "20", "265", "28024", "12400", "2020-11-31 00:00:00", "2020-12-22300:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072377", "30%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "100", "19072879", "Mediterranean Shipping Company", "104000", "434", "50.43", "484.43", "28025", "10000", "2020-11-07 00:00:00", "2020-12-02 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072393", "10%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "2050", "19072378", "China Ocean Shipping Company", "175000", "500", "32", "532", "28026", "17000", "2020-09-23 00:00:00", "2020-10-09 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072377", "14%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "2568", "19072380", "CGM", "155000", "655", "20.54", "675.54", "28027", "13000", "2020-10-11 00:00:00", "2020-11-17 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072376", "0%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "1532", "19072345", " Hapag-Lloyd", "106500", "344", "30", "374", "28028", "14500", "2020-06-17 00:00:00", "2020-07-07 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072369", "05%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "4462", "190723452", "Ocean Network Express", "100054", "541", "50", "591", "28029", "16500", "2020-04-07 00:00:00", "2020-05-07 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072359", "4%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "27547", "190723713", "Evergreen Line", "124000", "800", "10.23", "810.23", "28030", "12500", "2020-03-07 00:00:00", "2020-04-07 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072380", "20%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "7582", "19072312", "Yang Ming Marine Transport", "1046000", "290", "10", "300", "27631", "12670", "2020-11-10 00:00:00", "2020-12-13 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072381", "42%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "862", "19072354", "Hyundai Merchant Marine", "145000", "800", "10.23", "810.23", "28032", "45000", "2020-10-17 00:00:00", "2020-12-23 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072391", "84%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "82", "19072364", "Pacific International Line", "10094677", "344", "30", "374", "28033", "16500", "2020-11-14 00:00:00", "2020-12-21 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); + customers.Add(new Customer("9072392", "92%", "C/ Araquil, 67", "Madrid", "22020-08-10 00:00:00", "Spain", "Brittania", "82", "19072385", "Österreichischer Lloyd", "104270", "500", "32", "532", "28034", "156500", "2020-06-07 00:00:00", "2020-07-07 00:00:00","Syncfusion", "React","MailMerge", "Chikku", "Tomato", "Milk")); return customers; } } @@ -280,8 +280,25 @@ public class Customer public string RequiredDate { get; set; } public string ShippedDate { get; set; } public string ExtendedPrice { get; set; } - public Customer(string orderId, string discount, string shipAddress, string shipCity, string orderDate, string shipCountry, string productName, string quantity, string customerID, string shipName, string unitPrice, string subtotal, string freight, string total, string shipPostalCode, string extendedPrice, string requiredDate, string shippedDate) + + + + public string Company { get; set; } + public string Platform { get; set; } + public string Subject { get; set; } + + public string Fruit { get; set; } + public string Vegetable { get; set; } + public string Drink { get; set; } + + public Customer(string orderId, string discount, string shipAddress, string shipCity, string orderDate, string shipCountry, string productName, string quantity, string customerID, string shipName, string unitPrice, string subtotal, string freight, string total, string shipPostalCode, string extendedPrice, string requiredDate, string shippedDate,string company, string platform, string subject, string fruit, string vegetable, string drink) { + this.Company = company; + this.Platform = platform; + this.Subject = subject; + this.Fruit = fruit; + this.Vegetable = vegetable; + this.Drink = drink; this.CustomerID = customerID; this.ProductName = productName; this.Quantity = quantity; @@ -308,9 +325,6 @@ public class ExportData public string documentData { get; set; } } - - - public class CustomParameter { public string content { get; set; } From b5dda8b72ef23038f07114ba04ec212263c8c020 Mon Sep 17 00:00:00 2001 From: Kavitha Muralitharan <98306850+KAVITHAMURALITHARAN@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:20:21 +0530 Subject: [PATCH 4/4] DocumentEditorController.cs updated --- ASP.NET Core/src/Controllers/DocumentEditorController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index 55574d3..0eb62b6 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -325,6 +325,7 @@ public class ExportData public string documentData { get; set; } } + public class CustomParameter { public string content { get; set; }