Compare commits

..

1 Commits

Author SHA1 Message Date
65a433e9ab Merged PR 17498: Removed PdfViewController, HtmlViewRenderer and FakeView to be replaced with...
Removed PdfViewController, HtmlViewRenderer and FakeView to be replaced with ViewEngineResult Render method

To test use url
http://mestsa05ec.infineon.com:8080/ecn/printecnpdf?ecnNumber=82654
2025-05-28 22:21:03 +02:00
90 changed files with 1913 additions and 4509 deletions

27
.gitignore vendored
View File

@ -351,36 +351,9 @@ ASALocalRun/
/Fab2ApprovalMKLink/Utilities
/Fab2ApprovalMKLink/ViewModels
/Fab2ApprovalMKLink/Views/Account
/Fab2ApprovalMKLink/Views/Admin
/Fab2ApprovalMKLink/Views/Audit
/Fab2ApprovalMKLink/Views/ChangeControl
/Fab2ApprovalMKLink/Views/CorrectiveAction
/Fab2ApprovalMKLink/Views/ECN
/Fab2ApprovalMKLink/Views/Home
/Fab2ApprovalMKLink/Views/LotDisposition
/Fab2ApprovalMKLink/Views/LotTraveler
/Fab2ApprovalMKLink/Views/Manager
/Fab2ApprovalMKLink/Views/MRB
/Fab2ApprovalMKLink/Views/PartsRequest
/Fab2ApprovalMKLink/Views/Reports
/Fab2ApprovalMKLink/Views/Shared
/Fab2ApprovalMKLink/Views/Training
/Fab2ApprovalMKLink/Views/Workflow
/Fab2ApprovalMKLink/.vscode/.UserSecrets
/Fab2ApprovalSystem/.vscode/.UserSecrets
/Fab2ApprovalTests/.vscode/.UserSecrets
/MesaFabApproval.API/.vscode/.UserSecrets
/MesaFabApproval.Client/.vscode/.UserSecrets
/MesaFabApproval.Shared/.vscode/.UserSecrets
fab-001
fab-002
fab-004
fab-004
fab-005
fab-006
fab-007
fab-008
fab-009

42
.vscode/launch.json vendored
View File

