Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/gitleaks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Secret Value found!
on:
push:
public:
jobs:
scan:
name: gitleaks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install the gitleaks
run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz
shell: pwsh
- name: Extract the tar file
run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz
- name: Generate the report
id: gitleaks
run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json
shell: bash
continue-on-error: true
- name: Setup NuGet.exe
if: steps.gitleaks.outcome != 'success'
uses: nuget/setup-nuget@v1
with:
nuget-version: latest
- name: Install the dotnet
if: steps.gitleaks.outcome != 'success'
uses: actions/setup-dotnet@v3
with:
dotnet-version: '3.1.x'
- 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"
exit 1
25 changes: 25 additions & 0 deletions ASP.NET Core/DocumenteditorHtml.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1401
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocumenteditorHtml", "DocumenteditorHtml\DocumenteditorHtml.csproj", "{01067B25-54B4-4643-8B2C-DB5F92EE53ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{01067B25-54B4-4643-8B2C-DB5F92EE53ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01067B25-54B4-4643-8B2C-DB5F92EE53ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01067B25-54B4-4643-8B2C-DB5F92EE53ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01067B25-54B4-4643-8B2C-DB5F92EE53ED}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E1C29F0E-BFBE-410B-8356-9DCBD6F307E0}
EndGlobalSection
EndGlobal
300 changes: 300 additions & 0 deletions ASP.NET Core/DocumenteditorHtml/DocumentEditorController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.DocIO;
using System;
using System.IO;
using EJ2DocumentEditor = Syncfusion.EJ2.DocumentEditor;
using WDocument = Syncfusion.DocIO.DLS.WordDocument;
using WFormatType = Syncfusion.DocIO.FormatType;
using Syncfusion.EJ2.DocumentEditor;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace DocumenteditorHtml
{
[Route("api/[controller]")]
public class DocumentEditorController : Controller
{
// GET: api/<controller>
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}

private IHostingEnvironment hostEnvironment;
public DocumentEditorController(IHostingEnvironment environment)
{
this.hostEnvironment = environment;
}
//Import file from client side.
[Route("Import")]
public string Import(IFormCollection data)
{
if (data.Files.Count == 0)
return null;
Stream stream = new MemoryStream();
IFormFile file = data.Files[0];
int index = file.FileName.LastIndexOf('.');
string type = index > -1 && index < file.FileName.Length - 1 ?
file.FileName.Substring(index) : ".docx";
file.CopyTo(stream);
stream.Position = 0;

EJ2DocumentEditor.WordDocument document = EJ2DocumentEditor.WordDocument.Load(stream, GetFormatType(type.ToLower()));
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
return json;
}
//Import documents from web server.
[Route("ImportFile")]
public string ImportFile([FromBody]CustomParams param)
{
string path = this.hostEnvironment.WebRootPath + "\\Files\\" + param.fileName;
try
{
Stream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.ReadWrite);
Syncfusion.EJ2.DocumentEditor.WordDocument document = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(stream, GetFormatType(path));
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
stream.Dispose();
return json;
}
catch
{
return "Failure";
}
}
[Route("SystemClipboard")]
public string SystemClipboard([FromBody]CustomParameter param)
{
if (param.content != null && param.content != "")
{
try
{
WordDocument document = WordDocument.LoadString(param.content, GetFormatType(param.type.ToLower()));
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
return json;
}
catch (Exception)
{
return "";
}
}
return "";
}

public class SaveParam
{
public string content { get; set; }
}

public class CustomParams
{
public string fileName { get; set; }
}

public class SaveParameter
{
public string Content { get; set; }
public string FileName { get; set; }
}
[Route("Save")]
public void Save([FromBody] SaveParameter data)
{
string name = data.FileName;
string format = RetrieveFileType(name);
if (string.IsNullOrEmpty(name))
{
name = "Document1.doc";
}
WDocument document = WordDocument.Save(data.Content);
FileStream fileStream = new FileStream(name, FileMode.OpenOrCreate, FileAccess.ReadWrite);
document.Save(fileStream, GetWFormatType(format));
document.Close();
fileStream.Close();
}


[Route("ExportSFDT")]
public FileStreamResult ExportSFDT([FromBody] SaveParameter data)
{
string name = data.FileName;
string format = RetrieveFileType(name);
if (string.IsNullOrEmpty(name))
{
name = "Document1.doc";
}
WDocument document = WordDocument.Save(data.Content);
return SaveDocument(document, format, name);
}

