Tasks 184281, 184799, 184800, 184801 and 184802

Align .editorconfig files

Move Controller logic to DMO classes

GlobalVars.AppSettings = Models.AppSettings.GetFromConfigurationManager();

Question EditorConfig
Project level editorconfig
Format White Spaces
AppSetting when EnvironmentVariable not set
Corrective Actions Tests
Schedule Actions Tests
DMO Tests
Controller Tests

Get ready to use VSCode IDE
This commit is contained in:
2024-12-04 11:58:13 -07:00
parent 538b1f817e
commit b1c6903c1c
150 changed files with 29146 additions and 33456 deletions

View File

@ -1,4 +1,7 @@
using Excel;
#if !NET8
using Excel;
using System;
using System.Collections.Generic;
using System.Data;
@ -6,18 +9,15 @@ using System.IO;
using System.Linq;
using System.Web;
namespace Fab2ApprovalSystem.Misc
{
public class ExcelData
{
namespace Fab2ApprovalSystem.Misc {
public class ExcelData {
string _path;
public ExcelData(string path)
{
public ExcelData(string path) {
_path = path;
}
public IExcelDataReader getExcelReader()
{
public IExcelDataReader getExcelReader() {
// ExcelDataReader works with the binary Excel file, so it needs a FileStream
// to get started. This is how we avoid dependencies on ACE or Interop:
@ -25,27 +25,21 @@ namespace Fab2ApprovalSystem.Misc
// We return the interface, so that
IExcelDataReader reader = null;
try
{
if (_path.EndsWith(".xls"))
{
try {
if (_path.EndsWith(".xls")) {
reader = ExcelReaderFactory.CreateBinaryReader(stream);
}
if (_path.EndsWith(".xlsx"))
{
if (_path.EndsWith(".xlsx")) {
reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
}
return reader;
}
catch (Exception)
{
} catch (Exception) {
throw;
}
}
public class ExcelLotInfo
{
public class ExcelLotInfo {
public string LotNo { get; set; }
public string LotDispo { get; set; }
}
@ -54,57 +48,44 @@ namespace Fab2ApprovalSystem.Misc
///
/// </summary>
/// <returns></returns>
public IEnumerable<ExcelLotInfo> ReadData()
{
public IEnumerable<ExcelLotInfo> ReadData() {
var r = new List<ExcelLotInfo>();
var excelData = new ExcelData(_path);
var lots = excelData.getData().ToList();
int lotDispoColumnIndex = -1;
foreach (DataColumn col in lots[0].Table.Columns)
{
if (col.ColumnName.ToLower().Contains("dispo"))
{
foreach (DataColumn col in lots[0].Table.Columns) {
if (col.ColumnName.ToLower().Contains("dispo")) {
lotDispoColumnIndex = col.Ordinal;
break;
}
}
foreach (var row in lots)
{
foreach (var row in lots) {
string temValue = row[0].ToString();
if (temValue.Trim().Length > 0 && temValue.Trim().Length <= 10 )
{
r.Add(new ExcelLotInfo()
{
if (temValue.Trim().Length > 0 && temValue.Trim().Length <= 10) {
r.Add(new ExcelLotInfo() {
LotNo = row[0].ToString(),
LotDispo = (lotDispoColumnIndex >= 0 ? row[lotDispoColumnIndex].ToString() : "")
});
}
}
return r;
}
public IEnumerable<string> ReadQDBFlagData()
{
public IEnumerable<string> ReadQDBFlagData() {
List<string> s = new List<string>();
// We return the interface, so that
var excelData = new ExcelData(_path);
//var albums = excelData.getData("Sheet1");
var lotNos = excelData.getData();
foreach (var row in lotNos)
{
foreach (var row in lotNos) {
string temValue = row[0].ToString();
if (temValue.Trim().Length > 0 && temValue.Trim().Length == 9)
{
if (row[2].ToString().ToUpper() != "YES" && row[2].ToString().ToUpper() != "NO")
{
if (temValue.Trim().Length > 0 && temValue.Trim().Length == 9) {
if (row[2].ToString().ToUpper() != "YES" && row[2].ToString().ToUpper() != "NO") {
throw new Exception("Invalid data in the file");
}
else
{
} else {
s.Add(row[0].ToString() + "~" + row[1] + "~" + row[2]);
}
}
@ -113,23 +94,12 @@ namespace Fab2ApprovalSystem.Misc
return s;
}
//public IEnumerable<DataRow> getData(string sheet, bool firstRowIsColumnNames = true)
//{
// var reader = this.getExcelReader();
// reader.IsFirstRowAsColumnNames = firstRowIsColumnNames;
// var workSheet = reader.AsDataSet().Tables[sheet];
// var rows = from DataRow a in workSheet.Rows select a;
// return rows;
//}
/// <summary>
///
/// </summary>
/// <param name="firstRowIsColumnNames"></param>
/// <returns></returns>
public IEnumerable<DataRow> getData(bool firstRowIsColumnNames = true)
{
public IEnumerable<DataRow> getData(bool firstRowIsColumnNames = true) {
var reader = this.getExcelReader();
reader.IsFirstRowAsColumnNames = firstRowIsColumnNames;
var workSheet = reader.AsDataSet().Tables[0];
@ -138,7 +108,7 @@ namespace Fab2ApprovalSystem.Misc
}
}
}
}
#endif