@ -15,48 +15,6 @@
"console": "integratedTerminal",
"stopAtEntry": false
},
{
"name": ".NET Core Launch (web) - Fab2ApprovalMKLink",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Fab2ApprovalMKLink-build",
"program": "${workspaceFolder}/Fab2ApprovalMKLink/bin/Debug/net8.0/Fab2ApprovalMKLink.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
"uriFormat": "%s/swagger/index.html"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Launch (web) - fab-004",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "fab-004-build",
"program": "${workspaceFolder}/fab-004/bin/net8.0/fab-004.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
"uriFormat": "%s/swagger/index.html"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Launch (console) - MesaFabApproval.API",
"type": "coreclr",

16
.vscode/tasks.json vendored
View File

@ -63,7 +63,6 @@
"type": "process",
"args": [
"format",
"${workspaceFolder}/Fab2ApprovalMKLink/Fab2ApprovalMKLink.csproj",
"--report",
".vscode",
"--verbosity",
@ -79,8 +78,7 @@
"type": "process",
"args": [
"format",
"whitespace",
"${workspaceFolder}/Fab2ApprovalMKLink/Fab2ApprovalMKLink.csproj"
"whitespace"
],
"problemMatcher": "$msCompile"
},
@ -96,18 +94,6 @@
],
"problemMatcher": "$msCompile"
},
{
"label": "fab-004-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/fab-004/fab-004.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "Fab2ApprovalMKLink-publish",
"command": "dotnet",

View File

@ -36,36 +36,14 @@ mklink /J "L:\DevOps\Mesa_FI\MesaFabApproval\Fab2ApprovalMKLink\Jobs" "L:\DevOps
mklink /J "L:\DevOps\Mesa_FI\MesaFabApproval\Fab2ApprovalMKLink\JobSchedules" "L:\DevOps\Mesa_FI\MesaFabApproval\Fab2ApprovalSystem\JobSchedules"
```
```bash 1747242128286 = 638828389282860000 = 2025-2.Spring = Wed May 14 2025 10:02:07 GMT-0700 (Mountain Standard Time)
mklink /J "Fab2ApprovalMKLink\.vscode\.UserSecrets" "%AppData%\Microsoft\UserSecrets\f2da5035-aba9-4676-9f8d-d6689f84663d"
mklink /J "Fab2ApprovalMKLink\Controllers" "Fab2ApprovalSystem\Controllers"
mklink /J "Fab2ApprovalMKLink\DMO" "Fab2ApprovalSystem\DMO"
mklink /J "Fab2ApprovalMKLink\Jobs" "Fab2ApprovalSystem\Jobs"
mklink /J "Fab2ApprovalMKLink\JobSchedules" "Fab2ApprovalSystem\JobSchedules"
mklink /J "Fab2ApprovalMKLink\Misc" "Fab2ApprovalSystem\Misc"
mklink /J "Fab2ApprovalMKLink\Models" "Fab2ApprovalSystem\Models"
mklink /J "Fab2ApprovalMKLink\PdfGenerator" "Fab2ApprovalSystem\PdfGenerator"
mklink /J "Fab2ApprovalMKLink\Utilities" "Fab2ApprovalSystem\Utilities"
mklink /J "Fab2ApprovalMKLink\ViewModels" "Fab2ApprovalSystem\ViewModels"
mklink /J "Fab2ApprovalMKLink\ViewModels" "Fab2ApprovalSystem\ViewModels"
```
```bash 1747249935803 = 638828467358030000 = 2025-2.Spring = Wed May 14 2025 12:12:15 GMT-0700 (Mountain Standard Time)
mkdir "Fab2ApprovalMKLink\Views"
mklink /J "Fab2ApprovalMKLink\Views\Account" "Fab2ApprovalSystem\Views\Account"
mklink /J "Fab2ApprovalMKLink\Views\Admin" "Fab2ApprovalSystem\Views\Admin"
mklink /J "Fab2ApprovalMKLink\Views\Audit" "Fab2ApprovalSystem\Views\Audit"
mklink /J "Fab2ApprovalMKLink\Views\ChangeControl" "Fab2ApprovalSystem\Views\ChangeControl"
mklink /J "Fab2ApprovalMKLink\Views\CorrectiveAction" "Fab2ApprovalSystem\Views\CorrectiveAction"
mklink /J "Fab2ApprovalMKLink\Views\ECN" "Fab2ApprovalSystem\Views\ECN"
mklink /J "Fab2ApprovalMKLink\Views\Home" "Fab2ApprovalSystem\Views\Home"
mklink /J "Fab2ApprovalMKLink\Views\LotDisposition" "Fab2ApprovalSystem\Views\LotDisposition"
mklink /J "Fab2ApprovalMKLink\Views\LotTraveler" "Fab2ApprovalSystem\Views\LotTraveler"
mklink /J "Fab2ApprovalMKLink\Views\Manager" "Fab2ApprovalSystem\Views\Manager"
mklink /J "Fab2ApprovalMKLink\Views\MRB" "Fab2ApprovalSystem\Views\MRB"
mklink /J "Fab2ApprovalMKLink\Views\PartsRequest" "Fab2ApprovalSystem\Views\PartsRequest"
mklink /J "Fab2ApprovalMKLink\Views\Reports" "Fab2ApprovalSystem\Views\Reports"
mklink /J "Fab2ApprovalMKLink\Views\Shared" "Fab2ApprovalSystem\Views\Shared"
mklink /J "Fab2ApprovalMKLink\Views\Training" "Fab2ApprovalSystem\Views\Training"
mklink /J "Fab2ApprovalMKLink\Views\Workflow" "Fab2ApprovalSystem\Views\Workflow"
```bash 1734015544321 = 638696123443210000 = Thu Dec 12 2024 07:59:03 GMT-0700 (Mountain Standard Time)
mklink /J ".vscode\.UserSecrets" "%AppData%\Microsoft\UserSecrets\f2da5035-aba9-4676-9f8d-d6689f84663d"
mklink /J "DMO" "..\Fab2ApprovalSystem\DMO"
mklink /J "Jobs" "..\Fab2ApprovalSystem\Jobs"
mklink /J "JobSchedules" "..\Fab2ApprovalSystem\JobSchedules"
mklink /J "Misc" "..\Fab2ApprovalSystem\Misc"
mklink /J "Models" "..\Fab2ApprovalSystem\Models"
mklink /J "PdfGenerator" "..\Fab2ApprovalSystem\PdfGenerator"
mklink /J "Utilities" "..\Fab2ApprovalSystem\Utilities"
mklink /J "ViewModels" "..\Fab2ApprovalSystem\ViewModels"
```

View File

@ -1,74 +0,0 @@
#if NET8
using System;
using System.IO;
using System.Threading.Tasks;
using Fab2ApprovalSystem.PdfGenerator;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.Extensions.DependencyInjection;
namespace Fab2ApprovalSystem.Extensions;
public static class ControllerExtensions {
public static ActionResult GetBinaryContentResult<TModel>(this Controller controller, string viewName, string contentType, TModel model) {
string pageTitle = string.Empty;
string htmlText = RenderViewToString(controller, viewName, model);
StandardPdfRenderer standardPdfRenderer = new();
// Let the html be rendered into a PDF document through iTextSharp.
byte[] buffer = standardPdfRenderer.Render(htmlText, pageTitle);
// Return the PDF as a binary stream to the client.
return new BinaryContentResult(buffer, contentType);
}
public static string RenderViewToString<TModel>(this Controller controller, string viewName, TModel model) {
if (string.IsNullOrEmpty(viewName))
viewName = controller.ControllerContext.ActionDescriptor.ActionName;
controller.ViewData.Model = model;
using (StringWriter writer = new()) {
try {
CompositeViewEngine compositeViewEngine = controller.HttpContext.RequestServices.GetRequiredService(typeof(ICompositeViewEngine)) as CompositeViewEngine;
if (compositeViewEngine is null || compositeViewEngine.ViewEngines.Count == 0) { }
ViewEngineResult viewResult = null;
if (viewName.EndsWith(".cshtml"))
viewResult = compositeViewEngine.GetView(viewName, viewName, false);
else
viewResult = compositeViewEngine.FindView(controller.ControllerContext, viewName, false);
if (!viewResult.Success)
return $"A view with the name '{viewName}' could not be found";
ViewContext viewContext = new(
controller.ControllerContext,
viewResult.View,
controller.ViewData,
controller.TempData,
writer,
new HtmlHelperOptions()
);
Task task = viewResult.View.RenderAsync(viewContext);
task.Wait();
return writer.GetStringBuilder().ToString();
} catch (Exception ex) {
return $"Failed - {ex.Message}";
}
}
}
}
#endif

View File

@ -30,7 +30,6 @@
<PackageReference Include="EntityFramework" Version="6.5.1" />
<PackageReference Include="ExcelDataReader" Version="3.7.0" />
<PackageReference Include="jQuery" Version="3.7.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.10" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.2" />

View File

@ -1,23 +1,15 @@
using System;
using System.Diagnostics;
using System.Text;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.Services;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting.WindowsServices;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
namespace Fab2ApprovalMKLink;
@ -32,36 +24,12 @@ public class Program {
throw new Exception("Company name must have a value!");
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!");
GlobalVars.AppSettings = appSettings;
GlobalVars.AttachmentUrl = appSettings.AttachmentUrl is null ? string.Empty : appSettings.AttachmentUrl;
GlobalVars.CA_BlankFormsLocation = appSettings.CABlankFormsLocation;
GlobalVars.DBConnection = appSettings.DBConnection;
GlobalVars.DB_CONNECTION_STRING = appSettings.DBConnectionString;
GlobalVars.hostURL = appSettings.HostURL;
GlobalVars.IS_INFINEON_DOMAIN = appSettings.IsInfineonDomain;
GlobalVars.MesaTemplateFiles = appSettings.MesaTemplateFiles;
GlobalVars.NDriveURL = appSettings.NDriveURL;
GlobalVars.SENDER_EMAIL = appSettings.SenderEmail;
GlobalVars.USER_ID = appSettings.UserId;
GlobalVars.USER_ISADMIN = appSettings.UserIsAdmin;
GlobalVars.WSR_URL = appSettings.WSR_URL;
try {
_ = webApplicationBuilder.Services.Configure<ApiBehaviorOptions>(options => options.SuppressModelStateInvalidFilter = true);
_ = webApplicationBuilder.Services.AddControllers();
_ = webApplicationBuilder.Services.AddControllersWithViews();
_ = webApplicationBuilder.Services.AddDistributedMemoryCache();
_ = webApplicationBuilder.Services.AddHttpClient();
_ = webApplicationBuilder.Services.AddMemoryCache();
_ = webApplicationBuilder.Services.AddSingleton(_ => appSettings);
_ = webApplicationBuilder.Services.AddSingleton<ICompositeViewEngine, CompositeViewEngine>();
// _ = webApplicationBuilder.Services.AddTransient<IViewRenderingService, ViewRenderingService>();
// _ = webApplicationBuilder.Services.AddScoped<IViewRenderService, ViewRenderService>();
// _ = webApplicationBuilder.Services.AddSingleton<ITempDataProvider, ITempDataProvider>();
_ = webApplicationBuilder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
_ = webApplicationBuilder.Services.AddScoped<IAuthenticationService, AuthenticationService>();
_ = webApplicationBuilder.Services.AddScoped<IDalService, DalService>();
_ = webApplicationBuilder.Services.AddScoped<IDbConnectionService, DbConnectionService>();
_ = webApplicationBuilder.Services.AddScoped<IUserService, UserService>();
_ = webApplicationBuilder.Services.AddSwaggerGen();
_ = webApplicationBuilder.Services.AddSession(sessionOptions => {
sessionOptions.IdleTimeout = TimeSpan.FromSeconds(2000);
@ -69,29 +37,6 @@ public class Program {
sessionOptions.Cookie.IsEssential = true;
}
);
_ = webApplicationBuilder.Services.AddAuthentication(options => {
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options => {
options.RequireHttpsMetadata = false;
options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters {
ValidateIssuerSigningKey = true,
ValidIssuer = appSettings.JwtIssuer,
ValidateAudience = false,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(appSettings.JwtKey)),
ClockSkew = TimeSpan.Zero
};
});
_ = webApplicationBuilder.Services.AddAuthorization(options => {
options.DefaultPolicy = new AuthorizationPolicyBuilder()
.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
.RequireAuthenticatedUser()
.Build();
});
if (WindowsServiceHelpers.IsWindowsService()) {
_ = webApplicationBuilder.Services.AddSingleton<IHostLifetime, WindowsServiceLifetime>();
_ = webApplicationBuilder.Logging.AddEventLog(settings => {
@ -120,8 +65,6 @@ public class Program {
}
_ = webApplication.UseSession();
_ = webApplication.MapControllers();
_ = webApplication.UseAuthentication();
_ = webApplication.UseAuthorization();
logger.LogInformation("Starting Web Application");
webApplication.Run();
return 0;

View File

@ -1,266 +0,0 @@
using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Authentication;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using Fab2ApprovalSystem.Models;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
namespace Fab2ApprovalSystem.Services;
public interface IAuthenticationService {
public Task<LoginResult> AuthenticateUser(AuthAttempt login);
public Task<LoginResult> AttemptLocalUserAuth(WindowsIdentity identity);
public AuthTokens GenerateAuthTokens(AuthAttempt authAttempt, IEnumerable<string> roles);
public Task<LoginResult> RefreshAuthTokens(AuthAttempt authAttempt);
}
public class AuthenticationService : IAuthenticationService {
private readonly ILogger<AuthenticationService> _logger;
private readonly IMemoryCache _cache;
private readonly IUserService _userService;
private readonly string? _jwtIssuer;
private readonly string? _jwtAudience;
private readonly string? _jwtKey;
public AuthenticationService(ILogger<AuthenticationService> logger, IMemoryCache cache, IUserService userService, AppSettings appSettings) {
_logger = logger ?? throw new ArgumentNullException("ILogger not injected");
_cache = cache ?? throw new ArgumentNullException("IMemoryCache not injected");
_userService = userService ?? throw new ArgumentNullException("IUserService not injected");
_jwtKey = appSettings.JwtKey;
_jwtIssuer = appSettings.JwtIssuer;
_jwtAudience = appSettings.JwtAudience;
}
public async Task<LoginResult> AuthenticateUser(AuthAttempt login) {
try {
_logger.LogInformation("Attempting to authenticate user");
if (login is null)
throw new ArgumentNullException("Login cannot be null");
string domain = "infineon.com";
using (PrincipalContext pc = new(ContextType.Domain, domain)) {
bool isValid = pc.ValidateCredentials(login.LoginID, login.Password);
if (isValid) {
User? user = _cache.Get<User>($"user{login.LoginID}");
if (user is null) {
user = await _userService.GetUserByLoginId(login.LoginID);
_cache.Set($"user{login.LoginID}", user, DateTimeOffset.Now.AddDays(1));
}
List<string> roles = new();
if (user.IsManager)
roles.Add("manager");
if (user.IsAdmin)
roles.Add("admin");
AuthTokens tokens = GenerateAuthTokens(login, roles);
return new LoginResult {
IsAuthenticated = true,
AuthTokens = tokens,
User = user
};
} else {
return new LoginResult() {
IsAuthenticated = false,
AuthTokens = new() {
JwtToken = "",
RefreshToken = ""
},
User = null
};
}
}
} catch (Exception ex) {
_logger.LogError($"An exception occurred when attempting to authenticate user. Exception: {ex.Message}");
throw;
}
}
public async Task<LoginResult> AttemptLocalUserAuth(WindowsIdentity identity) {
try {
_logger.LogInformation("Attempting to authenticate local Windows system user");
if (identity is null)
throw new ArgumentNullException("WindowsIdentity cannot be null");
User user = await _userService.GetUserByLoginId(identity.Name);
List<string> roles = new();
if (user.IsManager)
roles.Add("manager");
if (user.IsAdmin)
roles.Add("admin");
AuthAttempt authAttempt = new() {
LoginID = user.LoginID,
};
AuthTokens tokens = GenerateAuthTokens(authAttempt, roles);
return new LoginResult {
IsAuthenticated = true,
AuthTokens = tokens,
User = user
};
} catch (Exception ex) {
_logger.LogError($"Unable to authenticate local Windows system user, because {ex.Message}");
throw;
}
}
public AuthTokens GenerateAuthTokens(AuthAttempt authAttempt, IEnumerable<string> roles) {
try {
_logger.LogInformation("Attempting to generate JWT");
if (authAttempt is null)
throw new ArgumentNullException("AuthAttempt cannot be null");
if (string.IsNullOrWhiteSpace(authAttempt.LoginID))
throw new ArgumentException("UserName cannot be null or empty");
if (roles is null)
throw new ArgumentNullException("roles cannot be null");
byte[] key = Encoding.ASCII.GetBytes(_jwtKey);
List<Claim> claims = new() {
new Claim(nameof(authAttempt.LoginID), authAttempt.LoginID)
};
foreach (string role in roles) {
claims.Add(new Claim(ClaimTypes.Role, role));
}
ClaimsIdentity identity = new(claims);
SecurityTokenDescriptor tokenDescriptor = new() {
Issuer = _jwtIssuer,
Audience = _jwtAudience,
Subject = identity,
NotBefore = DateTime.Now,
Expires = DateTime.Now.AddHours(8),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
};
JwtSecurityTokenHandler tokenHandler = new();
JwtSecurityToken token = tokenHandler.CreateJwtSecurityToken(tokenDescriptor);
string jwt = tokenHandler.WriteToken(token);
string refreshToken = GenerateRefreshToken();
List<string>? refreshTokensForUser = _cache.Get<List<string>>(authAttempt.LoginID);
refreshTokensForUser ??= new List<string>();
if (refreshTokensForUser.Count > 9)
refreshTokensForUser.RemoveRange(9, refreshTokensForUser.Count - 9);
refreshTokensForUser.Insert(0, refreshToken);
_cache.Set(authAttempt.LoginID, refreshTokensForUser, DateTimeOffset.Now.AddHours(4));
return new AuthTokens {
JwtToken = jwt,
RefreshToken = refreshToken
};
} catch (Exception ex) {
_logger.LogError($"An exception occurred when attempting to generate JWT. Exception: {ex.Message}");
throw;
}
}
public async Task<LoginResult> RefreshAuthTokens(AuthAttempt authAttempt) {
try {
_logger.LogInformation("Attempting to refresh auth tokens");
if (authAttempt is null)
throw new ArgumentNullException("AuthAttempt cannot be null");
if (authAttempt.AuthTokens is null)
throw new ArgumentNullException("AuthTokens cannot be null");
bool refreshTokenIsValid = IsRefreshTokenValid(authAttempt.LoginID, authAttempt.AuthTokens.RefreshToken);
if (refreshTokenIsValid) {
User? user = _cache.Get<User>($"user{authAttempt.LoginID}");
if (user is null) {
user = await _userService.GetUserByLoginId(authAttempt.LoginID);
_cache.Set($"user{authAttempt.LoginID}", user, DateTimeOffset.Now.AddDays(1));
}
List<string> roles = new();
if (user.IsManager)
roles.Add("manager");
if (user.IsAdmin)
roles.Add("admin");
AuthTokens refreshedTokens = GenerateAuthTokens(authAttempt, roles);
LoginResult loginResult = new() {
IsAuthenticated = true,
AuthTokens = refreshedTokens,
User = user
};
return loginResult;
} else {
throw new AuthenticationException("Invalid refresh token");
}
} catch (Exception ex) {
_logger.LogError($"An exception occurred when attempting to refresh auth tokens. Exception: {ex.Message}");
throw;
}
}
private string GenerateRefreshToken() {
byte[] randomNumber = new byte[32];
using (RandomNumberGenerator rng = RandomNumberGenerator.Create()) {
rng.GetBytes(randomNumber);
return Convert.ToBase64String(randomNumber);
}
}
private bool IsRefreshTokenValid(string loginId, string refreshToken) {
try {
_logger.LogInformation("Attempting to determine if refresh token is valid");
if (string.IsNullOrWhiteSpace(loginId))
throw new ArgumentNullException("LoginID cannot be null or empty");
if (string.IsNullOrWhiteSpace(refreshToken))
throw new ArgumentNullException("Refresh token cannot be null or empty");
List<string>? cachedRefreshTokensForUser = _cache.Get<List<string>>(loginId);
if (cachedRefreshTokensForUser is null || !cachedRefreshTokensForUser.Contains(refreshToken)) {
_logger.LogInformation($"Could not find cached refresh tokens for user {loginId}");
return false;
}
return true;
} catch (Exception ex) {
_logger.LogError($"An exception occurred when attempting to validate refresh token. Exception: {ex.Message}");
throw;
}
}
}

View File

@ -1,168 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using Microsoft.Extensions.Logging;
namespace Fab2ApprovalSystem.Services;
public interface IDalService {
Task<IEnumerable<T>> QueryAsync<T>(string sql);
Task<IEnumerable<T>> QueryAsync<T>(string sql, object parameters);
Task<int> ExecuteAsync(string sql);
Task<int> ExecuteAsync<T>(string sql, T parameters);
}
public class DalService : IDalService {
private static readonly int RETRIES = 3;
private static readonly int BACKOFF_SECONDS_INTERVAL = 30;
private readonly ILogger<DalService> _logger;
private readonly IDbConnectionService _dbConnectionService;
public DalService(IDbConnectionService dbConnectionService, ILogger<DalService> logger) {
_dbConnectionService = dbConnectionService ??
throw new ArgumentNullException("IDbConnectionService not injected");
_logger = logger ??
throw new ArgumentNullException("ILogger not injected");
}
public async Task<IEnumerable<T>> QueryAsync<T>(string sql) {
if (sql is null) throw new ArgumentNullException("sql cannot be null");
int remainingRetries = RETRIES;
bool queryWasSuccessful = false;
Exception exception = null;
IEnumerable<T> result = new List<T>();
while (!queryWasSuccessful && remainingRetries > 0) {
int backoffSeconds = (RETRIES - remainingRetries--) * BACKOFF_SECONDS_INTERVAL;
Task.Delay(backoffSeconds * 1000).Wait();
try {
_logger.LogInformation($"Attempting to perform query with {sql}. Remaining retries: {remainingRetries}");
using (IDbConnection conn = _dbConnectionService.GetConnection()) {
result = await conn.QueryAsync<T>(sql);
}
queryWasSuccessful = true;
} catch (Exception ex) {
_logger.LogError($"An exception occurred while attempting to perform a query. Exception: {ex.Message}");
exception = ex;
}
}
if (!queryWasSuccessful && exception is not null) {
throw exception;
}
return result;
}
public async Task<IEnumerable<T>> QueryAsync<T>(string sql, object parameters) {
if (sql is null) throw new ArgumentNullException("sql cannot be null");
if (parameters is null) throw new ArgumentNullException("parameters cannot be null");
StringBuilder logBuilder = new();
int remainingRetries = RETRIES;
bool queryWasSuccessful = false;
Exception exception = null;
IEnumerable<T> result = new List<T>();
while (!queryWasSuccessful && remainingRetries > 0) {
int backoffSeconds = (RETRIES - remainingRetries--) * BACKOFF_SECONDS_INTERVAL;
Task.Delay(backoffSeconds * 1000).Wait();
try {
logBuilder.Clear();
logBuilder.Append($"Attempting to perform query with {sql} ");
logBuilder.Append($"and parameters {parameters.ToString()}. ");
logBuilder.Append($"Remaining retries: {remainingRetries}");
_logger.LogInformation(logBuilder.ToString());
using (IDbConnection conn = _dbConnectionService.GetConnection()) {
result = await conn.QueryAsync<T>(sql, parameters);
}
queryWasSuccessful = true;
} catch (Exception ex) {
_logger.LogError($"An exception occurred while attempting to perform a query. Exception: {ex.Message}");
exception = ex;
}
}
if (!queryWasSuccessful && exception is not null) {
throw exception;
}
return result;
}
public async Task<int> ExecuteAsync(string sql) {
if (sql is null) throw new ArgumentNullException("sql cannot be null");
int remainingRetries = RETRIES;
bool queryWasSuccessful = false;
Exception exception = null;
int rowsAffected = 0;
while (!queryWasSuccessful && remainingRetries > 0) {
int backoffSeconds = (RETRIES - remainingRetries--) * BACKOFF_SECONDS_INTERVAL;
Task.Delay(backoffSeconds * 1000).Wait();
try {
_logger.LogInformation($"Attempting to execute {sql}. Remaining retries: {remainingRetries}");
using (IDbConnection conn = _dbConnectionService.GetConnection()) {
rowsAffected = await conn.ExecuteAsync(sql);
}
queryWasSuccessful = true;
} catch (Exception ex) {
_logger.LogError($"An exception occurred while attempting to execute a query. Exception: {ex.Message}");
exception = ex;
}
}
if (!queryWasSuccessful && exception is not null) {
throw exception;
}
return rowsAffected;
}
public async Task<int> ExecuteAsync<T>(string sql, T parameters) {
if (sql is null) throw new ArgumentNullException("sql cannot be null");
int remainingRetries = RETRIES;
bool queryWasSuccessful = false;
Exception exception = null;
int rowsAffected = 0;
while (!queryWasSuccessful && remainingRetries > 0) {
int backoffSeconds = (RETRIES - remainingRetries--) * BACKOFF_SECONDS_INTERVAL;
Task.Delay(backoffSeconds * 1000).Wait();
try {
_logger.LogInformation($"Attempting to execute {sql} with parameters. Remaining retries: {remainingRetries}");
using (IDbConnection conn = _dbConnectionService.GetConnection()) {
rowsAffected = await conn.ExecuteAsync(sql, parameters);
}
queryWasSuccessful = true;
} catch (Exception ex) {
_logger.LogError($"An exception occurred while attempting to execute a query. Exception: {ex.Message}");
exception = ex;
}
}
if (!queryWasSuccessful && exception is not null) {
throw exception;
}
return rowsAffected;
}
}

View File

@ -1,22 +0,0 @@
using System.Data;
using Fab2ApprovalSystem.Models;
using Microsoft.Data.SqlClient;
namespace Fab2ApprovalSystem.Services;
public interface IDbConnectionService {
IDbConnection GetConnection();
}
public class DbConnectionService : IDbConnectionService {
private readonly string _dbConnectionString;
public DbConnectionService(AppSettings appSettings) {
_dbConnectionString = appSettings.DBConnectionString;
}
public IDbConnection GetConnection() =>
new SqlConnection(_dbConnectionString);
}

View File

@ -1,150 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Fab2ApprovalSystem.Models;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
namespace Fab2ApprovalSystem.Services;
public interface IUserService {
Task<IEnumerable<User>> GetAllActiveUsers();
Task<User> GetUserByLoginId(string loginId);
Task<User> GetUserByUserId(int userId);
Task<IEnumerable<int>> GetApproverUserIdsBySubRoleCategoryItem(string item);
}
public class UserService : IUserService {
private readonly ILogger<UserService> _logger;
private readonly IDalService _dalService;
private readonly IMemoryCache _cache;
public UserService(ILogger<UserService> logger, IDalService dalService, IMemoryCache cache) {
_logger = logger ??
throw new ArgumentNullException("ILogger not injected");
_dalService = dalService ??
throw new ArgumentNullException("IDalService not injected");
_cache = cache ??
throw new ArgumentNullException("IMemoryCache not injected");
}
public async Task<IEnumerable<User>> GetAllActiveUsers() {
try {
_logger.LogInformation("Attempting to get all active users");
IEnumerable<User>? allActiveUsers = _cache.Get<IEnumerable<User>>("allActiveUsers");
if (allActiveUsers is null) {
string sql = "select * from Users where IsActive = 1";
allActiveUsers = (await _dalService.QueryAsync<User>(sql)).ToList();
_cache.Set("allActiveUsers", allActiveUsers, DateTimeOffset.Now.AddHours(1));
}
if (allActiveUsers is null || allActiveUsers.Count() == 0) {
throw new Exception("No users found");
}
return allActiveUsers;
} catch (Exception ex) {
string errMsg = $"An exception occurred when attempting to get all users. Exception: {ex.Message}";
_logger.LogError(errMsg);
throw;
}
}
public async Task<User> GetUserByLoginId(string loginId) {
try {
_logger.LogInformation("Attempting to get user by LoginId");
if (string.IsNullOrWhiteSpace(loginId))
throw new ArgumentException("LoginId cannot be null or empty");
User? user = _cache.Get<User>($"userByLoginId{loginId}");
user ??= _cache.Get<IEnumerable<User>>("allActiveUsers")?.FirstOrDefault(u => u.LoginID == loginId);
if (user is null) {
string sql = $"select * from Users where LoginID = '{loginId}';";
user = (await _dalService.QueryAsync<User>(sql)).FirstOrDefault();
_cache.Set($"userByLoginId{loginId}", user, DateTimeOffset.Now.AddHours(1));
}
if (user is null) throw new Exception($"No user found with LoginID {loginId}");
return user;
} catch (Exception ex) {
string errMsg = $"An exception occurred when attempting to get user for LoginID {loginId}. Exception: {ex.Message}";
_logger.LogError(errMsg);
throw;
}
}
public async Task<User> GetUserByUserId(int userId) {
try {
_logger.LogInformation("Attempting to get user by user ID");
if (userId <= 0) throw new ArgumentException($"{userId} is not a valid user ID");
User? user = _cache.Get<User>($"userByUserId{userId}");
user ??= _cache.Get<IEnumerable<User>>("allActiveUsers")?.FirstOrDefault(u => u.UserID == userId);
if (user is null) {
string sql = $"select * from Users where UserID = '{userId}';";
user = (await _dalService.QueryAsync<User>(sql)).FirstOrDefault();
_cache.Set($"userByUserId{userId}", user, DateTimeOffset.Now.AddHours(1));
}
if (user is null) throw new Exception($"No user found with UserID {userId}");
return user;
} catch (Exception ex) {
string errMsg = $"An exception occurred when attempting to get user for UserID {userId}. Exception: {ex.Message}";
_logger.LogError(errMsg);
throw;
}
}
public async Task<IEnumerable<int>> GetApproverUserIdsBySubRoleCategoryItem(string item) {
try {
_logger.LogInformation("Attempting to get approver user IDs");
if (string.IsNullOrWhiteSpace(item)) throw new ArgumentException("SubRoleCategoryItem cannot be null or empty");
IEnumerable<int>? userIds = _cache.Get<IEnumerable<int>>($"approverUserIdsBySubRollCategory{item}");
if (userIds is null) {
StringBuilder queryBuilder = new();
queryBuilder.Append("select us.UserID ");
queryBuilder.Append("from SubRole as sr ");
queryBuilder.Append("join UserSubRole as us on sr.SubRoleID=us.SubRoleID ");
queryBuilder.Append("join SubRoleCategory as sc on sr.SubRoleCategoryID=sc.SubRoleCategoryID ");
queryBuilder.Append($"where sc.SubRoleCategoryItem='{item}'");
userIds = (await _dalService.QueryAsync<int>(queryBuilder.ToString())).ToList();
_cache.Set($"approverUserIdsBySubRollCategory{item}", userIds, DateTimeOffset.Now.AddHours(1));
}
if (userIds is null || userIds.Count() == 0) {
throw new Exception($"No users found for SubRoleCategoryItem {item}");
}
return userIds;
} catch (Exception ex) {
string errMsg = $"An exception occurred when attempting to get approver user IDs. Exception: {ex.Message}";
_logger.LogError(errMsg);
throw;
}
}
}

View File

@ -1,8 +0,0 @@
@using Fab2ApprovalSystem.DMO
@using Fab2ApprovalSystem.JobSchedules
@using Fab2ApprovalSystem.Misc
@using Fab2ApprovalSystem.Models
@using Fab2ApprovalSystem.PdfGenerator
@using Fab2ApprovalSystem.Utilities
@using Fab2ApprovalSystem.ViewModels
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -1,3 +0,0 @@
@{
Layout = null;
}

View File

@ -1,7 +1,5 @@
using System.Web;
#if !NET8
using System.Web.Mvc;
#endif
namespace Fab2ApprovalSystem;

View File

@ -3,16 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
#if !NET8
using System.Web.Mvc;
#endif
using System.Web.Routing;
namespace Fab2ApprovalSystem;
public class RouteConfig {
public static void RegisterRoutes(RouteCollection routes) {
#if !NET8
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
@ -23,6 +20,5 @@ public class RouteConfig {
// otherwise MVC generates the wrong form action url
defaults: new { controller = "Home", action = "MyTasks", id = UrlParameter.Optional }
);
#endif
}
}

View File

@ -6,12 +6,10 @@ public static class WebApiConfig {
public static void Register(HttpConfiguration config) {
config.MapHttpAttributeRoutes();
#if !NET8
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
#endif
}
}

View File

@ -1,47 +1,30 @@
#if !NET8
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
#endif
#if NET8
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
#endif
#if !NET8
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
#endif
#if !NET8
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
#endif
#if !NET8
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using Newtonsoft.Json;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if NET8
[Route("[controller]")]
#endif
public class AccountController : Controller {
#if !NET8
public AccountController()
: this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()))) {
}
@ -52,23 +35,25 @@ public class AccountController : Controller {
public UserManager<ApplicationUser> UserManager { get; private set; }
#endif
#if !NET8
// GET: /Account/Login
[AllowAnonymous]
// try to make the browser refresh the login page every time, to prevent issues with changing usernames and the anti-forgery token validation
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
#endif
public ActionResult Login(string returnUrl) {
ViewBag.ReturnUrl = returnUrl;
return View();
}
#if !NET8
private void SetSessionParameters(LoginResult loginResult, LoginModel user) {
GlobalVars.SetSessionParameters(GetSession(), loginResult, user);
Session["JWT"] = loginResult.AuthTokens.JwtToken;
Session["RefreshToken"] = loginResult.AuthTokens.RefreshToken;
Session[GlobalVars.SESSION_USERID] = user.UserID;
Session[GlobalVars.SESSION_USERNAME] = user.FullName;
Session[GlobalVars.IS_ADMIN] = user.IsAdmin;
Session[GlobalVars.IS_MANAGER] = user.IsManager;
Session[GlobalVars.OOO] = user.OOO;
Session[GlobalVars.CAN_CREATE_PARTS_REQUEST] = user.IsAdmin || PartsRequestController.CanCreatePartsRequest(user.UserID);
FormsAuthentication.SetAuthCookie(user.LoginID, true);
}
@ -117,8 +102,8 @@ public class AccountController : Controller {
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
} catch (Exception ex) {
Functions.WriteEvent(GlobalVars.AppSettings, GetUserIdentityName() + " " + ex.InnerException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = 99999, UserID = GetUserIdentityName(), DocumentType = "Login", OperationType = "Error", Comments = "Reject - " + ex.Message });
Functions.WriteEvent(GlobalVars.AppSettings, @User.Identity.Name + " " + ex.InnerException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = 99999, UserID = @User.Identity.Name, DocumentType = "Login", OperationType = "Error", Comments = "Reject - " + ex.Message });
ModelState.AddModelError("", ex.Message);
}
@ -173,24 +158,20 @@ public class AccountController : Controller {
return new HttpResponseMessage(HttpStatusCode.Unauthorized);
}
} catch (Exception ex) {
Functions.WriteEvent(GlobalVars.AppSettings, GetUserIdentityName() + " " + ex.InnerException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = 99999, UserID = GetUserIdentityName(), DocumentType = "Login", OperationType = "Error", Comments = "Reject - " + ex.Message });
Functions.WriteEvent(GlobalVars.AppSettings, @User.Identity.Name + " " + ex.InnerException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = 99999, UserID = @User.Identity.Name, DocumentType = "Login", OperationType = "Error", Comments = "Reject - " + ex.Message });
ModelState.AddModelError("", ex.Message);
return new HttpResponseMessage(HttpStatusCode.InternalServerError);
}
}
#endif
// GET: /Account/Register
[AllowAnonymous]
public ActionResult Register() {
return View();
}
#if !NET8
// POST: /Account/Disassociate
[HttpPost]
[ValidateAntiForgeryToken]
@ -205,8 +186,6 @@ public class AccountController : Controller {
return RedirectToAction("Manage", new { Message = message });
}
#endif
// GET: /Account/Manage
#pragma warning disable IDE0060 // Remove unused parameter
public ActionResult Manage(ManageMessageId? message) {
@ -214,8 +193,6 @@ public class AccountController : Controller {
}
#pragma warning restore IDE0060 // Remove unused parameter
#if !NET8
// POST: /Account/ExternalLogin
[HttpPost]
[AllowAnonymous]
@ -246,6 +223,7 @@ public class AccountController : Controller {
return RedirectToAction("Manage", new { Message = ManageMessageId.Error });
}
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff() {
@ -253,15 +231,12 @@ public class AccountController : Controller {
return RedirectToAction("Login", "Account");
}
#endif
// GET: /Account/ExternalLoginFailure
[AllowAnonymous]
public ActionResult ExternalLoginFailure() {
return View();
}
#if !NET8
[ChildActionOnly]
public ActionResult RemoveAccountList() {
IList<UserLoginInfo> linkedAccounts = UserManager.GetLogins(User.Identity.GetUserId());
@ -277,14 +252,10 @@ public class AccountController : Controller {
base.Dispose(disposing);
}
#endif
#region Helpers
// Used for XSRF protection when adding external logins
private const string XsrfKey = "XsrfId";
#if !NET8
private IAuthenticationManager AuthenticationManager {
get {
return HttpContext.GetOwinContext().Authentication;
@ -311,8 +282,6 @@ public class AccountController : Controller {
return false;
}
#endif
public enum ManageMessageId {
ChangePasswordSuccess,
SetPasswordSuccess,
@ -328,18 +297,7 @@ public class AccountController : Controller {
}
}
#if !NET8
private class ChallengeResult : HttpUnauthorizedResult {
#endif
#if NET8
private class ChallengeResult {
#endif
public ChallengeResult(string provider, string redirectUri) : this(provider, redirectUri, null) {
}
@ -353,8 +311,6 @@ public class AccountController : Controller {
public string RedirectUri { get; set; }
public string UserId { get; set; }
#if !NET8
public override void ExecuteResult(ControllerContext context) {
AuthenticationProperties properties = new AuthenticationProperties() { RedirectUri = RedirectUri };
if (UserId != null) {
@ -362,40 +318,6 @@ public class AccountController : Controller {
}
context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
}
#endif
}
#endregion
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,47 +1,31 @@
using System;
using System.Collections.Generic;
#if !NET8
using System.Linq;
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
#if !NET8
using System.Linq;
using Fab2ApprovalSystem.ViewModels;
#endif
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class AdminController : Controller {
// GET: /Admin/
private readonly UserAccountDMO userDMO = new();
private readonly AdminDMO adminDMO = new();
private readonly TrainingDMO trainingDMO = new();
private readonly LotDispositionDMO ldDMO = new();
private readonly AppSettings? _AppSettings = GlobalVars.AppSettings;
UserAccountDMO userDMO = new UserAccountDMO();
AdminDMO adminDMO = new AdminDMO();
TrainingDMO trainingDMO = new TrainingDMO();
LotDispositionDMO ldDMO = new LotDispositionDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult Index() {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
var model = userDMO.GetAllUsers();
ViewBag.AllActiveUsers = userDMO.GetAllActiveUsers();
return View(model);
@ -49,10 +33,8 @@ public class AdminController : Controller {
return Content("Not Autthorized");
}
#if !NET8
public ActionResult AssignRoles() {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
ViewBag.ToplevelNode = GetRoles_SubRolesList();
return View();
} else
@ -61,26 +43,26 @@ public class AdminController : Controller {
public ActionResult GetAllUserList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<LoginModel> userlist = userDMO.GetAllActiveUsers();
return GetJsonResult(userlist);
return Json(userlist, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// For the Administration of the Users
/// </summary>
public ActionResult GetGridUserList([DataSourceRequest] DataSourceRequest request) {
return GetJsonResult(userDMO.GetAllUsers().ToDataSourceResult(request));
return Json(userDMO.GetAllUsers().ToDataSourceResult(request));
}
#endif
public JsonResult GetAllUserListBySubRole(int subRole) {
IEnumerable<LoginModel> userlist = adminDMO.GetAllUsersBySubRole(subRole);
return GetJsonResult(userlist);
return Json(userlist, JsonRequestBehavior.AllowGet);
}
public JsonResult AllSubRoles(string showInactiveRoles = "") {
List<ParentChildModel> newRoles = adminDMO.GetAllSubRoles(showInactiveRoles);
return GetJsonResult(newRoles);
}
#if !NET8
return Json(newRoles, JsonRequestBehavior.AllowGet);
}
public ActionResult GetSubRoleListByUserId([DataSourceRequest] DataSourceRequest request, string userId) {
int userIdInt = Convert.ToInt32(userId);
@ -88,6 +70,9 @@ public class AdminController : Controller {
return Json(adminDMO.GetUserSubRoles(userIdInt).ToDataSourceResult(request));
}
/// <summary>
/// OBSOLETE FUNCTION BELOW FOR THE KENDO TREEVIEW
/// </summary>
private IEnumerable<TreeViewItemModel> GetRoles_SubRolesList() {
List<Role> roles = adminDMO.GetSubRoles();
@ -118,8 +103,6 @@ public class AdminController : Controller {
return ToplevelNode;
}
#endif
public ActionResult AddUserRoles(int subRole, string users) {
adminDMO.AddUserRoles(subRole, users);
return View();
@ -145,8 +128,6 @@ public class AdminController : Controller {
return View();
}
#if !NET8
// POST: /Workflow/Create
[HttpPost]
public ActionResult Create(FormCollection collection) {
@ -173,16 +154,12 @@ public class AdminController : Controller {
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
#endif
public ActionResult DeleteUser(string userId) {
LoginModel loginModel = userDMO.GetUserByID(Convert.ToInt32(userId));
adminDMO.DeleteUser(userDMO, trainingDMO, loginModel);
return Content("Success");
}
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult InsertUser([DataSourceRequest] DataSourceRequest request, LoginModel model) {
try {
@ -197,8 +174,6 @@ public class AdminController : Controller {
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
#endif
public ActionResult EnableOOOStatus(int oooUserID, int delegatedTo, DateTime startDate, DateTime endDate) {
int returnValue = MiscDMO.EnableOOOStatus(oooUserID, delegatedTo, startDate, endDate);
if (returnValue == 3) // the delegator is already a delegator to someone else
@ -216,7 +191,7 @@ public class AdminController : Controller {
}
public ActionResult ManageTrainingGroups() {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
ViewBag.AllGroups = GetTrainingGroups();
return View();
} else
@ -237,17 +212,15 @@ public class AdminController : Controller {
return TrainingGroups;
}
#if !NET8
public ActionResult GetTaskListByUser([DataSourceRequest] DataSourceRequest request, string userId) {
IEnumerable<IssuesViewModel> data = ldDMO.GetTaskList(Convert.ToInt32(userId));
data = from a in data where a.PendingApprovers != null select a;
return GetJsonResult(data.ToDataSourceResult(request));
return Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
public ActionResult GetOpenActionItemsByUser([DataSourceRequest] DataSourceRequest request, string userId) {
IEnumerable<OpenActionItemViewModel> data = ldDMO.GetMyOpenActionItems(Convert.ToInt32(userId));
return GetJsonResult(data.ToDataSourceResult(request));
return Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
public ActionResult AddNewTrainingGroup(string groupName) {
@ -259,8 +232,6 @@ public class AdminController : Controller {
}
}
#endif
public ActionResult DeleteTrainingGroup(int groupID) {
try {
adminDMO.DeleteTrainingGroup(groupID);
@ -275,8 +246,6 @@ public class AdminController : Controller {
return View();
}
#if !NET8
public ActionResult TrainingGroupPartial(int TrainingGroupID) {
ViewBag.AllUsers = userDMO.GetAllActiveUsers();
ViewBag.TrainingGroupId = TrainingGroupID;
@ -294,8 +263,6 @@ public class AdminController : Controller {
return Json(new { test = "Succesfully saved" });
}
#endif
public ActionResult DeleteFromGroup(int userId, int groupId) {
try {
adminDMO.DeleteFromGroup(userId, groupId);
@ -307,7 +274,7 @@ public class AdminController : Controller {
}
public ActionResult JobSchedulerConfiguration() {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
return View();
} else
return Content("Not Autthorized");
@ -316,7 +283,7 @@ public class AdminController : Controller {
public ActionResult TrainingReportConfig() {
ViewBag.AllUsers = userDMO.GetAllActiveUsers();
List<TrainingReportUser> currentTrainingReportUsersIds = adminDMO.GetTrainingReportUsers();
List<LoginModel> currentTrainingReportUsers = new();
List<LoginModel> currentTrainingReportUsers = new List<LoginModel>();
foreach (TrainingReportUser id in currentTrainingReportUsersIds) {
currentTrainingReportUsers.Add(userDMO.GetUserByID(id.UserId));
@ -325,12 +292,10 @@ public class AdminController : Controller {
return PartialView();
}
#if !NET8
public ActionResult TECNNotificationConfig() {
ViewBag.AllUsers = userDMO.GetAllActiveUsers();
List<TECNNotificationsUser> currentTECNNotificationUsersIds = adminDMO.GetTECNNotificationUsers();
List<LoginModel> currentTECNNotificationUsers = new();
List<LoginModel> currentTECNNotificationUsers = new List<LoginModel>();
foreach (TECNNotificationsUser id in currentTECNNotificationUsersIds) {
currentTECNNotificationUsers.Add(userDMO.GetUserByID(id.UserId));
@ -339,10 +304,8 @@ public class AdminController : Controller {
return PartialView();
}
#endif
public ActionResult AddToTrainingReport(int userId) {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
// Check to make sure user is not apart of the group already
bool userExists = false;
List<TrainingReportUser> existingUsers = adminDMO.GetTrainingReportUsers();
@ -366,10 +329,8 @@ public class AdminController : Controller {
}
}
#if !NET8
public ActionResult AddToTECNNotification(int userId) {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
// Check to make sure user is not apart of the group already
bool userExists = false;
List<TECNNotificationsUser> existingUsers = adminDMO.GetTECNNotificationUsers();
@ -399,10 +360,8 @@ public class AdminController : Controller {
}
}
#endif
public ActionResult DeleteFromTrainingReport(int userId) {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
try {
adminDMO.TrainingReportDeleteUser(userId);
return Content("Successfully Deleted");
@ -415,7 +374,7 @@ public class AdminController : Controller {
}
public ActionResult DeleteFromTECNNotification(int userId) {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
try {
adminDMO.TECNExpirationDeleteUser(userId);
return Content("Successfully Deleted");
@ -427,33 +386,4 @@ public class AdminController : Controller {
}
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,43 +1,27 @@
using System;
using System.Collections.Generic;
#if !NET8
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
#if !NET8
using System.Configuration;
using System.Linq;
using Fab2ApprovalSystem.Utilities;
#endif
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class AuditController : Controller {
private readonly AuditDMO auditDMO = new(GlobalVars.AppSettings);
private readonly CorrectiveActionDMO caDMO = new();
AuditDMO auditDMO = new AuditDMO(GlobalVars.AppSettings);
CorrectiveActionDMO caDMO = new CorrectiveActionDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: Audit
@ -46,11 +30,11 @@ public class AuditController : Controller {
}
public ActionResult Create() {
Audit audit = new();
Audit audit = new Audit();
try {
// TODO: Add insert logic here
audit.OriginatorID = GlobalVars.GetUserId(GetSession());
audit.OriginatorID = (int)Session[GlobalVars.SESSION_USERID];
auditDMO.InsertAudit(audit);
return RedirectToAction("Edit", new { issueID = audit.AuditNo });
} catch (Exception e) {
@ -61,19 +45,19 @@ public class AuditController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + audit.AuditNo.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n SubmitDocument - Audit\r\n" + audit.AuditNo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = audit.AuditNo, UserID = GetUserIdentityName(), DocumentType = "Audit", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n SubmitDocument - Audit\r\n" + audit.AuditNo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = audit.AuditNo, UserID = @User.Identity.Name, DocumentType = "Audit", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
throw new Exception(e.Message);
}
}
public ActionResult Edit(int issueID) {
int isITARCompliant = 1;
Audit audit = new();
Audit audit = new Audit();
try {
bool isAdmin = GlobalVars.IsAdmin(GetSession());
int userId = GlobalVars.GetUserId(GetSession());
bool isAdmin = (bool)Session[GlobalVars.IS_ADMIN];
int userId = (int)Session[GlobalVars.SESSION_USERID];
audit = auditDMO.GetAuditItem(issueID, userId);
AuditEdit auditEdit = auditDMO.GetAuditEdit(issueID, audit, isAdmin, userId);
if (auditEdit.RedirectToAction)
@ -97,8 +81,8 @@ public class AuditController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + audit.AuditNo.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Edit - Audit\r\n" + audit.AuditNo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = audit.AuditNo, UserID = GetUserIdentityName(), DocumentType = "Audit", OperationType = "Error", Comments = "Edit - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Edit - Audit\r\n" + audit.AuditNo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = audit.AuditNo, UserID = @User.Identity.Name, DocumentType = "Audit", OperationType = "Error", Comments = "Edit - " + exceptionString });
throw new Exception(e.Message);
}
@ -109,7 +93,7 @@ public class AuditController : Controller {
public ActionResult Edit(Audit model) {
try {
var data = model;
auditDMO.UpdateAudit(model, GlobalVars.GetUserId(GetSession()));
auditDMO.UpdateAudit(model, (int)Session[GlobalVars.SESSION_USERID]);
} catch (Exception ex) {
return Content(ex.Message);
}
@ -129,8 +113,8 @@ public class AuditController : Controller {
}
public ActionResult ReadOnlyAudit(int auditNo) {
Audit audit = new();
audit = auditDMO.GetAuditItemReadOnly(auditNo, GlobalVars.GetUserId(GetSession()));
Audit audit = new Audit();
audit = auditDMO.GetAuditItemReadOnly(auditNo, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.AuditTypeList = auditDMO.GetAuditTypeList();
ViewBag.AuditorList = auditDMO.GetAuditorList();
@ -140,13 +124,11 @@ public class AuditController : Controller {
return View(audit);
}
#if !NET8
public ActionResult AuditReportAttachSave(IEnumerable<HttpPostedFileBase> AuditReportFiles, int auditNo) {
try {
// The Name of the Upload component is "files"
if (AuditReportFiles != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in AuditReportFiles) {
AuditHelper.AuditReportAttachSave(_AppSettings, auditDMO, auditNo, userId, file.FileName, file.InputStream);
}
@ -163,8 +145,6 @@ public class AuditController : Controller {
return Json(auditDMO.GetAuditReportAttachments(auditNo).ToDataSourceResult(request));
}
#endif
[HttpPost]
public void DeleteAuditReportAttachment(int attachID) {
auditDMO.DeleteAuditReportAttachment(attachID);
@ -193,21 +173,18 @@ public class AuditController : Controller {
}
}
#if !NET8
public ActionResult GetAuditFindingsList([DataSourceRequest] DataSourceRequest request, int auditNo) {
return Json(auditDMO.GetAuditFindingsList(auditNo).ToDataSourceResult(request));
}
#endif
public ActionResult InsertAuditFindingsItem(AuditFindings data) {
if ((data.FindingType == "Major" || data.FindingType == "Minor") && data.CANo == 0) {
throw new ArgumentException("You must select add a CA for a Major or Minor finding.");
} else {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
Audit audit = auditDMO.InsertAndGetAudit(caDMO, data, userId);
return GetJsonResult(audit);
return Json(audit, JsonRequestBehavior.AllowGet);
}
}
@ -215,24 +192,25 @@ public class AuditController : Controller {
if ((data.FindingType == "Major" || data.FindingType == "Minor") && data.CANo == 0) {
throw new ArgumentException("You must select add a CA for a Major or Minor finding.");
} else {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
Audit audit = auditDMO.UpdateAndGetAudit(caDMO, data, userId);
return GetJsonResult(audit);
return Json(audit, JsonRequestBehavior.AllowGet);
}
}
public ActionResult DeleteAuditFindingsItem(int auditFindingsID) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
Audit audit = auditDMO.DeleteAndGetAudit(auditFindingsID, userId);
return GetJsonResult(audit);
return Json(audit, JsonRequestBehavior.AllowGet);
}
public void ReleaseLockOnDocument(int issueID) {
try {
auditDMO.ReleaseLockOnDocument(GlobalVars.GetUserId(GetSession()), issueID);
auditDMO.ReleaseLockOnDocument((int)Session[GlobalVars.SESSION_USERID], issueID);
} catch (Exception e) {
try {
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReleaseLockOnDocument CA\r\n" + issueID.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReleaseLockOnDocument CA\r\n" + issueID.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
} catch { }
auditDMO.ReleaseLockOnDocument(-1, issueID);
}
@ -259,8 +237,6 @@ public class AuditController : Controller {
return Content("");
}
#if !NET8
public ActionResult GetCAFindingsList([DataSourceRequest] DataSourceRequest request, int auditNo) {
return Json(auditDMO.GetCAFindingsList(auditNo).ToDataSourceResult(request));
}
@ -269,10 +245,8 @@ public class AuditController : Controller {
return Json(auditDMO.GetCAFindingsItemAttachments(caFindingsID).ToDataSourceResult(request));
}
#endif
public ActionResult GetCAFindingsItem(int caFindingsID) {
CAFindings model = new();
var model = new CAFindings();
model = auditDMO.GetCAFindingsItem(caFindingsID);
return PartialView("_CAFindingsAttachment", model);
@ -283,13 +257,11 @@ public class AuditController : Controller {
auditDMO.DeleteCAFindingsItem(caFindingsID);
}
#if !NET8
public ActionResult SaveCAFindings_Attachemnt(IEnumerable<HttpPostedFileBase> CAFindings_Attachemnt, int caFindingsID, int auditNo) {
try {
// The Name of the Upload component is "files"
if (CAFindings_Attachemnt != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in CAFindings_Attachemnt) {
AuditHelper.SaveAndInsert(_AppSettings, auditDMO, caFindingsID, auditNo, userId, file.FileName, file.InputStream);
}
@ -301,14 +273,12 @@ public class AuditController : Controller {
return Content("");
}
#endif
public void NotifyActionItemOwner(int issueID, DateTime? dueDate, int? responsibleOwnerID) {
try {
string email = auditDMO.NotifyActionItemOwner(issueID, dueDate, responsibleOwnerID, _AppSettings.EmailTemplatesPath);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 5S/CA Findings" + ":" + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 5S/CA Findings" + ":" + email });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -319,8 +289,8 @@ public class AuditController : Controller {
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 5s/CAFindings:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n 5s/CAFindings - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "5s/CAFindings Notification - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 5s/CAFindings - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "5s/CAFindings Notification - " + exceptionString });
}
}
@ -328,33 +298,4 @@ public class AuditController : Controller {
return Content(auditDMO.IsCAAssignedToAudit(caNo, auditNo).ToString());
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,50 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if !NET8
using System.Web;
using System.Web.Mvc;
using System.Web.Services;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.ViewModels;
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class ChangeControlController : Controller {
private readonly ChangeControlDMO ccDMO = new();
private readonly AppSettings? _AppSettings = GlobalVars.AppSettings;
ChangeControlDMO ccDMO = new ChangeControlDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult Index() {
return View();
}
public ActionResult Create() {
ChangeControlViewModel cc = new();
ChangeControlViewModel cc = new ChangeControlViewModel();
try {
cc.OwnerID = GlobalVars.GetUserId(GetSession());
cc.OwnerID = (int)Session[GlobalVars.SESSION_USERID];
ccDMO.InsertChangeControl(cc);
return RedirectToAction("Edit", new { issueID = cc.PlanNumber });
} catch (Exception e) {
@ -55,16 +41,16 @@ public class ChangeControlController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + cc.PlanNumber.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Create - Change Control\r\n" + cc.PlanNumber.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = cc.PlanNumber, UserID = GetUserIdentityName(), DocumentType = "Change Control", OperationType = "Error", Comments = "Create - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Create - Change Control\r\n" + cc.PlanNumber.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = cc.PlanNumber, UserID = @User.Identity.Name, DocumentType = "Change Control", OperationType = "Error", Comments = "Create - " + exceptionString });
throw new Exception(e.Message);
}
}
public ActionResult Edit(int issueID) {
string jwt = GlobalVars.GetJWT(GetSession());
string jwt = Session["JWT"].ToString();
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
string refreshToken = GlobalVars.GetRefreshToken(GetSession());
string refreshToken = Session["RefreshToken"].ToString();
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=pcrb/{issueID}";
@ -72,9 +58,9 @@ public class ChangeControlController : Controller {
}
public ActionResult ReadOnlyCC(int issueID) {
string jwt = GlobalVars.GetJWT(GetSession());
string jwt = Session["JWT"].ToString();
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
string refreshToken = GlobalVars.GetRefreshToken(GetSession());
string refreshToken = Session["RefreshToken"].ToString();
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=pcrb/{issueID}";
@ -85,7 +71,7 @@ public class ChangeControlController : Controller {
public ActionResult Edit(ChangeControlViewModel model) {
try {
var data = model;
ccDMO.UpdateChangeControl(model, GlobalVars.GetUserId(GetSession()));
ccDMO.UpdateChangeControl(model, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.AIResponsibles = ccDMO.GetActionItemResponsible();
} catch (Exception ex) {
return Content(ex.Message);
@ -107,12 +93,10 @@ public class ChangeControlController : Controller {
}
public JsonResult SearchParts(string searchText) {
List<string> partList = MiscDMO.SearchLTParts(searchText.Trim()).Select(x => x.WIPPartData).ToList();
return GetJsonResult(partList);
List<String> partList = MiscDMO.SearchLTParts(searchText.Trim()).Select(x => x.WIPPartData).ToList<String>();
return Json(partList, JsonRequestBehavior.AllowGet);
}
#if !NET8
public ActionResult GetCCAttachments([DataSourceRequest] DataSourceRequest request, int planNumber) {
return Json(ccDMO.GetCCAttachment(planNumber).ToDataSourceResult(request));
}
@ -146,7 +130,7 @@ public class ChangeControlController : Controller {
public ActionResult AttachSaveCC(IEnumerable<HttpPostedFileBase> files, int planNumber, int attachID) {
// The Name of the Upload component is "files"
if (files != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
ChangeControlHelper.AttachSaveCC(_AppSettings, ccDMO, planNumber, attachID, userId, file.FileName, file.InputStream);
}
@ -161,7 +145,6 @@ public class ChangeControlController : Controller {
public ActionResult GetMeetingAttachments([DataSourceRequest] DataSourceRequest request, int meetingID) {
return Json(ccDMO.GetMeetingAttachments(meetingID).ToDataSourceResult(request));
}
public ActionResult GetPCRB([DataSourceRequest] DataSourceRequest request, int PlanNumber, string PCRB) {
return Json(ccDMO.GetPCRB(PlanNumber, PCRB).ToDataSourceResult(request));
}
@ -194,7 +177,7 @@ public class ChangeControlController : Controller {
public ActionResult AttachSaveMeeting(IEnumerable<HttpPostedFileBase> files, int planNumber, int meetingID, int attachID) {
// The Name of the Upload component is "files"
if (files != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
ChangeControlHelper.AttachSaveMeeting(_AppSettings, ccDMO, planNumber, attachID, userId, file.FileName, file.InputStream);
}
@ -202,8 +185,6 @@ public class ChangeControlController : Controller {
return Content("");
}
#endif
public FileResult DownloadCCFile(string fileGuid, int planNumber) {
string fileName = ccDMO.GetCCFileName(fileGuid);
@ -238,20 +219,20 @@ public class ChangeControlController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + planNumber.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Create - Meeting\r\n" + planNumber.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = planNumber, UserID = GetUserIdentityName(), DocumentType = "Meeting", OperationType = "Error", Comments = "Create - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Create - Meeting\r\n" + planNumber.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = planNumber, UserID = @User.Identity.Name, DocumentType = "Meeting", OperationType = "Error", Comments = "Create - " + exceptionString });
throw new Exception("Error: " + e.Message);
}
}
public ActionResult EditMeeting(int meetingID) {
int isITARCompliant = 1;
CCMeeting meeting = new();
meeting = ccDMO.GetMeetingRead(meetingID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
CCMeeting meeting = new CCMeeting();
meeting = ccDMO.GetMeetingRead(meetingID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.MeetingList = ccDMO.GetMeetingList(meeting.PlanNumber);
// TODO locked functionality
List<ApproversListViewModel> userList = MiscDMO.GetApproversListByDocument(meeting.PlanNumber, meeting.CurrentStep, (int)GlobalVars.DocumentType.ChangeControl);
ApproversListViewModel appUser = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == GlobalVars.GetUserId(GetSession()); });
ApproversListViewModel appUser = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (appUser != null) {
ViewBag.IsApprover = "true";
}
@ -260,7 +241,7 @@ public class ChangeControlController : Controller {
{
return View("UnAuthorizedAccess");
} else {
if ((meeting.RecordLockIndicator && meeting.RecordLockedBy != GlobalVars.GetUserId(GetSession()))
if ((meeting.RecordLockIndicator && meeting.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID])
|| (meeting.PCRBClosed)) {
return RedirectToAction("ReadOnlyMeeting", new { meetingID = meetingID });
} else if (meeting.Decision != -1) {
@ -270,7 +251,7 @@ public class ChangeControlController : Controller {
ViewBag.Attendees = ccDMO.GetUsers();
ViewBag.Sites = ccDMO.GetSites();
ViewBag.PCRValues = ccDMO.GetPCRValues();
meeting = ccDMO.GetMeeting(meetingID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
meeting = ccDMO.GetMeeting(meetingID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
return View(meeting);
}
@ -279,8 +260,8 @@ public class ChangeControlController : Controller {
public ActionResult ReadOnlyMeeting(int meetingID) {
int isITARCompliant = 1;
CCMeeting meeting = new();
meeting = ccDMO.GetMeetingRead(meetingID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
CCMeeting meeting = new CCMeeting();
meeting = ccDMO.GetMeetingRead(meetingID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.MeetingList = ccDMO.GetMeetingList(meeting.PlanNumber);
ViewBag.PCRValues = ccDMO.GetPCRValues();
@ -305,13 +286,13 @@ public class ChangeControlController : Controller {
public ActionResult EditMeetingUpdate(int meetingID) {
int isITARCompliant = 1;
CCMeeting meeting = new();
meeting = ccDMO.GetMeetingRead(meetingID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
CCMeeting meeting = new CCMeeting();
meeting = ccDMO.GetMeetingRead(meetingID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.MeetingList = ccDMO.GetMeetingList(meeting.PlanNumber);
ViewBag.PCRValues = ccDMO.GetPCRValues();
// TODO locked functionality
List<ApproversListViewModel> userList = MiscDMO.GetApproversListByDocument(meeting.PlanNumber, meeting.CurrentStep, (int)GlobalVars.DocumentType.ChangeControl);
ApproversListViewModel appUser = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == GlobalVars.GetUserId(GetSession()); });
ApproversListViewModel appUser = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (appUser != null) {
ViewBag.IsApprover = "true";
}
@ -320,11 +301,11 @@ public class ChangeControlController : Controller {
{
return View("UnAuthorizedAccess");
} else {
if ((meeting.RecordLockIndicator && meeting.RecordLockedBy != GlobalVars.GetUserId(GetSession()))
if ((meeting.RecordLockIndicator && meeting.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID])
|| (meeting.PCRBClosed)) {
return RedirectToAction("ReadOnlyMeeting", new { meetingID = meetingID });
} else {
meeting = ccDMO.GetMeeting(meetingID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
meeting = ccDMO.GetMeeting(meetingID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.AIResponsibles = ccDMO.GetActionItemResponsible();
@ -355,14 +336,10 @@ public class ChangeControlController : Controller {
return File(sDocument, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
#if !NET8
public ActionResult GetDecisionsSummaryList([DataSourceRequest] DataSourceRequest request, int meetingID) {
return Json(ccDMO.GetDecisionsSummaryList(meetingID).ToDataSourceResult(request));
}
#endif
public ActionResult UpdateMeetingDecisionNotes(CCDecisionSummary model) {
try {
ccDMO.UpdateDecisionSummary(model);
@ -372,8 +349,6 @@ public class ChangeControlController : Controller {
return Content("Saved Succesfully");
}
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteDecisionsSummary([DataSourceRequest] DataSourceRequest request, CCDecisionSummary model) {
if (model != null && ModelState.IsValid) {
@ -382,8 +357,6 @@ public class ChangeControlController : Controller {
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
#endif
public ActionResult InsertDecisionsSummary(CCDecisionSummary model) {
try {
ccDMO.InsertDecisionSummary(model);
@ -402,23 +375,19 @@ public class ChangeControlController : Controller {
return Content("Saved Succesfully", "application/json");
}
#if !NET8
public ActionResult GetMeetingList([DataSourceRequest] DataSourceRequest request, int planNumber) {
var meetingList = ccDMO.GetMeetingList(planNumber);
return Json(meetingList.ToDataSourceResult(request));
}
///
public ActionResult GetMeetingAttendees([DataSourceRequest] DataSourceRequest request, int meetingID) {
return Json(ccDMO.GetMeetingAttendees(meetingID).ToDataSourceResult(request));
}
public ActionResult GetPCRBAttendees([DataSourceRequest] DataSourceRequest request, int PCRBID) {
return Json(ccDMO.GetPCRBAttendees(PCRBID).ToDataSourceResult(request));
}
#endif
public void InsertNewMeetingAttendee(string attendeeName, string jobTitle, string siteName) {
try {
} catch (Exception e) {
@ -443,8 +412,8 @@ public class ChangeControlController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + docid.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n UpdateMeetingAttendee - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = GetUserIdentityName(), DocumentType = "Change Control", OperationType = "Error", Comments = "UpdateMeetingAttendee - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n UpdateMeetingAttendee - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = @User.Identity.Name, DocumentType = "Change Control", OperationType = "Error", Comments = "UpdateMeetingAttendee - " + exceptionString });
throw new Exception(e.Message);
}
}
@ -463,14 +432,12 @@ public class ChangeControlController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + docid.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n UpdateMeetingAttendee - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = GetUserIdentityName(), DocumentType = "Change Control", OperationType = "Error", Comments = "UpdateMeetingAttendee - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n UpdateMeetingAttendee - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = @User.Identity.Name, DocumentType = "Change Control", OperationType = "Error", Comments = "UpdateMeetingAttendee - " + exceptionString });
throw new Exception(e.Message);
}
}
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteMeetingAttendee([DataSourceRequest] DataSourceRequest request, CCMeetingAttendee model) {
if (model != null && ModelState.IsValid) {
@ -508,8 +475,6 @@ public class ChangeControlController : Controller {
return Json(ccDMO.GetMeetingActionItems_All(planNumber).ToDataSourceResult(request));
}
#endif
public ActionResult InsertPCRBActionItem(CCPCRBActionItem model) {
try {
if (model != null) {
@ -536,8 +501,6 @@ public class ChangeControlController : Controller {
return Content("1");
}
#if !NET8
public ActionResult InsertPCRBAttendee([DataSourceRequest] DataSourceRequest request, int pcrId, int attendeeId, string jobTitle, string siteName) {
CCPCRBAttendee newAttendee = new CCPCRBAttendee();
newAttendee.AttendeeID = attendeeId;
@ -554,8 +517,6 @@ public class ChangeControlController : Controller {
return Content("1");
}
#endif
public ActionResult UpdatePCRBActionItem(CCPCRBActionItem model) {
try {
if (model != null) {
@ -568,12 +529,10 @@ public class ChangeControlController : Controller {
return Content("1");
}
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateMeetingActionItemAll([DataSourceRequest] DataSourceRequest request, CCMeetingActionItemAll model) {
if (model != null && ModelState.IsValid) {
model.ClosedBy = GlobalVars.GetUserId(GetSession());
model.ClosedBy = (int)Session[GlobalVars.SESSION_USERID];
ccDMO.UpdateMeetingActionItem_All(model);
}
if (model.ClosedStatus)
@ -584,8 +543,6 @@ public class ChangeControlController : Controller {
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
#endif
public ActionResult UpdateMeetingActionItem(CCMeetingActionItem model) {
try {
if (model != null) {
@ -600,11 +557,11 @@ public class ChangeControlController : Controller {
[HttpPost]
public ActionResult ReassignMeetingActionItemResponsiblePersons(int meetingActionItemId, string newResponsiblePersonIDs, string comments) {
if (GlobalVars.IsAdminValueNull(GetSession()))
if (Session[GlobalVars.IS_ADMIN] == null)
throw new Exception("Permission denied");
try {
ccDMO.ReassignMeetingActionItemResponsiblePersons(meetingActionItemId, newResponsiblePersonIDs, comments, GlobalVars.GetUserId(GetSession()));
ccDMO.ReassignMeetingActionItemResponsiblePersons(meetingActionItemId, newResponsiblePersonIDs, comments, (int)Session[GlobalVars.SESSION_USERID]);
} catch (Exception ex) {
return Content(ex.Message.ToString());
}
@ -612,8 +569,6 @@ public class ChangeControlController : Controller {
return Content("1");
}
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteMeetingActionItem([DataSourceRequest] DataSourceRequest request, CCMeetingActionItem model) {
if (model != null && ModelState.IsValid) {
@ -629,8 +584,6 @@ public class ChangeControlController : Controller {
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
#endif
public void CompleteCC(int planNumber) {
int docid = planNumber;
try {
@ -643,8 +596,8 @@ public class ChangeControlController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + docid.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n CompleteCC - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = GetUserIdentityName(), DocumentType = "Change Control", OperationType = "Error", Comments = "CompleteCC - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n CompleteCC - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = @User.Identity.Name, DocumentType = "Change Control", OperationType = "Error", Comments = "CompleteCC - " + exceptionString });
throw new Exception(e.Message);
}
}
@ -661,18 +614,16 @@ public class ChangeControlController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + docid.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n CompleteCC - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = GetUserIdentityName(), DocumentType = "Change Control", OperationType = "Error", Comments = "CancelCC - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n CompleteCC - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = @User.Identity.Name, DocumentType = "Change Control", OperationType = "Error", Comments = "CancelCC - " + exceptionString });
throw new Exception(e.Message);
}
}
#if !NET8
public ActionResult AttachSaveActionItem(IEnumerable<HttpPostedFileBase> AIfiles, int planNumber, int attachID) {
// The Name of the Upload component is "files"
if (AIfiles != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in AIfiles) {
ChangeControlHelper.AttachSaveActionItem(_AppSettings, ccDMO, planNumber, attachID, userId, file.FileName, file.InputStream);
}
@ -680,8 +631,6 @@ public class ChangeControlController : Controller {
return Content("");
}
#endif
public FileResult DownloadActionItemFile(string fileGuid, int planNumber) {
string fileName = ccDMO.GetActionItemFileName(fileGuid);
@ -709,36 +658,36 @@ public class ChangeControlController : Controller {
}
public void ReleaseLockOnDocument(int planNumber) {
ccDMO.ReleaseLockOnDocument(GlobalVars.GetUserId(GetSession()), planNumber);
ccDMO.ReleaseLockOnDocument((int)Session[GlobalVars.SESSION_USERID], planNumber);
try {
ccDMO.ReleaseLockOnDocument(GlobalVars.GetUserId(GetSession()), planNumber);
ccDMO.ReleaseLockOnDocument((int)Session[GlobalVars.SESSION_USERID], planNumber);
} catch (Exception e) {
try {
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReleaseLockOnDocument LD\r\n" + planNumber.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReleaseLockOnDocument LD\r\n" + planNumber.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
} catch { }
ccDMO.ReleaseLockOnDocument(-1, planNumber);
}
}
public JsonResult GetAllUsersList() {
UserAccountDMO userDMO = new();
UserAccountDMO userDMO = new UserAccountDMO();
IEnumerable<LoginModel> userlist = userDMO.GetAllUsers();
return GetJsonResult(userlist);
return Json(userlist, JsonRequestBehavior.AllowGet);
}
[HttpPost]
public void ReAssignOwnerByAdmin(string planNumber, string comments, int newOwnerId) {
if (GlobalVars.IsAdminValueNull(GetSession()))
if (Session[GlobalVars.IS_ADMIN] == null)
throw new Exception("Permission denied");
int planNumberInt = 0;
try {
// remove non-numeric characters from Plan # then convert to int
planNumberInt = int.Parse(new string(planNumber.Where(char.IsNumber).ToArray()));
planNumberInt = Int32.Parse(new String(planNumber.Where<char>(c => char.IsNumber(c)).ToArray()));
ccDMO.ReassignOwner(planNumberInt, newOwnerId, comments, GlobalVars.GetUserId(GetSession()));
ccDMO.ReassignOwner(planNumberInt, newOwnerId, comments, (int)Session[GlobalVars.SESSION_USERID]);
} catch (Exception e) {
string detailedException = "";
try {
@ -749,46 +698,17 @@ public class ChangeControlController : Controller {
string exceptionString = e.Message.ToString().Trim();
if (exceptionString.Length > 450)
exceptionString = exceptionString.Substring(0, 450);
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReAssignOwnerByAdmin\r\n" + planNumber.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = planNumberInt, UserID = GetUserIdentityName(), DocumentType = "ChangeControl", OperationType = "Error", Comments = "ReAssignOwnerByAdmin - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReAssignOwnerByAdmin\r\n" + planNumber.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = planNumberInt, UserID = @User.Identity.Name, DocumentType = "ChangeControl", OperationType = "Error", Comments = "ReAssignOwnerByAdmin - " + exceptionString });
throw new Exception(e.Message);
}
}
public ActionResult GetPCRBMesaTitle(int issueID) {
int isItarCompliant = 1;
ChangeControlViewModel cc = ccDMO.GetChangeControlRead(issueID, out isItarCompliant, GlobalVars.GetUserId(GetSession()));
ChangeControlViewModel cc = ccDMO.GetChangeControlRead(issueID, out isItarCompliant, (int)Session[GlobalVars.SESSION_USERID]);
string content = cc.PlanTitle;
return Content(content);
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,63 +1,43 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
#if !NET8
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
#if !NET8
using Fab2ApprovalSystem.Utilities;
#endif
using Fab2ApprovalSystem.ViewModels;
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class CorrectiveActionController : Controller {
private readonly AuditDMO auditDMO = new(GlobalVars.AppSettings);
private readonly CorrectiveActionDMO caDMO = new();
private readonly WorkflowDMO wfDMO = new();
AuditDMO auditDMO = new AuditDMO(GlobalVars.AppSettings);
CorrectiveActionDMO caDMO = new CorrectiveActionDMO();
WorkflowDMO wfDMO = new WorkflowDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
private readonly UserAccountDMO userDMO = new();
#if !NET8
UserAccountDMO userDMO = new UserAccountDMO();
FileUtilities<System.Web.Mvc.FileContentResult> fileUtilities = new FileUtilities<System.Web.Mvc.FileContentResult>();
#endif
public ActionResult Index() {
return View();
}
public ActionResult Create() {
CorrectiveAction ca = new();
CorrectiveAction ca = new CorrectiveAction();
try {
// TODO: Add insert logic here
ca.RequestorID = GlobalVars.GetUserId(GetSession());
ca.RequestorID = (int)Session[GlobalVars.SESSION_USERID];
caDMO.InsertCA(ca);
return RedirectToAction("Edit", new { issueID = ca.CANo });
} catch (Exception e) {
@ -68,18 +48,18 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + ca.CANo.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n SubmitDocument - Audit\r\n" + ca.CANo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = ca.CANo, UserID = GetUserIdentityName(), DocumentType = "CA", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n SubmitDocument - Audit\r\n" + ca.CANo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = ca.CANo, UserID = @User.Identity.Name, DocumentType = "CA", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
throw new Exception(e.Message);
}
}
public ActionResult CreateFromAudit(string title) {
CorrectiveAction ca = new();
CorrectiveAction ca = new CorrectiveAction();
try {
// TODO: Add insert logic here
ca.RequestorID = GlobalVars.GetUserId(GetSession());
ca.RequestorID = (int)Session[GlobalVars.SESSION_USERID];
ca.CASource = "Audit";
caDMO.InsertCA(ca);
string test = ca.CANoDisp;
@ -92,43 +72,43 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + ca.CANo.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n SubmitDocument - Audit\r\n" + ca.CANo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = ca.CANo, UserID = GetUserIdentityName(), DocumentType = "CA", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n SubmitDocument - Audit\r\n" + ca.CANo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = ca.CANo, UserID = @User.Identity.Name, DocumentType = "CA", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
throw new Exception(e.Message);
}
}
public ActionResult Edit(int issueID) {
CorrectiveAction ca = new();
CorrectiveAction ca = new CorrectiveAction();
string s = Functions.ReturnCANoStringFormat(issueID);
try {
List<int> _8DQAList = caDMO.Get8DQA();
int QAs = _8DQAList.Find(delegate (int al) { return al == GlobalVars.GetUserId(GetSession()); });
int QAs = _8DQAList.Find(delegate (int al) { return al == (int)Session[GlobalVars.SESSION_USERID]; });
ViewBag.Is8DQA = "false";
if (QAs != 0) {
ViewBag.Is8DQA = "true";
}
ca = caDMO.GetCAItem(issueID, GlobalVars.GetUserId(GetSession()));
ca = caDMO.GetCAItem(issueID, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.CanCompleteCA = "false";
if (ca.D1AssigneeID == GlobalVars.GetUserId(GetSession()))
if (ca.D1AssigneeID == (int)Session[GlobalVars.SESSION_USERID])
ViewBag.CanCompleteCA = "true";
List<ApproversListViewModel> userList = MiscDMO.GetPendingApproversListByDocument(issueID, ca.CurrentStep, (int)GlobalVars.DocumentType.CorrectiveAction);
ApproversListViewModel approver = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == GlobalVars.GetUserId(GetSession()); });
ApproversListViewModel approver = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (approver == null)
ViewBag.IsApprover = "false";
else
ViewBag.IsApprover = "true";
ViewBag.IsAIAssignee = caDMO.IsAIAssignee(GlobalVars.GetUserId(GetSession()), issueID);
ViewBag.IsSectionApprover = caDMO.IsUserSectionApprover(ca.CANo, GlobalVars.GetUserId(GetSession()));
ViewBag.IsAIAssignee = caDMO.IsAIAssignee((int)Session[GlobalVars.SESSION_USERID], issueID);
ViewBag.IsSectionApprover = caDMO.IsUserSectionApprover(ca.CANo, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.AuditFindingCategoriesOptions = auditDMO.GetAuditFindingCategories().ToList();
if (ca.RelatedAudit > 0) {
Audit audit = auditDMO.GetAuditItem(ca.RelatedAudit, GlobalVars.GetUserId(GetSession()));
if (ca.RelatedAudit != null && ca.RelatedAudit > 0) {
Audit audit = auditDMO.GetAuditItem(ca.RelatedAudit, (int)Session[GlobalVars.SESSION_USERID]);
IEnumerable<AuditFindings> auditFindings = auditDMO.GetAuditFindingsList(audit.AuditNo);
AuditFindings relatedFinding = (from a in auditFindings where a.CANo == ca.CANo select a).First();
@ -149,7 +129,7 @@ public class CorrectiveActionController : Controller {
if ((ca.ClosedDate != null) ||
// TODO Aproverslist================================================================
(ca.ClosedDate != null && ViewBag.IsApprover == "false" && ViewBag.IsAIAssignee == "false") ||
(ca.RecordLockIndicator && ca.RecordLockedBy != GlobalVars.GetUserId(GetSession())) || (ca.Status == 11 && ViewBag.IsApprover == "false")) {
(ca.RecordLockIndicator && ca.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID]) || (ca.Status == 11 && ViewBag.IsApprover == "false")) {
return RedirectToAction("ReadOnlyCA", new { caNo = ca.CANo });
} else {
ViewBag.ECNList = caDMO.GetECNList();
@ -174,8 +154,8 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + ca.CANo.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Edit - CA\r\n" + ca.CANo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = ca.CANo, UserID = GetUserIdentityName(), DocumentType = "Audit", OperationType = "Error", Comments = "Edit - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Edit - CA\r\n" + ca.CANo.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = ca.CANo, UserID = @User.Identity.Name, DocumentType = "Audit", OperationType = "Error", Comments = "Edit - " + exceptionString });
throw new Exception(e.Message);
}
@ -184,7 +164,7 @@ public class CorrectiveActionController : Controller {
[HttpPost]
public ActionResult Edit(CorrectiveAction model) {
int currentUserId = GlobalVars.GetUserId(GetSession());
int currentUserId = (int)Session[GlobalVars.SESSION_USERID];
CorrectiveAction caPrevious = caDMO.GetCAItemReadOnly(model.CANo, currentUserId);
if ((currentUserId != caPrevious.D1AssigneeID && currentUserId != caPrevious.QAID && currentUserId != caPrevious.RequestorID)) {
return Content("User is not authorized to save the CA.");
@ -221,7 +201,7 @@ public class CorrectiveActionController : Controller {
return Content("Successfully Saved...Approval initiated!");
}
if (model.TriggerApproval) {
caDMO.StartApproval(model.CANo, GlobalVars.GetUserId(GetSession()), model.WorkFlowNumber);
caDMO.StartApproval(model.CANo, (int)Session[GlobalVars.SESSION_USERID], model.WorkFlowNumber);
NotifyApprovers(model.CANo, 1);
return Content("Successfully Saved...Approval initiated!");
}
@ -233,9 +213,9 @@ public class CorrectiveActionController : Controller {
}
public ActionResult ReadOnlyCA(int caNo) {
CorrectiveAction ca = new();
CorrectiveAction ca = new CorrectiveAction();
ca = caDMO.GetCAItemReadOnly(caNo, GlobalVars.GetUserId(GetSession()));
ca = caDMO.GetCAItemReadOnly(caNo, (int)Session[GlobalVars.SESSION_USERID]);
if (ca.Status == 1 || ca.Status == 2 || ca.Status == 11 || ca.ClosedDate != null) {
ViewBag.UserList = caDMO.GetAllUserList();
} else {
@ -247,8 +227,8 @@ public class CorrectiveActionController : Controller {
ViewBag.D5D6ImprovementIDs = caDMO.GetD5D6Improvement();
ViewBag.AuditFindingCategoriesOptions = auditDMO.GetAuditFindingCategories().ToList();
if (ca.RelatedAudit > 0) {
Audit audit = auditDMO.GetAuditItem(ca.RelatedAudit, GlobalVars.GetUserId(GetSession()));
if (ca.RelatedAudit != null && ca.RelatedAudit > 0) {
Audit audit = auditDMO.GetAuditItem(ca.RelatedAudit, (int)Session[GlobalVars.SESSION_USERID]);
IEnumerable<AuditFindings> auditFindings = auditDMO.GetAuditFindingsList(audit.AuditNo);
AuditFindings relatedFinding = (from a in auditFindings where a.CANo == ca.CANo select a).First();
@ -274,32 +254,26 @@ public class CorrectiveActionController : Controller {
caDMO.ReleaseLockOnDocument(-1, issueID);
} catch (Exception e) {
try {
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReleaseLockOnDocument CA\r\n" + issueID.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReleaseLockOnDocument CA\r\n" + issueID.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
} catch { }
caDMO.ReleaseLockOnDocument(-1, issueID);
}
}
#if !NET8
public ActionResult GetD2AttachmentList([DataSourceRequest] DataSourceRequest request, int caNo) {
return Json(caDMO.GetCAAttachmentsList(caNo, Functions.CASectionMapper(GlobalVars.CASection.D2)).ToDataSourceResult(request));
}
public ActionResult Attachment_Read([DataSourceRequest] DataSourceRequest request, int caNO) {
return GetJsonResult(caDMO.GetCAAttachmentsList(caNO, "Main").ToDataSourceResult(request));
return Json(caDMO.GetCAAttachmentsList(caNO, "Main").ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
#endif
[HttpPost]
public void DeleteCAAttachment(int attachmentID) {
caDMO.DeleteCAAttachment(attachmentID);
}
#if !NET8
public ActionResult DownloadCAAttachment(string fileGuid, int caNo) {
try {
string fileName = caDMO.GetCAAttachmentFileName(fileGuid);
@ -338,7 +312,7 @@ public class CorrectiveActionController : Controller {
try {
// The Name of the Upload component is "files"
if (files != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
CorrectiveActionHelper.AttachSave(_AppSettings, caDMO, caNo, userId, file.FileName, file.InputStream);
}
@ -354,8 +328,6 @@ public class CorrectiveActionController : Controller {
return Json(caDMO.GetD3ContainmentActions(caNo).ToDataSourceResult(request));
}
#endif
public ActionResult UpdateD3ContainmentAction(D3ContainmentAction data) {
caDMO.UpdateD3ContainmentAction(data);
if (data.ResponsibilityOwnerID != data.CurrentResponsibilityOwnerID && data.ResponsibilityOwnerID != 0) {
@ -367,7 +339,7 @@ public class CorrectiveActionController : Controller {
public ActionResult InsertD3ContainmentAction(D3ContainmentAction data) {
caDMO.InsertD3ContainmentAction(data);
if (data.ResponsibilityOwnerID != 0) {
if (data.ResponsibilityOwnerID != null && data.ResponsibilityOwnerID != 0) {
NotifyActionItemOwner(data.CANo, data.ECD, data.ResponsibilityOwnerID, "CorrectiveActionAIAssigned.txt");
}
return Content("");
@ -378,8 +350,6 @@ public class CorrectiveActionController : Controller {
caDMO.DeleteD3ContainmentActionItem(d3ContainmentActionID);
}
#if !NET8
public ActionResult GetD4AttachmentList([DataSourceRequest] DataSourceRequest request, int caNo) {
return Json(caDMO.GetCAAttachmentsList(caNo, Functions.CASectionMapper(GlobalVars.CASection.D4)).ToDataSourceResult(request));
}
@ -388,7 +358,7 @@ public class CorrectiveActionController : Controller {
try {
// The Name of the Upload component is "files"
if (D4Files != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in D4Files) {
CorrectiveActionHelper.D4FilesAttachSave(_AppSettings, caDMO, caNo, userId, file.FileName, file.InputStream);
}
@ -404,8 +374,6 @@ public class CorrectiveActionController : Controller {
return Json(caDMO.GetD5D6CorrectivetActions(caNo).ToDataSourceResult(request));
}
#endif
public ActionResult InsertD5D6CAItem(D5D6CorrectivetAction data) {
try {
caDMO.InsertD5D6CorrectivetAction(data);
@ -417,7 +385,7 @@ public class CorrectiveActionController : Controller {
public ActionResult UpdateD5D6CAItem(D5D6CorrectivetAction data) {
D5D6CorrectivetAction previousData = caDMO.GetD5D5CAItem(data.ID);
CorrectiveAction caData = caDMO.GetCAItem(data.CANo, GlobalVars.GetUserId(GetSession()));
CorrectiveAction caData = caDMO.GetCAItem(data.CANo, (int)Session[GlobalVars.SESSION_USERID]);
try {
caDMO.UpdateD5D6CorrectivetAction(data);
} catch (Exception e) {
@ -436,32 +404,26 @@ public class CorrectiveActionController : Controller {
}
public ActionResult GetD5D6CAItem(int d5d6CAID) {
D5D6CorrectivetAction model = new();
var model = new D5D6CorrectivetAction();
model = caDMO.GetD5D5CAItem(d5d6CAID);
return PartialView("_D5D6CAAttachment", model);
}
#if !NET8
public ActionResult GetD5D6ItemAttachments([DataSourceRequest] DataSourceRequest request, int d5d6CAID) {
return Json(caDMO.GetD5D6ItemAttachments(d5d6CAID).ToDataSourceResult(request));
}
#endif
[HttpPost]
public void DeleteD5D6CAItem(int d5d6CAID) {
caDMO.DeleteD5D6CorrectivetAction(d5d6CAID);
}
#if !NET8
public ActionResult SaveD5D6CA_Attachemnt(IEnumerable<HttpPostedFileBase> D5D6CA_Attachemnt, int d5d6CAID, int caNo) {
try {
// The Name of the Upload component is "files"
if (D5D6CA_Attachemnt != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in D5D6CA_Attachemnt) {
CorrectiveActionHelper.SaveD5D6CA_Attachemnt(_AppSettings, caDMO, d5d6CAID, caNo, userId, file.FileName, file.InputStream);
}
@ -473,15 +435,14 @@ public class CorrectiveActionController : Controller {
return Content("");
}
// D7 ====================================================================================
public ActionResult GetD7PreventiveActionList([DataSourceRequest] DataSourceRequest request, int caNo) {
return Json(caDMO.GetD7PreventiveActions(caNo).ToDataSourceResult(request));
}
#endif
public ActionResult InsertD7PAItem(D7PreventiveAction data) {
caDMO.InsertD7PreventiveAction(data);
if (data.ResponsibilityOwnerID != 0) {
if (data.ResponsibilityOwnerID != null && data.ResponsibilityOwnerID != 0) {
NotifyActionItemOwner(data.CANo, data.ECD, data.ResponsibilityOwnerID, "CorrectiveActionAIAssigned.txt");
}
@ -498,32 +459,26 @@ public class CorrectiveActionController : Controller {
}
public ActionResult GetD7PAItem(int d7paID) {
D7PreventiveAction model = new();
var model = new D7PreventiveAction();
model = caDMO.GetD7PAItem(d7paID);
return PartialView("_D7PAAttachment", model);
}
#if !NET8
public ActionResult GetD7ItemAttachments([DataSourceRequest] DataSourceRequest request, int d7PAID) {
return Json(caDMO.GetD7ItemAttachments(d7PAID).ToDataSourceResult(request));
}
#endif
[HttpPost]
public void DeleteD7PAItem(int d7PAID) {
caDMO.DeleteD7PreventiveActionItem(d7PAID);
}
#if !NET8
public ActionResult SaveD7PA_Attachemnt(IEnumerable<HttpPostedFileBase> D7PA_Attachemnt, int d7PAID, int caNo) {
try {
// The Name of the Upload component is "files"
if (D7PA_Attachemnt != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in D7PA_Attachemnt) {
CorrectiveActionHelper.SaveD7PA_Attachemnt(_AppSettings, caDMO, d7PAID, caNo, userId, file.FileName, file.InputStream);
}
@ -535,23 +490,21 @@ public class CorrectiveActionController : Controller {
return Content("");
}
#endif
public void ReleaseLockOnDocument(int issueID) {
try {
caDMO.ReleaseLockOnDocument(GlobalVars.GetUserId(GetSession()), issueID);
caDMO.ReleaseLockOnDocument((int)Session[GlobalVars.SESSION_USERID], issueID);
} catch (Exception e) {
try {
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReleaseLockOnDocument CA\r\n" + issueID.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReleaseLockOnDocument CA\r\n" + issueID.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
} catch { }
caDMO.ReleaseLockOnDocument(-1, issueID);
}
}
public JsonResult GetAllUsersList() {
UserAccountDMO userDMO = new();
UserAccountDMO userDMO = new UserAccountDMO();
IEnumerable<LoginModel> userlist = userDMO.GetAllUsers();
return GetJsonResult(userlist);
return Json(userlist, JsonRequestBehavior.AllowGet);
}
public void ReAssignApproverByAdmin(int issueID, int reAssignApproverFrom, int reAssignApproverTo, byte step, int docType) {
@ -566,20 +519,20 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + step + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReAssignApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "CA", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReAssignApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "CA", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
CorrectiveActionHelper.ReAssignApproverByAdmin(_AppSettings, issueID, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "ReAssign Approver: " + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
}
public void ReAssignApproval(int issueID, int userIDs, byte step) {
var email = "";
try {
email = wfDMO.ReAssignApproval(issueID, GlobalVars.GetUserId(GetSession()), userIDs, step, (int)GlobalVars.DocumentType.CorrectiveAction);
email = wfDMO.ReAssignApproval(issueID, (int)Session[GlobalVars.SESSION_USERID], userIDs, step, (int)GlobalVars.DocumentType.CorrectiveAction);
} catch (Exception e) {
string detailedException = "";
try {
@ -588,20 +541,20 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + step + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReAssignApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReAssignApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
CorrectiveActionHelper.ReAssignApproval(_AppSettings, issueID, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "ReAssign Approver: " + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
}
public void Reject(int issueID, byte currentStep, string comments) {
try {
if (GlobalVars.IsUserIdValueNotNull(GetSession())) {
wfDMO.Reject(issueID, currentStep, comments, GlobalVars.GetUserId(GetSession()), (int)GlobalVars.DocumentType.CorrectiveAction);
if (Session[GlobalVars.SESSION_USERID] != null) {
wfDMO.Reject(issueID, currentStep, comments, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.CorrectiveAction);
NotifyRejectionToAssignee(issueID, comments);
} else {
Response.Redirect("~/Account/Login");
@ -614,18 +567,18 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + currentStep + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Reject\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "Reject - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Reject\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Reject - " + exceptionString });
throw new Exception(e.Message);
}
}
public void NotifyRejectionToAssignee(int issueID, string comments) {
string username = GlobalVars.GetUserName(GetSession());
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
List<string> emailIst = caDMO.GetRejectionAssigneeEmailList(@issueID).Distinct().ToList();
string userEmail = CorrectiveActionHelper.NotifyRejectionToAssignee(_AppSettings, issueID, comments, username, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Rejection: " + userEmail });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Rejection: " + userEmail });
} catch { }
}
@ -633,9 +586,9 @@ public class CorrectiveActionController : Controller {
int isITARCompliant = 1;
try {
bool lastStep = false;
CorrectiveAction ca = caDMO.GetCAItemReadOnly(issueID, GlobalVars.GetUserId(GetSession()));
CorrectiveAction ca = caDMO.GetCAItemReadOnly(issueID, (int)Session[GlobalVars.SESSION_USERID]);
bool lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, GlobalVars.GetUserId(GetSession()), (int)GlobalVars.DocumentType.CorrectiveAction, ca.WorkFlowNumber);
bool lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.CorrectiveAction, ca.WorkFlowNumber);
if (lastApprover && !lastStep) {
// Set to complete
@ -657,8 +610,8 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + currentStep + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "Approve - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Approve - " + exceptionString });
throw new Exception(e.Message);
}
}
@ -668,7 +621,7 @@ public class CorrectiveActionController : Controller {
string userEmail = userDMO.GetUserEmailByID(userId);
CorrectiveActionHelper.NotifySectionApprover(_AppSettings, issueID, section, userEmail);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -678,9 +631,9 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw;
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw e;
}
}
@ -689,7 +642,7 @@ public class CorrectiveActionController : Controller {
List<string> emailIst = MiscDMO.GetApproverEmailListByDocument(@issueID, currentStep, (int)GlobalVars.DocumentType.CorrectiveAction).Distinct().ToList();
string emailSentList = CorrectiveActionHelper.NotifyApprovers(_AppSettings, issueID, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -699,9 +652,9 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + currentStep + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw;
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw e;
}
}
@ -720,20 +673,18 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + step + " " + " Userid:" + userIDs + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n AddAdditionalApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AddAdditionalApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw new Exception(e.Message);
}
emailSentList = CorrectiveActionHelper.AddAdditionalApproval(_AppSettings, issueID, emailSentList, emailArray);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
} catch { }
}
#endregion
#if !NET8
public ActionResult GetApproversList([DataSourceRequest] DataSourceRequest request, int issueID, byte step) {
return Json(MiscDMO.GetApproversListByDocument(issueID, step, (int)GlobalVars.DocumentType.CorrectiveAction).ToDataSourceResult(request));
}
@ -742,14 +693,12 @@ public class CorrectiveActionController : Controller {
return Json(caDMO.GetCASectionApprovalLog(caNo).ToDataSourceResult(request));
}
#endif
public void NotifyRequestor(int issueID, DateTime? dueDate, int? responsibleOwnerID, string template) {
try {
string email = MiscDMO.GetEmail(responsibleOwnerID);
CorrectiveActionHelper.NotifyRequestor(_AppSettings, issueID, dueDate, template, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -760,8 +709,8 @@ public class CorrectiveActionController : Controller {
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 8D Action Item:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
}
}
@ -770,7 +719,7 @@ public class CorrectiveActionController : Controller {
string email = MiscDMO.GetEmail(responsibleOwnerID);
CorrectiveActionHelper.NotifyAssignee(_AppSettings, issueID, template, D3DueDate, D5D7DueDate, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -781,8 +730,8 @@ public class CorrectiveActionController : Controller {
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 8D Action Item:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
}
}
@ -790,7 +739,7 @@ public class CorrectiveActionController : Controller {
try {
string email = CorrectiveActionHelper.NotifyActionItemOwner(_AppSettings, issueID, dueDate, responsibleOwnerID, template);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -801,8 +750,8 @@ public class CorrectiveActionController : Controller {
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 8D Action Item:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
}
}
@ -810,7 +759,7 @@ public class CorrectiveActionController : Controller {
try {
string email = CorrectiveActionHelper.NotifyActionItemCompletion(_AppSettings, issueID, dueDate, recipientId, template);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -821,8 +770,8 @@ public class CorrectiveActionController : Controller {
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 8D Action Item:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n 8D Action Item - NotifyActionItemCompletion\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 8D Action Item - NotifyActionItemCompletion\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
}
}
@ -830,7 +779,7 @@ public class CorrectiveActionController : Controller {
try {
string emailSentList = CorrectiveActionHelper.NotifyClosureOf8D(_AppSettings, issueID);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Closure of 8D Item" + ":" + emailSentList });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Closure of 8D Item" + ":" + emailSentList });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -841,8 +790,8 @@ public class CorrectiveActionController : Controller {
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Closure of 8D:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Closure of 8D - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "Closure of 8D Notification - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Closure of 8D - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Closure of 8D Notification - " + exceptionString });
}
}
@ -850,7 +799,7 @@ public class CorrectiveActionController : Controller {
try {
string emailSentList = CorrectiveActionHelper.NotifyCompletionOf8D(_AppSettings, issueID, followUpDate);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Closure of 8D Item" + ":" + emailSentList });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Closure of 8D Item" + ":" + emailSentList });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -861,14 +810,14 @@ public class CorrectiveActionController : Controller {
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Closure of 8D:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Closure of 8D - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "Closure of 8D Notification - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Closure of 8D - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Closure of 8D Notification - " + exceptionString });
}
}
public void StartSectionApproval(int issueID, string dSection) {
try {
CorrectiveAction ca = caDMO.GetCAItem(issueID, GlobalVars.GetUserId(GetSession()));
CorrectiveAction ca = caDMO.GetCAItem(issueID, (int)Session[GlobalVars.SESSION_USERID]);
int requestorId = ca.RequestorID;
int qaId = ca.QAID;
@ -885,16 +834,16 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "Approve - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Approve - " + exceptionString });
throw new Exception(e.Message);
}
}
[HttpPost]
public ActionResult ApproveSection(int issueID, string dSection) {
try {
int userID = GlobalVars.GetUserId(GetSession());
CorrectiveAction caItem = caDMO.GetCAItem(issueID, GlobalVars.GetUserId(GetSession()));
int userID = (int)Session[GlobalVars.SESSION_USERID];
CorrectiveAction caItem = caDMO.GetCAItem(issueID, (int)Session[GlobalVars.SESSION_USERID]);
caDMO.ApproveSection(issueID, userID, dSection);
bool isLastApprover = caDMO.IsLastSectionApprover(issueID, dSection);
if (isLastApprover) {
@ -927,8 +876,8 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "Approve - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Approve - " + exceptionString });
return Content(e.Message);
}
}
@ -936,7 +885,7 @@ public class CorrectiveActionController : Controller {
public ActionResult RejectSection(int issueID, string dSection, string comments) {
try {
int userID = GlobalVars.GetUserId(GetSession());
int userID = (int)Session[GlobalVars.SESSION_USERID];
CorrectiveAction ca = caDMO.GetCAItem(issueID, userID);
caDMO.RejectSection(issueID, userID, dSection, comments);
// Notify Rejection to assignee and requestor
@ -956,19 +905,18 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n " + "Reject\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "Reject - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n " + "Reject\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Reject - " + exceptionString });
return Content(e.Message);
}
}
public void NotifySectionRejection(int issueID, int recipientUserId, int loggedInUserId, string section, string comment) {
try {
LoginModel recipient = userDMO.GetUserByID(recipientUserId);
LoginModel loggedInUser = userDMO.GetUserByID(loggedInUserId);
CorrectiveActionHelper.NotifySectionRejection(_AppSettings, issueID, section, comment, recipient, loggedInUser);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -978,9 +926,9 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw;
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw e;
}
}
@ -989,7 +937,7 @@ public class CorrectiveActionController : Controller {
string userEmail = userDMO.GetUserEmailByID(userId);
CorrectiveActionHelper.NotifyForD5D6D7Validation(_AppSettings, issueID, dSection, userEmail);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -999,9 +947,9 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw;
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw e;
}
}
@ -1010,7 +958,7 @@ public class CorrectiveActionController : Controller {
string userEmail = userDMO.GetUserEmailByID(userId);
CorrectiveActionHelper.NotifyUsersDSectionApproved(_AppSettings, issueID, dSection, userEmail);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -1020,9 +968,9 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw;
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Corrective Action - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw e;
}
}
@ -1031,12 +979,10 @@ public class CorrectiveActionController : Controller {
return d3DueDate;
}
public DateTime SetD5D7DueDate(int caNo) {
DateTime d5d7DueDate = caDMO.SetCAD5D7DueDate(caNo);
return d5d7DueDate;
}
public bool ProcessCARDueDates() {
bool isSuccess = false;
List<CAD3D5D7Due> dueCAs = caDMO.GetCAD3D5D7Due().ToList();
@ -1060,8 +1006,8 @@ public class CorrectiveActionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + dueCA.CANo.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Corrective Action - ProcessCARDueDates\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = dueCA.CANo, UserID = GetUserIdentityName(), DocumentType = "Corrective Action", OperationType = "Error", Comments = "ProcessCARDueDates - Called via API - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Corrective Action - ProcessCARDueDates\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = dueCA.CANo, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "ProcessCARDueDates - Called via API - " + exceptionString });
}
@ -1072,33 +1018,4 @@ public class CorrectiveActionController : Controller {
public void ProcessCAForFollowUp() {
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +1,35 @@
using System;
using System.Collections.Generic;
#if !NET8
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.Utilities;
#if !NET8
using System.Configuration;
using System.Linq;
using Fab2ApprovalSystem.ViewModels;
#endif
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
namespace Fab2ApprovalSystem.Controllers;
#if !NET8
[Authorize]
#if !NET8
[SessionExpireFilter]
#endif
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
#endif
#if NET8
[Route("[controller]")]
#endif
public class HomeController : Controller {
private readonly MRB_DMO mrbDMO = new(GlobalVars.AppSettings);
private readonly PartsRequestDMO prDMO = new();
private readonly LotDispositionDMO ldDMO = new();
private readonly WorkflowDMO wfDMO = new();
private readonly ECN_DMO ecnDMO = new();
private readonly UserUtilities userDMO = new();
private readonly UserAccountDMO originalUserDMO = new();
private readonly TrainingDMO trainingDMO = new();
private readonly MiscDMO miscDMO = new();
MRB_DMO mrbDMO = new MRB_DMO(GlobalVars.AppSettings);
PartsRequestDMO prDMO = new PartsRequestDMO();
LotDispositionDMO ldDMO = new LotDispositionDMO();
WorkflowDMO wfDMO = new WorkflowDMO();
ECN_DMO ecnDMO = new ECN_DMO();
UserUtilities userDMO = new UserUtilities();
UserAccountDMO originalUserDMO = new UserAccountDMO();
TrainingDMO trainingDMO = new TrainingDMO();
MiscDMO miscDMO = new MiscDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult Index(string tabName) {
@ -75,7 +57,6 @@ public class HomeController : Controller {
public ActionResult ECNList() {
return View();
}
public ActionResult TrainingList() {
return View();
}
@ -101,25 +82,25 @@ public class HomeController : Controller {
return View();
}
#if !NET8
public ActionResult GetTaskList([DataSourceRequest] DataSourceRequest request, string tabName) {
try {
ViewBag.ActiveTabName = tabName;
List<IssuesViewModel> data = ldDMO.GetTaskList(GlobalVars.GetUserId(GetSession())).Distinct().ToList();
return GetJsonResult(data.ToDataSourceResult(request));
List<IssuesViewModel> data = ldDMO.GetTaskList((int)Session[GlobalVars.SESSION_USERID]).Distinct().ToList();
return Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
} catch (Exception ex) {
throw;
// TODO record the error
throw ex;
}
}
public ActionResult GetMyOpenActionItems([DataSourceRequest] DataSourceRequest request, string tabName) {
try {
ViewBag.ActiveTabName = tabName;
List<OpenActionItemViewModel> data = ldDMO.GetMyOpenActionItems(GlobalVars.GetUserId(GetSession())).Distinct().ToList();
return GetJsonResult(data.ToDataSourceResult(request));
List<OpenActionItemViewModel> data = ldDMO.GetMyOpenActionItems((int)Session[GlobalVars.SESSION_USERID]).Distinct().ToList();
return Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
} catch (Exception ex) {
throw;
// TODO record the error
throw ex;
}
}
@ -135,82 +116,76 @@ public class HomeController : Controller {
}
public ActionResult GetChangeControlList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<ChangeControlList> data = ldDMO.GetChangeControls(GlobalVars.GetUserId(GetSession()));
IEnumerable<ChangeControlList> data = ldDMO.GetChangeControls(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()));
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetAuditList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<AuditList> data = ldDMO.GetAuditList(GlobalVars.GetUserId(GetSession()));
IEnumerable<AuditList> data = ldDMO.GetAuditList(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()));
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetCorrectiveActionList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<CorrectiveAction> data = ldDMO.GetCorrectiveActionList(GlobalVars.GetUserId(GetSession()));
IEnumerable<CorrectiveAction> data = ldDMO.GetCorrectiveActionList(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()));
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetMRBList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<IssuesViewModel> data = ldDMO.GetMRBList(GlobalVars.GetUserId(GetSession()));
IEnumerable<IssuesViewModel> data = ldDMO.GetMRBList(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()));
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetLotDispositionList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<IssuesViewModel> data = ldDMO.GetLotDispositionList(GlobalVars.GetUserId(GetSession()));
IEnumerable<IssuesViewModel> data = ldDMO.GetLotDispositionList(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()));
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetECNList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<IssuesViewModel> data = ldDMO.GetECNList(GlobalVars.GetUserId(GetSession()));
IEnumerable<IssuesViewModel> data = ldDMO.GetECNList(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()));
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetTrainingList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<Training> data = trainingDMO.GetAllTrainings();
return Json(data.ToDataSourceResult(request));
}
#endif
public ActionResult MyECNsTECNs(string dataType) {
ViewBag.ActiveTabName = dataType;
return View();
}
#if !NET8
public ActionResult GetECN_TECNsPendingApproval([DataSourceRequest] DataSourceRequest request) {
IEnumerable<IssuesViewModel> data = ecnDMO.GetECN_TECNPendingApprovals(GlobalVars.GetUserId(GetSession()));
IEnumerable<IssuesViewModel> data = ecnDMO.GetECN_TECNPendingApprovals(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()));
ViewBag.ViewOption = "Pending Approvals";
GlobalVars.SetECNViewOption(GetSession(), ViewBag.ViewOption);
Session[GlobalVars.ECN_VIEW_OPTION] = ViewBag.ViewOption;
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetMyExpiredTECNs([DataSourceRequest] DataSourceRequest request) {
IEnumerable<IssuesViewModel> data = ecnDMO.GetMyExpiredTECNs(GlobalVars.GetUserId(GetSession()), 7);
IEnumerable<IssuesViewModel> data = ecnDMO.GetMyExpiredTECNs(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()), 7);
ViewBag.ViewOption = "Expired TECNs";
GlobalVars.SetECNViewOption(GetSession(), ViewBag.ViewOption);
Session[GlobalVars.ECN_VIEW_OPTION] = ViewBag.ViewOption;
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetAllTECNs([DataSourceRequest] DataSourceRequest request) {
IEnumerable<IssuesViewModel> data = ecnDMO.GetAllTECNs();
ViewBag.ViewOption = "All TECNs";
GlobalVars.SetECNViewOption(GetSession(), ViewBag.ViewOption);
Session[GlobalVars.ECN_VIEW_OPTION] = ViewBag.ViewOption;
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetMyConvertedTECNsToECNs([DataSourceRequest] DataSourceRequest request) {
IEnumerable<IssuesViewModel> data = ecnDMO.GetMyConvertedTECNsToECNs(GlobalVars.GetUserId(GetSession()), 7);
IEnumerable<IssuesViewModel> data = ecnDMO.GetMyConvertedTECNsToECNs(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()), 7);
ViewBag.ViewOption = "Converted TECNs";
GlobalVars.SetECNViewOption(GetSession(), ViewBag.ViewOption);
Session[GlobalVars.ECN_VIEW_OPTION] = ViewBag.ViewOption;
return Json(data.ToDataSourceResult(request));
}
public ActionResult GetMyExpiringTECNs([DataSourceRequest] DataSourceRequest request) {
IEnumerable<IssuesViewModel> data = ecnDMO.GetMyExpiringTECNs(GlobalVars.GetUserId(GetSession()), 7);
IEnumerable<IssuesViewModel> data = ecnDMO.GetMyExpiringTECNs(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()), 7);
ViewBag.ViewOption = "Expiring TECNs";
GlobalVars.SetECNViewOption(GetSession(), ViewBag.ViewOption);
Session[GlobalVars.ECN_VIEW_OPTION] = ViewBag.ViewOption;
return Json(data.ToDataSourceResult(request));
}
@ -219,17 +194,17 @@ public class HomeController : Controller {
return Json(LotTravDMO.GetLotListBasedOnSWRNumber(workRequestID).ToDataSourceResult(request));
}
#endif
/// <returns></returns>
public ActionResult SetOOOStatus(int delegatedTo, DateTime startDate, DateTime endDate, string tab) {
if (GlobalVars.IsUserIdValueNotNull(GetSession())) {
int returnValue = MiscDMO.EnableOOOStatus(GlobalVars.GetUserId(GetSession()), delegatedTo, startDate, endDate);
if (Session[GlobalVars.SESSION_USERID] != null) {
int returnValue = MiscDMO.EnableOOOStatus(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()), delegatedTo, startDate, endDate);
if (returnValue == 3) // the delegator is already a delegator to someone else
{
return Content("3");
}
if (startDate <= DateTime.Today)
GlobalVars.SetOOO(GetSession(), true);
Session[GlobalVars.OOO] = true;
NotifyDelegation(delegatedTo, startDate, endDate);
}
@ -238,14 +213,12 @@ public class HomeController : Controller {
}
public void ExpireOOOStatus(string tab) {
if (GlobalVars.IsUserIdValueNotNull(GetSession())) {
MiscDMO.ExpireOOOStatus(GlobalVars.GetUserId(GetSession()));
GlobalVars.SetOOO(GetSession(), false);
if (Session[GlobalVars.SESSION_USERID] != null) {
MiscDMO.ExpireOOOStatus(int.Parse(Session[GlobalVars.SESSION_USERID].ToString()));
Session[GlobalVars.OOO] = false;
}
}
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteItem([DataSourceRequest] DataSourceRequest request, IssuesViewModel issue) {
GlobalVars.DocumentType dType;
@ -255,22 +228,20 @@ public class HomeController : Controller {
else if (dType == GlobalVars.DocumentType.LotDisposition)
ldDMO.DeleteLotDisposition(issue.IssueID);
else if (dType == GlobalVars.DocumentType.ECN)
ecnDMO.DeleteDocument(issue.IssueID, GlobalVars.GetUserId(GetSession()), "ECN");
ecnDMO.DeleteDocument(issue.IssueID, int.Parse(Session[GlobalVars.SESSION_USERID].ToString()), "ECN");
else if (dType == GlobalVars.DocumentType.CorrectiveAction)
ldDMO.DeleteCADocument(issue.IssueID, GlobalVars.GetUserId(GetSession()), "Corrective Action");
ldDMO.DeleteCADocument(issue.IssueID, int.Parse(Session[GlobalVars.SESSION_USERID].ToString()), "Corrective Action");
return Json(new[] { issue }.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteCAItem([DataSourceRequest] DataSourceRequest request, CorrectiveAction ca) {
ldDMO.DeleteCADocument(ca.CANo, GlobalVars.GetUserId(GetSession()), "Corrective Action");
ldDMO.DeleteCADocument(ca.CANo, int.Parse(Session[GlobalVars.SESSION_USERID].ToString()), "Corrective Action");
return Json(new[] { ca }.ToDataSourceResult(request, ModelState));
}
#endif
public ActionResult About() {
ViewBag.Message = "Your application description page.";
@ -312,63 +283,61 @@ public class HomeController : Controller {
public void DelegateDocumentApproval(int issueID, int delegateTo, string ecnTypeString, string title) {
var email = "";
int delegateFrom = GlobalVars.GetUserId(GetSession());
int delegateFrom = (int)Session[GlobalVars.SESSION_USERID];
try {
email = wfDMO.DelegateDocumentApproval(issueID, delegateFrom, delegateTo);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = ecnTypeString, OperationType = "Delegation", Comments = "Delegated from - " + delegateFrom + " to " + delegateTo });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Delegation", Comments = "Delegated from - " + delegateFrom + " to " + delegateTo });
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n DelegateApproval\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = " + ecnTypeString + ", OperationType = "Error", Comments = "DelegateApproval - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n DelegateApproval\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = " + ecnTypeString + ", OperationType = "Error", Comments = "DelegateApproval - " + exceptionString });
throw new Exception(e.Message);
}
HomeHelper.DelegateDocumentApproval(_AppSettings, issueID, ecnTypeString, title, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = ecnTypeString, OperationType = "Email", Comments = "Delegated to Approver: " + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Delegated to Approver: " + email });
} catch { }
}
public JsonResult GetAllUsersList() {
UserAccountDMO userDMO = new();
UserAccountDMO userDMO = new UserAccountDMO();
IEnumerable<LoginModel> userlist = userDMO.GetAllUsers();
return GetJsonResult(userlist);
return Json(userlist, JsonRequestBehavior.AllowGet);
}
public ActionResult SaveAllDocumentsFilter(string data) {
GlobalVars.SetAllDocumentsFilterData(GetSession(), data);
Session["AllDocumentsFilterData"] = data;
return new EmptyResult();
}
public ActionResult LoadAllDocumentsFilter() {
return GetJsonResult(GlobalVars.GetAllDocumentsFilterData(GetSession()));
return Json(Session["AllDocumentsFilterData"], JsonRequestBehavior.AllowGet);
}
public ActionResult SaveSWRFilter(string data) {
GlobalVars.SetSWRFilterData(GetSession(), data);
Session["SWRFilterData"] = data;
return new EmptyResult();
}
public ActionResult LoadSWRFilter() {
return GetJsonResult(GlobalVars.GetSWRFilterData(GetSession()));
return Json(Session["SWRFilterData"], JsonRequestBehavior.AllowGet);
}
public ActionResult SavePCRBFilter(string data) {
GlobalVars.SetPCRBFilterData(GetSession(), data);
Session["PCRBFilterData"] = data;
return new EmptyResult();
}
public ActionResult LoadPCRBFilter() {
return GetJsonResult(GlobalVars.GetPCRBFilterData(GetSession()));
return Json(Session["PCRBFilterData"], JsonRequestBehavior.AllowGet);
}
public ActionResult PartsRequestList() {
ViewBag.CanDeletePR = GlobalVars.GetCanCreatePartsRequest(GetSession());
ViewBag.CanDeletePR = Session[GlobalVars.CAN_CREATE_PARTS_REQUEST];
return View();
}
#if !NET8
public ActionResult GetPartsRequestList([DataSourceRequest] DataSourceRequest request) {
IEnumerable<PartsRequestList> data = prDMO.GetPartsRequestList();
return Json(data.ToDataSourceResult(request));
@ -377,32 +346,31 @@ public class HomeController : Controller {
public ActionResult GetMyPartsRequestsList([DataSourceRequest] DataSourceRequest request, string tabName) {
try {
ViewBag.ActiveTabName = tabName;
var data = prDMO.GetMyPartsRequests(GlobalVars.GetUserId(GetSession()));
return GetJsonResult(data.ToDataSourceResult(request));
var data = prDMO.GetMyPartsRequests((int)Session[GlobalVars.SESSION_USERID]);
return Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
} catch (Exception ex) {
throw;
// TODO record the error
throw ex;
}
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeletePR([DataSourceRequest] DataSourceRequest request, MyPartsRequestList pr) {
try {
if (!GlobalVars.GetCanCreatePartsRequest(GetSession()))
if (Convert.ToBoolean(Session[GlobalVars.CAN_CREATE_PARTS_REQUEST]) == false)
throw new Exception("Permission denied");
prDMO.DeleteDocument(pr.PRNumber, GlobalVars.GetUserId(GetSession()));
prDMO.DeleteDocument(pr.PRNumber, (int)Session[GlobalVars.SESSION_USERID]);
return Json(new[] { pr }.ToDataSourceResult(request, ModelState));
} catch (Exception ex) {
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, ex.Message);
}
}
#endif
public void NotifyDelegation(int delegatedUser, DateTime startDate, DateTime endDate) {
LoginModel delegateFrom = originalUserDMO.GetUserByID(GlobalVars.GetUserId(GetSession()));
LoginModel delegateFrom = originalUserDMO.GetUserByID((int)Session[GlobalVars.SESSION_USERID]);
LoginModel delegateTo = originalUserDMO.GetUserByID(delegatedUser);
List<string> emailList = new();
List<string> emailList = new List<string>();
emailList.Add(delegateFrom.Email);
emailList.Add(delegateTo.Email);
HomeHelper.NotifyDelegation(_AppSettings, startDate, endDate, delegateFrom, delegateTo, emailList);
@ -413,24 +381,22 @@ public class HomeController : Controller {
public bool ProcessOoO() {
try {
UserAccountDMO userDMO = new();
UserAccountDMO userDMO = new UserAccountDMO();
userDMO.ProcessOoO();
return true;
} catch {
return false;
}
}
public bool ExpireOoO() {
try {
UserAccountDMO userDMO = new();
UserAccountDMO userDMO = new UserAccountDMO();
userDMO.ExpireOoO();
return true;
} catch {
return false;
}
}
public bool ApprovalsReminderNotifications() {
try {
// Get list of approvals
@ -451,13 +417,12 @@ public class HomeController : Controller {
return false;
}
}
public void NotifyApprover(string toEmail, string title, int issueId, string docType) {
try {
HomeHelper.NotifyApprover(_AppSettings, toEmail, title, issueId, docType);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = GetUserIdentityName(), DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = @User.Identity.Name, DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
} catch { }
} catch (Exception e) {
@ -467,38 +432,9 @@ public class HomeController : Controller {
} catch {
detailedException = e.Message;
}
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = GetUserIdentityName(), DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
throw;
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = @User.Identity.Name, DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
throw e;
}
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,57 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
#if !NET8
using System.Runtime.Serialization;
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.ViewModels;
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
#if !NET8
using System.Collections;
using System.Configuration;
using System.Runtime.Serialization;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class LotDispositionController : Controller {
private readonly LotDispositionDMO ldDMO = new();
private readonly WorkflowDMO wfDMO = new();
private readonly AppSettings? _AppSettings = GlobalVars.AppSettings;
LotDispositionDMO ldDMO = new LotDispositionDMO();
WorkflowDMO wfDMO = new WorkflowDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: /LotDisposition/Create
public ActionResult Create() {
LotDisposition lotDispo = new();
LotDisposition lotDispo = new LotDisposition();
try {
// insert a records to get the issueID
lotDispo.OriginatorID = GlobalVars.GetUserId(GetSession());
lotDispo.OriginatorID = (int)Session[GlobalVars.SESSION_USERID];
ldDMO.InsertLotDisposition(lotDispo);
return RedirectToAction("Edit", new { issueID = lotDispo.IssueID.ToString() });
} catch (Exception e) {
@ -62,16 +44,16 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\nCreat Lot Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = lotDispo.IssueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\nCreat Lot Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = lotDispo.IssueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
return View("Error");
}
}
public JsonResult AddLot(Lot lot) {
Lot l = lot;
MRB_DMO mrbDMO = new(_AppSettings);
IssueWithExistingLotsViewModel issueWEL = new();
MRB_DMO mrbDMO = new MRB_DMO(_AppSettings);
IssueWithExistingLotsViewModel issueWEL = new IssueWithExistingLotsViewModel();
try {
lot.LotStatusOption.LotStatusOptionID = l.LotStatusOptionID;
@ -85,22 +67,22 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "IssueID=" + lot.IssueID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Add Lot Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = l.IssueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Add Lot Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = l.IssueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
throw new Exception(e.Message);
}
return GetJsonResult(l);
return Json(l, JsonRequestBehavior.AllowGet);
}
public JsonResult AddLots(string lotNumbers, int issueID) {
MRB_DMO mrbDMO = new(_AppSettings);
MRB_DMO mrbDMO = new MRB_DMO(_AppSettings);
bool existingLotUpdated;
IssueWithExistingLotsViewModel issueWEL = new();
IssueWithExistingLotsViewModel issueWEL = new IssueWithExistingLotsViewModel();
try {
if (lotNumbers.Length > 0) {
string[] tempLots = lotNumbers.Split(new char[] { '~' });
foreach (string lotNumber in tempLots) {
Lot l = new();
Lot l = new Lot();
l.LotNumber = lotNumber;
l.IssueID = issueID;
l.LotStatusOption.LotStatusOptionID = (int)GlobalVars.LotStatusOption.NotAvailable;
@ -122,19 +104,20 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "IssueID=" + issueID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n AddLots Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AddLots Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
throw new Exception(e.Message);
}
return GetJsonResult(issueWEL);
return Json(issueWEL, JsonRequestBehavior.AllowGet);
}
// GET: /LotDisposition/Edit/5
public ActionResult Edit(int issueID) {
int isITARCompliant = 1;
try {
LotDisposition lotDispo = new();
lotDispo = ldDMO.GetLotDispositionItemForRead(issueID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
LotDisposition lotDispo = new LotDisposition();
lotDispo = ldDMO.GetLotDispositionItemForRead(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
if (isITARCompliant == 0) // not ITAR Compliant
{
@ -145,20 +128,20 @@ public class LotDispositionController : Controller {
}
if (lotDispo.CurrentStep == 1) {
List<ApproversListViewModel> userList = MiscDMO.GetPendingApproversListByDocument(issueID, lotDispo.CurrentStep, (int)GlobalVars.DocumentType.LotDisposition);
ApproversListViewModel approver = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == GlobalVars.GetUserId(GetSession()); });
ApproversListViewModel approver = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (approver == null)
ViewBag.IsApprover = "false";
else
ViewBag.IsApprover = "true";
if (approver == null && (!GlobalVars.IsAdmin(GetSession())) && GlobalVars.GetUserId(GetSession()) != lotDispo.OriginatorID) {
if (approver == null && (!(bool)Session[GlobalVars.IS_ADMIN]) && (int)Session[GlobalVars.SESSION_USERID] != lotDispo.OriginatorID) {
return RedirectToAction("ReadOnly", new { issueID = issueID });
} else {
if ((ViewBag.IsApprover == "true" || GlobalVars.IsAdmin(GetSession()))
|| GlobalVars.GetUserId(GetSession()) == lotDispo.OriginatorID) {
lotDispo = ldDMO.GetLotDispositionItem(issueID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
if ((ViewBag.IsApprover == "true" || (bool)Session[GlobalVars.IS_ADMIN])
|| (int)Session[GlobalVars.SESSION_USERID] == lotDispo.OriginatorID) {
lotDispo = ldDMO.GetLotDispositionItem(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
if (lotDispo.RecordLockIndicator && lotDispo.RecordLockedBy == GlobalVars.GetUserId(GetSession())) {
if (lotDispo.RecordLockIndicator && lotDispo.RecordLockedBy == (int)Session[GlobalVars.SESSION_USERID]) {
PopulateLotStatusOptions();
ViewBag.OriginatorList = ldDMO.GetUserList();
ViewBag.deps = ldDMO.GetDepartments();
@ -176,7 +159,7 @@ public class LotDispositionController : Controller {
} else if (lotDispo.CurrentStep > 1) {
List<ApproversListViewModel> userList = MiscDMO.GetPendingApproversListByDocument(issueID, lotDispo.CurrentStep, (int)GlobalVars.DocumentType.LotDisposition);
ApproversListViewModel approver = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == GlobalVars.GetUserId(GetSession()); });
ApproversListViewModel approver = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (approver == null) {
ViewBag.IsApprover = "false";
@ -185,12 +168,12 @@ public class LotDispositionController : Controller {
}
if (approver == null && (!GlobalVars.IsAdmin(GetSession())) && GlobalVars.GetUserId(GetSession()) != lotDispo.OriginatorID) {
if (approver == null && (!(bool)Session[GlobalVars.IS_ADMIN]) && (int)Session[GlobalVars.SESSION_USERID] != lotDispo.OriginatorID) {
return RedirectToAction("ReadOnly", new { issueID = issueID });
} else {
if ((ViewBag.IsApprover == "true" || GlobalVars.IsAdmin(GetSession()))
|| GlobalVars.GetUserId(GetSession()) == lotDispo.OriginatorID) {
if ((ViewBag.IsApprover == "true" || (bool)Session[GlobalVars.IS_ADMIN])
|| (int)Session[GlobalVars.SESSION_USERID] == lotDispo.OriginatorID) {
return RedirectToAction("EditStep", new { issueID = issueID });
} else {
@ -202,10 +185,10 @@ public class LotDispositionController : Controller {
} else {
// TODO
// Check the recordlock indicator
if ((lotDispo.RecordLockIndicator && lotDispo.RecordLockedBy != GlobalVars.GetUserId(GetSession())) || (ViewBag.IsApprover == "false")) {
if ((lotDispo.RecordLockIndicator && lotDispo.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID]) || (ViewBag.IsApprover == "false")) {
return RedirectToAction("ReadOnly", new { issueID = issueID });
} else {
lotDispo = ldDMO.GetLotDispositionItem(issueID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
lotDispo = ldDMO.GetLotDispositionItem(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
PopulateLotStatusOptions();
ViewBag.OriginatorList = ldDMO.GetUserList();
ViewBag.deps = ldDMO.GetDepartments();
@ -224,8 +207,8 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\nEdit Lot Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\nEdit Lot Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
return View("Error");
}
}
@ -244,8 +227,8 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "IssueID=" + lotDispo.IssueID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n UpdatEdit Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = lotDispo.IssueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n UpdatEdit Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = lotDispo.IssueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
throw new Exception(e.Message);
}
}
@ -253,8 +236,8 @@ public class LotDispositionController : Controller {
public ActionResult ReadOnly(int issueID) {
int isITARCompliant = 1;
try {
LotDisposition lotDispo = new();
lotDispo = ldDMO.GetLotDispositionItemForRead(issueID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
LotDisposition lotDispo = new LotDisposition();
lotDispo = ldDMO.GetLotDispositionItemForRead(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
PopulateLotStatusOptions();
ViewBag.OriginatorList = ldDMO.GetUserList();
@ -271,8 +254,8 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "IssueID=" + issueID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReadOnly Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReadOnly Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
throw new Exception(e.Message);
}
}
@ -281,10 +264,10 @@ public class LotDispositionController : Controller {
int isITARCompliant = 1;
try {
LotDisposition lotDispo = new();
lotDispo = ldDMO.GetLotDispositionItemForRead(issueID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
LotDisposition lotDispo = new LotDisposition();
lotDispo = ldDMO.GetLotDispositionItemForRead(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
List<ApproversListViewModel> userList = MiscDMO.GetPendingApproversListByDocument(issueID, lotDispo.CurrentStep, (int)GlobalVars.DocumentType.LotDisposition);
ApproversListViewModel appUser = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == GlobalVars.GetUserId(GetSession()); });
ApproversListViewModel appUser = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (appUser == null)
ViewBag.IsApprover = "false";
else
@ -292,10 +275,10 @@ public class LotDispositionController : Controller {
// Check the recordlock indicator
if ((ViewBag.IsApprover == "true" || GlobalVars.IsAdmin(GetSession()))) {
lotDispo = ldDMO.GetLotDispositionItem(issueID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
if ((ViewBag.IsApprover == "true" || (bool)Session[GlobalVars.IS_ADMIN])) {
lotDispo = ldDMO.GetLotDispositionItem(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
if (lotDispo.RecordLockIndicator && lotDispo.RecordLockedBy == GlobalVars.GetUserId(GetSession())) {
if (lotDispo.RecordLockIndicator && lotDispo.RecordLockedBy == (int)Session[GlobalVars.SESSION_USERID]) {
PopulateLotStatusOptions();
ViewBag.OriginatorList = ldDMO.GetUserList();
ViewBag.deps = ldDMO.GetDepartments();
@ -318,8 +301,8 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "IssueID=" + issueID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n EditStep Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n EditStep Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
throw new Exception(e.Message);
}
}
@ -332,32 +315,30 @@ public class LotDispositionController : Controller {
public JsonResult GetResponsibilityIssue(int responsibilityID) {
List<ResponsibilityIssue> respIssue = ldDMO.GetResponsibilityIssueList(responsibilityID);
var data = respIssue.Select(s => new SelectListItem() { Value = s.ResponsibilityIssueID.ToString(), Text = s.Issue });
return GetJsonResult(data);
var data = respIssue.Select(s => new SelectListItem { Value = s.ResponsibilityIssueID.ToString(), Text = s.Issue });
return Json(data, JsonRequestBehavior.AllowGet);
}
#if !NET8
public JsonResult GetDepartments([DataSourceRequest] DataSourceRequest request) {
var departments = ldDMO.GetDepartments();
return GetJsonResult(departments);
return Json(departments, JsonRequestBehavior.AllowGet);
}
#endif
public void PopulateLotStatusOptions() {
var lotStatusOptions = ldDMO.GetLotStatusOptions();
ViewData["LotStatusOptions"] = lotStatusOptions;
}
#if !NET8
public ActionResult EditingCustom_Read([DataSourceRequest] DataSourceRequest request, int issueID) {
return Json(ldDMO.GetLotDispositionLots(issueID).ToDataSourceResult(request));
}
/// <summary>
/// Updates the lot tables
/// </summary>
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingCustom_Update([DataSourceRequest] DataSourceRequest request, Lot lot) {
if (lot != null && ModelState.IsValid) {
ldDMO.UpdateLotDispoLot(lot);
}
@ -366,6 +347,10 @@ public class LotDispositionController : Controller {
return Json(new[] { lot }.ToDataSourceResult(request, ModelState));
}
/// <summary>
/// Deletes record from the lot table
/// </summary>
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingCustom_Destroy([DataSourceRequest] DataSourceRequest request, Lot lot) {
try {
@ -381,6 +366,8 @@ public class LotDispositionController : Controller {
return Json(new[] { lot }.ToDataSourceResult(request, ModelState));
}
// REGION ATTACHMENT
public ActionResult Attachment_Read([DataSourceRequest] DataSourceRequest request, int issueID) {
return Json(ldDMO.GetLotDispoAttachments(issueID).ToDataSourceResult(request));
}
@ -398,8 +385,6 @@ public class LotDispositionController : Controller {
return Json(new[] { attachment }.ToDataSourceResult(request, ModelState));
}
#endif
[HttpPost]
public void DeleteAttachment(int attachmentID, string fileName) {
try {
@ -407,7 +392,7 @@ public class LotDispositionController : Controller {
ldDMO.DeleteLotDispoAttachment(attachmentID);
var physicalPath = System.IO.Path.Combine(_AppSettings.AttachmentFolder + "LotDisposition", fileName);
System.IO.FileInfo f = new(physicalPath);
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@ -421,23 +406,21 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "AttachmentID=" + attachmentID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n AttachmentID Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = 999, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "AttachmentID Disposition " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AttachmentID Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = 999, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "AttachmentID Disposition " + exceptionString });
throw new Exception(e.Message);
}
}
public JsonResult GetLotDispoAttachments(int issueID) {
var model = ldDMO.GetLotDispoAttachments(issueID);
return GetJsonResult(model);
return Json(model, JsonRequestBehavior.AllowGet);
}
#if !NET8
public ActionResult AttachSave(IEnumerable<HttpPostedFileBase> files, int issueID) {
// The Name of the Upload component is "files"
if (files != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
LotDispositionHelper.AttachSave(_AppSettings, ldDMO, issueID, userId, file.FileName, file.InputStream);
}
@ -446,11 +429,10 @@ public class LotDispositionController : Controller {
return Content("");
}
#endif
public JsonResult SearchLots(string searchText, string searchBy) {
List<string> lotlist = MiscDMO.SearchLots(searchText, searchBy).Select(x => x.LotNumber).ToList();
return GetJsonResult(lotlist);
List<String> lotlist = MiscDMO.SearchLots(searchText, searchBy).Select(x => x.LotNumber).ToList<String>();
return Json(lotlist, JsonRequestBehavior.AllowGet);
}
public void DeleteAllLots(int issueID) {
@ -458,12 +440,10 @@ public class LotDispositionController : Controller {
ldDMO.DeleteAllLotDispoLot(issueID);
}
#if !NET8
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
#endif
public ActionResult LotStatusDetail(int issueID, string lotNumber, bool readonlyView, string lotLocation = "") {
ViewBag.LotLocation = lotLocation;
ScrapLot model = new();
var model = new ScrapLot();
var data = ldDMO.GetLotStausDetail(issueID, lotNumber);
if (data != null)
model = data;
@ -490,8 +470,7 @@ public class LotDispositionController : Controller {
try {
foreach (PropertyInfo pi in sl.GetType().GetProperties()) {
if (pi.Name.ToLower().StartsWith("lot") && pi.Name.ToLower().EndsWith("state")) {
object? check = pi.GetValue(sl, null);
byte currentValue = check is null ? (byte)0 : (byte)check;
byte currentValue = (byte)pi.GetValue(sl, null);
if (currentValue == (int)GlobalVars.LotStatusOption.Release || currentValue == (int)GlobalVars.LotStatusOption.CloseToQDB) {
releaseCount++;
// required to update the lot status option
@ -519,8 +498,8 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + sl.IssueID.ToString() + " LotNo:" + sl.LotNo.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Scrap Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = sl.IssueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "UpdateLotScrapReleaseStatus - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Scrap Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = sl.IssueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "UpdateLotScrapReleaseStatus - " + exceptionString });
throw new Exception(e.Message);
}
}
@ -529,7 +508,7 @@ public class LotDispositionController : Controller {
/// Update the all the lots to "RELEASE" Status for a given Lot disposition document
/// </summary>
public void ReleaseAll(int issueID) {
ScrapLot sl = new();
ScrapLot sl = new ScrapLot();
try {
sl.IssueID = issueID;
foreach (PropertyInfo pi in sl.GetType().GetProperties()) {
@ -547,8 +526,8 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + sl.IssueID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Release All Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = sl.IssueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ReleaseAll - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Release All Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = sl.IssueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ReleaseAll - " + exceptionString });
throw new Exception(e.Message);
}
}
@ -557,7 +536,7 @@ public class LotDispositionController : Controller {
/// Update the all the lots to "SCRAP" Status for a given Lot disposition document
/// </summary>
public void ScrapAll(int issueID) {
ScrapLot sl = new();
ScrapLot sl = new ScrapLot();
try {
sl.IssueID = issueID;
foreach (PropertyInfo pi in sl.GetType().GetProperties()) {
@ -575,20 +554,20 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + sl.IssueID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Scrap All Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = sl.IssueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ScrapAll - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Scrap All Disposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = sl.IssueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ScrapAll - " + exceptionString });
throw new Exception(e.Message);
}
}
public JsonResult GetLotDispositionLotSummary(int issueID) {
return GetJsonResult(ldDMO.GetLotDispositionLotSummary(issueID));
return Json(ldDMO.GetLotDispositionLotSummary(issueID), JsonRequestBehavior.AllowGet);
}
///
public ActionResult SubmitDocument(int issueID, bool peRequired, bool mrbRequired) {
try {
int appoverCount = ldDMO.SubmitDocument(issueID, peRequired, mrbRequired, GlobalVars.GetUserId(GetSession()));
int appoverCount = ldDMO.SubmitDocument(issueID, peRequired, mrbRequired, (int)Session[GlobalVars.SESSION_USERID]);
if (appoverCount > 0)
NotifyApprovers(issueID, (byte)GlobalVars.WorkFLowStepNumber.Step1);
else {
@ -597,11 +576,10 @@ public class LotDispositionController : Controller {
}
if (IsAjaxRequest()) {
if (Request.IsAjaxRequest()) {
return Content("Redirect");
} else {
} else
return Content("Invalid");
}
} catch (Exception e) {
string detailedException = "";
try {
@ -610,11 +588,11 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n SubmitDocument\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n SubmitDocument\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
return GetJsonResult(new { result = "Error", issueID = issueID, detail = e.Message });
return Json(new { result = "Error", issueID = issueID, detail = e.Message }, JsonRequestBehavior.AllowGet);
}
}
@ -622,13 +600,13 @@ public class LotDispositionController : Controller {
int isITARCompliant = 1;
try {
bool lastStep = false;
LotDisposition ltDispo = ldDMO.GetLotDispositionItemForRead(issueID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
LotDisposition ltDispo = ldDMO.GetLotDispositionItemForRead(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
bool lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, GlobalVars.GetUserId(GetSession()), (int)GlobalVars.DocumentType.LotDisposition, ltDispo.WorkFlowNumber);
bool lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.LotDisposition, ltDispo.WorkFlowNumber);
while (lastApprover && !lastStep) {
currentStep++;
lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, GlobalVars.GetUserId(GetSession()), (int)GlobalVars.DocumentType.LotDisposition, ltDispo.WorkFlowNumber);
lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.LotDisposition, ltDispo.WorkFlowNumber);
NotifyApprovers(issueID, currentStep);
}
} catch (Exception e) {
@ -639,16 +617,16 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + currentStep + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "Approve - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "Approve - " + exceptionString });
throw new Exception(e.Message);
}
}
public void Reject(int issueID, byte currentStep, string comments) {
try {
if (GlobalVars.IsUserIdValueNotNull(GetSession())) {
wfDMO.Reject(issueID, currentStep, comments, GlobalVars.GetUserId(GetSession()), (int)GlobalVars.DocumentType.LotDisposition);
if (Session[GlobalVars.SESSION_USERID] != null) {
wfDMO.Reject(issueID, currentStep, comments, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.LotDisposition);
NotifyRejectionToOrginator(issueID);
} else {
@ -662,30 +640,29 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + currentStep + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Reject\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "Reject - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Reject\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "Reject - " + exceptionString });
throw new Exception(e.Message);
}
}
#if !NET8
/// <summary>
/// Get a list of Approvers and the status
/// </summary>
public ActionResult GetApproversList([DataSourceRequest] DataSourceRequest request, int issueID, byte step) {
return Json(MiscDMO.GetApproversListByDocument(issueID, step, (int)GlobalVars.DocumentType.LotDisposition).ToDataSourceResult(request));
}
#endif
public JsonResult GetAllUsersList() {
UserAccountDMO userDMO = new();
UserAccountDMO userDMO = new UserAccountDMO();
IEnumerable<LoginModel> userlist = userDMO.GetAllUsers();
return GetJsonResult(userlist);
return Json(userlist, JsonRequestBehavior.AllowGet);
}
public void ReAssignApproval(int issueID, int userIDs, byte step) {
var email = "";
try {
email = wfDMO.ReAssignApproval(issueID, GlobalVars.GetUserId(GetSession()), userIDs, step, (int)GlobalVars.DocumentType.LotDisposition);
email = wfDMO.ReAssignApproval(issueID, (int)Session[GlobalVars.SESSION_USERID], userIDs, step, (int)GlobalVars.DocumentType.LotDisposition);
} catch (Exception e) {
string detailedException = "";
try {
@ -694,13 +671,13 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + step + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReAssignApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReAssignApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
LotDispositionHelper.ReAssignApproval(_AppSettings, issueID, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Email", Comments = "ReAssign Approver: " + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
}
@ -716,22 +693,22 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + step + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReAssignApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReAssignApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
LotDispositionHelper.ReAssignApproverByAdmin(_AppSettings, issueID, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Email", Comments = "ReAssign Approver: " + email });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
}
#region Additional Approvers
public JsonResult GetUserListForAdditionalAppprrovers() {
UserAccountDMO userDMO = new();
UserAccountDMO userDMO = new UserAccountDMO();
IEnumerable<LoginModel> userlist = userDMO.GetAllUsers();
return GetJsonResult(userlist);
return Json(userlist, JsonRequestBehavior.AllowGet);
}
public void AddAdditionalApproval(int issueID, byte step, string userIDs) {
@ -747,13 +724,13 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + step + " " + " Userid:" + userIDs + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n AddAdditionalApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AddAdditionalApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw new Exception(e.Message);
}
emailSentList = LotDispositionHelper.AddAdditionalApproval(_AppSettings, issueID, emailSentList, emailArray);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
} catch { }
}
@ -764,7 +741,7 @@ public class LotDispositionController : Controller {
List<string> emailIst = MiscDMO.GetApproverEmailListByDocument(@issueID, currentStep, (int)GlobalVars.DocumentType.LotDisposition).Distinct().ToList();
string emailSentList = LotDispositionHelper.NotifyApprovers(_AppSettings, issueID, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
} catch (Exception e) {
string detailedException = "";
@ -774,19 +751,19 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + currentStep + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Lot Dispo - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw;
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Lot Dispo - NotifyApprovers\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw e;
}
}
public void NotifyRejectionToOrginator(int issueID) {
string username = GlobalVars.GetUserName(GetSession());
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
List<string> emailIst = ldDMO.GetRejectionOrginatorEmailList(@issueID).Distinct().ToList();
string userEmail = LotDispositionHelper.NotifyRejectionToOrginator(_AppSettings, issueID, username, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Rejection: " + userEmail });
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Rejection: " + userEmail });
} catch { }
}
@ -801,23 +778,19 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n UpdateReasonForDisposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "UpdateReasonForDisposition - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n UpdateReasonForDisposition\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "UpdateReasonForDisposition - " + exceptionString });
throw new Exception(e.Message);
}
}
#if !NET8
public ActionResult GetComments([DataSourceRequest] DataSourceRequest request, int issueID) {
return Json(ldDMO.GetComments(issueID).ToDataSourceResult(request));
}
#endif
public void InsertComments(int issueID, string Comments) {
try {
ldDMO.InsertComments(issueID, Comments, GlobalVars.GetUserId(GetSession()));
ldDMO.InsertComments(issueID, Comments, (int)Session[GlobalVars.SESSION_USERID]);
} catch (Exception e) {
string detailedException = "";
try {
@ -826,19 +799,17 @@ public class LotDispositionController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n UpdateCopmments\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "UpdateCopmments - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n UpdateCopmments\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "UpdateCopmments - " + exceptionString });
throw new Exception(e.Message);
}
}
#if !NET8
public ActionResult ExcelLotOpen(IEnumerable<HttpPostedFileBase> Lotfile, int issueID) {
MRB_DMO mrbDMO = new MRB_DMO(_AppSettings);
var physicalPath = "";
try {
string userIdentityName = GetUserIdentityName();
string userIdentityName = @User.Identity.Name;
foreach (var file in Lotfile) {
physicalPath = LotDispositionHelper.ExcelLotOpen(ldDMO, issueID, userIdentityName, _AppSettings.LotTempPipeLine, file.FileName, file.InputStream);
}
@ -853,14 +824,12 @@ public class LotDispositionController : Controller {
}
}
#endif
public void ReleaseLockOnDocument(int issueID) {
try {
ldDMO.ReleaseLockOnDocument(GlobalVars.GetUserId(GetSession()), issueID);
ldDMO.ReleaseLockOnDocument((int)Session[GlobalVars.SESSION_USERID], issueID);
} catch (Exception e) {
try {
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n ReleaseLockOnDocument LD\r\n" + issueID.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReleaseLockOnDocument LD\r\n" + issueID.ToString() + "\r\n" + e.Message, System.Diagnostics.EventLogEntryType.Error);
} catch { }
ldDMO.ReleaseLockOnDocument(-1, issueID);
}
@ -888,34 +857,4 @@ public class LotDispositionController : Controller {
return File(sDocument, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +1,33 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Text;
#if !NET8
using System.Threading;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.ViewModels;
#if !NET8
using System.Dynamic;
using System.Threading;
using System.Configuration;
#endif
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class MRBController : Controller {
private readonly MRB_DMO mrbDMO = new(GlobalVars.AppSettings);
private readonly WorkflowDMO wfDMO = new();
private readonly CredentialsStorage credentialsStorage = new();
MRB_DMO mrbDMO = new MRB_DMO(GlobalVars.AppSettings);
WorkflowDMO wfDMO = new WorkflowDMO();
CredentialsStorage credentialsStorage = new CredentialsStorage();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: /MRB/
@ -59,27 +42,25 @@ public class MRBController : Controller {
// GET: /MRB/Create
public ActionResult Create() {
MRB mrb = new();
MRB_DMO mrbDMO = new(_AppSettings);
mrb.OriginatorID = GlobalVars.GetUserId(GetSession());
MRB mrb = new MRB();
MRB_DMO mrbDMO = new MRB_DMO(_AppSettings);
mrb.OriginatorID = (int)Session[GlobalVars.SESSION_USERID];
mrbDMO.InsertMRB(mrb);
// Automatically Submit the Document as soon as an MRB is created
try {
PopulateCloseToQDB();
mrbDMO.SubmitDocument(mrb.MRBNumber, GlobalVars.GetUserId(GetSession()));
mrbDMO.SubmitDocument(mrb.MRBNumber, (int)Session[GlobalVars.SESSION_USERID]);
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + mrb.MRBNumber.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n SubmitDocument - MRB\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = mrb.MRBNumber, UserID = GetUserIdentityName(), DocumentType = "MRB", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n SubmitDocument - MRB\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = mrb.MRBNumber, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Error", Comments = "SubmitDocument - " + exceptionString });
throw new Exception(e.Message);
}
return RedirectToAction("Edit", new { IssueID = mrb.MRBNumber });
}
#if !NET8
// POST: /MRB/Create
[HttpPost]
public ActionResult Create(FormCollection collection) {
@ -92,13 +73,11 @@ public class MRBController : Controller {
}
}
#endif
// GET: /MRB/Edit/5
public ActionResult Edit(int issueID) {
string jwt = GlobalVars.GetJWT(GetSession());
string jwt = Session["JWT"].ToString();
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
string refreshToken = GlobalVars.GetRefreshToken(GetSession());
string refreshToken = Session["RefreshToken"].ToString();
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=mrb/{issueID}";
@ -112,16 +91,16 @@ public class MRBController : Controller {
mrbDMO.UpdateMRB(mrb);
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "IssueID=" + mrb.MRBNumber.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n UpdateEdit MRB\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = mrb.MRBNumber, UserID = GetUserIdentityName(), DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n UpdateEdit MRB\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = mrb.MRBNumber, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
throw new Exception(e.Message);
}
}
public ActionResult ReadOnly(int issueID) {
string jwt = GlobalVars.GetJWT(GetSession());
string jwt = Session["JWT"].ToString();
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
string refreshToken = GlobalVars.GetRefreshToken(GetSession());
string refreshToken = Session["RefreshToken"].ToString();
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=mrb/{issueID}";
@ -133,8 +112,6 @@ public class MRBController : Controller {
return View();
}
#if !NET8
// POST: /MRB/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection) {
@ -147,31 +124,23 @@ public class MRBController : Controller {
}
}
#endif
public JsonResult SearchLots(string searchText, string searchBy) {
List<string> lotlist = MiscDMO.SearchLots(searchText, searchBy).Select(x => x.LotNumber).ToList();
return GetJsonResult(lotlist);
List<String> lotlist = MiscDMO.SearchLots(searchText, searchBy).Select(x => x.LotNumber).ToList<String>();
return Json(lotlist, JsonRequestBehavior.AllowGet);
}
#if !NET8
public ActionResult GetMRBLots([DataSourceRequest] DataSourceRequest request, int mrbNumber) {
return Json(mrbDMO.GetMRBLots(mrbNumber).ToDataSourceResult(request));
}
#endif
[HttpGet]
public ActionResult GetTools() {
return GetJsonResult(mrbDMO.GetTools());
return Json(mrbDMO.GetTools(), JsonRequestBehavior.AllowGet);
}
/// <summary>
/// Updates the lot tables
/// </summary>
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateMRBLot([DataSourceRequest] DataSourceRequest request, Lot lot) {
if (lot != null && ModelState.IsValid) {
@ -199,8 +168,6 @@ public class MRBController : Controller {
return Json(new[] { lot }.ToDataSourceResult(request, ModelState));
}
#endif
public void DeleteAllMRBLots(int issueID) {
// trap the error on then client side
mrbDMO.DeleteAllMRBLot(issueID);
@ -216,24 +183,24 @@ public class MRBController : Controller {
mrbDMO.InsertLot(lot, false, out existingRowUpdated);
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "IssueID=" + lot.IssueID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Add Lot Disposition\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = l.IssueID, UserID = GetUserIdentityName(), DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Add Lot Disposition\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = l.IssueID, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
throw new Exception(e.Message);
}
return GetJsonResult(l);
return Json(l, JsonRequestBehavior.AllowGet);
}
public ActionResult AddLots(string lotNumbers, int mrbNumber) {
// This is for adding lot(s) via search
try {
StringBuilder warnings = new();
var warnings = new StringBuilder();
if (lotNumbers.Length > 0) {
string[] tempLots = lotNumbers.Split(new char[] { '~' });
foreach (string lotNumber in tempLots) {
bool existingRowUpdated;
Lot l = new();
Lot l = new Lot();
l.LotNumber = lotNumber;
l.MRBNumber = mrbNumber;
mrbDMO.InsertLot(l, true, out existingRowUpdated);
@ -243,8 +210,8 @@ public class MRBController : Controller {
return Content(warnings.ToString());
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRBNumber=" + mrbNumber.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n AddLots MRB\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { UserID = GetUserIdentityName(), OperationType = "Error", DocumentType = "MRB", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AddLots MRB\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { UserID = @User.Identity.Name, OperationType = "Error", DocumentType = "MRB", Comments = exceptionString });
Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
return Content(e.Message);
@ -253,14 +220,10 @@ public class MRBController : Controller {
#region ATTACHMENT
#if !NET8
public ActionResult Attachment_Read([DataSourceRequest] DataSourceRequest request, int mrbNumber) {
return Json(mrbDMO.GetMRBAttachments(mrbNumber).ToDataSourceResult(request));
}
#endif
[HttpPost]
public void DeleteAttachment(int attachmentID) {
try {
@ -270,16 +233,16 @@ public class MRBController : Controller {
if (attachment == null)
return;
string fileName = attachment.Path;
if (string.IsNullOrEmpty(fileName))
String fileName = attachment.Path;
if (String.IsNullOrEmpty(fileName))
fileName = attachment.FileName;
mrbDMO.DeleteMRBAttachment(attachmentID);
if (!string.IsNullOrWhiteSpace(fileName)) {
if (!String.IsNullOrWhiteSpace(fileName)) {
var physicalPath = System.IO.Path.Combine(_AppSettings.AttachmentFolder + "MRB", fileName);
System.IO.FileInfo f = new(physicalPath);
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@ -287,20 +250,18 @@ public class MRBController : Controller {
}
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "AttachmentID=" + attachmentID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n AttachmentID MRB\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = 999, UserID = GetUserIdentityName(), DocumentType = "MRB", OperationType = "Error", Comments = "AttachmentID Disposition " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AttachmentID MRB\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = 999, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Error", Comments = "AttachmentID Disposition " + exceptionString });
throw new Exception(e.Message);
}
}
#if !NET8
public ActionResult AttachSave(IEnumerable<HttpPostedFileBase> files, int mrbNumber) {
var errorList = new List<String>();
// The Name of the Upload component is "files"
if (files != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
MRBHelper.AttachSave(_AppSettings, mrbDMO, mrbNumber, userId, file.FileName, file.InputStream);
}
@ -308,17 +269,13 @@ public class MRBController : Controller {
return Json(new { errors = errorList });
}
#endif
#endregion
#if !NET8
public ActionResult ExcelLotOpen(IEnumerable<HttpPostedFileBase> Lotfile, int mrbNumber) {
var warnings = new StringBuilder();
var physicalPath = "";
try {
string userIdentityName = GetUserIdentityName();
string userIdentityName = @User.Identity.Name;
var dispos = mrbDMO.GetDispositions(mrbNumber);
foreach (var file in Lotfile) {
physicalPath = MRBHelper.ExcelLotOpen(mrbDMO, mrbNumber, warnings, dispos, userIdentityName, _AppSettings.LotTempPipeLine, file.FileName, file.InputStream);
@ -333,8 +290,8 @@ public class MRBController : Controller {
detailedException = e.Message;
}
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "IssueID=" + mrbNumber.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n MRB Excel\r\n" + detailedException, EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = mrbNumber, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n MRB Excel\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = mrbNumber, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
@ -350,7 +307,7 @@ public class MRBController : Controller {
try {
string message;
string c = Server.MapPath("/FTPBatch/");
string userIdentityName = GetUserIdentityName();
string userIdentityName = @User.Identity.Name;
string b = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName);
string a = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName_Test);
foreach (var file in AddQDBFlag) {
@ -375,7 +332,7 @@ public class MRBController : Controller {
try {
string message;
string c = Server.MapPath("/FTPBatch/");
string userIdentityName = GetUserIdentityName();
string userIdentityName = @User.Identity.Name;
string b = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName);
string a = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName_Test);
foreach (var file in RemoveQDBFlag) {
@ -395,19 +352,11 @@ public class MRBController : Controller {
}
}
#if !NET8
public ActionResult GetContainmentActions([DataSourceRequest] DataSourceRequest request, int mrbNumber) {
return Json(mrbDMO.GetContainmentActions(mrbNumber).ToDataSourceResult(request));
}
#endif
#endif
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
#endif
public ActionResult UpdateContainmentAction(ContainmentActionObj model) {
if (model != null && ModelState.IsValid) {
mrbDMO.UpdateContainmentAction(model);
@ -416,9 +365,7 @@ public class MRBController : Controller {
return Content("");
}
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
#endif
public ActionResult InsertContainmentAction(ContainmentActionObj model) {
if (model != null && ModelState.IsValid) {
mrbDMO.InsertContainmentAction(model);
@ -427,8 +374,6 @@ public class MRBController : Controller {
return Content("");
}
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteContainmentAction([DataSourceRequest] DataSourceRequest request, ContainmentActionObj model) {
if (model != null && ModelState.IsValid) {
@ -438,25 +383,19 @@ public class MRBController : Controller {
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
#endif
#region
#if !NET8
public ActionResult GetDispostions([DataSourceRequest] DataSourceRequest request, int mrbNumber) {
return Json(mrbDMO.GetDispositions(mrbNumber).ToDataSourceResult(request));
}
#endif
#if !NET8
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateDisposition(Disposition model) {
if (model != null && ModelState.IsValid) {
mrbDMO.UpdateDisposition(model);
}
return GetJsonResult(model);
return Json(model, JsonRequestBehavior.AllowGet);
}
[AcceptVerbs(HttpVerbs.Post)]
@ -472,15 +411,13 @@ public class MRBController : Controller {
mrbDMO.DeleteDisposition(model);
}
return GetJsonResult(model);
return Json(model, JsonRequestBehavior.AllowGet);
}
#endif
#endregion
public void PopulateCloseToQDB() {
List<CloseToQDBOptionViewModel> options = new();
List<CloseToQDBOptionViewModel> options = new List<CloseToQDBOptionViewModel>();
options.Add(new CloseToQDBOptionViewModel { CloseToQDBOptionID = 0, CloseToQDBOption = "No" });
options.Add(new CloseToQDBOptionViewModel { CloseToQDBOptionID = 1, CloseToQDBOption = "Yes" });
ViewData["CloseToQDBOptions"] = options;
@ -491,28 +428,28 @@ public class MRBController : Controller {
List<string> emailIst = MiscDMO.GetApproverEmailListByDocument(mrbNumber, currentStep, (int)GlobalVars.DocumentType.MRB).Distinct().ToList();
string emailSentList = MRBHelper.NotifyApprovers(_AppSettings, mrbNumber, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = mrbNumber, UserID = GetUserIdentityName(), DocumentType = "MRB", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
EventLogDMO.Add(new WinEventLog() { IssueID = mrbNumber, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
}
public void Approve(int issueID, byte currentStep, string comments) {
int isITARCompliant = 1;
MRB mrb = new();
mrb = mrbDMO.GetMRBItem(issueID, out isITARCompliant, GlobalVars.GetUserId(GetSession()));
MRB mrb = new MRB();
mrb = mrbDMO.GetMRBItem(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
try {
bool lastStep = false;
bool lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, GlobalVars.GetUserId(GetSession()), (int)GlobalVars.DocumentType.MRB, mrb.WorkFlowNumber);
bool lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.MRB, mrb.WorkFlowNumber);
while (lastApprover && !lastStep) {
currentStep++;
lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, GlobalVars.GetUserId(GetSession()), (int)GlobalVars.DocumentType.MRB, mrb.WorkFlowNumber);
lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.MRB, mrb.WorkFlowNumber);
NotifyApprovers(issueID, currentStep);
}
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Step:" + currentStep + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = GetUserIdentityName(), DocumentType = "Lot Disposition", OperationType = "Error", Comments = "Approve - " + exceptionString });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Approve\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "Approve - " + exceptionString });
throw new Exception(e.Message);
}
}
@ -530,11 +467,9 @@ public class MRBController : Controller {
int waferCount = 0;
int dieCount = 0;
mrbDMO.GetLotWaferDieCount(mrbNumber, out lotCount, out waferCount, out dieCount);
return GetJsonResult(lotCount.ToString() + "~" + waferCount.ToString() + "~" + dieCount);
return Json(lotCount.ToString() + "~" + waferCount.ToString() + "~" + dieCount, JsonRequestBehavior.AllowGet);
}
#if !NET8
public ActionResult SendMRBHoldFlagToSPN(int mrbNumber) {
MRB mrbInfo;
try {
@ -545,7 +480,7 @@ public class MRBController : Controller {
}
if (!mrbInfo.ToolCSV.ToUpper().Equals("NA")) {
Lot l = new();
Lot l = new Lot();
var mrbLotInfo = mrbDMO.GetLotsToFindNewChildLots(mrbNumber);
foreach (Lot lot in mrbLotInfo) {
@ -558,10 +493,10 @@ public class MRBController : Controller {
// SEND DATA to SPN
StringBuilder output = new();
StringBuilder output = new StringBuilder();
try {
string c = Server.MapPath("/FTPBatch/");
string userIdentityName = GetUserIdentityName();
string userIdentityName = @User.Identity.Name;
string b = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName);
string a = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName_Test);
IEnumerable<string> data = mrbDMO.GetMRBHoldLots(mrbNumber);
@ -591,33 +526,33 @@ public class MRBController : Controller {
}
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + mrbNumber.ToString() + " FTPToSPN(): SendMRBHoldFlagToSPN(mrbNumber) - FTP Upload Error " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = GetUserIdentityName(), DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return GetJsonResult(new { Error = true, Message = e.Message });
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return Json(new { Error = true, Message = e.Message }, JsonRequestBehavior.AllowGet);
}
}
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + mrbNumber.ToString() + " SendMRBHoldFlagToSPN(mrbNumber) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = GetUserIdentityName(), DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return GetJsonResult(new { Error = true, Message = e.Message });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Approve\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return Json(new { Error = true, Message = e.Message }, JsonRequestBehavior.AllowGet);
;
}
return GetJsonResult(new { Error = false, Message = "Success" });
return Json(new { Error = false, Message = "Success" }, JsonRequestBehavior.AllowGet);
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "GUID =" + mrbNumber.ToString() + " SendMRBHoldFlagToSPN(mrbNumber) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = GetUserIdentityName(), DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return GetJsonResult(new { Error = true, Message = e.Message });
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Approve\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return Json(new { Error = true, Message = e.Message }, JsonRequestBehavior.AllowGet);
}
}
public bool BatchFTP_Old(string sourceFile, string destFile) {
System.IO.FileInfo sourcefile = new(sourceFile);
System.IO.FileInfo sourcefile = new System.IO.FileInfo(sourceFile);
try {
ProcessStartInfo psiFab1 = new();
ProcessStartInfo psiFab1 = new ProcessStartInfo();
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
psiFab1.FileName = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName_Test);
} else {
@ -626,26 +561,24 @@ public class MRBController : Controller {
psiFab1.Arguments = sourcefile.FullName + " " + destFile;
Process procFab1 = new();
Process procFab1 = new Process();
procFab1.StartInfo = psiFab1;
procFab1.Start();
return true;
} catch (Exception e) {
Functions.WriteEvent(_AppSettings, GetUserIdentityName() + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Approve\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
return false;
}
}
#endif
public FileResult DownloadFile(string attachmentID) {
var attachment = mrbDMO.GetMRBAttachment(Convert.ToInt32(attachmentID));
if (attachment == null)
throw new Exception("Invalid attachment ID");
string fileName = attachment.Path;
if (string.IsNullOrEmpty(fileName))
String fileName = attachment.Path;
if (String.IsNullOrEmpty(fileName))
fileName = attachment.FileName;
var sDocument = System.IO.Path.Combine(_AppSettings.AttachmentFolder + "MRB", fileName);
@ -664,7 +597,7 @@ public class MRBController : Controller {
}
public FileResult ExportMRBHoldFlagReport(int mrbNumber) {
StringBuilder sb = new();
var sb = new StringBuilder();
sb.AppendLine("LotNo,PartNo ,CurrentLocation,CurrentOperation,StartQty,CurrentQty,LotStatus,OperStatus,Successful,Comment,PriorMRB_DispoType,PriorMRBHoldLocation,PriorMRBHoldOperation,CurrentMRB_DispoType,CurrentMRBHoldLocation,CurrentMRBHoldOperation,TransactionDatetime");
foreach (var report in mrbDMO.GetMRBHoldFlagReport(mrbNumber)) {
sb.AppendLine(MRB_DMO.FormCSV(
@ -693,7 +626,7 @@ public class MRBController : Controller {
}
public FileResult PreviewMRBHoldFlagTobeSentToSPN(int mrbNumber) {
StringBuilder sb = new();
var sb = new StringBuilder();
sb.AppendLine("LotNumber,MRBNumber,DispoType,MRB Flag,Modified,Sent To SPN,Last Sent to SPN");
foreach (var lot in mrbDMO.GetMRHoldFlagSentHistory(mrbNumber)) {
sb.AppendLine(MRB_DMO.FormCSV(
@ -711,7 +644,7 @@ public class MRBController : Controller {
}
public FileResult ExportLots(int mrbNumber) {
StringBuilder sb = new();
var sb = new StringBuilder();
sb.AppendLine("LotNumber,DieLotNumber,WipPartNo,DispoType,WaferCount,DiePartNo,DieCount,SourceLot,TotalCost,ProductFamily,Gen,HexSize,Channel,Voltage,Location,Status,QualityCode");
foreach (var lot in mrbDMO.GetMRBLots(mrbNumber)) {
sb.AppendLine(MRB_DMO.FormCSV(
@ -738,33 +671,4 @@ public class MRBController : Controller {
return File(b, "application/octet-stream", "mrb_lots_" + mrbNumber.ToString() + ".csv");
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,75 +1,31 @@
#if !NET8
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
#if !NET8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class ManagerController : Controller {
private readonly UserAccountDMO userDMO = new();
private readonly AdminDMO adminDMO = new();
private readonly TrainingDMO trainingDMO = new();
private readonly LotDispositionDMO ldDMO = new();
UserAccountDMO userDMO = new UserAccountDMO();
AdminDMO adminDMO = new AdminDMO();
TrainingDMO trainingDMO = new TrainingDMO();
LotDispositionDMO ldDMO = new LotDispositionDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult Index() {
if (GlobalVars.IsManager(GetSession())) {
if ((bool)Session[GlobalVars.IS_MANAGER]) {
var model = userDMO.GetAllUsers();
ViewBag.AllActiveUsers = userDMO.GetAllActiveUsers();
return View(model);
} else
return Content("Not Autthorized");
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,62 +1,20 @@
#if !NET8
using System;
using System;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.Misc;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class PCRBController : Controller {
public ActionResult Edit(int issueID) {
string jwt = GlobalVars.GetJWT(GetSession());
string jwt = Session["JWT"].ToString();
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
string refreshToken = GlobalVars.GetRefreshToken(GetSession());
string refreshToken = Session["RefreshToken"].ToString();
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
return Redirect(mrbUrl);
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,42 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if !NET8
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class PartsRequestController : Controller {
private const int WorkflowNumber = 1;
private readonly PartsRequestDMO prDMO = new();
private readonly UserAccountDMO userDMO = new();
private readonly WorkflowDMO wfDMO = new();
private readonly AppSettings? _AppSettings = GlobalVars.AppSettings;
const int WorkflowNumber = 1;
PartsRequestDMO prDMO = new PartsRequestDMO();
UserAccountDMO userDMO = new UserAccountDMO();
WorkflowDMO wfDMO = new WorkflowDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public PartsRequestController() {
ViewBag.ShowReAssignApprovers = false;
@ -55,13 +42,13 @@ public class PartsRequestController : Controller {
}
protected void HandleException(int issueID, Exception ex, string additionalKeys = "") {
System.Diagnostics.StackTrace st = new();
System.Diagnostics.StackFrame? sf = st.GetFrame(1);
var st = new System.Diagnostics.StackTrace();
var sf = st.GetFrame(1);
string controller = sf.GetMethod().DeclaringType.Name.Replace("Controller", "");
string method = sf.GetMethod().Name;
String controller = sf.GetMethod().DeclaringType.Name.Replace("Controller", "");
String method = sf.GetMethod().Name;
string detailedException = string.Format(
string detailedException = String.Format(
"Exception for issue # {0}\r\n" +
"Controller: {1}, Method: {2}, User: {3}, Keys: {4}\r\n" +
"=====\r\n",
@ -82,19 +69,20 @@ public class PartsRequestController : Controller {
EventLogDMO.Add(new WinEventLog() {
IssueID = issueID,
UserID = GetUserIdentityName(),
UserID = @User.Identity.Name,
DocumentType = controller,
OperationType = "Error",
Comments = detailedException
});
}
// GET: PartsRequest
public ActionResult Index() {
return View();
}
public ActionResult Edit(int issueID) {
PartsRequest pr = new();
var pr = new PartsRequest();
try {
pr = prDMO.Get(issueID);
@ -107,8 +95,8 @@ public class PartsRequestController : Controller {
} else if (pr.CurrentStep >= 1) {
return RedirectToAction("EditApproval", new { issueID = issueID });
} else {
if (pr.OriginatorID != GlobalVars.GetUserId(GetSession())) {
if (!GlobalVars.IsAdmin(GetSession())) {
if (pr.OriginatorID != (int)Session[GlobalVars.SESSION_USERID]) {
if (Convert.ToBoolean(Session[GlobalVars.IS_ADMIN]) == false) {
return RedirectToAction("ReadOnly", new { issueID = issueID });
}
}
@ -122,8 +110,6 @@ public class PartsRequestController : Controller {
}
}
#if !NET8
[HttpPost]
public ActionResult Edit(PartsRequest pr) {
try {
@ -147,12 +133,10 @@ public class PartsRequestController : Controller {
}
}
#endif
public ActionResult EditApproval(int issueID) {
PartsRequest pr = new();
var pr = new PartsRequest();
try {
int myUserID = GlobalVars.GetUserId(GetSession());
int myUserID = (int)Session[GlobalVars.SESSION_USERID];
pr = prDMO.Get(issueID);
@ -172,15 +156,15 @@ public class PartsRequestController : Controller {
if (ViewBag.IsApprover == false) {
if (pr.OriginatorID != myUserID) {
if (!GlobalVars.IsAdmin(GetSession())) {
if (Convert.ToBoolean(Session[GlobalVars.IS_ADMIN]) == false) {
return RedirectToAction("ReadOnly", new { issueID = issueID });
}
}
}
ViewBag.IsAdmin = GlobalVars.IsAdmin(GetSession());
ViewBag.IsAdmin = Convert.ToBoolean(Session[GlobalVars.IS_ADMIN]);
ViewBag.IsOriginator = (pr.OriginatorID == myUserID);
ViewBag.AllowReject = (wfStep != null && (wfStep.AllowReject.HasValue && wfStep.AllowReject.Value));
ViewBag.AllowReject = (wfStep != null ? (wfStep.AllowReject.HasValue && wfStep.AllowReject.Value) : false);
ViewBag.ShowReAssignApprovers = ViewBag.IsAdmin || ViewBag.IsOriginator;
ViewBag.ShowAddApprovers = ViewBag.IsAdmin || ViewBag.IsApprover || ViewBag.IsOriginator;
ViewBag.UserList = userDMO.GetAllUsers();
@ -192,9 +176,9 @@ public class PartsRequestController : Controller {
}
public ActionResult ReadOnly(int issueID) {
PartsRequest pr = new();
var pr = new PartsRequest();
try {
int myUserID = GlobalVars.GetUserId(GetSession());
int myUserID = (int)Session[GlobalVars.SESSION_USERID];
pr = prDMO.Get(issueID);
@ -207,7 +191,7 @@ public class PartsRequestController : Controller {
return View("Error");
}
ViewBag.IsAdmin = GlobalVars.IsAdmin(GetSession());
ViewBag.IsAdmin = Convert.ToBoolean(Session[GlobalVars.IS_ADMIN]);
ViewBag.IsOriginator = (pr.OriginatorID == myUserID);
ViewBag.UserList = userDMO.GetAllUsers();
return View(pr);
@ -218,11 +202,11 @@ public class PartsRequestController : Controller {
}
public ActionResult Create() {
PartsRequest pr = new();
var pr = new PartsRequest();
try {
pr.OriginatorID = GlobalVars.GetUserId(GetSession());
pr.OriginatorID = (int)Session[GlobalVars.SESSION_USERID];
if (!CanCreatePartsRequest(pr.OriginatorID) && !GlobalVars.GetCanCreatePartsRequest(GetSession()))
if (!CanCreatePartsRequest(pr.OriginatorID) && Convert.ToBoolean(Session[GlobalVars.CAN_CREATE_PARTS_REQUEST]) == false)
throw new Exception("User does not have permission to create Parts Request");
prDMO.Insert(pr);
@ -234,8 +218,8 @@ public class PartsRequestController : Controller {
}
public static bool CanCreatePartsRequest(int userID) {
AdminDMO adminDMO = new();
Role? role = adminDMO.GetSubRoles().FirstOrDefault(r => string.Equals(r.RoleName, "Parts Request", StringComparison.OrdinalIgnoreCase));
var adminDMO = new AdminDMO();
var role = adminDMO.GetSubRoles().Where(r => string.Equals(r.RoleName, "Parts Request", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (role != null) {
var subrole = role.SubRoles.FirstOrDefault(sr => string.Equals(sr.SubRoleCategoryItem, "Originator", StringComparison.OrdinalIgnoreCase));
if (subrole != null) {
@ -248,11 +232,9 @@ public class PartsRequestController : Controller {
return false;
}
#if !NET8
public ActionResult Attachment_Read([DataSourceRequest] DataSourceRequest request, int prNumber) {
try {
return GetJsonResult(prDMO.GetAttachments(prNumber).ToDataSourceResult(request));
return Json(prDMO.GetAttachments(prNumber).ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
} catch (Exception ex) {
return HandleAPIException(prNumber, ex);
}
@ -262,7 +244,7 @@ public class PartsRequestController : Controller {
public ActionResult AttachSave(IEnumerable<HttpPostedFileBase> files, int prNumber) {
// The Name of the Upload component is "files"
if (files != null) {
int userId = GlobalVars.GetUserId(GetSession());
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
PartsRequestHelper.AttachSave(_AppSettings, prDMO, prNumber, userId, file.FileName, file.InputStream);
}
@ -271,8 +253,6 @@ public class PartsRequestController : Controller {
return Content("");
}
#endif
public FileResult DownloadFile(string attachmentID, string prNumber) {
string fileName = prDMO.GetFileName(attachmentID);
@ -309,19 +289,17 @@ public class PartsRequestController : Controller {
}
}
#if !NET8
[HttpPost]
public ActionResult Submit(int prNumber) {
try {
int myUserID = GlobalVars.GetUserId(GetSession());
int myUserID = (int)Session[GlobalVars.SESSION_USERID];
var pr = prDMO.Get(prNumber);
if (pr == null)
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Document does not exist");
if (string.IsNullOrWhiteSpace(pr.Title))
if (String.IsNullOrWhiteSpace(pr.Title))
return HandleValidationError("Title is required");
if (pr.RequestorID <= 0)
return HandleValidationError("Requestor is required");
@ -335,9 +313,9 @@ public class PartsRequestController : Controller {
if (approvers.Count(a => a.Step.HasValue && a.Step.Value == 1 && a.UserID == myUserID) > 0) {
// Auto-Approve if the user is an approver for workflow step 1
var c = Approve(prNumber, 1, "Auto-Approve");
if (c != null && c is ContentResult contentResult) {
var result = contentResult.Content;
if (!string.Equals(result, "OK"))
if (c != null && c is ContentResult) {
var result = ((ContentResult)c).Content;
if (!String.Equals(result, "OK"))
throw new Exception(result);
}
if (c != null && c is JsonResult)
@ -347,7 +325,7 @@ public class PartsRequestController : Controller {
NotifyApprovers(prNumber, 1);
}
if (IsAjaxRequest()) {
if (Request.IsAjaxRequest()) {
return Content("Redirect");
} else {
return Content("Invalid");
@ -370,18 +348,16 @@ public class PartsRequestController : Controller {
try {
UserAccountDMO userDMO = new UserAccountDMO();
IEnumerable<LoginModel> userlist = userDMO.GetAllUsers();
return GetJsonResult(userlist);
return Json(userlist, JsonRequestBehavior.AllowGet);
} catch (Exception e) {
return HandleAPIException(0, e);
}
}
#endif
[HttpPost]
public ActionResult ReAssignApproval(int issueID, int fromUserID, int userIDs, byte step) {
try {
string email = wfDMO.ReAssignApproval(
String email = wfDMO.ReAssignApproval(
issueID, fromUserID, userIDs, step, (int)GlobalVars.DocumentType.PartsRequest);
NotifyReAssignment(issueID, email);
@ -392,14 +368,12 @@ public class PartsRequestController : Controller {
}
}
#if !NET8
[HttpPost]
public ActionResult Approve(int prNumber, byte currentStep, string comments) {
try {
bool lastStep = false;
bool lastApproverInCurrentStep = false;
int myUserID = GlobalVars.GetUserId(GetSession());
int myUserID = (int)Session[GlobalVars.SESSION_USERID];
var pr = prDMO.Get(prNumber);
@ -413,7 +387,7 @@ public class PartsRequestController : Controller {
currentStep,
comments,
out lastStep,
GlobalVars.GetUserId(GetSession()),
(int)Session[GlobalVars.SESSION_USERID],
(int)GlobalVars.DocumentType.PartsRequest,
WorkflowNumber);
@ -443,24 +417,22 @@ public class PartsRequestController : Controller {
}
}
#endif
protected void NotifyReAssignment(int prNumber, string email) {
var pr = prDMO.Get(prNumber);
if (pr == null)
return;
string username = GlobalVars.GetUserName(GetSession());
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: string.Format("Parts Request Re-Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
subject: String.Format("Parts Request Re-Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: email,
emailTemplate: "PRReAssigned.txt");
EventLogDMO.Add(new WinEventLog() {
IssueID = prNumber,
UserID = GetUserIdentityName(),
UserID = @User.Identity.Name,
DocumentType = "PR",
OperationType = "Email",
Comments = "ReAssigned Approver: " + email
@ -474,17 +446,17 @@ public class PartsRequestController : Controller {
return;
var u = userDMO.GetUserByID(pr.RequestorID);
if ((u != null) && (!string.IsNullOrWhiteSpace(u.Email))) {
string username = GlobalVars.GetUserName(GetSession());
if ((u != null) && (!String.IsNullOrWhiteSpace(u.Email))) {
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: string.Format("Parts Request Completion notice for # {0} - {1}", pr.PRNumber, pr.Title),
subject: String.Format("Parts Request Completion notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: u.Email,
emailTemplate: "PRCompleted.txt");
EventLogDMO.Add(new WinEventLog() {
IssueID = prNumber,
UserID = GetUserIdentityName(),
UserID = @User.Identity.Name,
DocumentType = "PR",
OperationType = "Email",
Comments = "Completed: " + u.Email
@ -499,17 +471,17 @@ public class PartsRequestController : Controller {
return;
var u = userDMO.GetUserByID(pr.OriginatorID);
if ((u != null) && (!string.IsNullOrWhiteSpace(u.Email))) {
string username = GlobalVars.GetUserName(GetSession());
if ((u != null) && (!String.IsNullOrWhiteSpace(u.Email))) {
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: string.Format("Parts Request Rejection notice for # {0} - {1}", pr.PRNumber, pr.Title),
subject: String.Format("Parts Request Rejection notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: u.Email,
emailTemplate: "PRReject.txt");
EventLogDMO.Add(new WinEventLog() {
IssueID = prNumber,
UserID = GetUserIdentityName(),
UserID = @User.Identity.Name,
DocumentType = "PR",
OperationType = "Email",
Comments = "Rejected: " + u.Email
@ -531,9 +503,9 @@ public class PartsRequestController : Controller {
foreach (string email in emailList) {
try {
string username = GlobalVars.GetUserName(GetSession());
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: string.Format("Parts Request Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
subject: String.Format("Parts Request Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: email,
emailTemplate: "PRAssigned.txt");
@ -547,7 +519,7 @@ public class PartsRequestController : Controller {
try {
EventLogDMO.Add(new WinEventLog() {
IssueID = prNumber,
UserID = GetUserIdentityName(),
UserID = @User.Identity.Name,
DocumentType = "PR",
OperationType = "Email",
Comments = "Approvers for Step " + step.ToString() + ":" + emailSentList
@ -561,8 +533,8 @@ public class PartsRequestController : Controller {
[HttpPost]
public ActionResult Reject(int prNumber, byte currentStep, string comments) {
try {
if (GlobalVars.IsUserIdValueNotNull(GetSession())) {
wfDMO.Reject(prNumber, currentStep, comments, GlobalVars.GetUserId(GetSession()), (int)GlobalVars.DocumentType.PartsRequest);
if (Session[GlobalVars.SESSION_USERID] != null) {
wfDMO.Reject(prNumber, currentStep, comments, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.PartsRequest);
NotifyRejection(prNumber);
} else {
Response.Redirect("~/Account/Login");
@ -574,30 +546,26 @@ public class PartsRequestController : Controller {
}
}
#if !NET8
public ActionResult ApprovalLogHistory_Read([DataSourceRequest] DataSourceRequest request, int prNumber) {
return GetJsonResult(prDMO.GetApprovalLogHistory(prNumber).ToDataSourceResult(request));
return Json(prDMO.GetApprovalLogHistory(prNumber).ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
#endif
protected void NotifyAssignment(int prNumber, string email) {
var pr = prDMO.Get(prNumber);
if (pr == null)
return;
string username = GlobalVars.GetUserName(GetSession());
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: string.Format("Parts Request Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
subject: String.Format("Parts Request Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: email,
emailTemplate: "PRAssigned.txt");
EventLogDMO.Add(new WinEventLog() {
IssueID = prNumber,
UserID = GetUserIdentityName(),
UserID = @User.Identity.Name,
DocumentType = "PR",
OperationType = "Email",
Comments = "Assigned Approver: " + email
@ -626,7 +594,7 @@ public class PartsRequestController : Controller {
try {
EventLogDMO.Add(new WinEventLog() {
IssueID = issueID,
UserID = GetUserIdentityName(),
UserID = @User.Identity.Name,
DocumentType = "PR",
OperationType = "Email",
Comments = "Additional Approver: " + emailSentList
@ -634,33 +602,4 @@ public class PartsRequestController : Controller {
} catch { }
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,60 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if !NET8
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
#if !NET8
using System.Collections.Generic;
using Fab2ApprovalSystem.ViewModels;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class ReportsController : Controller {
public const string specialNullString = "~NULL~";
private readonly AppSettings? _AppSettings = GlobalVars.AppSettings;
public const String specialNullString = "~NULL~";
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: Export
public ActionResult Index() {
UserAccountDMO userDMO = new();
ViewBag.HasITARAccess = userDMO.GetITARAccess(GlobalVars.GetUserId(GetSession()));
UserAccountDMO userDMO = new UserAccountDMO();
ViewBag.HasITARAccess = userDMO.GetITARAccess((int)Session[GlobalVars.SESSION_USERID]);
return View();
}
#if !NET8
public ActionResult Report(string id, string docType = "") {
if (string.IsNullOrEmpty(id))
public ActionResult Report(String id, String docType = "") {
if (String.IsNullOrEmpty(id))
return RedirectToAction("Index");
UserAccountDMO userDMO = new();
if (!userDMO.GetITARAccess(GlobalVars.GetUserId(GetSession())))
UserAccountDMO userDMO = new UserAccountDMO();
if (!userDMO.GetITARAccess((int)Session[GlobalVars.SESSION_USERID]))
return View("UnAuthorizedAccess");
ReportViewModel<SelectListItem> m = new();
var m = new ReportViewModel<System.Web.Mvc.SelectListItem>();
var reports = GetReportList(docType);
foreach (var report in reports) {
if (string.Equals(report.ReportID, id, StringComparison.OrdinalIgnoreCase)) {
if (String.Equals(report.ReportID, id, StringComparison.OrdinalIgnoreCase)) {
m.ReportID = report.ReportID;
m.ReportName = report.Name;
m.Description = report.Description;
@ -63,8 +46,8 @@ public class ReportsController : Controller {
var c = SetupSSRSHelperClient();
m.Parameters = c.GetReportParameters(report.FullPath).Select(parm => {
ReportParameterViewModel<SelectListItem> r = new();
r.Visible = (parm.PromptUser.HasValue == false || parm.PromptUser == true) && !string.IsNullOrEmpty(parm.Prompt);
var r = new ReportParameterViewModel<System.Web.Mvc.SelectListItem>();
r.Visible = (parm.PromptUser.HasValue == false || parm.PromptUser == true) && !String.IsNullOrEmpty(parm.Prompt);
r.Prompt = parm.Prompt;
r.Name = parm.Name;
r.HtmlID = "parm_" + parm.Name;
@ -104,7 +87,7 @@ public class ReportsController : Controller {
public SSRSHelper.SSRSClient SetupSSRSHelperClient() {
var useCfgForBindings = false;
if (string.Equals(_AppSettings.SSRSBindingsByConfiguration, "true", StringComparison.OrdinalIgnoreCase))
if (String.Equals(_AppSettings.SSRSBindingsByConfiguration, "true", StringComparison.OrdinalIgnoreCase))
useCfgForBindings = true;
var c = new SSRSHelper.SSRSClient(
@ -129,26 +112,27 @@ public class ReportsController : Controller {
return c.ListReports(folderName);
}
public ActionResult GetReports(string docType) {
public ActionResult GetReports(String docType) {
var reports = GetReportList(docType);
return GetJsonResult(new {
return Json(new {
Data =
reports.Select(r => new ReportViewModel<SelectListItem>() {
reports.Select(r => new ReportViewModel<System.Web.Mvc.SelectListItem>() {
ReportName = r.Name ?? "",
Description = r.Description ?? "",
ReportID = r.ReportID ?? "",
DocType = docType
})
});
},
JsonRequestBehavior.AllowGet);
}
[HttpPost]
public ActionResult ExportReport(string DocType, string ReportID) {
public ActionResult ExportReport(String DocType, String ReportID) {
var c = SetupSSRSHelperClient();
var reports = GetReportList(DocType);
var report = reports.Where(r => string.Equals(r.ReportID, ReportID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
var report = reports.Where(r => String.Equals(r.ReportID, ReportID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (report == null)
return Content("Invalid report ID");
@ -156,16 +140,16 @@ public class ReportsController : Controller {
var parms = new SSRSHelper.ReportParameterCollection();
parms.Add("DocType", DocType);
parms.Add("UserID", GlobalVars.GetUserIdValue(GetSession()));
parms.Add("UserID", Convert.ToString(Session[GlobalVars.SESSION_USERID]));
parms.Add("BaseURL", GlobalVars.hostURL);
foreach (var rp in reportParms) {
if (rp.MultiValue.HasValue && rp.MultiValue.Value) {
foreach (string v in Request.Params.GetValues("parm_" + rp.Name)) {
foreach (String v in Request.Params.GetValues("parm_" + rp.Name)) {
parms.Add(rp.Name, v);
}
} else {
string value = null;
String value = null;
if (Request.Params.AllKeys.Contains("parm_" + rp.Name))
value = Request.Params.GetValues("parm_" + rp.Name).FirstOrDefault();
@ -189,7 +173,7 @@ public class ReportsController : Controller {
}
}
var b = c.ExportReport(report.FullPath, GetUserIdentityName(), parms, "EXCELOPENXML");
var b = c.ExportReport(report.FullPath, @User.Identity.Name, parms, "EXCELOPENXML");
try {
var b2 = c.FreezeExcelHeaders(b);
return File(b2, "application/octet-stream", MakeFilename(report.Name) + ".xlsx");
@ -198,10 +182,8 @@ public class ReportsController : Controller {
return File(b, "application/octet-stream", MakeFilename(report.Name) + ".xlsx");
}
#endif
protected string MakeFilename(string reportName) {
string r = "";
protected String MakeFilename(String reportName) {
String r = "";
char[] invalidChars = System.IO.Path.GetInvalidFileNameChars();
foreach (char c in reportName) {
if (invalidChars.Contains(c))
@ -212,33 +194,4 @@ public class ReportsController : Controller {
return r;
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,14 +1,8 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
#if !NET8
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
@ -16,26 +10,19 @@ using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.Utilities;
using Fab2ApprovalSystem.ViewModels;
#if !NET8
using Kendo.Mvc.Extensions;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class TrainingController : Controller {
private readonly UserAccountDMO userDMO = new();
private readonly AdminDMO adminDMO = new();
private readonly TrainingDMO trainingDMO = new();
private readonly ECN_DMO ecnDMO = new();
private readonly AppSettings? _AppSettings = GlobalVars.AppSettings;
UserAccountDMO userDMO = new UserAccountDMO();
AdminDMO adminDMO = new AdminDMO();
TrainingDMO trainingDMO = new TrainingDMO();
ECN_DMO ecnDMO = new ECN_DMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: Training
public ActionResult Index() {
@ -43,19 +30,19 @@ public class TrainingController : Controller {
}
public int Create(int ecnId) {
ECN_DMO ecnDMO = new();
ECN_DMO ecnDMO = new ECN_DMO();
// Delete old training if exists
int oldTrainingId = trainingDMO.GetTrainingId(ecnId);
if (oldTrainingId != 0) {
if (oldTrainingId != null && oldTrainingId != 0) {
trainingDMO.DeleteTraining(oldTrainingId);
}
int trainingId = trainingDMO.Create(ecnId);
List<int> TrainingGroups = new();
List<int> TrainingGroups = new List<int>();
TrainingGroups = trainingDMO.GetECNAssignedTrainingGroups(ecnId);
string ECNTitle = ecnDMO.GetECN(ecnId).Title;
List<int> Trainees = new();
List<int> Trainees = new List<int>();
foreach (int group in TrainingGroups) {
Trainees.AddRange(trainingDMO.GetTrainees(group));
}
@ -68,9 +55,8 @@ public class TrainingController : Controller {
return trainingId;
}
public ActionResult AddUserToTrainingAdHoc(int trainingId, int traineeId, int ecnId) {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
// Get ECN
ECN ecn = ecnDMO.GetECN(ecnId);
@ -119,7 +105,7 @@ public class TrainingController : Controller {
}
public ActionResult AddGroupToTrainingAdHoc(int trainingId, int groupId, int ecnId) {
if (GlobalVars.IsAdmin(GetSession())) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
ECN ecn = ecnDMO.GetECN(ecnId);
Training training = trainingDMO.GetTraining(trainingId);
TrainingGroup group = trainingDMO.GetTrainingGroupByID(groupId);
@ -177,14 +163,14 @@ public class TrainingController : Controller {
public ActionResult DeleteTrainingByECN(int ECNNumber) {
int trainingId = trainingDMO.GetTrainingId(ECNNumber);
if (trainingId != 0) {
if (trainingId != null && trainingId != 0) {
trainingDMO.DeleteTraining(trainingId);
}
return RedirectToAction("ViewTrainings");
}
public ActionResult DeleteTrainingByID(int trainingId) {
if (trainingId != 0) {
if (trainingId != null && trainingId != 0) {
trainingDMO.DeleteTraining(trainingId);
}
return RedirectToAction("ViewTrainings");
@ -268,7 +254,7 @@ public class TrainingController : Controller {
// Group Filter
if (filterType == 1 && filterValue != "") {
ViewBag.GroupFilter = filterValue;
List<Training> filteredTraining = new();
List<Training> filteredTraining = new List<Training>();
foreach (Training item in trainingList) {
List<int> assignedTrainingGroups = trainingDMO.GetECNAssignedTrainingGroups(item.ECN);
foreach (int id in assignedTrainingGroups) {
@ -282,7 +268,7 @@ public class TrainingController : Controller {
}
// Status Filter
if (filterType == 2 && filterValue != "") {
List<Training> filteredTraining = new();
List<Training> filteredTraining = new List<Training>();
switch (filterValue) {
case "1":
// Completed
@ -321,7 +307,7 @@ public class TrainingController : Controller {
float assignmentCount = (from a in trainingAssignments where a.Deleted != true select a).Count();
float totalCompleted = 0;
foreach (TrainingAssignment assignment in trainingAssignments) {
if (assignment.status && assignment.Deleted != true) {
if (assignment.status == true && assignment.Deleted != true) {
totalCompleted++;
}
}
@ -330,7 +316,7 @@ public class TrainingController : Controller {
if (groupFilter != "" && groupFilter != null) {
ViewBag.GroupFilter = groupFilter;
List<TrainingAssignment> groupFilteredTraining = new();
List<TrainingAssignment> groupFilteredTraining = new List<TrainingAssignment>();
List<int> groupMemberIds = trainingDMO.GetTrainees(Convert.ToInt32(groupFilter));
foreach (TrainingAssignment assignment in trainingAssignments) {
if (trainingDMO.isUserTrainingMember(Convert.ToInt32(groupFilter), assignment.UserID)) {
@ -340,15 +326,15 @@ public class TrainingController : Controller {
trainingAssignments = groupFilteredTraining;
}
if (statusFilter != "" && statusFilter != null) {
List<TrainingAssignment> filteredTraining = new();
List<TrainingAssignment> filteredTraining = new List<TrainingAssignment>();
switch (statusFilter) {
case "1":
// Completed
filteredTraining = (from a in trainingAssignments where a.status && a.Deleted != true select a).ToList();
filteredTraining = (from a in trainingAssignments where a.status == true && a.Deleted != true select a).ToList();
break;
case "2":
// In Progress
filteredTraining = (from a in trainingAssignments where !a.status && a.Deleted != true select a).ToList();
filteredTraining = (from a in trainingAssignments where a.status != true && a.Deleted != true select a).ToList();
break;
case "3":
// Cancelled
@ -383,9 +369,9 @@ public class TrainingController : Controller {
/// Method to return all the training assignments for a specified user
/// </summary>
public ActionResult ViewMyTrainingAssignments() {
int userID = GlobalVars.GetUserId(GetSession());
int userID = (int)Session[GlobalVars.SESSION_USERID];
List<TrainingAssignment> assignments = trainingDMO.GetTrainingAssignmentsByUserID(userID);
List<ECNTrainingAssignments> ViewData = new();
List<ECNTrainingAssignments> ViewData = new List<ECNTrainingAssignments>();
foreach (TrainingAssignment assignment in assignments) {
Training training = trainingDMO.GetTraining(assignment.TrainingID);
if (training != null && !assignment.status) {
@ -421,7 +407,7 @@ public class TrainingController : Controller {
// Group Filter
if (filterType == 1 && filterValue != "") {
ViewBag.GroupFilter = filterValue;
List<Training> filteredTraining = new();
List<Training> filteredTraining = new List<Training>();
foreach (Training item in AllTrainings) {
List<int> assignedTrainingGroups = trainingDMO.GetECNAssignedTrainingGroups(item.ECN);
foreach (int id in assignedTrainingGroups) {
@ -468,8 +454,8 @@ public class TrainingController : Controller {
}
public ActionResult ManuallyExecuteECNTraining(int ecnId, int[] trainingGroupsIn) {
if (GlobalVars.IsAdmin(GetSession())) {
List<int> newTrainingGroupIds = new(trainingGroupsIn);
if ((bool)Session[GlobalVars.IS_ADMIN]) {
List<int> newTrainingGroupIds = new List<int>(trainingGroupsIn);
ECN ecn = ecnDMO.GetECN(ecnId);
if (ecn != null) {
if (ecn.CloseDate != null) {
@ -507,7 +493,7 @@ public class TrainingController : Controller {
if (ecn != null) {
if (ecn.CloseDate != null) {
List<int> trainingGroupIds = trainingDMO.GetECNAssignedTrainingGroups(ecnId);
List<TrainingGroup> assignedGroups = new();
List<TrainingGroup> assignedGroups = new List<TrainingGroup>();
foreach (int trainingGroupId in trainingGroupIds) {
TrainingGroup trainingGroup = trainingDMO.GetTrainingGroupByID(trainingGroupId);
assignedGroups.Add(trainingGroup);
@ -531,7 +517,7 @@ public class TrainingController : Controller {
emailBody += "<style>table,th,td{border: 1px solid black;}</style>";
// Get all users set up to receive the training report email.
List<TrainingReportUser> trainingReportUsers = adminDMO.GetTrainingReportUsers();
List<string> emailList = new();
List<string> emailList = new List<string>();
foreach (TrainingReportUser user in trainingReportUsers) {
string userEmail = userDMO.GetUserByID(user.UserId).Email;
emailList.Add(userEmail);
@ -578,34 +564,4 @@ public class TrainingController : Controller {
}
return isSuccess;
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -1,56 +1,34 @@
using System;
using System.Collections.Generic;
#if !NET8
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
#endif
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
#if !NET8
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
#endif
namespace Fab2ApprovalSystem.Controllers;
#if !NET8
public class WebAPIController : ApiController {
#endif
#if NET8
[ApiController]
[Route("[controller]")]
public class WebAPIController : Controller {
#endif
public TrainingController trainingFunctions = new();
public CorrectiveActionController carFunctions = new();
public AccountController accountFunctions = new();
public HomeController homeFunctions = new();
private readonly AppSettings? _AppSettings = GlobalVars.AppSettings;
public TrainingController trainingFunctions = new TrainingController();
public CorrectiveActionController carFunctions = new CorrectiveActionController();
public AccountController accountFunctions = new AccountController();
public HomeController homeFunctions = new HomeController();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public string Get() {
return "Welcome To Web API";
}
public List<string> Get(int Id) {
return new List<string> {
"Data1",
"Data2"
};
}
public void Post() {
}
#if !NET8
public HttpResponseMessage Post(HttpRequestMessage request, string action) {
switch (action) {
case "TrainingReport":
@ -87,7 +65,4 @@ public class WebAPIController : Controller {
return request.CreateResponse(HttpStatusCode.InternalServerError, "Action Not Found");
}
}
#endif
}

View File

@ -1,30 +1,17 @@
#if !NET8
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
#endif
#if !NET8
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Models;
#endif
#if !NET8
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
#endif
namespace Fab2ApprovalSystem.Controllers;
#if NET8
[Route("[controller]")]
#endif
public class WorkflowController : Controller {
// GET: /Workflow/Details/5
@ -37,8 +24,6 @@ public class WorkflowController : Controller {
return View();
}
#if !NET8
// POST: /Workflow/Create
[HttpPost]
public ActionResult Create(FormCollection collection) {
@ -51,15 +36,11 @@ public class WorkflowController : Controller {
}
}
#endif
// GET: /Workflow/Edit/5
public ActionResult Edit(int id) {
return View();
}
#if !NET8
// POST: /Workflow/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection) {
@ -72,15 +53,11 @@ public class WorkflowController : Controller {
}
}
#endif
// GET: /Workflow/Delete/5
public ActionResult Delete(int id) {
return View();
}
#if !NET8
// POST: /Workflow/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection) {
@ -93,35 +70,4 @@ public class WorkflowController : Controller {
}
}
#endif
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}

View File

@ -130,19 +130,13 @@ public class AdminDMO {
}
#if !NET8
public List<TrainingReportUser> GetTrainingReportUsers() {
List<TrainingReportUser> CurrentReportUsers = (from a in FabApprovalDB.TrainingReportUsers select a).ToList();
return CurrentReportUsers;
}
#endif
#if NET8
#else
public List<TrainingReportUser> GetTrainingReportUsers() =>
throw new NotImplementedException();
#endif
#if !NET8
@ -185,20 +179,14 @@ public class AdminDMO {
return;
}
public List<TrainingGroup> GetTrainingGroups() {
#if !NET8
public List<TrainingGroup> GetTrainingGroups() {
var TrainingGroups = from a in FabApprovalDB.TrainingGroups select a;
List<TrainingGroup> GroupsToReturn = TrainingGroups.ToList();
return GroupsToReturn;
#endif
#if NET8
throw new NotImplementedException();
#endif
}
#if !NET8
public void AddNewTrainingGroup(string groupName) {
TrainingGroup existing = null;
// Check to see that the group name doesn't exist.

View File

@ -46,9 +46,7 @@ public class TrainingDMO {
IEnumerable<Training> allTrainings = (from a in db.Trainings select a).ToList();
return allTrainings;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -59,9 +57,7 @@ public class TrainingDMO {
Training trainingRecord = new Training();
trainingRecord = (from a in db.Trainings where a.TrainingID == trainingId select a).FirstOrDefault();
return trainingRecord;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -71,9 +67,7 @@ public class TrainingDMO {
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
TrainingAssignment assignmentRecord = (from a in db.TrainingAssignments where a.ID == assignmentId select a).FirstOrDefault();
return assignmentRecord;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -85,9 +79,7 @@ public class TrainingDMO {
int trainingId = (from a in db.Trainings where a.ECN == ECNId select a.TrainingID).FirstOrDefault();
return trainingId;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -98,9 +90,7 @@ public class TrainingDMO {
var users = (from a in db.TrainingGroupMembers where a.TrainingGroupID == groupId select a.UserID).ToList();
return users;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -115,9 +105,7 @@ public class TrainingDMO {
} else {
return true;
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -126,11 +114,8 @@ public class TrainingDMO {
#if !NET8
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
return (from a in db.TrainingGroups select a).ToList();
#endif
#if NET8
System.Text.StringBuilder query = new("SELECT TrainingGroupID, TrainingGroupName FROM TrainingGroups ORDER BY TrainingGroupID");
return db.Query<TrainingGroup>(query.ToString()).ToList();
#else
throw new NotImplementedException();
#endif
}
@ -139,9 +124,7 @@ public class TrainingDMO {
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
TrainingGroup groups = (from a in db.TrainingGroups where a.TrainingGroupID == groupId select a).FirstOrDefault();
return groups;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -151,9 +134,7 @@ public class TrainingDMO {
List<int> trainingGroups = (from a in FabApprovalDB.ECNTrainingBies where a.ECNNumber == ECNNumber select a.AcknowledgementTrainingByID).ToList();
return trainingGroups;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -168,9 +149,7 @@ public class TrainingDMO {
this.db.Execute("ECNInsertTrainingBy", parameters, commandType: CommandType.StoredProcedure);
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -183,9 +162,7 @@ public class TrainingDMO {
this.db.Execute("ECNSetTrainingFlag", parameters, commandType: CommandType.StoredProcedure);
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -200,9 +177,7 @@ public class TrainingDMO {
TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID select a;
return TrainingData.ToList();
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -217,9 +192,7 @@ public class TrainingDMO {
TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID select a;
return TrainingData.ToList();
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -230,9 +203,7 @@ public class TrainingDMO {
var TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID && a.UserID == userID select a;
return TrainingData.ToList();
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -243,9 +214,7 @@ public class TrainingDMO {
var docs = (from a in db.TrainingDocAcks where a.TrainingAssignmentID == trainingAssignmentId && a.Deleted != true select a).ToList();
return docs;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -271,9 +240,7 @@ public class TrainingDMO {
Console.WriteLine(e);
}
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -284,9 +251,7 @@ public class TrainingDMO {
int trainingID = (from a in db.TrainingAssignments where a.ID == trainingAssignmentID select a.TrainingID).SingleOrDefault();
return trainingID;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -307,9 +272,7 @@ public class TrainingDMO {
Console.WriteLine(e);
}
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -330,9 +293,7 @@ public class TrainingDMO {
Console.WriteLine(e);
}
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -350,9 +311,7 @@ public class TrainingDMO {
}
}
return isFinished;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -372,9 +331,7 @@ public class TrainingDMO {
}
return isFinished;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -391,9 +348,7 @@ public class TrainingDMO {
}
return userHasAssignment;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -404,9 +359,7 @@ public class TrainingDMO {
var trainings = from a in db.Trainings select a;
return trainings.ToList();
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -417,9 +370,7 @@ public class TrainingDMO {
var trainingAssignments = from a in db.TrainingAssignments where a.UserID == userID && a.Deleted != true select a;
return trainingAssignments.ToList();
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -439,9 +390,7 @@ public class TrainingDMO {
string exception = e.ToString();
Console.WriteLine(e);
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -461,9 +410,7 @@ public class TrainingDMO {
string exception = e.ToString();
Console.WriteLine(e);
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -484,9 +431,7 @@ public class TrainingDMO {
DeleteTrainingAssignment(trainingAssignment.ID);
DeleteTrainingDocAck(trainingAssignment.ID);
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -506,9 +451,7 @@ public class TrainingDMO {
}
DeleteTrainingAssignment(item.ID);
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -535,9 +478,7 @@ public class TrainingDMO {
} else {
return false;
}
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -547,9 +488,7 @@ public class TrainingDMO {
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
List<Training> openTrainings = (from a in db.Trainings where a.Status != true && a.Deleted != true select a).ToList();
return openTrainings;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}
@ -559,9 +498,7 @@ public class TrainingDMO {
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
List<TrainingAssignment> openAssignments = (from a in FabApprovalDB.TrainingAssignments where a.TrainingID == trainingID && a.status != true && a.Deleted != true select a).ToList();
return openAssignments;
#endif
#if NET8
#else
throw new NotImplementedException();
#endif
}

View File

@ -321,14 +321,10 @@
<Compile Include="Models\PartsRequestModels.cs" />
<Compile Include="Models\ProductViewModel.cs" />
<Compile Include="Models\TestModels.cs" />
<Compile Include="Models\User.cs" />
<Compile Include="Models\UserSubRoles.cs" />
<Compile Include="Models\WinEventLogModel.cs" />
<Compile Include="Models\WorkFlowModels.cs" />
<Compile Include="PdfGenerator\BinaryContentResult.cs" />
<Compile Include="PdfGenerator\FakeView.cs" />
<Compile Include="PdfGenerator\HtmlViewRenderer.cs" />
<Compile Include="PdfGenerator\PdfViewController.cs" />
<Compile Include="PdfGenerator\PrintHeaderFooter.cs" />
<Compile Include="PdfGenerator\StandardPdfRenderer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -5,9 +5,7 @@ using System.Linq;
using System.Web;
using System.Web.Hosting;
using System.Web.Http;
#if !NET8
using System.Web.Mvc;
#endif
using System.Web.Optimization;
using System.Web.Routing;
using System.Web.Security;
@ -65,7 +63,7 @@ public class MvcApplication : System.Web.HttpApplication {
protected void Application_EndRequest() {
var context = new HttpContextWrapper(Context);
#if !NET8
// Do a direct 401 unauthorized
if (Context.Response.StatusCode == 301 && context.Request.IsAjaxRequest()) {
Context.Response.Clear();
Context.Response.StatusCode = 401;
@ -74,27 +72,18 @@ public class MvcApplication : System.Web.HttpApplication {
context.Response.Clear();
context.Response.StatusCode = 401;
}
#endif
#if NET8
if (Context.Response.StatusCode == 301 && context.Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest") {
Context.Response.Clear();
Context.Response.StatusCode = 401;
} else if (FormsAuthentication.IsEnabled && context.Response.StatusCode == 302
&& context.Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest") {
context.Response.Clear();
context.Response.StatusCode = 401;
}
#endif
}
protected void Session_Start(object sender, EventArgs e) {
GlobalVars.SetECNViewOption(Session, "Pending Approvals");
Session[GlobalVars.ECN_VIEW_OPTION] = "Pending Approvals";
}
protected void Session_End(object sender, EventArgs e) {
// FormsAuthentication.SignOut();
try {
GlobalVars.EndSession(Session);
Session[GlobalVars.SESSION_USERNAME] = "";
Session[GlobalVars.SESSION_USERID] = "";
Session[GlobalVars.IS_ADMIN] = null;
} catch (Exception ex) {
Functions.WriteEvent(null, @User.Identity.Name + "\r\n Session Closed - \r\n" + ex.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
}

View File

@ -2,9 +2,7 @@
using ExcelDataReader;
#endif
#if !NET8
#else
using Excel;
@ -96,9 +94,7 @@ public class ExcelData {
public IEnumerable<DataRow> getData(bool firstRowIsColumnNames = true) =>
throw new NotImplementedException();
#endif
#if !NET8
#else
public IEnumerable<DataRow> getData(bool firstRowIsColumnNames = true) {
IExcelDataReader reader = getExcelReader();

View File

@ -6,15 +6,10 @@ namespace Fab2ApprovalSystem.Misc;
public class GlobalVars {
public int USER_ID;
#endif
#if NET8
#else
public static class GlobalVars {
public static int USER_ID = 0;
#endif
public const string SESSION_USERNAME = "UserName";
public const string ApplicationName = "LotDisposition";
@ -103,268 +98,4 @@ public static class GlobalVars {
Main, D1, D2, D3, D4, D5, D6, D7, D8, CF
}
#if !NET8
public static void EndSession(System.Web.SessionState.HttpSessionState session) {
session[SESSION_USERNAME] = "";
session[SESSION_USERID] = "";
session[IS_ADMIN] = null;
}
public static bool IsAdminValueNull(System.Web.SessionState.HttpSessionState session) =>
session[IS_ADMIN] == null;
public static bool IsUserIdValueNotNull(System.Web.SessionState.HttpSessionState session) =>
session[SESSION_USERID] != null;
public static bool IsAdminValueNotNull(System.Web.SessionState.HttpSessionState session) =>
session[IS_ADMIN] != null;
public static bool IsUserNameNull(System.Web.SessionState.HttpSessionState session) =>
session[SESSION_USERNAME] == null;
public static bool IsAdmin(System.Web.SessionState.HttpSessionState session) =>
bool.Parse(session[IS_ADMIN].ToString());
public static bool IsManager(System.Web.SessionState.HttpSessionState session) =>
bool.Parse(session[IS_MANAGER].ToString());
public static bool IsOOO(System.Web.SessionState.HttpSessionState session) =>
bool.Parse(session[OOO].ToString());
public static bool GetCreateNewRevision(System.Web.SessionState.HttpSessionState session) =>
bool.Parse(session["CreateNewRevision"].ToString());
public static bool GetCreateLotTravNewRevision(System.Web.SessionState.HttpSessionState session) =>
bool.Parse(session["CreateLotTravNewRevision"].ToString());
public static int GetUserId(System.Web.SessionState.HttpSessionState session) =>
int.Parse(GetUserIdValue(session));
public static string GetUserIdValue(System.Web.SessionState.HttpSessionState session) =>
session[SESSION_USERID].ToString();
public static string GetJWT(System.Web.SessionState.HttpSessionState session) =>
session["JWT"].ToString();
public static string GetRefreshToken(System.Web.SessionState.HttpSessionState session) =>
session["RefreshToken"].ToString();
public static string GetAllDocumentsFilterData(System.Web.SessionState.HttpSessionState session) =>
session["AllDocumentsFilterData"].ToString();
public static string GetSWRFilterData(System.Web.SessionState.HttpSessionState session) =>
session["SWRFilterData"].ToString();
public static string GetPCRBFilterData(System.Web.SessionState.HttpSessionState session) =>
session["PCRBFilterData"].ToString();
public static string GetUserName(System.Web.SessionState.HttpSessionState session) =>
session[SESSION_USERNAME].ToString();
public static bool GetCanCreatePartsRequest(System.Web.SessionState.HttpSessionState session) =>
bool.Parse(session[CAN_CREATE_PARTS_REQUEST].ToString());
public static void SetECNViewOption(System.Web.SessionState.HttpSessionState session, string value) =>
session[ECN_VIEW_OPTION] = value;
public static void SetCreateNewRevision(System.Web.SessionState.HttpSessionState session, bool value) =>
session["CreateNewRevision"] = value;
public static void SetSWRFilterData(System.Web.SessionState.HttpSessionState session, string value) =>
session["SWRFilterData"] = value;
public static void SetPCRBFilterData(System.Web.SessionState.HttpSessionState session, string value) =>
session["PCRBFilterData"] = value;
public static void SetAllDocumentsFilterData(System.Web.SessionState.HttpSessionState session, string value) =>
session["AllDocumentsFilterData"] = value;
public static void SetCreateLotTravNewRevision(System.Web.SessionState.HttpSessionState session, bool value) =>
session["CreateLotTravNewRevision"] = value;
public static void SetOOO(System.Web.SessionState.HttpSessionState session, bool value) =>
session[OOO] = value;
public static bool IsAdminValueNull(System.Web.HttpSessionStateBase session) =>
session[IS_ADMIN] == null;
public static bool IsUserIdValueNotNull(System.Web.HttpSessionStateBase session) =>
session[SESSION_USERID] != null;
public static bool IsAdminValueNotNull(System.Web.HttpSessionStateBase session) =>
session[IS_ADMIN] != null;
public static bool IsUserNameNull(System.Web.HttpSessionStateBase session) =>
session[SESSION_USERNAME] == null;
public static bool IsAdmin(System.Web.HttpSessionStateBase session) =>
bool.Parse(session[IS_ADMIN].ToString());
public static bool IsManager(System.Web.HttpSessionStateBase session) =>
bool.Parse(session[IS_MANAGER].ToString());
public static bool IsOOO(System.Web.HttpSessionStateBase session) =>
bool.Parse(session[OOO].ToString());
public static bool GetCreateNewRevision(System.Web.HttpSessionStateBase session) =>
bool.Parse(session["CreateNewRevision"].ToString());
public static bool GetCreateLotTravNewRevision(System.Web.HttpSessionStateBase session) =>
bool.Parse(session["CreateLotTravNewRevision"].ToString());
public static int GetUserId(System.Web.HttpSessionStateBase session) =>
int.Parse(GetUserIdValue(session));
public static string GetUserIdValue(System.Web.HttpSessionStateBase session) =>
session[SESSION_USERID].ToString();
public static string GetJWT(System.Web.HttpSessionStateBase session) =>
session["JWT"].ToString();
public static string GetRefreshToken(System.Web.HttpSessionStateBase session) =>
session["RefreshToken"].ToString();
public static string GetAllDocumentsFilterData(System.Web.HttpSessionStateBase session) =>
session["AllDocumentsFilterData"].ToString();
public static string GetSWRFilterData(System.Web.HttpSessionStateBase session) =>
session["SWRFilterData"].ToString();
public static string GetPCRBFilterData(System.Web.HttpSessionStateBase session) =>
session["PCRBFilterData"].ToString();
public static string GetUserName(System.Web.HttpSessionStateBase session) =>
session[SESSION_USERNAME].ToString();
public static bool GetCanCreatePartsRequest(System.Web.HttpSessionStateBase session) =>
bool.Parse(session[CAN_CREATE_PARTS_REQUEST].ToString());
public static void SetECNViewOption(System.Web.HttpSessionStateBase session, string value) =>
session[ECN_VIEW_OPTION] = value;
public static void SetCreateNewRevision(System.Web.HttpSessionStateBase session, bool value) =>
session["CreateNewRevision"] = value;
public static void SetSWRFilterData(System.Web.HttpSessionStateBase session, string value) =>
session["SWRFilterData"] = value;
public static void SetPCRBFilterData(System.Web.HttpSessionStateBase session, string value) =>
session["PCRBFilterData"] = value;
public static void SetAllDocumentsFilterData(System.Web.HttpSessionStateBase session, string value) =>
session["AllDocumentsFilterData"] = value;
public static void SetCreateLotTravNewRevision(System.Web.HttpSessionStateBase session, bool value) =>
session["CreateLotTravNewRevision"] = value;
public static void SetOOO(System.Web.HttpSessionStateBase session, bool value) =>
session[OOO] = value;
public static void SetSessionParameters(System.Web.HttpSessionStateBase session, LoginResult loginResult, LoginModel user) {
session["JWT"] = loginResult.AuthTokens.JwtToken;
session["RefreshToken"] = loginResult.AuthTokens.RefreshToken;
session[SESSION_USERID] = user.UserID;
session[SESSION_USERNAME] = user.FullName;
session[IS_ADMIN] = user.IsAdmin;
session[IS_MANAGER] = user.IsManager;
session[OOO] = user.OOO;
bool check = user.IsAdmin || Fab2ApprovalSystem.Controllers.PartsRequestController.CanCreatePartsRequest(user.UserID);
session[CAN_CREATE_PARTS_REQUEST] = check;
}
#endif
#if NET8
public static bool IsAdminValueNull(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.Get(session, IS_ADMIN) == null;
public static bool IsUserIdValueNotNull(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.Get(session, SESSION_USERID) != null;
public static bool IsAdminValueNotNull(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.Get(session, IS_ADMIN) != null;
public static bool IsUserNameNull(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.Get(session, SESSION_USERNAME) == null;
public static bool IsAdmin(Microsoft.AspNetCore.Http.ISession session) =>
bool.Parse(Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, IS_ADMIN));
public static bool IsManager(Microsoft.AspNetCore.Http.ISession session) =>
bool.Parse(Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, IS_MANAGER));
public static bool IsOOO(Microsoft.AspNetCore.Http.ISession session) =>
bool.Parse(Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, OOO));
public static bool GetCreateNewRevision(Microsoft.AspNetCore.Http.ISession session) =>
bool.Parse(Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, "CreateNewRevision"));
public static bool GetCreateLotTravNewRevision(Microsoft.AspNetCore.Http.ISession session) =>
bool.Parse(Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, "CreateLotTravNewRevision"));
public static int GetUserId(Microsoft.AspNetCore.Http.ISession session) =>
int.Parse(GetUserIdValue(session));
public static string GetUserIdValue(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, SESSION_USERID);
public static string GetJWT(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, "JWT");
public static string GetRefreshToken(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, "RefreshToken");
public static string GetAllDocumentsFilterData(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, "AllDocumentsFilterData");
public static string GetSWRFilterData(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, "SWRFilterData");
public static string GetPCRBFilterData(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, "PCRBFilterData");
public static string GetUserName(Microsoft.AspNetCore.Http.ISession session) =>
Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, SESSION_USERNAME);
public static bool GetCanCreatePartsRequest(Microsoft.AspNetCore.Http.ISession session) =>
bool.Parse(Microsoft.AspNetCore.Http.SessionExtensions.GetString(session, CAN_CREATE_PARTS_REQUEST));
public static void SetECNViewOption(Microsoft.AspNetCore.Http.ISession session, string value) =>
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, ECN_VIEW_OPTION, value);
public static void SetSWRFilterData(Microsoft.AspNetCore.Http.ISession session, string value) =>
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, "SWRFilterData", value);
public static void SetPCRBFilterData(Microsoft.AspNetCore.Http.ISession session, string value) =>
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, "PCRBFilterData", value);
public static void SetAllDocumentsFilterData(Microsoft.AspNetCore.Http.ISession session, string value) =>
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, "AllDocumentsFilterData", value);
public static void SetCreateNewRevision(Microsoft.AspNetCore.Http.ISession session, bool value) =>
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, "CreateNewRevision", value.ToString());
public static void SetCreateLotTravNewRevision(Microsoft.AspNetCore.Http.ISession session, bool value) =>
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, "CreateLotTravNewRevision", value.ToString());
public static void SetOOO(Microsoft.AspNetCore.Http.ISession session, bool value) =>
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, OOO, value.ToString());
public static void SetSessionParameters(Microsoft.AspNetCore.Http.ISession session, LoginResult loginResult, LoginModel user) {
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, "JWT", loginResult.AuthTokens.JwtToken);
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, "RefreshToken", loginResult.AuthTokens.RefreshToken);
Microsoft.AspNetCore.Http.SessionExtensions.SetInt32(session, SESSION_USERID, user.UserID);
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, SESSION_USERNAME, user.FullName);
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, IS_ADMIN, user.IsAdmin.ToString());
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, IS_MANAGER, user.IsManager.ToString());
Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, OOO, user.OOO.ToString());
// bool check = user.IsAdmin || Fab2ApprovalSystem.Controllers.PartsRequestController.CanCreatePartsRequest(user.UserID);
// Microsoft.AspNetCore.Http.SessionExtensions.SetString(session, CAN_CREATE_PARTS_REQUEST, check.ToString());
}
#endif
}

View File

@ -4,9 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
#if !NET8
using System.Web.Mvc;
#endif
namespace Fab2ApprovalSystem.Misc {
@ -18,7 +16,7 @@ namespace Fab2ApprovalSystem.Misc {
// check if session is supported
if (GlobalVars.IsUserNameNull(session)) {
if (session[GlobalVars.SESSION_USERNAME] == null) {
// check if a new session id was generated
// this will force MVC to use the standard login redirect, enabling ReturnURL functionality

View File

@ -26,9 +26,6 @@ public class AppSettings {
string ifxContainer,
string ifxDomain,
bool isInfineonDomain,
string? jwtAudience,
string? jwtIssuer,
string? jwtKey,
string lotTempPipeLine,
string mesaTemplateFiles,
string nDriveURL,
@ -71,9 +68,6 @@ public class AppSettings {
IFXContainer = ifxContainer;
IFXDomain = ifxDomain;
IsInfineonDomain = isInfineonDomain;
JwtAudience = jwtAudience;
JwtIssuer = jwtIssuer;
JwtKey = jwtKey;
LotTempPipeLine = lotTempPipeLine;
MesaTemplateFiles = mesaTemplateFiles;
NDriveURL = nDriveURL;
@ -118,9 +112,6 @@ public class AppSettings {
public string IFXContainer { get; }
public string IFXDomain { get; }
public bool IsInfineonDomain { get; }
public string? JwtAudience { get; }
public string? JwtIssuer { get; }
public string? JwtKey { get; }
public string LotTempPipeLine { get; }
public string MesaTemplateFiles { get; }
public string NAContainer { get; }
@ -232,9 +223,6 @@ public class AppSettings {
string? workingDirectoryName = ConfigurationManager.AppSettings["WorkingDirectoryName"]?.ToString();
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
"https://localhost:7255";
string? jwtAudience = ConfigurationManager.AppSettings["JwtAudience"]?.ToString();
string? jwtIssuer = ConfigurationManager.AppSettings["JwtIssuer"]?.ToString();
string? jwtKey = ConfigurationManager.AppSettings["JwtKey"]?.ToString();
result = new(adminNotificationRecepient: adminNotificationRecepient,
apiBaseUrl: apiBaseUrl,
attachmentFolder: attachmentFolder,
@ -254,9 +242,6 @@ public class AppSettings {
ifxContainer: ifxContainer,
ifxDomain: ifxDomain,
isInfineonDomain: Misc.GlobalVars.IS_INFINEON_DOMAIN,
jwtAudience: jwtAudience,
jwtIssuer: jwtIssuer,
jwtKey: jwtKey,
lotTempPipeLine: lotTempPipeLine,
mesaTemplateFiles: Misc.GlobalVars.MesaTemplateFiles,
naContainer: naContainer,

View File

@ -1,37 +0,0 @@
#if NET8
using System;
namespace Fab2ApprovalSystem.Models;
public class HttpException : Exception {
private readonly int httpStatusCode;
public HttpException(int httpStatusCode) {
this.httpStatusCode = httpStatusCode;
}
public HttpException(System.Net.HttpStatusCode httpStatusCode) {
this.httpStatusCode = (int)httpStatusCode;
}
public HttpException(int httpStatusCode, string message) : base(message) {
this.httpStatusCode = httpStatusCode;
}
public HttpException(System.Net.HttpStatusCode httpStatusCode, string message) : base(message) {
this.httpStatusCode = (int)httpStatusCode;
}
public HttpException(int httpStatusCode, string message, Exception inner) : base(message, inner) {
this.httpStatusCode = httpStatusCode;
}
public HttpException(System.Net.HttpStatusCode httpStatusCode, string message, Exception inner) : base(message, inner) {
this.httpStatusCode = (int)httpStatusCode;
}
public int StatusCode { get { return httpStatusCode; } }
}
#endif

View File

@ -3,7 +3,6 @@
public class LoginResult {
public bool IsAuthenticated { get; set; }
public User User { get; set; }
public AuthTokens AuthTokens { get; set; }
}

View File

@ -1,30 +0,0 @@
using System;
namespace Fab2ApprovalSystem.Models;
public class User {
public int UserID { get; set; }
public string LoginID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public bool IsAdmin { get; set; } = false;
public bool IsManager { get; set; } = false;
public bool IsActive { get; set; } = false;
public bool OOO { get; set; } = false;
public DateTime OOOStartDate { get; set; }
public DateTime OOOExpirationDate { get; set; }
public int DelegatedTo { get; set; }
public string GetFullName() =>
$"{FirstName} {LastName}";
public override bool Equals(object? obj) {
User? u = obj as User;
return u is not null && u.UserID == UserID;
}
public override int GetHashCode() =>
UserID.GetHashCode();
}

View File

@ -1,47 +1,43 @@
#if !NET8
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
#endif
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BinaryContentResult.cs" company="SemanticArchitecture">
// http://www.SemanticArchitecture.net pkalkie@gmail.com
// </copyright>
// <summary>
// An ActionResult used to send binary data to the browser.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
#if !NET8
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
using System.IO;
#endif
namespace Fab2ApprovalSystem.PdfGenerator {
using System.IO;
using System.Web;
using System.Web.Mvc;
namespace Fab2ApprovalSystem.PdfGenerator;
/// <summary>
/// An ActionResult used to send binary data to the browser.
/// </summary>
public class BinaryContentResult : ActionResult {
private readonly string contentType;
private readonly byte[] contentBytes;
public class BinaryContentResult : ActionResult {
private readonly string contentType;
private readonly byte[] contentBytes;
public BinaryContentResult(byte[] contentBytes, string contentType) {
this.contentBytes = contentBytes;
this.contentType = contentType;
}
public BinaryContentResult(byte[] contentBytes, string contentType) {
this.contentBytes = contentBytes;
this.contentType = contentType;
}
public override void ExecuteResult(ControllerContext context) {
var response = context.HttpContext.Response;
response.Clear();
response.Cache.SetCacheability(HttpCacheability.Public);
response.ContentType = this.contentType;
#if !NET8
public override void ExecuteResult(ControllerContext context) {
var response = context.HttpContext.Response;
response.Clear();
response.Cache.SetCacheability(HttpCacheability.Public);
response.ContentType = contentType;
using (var stream = new MemoryStream(contentBytes)) {
stream.WriteTo(response.OutputStream);
stream.Flush();
using (var stream = new MemoryStream(this.contentBytes)) {
stream.WriteTo(response.OutputStream);
stream.Flush();
}
}
}
}
#endif
}

View File

@ -1,36 +0,0 @@
using System;
using System.IO;
using System.Threading.Tasks;
#if !NET8
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewEngines;
#endif
#if !NET8
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
#endif
namespace Fab2ApprovalSystem.PdfGenerator;
public class FakeView : IView {
public void Render(ViewContext viewContext, TextWriter writer) {
throw new NotImplementedException();
}
#if NET8
string IView.Path => throw new NotImplementedException();
Task IView.RenderAsync(ViewContext context) => throw new NotImplementedException();
#endif
}

View File

@ -1,59 +0,0 @@
#if !NET8
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Security;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
#endif
#if !NET8
using System;
using System.IO;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
#endif
using System.Text;
namespace Fab2ApprovalSystem.PdfGenerator;
public class HtmlViewRenderer {
public string RenderViewToString(Controller controller, string viewName, object viewData) {
StringBuilder renderedView = new();
#if !NET8
using (StringWriter responseWriter = new(renderedView)) {
HttpResponse fakeResponse = new(responseWriter);
HttpContext fakeContext = new(HttpContext.Current.Request, fakeResponse);
ControllerContext fakeControllerContext = new(new HttpContextWrapper(fakeContext), controller.ControllerContext.RouteData, controller.ControllerContext.Controller);
var oldContext = HttpContext.Current;
HttpContext.Current = fakeContext;
using (var viewPage = new ViewPage()) {
HtmlHelper html = new HtmlHelper(CreateViewContext(responseWriter, fakeControllerContext), viewPage);
html.RenderPartial(viewName, viewData);
HttpContext.Current = oldContext;
}
}
#endif
return renderedView.ToString();
}
#if !NET8
private static ViewContext CreateViewContext(TextWriter responseWriter, ControllerContext fakeControllerContext) {
return new ViewContext(fakeControllerContext, new FakeView(), new ViewDataDictionary(), new TempDataDictionary(), responseWriter);
}
#endif
}

View File

@ -1,56 +0,0 @@
#if !NET8
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
#endif
#if !NET8
using System;
using System.IO;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
#endif
namespace Fab2ApprovalSystem.PdfGenerator;
#if !NET8
public class PdfViewController : Controller {
private readonly HtmlViewRenderer htmlViewRenderer;
private readonly StandardPdfRenderer standardPdfRenderer;
public PdfViewController() {
htmlViewRenderer = new HtmlViewRenderer();
standardPdfRenderer = new StandardPdfRenderer();
}
protected ActionResult ViewPdf(string pageTitle, string viewName, object model) {
// Render the view html to a string.
string htmlText = htmlViewRenderer.RenderViewToString(this, viewName, model);
// Let the html be rendered into a PDF document through iTextSharp.
byte[] buffer = standardPdfRenderer.Render(htmlText, pageTitle);
// Return the PDF as a binary stream to the client.
return new BinaryContentResult(buffer, "application/pdf");
}
protected void SavePdf(string fileName, string viewName, object model) {
// Render the view html to a string.
string htmlText = htmlViewRenderer.RenderViewToString(this, viewName, model);
// Let the html be rendered into a PDF document through iTextSharp.
byte[] buffer = standardPdfRenderer.Render(htmlText, "");
using (FileStream fs = new(fileName, FileMode.Create)) {
fs.Write(buffer, 0, buffer.Length);
}
}
}
#endif

View File

@ -1,102 +1,79 @@
#if !NET8
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
#endif
#if !NET8
using iTextSharp.text;
using iTextSharp.text.pdf;
#endif
namespace Fab2ApprovalSystem.PdfGenerator {
using iTextSharp.text;
using iTextSharp.text.pdf;
#if !NET8
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
#endif
using System;
namespace Fab2ApprovalSystem.PdfGenerator;
/// <summary>
/// This class represents the standard header and footer for a PDF print.
/// application.
/// </summary>
public class PrintHeaderFooter : PdfPageEventHelper {
private PdfContentByte pdfContent;
private PdfTemplate pageNumberTemplate;
private BaseFont baseFont;
private DateTime printTime;
#if !NET8
public string Title { get; set; }
public class PrintHeaderFooter : PdfPageEventHelper {
public override void OnOpenDocument(PdfWriter writer, Document document) {
printTime = DateTime.Now;
baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
pdfContent = writer.DirectContent;
pageNumberTemplate = pdfContent.CreateTemplate(50, 50);
}
private PdfContentByte pdfContent;
private PdfTemplate pageNumberTemplate;
private BaseFont baseFont;
private DateTime printTime;
#endif
public override void OnStartPage(PdfWriter writer, Document document) {
base.OnStartPage(writer, document);
#if NET8
Rectangle pageSize = document.PageSize;
public class PrintHeaderFooter {
if (Title != string.Empty) {
pdfContent.BeginText();
pdfContent.SetFontAndSize(baseFont, 11);
pdfContent.SetRGBColorFill(0, 0, 0);
pdfContent.SetTextMatrix(pageSize.GetLeft(40), pageSize.GetTop(40));
pdfContent.ShowText(Title);
pdfContent.EndText();
}
}
#endif
public override void OnEndPage(PdfWriter writer, Document document) {
base.OnEndPage(writer, document);
public string Title { get; set; }
int pageN = writer.PageNumber;
string text = pageN + " - ";
float len = baseFont.GetWidthPoint(text, 8);
#if !NET8
Rectangle pageSize = document.PageSize;
pdfContent = writer.DirectContent;
pdfContent.SetRGBColorFill(100, 100, 100);
public override void OnOpenDocument(PdfWriter writer, Document document) {
printTime = DateTime.Now;
baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
pdfContent = writer.DirectContent;
pageNumberTemplate = pdfContent.CreateTemplate(50, 50);
}
public override void OnStartPage(PdfWriter writer, Document document) {
base.OnStartPage(writer, document);
Rectangle pageSize = document.PageSize;
if (Title != string.Empty) {
pdfContent.BeginText();
pdfContent.SetFontAndSize(baseFont, 11);
pdfContent.SetRGBColorFill(0, 0, 0);
pdfContent.SetTextMatrix(pageSize.GetLeft(40), pageSize.GetTop(40));
pdfContent.ShowText(Title);
pdfContent.SetFontAndSize(baseFont, 8);
pdfContent.SetTextMatrix(pageSize.Width / 2, pageSize.GetBottom(30));
pdfContent.ShowText(text);
pdfContent.EndText();
pdfContent.AddTemplate(pageNumberTemplate, (pageSize.Width / 2) + len, pageSize.GetBottom(30));
pdfContent.BeginText();
pdfContent.SetFontAndSize(baseFont, 8);
pdfContent.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, printTime.ToString(), pageSize.GetRight(40), pageSize.GetBottom(30), 0);
pdfContent.EndText();
}
public override void OnCloseDocument(PdfWriter writer, Document document) {
base.OnCloseDocument(writer, document);
pageNumberTemplate.BeginText();
pageNumberTemplate.SetFontAndSize(baseFont, 8);
pageNumberTemplate.SetTextMatrix(0, 0);
pageNumberTemplate.ShowText(string.Empty + (writer.PageNumber - 1));
pageNumberTemplate.EndText();
}
}
public override void OnEndPage(PdfWriter writer, Document document) {
base.OnEndPage(writer, document);
int pageN = writer.PageNumber;
string text = pageN + " - ";
float len = baseFont.GetWidthPoint(text, 8);
Rectangle pageSize = document.PageSize;
pdfContent = writer.DirectContent;
pdfContent.SetRGBColorFill(100, 100, 100);
pdfContent.BeginText();
pdfContent.SetFontAndSize(baseFont, 8);
pdfContent.SetTextMatrix(pageSize.Width / 2, pageSize.GetBottom(30));
pdfContent.ShowText(text);
pdfContent.EndText();
pdfContent.AddTemplate(pageNumberTemplate, (pageSize.Width / 2) + len, pageSize.GetBottom(30));
pdfContent.BeginText();
pdfContent.SetFontAndSize(baseFont, 8);
pdfContent.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, printTime.ToString(), pageSize.GetRight(40), pageSize.GetBottom(30), 0);
pdfContent.EndText();
}
public override void OnCloseDocument(PdfWriter writer, Document document) {
base.OnCloseDocument(writer, document);
pageNumberTemplate.BeginText();
pageNumberTemplate.SetFontAndSize(baseFont, 8);
pageNumberTemplate.SetTextMatrix(0, 0);
pageNumberTemplate.ShowText(string.Empty + (writer.PageNumber - 1));
pageNumberTemplate.EndText();
}
#endif
}
#endif

View File

@ -1,24 +1,38 @@
#if !NET8
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
#endif
using System.IO;
namespace Fab2ApprovalSystem.PdfGenerator;
public class StandardPdfRenderer {
private const int HorizontalMargin = 40;
private const int VerticalMargin = 40;
public byte[] Render(string htmlText, string pageTitle) {
byte[] renderedBuffer;
public static byte[] GetPortableDocumentFormatBytes(string pageTitle, string htmlText) {
byte[] results;
using (MemoryStream memoryStream = GetPortableDocumentFormat(pageTitle, htmlText)) {
results = new byte[memoryStream.Position];
memoryStream.Position = 0;
memoryStream.Read(results, 0, results.Length);
}
return results;
}
using (MemoryStream outputMemoryStream = new()) {
#if !NET8
using (Document pdfDocument = new Document(PageSize.A4, HorizontalMargin, HorizontalMargin, VerticalMargin, VerticalMargin)) {
PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDocument, outputMemoryStream);
public static void WritePortableDocumentFormatToFile(string pageTitle, string htmlText, string path) {
using (MemoryStream memoryStream = GetPortableDocumentFormat(pageTitle, htmlText)) {
using (FileStream fileStream = new(path, FileMode.Create)) {
memoryStream.CopyTo(fileStream);
}
}
}
public static MemoryStream GetPortableDocumentFormat(string pageTitle, string htmlText) {
MemoryStream result = new();
using (Document pdfDocument = new Document(PageSize.A4, HorizontalMargin, HorizontalMargin, VerticalMargin, VerticalMargin)) {
using (PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDocument, result)) {
pdfWriter.CloseStream = false;
pdfWriter.PageEvent = new PrintHeaderFooter { Title = pageTitle };
pdfDocument.Open();
@ -27,15 +41,9 @@ public class StandardPdfRenderer {
htmlWorker.Parse(htmlViewReader);
}
}
}
#endif
renderedBuffer = new byte[outputMemoryStream.Position];
outputMemoryStream.Position = 0;
outputMemoryStream.Read(renderedBuffer, 0, renderedBuffer.Length);
}
return renderedBuffer;
return result;
}
}

View File

@ -20,7 +20,6 @@ using System.Configuration;
namespace Fab2ApprovalSystem.Utilities;
#if !NET8
public class FileUtilities<T> : Controller // <T> => System.Web.Mvc.FileContentResult
{
@ -29,22 +28,14 @@ public class FileUtilities<T> : Controller // <T> => System.Web.Mvc.FileContentR
var result = File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, pathToFile);
return (T)Convert.ChangeType(result, typeof(T));
}
#endif
#if NET8
#else
public class FileUtilities<T> {
#endif
public byte[] GetFile(string s) {
#if !NET8
FileStream fs = System.IO.File.OpenRead(s);
#endif
#if NET8
#else
FileStream fs = File.OpenRead(s);
#endif
byte[] data = new byte[fs.Length];

View File

@ -34,7 +34,7 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
@if (@GlobalVars.IsAdmin(Session))
@if ((bool)@Session[GlobalVars.IS_ADMIN])
{
<li>@Html.ActionLink("Admin", "Index", "Admin")</li>
}

View File

@ -144,7 +144,7 @@
</div>
<div class="col-sm-9">
@Html.TextBoxFor(model => model.OwnerName, new { id = "txtOwner", @class = "k-textbox", Readonly = "Readonly", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOwner" class="linkbutton edit" title="Re-assign Owner"></a>
}
@ -200,7 +200,7 @@
<label class="control-label pull-right">Export Control:</label>
</div>
<div class="col-sm-9">
@if (ViewBag.IsOriginator == "true" || (GlobalVars.IsAdmin(Session)))
@if (ViewBag.IsOriginator == "true" || ((bool)Session[GlobalVars.IS_ADMIN]))
{
@(Html.Kendo().DropDownList()
.Name("IsITAR")

View File

@ -329,7 +329,7 @@
columns.Bound(a => a.Gating).Width("50px");
columns.Bound(a => a.DueDate).Width("50px").Format("{0:MM/dd/yy}").Width("150px");
if (GlobalVars.IsAdminValueNotNull(Session))
if (Session[GlobalVars.IS_ADMIN] != null)
columns.Command(c => c.Custom("Edit").Click("EditMeetingActionItem")).Width("70px");
//columns.Command(c => c.Destroy()).Width("40px");

View File

@ -128,7 +128,7 @@
</div>
<div class="col-sm-9">
@Html.TextBoxFor(model => model.OwnerName, new { id = "txtOwner", @class = "k-textbox", Readonly = "Readonly", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOwner" class="linkbutton edit" title="Re-assign Owner"></a>
}

View File

@ -1465,7 +1465,7 @@
Additional Approvers
</button>
}
else if (((GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))) && Model.ClosedDate == null)
else if ((((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))) && Model.ClosedDate == null)
{
<button class="k-textbox" data-toggle="modal" id="additionalApprovers">
Additional Approvers
@ -1475,7 +1475,7 @@
</div>
<div class="panel-body bg-warning">
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
@if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")
@ -2180,7 +2180,7 @@
var currentD5D6AttachmentLinks;
var currentD7AttachmentLinks;
var currentRejectingSection = '';
var currentUserId = @(GlobalVars.GetUserId(Session))
var currentUserId = @((int)Session[GlobalVars.SESSION_USERID])
var currentRequestor = @(Model.RequestorID);

View File

@ -44,7 +44,7 @@
<div class="panel panel-default center-block" data-spy="affix">
<input type="button" value="Back to CA List" class="btn btn-primary btn-xs" id="CAList" />
<input type="button" value="Section Approval Log" class="btn btn-primary btn-xs" id="ShowSectionApprovalLog" />
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<input type="button" value="Unlock Document" class="btn btn-primary btn-xs" id="UnlockDocumentBtn" onclick="UnlockDocument()" />
}

View File

@ -52,7 +52,7 @@
}
<input type="button" value="Approval Log History" class="btn btn-primary btn-xs" id="ApprovalLogHistoryData" />
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<input type="button" value="Unlock Document" class="btn btn-primary btn-xs" id="UnlockDocumentBtn" onclick="UnlockDocument()" />
}
@ -137,7 +137,7 @@
<label class="control-label col-sm-4">Originator Name:</label>
<div class="col-sm-8">
@Html.TextBoxFor(model => model.OriginatorName, new { id = "txtOriginatorName", @class = "k-textbox", disabled = "disabled", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}
@ -892,9 +892,9 @@
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
<label class="control-label col-sm-4">Originator Name:</label>
<div class="col-sm-8">
@Html.TextBoxFor(model => model.OriginatorName, new { id = "txtOriginatorName", @class = "k-textbox", disabled = "disabled", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}

View File

@ -90,7 +90,7 @@
<label class="control-label col-sm-4">Originator Name:</label>
<div class="col-sm-8">
@Html.TextBoxFor(model => model.OriginatorName, new { id = "txtOriginatorName", @class = "k-textbox", disabled = "disabled", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}
@ -785,9 +785,9 @@
<div class="panel-body bg-warning">
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")

View File

@ -173,7 +173,7 @@
<label class="control-label col-sm-4">Originator Name:</label>
<div class="col-sm-6 col-sm-8">
@Html.TextBoxFor(model => model.OriginatorName, new { id = "txtOriginatorName", @class = "k-textbox", disabled = "disabled", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}
@ -367,7 +367,7 @@
@if (
(ViewBag.IsOriginator == "true" && Model.IsTECN && Model.CloseDate != null && !Model.ExpirationProcessed && !Model.ExpirationInProgress && !Model.CancellationApproved && !Model.CancellationInProgress && Model.ConversionApprovalInProgress == false && (Model.ExpirationDate >= DateTime.Today || Model.ExtensionDate >= DateTime.Today))
||
(Model.IsTECN && GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated) && Model.CloseDate != null && !Model.ExpirationProcessed && !Model.ExpirationInProgress && !Model.CancellationApproved && !Model.CancellationInProgress && Model.ConversionApprovalInProgress == false && (Model.ExpirationDate >= DateTime.Today || Model.ExtensionDate >= DateTime.Today))
(Model.IsTECN && (bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated) && Model.CloseDate != null && !Model.ExpirationProcessed && !Model.ExpirationInProgress && !Model.CancellationApproved && !Model.CancellationInProgress && Model.ConversionApprovalInProgress == false && (Model.ExpirationDate >= DateTime.Today || Model.ExtensionDate >= DateTime.Today))
)
{
@(Html.Kendo().DatePickerFor(model => model.ExtensionDate)
@ -980,7 +980,7 @@
Additional Approvers
</button>
}
else if ((ViewBag.IsOriginator == "true" || (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))) && Model.CloseDate == null)
else if ((ViewBag.IsOriginator == "true" || ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))) && Model.CloseDate == null)
{
<button class="k-textbox" data-toggle="modal" id="additionalApprovers">
Additional Approvers
@ -994,9 +994,9 @@
<div class="panel-body bg-warning">
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")

View File

@ -52,7 +52,7 @@
}
<input type="button" value="Approval Log History" class="btn btn-primary btn-xs" id="ApprovalLogHistoryData" />
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<input type="button" value="Unlock Document" class="btn btn-primary btn-xs" id="UnlockDocumentBtn" onclick="UnlockDocument()" />
}
@ -149,7 +149,7 @@
<label class="control-label col-sm-4">Originator Name:</label>
<div class="col-sm-8">
@Html.TextBoxFor(model => model.OriginatorName, new { id = "txtOriginatorName", @class = "k-textbox", disabled = "disabled", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}
@ -895,9 +895,9 @@
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")
@ -999,7 +999,7 @@
@{
if (ViewBag.TrainingID != 0)
{
Html.RenderAction("ViewTrainingPartial", "Training", new { trainingId = Convert.ToInt32(ViewBag.TrainingID), userID = Convert.ToInt32(GlobalVars.GetUserId(Session)) });
Html.RenderAction("ViewTrainingPartial", "Training", new { trainingId = Convert.ToInt32(ViewBag.TrainingID), userID = Convert.ToInt32((int)Session[GlobalVars.SESSION_USERID]) });
}

View File

@ -33,7 +33,7 @@
</div>
<div id="alltasklistdiv" class="k-content" style="font-size: 11px;">
@if (GlobalVars.IsAdmin(Session))
@if ((bool)Session[GlobalVars.IS_ADMIN])
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("alltasklist")

View File

@ -38,7 +38,7 @@
columns.Bound(l => l.D8DueDate).Format("{0:MM/dd/yy}");
columns.Bound(l => l.NextDueDate).Format("{0:MM/dd/yy}");
columns.Bound(l => l.ClosedDate).Format("{0:MM/dd/yy}");
if (GlobalVars.IsAdmin(Session))
if ((bool)Session[GlobalVars.IS_ADMIN])
columns.Template(t => { }).HeaderTemplate("").ClientTemplate(@"<a href='javascript: void(0)' class='abutton delete' onclick='deleteRowCA(this)' title='button delete'>button delete</a>");
})

View File

@ -33,7 +33,7 @@
</div>
<div id="ecnTasklistdiv" class="k-content" style="font-size: 11px;">
@if (GlobalVars.IsAdmin(Session))
@if ((bool)Session[GlobalVars.IS_ADMIN])
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("ecnTasklist")

View File

@ -26,7 +26,7 @@
<ul class="nav navbar-nav" id="myTab">
<li><a href=@Url.Action("Index", "Home", new {tabName = "MyTasks"})>My Tasks</a></li>
<li><a href=@Url.Action("Index", "Home", new { tabName = "AllTasks" })>All Documents</a></li>
@*<li><a href=@Url.Action("ViewMyTrainingAssignments", "Training", new { userID = GlobalVars.GetUserId(Session) })>My Training</a></li>*@
@*<li><a href=@Url.Action("ViewMyTrainingAssignments", "Training", new { userID = (int)Session[GlobalVars.SESSION_USERID] })>My Training</a></li>*@
@*<li><a href=@Url.Action("SpecialWorkRequestList", "Home", new { tabName = "AllTasks" })>Special Work Requests</a></li>*@
@*<li><a href="file:////temirwfp001.irworld.irf.com/UserData/QA/CommonRO/Projects/AVI Tool/">AVI Tool</a></li>*@
<li class="dropdown">
@ -44,7 +44,7 @@
@*<div class="form-group">
<input type="text" class="form-control" placeholder="Search" style="font-size: 11px">
</div>*@
@if (!GlobalVars.IsOOO(Session))
@if (!(bool)Session[GlobalVars.OOO])
{
<button class="btn btn-default btn-primary" data-toggle="modal" id="OOO">Out Of Office</button>
}
@ -170,7 +170,7 @@
</div>
<div id="alltasklistdiv" class="k-content" style="font-size: 11px;">
@if (GlobalVars.IsAdmin(Session))
@if ((bool)Session[GlobalVars.IS_ADMIN])
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("alltasklist")
@ -427,7 +427,7 @@
var issueID="";
var docType = "";
var submitdate = "";
var userName = '@GlobalVars.GetUserName(Session)';
var userName = "@Session[@GlobalVars.SESSION_USERNAME].ToString()";
$(document).ready(function () {
})
@ -450,7 +450,7 @@
window.location.href = url.replace('__id__', issueID);
})*@
var userid = @GlobalVars.GetUserId(Session);
var userid = @Session[@GlobalVars.SESSION_USERID].ToString()
$("#IncludeAllDocuments").on("click", function () {

View File

@ -34,7 +34,7 @@
</div>
<div id="LotDispoTasklistdiv" class="k-content" style="font-size: 11px;">
@if (GlobalVars.IsAdmin(Session))
@if ((bool)Session[GlobalVars.IS_ADMIN])
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("LotDispoTasklist")

View File

@ -32,7 +32,7 @@
<table class="pull-right">
<tr>
<td class="pull-right">
@if (GlobalVars.IsAdmin(Session))
@if ((bool)Session[GlobalVars.IS_ADMIN])
{
@(Html.Kendo().Upload()
.Name("AddQDBFlag")
@ -45,7 +45,7 @@
}
</td>
<td class="pull-right">
@if (GlobalVars.IsAdmin(Session))
@if ((bool)Session[GlobalVars.IS_ADMIN])
{
@(Html.Kendo().Upload()
.Name("RemoveQDBFlag")
@ -72,7 +72,7 @@
</div>
<div id="mrbTasklistdiv" class="k-content" style="font-size: 11px;">
@if (GlobalVars.IsAdmin(Session))
@if ((bool)Session[GlobalVars.IS_ADMIN])
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("mrbTasklist")

View File

@ -175,7 +175,7 @@
</div>
@if (GlobalVars.GetCanCreatePartsRequest(Session) && !GlobalVars.IsAdmin(Session))
@if (Convert.ToBoolean(Session[GlobalVars.CAN_CREATE_PARTS_REQUEST]) && !Convert.ToBoolean(Session[GlobalVars.IS_ADMIN]))
{
<br /><br />
<div class="panel-heading" style="background-color:beige">

View File

@ -55,11 +55,11 @@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
@*<li>@Html.ActionLink("Reports", "Index", "Reports")</li>*@
@if (@GlobalVars.IsAdmin(Session))
@if ((bool)@Session[GlobalVars.IS_ADMIN])
{
<li>@Html.ActionLink("Admin", "Index", "Admin")</li>
}
@if (GlobalVars.IsManager(Session))
@if ((bool)@Session[GlobalVars.IS_MANAGER])
{
<li>@Html.ActionLink("Manager", "Index", "Manager")</li>
}
@ -83,10 +83,10 @@
@*<li><a href=@Url.Action("Create", "LotDisposition")>Lot Dispostion</a></li>*@
@*<li><a href=@Url.Action("Create", "MRB")>Create MRB</a></li>*@
<li><a href=@Url.Action("Create", "ECN")>Create ECN/TECN</a></li>
@if (!string.IsNullOrWhiteSpace(GlobalVars.GetJWT(Session))) {
string jwt = GlobalVars.GetJWT(Session);
@if (!string.IsNullOrWhiteSpace(Session["JWT"].ToString())) {
string jwt = Session["JWT"].ToString();
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
string refreshToken = GlobalVars.GetRefreshToken(Session);
string refreshToken = Session["RefreshToken"].ToString();
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
"https://localhost:7255";
@ -106,7 +106,7 @@
@*<li><a href=@Url.Action("Create", "ChangeControl")>Create PCR</a></li>*@
<li><a href=@Url.Action("Create", "Audit")>Create Audit</a></li>
<li><a href=@Url.Action("Create", "CorrectiveAction")>Create Corrective Action</a></li>
@*@if (GlobalVars.GetCanCreatePartsRequest(Session))
@*@if (Convert.ToBoolean(Session[GlobalVars.CAN_CREATE_PARTS_REQUEST]))
{
<li><a href=@Url.Action("Create", "PartsRequest")>Create New/Repair Spare Parts Request</a></li>
}*@
@ -118,7 +118,7 @@
@*<div class="form-group">
<input type="text" class="form-control" placeholder="Search" style="font-size: 11px">
</div>*@
@if (!GlobalVars.IsOOO(Session))
@if (!(bool)Session[GlobalVars.OOO])
{
<button class="btn btn-default btn-primary" data-toggle="modal" id="OOO">Out Of Office</button>
}
@ -144,9 +144,9 @@
menu.Add().Text("My Training").Action("ViewMyTrainingAssignments", "Training");
menu.Add().Text("Training Reports").Action("TrainingReports", "Training");
menu.Add().Text("All Documents").Action("AllDocuments", "Home");
string jwt = GlobalVars.GetJWT(Session);
string jwt = Session["JWT"].ToString();
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
string refreshToken = GlobalVars.GetRefreshToken(Session);
string refreshToken = Session["RefreshToken"].ToString();
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
"https://localhost:7255";
@ -279,7 +279,7 @@
var issueID="";
var docType = "";
var submitdate = "";
var userName = '@GlobalVars.GetUserName(Session)';
var userName = "@Session[@GlobalVars.SESSION_USERNAME].ToString()";
$(document).ready(function () {
})
@ -302,7 +302,7 @@
window.location.href = url.replace('__id__', issueID);
})*@
var userid = @GlobalVars.GetUserId(Session);
var userid = @Session[@GlobalVars.SESSION_USERID].ToString()
$("#IncludeAllDocuments").on("click", function () {

View File

@ -41,10 +41,10 @@
@(Html.Kendo().DropDownList()
.Name("OriginatorID")
.BindTo(new SelectList(ViewBag.OriginatorList, "OriginatorID", "OriginatorName"))
.Value(@GlobalVars.GetUserIdValue(Session))
.Value(@Session[GlobalVars.SESSION_USERID].ToString())
)
@*@Html.TextBoxFor(model => model.OriginatorID, new { id = @GlobalVars.USER_ID, Value = @GlobalVars.GetUserName(Session);, @class = "k-textbox" })*@
@*@Html.TextBoxFor(model => model.OriginatorID, new { id = @GlobalVars.USER_ID, Value = @Session[GlobalVars.SESSION_USERNAME].ToString();, @class = "k-textbox" })*@
</div>
</div>

View File

@ -478,9 +478,9 @@
<div class="panel-body bg-warning">
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")

View File

@ -421,7 +421,7 @@
<div class="panel-body bg-warning">
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
@if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")

View File

@ -133,7 +133,7 @@
</div>
<div class="col-sm-9">
@Html.TextBoxFor(model => model.OriginatorName, new { id = "txtOriginatorName", @class = "k-textbox", Readonly = "Readonly", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}
@ -901,9 +901,9 @@
<div class="panel-body bg-warning">
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")

View File

@ -125,7 +125,7 @@
</div>
<div class="col-sm-9">
@Html.TextBoxFor(model => model.Originator, new { @class = "k-textbox", Readonly = "Readonly", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}

View File

@ -166,7 +166,7 @@
</div>
<div class="col-sm-9">
@Html.TextBoxFor(model => model.Originator, new { @class = "k-textbox", Readonly = "Readonly", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}

View File

@ -146,7 +146,7 @@
</div>
<div class="col-sm-9">
@Html.TextBoxFor(model => model.Originator, new { @class = "k-textbox", Readonly = "Readonly", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}

View File

@ -152,7 +152,7 @@
</div>
<div class="col-sm-9">
@Html.TextBoxFor(model => model.OriginatorName, new { id = "txtOriginatorName", @class = "k-textbox", Readonly = "Readonly", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}
@ -818,7 +818,7 @@
</div>
<div class="panel-heading">
@if ((GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated)))
@if (((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated)))
{
<button class="btn btn-warning btn-xs" data-toggle="modal" id="additionalApprovers" style="font-size:x-small">
Additional Approvers
@ -839,9 +839,9 @@
<div class="panel-body bg-warning">
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")

View File

@ -196,7 +196,7 @@
</div>
<div class="col-sm-9">
@Html.TextBoxFor(model => model.OriginatorName, new { id = "txtOriginatorName", @class = "k-textbox", Readonly = "Readonly", style = "background-color:lightblue" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="javascript:undefined" id="lnkReassignOriginator" class="linkbutton edit" title="Re-assign Originator"></a>
}

View File

@ -929,9 +929,9 @@
<div class="panel-body bg-warning">
<div class="col-sm-offset-0">
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.ApproversListViewModel>()
.Name("ApproversList")
@ -1711,7 +1711,7 @@
$("#UploadWRAttchmentRev").on('click', function (e) {
e.preventDefault();
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
wrAttachmentOperation = "Add";
if (model == "true") {
$("#WinWorkReqAttRevComments").modal('show');
@ -1787,7 +1787,7 @@
data.RevisionComments = $("#revisionWRAttachComments").val();
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
if (model == "true") {
var urlString = '/LotTraveler/UpdateWorkRequestAttachmentRevision';
$.ajax({
@ -1851,7 +1851,7 @@
function on_WorkReqAttachmentsGridSuccess() {
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
if (model == "true") {
$.ajax({
@ -1887,7 +1887,7 @@
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
currentWrkReqAttachID = dataItem.ID;
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
if (model == "true") {
$("#WinWorkReqAttRevComments").modal('show');
@ -1910,7 +1910,7 @@
if (confirm("Do you really wish to delete the attachment record")) {
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
if (model == "true") {
$("#WinWorkReqAttRevComments").modal('show');
}
@ -2009,7 +2009,7 @@
if (confirm("Do you really wish to delete the record?")) {
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
if (model == "true") {
$("#WinHoldStepRevisionComments").modal("show");
}
@ -2180,7 +2180,7 @@
else {
// save
$("#AddHoldStepForm").modal('hide');
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
if (model == "true") {
$("#WinHoldStepRevisionComments").modal("show");
}
@ -2451,7 +2451,7 @@
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
currentHoldStepID = dataItem.ID;
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
if (model == "true") {
$("#WinHoldStepAttRevComments").modal('show');
@ -2769,7 +2769,7 @@
return;
}
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = '@Session["CreateNewRevision"]';
$('#submitRevisionComments').attr("disabled", false);
@ -2919,7 +2919,7 @@
if (confirm("Do you really wish to delete?")) {
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = '@Session["CreateNewRevision"]';
if (model == "true")
$("#WinEPIRevisionComments").modal('show');
else {
@ -2968,7 +2968,7 @@
var Quantity = $("#txtEPiQuantity").val();
$("#EPIForm").modal('hide');
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = '@Session["CreateNewRevision"]';
if (model == "true")
$("#WinEPIRevisionComments").modal('show');

View File

@ -118,7 +118,7 @@
function SetDocType(e) {
var model = '@GlobalVars.GetCreateNewRevision(Session)';
var model = "@Session["CreateNewRevision"]";
if (model == "true") {
$.ajax({

View File

@ -464,7 +464,7 @@
</td>
<td width="33%">
<div class="text-center">
@if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
@if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
<a class="k-button" href="javascript: void(0)" id="addMRBFlagAndHoldToSPN" style="padding-left: 10px;">
Add MRB Flag/Hold to SPN

View File

@ -34,7 +34,7 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
@if (@GlobalVars.IsManager(Session))
@if ((bool)@Session[GlobalVars.IS_MANAGER])
{
<li>@Html.ActionLink("Manager", "Index", "Manager")</li>
}

View File

@ -42,8 +42,8 @@
@*<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>*@
@if (GlobalVars.IsAdminValueNotNull(Session)) {
if (GlobalVars.IsAdmin(Session) && (Request.IsAuthenticated))
@if (Session[GlobalVars.IS_ADMIN] != null) {
if ((bool)Session[GlobalVars.IS_ADMIN] && (Request.IsAuthenticated))
{
<li>@Html.ActionLink("Admin", "Index", "Admin")</li>
}

View File

@ -74,12 +74,12 @@ else
}
</style>
<div id="cover-spin"></div>
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<a href="/Training/ViewTrainings" class="btn btn-primary">Back To Trainings</a>
}
@Html.ActionLink("Go to ECN", "ReadOnly", "ECN", new { IssueID = Convert.ToInt32(ViewBag.ECNNumber) }, new { @class = "btn btn-primary" })
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<button class="btn btn-primary" id="openAddUserBtn">Add User</button>
<button class="btn btn-primary" id="openAddGroupBtn">Add Group</button>
@ -98,7 +98,7 @@ else
<th>
@Html.DisplayNameFor(model => model.status)
</th>
@if (GlobalVars.IsAdminValueNotNull(Session))
@if (Session[GlobalVars.IS_ADMIN] != null)
{
<th>
@ -130,7 +130,7 @@ else
<td>Incomplete</td>
}
<td>
@if (GlobalVars.IsAdminValueNotNull(Session) && item.status != true)
@if (Session[GlobalVars.IS_ADMIN] != null && item.status != true)
{
<button class="btn btn-primary" onclick="DeleteAssignment(@item.ID)">Delete</button>
@ -138,7 +138,7 @@ else
}
</td>
<td>
@if (GlobalVars.IsAdminValueNotNull(Session) && item.status != true)
@if (Session[GlobalVars.IS_ADMIN] != null && item.status != true)
{
<button id="ReminderButton" class="btn btn-primary" onclick="SendReminder(@item.UserID, @item.ID, @Convert.ToInt32(ViewBag.ECNNumber))">Remind</button>

View File

@ -18,7 +18,7 @@
</tr>
@foreach (var item in Model) {
if (item.UserID.ToString() == GlobalVars.GetUserIdValue(Session) || GlobalVars.IsAdminValueNotNull(Session))
if (item.UserID.ToString() == Session[GlobalVars.SESSION_USERID].ToString() || Session[GlobalVars.IS_ADMIN] != null)
{
<tr>
<td>

View File

@ -137,7 +137,7 @@
<td>
@Html.ActionLink("View", "ViewTrainingAssignments", new { trainingID = item.TrainingID }, new { @class = "btn btn-primary" })
</td>
@if (GlobalVars.IsAdmin(Session))
@if ((bool)Session[GlobalVars.IS_ADMIN] == true)
{
<td>
@Html.ActionLink("Delete", "DeleteTrainingByID", new { trainingId = item.TrainingID }, new { @class = "btn btn-primary" })

View File

@ -41,7 +41,6 @@ stages:
- script: |
mklink /J ".vscode\.UserSecrets" "%AppData%\Microsoft\UserSecrets\f2da5035-aba9-4676-9f8d-d6689f84663d"
mklink /J "Controllers" "..\Fab2ApprovalSystem\Controllers"
mklink /J "DMO" "..\Fab2ApprovalSystem\DMO"
mklink /J "Jobs" "..\Fab2ApprovalSystem\Jobs"
mklink /J "JobSchedules" "..\Fab2ApprovalSystem\JobSchedules"
@ -149,7 +148,6 @@ stages:
- script: |
mklink /J ".vscode\.UserSecrets" "%AppData%\Microsoft\UserSecrets\f2da5035-aba9-4676-9f8d-d6689f84663d"
mklink /J "Controllers" "..\Fab2ApprovalSystem\Controllers"
mklink /J "DMO" "..\Fab2ApprovalSystem\DMO"
mklink /J "Jobs" "..\Fab2ApprovalSystem\Jobs"
mklink /J "JobSchedules" "..\Fab2ApprovalSystem\JobSchedules"

View File

@ -48,7 +48,6 @@ stages:
- script: |
mklink /J ".vscode\.UserSecrets" "%AppData%\Microsoft\UserSecrets\f2da5035-aba9-4676-9f8d-d6689f84663d"
mklink /J "Controllers" "..\Fab2ApprovalSystem\Controllers"
mklink /J "DMO" "..\Fab2ApprovalSystem\DMO"
mklink /J "Jobs" "..\Fab2ApprovalSystem\Jobs"
mklink /J "JobSchedules" "..\Fab2ApprovalSystem\JobSchedules"
@ -156,7 +155,6 @@ stages:
- script: |
mklink /J ".vscode\.UserSecrets" "%AppData%\Microsoft\UserSecrets\f2da5035-aba9-4676-9f8d-d6689f84663d"
mklink /J "Controllers" "..\Fab2ApprovalSystem\Controllers"
mklink /J "DMO" "..\Fab2ApprovalSystem\DMO"
mklink /J "Jobs" "..\Fab2ApprovalSystem\Jobs"
mklink /J "JobSchedules" "..\Fab2ApprovalSystem\JobSchedules"