Refactor code to .NET8
This commit is contained in:
@@ -21,7 +21,7 @@ public class BaseCalc
|
|||||||
public bool IsFormulaCorrect()
|
public bool IsFormulaCorrect()
|
||||||
{
|
{
|
||||||
// check left side of expression
|
// check left side of expression
|
||||||
if (!ResultCode.StartsWith("[") || !ResultCode.EndsWith("]"))
|
if (!ResultCode.StartsWith('[') || !ResultCode.EndsWith(']'))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ public class LayersController : Controller
|
|||||||
.ToList();
|
.ToList();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!importWorkerLayers.Any())
|
if (importWorkerLayers.Count == 0)
|
||||||
{
|
{
|
||||||
_logsController.AddEntry(new LogEntry
|
_logsController.AddEntry(new LogEntry
|
||||||
{
|
{
|
||||||
@@ -346,7 +346,7 @@ public class LayersController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
string[] processTypes =
|
string[] processTypes =
|
||||||
{
|
[
|
||||||
"T3-SingleSource",
|
"T3-SingleSource",
|
||||||
"T3-SourceYearSummary",
|
"T3-SourceYearSummary",
|
||||||
"T3-MultiSourceSummary", // AA
|
"T3-MultiSourceSummary", // AA
|
||||||
@@ -354,7 +354,7 @@ public class LayersController : Controller
|
|||||||
"T4-SingleSource",
|
"T4-SingleSource",
|
||||||
"T1-R1",
|
"T1-R1",
|
||||||
"T4-R2"
|
"T4-R2"
|
||||||
};
|
];
|
||||||
|
|
||||||
foreach (var type in processTypes)
|
foreach (var type in processTypes)
|
||||||
{
|
{
|
||||||
@@ -378,7 +378,7 @@ public class LayersController : Controller
|
|||||||
.OrderBy(x => x.CreatedAt)
|
.OrderBy(x => x.CreatedAt)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (!processWorkerLayers.Any())
|
if (processWorkerLayers.Count == 0)
|
||||||
{
|
{
|
||||||
_logsController.AddEntry(new LogEntry
|
_logsController.AddEntry(new LogEntry
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GoogleDriveHelper
|
|||||||
{
|
{
|
||||||
public DriveService? Service { get; private set; }
|
public DriveService? Service { get; private set; }
|
||||||
private const string ApplicationName = "Diuna";
|
private const string ApplicationName = "Diuna";
|
||||||
private static readonly string[] Scopes = { DriveService.Scope.Drive };
|
private static readonly string[] Scopes = [DriveService.Scope.Drive];
|
||||||
public GoogleDriveHelper()
|
public GoogleDriveHelper()
|
||||||
{
|
{
|
||||||
InitializeService();
|
InitializeService();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GoogleSheetsHelper
|
|||||||
{
|
{
|
||||||
public SheetsService? Service { get; private set; }
|
public SheetsService? Service { get; private set; }
|
||||||
private const string ApplicationName = "Diuna";
|
private const string ApplicationName = "Diuna";
|
||||||
private static readonly string[] Scopes = { SheetsService.Scope.Spreadsheets };
|
private static readonly string[] Scopes = [SheetsService.Scope.Spreadsheets];
|
||||||
public GoogleSheetsHelper()
|
public GoogleSheetsHelper()
|
||||||
{
|
{
|
||||||
InitializeService();
|
InitializeService();
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ var app = builder.Build();
|
|||||||
|
|
||||||
app.Use(async (context, next) =>
|
app.Use(async (context, next) =>
|
||||||
{
|
{
|
||||||
var token = context.Request.Headers["Authorization"].ToString();
|
var token = context.Request.Headers.Authorization.ToString();
|
||||||
if (token.Length > 0 && !context.Request.Path.ToString().Contains("getForPowerBI")) {
|
if (token.Length > 0 && !context.Request.Path.ToString().Contains("getForPowerBI")) {
|
||||||
var handler = new JwtSecurityTokenHandler();
|
var handler = new JwtSecurityTokenHandler();
|
||||||
var data = handler.ReadJwtToken(token.Split(' ')[1]);
|
var data = handler.ReadJwtToken(token.Split(' ')[1]);
|
||||||
context.Request.Headers.Add("UserId", new Microsoft.Extensions.Primitives.StringValues(data.Subject));
|
context.Request.Headers.Append("UserId", new Microsoft.Extensions.Primitives.StringValues(data.Subject));
|
||||||
}
|
}
|
||||||
await next(context);
|
await next(context);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class T1R1Processor
|
|||||||
{
|
{
|
||||||
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
||||||
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
||||||
if (!sources!.Any())
|
if (sources!.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Source record not found");
|
throw new Exception("Source record not found");
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ public class T1R1Processor
|
|||||||
|
|
||||||
var dataSources = new List<Layer>();
|
var dataSources = new List<Layer>();
|
||||||
|
|
||||||
foreach (var source in sources!)
|
foreach (var source in sources)
|
||||||
{
|
{
|
||||||
for (var month = 1; month <= DateTime.UtcNow.Month; month++)
|
for (var month = 1; month <= DateTime.UtcNow.Month; month++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class T3MultiSourceCopySelectedCodesProcessor
|
|||||||
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
||||||
var month = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Month")?.Desc1!);
|
var month = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Month")?.Desc1!);
|
||||||
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
||||||
if (!sources!.Any())
|
if (sources!.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Source record not found");
|
throw new Exception("Source record not found");
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ public class T3MultiSourceCopySelectedCodesProcessor
|
|||||||
processedLayer.ModifiedById = Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D");
|
processedLayer.ModifiedById = Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D");
|
||||||
processedLayer.ModifiedAt = DateTime.UtcNow;
|
processedLayer.ModifiedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
var dataSources = sources!.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/{month}-{source.Desc1}-T3"))
|
var dataSources = sources.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/{month}-{source.Desc1}-T3"))
|
||||||
.Include(x => x.Records)
|
.Include(x => x.Records)
|
||||||
.FirstOrDefault())
|
.FirstOrDefault())
|
||||||
.OfType<Layer>()
|
.OfType<Layer>()
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class T3MultiSourceSummaryProcessor
|
|||||||
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
||||||
var month = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Month")?.Desc1!);
|
var month = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Month")?.Desc1!);
|
||||||
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
||||||
if (!sources!.Any())
|
if (sources!.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Source record not found");
|
throw new Exception("Source record not found");
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ public class T3MultiSourceSummaryProcessor
|
|||||||
|
|
||||||
var newRecords = new List<Record>();
|
var newRecords = new List<Record>();
|
||||||
|
|
||||||
var dataSources = sources!.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/{month}-{source.Desc1}-T3"))
|
var dataSources = sources.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/{month}-{source.Desc1}-T3"))
|
||||||
.Include(x => x.Records)
|
.Include(x => x.Records)
|
||||||
.FirstOrDefault())
|
.FirstOrDefault())
|
||||||
.OfType<Layer>()
|
.OfType<Layer>()
|
||||||
@@ -98,7 +98,7 @@ public class T3MultiSourceSummaryProcessor
|
|||||||
|
|
||||||
// Dynamic Codes
|
// Dynamic Codes
|
||||||
var dynamicCodes = processWorker.Records?.Where(x => x.Code == "DynamicCode").ToList();
|
var dynamicCodes = processWorker.Records?.Where(x => x.Code == "DynamicCode").ToList();
|
||||||
if (dynamicCodes != null && dynamicCodes.Any())
|
if (dynamicCodes != null && dynamicCodes.Count != 0)
|
||||||
{
|
{
|
||||||
foreach (var dynamicCode in dynamicCodes)
|
foreach (var dynamicCode in dynamicCodes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class T3MultiSourceYearSummaryProcessor
|
|||||||
{
|
{
|
||||||
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
||||||
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
||||||
if (!sources!.Any())
|
if (sources!.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Source record not found");
|
throw new Exception("Source record not found");
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ public class T3MultiSourceYearSummaryProcessor
|
|||||||
|
|
||||||
var newRecords = new List<Record>();
|
var newRecords = new List<Record>();
|
||||||
|
|
||||||
var dataSources = sources!.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/13-{source.Desc1}-T3"))
|
var dataSources = sources.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/13-{source.Desc1}-T3"))
|
||||||
.Include(x => x.Records)
|
.Include(x => x.Records)
|
||||||
.FirstOrDefault())
|
.FirstOrDefault())
|
||||||
.OfType<Layer>()
|
.OfType<Layer>()
|
||||||
@@ -120,7 +120,7 @@ public class T3MultiSourceYearSummaryProcessor
|
|||||||
|
|
||||||
// Dynamic Codes
|
// Dynamic Codes
|
||||||
var dynamicCodes = processWorker.Records?.Where(x => x.Code == "DynamicCode").ToList();
|
var dynamicCodes = processWorker.Records?.Where(x => x.Code == "DynamicCode").ToList();
|
||||||
if (dynamicCodes != null && dynamicCodes.Any())
|
if (dynamicCodes != null && dynamicCodes.Count != 0)
|
||||||
{
|
{
|
||||||
foreach (var dynamicCode in dynamicCodes)
|
foreach (var dynamicCode in dynamicCodes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class T4R2Processor
|
|||||||
{
|
{
|
||||||
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!);
|
||||||
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList();
|
||||||
if (!sources!.Any())
|
if (sources!.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Source record not found");
|
throw new Exception("Source record not found");
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ public class T4R2Processor
|
|||||||
|
|
||||||
var newRecords = new List<Record>();
|
var newRecords = new List<Record>();
|
||||||
|
|
||||||
foreach (var source in sources!)
|
foreach (var source in sources)
|
||||||
{
|
{
|
||||||
var rawSourceCodes = processWorker.Records?.SingleOrDefault(x => x.Code == $"Codes-{source.Desc1}")
|
var rawSourceCodes = processWorker.Records?.SingleOrDefault(x => x.Code == $"Codes-{source.Desc1}")
|
||||||
?.Desc1;
|
?.Desc1;
|
||||||
|
|||||||
Reference in New Issue
Block a user