Tasks 184281, 184799, 184800, 184801 and 184802
Align .editorconfig files Move Controller logic to DMO classes GlobalVars.AppSettings = Models.AppSettings.GetFromConfigurationManager(); Question EditorConfig Project level editorconfig Format White Spaces AppSetting when EnvironmentVariable not set Corrective Actions Tests Schedule Actions Tests DMO Tests Controller Tests Get ready to use VSCode IDE
This commit is contained in:
@ -1,34 +1,50 @@
|
||||
#pragma warning disable CS8019
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
#if !NET8
|
||||
using System.Web.Mvc;
|
||||
#endif
|
||||
|
||||
using Fab2ApprovalSystem.DMO;
|
||||
using Fab2ApprovalSystem.Misc;
|
||||
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Fab2ApprovalSystem.Utilities
|
||||
#pragma warning restore CS8019
|
||||
|
||||
namespace Fab2ApprovalSystem.Utilities;
|
||||
|
||||
#if !NET8
|
||||
public class FileUtilities<T> : Controller // <T> => System.Web.Mvc.FileContentResult
|
||||
{
|
||||
public class FileUtilities : Controller
|
||||
{
|
||||
public ActionResult DownloadFilesFromServer(string pathToFile)
|
||||
{
|
||||
//string templatesPath = GlobalVars.CA_BlankFormsLocation;
|
||||
//string fullName = Server.MapPath("~" + filePath);
|
||||
|
||||
byte[] fileBytes = GetFile(pathToFile);
|
||||
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, pathToFile);
|
||||
}
|
||||
public T DownloadFilesFromServer<T>(string pathToFile) {
|
||||
//string templatesPath = GlobalVars.CA_BlankFormsLocation;
|
||||
//string fullName = Server.MapPath("~" + filePath);
|
||||
|
||||
public byte[] GetFile(string s)
|
||||
{
|
||||
System.IO.FileStream fs = System.IO.File.OpenRead(s);
|
||||
byte[] data = new byte[fs.Length];
|
||||
int br = fs.Read(data, 0, data.Length);
|
||||
if (br != fs.Length)
|
||||
throw new System.IO.IOException(s);
|
||||
return data;
|
||||
}
|
||||
byte[] fileBytes = GetFile(pathToFile);
|
||||
var result = File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, pathToFile);
|
||||
return (T)Convert.ChangeType(result, typeof(T));
|
||||
}
|
||||
}
|
||||
#else
|
||||
public class FileUtilities<T> {
|
||||
#endif
|
||||
|
||||
public byte[] GetFile(string s) {
|
||||
#if !NET8
|
||||
FileStream fs = System.IO.File.OpenRead(s);
|
||||
#else
|
||||
FileStream fs = File.OpenRead(s);
|
||||
#endif
|
||||
byte[] data = new byte[fs.Length];
|
||||
int br = fs.Read(data, 0, data.Length);
|
||||
if (br != fs.Length)
|
||||
throw new IOException(s);
|
||||
return data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user