private string RetrieveFileType(string name)
{
int index = name.LastIndexOf('.');
string format = index > -1 && index < name.Length - 1 ?
name.Substring(index) : ".doc";
return format;
}


[Route("Export")]
public FileStreamResult Export(IFormCollection data)
{
if (data.Files.Count == 0)
return null;
string fileName = this.GetValue(data, "filename");
string name = fileName;
string format = RetrieveFileType(name);
if (string.IsNullOrEmpty(name))
{
name = "Document1";
}
WDocument document = this.GetDocument(data);
return SaveDocument(document, format, fileName);
}

private FileStreamResult SaveDocument(WDocument document, string format, string fileName)
{
Stream stream = new MemoryStream();
string contentType = "";
if (format == ".pdf")
{
contentType = "application/pdf";
}
else
{
WFormatType type = GetWFormatType(format);
switch (type)
{
case WFormatType.Rtf:
contentType = "application/rtf";
break;
case WFormatType.WordML:
contentType = "application/xml";
break;
case WFormatType.Html:
contentType = "application/html";
break;
case WFormatType.Dotx:
contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.template";
break;
case WFormatType.Doc:
contentType = "application/msword";
break;
case WFormatType.Dot:
contentType = "application/msword";
break;
}
document.Save(stream, type);
}
document.Close();
stream.Position = 0;
return new FileStreamResult(stream, contentType)
{
FileDownloadName = fileName
};
}
internal static WFormatType GetWFormatType(string format)
{
if (string.IsNullOrEmpty(format))
throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");
switch (format.ToLower())
{
case ".dotx":
return WFormatType.Dotx;
case ".docx":
return WFormatType.Docx;
case ".docm":
return WFormatType.Docm;
case ".dotm":
return WFormatType.Dotm;
case ".dot":
return WFormatType.Dot;
case ".doc":
return WFormatType.Doc;
case ".rtf":
return WFormatType.Rtf;
case ".html":
return WFormatType.Html;
case ".txt":
return WFormatType.Txt;
case ".xml":
return WFormatType.WordML;
case ".odt":
return WFormatType.Odt;
default:
throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");
}
}
internal static EJ2DocumentEditor.FormatType GetFormatType(string fileName)
{
int index = fileName.LastIndexOf('.');
string format = index > -1 && index < fileName.Length - 1 ? fileName.Substring(index + 1) : "";

if (string.IsNullOrEmpty(format))
throw new NotSupportedException("EJ2 Document editor does not support this file format.");
switch (format.ToLower())
{
case "dotx":
case "docx":
case "docm":
case "dotm":
return EJ2DocumentEditor.FormatType.Docx;
case "dot":
case "doc":
return EJ2DocumentEditor.FormatType.Doc;
case "rtf":
return EJ2DocumentEditor.FormatType.Rtf;
case "html":
return EJ2DocumentEditor.FormatType.Html;
case "txt":
return EJ2DocumentEditor.FormatType.Txt;
case "xml":
return EJ2DocumentEditor.FormatType.WordML;
default:
throw new NotSupportedException("EJ2 Document editor does not support this file format.");
}
}
public class ExportData
{
public string fileName { get; set; }
public string documentData { get; set; }
}

public class CustomParameter
{
public string content { get; set; }
public string type { get; set; }
}
private string GetValue(IFormCollection data, string key)
{
if (data.ContainsKey(key))
{
string[] values = data[key];
if (values.Length > 0)
{
return values[0];
}
}
return "";
}
private WDocument GetDocument(IFormCollection data)
{
Stream stream = new MemoryStream();
IFormFile file = data.Files[0];
file.CopyTo(stream);
stream.Position = 0;

WDocument document = new WDocument(stream, WFormatType.Docx);
stream.Dispose();
return document;
}
}
}
14 changes: 14 additions & 0 deletions ASP.NET Core/DocumenteditorHtml/DocumenteditorHtml.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="20.1.0.57" />
<PackageReference Include="Syncfusion.EJ2.WordEditor.AspNet.Core" Version="20.1.0.57" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions ASP.NET Core/DocumenteditorHtml/Pages/About.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@page
@model AboutModel
@{
ViewData["Title"] = "About";
}
<h2>@ViewData["Title"]</h2>
<h3>@Model.Message</h3>

<p>Use this area to provide additional information.</p>
Loading