Skip to content

Commit 2cc6738

Browse files
committed
Updated to .NET 6 version.
1 parent e334916 commit 2cc6738

File tree

82 files changed

+74269
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+74269
-159
lines changed
0 Bytes
Binary file not shown.

ASP.NET Core/Controllers/DocumenteditorController.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ namespace DocumentEditorApp.Controllers
2323
[ApiController]
2424
public class DocumenteditorController : ControllerBase
2525
{
26-
private IHostingEnvironment hostEnvironment;
26+
private IWebHostEnvironment hostEnvironment;
2727

2828
private string dataSourcePath;
2929

3030
private string connectionString;
31-
public DocumenteditorController(IHostingEnvironment environment)
31+
public DocumenteditorController(IWebHostEnvironment environment)
3232
{
3333
this.hostEnvironment = environment;
3434
this.dataSourcePath = Path.Combine(this.hostEnvironment.ContentRootPath,"AppData"+"\\DocumentInfo.accdb");
@@ -108,8 +108,10 @@ public string ImportFile([FromBody]Documentdetails param)
108108
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dataSourcePath + ";User Id=admin;Password=;";
109109
DataTable table = getDatabaseData(connectionString,query);
110110
string Result = Newtonsoft.Json.JsonConvert.SerializeObject(table);
111-
string status = (string)table.Rows[0][0];
112-
if(status != ""){
111+
string status = "";
112+
if (table.Rows[0][0] is string)
113+
status = (string)table.Rows[0][0];
114+
if (status != ""){
113115
return Result;
114116
}
115117
DateTime date = DateTime.Now;
@@ -129,9 +131,8 @@ public string ImportFile([FromBody]Documentdetails param)
129131
}
130132

131133
[Route("LogOut")]
132-
133-
public void LogOut([FromBody]Documentdetails param){
134-
string SQLquery = "UPDATE DocumentInfo SET EditorName = '' WHERE DocumentName = '"+param.FileName+"'";
134+
public void LogOut([FromBody]CustomParams param){
135+
string SQLquery = "UPDATE DocumentInfo SET EditorName = '' WHERE DocumentName = '"+ param.fileName +"'";
135136
performCRUD(connectionString,SQLquery);
136137
}
137138

@@ -171,7 +172,7 @@ public class SaveParameter
171172
public void ExportSFDT([FromBody]Saveparameter data)
172173
{
173174
string name = data.FileName;
174-
string path = this.hostEnvironment.WebRootPath + "\\Files\\" + data.FileName;
175+
string path = this.hostEnvironment.WebRootPath + "\\Files\\" + data.FileName;
175176
EJ2DocumentEditor.FormatType format = GetFormatType(data.FileName);
176177
if (string.IsNullOrEmpty(name))
177178
{
Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Linq;
5-
using System.Threading.Tasks;
1+
using DocumentEditorApp.Models;
62
using Microsoft.AspNetCore.Mvc;
7-
using DocumentEditorApp.Models;
8-
using Microsoft.AspNetCore.Hosting;
3+
using System.Diagnostics;
94
using System.IO;
105
using EJ2DocumentEditor = Syncfusion.EJ2.DocumentEditor;
116

127
namespace DocumentEditorApp.Controllers
138
{
149
public class HomeController : Controller
1510
{
16-
11+
private readonly ILogger<HomeController> _logger;
12+
13+
public HomeController(ILogger<HomeController> logger)
14+
{
15+
_logger = logger;
16+
}
17+
1718
public IActionResult Index()
1819
{
1920
return View();
2021
}
21-
public IActionResult Documenteditor(string serviceName,string userName)
22+
public IActionResult Documenteditor(string serviceName, string userName)
2223
{
2324
ViewBag.serviceName = serviceName;
2425
ViewBag.userName = userName;
2526
return View();
2627
}
2728

29+
public IActionResult Privacy()
30+
{
31+
return View();
32+
}
33+
34+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
35+
public IActionResult Error()
36+
{
37+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
38+
}
2839
}
29-
}
40+
}
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
57
</PropertyGroup>
68

79
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.App" />
9-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
10-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.9" />
11-
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="20.3.0.58" />
12-
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="20.3.0.58" />
13-
<PackageReference Include="System.Data.OleDb" Version="4.6.0" />
14-
<PackageReference Include="Syncfusion.EJ2.WordEditor.AspNet.Core" Version="20.3.0.58" />
10+
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" />
11+
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
12+
<PackageReference Include="Syncfusion.EJ2.WordEditor.AspNet.Core" Version="*" />
13+
<PackageReference Include="System.Data.OleDb" Version="7.0.0" />
1514
</ItemGroup>
16-
17-
<ItemGroup>
18-
<Folder Include="wwwroot\documenteditor\" />
19-
</ItemGroup>
20-
2115
</Project>

ASP.NET Core/DocumentEditorApp.sln

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.1401
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32519.111
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentEditorApp", "DocumentEditorApp.csproj", "{31AD4D79-2D70-46D4-AD8E-BE0AEB4B431C}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocumentEditorApp", "DocumentEditorApp.csproj", "{D05102F5-0598-4651-9C1F-30B6B972D1FC}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{31AD4D79-2D70-46D4-AD8E-BE0AEB4B431C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{31AD4D79-2D70-46D4-AD8E-BE0AEB4B431C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{31AD4D79-2D70-46D4-AD8E-BE0AEB4B431C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{31AD4D79-2D70-46D4-AD8E-BE0AEB4B431C}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{D05102F5-0598-4651-9C1F-30B6B972D1FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D05102F5-0598-4651-9C1F-30B6B972D1FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D05102F5-0598-4651-9C1F-30B6B972D1FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D05102F5-0598-4651-9C1F-30B6B972D1FC}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {E6DC4D34-91DA-4195-866D-91D1DD6A41E3}
23+
SolutionGuid = {3EFA96ED-B2E5-45AC-8E1F-01AFE89B9EC4}
2424
EndGlobalSection
2525
EndGlobal
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace DocumentEditorApp.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}

ASP.NET Core/Program.cs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore;
7-
using Microsoft.AspNetCore.Hosting;
8-
using Microsoft.Extensions.Configuration;
9-
using Microsoft.Extensions.Logging;
10-
11-
namespace ImportAndExport
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
builder.Services.AddControllersWithViews();
5+
6+
var app = builder.Build();
7+
8+
// Configure the HTTP request pipeline.
9+
if (!app.Environment.IsDevelopment())
1210
{
13-
public class Program
14-
{
15-
public static void Main(string[] args)
16-
{
17-
CreateWebHostBuilder(args).Build().Run();
18-
}
19-
20-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
21-
WebHost.CreateDefaultBuilder(args)
22-
.UseStartup<Startup>();
23-
}
11+
app.UseExceptionHandler("/Home/Error");
12+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
13+
app.UseHsts();
2414
}
15+
16+
app.UseHttpsRedirection();
17+
app.UseStaticFiles();
18+
19+
app.UseRouting();
20+
21+
app.UseAuthorization();
22+
23+
app.MapControllerRoute(
24+
name: "default",
25+
pattern: "{controller=Home}/{action=Index}/{id?}");
26+
27+
app.Run();
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
{
22
"iisSettings": {
3-
"windowsAuthentication": false,
4-
"anonymousAuthentication": true,
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
55
"iisExpress": {
6-
"applicationUrl": "http://localhost:51056",
7-
"sslPort": 0
6+
"applicationUrl": "http://localhost:62037",
7+
"sslPort": 44393
88
}
99
},
1010
"profiles": {
11-
"IIS Express": {
12-
"commandName": "IISExpress",
11+
"DocumentEditorApp": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
1314
"launchBrowser": true,
15+
"applicationUrl": "https://localhost:7283;http://localhost:5283",
1416
"environmentVariables": {
1517
"ASPNETCORE_ENVIRONMENT": "Development"
1618
}
1719
},
18-
"ImportAndExport": {
19-
"commandName": "Project",
20+
"IIS Express": {
21+
"commandName": "IISExpress",
2022
"launchBrowser": true,
21-
"applicationUrl": "http://localhost:5000",
2223
"environmentVariables": {
2324
"ASPNETCORE_ENVIRONMENT": "Development"
2425
}
2526
}
2627
}
27-
}
28+
}

ASP.NET Core/Startup.cs

Lines changed: 0 additions & 60 deletions
This file was deleted.

ASP.NET Core/Views/Home/Documenteditor.cshtml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
@{
33
ViewData["Title"] = "View document";
44
}
5-
<div>
6-
5+
<div style="margin-top:80px">
76
<ejs-button id="new" content='New Document'></ejs-button>
87
<ejs-button id="edit" content='Edit'></ejs-button>
98
<ejs-button id="delete" content='Delete' onclick='deleteRecords()' ></ejs-button>
@@ -26,7 +25,7 @@
2625
<script>
2726
2827
function loggedOut() {
29-
window.location.href = 'http://localhost:5000/Home/Index';
28+
window.location.href = window.location.origin;
3029
}
3130
3231
// Initialize DocumentEditorcontainer component
@@ -36,7 +35,7 @@ width: "100%",
3635
height: '590px',
3736
toolbarItems: [ 'Undo', 'Redo', 'Separator', 'Image', 'Table', 'Hyperlink', 'Bookmark', 'Comments', 'TableOfContents', 'Separator', 'Header', 'Footer', 'PageSetup', 'PageNumber', 'Break', 'Separator', 'Find', 'Separator', 'LocalClipboard'],
3837
serviceUrl:
39-
'http://localhost:5000/api/documenteditor/'
38+
window.location.origin + '/api/documenteditor/'
4039
});
4140
ej.documenteditor.DocumentEditorContainer.Inject(ej.documenteditor.Toolbar);
4241
container.appendTo('#DocumentEditor');
@@ -183,7 +182,7 @@ function onClose(){
183182
}
184183
function makeHTTPRequest(APIName) {
185184
var httpRequest = new XMLHttpRequest();
186-
httpRequest.open('POST',"/api/documenteditor/"+APIName+"");
185+
httpRequest.open('POST', window.location.origin + '/api/documenteditor/' + APIName);
187186
httpRequest.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
188187
httpRequest.send(JSON.stringify({ "fileName": fileName }));
189188
}
@@ -219,7 +218,7 @@ function refresh(){
219218
220219
function retriveDataSource(){
221220
var httpRequest = new XMLHttpRequest();
222-
httpRequest.open('POST','/api/documenteditor/RetriveDataSource');
221+
httpRequest.open('POST', window.location.origin + '/api/documenteditor/RetriveDataSource');
223222
httpRequest.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
224223
httpRequest.onreadystatechange = () => {
225224
if (httpRequest.readyState === 4) {
@@ -238,7 +237,7 @@ function createNewDocument(){
238237
var docName = document.getElementById('field_text').value;
239238
if(docName != ''){
240239
var httpRequest = new XMLHttpRequest();
241-
httpRequest.open('POST','/api/documenteditor/InsertRow');
240+
httpRequest.open('POST', window.location.origin + '/api/documenteditor/InsertRow');
242241
httpRequest.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
243242
httpRequest.onreadystatechange = () => {
244243
if (httpRequest.readyState === 4) {
@@ -292,7 +291,7 @@ function selectionAlertDialog() {
292291
}
293292
function ImportDocument(){
294293
var http = new XMLHttpRequest();
295-
http.open('POST', '/api/documenteditor/ImportFile');
294+
http.open('POST', window.location.origin + '/api/documenteditor/ImportFile');
296295
http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
297296
http.onreadystatechange = () => {
298297
if (http.readyState === 4) {
@@ -325,7 +324,8 @@ function ImportDocument(){
325324
function enableProtection() {
326325
if ("@ViewBag.userName" == "User1"
327326
|| "@ViewBag.userName" == "User2") {
328-
container.documentEditor.editor.enforceProtection("123", "RevisionsOnly");
327+
container.documentEditor.editor.enforceProtection("123", "RevisionsOnly");
328+
container.documentEditor.showrestricteditingpane(false);
329329
}
330330
else if ("@ViewBag.userName" == "Author") {
331331
//stop the document protection

0 commit comments

Comments
 (0)