AutoImport: DataVaidation FIX

This commit is contained in:
Michał Zieliński
2023-10-02 21:14:15 +02:00
parent f70ba9b701
commit f22b1933df
2 changed files with 29 additions and 27 deletions

View File

@@ -305,7 +305,7 @@ namespace WebAPI.Controllers
throw new Exception($"SheetId not found, {importWorker.Name}");
}
string? sheetTabName = importWorker.Records!.Where(x => x.Code == "SheetTabName").FirstOrDefault()?.Desc1;
if (sheetId == null)
if (sheetTabName == null)
{
throw new Exception($"SheetTabName not found, {importWorker.Name}");
}
@@ -336,7 +336,7 @@ namespace WebAPI.Controllers
}
// open excel and read data
var nameResponse = googleSheetValues.Get(sheetId, $"{sheetTabName}!{importNameCell}:{importNameCell}").Execute();
string? name = nameResponse.Values[0][0].ToString();
string? name = nameResponse.Values?[0][0].ToString();
if (name == null)
{
throw new Exception($"ImportName cell is empty, {importWorker.Name}");
@@ -382,7 +382,9 @@ namespace WebAPI.Controllers
layer.Records.Add(record);
};
}
AddLayer(layer, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
logsController.AddEntry(new LogEntry
{
Title = $"Import Success, {importWorker.Name}",
@@ -390,6 +392,7 @@ namespace WebAPI.Controllers
LogType = LogType.import,
CreatedAt = DateTime.UtcNow
});
}
private Layer AddLayer(Layer input, Guid currentUserId)
{