From 2147ac72640b28d2da09fdddaae47435ad2cc18d Mon Sep 17 00:00:00 2001 From: Kavitha Muralitharan Date: Mon, 4 Sep 2023 20:24:26 +0530 Subject: [PATCH 01/15] (846325): Upgraded to 6 and 7 --- ASP.NET Core/EJ2APIServices.sln | 25 ---- .../Controllers/DocumentEditorController.cs | 74 +++++++++--- ASP.NET Core/src/EJ2APIServices.csproj | 43 ------- ...WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs | 42 +++---- ASP.NET Core/src/Startup.cs | 111 ++++++++---------- ASP.NET Core/src/web.config | 4 +- Minimal Web API/DocumentEditorCore.csproj | 22 ---- Minimal Web API/DocumentEditorCore.sln | 25 ---- 8 files changed, 129 insertions(+), 217 deletions(-) delete mode 100644 ASP.NET Core/EJ2APIServices.sln delete mode 100644 ASP.NET Core/src/EJ2APIServices.csproj delete mode 100644 Minimal Web API/DocumentEditorCore.csproj delete mode 100644 Minimal Web API/DocumentEditorCore.sln diff --git a/ASP.NET Core/EJ2APIServices.sln b/ASP.NET Core/EJ2APIServices.sln deleted file mode 100644 index cf3da83..0000000 --- a/ASP.NET Core/EJ2APIServices.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27004.2009 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EJ2APIServices", "src\EJ2APIServices.csproj", "{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {00388905-5E88-4BCF-B5FC-E4CAB5FA88EE} - EndGlobalSection -EndGlobal diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index 83557e5..e521e07 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -1,29 +1,21 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using System.Net.Http; -using System.Text; -using System.IO; +using System.Text.RegularExpressions; using Microsoft.AspNetCore.Cors; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; using Syncfusion.EJ2.DocumentEditor; using WDocument = Syncfusion.DocIO.DLS.WordDocument; using WFormatType = Syncfusion.DocIO.FormatType; using Syncfusion.EJ2.SpellChecker; -using EJ2APIServices; -namespace SyncfusionDocument.Controllers +namespace EJ2APIServices.Controllers { [Route("api/[controller]")] public class DocumentEditorController : Controller { - private readonly IHostingEnvironment _hostingEnvironment; - string path; + private readonly IWebHostEnvironment _hostingEnvironment; + string? path; - public DocumentEditorController(IHostingEnvironment hostingEnvironment) + public DocumentEditorController(IWebHostEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment; path = Startup.path; @@ -35,7 +27,7 @@ public DocumentEditorController(IHostingEnvironment hostingEnvironment) [Route("Import")] public string Import(IFormCollection data) { - if (data.Files.Count == 0) + if (data.Files.Count == 0) return null; Stream stream = new MemoryStream(); IFormFile file = data.Files[0]; @@ -92,7 +84,7 @@ private static Stream GetManifestResourceStream(string fileName) [Route("SpellCheck")] public string SpellCheck([FromBody] SpellCheckJsonData spellChecker) { - try + try { SpellChecker spellCheck = new SpellChecker(); spellCheck.GetSuggestions(spellChecker.LanguageID, spellChecker.TexttoCheck, spellChecker.CheckSpelling, spellChecker.CheckSuggestion, spellChecker.AddWord); @@ -122,6 +114,56 @@ public string SpellCheckByPage([FromBody] SpellCheckJsonData spellChecker) } } + [HttpPost] + [Route("SaveAsContent")] + public string SaveAsContent([FromBody] ExportAsContentParameter args) + { + string documentName = args.DocumentName; + for (int i = 0; i < args.PageContents.Length; i++) + { + string fileName = string.Format("{0}-{1}.txt", documentName, (i + 1)); + using (StreamWriter writer = new StreamWriter(fileName)) + { + string content = ReplaceDecimalValues(args.PageContents[i]); + writer.Write(content); + writer.Dispose(); + } + } + return Newtonsoft.Json.JsonConvert.SerializeObject("Success"); + } + + private string ReplaceDecimalValues(string inputText) + { + // Finds all the occurrence of decimal values with minimum 1 decimal place and suffix string ";". + string regexPatternForDecimalValue = "([-]?[0-9]*[.]{1}[0-9]*[;])"; + MatchCollection matches = Regex.Matches(inputText, regexPatternForDecimalValue); + Dictionary keyValuePairs = new Dictionary(); + foreach (Match matchItem in matches) + { + if (keyValuePairs.ContainsKey(matchItem.Value)) + continue; + string num = matchItem.Value.Replace(";", ""); + double doubleValue; + if (double.TryParse(num, out doubleValue)) + { + string result = Math.Truncate(doubleValue).ToString(); + keyValuePairs.Add(matchItem.Value, result + ";"); + } + } + //Purpose is to resolve decimal precision mismatch in output content. + foreach (var keyValue in keyValuePairs) + { + inputText = inputText.Replace(keyValue.Key, keyValue.Value); + } + return inputText; + } + + public class ExportAsContentParameter + { + public string DocumentName { get; set; } + public string[] PageContents { get; set; } + } + public class SpellCheckJsonData { public int LanguageID { get; set; } @@ -156,7 +198,7 @@ public string MailMerge([FromBody] ExportData exportData) document.MailMerge.Execute(CustomerDataModel.GetAllRecords()); document.Save(stream, Syncfusion.DocIO.FormatType.Docx); } - catch (Exception ex) + catch (Exception) { } string sfdtText = ""; Syncfusion.EJ2.DocumentEditor.WordDocument document1 = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx); diff --git a/ASP.NET Core/src/EJ2APIServices.csproj b/ASP.NET Core/src/EJ2APIServices.csproj deleted file mode 100644 index f5939e2..0000000 --- a/ASP.NET Core/src/EJ2APIServices.csproj +++ /dev/null @@ -1,43 +0,0 @@ - - - - netcoreapp2.0 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ASP.NET Core/src/Models/EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs b/ASP.NET Core/src/Models/EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs index 7d2910b..df25851 100644 --- a/ASP.NET Core/src/Models/EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs +++ b/ASP.NET Core/src/Models/EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs @@ -1,27 +1,27 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; +//using System; +//using Microsoft.EntityFrameworkCore; +//using Microsoft.EntityFrameworkCore.Metadata; -namespace EJ2APIServices.Models -{ - public partial class EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext : DbContext - { +//namespace EJ2APIServices.Models +//{ +// public partial class EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext : DbContext +// { - public EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext(DbContextOptions options) - : base(options) - { - } +// public EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext(DbContextOptions options) +// : base(options) +// { +// } - public virtual DbSet DiagramData { get; set; } +// public virtual DbSet DiagramData { get; set; } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.Property(e => e.DiagramName).HasMaxLength(50); - }); - } - } -} +// protected override void OnModelCreating(ModelBuilder modelBuilder) +// { +// modelBuilder.Entity(entity => +// { +// entity.Property(e => e.DiagramName).HasMaxLength(50); +// }); +// } +// } +//} diff --git a/ASP.NET Core/src/Startup.cs b/ASP.NET Core/src/Startup.cs index 7d38ed7..59ba43e 100644 --- a/ASP.NET Core/src/Startup.cs +++ b/ASP.NET Core/src/Startup.cs @@ -1,35 +1,18 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Microsoft.EntityFrameworkCore; -using Microsoft.Data.Edm; -using Microsoft.AspNet.OData.Builder; -using Microsoft.AspNet.OData.Extensions; -using Microsoft.AspNetCore.Routing; -using Microsoft.OData.UriParser; -using Microsoft.AspNetCore.Cors.Infrastructure; -using EJ2APIServices.Models; -using EJ2APIServices.Controllers; -using Syncfusion.EJ2.SpellChecker; using System.IO; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.ResponseCompression; +using Newtonsoft.Json.Serialization; +using Syncfusion.EJ2.SpellChecker; using Newtonsoft.Json; - namespace EJ2APIServices { public class Startup { - private string _contentRootPath = ""; - internal static string path; + internal static string? path; - public Startup(IConfiguration configuration, IHostingEnvironment env) + public Startup(IConfiguration configuration, IWebHostEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) @@ -38,82 +21,84 @@ public Startup(IConfiguration configuration, IHostingEnvironment env) .AddEnvironmentVariables(); Configuration = builder.Build(); - _contentRootPath = env.ContentRootPath; path = Configuration["SPELLCHECK_DICTIONARY_PATH"]; - string jsonFileName = Configuration["SPELLCHECK_JSON_FILENAME"]; + string? jsonFileName = Configuration["SPELLCHECK_JSON_FILENAME"]; //check the spell check dictionary path environment variable value and assign default data folder //if it is null. - path = string.IsNullOrEmpty(path) ? Path.Combine(env.ContentRootPath, "App_Data") : Path.Combine(env.ContentRootPath, path); + path = string.IsNullOrEmpty(path) ? Path.Combine(env.ContentRootPath, "Data") : Path.Combine(env.ContentRootPath, path); //Set the default spellcheck.json file if the json filename is empty. jsonFileName = string.IsNullOrEmpty(jsonFileName) ? Path.Combine(path, "spellcheck.json") : Path.Combine(path, jsonFileName); - if (System.IO.File.Exists(jsonFileName)) + if (File.Exists(jsonFileName)) { - string jsonImport = System.IO.File.ReadAllText(jsonFileName); - List spellChecks = JsonConvert.DeserializeObject>(jsonImport); + string jsonImport = File.ReadAllText(jsonFileName); + List? spellChecks = JsonConvert.DeserializeObject>(jsonImport); List spellDictCollection = new List(); - string personalDictPath = null; + string? personalDictPath = null; //construct the dictionary file path using customer provided path and dictionary name - foreach (var spellCheck in spellChecks) + if (spellChecks != null) { - spellDictCollection.Add(new DictionaryData(spellCheck.LanguadeID, Path.Combine(path, spellCheck.DictionaryPath), Path.Combine(path, spellCheck.AffixPath))); - personalDictPath = Path.Combine(path, spellCheck.PersonalDictPath); + foreach (var spellCheck in spellChecks) + { + spellDictCollection.Add(new DictionaryData(spellCheck.LanguadeID, Path.Combine(path, spellCheck.DictionaryPath), Path.Combine(path, spellCheck.AffixPath))); + personalDictPath = Path.Combine(path, spellCheck.PersonalDictPath); + } } SpellChecker.InitializeDictionaries(spellDictCollection, personalDictPath, 3); } } public IConfiguration Configuration { get; } - + readonly string MyAllowSpecificOrigins = "MyPolicy"; // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddOData(); - services.AddMvc().AddJsonOptions(x => { - x.SerializerSettings.ContractResolver = null; + services.AddControllers(); + services.AddMemoryCache(); + services.AddControllers().AddNewtonsoftJson(options => + { + // Use the default property (Pascal) casing + options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); services.AddCors(options => { - options.AddPolicy("AllowAllOrigins", builder => + options.AddPolicy(MyAllowSpecificOrigins, + builder => { builder.AllowAnyOrigin() - .AllowAnyMethod() - .AllowAnyHeader(); + .AllowAnyMethod() + .AllowAnyHeader(); }); }); - string connection = Configuration.GetConnectionString("Test"); - if (connection.Contains("%CONTENTROOTPATH%")) - { - connection = connection.Replace("%CONTENTROOTPATH%", _contentRootPath); - - } - services.AddEntityFrameworkNpgsql().AddDbContext(options => options.UseNpgsql(connection)); - // Add framework services. - services.AddMvc(); + services.Configure(options => options.Level = System.IO.Compression.CompressionLevel.Optimal); + services.AddResponseCompression(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - app.UseDeveloperExceptionPage(); - app.UseCors("AllowAllOrigins"); + //Register Syncfusion license + string licenseKey = string.Empty; + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(licenseKey); + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - - app.UseMvc(b => + else + { + app.UseHsts(); + } + app.UseHttpsRedirection(); + app.UseRouting(); + app.UseAuthorization(); + app.UseCors(MyAllowSpecificOrigins); + app.UseResponseCompression(); + app.UseEndpoints(endpoints => { - b.Count().Filter().OrderBy().Expand().Select().MaxTop(null); + endpoints.MapControllers().RequireCors("MyPolicy"); }); - } - - } - - public class ServerPath - { - public static string MapPath = ""; } -} +} \ No newline at end of file diff --git a/ASP.NET Core/src/web.config b/ASP.NET Core/src/web.config index a130cac..2d9ed3f 100644 --- a/ASP.NET Core/src/web.config +++ b/ASP.NET Core/src/web.config @@ -10,9 +10,9 @@ - + - + diff --git a/Minimal Web API/DocumentEditorCore.csproj b/Minimal Web API/DocumentEditorCore.csproj deleted file mode 100644 index c13f629..0000000 --- a/Minimal Web API/DocumentEditorCore.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - - - - - - diff --git a/Minimal Web API/DocumentEditorCore.sln b/Minimal Web API/DocumentEditorCore.sln deleted file mode 100644 index 8842638..0000000 --- a/Minimal Web API/DocumentEditorCore.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.1.32210.238 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocumentEditorCore", "DocumentEditorCore.csproj", "{1B5FEECA-801B-456F-8565-BCD85C5A6C0D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1B5FEECA-801B-456F-8565-BCD85C5A6C0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1B5FEECA-801B-456F-8565-BCD85C5A6C0D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1B5FEECA-801B-456F-8565-BCD85C5A6C0D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1B5FEECA-801B-456F-8565-BCD85C5A6C0D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {C2B954E1-9860-48D1-8D7D-D243161FD4FC} - EndGlobalSection -EndGlobal From 8cedb663b6c534bbdcc19c7d3ecceb4f6663fa61 Mon Sep 17 00:00:00 2001 From: Kavitha Muralitharan Date: Mon, 4 Sep 2023 20:31:50 +0530 Subject: [PATCH 02/15] (846325): updated commit --- .../Controllers/DocumentEditorController.cs | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index e521e07..d6a79d5 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -114,56 +114,6 @@ public string SpellCheckByPage([FromBody] SpellCheckJsonData spellChecker) } } - [HttpPost] - [Route("SaveAsContent")] - public string SaveAsContent([FromBody] ExportAsContentParameter args) - { - string documentName = args.DocumentName; - for (int i = 0; i < args.PageContents.Length; i++) - { - string fileName = string.Format("{0}-{1}.txt", documentName, (i + 1)); - using (StreamWriter writer = new StreamWriter(fileName)) - { - string content = ReplaceDecimalValues(args.PageContents[i]); - writer.Write(content); - writer.Dispose(); - } - } - return Newtonsoft.Json.JsonConvert.SerializeObject("Success"); - } - - private string ReplaceDecimalValues(string inputText) - { - // Finds all the occurrence of decimal values with minimum 1 decimal place and suffix string ";". - string regexPatternForDecimalValue = "([-]?[0-9]*[.]{1}[0-9]*[;])"; - MatchCollection matches = Regex.Matches(inputText, regexPatternForDecimalValue); - Dictionary keyValuePairs = new Dictionary(); - foreach (Match matchItem in matches) - { - if (keyValuePairs.ContainsKey(matchItem.Value)) - continue; - string num = matchItem.Value.Replace(";", ""); - double doubleValue; - if (double.TryParse(num, out doubleValue)) - { - string result = Math.Truncate(doubleValue).ToString(); - keyValuePairs.Add(matchItem.Value, result + ";"); - } - } - //Purpose is to resolve decimal precision mismatch in output content. - foreach (var keyValue in keyValuePairs) - { - inputText = inputText.Replace(keyValue.Key, keyValue.Value); - } - return inputText; - } - - public class ExportAsContentParameter - { - public string DocumentName { get; set; } - public string[] PageContents { get; set; } - } - public class SpellCheckJsonData { public int LanguageID { get; set; } From 2ac8a497095e1a7b416ad863af7e24c7ffc20c8d Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Mon, 4 Sep 2023 21:41:06 +0530 Subject: [PATCH 03/15] Added project file --- ASP.NET Core/EJ2APIServices_NET6.sln | 25 +++++++++++++++++++++ ASP.NET Core/EJ2APIServices_NET7.sln | 25 +++++++++++++++++++++ ASP.NET Core/src/EJ2APIServices_NET6.csproj | 21 +++++++++++++++++ ASP.NET Core/src/EJ2APIServices_NET7.csproj | 21 +++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 ASP.NET Core/EJ2APIServices_NET6.sln create mode 100644 ASP.NET Core/EJ2APIServices_NET7.sln create mode 100644 ASP.NET Core/src/EJ2APIServices_NET6.csproj create mode 100644 ASP.NET Core/src/EJ2APIServices_NET7.csproj diff --git a/ASP.NET Core/EJ2APIServices_NET6.sln b/ASP.NET Core/EJ2APIServices_NET6.sln new file mode 100644 index 0000000..b5e5ec6 --- /dev/null +++ b/ASP.NET Core/EJ2APIServices_NET6.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2009 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EJ2APIServices", "src\EJ2APIServices_NET6.csproj", "{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {00388905-5E88-4BCF-B5FC-E4CAB5FA88EE} + EndGlobalSection +EndGlobal diff --git a/ASP.NET Core/EJ2APIServices_NET7.sln b/ASP.NET Core/EJ2APIServices_NET7.sln new file mode 100644 index 0000000..0dd553e --- /dev/null +++ b/ASP.NET Core/EJ2APIServices_NET7.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2009 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EJ2APIServices", "src\EJ2APIServices_NET7.csproj", "{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {00388905-5E88-4BCF-B5FC-E4CAB5FA88EE} + EndGlobalSection +EndGlobal diff --git a/ASP.NET Core/src/EJ2APIServices_NET6.csproj b/ASP.NET Core/src/EJ2APIServices_NET6.csproj new file mode 100644 index 0000000..920c8ec --- /dev/null +++ b/ASP.NET Core/src/EJ2APIServices_NET6.csproj @@ -0,0 +1,21 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/ASP.NET Core/src/EJ2APIServices_NET7.csproj b/ASP.NET Core/src/EJ2APIServices_NET7.csproj new file mode 100644 index 0000000..90be4a9 --- /dev/null +++ b/ASP.NET Core/src/EJ2APIServices_NET7.csproj @@ -0,0 +1,21 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + + + + + From 431967cb1fbac1cbc2eae0e3dc1cb929359cf839 Mon Sep 17 00:00:00 2001 From: Kavitha Muralitharan <98306850+KAVITHAMURALITHARAN@users.noreply.github.com> Date: Mon, 4 Sep 2023 22:07:31 +0530 Subject: [PATCH 04/15] Update EJ2APIServices_NET6.csproj updated NET6 dependencies --- ASP.NET Core/src/EJ2APIServices_NET6.csproj | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ASP.NET Core/src/EJ2APIServices_NET6.csproj b/ASP.NET Core/src/EJ2APIServices_NET6.csproj index 920c8ec..dddc73b 100644 --- a/ASP.NET Core/src/EJ2APIServices_NET6.csproj +++ b/ASP.NET Core/src/EJ2APIServices_NET6.csproj @@ -7,15 +7,20 @@ - - - - - - - - - + + + + + + + + + + + + + + From fb88376ca2ee3c3da3cfa8c0a1c5f445d50c8167 Mon Sep 17 00:00:00 2001 From: Kavitha Muralitharan <98306850+KAVITHAMURALITHARAN@users.noreply.github.com> Date: Mon, 4 Sep 2023 22:08:28 +0530 Subject: [PATCH 05/15] Update EJ2APIServices_NET7.csproj Update NET 7 dependencies --- ASP.NET Core/src/EJ2APIServices_NET7.csproj | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ASP.NET Core/src/EJ2APIServices_NET7.csproj b/ASP.NET Core/src/EJ2APIServices_NET7.csproj index 90be4a9..e78b2e3 100644 --- a/ASP.NET Core/src/EJ2APIServices_NET7.csproj +++ b/ASP.NET Core/src/EJ2APIServices_NET7.csproj @@ -7,15 +7,20 @@ - - - - - - - - - + + + + + + + + + + + + + + From 250dd2679d4b6acfdeefa2154c51c6070cb612da Mon Sep 17 00:00:00 2001 From: Sarubala20 <121480540+Sarubala20@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:28:37 +0530 Subject: [PATCH 06/15] Github action file updated --- .github/workflows/gitleaks.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index d9a8e36..65843b8 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -1,4 +1,4 @@ -name: Secret Value found! +name: Secret Value found!! on: push: public: @@ -32,7 +32,7 @@ jobs: - name: Install the report tool packages if: steps.gitleaks.outcome != 'success' run: | - nuget install "Syncfusion.Email" -source "https://nexus.syncfusion.com/repository/nuget-hosted/" - dir $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1 - dotnet $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1/Email.dll "citeam@syncfusion.com" "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" + nuget install "Syncfusion.Email" -source "https://nexus.syncfusion.com/repository/nuget-hosted/" -ExcludeVersion + dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1 + dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }} exit 1 \ No newline at end of file From 90f8b13967a01c6abada93e3928569f72b91b8cd Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:33:14 +0530 Subject: [PATCH 07/15] Updated Tiff to Png conversion in ASP.Net Core --- .../Controllers/DocumentEditorController.cs | 80 ++++++++++++++++++- ASP.NET Core/src/EJ2APIServices.csproj | 2 + 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index 83557e5..1ec4ce6 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -14,6 +14,9 @@ using WFormatType = Syncfusion.DocIO.FormatType; using Syncfusion.EJ2.SpellChecker; using EJ2APIServices; +using System.Drawing; +using SkiaSharp; +using BitMiracle.LibTiff.Classic; namespace SyncfusionDocument.Controllers { @@ -59,11 +62,80 @@ public string Import(IFormCollection data) //Converts Metafile to raster image. private static void OnMetafileImageParsed(object sender, MetafileImageParsedEventArgs args) { - //You can write your own method definition for converting metafile to raster image using any third-party image converter. - args.ImageStream = ConvertMetafileToRasterImage(args.MetafileStream); - } + if (args.IsMetafile) + { + //MetaFile image conversion(EMF and WMF) + //You can write your own method definition for converting metafile to raster image using any third-party image converter. + args.ImageStream = ConvertMetafileToRasterImage(args.MetafileStream); + } + else + { + //TIFF image conversion + args.ImageStream = TiffToPNG(args.MetafileStream); - private static Stream ConvertMetafileToRasterImage(Stream ImageStream) + } + } + private static MemoryStream TiffToPNG(Stream tiffStream) + { + MemoryStream imageStream = new MemoryStream(); + using (Tiff tif = Tiff.ClientOpen("in-memory", "r", tiffStream, new TiffStream())) + { + // Find the width and height of the image + FieldValue[] value = tif.GetField(BitMiracle.LibTiff.Classic.TiffTag.IMAGEWIDTH); + int width = value[0].ToInt(); + + value = tif.GetField(BitMiracle.LibTiff.Classic.TiffTag.IMAGELENGTH); + int height = value[0].ToInt(); + + // Read the image into the memory buffer + int[] raster = new int[height * width]; + if (!tif.ReadRGBAImage(width, height, raster)) + { + throw new Exception("Could not read image"); + } + + // Create a bitmap image using SkiaSharp. + using (SKBitmap sKBitmap = new SKBitmap(width, height, SKImageInfo.PlatformColorType, SKAlphaType.Premul)) + { + // Convert a RGBA value to byte array. + byte[] bitmapData = new byte[sKBitmap.RowBytes * sKBitmap.Height]; + for (int y = 0; y < sKBitmap.Height; y++) + { + int rasterOffset = y * sKBitmap.Width; + int bitsOffset = (sKBitmap.Height - y - 1) * sKBitmap.RowBytes; + + for (int x = 0; x < sKBitmap.Width; x++) + { + int rgba = raster[rasterOffset++]; + bitmapData[bitsOffset++] = (byte)((rgba >> 16) & 0xff); + bitmapData[bitsOffset++] = (byte)((rgba >> 8) & 0xff); + bitmapData[bitsOffset++] = (byte)(rgba & 0xff); + bitmapData[bitsOffset++] = (byte)((rgba >> 24) & 0xff); + } + } + + // Convert a byte array to SKColor array. + SKColor[] sKColor = new SKColor[bitmapData.Length / 4]; + int index = 0; + for (int i = 0; i < bitmapData.Length; i++) + { + sKColor[index] = new SKColor(bitmapData[i + 2], bitmapData[i + 1], bitmapData[i], bitmapData[i + 3]); + i += 3; + index += 1; + } + + // Set the SKColor array to SKBitmap. + sKBitmap.Pixels = sKColor; + + // Save the SKBitmap to PNG image stream. + sKBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(imageStream); + imageStream.Flush(); + } + } + return imageStream; + } + + private static Stream ConvertMetafileToRasterImage(Stream ImageStream) { //Here we are loading a default raster image as fallback. Stream imgStream = GetManifestResourceStream("ImageNotFound.jpg"); diff --git a/ASP.NET Core/src/EJ2APIServices.csproj b/ASP.NET Core/src/EJ2APIServices.csproj index f5939e2..e9557d4 100644 --- a/ASP.NET Core/src/EJ2APIServices.csproj +++ b/ASP.NET Core/src/EJ2APIServices.csproj @@ -18,6 +18,7 @@ + @@ -31,6 +32,7 @@ + From 2cc4d572111bf8d5bdabca4fbd8077459d463967 Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:39:55 +0530 Subject: [PATCH 08/15] Updated comments --- ASP.NET Core/src/Controllers/DocumentEditorController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index 1ec4ce6..5911e12 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -75,6 +75,8 @@ private static void OnMetafileImageParsed(object sender, MetafileImageParsedEven } } + + // Converting Tiff to Png image using Bitmiracle https://www.nuget.org/packages/BitMiracle.LibTiff.NET private static MemoryStream TiffToPNG(Stream tiffStream) { MemoryStream imageStream = new MemoryStream(); From 2a1c0dfbca7bf8bb77e7cb7312f041c53b1fcb79 Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:40:54 +0530 Subject: [PATCH 09/15] Removed unwanted name space --- ASP.NET Core/src/Controllers/DocumentEditorController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index 5911e12..cb18e7d 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -14,7 +14,6 @@ using WFormatType = Syncfusion.DocIO.FormatType; using Syncfusion.EJ2.SpellChecker; using EJ2APIServices; -using System.Drawing; using SkiaSharp; using BitMiracle.LibTiff.Classic; From cd9a19056f6fae85160a18f21f67ceb18ff9b4a2 Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:50:00 +0530 Subject: [PATCH 10/15] Resolved formatting --- .../Controllers/DocumentEditorController.cs | 136 +++++++++--------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/ASP.NET Core/src/Controllers/DocumentEditorController.cs b/ASP.NET Core/src/Controllers/DocumentEditorController.cs index cb18e7d..03dec4e 100644 --- a/ASP.NET Core/src/Controllers/DocumentEditorController.cs +++ b/ASP.NET Core/src/Controllers/DocumentEditorController.cs @@ -63,80 +63,80 @@ private static void OnMetafileImageParsed(object sender, MetafileImageParsedEven { if (args.IsMetafile) { - //MetaFile image conversion(EMF and WMF) - //You can write your own method definition for converting metafile to raster image using any third-party image converter. - args.ImageStream = ConvertMetafileToRasterImage(args.MetafileStream); + //MetaFile image conversion(EMF and WMF) + //You can write your own method definition for converting metafile to raster image using any third-party image converter. + args.ImageStream = ConvertMetafileToRasterImage(args.MetafileStream); } else { - //TIFF image conversion - args.ImageStream = TiffToPNG(args.MetafileStream); + //TIFF image conversion + args.ImageStream = TiffToPNG(args.MetafileStream); - } + } + } + + // Converting Tiff to Png image using Bitmiracle https://www.nuget.org/packages/BitMiracle.LibTiff.NET + private static MemoryStream TiffToPNG(Stream tiffStream) + { + MemoryStream imageStream = new MemoryStream(); + using (Tiff tif = Tiff.ClientOpen("in-memory", "r", tiffStream, new TiffStream())) + { + // Find the width and height of the image + FieldValue[] value = tif.GetField(BitMiracle.LibTiff.Classic.TiffTag.IMAGEWIDTH); + int width = value[0].ToInt(); + + value = tif.GetField(BitMiracle.LibTiff.Classic.TiffTag.IMAGELENGTH); + int height = value[0].ToInt(); + + // Read the image into the memory buffer + int[] raster = new int[height * width]; + if (!tif.ReadRGBAImage(width, height, raster)) + { + throw new Exception("Could not read image"); + } + + // Create a bitmap image using SkiaSharp. + using (SKBitmap sKBitmap = new SKBitmap(width, height, SKImageInfo.PlatformColorType, SKAlphaType.Premul)) + { + // Convert a RGBA value to byte array. + byte[] bitmapData = new byte[sKBitmap.RowBytes * sKBitmap.Height]; + for (int y = 0; y < sKBitmap.Height; y++) + { + int rasterOffset = y * sKBitmap.Width; + int bitsOffset = (sKBitmap.Height - y - 1) * sKBitmap.RowBytes; + + for (int x = 0; x < sKBitmap.Width; x++) + { + int rgba = raster[rasterOffset++]; + bitmapData[bitsOffset++] = (byte)((rgba >> 16) & 0xff); + bitmapData[bitsOffset++] = (byte)((rgba >> 8) & 0xff); + bitmapData[bitsOffset++] = (byte)(rgba & 0xff); + bitmapData[bitsOffset++] = (byte)((rgba >> 24) & 0xff); + } + } + + // Convert a byte array to SKColor array. + SKColor[] sKColor = new SKColor[bitmapData.Length / 4]; + int index = 0; + for (int i = 0; i < bitmapData.Length; i++) + { + sKColor[index] = new SKColor(bitmapData[i + 2], bitmapData[i + 1], bitmapData[i], bitmapData[i + 3]); + i += 3; + index += 1; + } + + // Set the SKColor array to SKBitmap. + sKBitmap.Pixels = sKColor; + + // Save the SKBitmap to PNG image stream. + sKBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(imageStream); + imageStream.Flush(); + } + } + return imageStream; } - // Converting Tiff to Png image using Bitmiracle https://www.nuget.org/packages/BitMiracle.LibTiff.NET - private static MemoryStream TiffToPNG(Stream tiffStream) - { - MemoryStream imageStream = new MemoryStream(); - using (Tiff tif = Tiff.ClientOpen("in-memory", "r", tiffStream, new TiffStream())) - { - // Find the width and height of the image - FieldValue[] value = tif.GetField(BitMiracle.LibTiff.Classic.TiffTag.IMAGEWIDTH); - int width = value[0].ToInt(); - - value = tif.GetField(BitMiracle.LibTiff.Classic.TiffTag.IMAGELENGTH); - int height = value[0].ToInt(); - - // Read the image into the memory buffer - int[] raster = new int[height * width]; - if (!tif.ReadRGBAImage(width, height, raster)) - { - throw new Exception("Could not read image"); - } - - // Create a bitmap image using SkiaSharp. - using (SKBitmap sKBitmap = new SKBitmap(width, height, SKImageInfo.PlatformColorType, SKAlphaType.Premul)) - { - // Convert a RGBA value to byte array. - byte[] bitmapData = new byte[sKBitmap.RowBytes * sKBitmap.Height]; - for (int y = 0; y < sKBitmap.Height; y++) - { - int rasterOffset = y * sKBitmap.Width; - int bitsOffset = (sKBitmap.Height - y - 1) * sKBitmap.RowBytes; - - for (int x = 0; x < sKBitmap.Width; x++) - { - int rgba = raster[rasterOffset++]; - bitmapData[bitsOffset++] = (byte)((rgba >> 16) & 0xff); - bitmapData[bitsOffset++] = (byte)((rgba >> 8) & 0xff); - bitmapData[bitsOffset++] = (byte)(rgba & 0xff); - bitmapData[bitsOffset++] = (byte)((rgba >> 24) & 0xff); - } - } - - // Convert a byte array to SKColor array. - SKColor[] sKColor = new SKColor[bitmapData.Length / 4]; - int index = 0; - for (int i = 0; i < bitmapData.Length; i++) - { - sKColor[index] = new SKColor(bitmapData[i + 2], bitmapData[i + 1], bitmapData[i], bitmapData[i + 3]); - i += 3; - index += 1; - } - - // Set the SKColor array to SKBitmap. - sKBitmap.Pixels = sKColor; - - // Save the SKBitmap to PNG image stream. - sKBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(imageStream); - imageStream.Flush(); - } - } - return imageStream; - } - - private static Stream ConvertMetafileToRasterImage(Stream ImageStream) + private static Stream ConvertMetafileToRasterImage(Stream ImageStream) { //Here we are loading a default raster image as fallback. Stream imgStream = GetManifestResourceStream("ImageNotFound.jpg"); From 31de112e094929d79d9f2b7f911dadb0ded0ba09 Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Tue, 19 Dec 2023 09:39:07 +0530 Subject: [PATCH 11/15] Updated Java tiff image --- Java/build.gradle | 3 ++ .../ej2/webservices/WordEditorController.java | 36 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Java/build.gradle b/Java/build.gradle index 99ffdd3..812bc2c 100644 --- a/Java/build.gradle +++ b/Java/build.gradle @@ -22,6 +22,9 @@ dependencies { implementation 'com.syncfusion:syncfusion-ej2-spellchecker:+' implementation 'com.syncfusion:syncfusion-docio:+' implementation 'com.syncfusion:syncfusion-javahelper:+' + implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-tiff', version: '3.7.0' + implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-jpeg', version: '3.7.0' + implementation group: 'org.apache.commons', name: 'commons-imaging', version: '1.0' compile 'com.google.code.gson:gson:2.8.6' testImplementation 'org.apache.httpcomponents:httpclient' testImplementation('org.springframework.boot:spring-boot-starter-test') { diff --git a/Java/src/main/java/ej2/webservices/WordEditorController.java b/Java/src/main/java/ej2/webservices/WordEditorController.java index 5fba110..3fc371c 100644 --- a/Java/src/main/java/ej2/webservices/WordEditorController.java +++ b/Java/src/main/java/ej2/webservices/WordEditorController.java @@ -7,8 +7,17 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; + +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.ImageWriter; +import javax.imageio.spi.IIORegistry; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; +import java.io.InputStream; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; @@ -24,6 +33,7 @@ import com.syncfusion.javahelper.system.collections.generic.ListSupport; import com.syncfusion.javahelper.system.io.StreamSupport; import com.syncfusion.javahelper.system.reflection.AssemblySupport; +import com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReaderSpi; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -118,8 +128,30 @@ public void remove(MetafileImageParsedEventHandler delegate) throws Exception { // Converts Metafile to raster image. private static void onMetafileImageParsed(Object sender, MetafileImageParsedEventArgs args) throws Exception { - // You can write your own method definition for converting Metafile to raster image using any third-party image converter. - args.setImageStream(convertMetafileToRasterImage(args.getMetafileStream())); + if(args.getIsMetafile()) { // You can write your own method definition for converting Metafile to raster image using any third-party image converter. + args.setImageStream(convertMetafileToRasterImage(args.getMetafileStream())); + }else { + StreamSupport inputStream = args.getMetafileStream(); + + IIORegistry.getDefaultInstance().registerServiceProvider(new TIFFImageReaderSpi()); + + // Create ImageReader and ImageWriter instances + ImageReader tiffReader = ImageIO.getImageReadersByFormatName("TIFF").next(); + ImageWriter pngWriter = ImageIO.getImageWritersByFormatName("PNG").next(); + + // Set up input and output streams + tiffReader.setInput(ImageIO.createImageInputStream(tiffInputStream)); + ByteArrayOutputStream pngOutputStream = new ByteArrayOutputStream(); + pngWriter.setOutput(ImageIO.createImageOutputStream(pngOutputStream)); + + // Read the TIFF image and write it as a PNG + BufferedImage image = tiffReader.read(0); + pngWriter.write(image); + pngWriter.dispose(); + byte[] jpgData = pngOutputStream.toByteArray(); + InputStream jpgStream = new ByteArrayInputStream(jpgData); + args.setImageStream(StreamSupport.toStream(jpgStream)); + } } private static StreamSupport convertMetafileToRasterImage(StreamSupport ImageStream) throws Exception { From f4b6f5fc92e54ad11305b32ea0de3fc7d7bcdf4c Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Tue, 19 Dec 2023 11:52:13 +0530 Subject: [PATCH 12/15] Updated some changes --- .../ej2/webservices/WordEditorController.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Java/src/main/java/ej2/webservices/WordEditorController.java b/Java/src/main/java/ej2/webservices/WordEditorController.java index 3fc371c..47f943c 100644 --- a/Java/src/main/java/ej2/webservices/WordEditorController.java +++ b/Java/src/main/java/ej2/webservices/WordEditorController.java @@ -128,11 +128,25 @@ public void remove(MetafileImageParsedEventHandler delegate) throws Exception { // Converts Metafile to raster image. private static void onMetafileImageParsed(Object sender, MetafileImageParsedEventArgs args) throws Exception { - if(args.getIsMetafile()) { // You can write your own method definition for converting Metafile to raster image using any third-party image converter. - args.setImageStream(convertMetafileToRasterImage(args.getMetafileStream())); + if(args.getIsMetafile()) { + // You can write your own method definition for converting Metafile to raster image using any third-party image converter. + args.setImageStream(convertMetafileToRasterImage(args.getMetafileStream())); }else { - StreamSupport inputStream = args.getMetafileStream(); - + InputStream inputStream = StreamSupport.toStream(args.getMetafileStream()); + // Use ByteArrayOutputStream to collect data into a byte array + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + // Read data from the InputStream and write it to the ByteArrayOutputStream + byte[] buffer = new byte[1024]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + byteArrayOutputStream.write(buffer, 0, bytesRead); + } + + // Convert the ByteArrayOutputStream to a byte array + byte[] tiffData = byteArrayOutputStream.toByteArray(); + // Read TIFF image from byte array + ByteArrayInputStream tiffInputStream = new ByteArrayInputStream(tiffData); IIORegistry.getDefaultInstance().registerServiceProvider(new TIFFImageReaderSpi()); // Create ImageReader and ImageWriter instances From 3c59ae0f2beb331ac355c44efdf89e6258a2d71b Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Tue, 19 Dec 2023 11:58:54 +0530 Subject: [PATCH 13/15] Removed unwanted changes --- Java/build.gradle | 1 - .../ej2/webservices/WordEditorController.java | 30 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Java/build.gradle b/Java/build.gradle index 812bc2c..f45e3c0 100644 --- a/Java/build.gradle +++ b/Java/build.gradle @@ -24,7 +24,6 @@ dependencies { implementation 'com.syncfusion:syncfusion-javahelper:+' implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-tiff', version: '3.7.0' implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-jpeg', version: '3.7.0' - implementation group: 'org.apache.commons', name: 'commons-imaging', version: '1.0' compile 'com.google.code.gson:gson:2.8.6' testImplementation 'org.apache.httpcomponents:httpclient' testImplementation('org.springframework.boot:spring-boot-starter-test') { diff --git a/Java/src/main/java/ej2/webservices/WordEditorController.java b/Java/src/main/java/ej2/webservices/WordEditorController.java index 47f943c..0760695 100644 --- a/Java/src/main/java/ej2/webservices/WordEditorController.java +++ b/Java/src/main/java/ej2/webservices/WordEditorController.java @@ -129,24 +129,24 @@ public void remove(MetafileImageParsedEventHandler delegate) throws Exception { // Converts Metafile to raster image. private static void onMetafileImageParsed(Object sender, MetafileImageParsedEventArgs args) throws Exception { if(args.getIsMetafile()) { - // You can write your own method definition for converting Metafile to raster image using any third-party image converter. - args.setImageStream(convertMetafileToRasterImage(args.getMetafileStream())); + // You can write your own method definition for converting Metafile to raster image using any third-party image converter. + args.setImageStream(convertMetafileToRasterImage(args.getMetafileStream())); }else { - InputStream inputStream = StreamSupport.toStream(args.getMetafileStream()); - // Use ByteArrayOutputStream to collect data into a byte array - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + InputStream inputStream = StreamSupport.toStream(args.getMetafileStream()); + // Use ByteArrayOutputStream to collect data into a byte array + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - // Read data from the InputStream and write it to the ByteArrayOutputStream - byte[] buffer = new byte[1024]; - int bytesRead; - while ((bytesRead = inputStream.read(buffer)) != -1) { - byteArrayOutputStream.write(buffer, 0, bytesRead); - } + // Read data from the InputStream and write it to the ByteArrayOutputStream + byte[] buffer = new byte[1024]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + byteArrayOutputStream.write(buffer, 0, bytesRead); + } - // Convert the ByteArrayOutputStream to a byte array - byte[] tiffData = byteArrayOutputStream.toByteArray(); - // Read TIFF image from byte array - ByteArrayInputStream tiffInputStream = new ByteArrayInputStream(tiffData); + // Convert the ByteArrayOutputStream to a byte array + byte[] tiffData = byteArrayOutputStream.toByteArray(); + // Read TIFF image from byte array + ByteArrayInputStream tiffInputStream = new ByteArrayInputStream(tiffData); IIORegistry.getDefaultInstance().registerServiceProvider(new TIFFImageReaderSpi()); // Create ImageReader and ImageWriter instances From d82fd1d3d2fa8468bad64440d401826c199e57ee Mon Sep 17 00:00:00 2001 From: Sarubala20 <121480540+Sarubala20@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:13:36 +0530 Subject: [PATCH 14/15] Github action file updated --- .github/workflows/gitleaks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index 65843b8..c115f77 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -32,7 +32,7 @@ jobs: - name: Install the report tool packages if: steps.gitleaks.outcome != 'success' run: | - nuget install "Syncfusion.Email" -source "https://nexus.syncfusion.com/repository/nuget-hosted/" -ExcludeVersion + nuget install "Syncfusion.Email" -source ${{ secrets.NexusFeedLink }} -ExcludeVersion dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1 dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }} exit 1 \ No newline at end of file From 8a04b21266451699f0df98975880790f2fa03326 Mon Sep 17 00:00:00 2001 From: Suriya-Murugan <43063728+Suriya-Murugan@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:19:00 +0530 Subject: [PATCH 15/15] Removed unwanted changes --- ASP.NET Core/src/EJ2APIServices_NET6.csproj | 10 +++-- ASP.NET Core/src/EJ2APIServices_NET8.csproj | 10 +++-- ...WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs | 42 +++++++++---------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/ASP.NET Core/src/EJ2APIServices_NET6.csproj b/ASP.NET Core/src/EJ2APIServices_NET6.csproj index 3ebfccc..bae506a 100644 --- a/ASP.NET Core/src/EJ2APIServices_NET6.csproj +++ b/ASP.NET Core/src/EJ2APIServices_NET6.csproj @@ -16,10 +16,12 @@ - - - - + + + + + + diff --git a/ASP.NET Core/src/EJ2APIServices_NET8.csproj b/ASP.NET Core/src/EJ2APIServices_NET8.csproj index 1f64558..ac08dc6 100644 --- a/ASP.NET Core/src/EJ2APIServices_NET8.csproj +++ b/ASP.NET Core/src/EJ2APIServices_NET8.csproj @@ -16,10 +16,12 @@ - - - - + + + + + + diff --git a/ASP.NET Core/src/Models/EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs b/ASP.NET Core/src/Models/EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs index df25851..4988669 100644 --- a/ASP.NET Core/src/Models/EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs +++ b/ASP.NET Core/src/Models/EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext.cs @@ -1,27 +1,27 @@ -//using System; -//using Microsoft.EntityFrameworkCore; -//using Microsoft.EntityFrameworkCore.Metadata; +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; -//namespace EJ2APIServices.Models -//{ -// public partial class EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext : DbContext -// { +namespace EJ2APIServices.Models +{ + public partial class EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext : DbContext + { -// public EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext(DbContextOptions options) -// : base(options) -// { -// } + public EEJ2SERVICEEJ2WEBSERVICESSRCAPP_DATADIAGRAMMDFContext(DbContextOptions options) + : base(options) + { + } -// public virtual DbSet DiagramData { get; set; } + public virtual DbSet DiagramData { get; set; } -// protected override void OnModelCreating(ModelBuilder modelBuilder) -// { -// modelBuilder.Entity(entity => -// { -// entity.Property(e => e.DiagramName).HasMaxLength(50); -// }); -// } -// } -//} + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.Property(e => e.DiagramName).HasMaxLength(50); + }); + } + } +} \ No newline at end of file