Code refactor finished
This commit is contained in:
@@ -85,8 +85,8 @@ public class AdminController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Backup success",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.backup,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Backup,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return Ok();
|
||||
@@ -96,8 +96,8 @@ public class AdminController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Backup error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.backup,
|
||||
Type = LogEntryType.Error,
|
||||
LogType = LogType.Backup,
|
||||
Message = e.ToString(),
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
|
||||
@@ -90,8 +90,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"Unauthorized request - wrong apiKey ({number})",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.powerBI,
|
||||
Type = LogEntryType.Warning,
|
||||
LogType = LogType.PowerBi,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return Unauthorized();
|
||||
@@ -105,8 +105,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"Unauthorized request - no authorization header ({number})",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.powerBI,
|
||||
Type = LogEntryType.Warning,
|
||||
LogType = LogType.PowerBi,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return Unauthorized();
|
||||
@@ -118,8 +118,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"Unauthorized request - wrong auth header format ({number})",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.powerBI,
|
||||
Type = LogEntryType.Warning,
|
||||
LogType = LogType.PowerBi,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return Unauthorized();
|
||||
@@ -133,8 +133,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"Unauthorized request - bad credentials ({number})",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.powerBI,
|
||||
Type = LogEntryType.Warning,
|
||||
LogType = LogType.PowerBi,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return Unauthorized();
|
||||
@@ -143,8 +143,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"Sending data for layer {number}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.powerBI,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.PowerBi,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
|
||||
@@ -157,8 +157,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = e.ToString(),
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.powerBI,
|
||||
Type = LogEntryType.Error,
|
||||
LogType = LogType.PowerBi,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return BadRequest(e.ToString());
|
||||
@@ -213,8 +213,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "No Layers to import.",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.import,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Import,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return Ok();
|
||||
@@ -235,8 +235,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.import,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Import,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -267,8 +267,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.import,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Import,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -282,8 +282,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.import,
|
||||
Type = LogEntryType.Warning,
|
||||
LogType = LogType.Import,
|
||||
Message = "Success (reimported)",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -293,8 +293,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.import,
|
||||
Type = LogEntryType.Warning,
|
||||
LogType = LogType.Import,
|
||||
Message = "importLayer records are up of date. Not processed.",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -306,8 +306,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.import,
|
||||
Type = LogEntryType.Error,
|
||||
LogType = LogType.Import,
|
||||
Message = e.ToString(),
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -321,8 +321,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Process error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.import,
|
||||
Type = LogEntryType.Error,
|
||||
LogType = LogType.Import,
|
||||
Message = e.ToString(),
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -363,8 +363,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"Processing: {type}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Process,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
|
||||
@@ -383,8 +383,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "No Layers to process.",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Process,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
@@ -400,8 +400,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{processWorker.Name}, {processWorker.Id}",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Error,
|
||||
LogType = LogType.Process,
|
||||
Message = e.ToString(),
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -413,8 +413,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Process error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Error,
|
||||
LogType = LogType.Process,
|
||||
Message = e.ToString(),
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -445,14 +445,14 @@ public class LayersController : Controller
|
||||
case "T3-SourceYearSummary":
|
||||
{
|
||||
var processor =
|
||||
new T3SourceYearSummaryProcessor(_db, _googleSheetValues, this);
|
||||
processor.process(processWorker);
|
||||
new T3SourceYearSummaryProcessor(_db, this);
|
||||
processor.Process(processWorker);
|
||||
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{processWorker.Name}, {processWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Process,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -461,14 +461,14 @@ public class LayersController : Controller
|
||||
case "T3-MultiSourceYearSummary":
|
||||
{
|
||||
var processor =
|
||||
new T3MultiSourceYearSummaryProcessor(_db, _googleSheetValues, this, _logsController);
|
||||
processor.process(processWorker);
|
||||
new T3MultiSourceYearSummaryProcessor(_db, this, _logsController);
|
||||
processor.Process(processWorker);
|
||||
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{processWorker.Name}, {processWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Process,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -477,14 +477,14 @@ public class LayersController : Controller
|
||||
case "T3-MultiSourceCopySelectedCodesYearSummary":
|
||||
{
|
||||
var processor =
|
||||
new T3MultiSourceCopySelectedCodesYearSummaryProcessor(_db, _googleSheetValues, this);
|
||||
processor.process(processWorker);
|
||||
new T3MultiSourceCopySelectedCodesYearSummaryProcessor(_db, this);
|
||||
processor.Process(processWorker);
|
||||
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{processWorker.Name}, {processWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Process,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -498,8 +498,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{processWorker.Name}, {processWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Process,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -507,14 +507,14 @@ public class LayersController : Controller
|
||||
}
|
||||
case "T4-R2":
|
||||
{
|
||||
var processor = new T4R2Processor(_db, _googleSheetValues, this, _logsController);
|
||||
var processor = new T4R2Processor(_db, this, _logsController);
|
||||
processor.Process(processWorker);
|
||||
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{processWorker.Name}, {processWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Process,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
@@ -531,28 +531,28 @@ public class LayersController : Controller
|
||||
switch (processType!)
|
||||
{
|
||||
case "T3-SingleSource":
|
||||
var t3SingleSource = new T3SingleSourceProcessor(_db, _googleSheetValues, this);
|
||||
var t3SingleSource = new T3SingleSourceProcessor(_db, this);
|
||||
{
|
||||
t3SingleSource.process(processWorker);
|
||||
t3SingleSource.Process(processWorker);
|
||||
break;
|
||||
}
|
||||
case "T4-SingleSource":
|
||||
{
|
||||
var t4SingleSource = new T4SingleSourceProcessor(_db, _googleSheetValues, this);
|
||||
t4SingleSource.process(processWorker);
|
||||
var t4SingleSource = new T4SingleSourceProcessor(_db, this);
|
||||
t4SingleSource.Process(processWorker);
|
||||
break;
|
||||
}
|
||||
case "T3-MultiSourceSummary":
|
||||
{
|
||||
var t3MultiSourceSummary =
|
||||
new T3MultiSourceSummaryProcessor(_db, _googleSheetValues, this, _logsController);
|
||||
t3MultiSourceSummary.process(processWorker);
|
||||
new T3MultiSourceSummaryProcessor(_db, this, _logsController);
|
||||
t3MultiSourceSummary.Process(processWorker);
|
||||
break;
|
||||
}
|
||||
case "T3-MultiSourceCopySelectedCodes":
|
||||
{
|
||||
var t3MultiSourceCopySelectedCode =
|
||||
new T3MultiSourceCopySelectedCodesProcessor(_db, _googleSheetValues, this);
|
||||
new T3MultiSourceCopySelectedCodesProcessor(_db, this);
|
||||
t3MultiSourceCopySelectedCode.Process(processWorker);
|
||||
break;
|
||||
}
|
||||
@@ -561,8 +561,8 @@ public class LayersController : Controller
|
||||
_logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{processWorker.Name}, {processWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.process,
|
||||
Type = LogEntryType.Info,
|
||||
LogType = LogType.Process,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
|
||||
@@ -28,10 +28,10 @@ public class LogsController : Controller
|
||||
|
||||
var type = entry.LogType switch
|
||||
{
|
||||
LogType.import => "Import",
|
||||
LogType.backup => "Backup",
|
||||
LogType.process => "Process",
|
||||
LogType.powerBI => "PowerBIAccess",
|
||||
LogType.Import => "Import",
|
||||
LogType.Backup => "Backup",
|
||||
LogType.Process => "Process",
|
||||
LogType.PowerBi => "PowerBIAccess",
|
||||
_ => "Other"
|
||||
};
|
||||
var response = _googleSheetValues.Get(_configuration["appLogsFile"], $"{type}!A:A").Execute();
|
||||
|
||||
Reference in New Issue
Block a user