Added HttpException class for missing HttpException for net8 Wrapped HttpContext.Session, GetJsonResult, IsAjaxRequest and GetUserIdentityName in controllers for net8 Added AuthenticationService to test Fab2ApprovalMKLink code for net8 Compile conditionally flags to debug in dotnet core
56 lines
1.1 KiB
C#
56 lines
1.1 KiB
C#
#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;
|
|
|
|
#pragma warning restore CS8019
|
|
|
|
namespace Fab2ApprovalSystem.Utilities;
|
|
|
|
#if !NET8
|
|
|
|
public class FileUtilities<T> : Controller // <T> => System.Web.Mvc.FileContentResult
|
|
{
|
|
|
|
public T DownloadFilesFromServer<T>(string pathToFile) {
|
|
byte[] fileBytes = GetFile(pathToFile);
|
|
var result = File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, pathToFile);
|
|
return (T)Convert.ChangeType(result, typeof(T));
|
|
}
|
|
|
|
#endif
|
|
|
|
#if NET8
|
|
|
|
public class FileUtilities<T> {
|
|
|
|
#endif
|
|
|
|
public byte[] GetFile(string s) {
|
|
|
|
#if !NET8
|
|
FileStream fs = System.IO.File.OpenRead(s);
|
|
#endif
|
|
|
|
#if NET8
|
|
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;
|
|
}
|
|
} |