Repository navigation
Expand file tree
/
Copy pathHomeController.cs
More file actions
50 lines (46 loc) · 1.87 KB
/
Copy pathHomeController.cs
File metadata and controls
50 lines (46 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using DevExpress.AspNetCore.Spreadsheet;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using T845880.Models;
namespace T845880.Controllers {
public class HomeController : Controller {
public IWebHostEnvironment HostingEnvironment { get; }
public string RootPath { get; set; }
public HomeController(IWebHostEnvironment hostingEnvironment) {
HostingEnvironment = hostingEnvironment;
RootPath = Path.Combine(HostingEnvironment.WebRootPath, "SampleDocs");
}
public IActionResult Index() {
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
public IActionResult OpenDocInSpreadsheet(string filePath) {
return PartialView("SpreadsheetPartial", GetDocumentModel(filePath));
}
[HttpPost]
[HttpGet]
public IActionResult DxDocRequest() {
return SpreadsheetRequestProcessor.GetResponse(HttpContext);
}
private DocumentModel GetDocumentModel(string filePath) {
string path = Path.Combine(RootPath, filePath);
byte[] fileBytes = System.IO.File.ReadAllBytes(path);
DocumentModel model = new DocumentModel() { DocumentID = Path.GetFileName(path), FileBytes = fileBytes };
return model;
}
}
public class DocumentModel {
public string DocumentID { get; set; }
public byte[] FileBytes { get; set; }
}
}