Enable FK2 import
This commit is contained in:
12
.idea/.idea.DiunaBI/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
12
.idea/.idea.DiunaBI/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="IncorrectHttpHeaderInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="customHeaders">
|
||||
<set>
|
||||
<option value="D-BI-AUTH" />
|
||||
</set>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
@@ -160,6 +160,7 @@ namespace WebAPI.Controllers
|
||||
.Where(x =>
|
||||
x.Records!.Any(x => x.Code == "Type" && x.Desc1 == "ImportWorker") &&
|
||||
x.Records!.Any(x => x.Code == "IsEnabled" && x.Desc1 == "True")
|
||||
//&& x.Records!.Any(x => x.Code == "ImportType" && x.Desc1 == "FK2")
|
||||
)
|
||||
.OrderBy(x => x.CreatedAt)
|
||||
.ToList();
|
||||
@@ -199,61 +200,68 @@ namespace WebAPI.Controllers
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return Ok();
|
||||
}
|
||||
|
||||
string? startDate = importWorker.Records!.FirstOrDefault(x => x.Code == "StartDate")?.Desc1;
|
||||
if (startDate == null)
|
||||
{
|
||||
throw new Exception("StartDate record nod found");
|
||||
}
|
||||
string? endDate = importWorker.Records!.Where(x => x.Code == "EndDate").First().Desc1;
|
||||
if (endDate == null)
|
||||
{
|
||||
throw new Exception("EndDate record nod found");
|
||||
}
|
||||
var startDateParsed = DateTime.ParseExact(startDate!, "yyyy.MM.dd", null);
|
||||
var endDateParsed = DateTime.ParseExact(endDate!, "yyyy.MM.dd", null);
|
||||
if (startDateParsed.Date <= DateTime.UtcNow.Date && endDateParsed.Date >= DateTime.UtcNow.Date)
|
||||
{
|
||||
MorskaImporter importer = new MorskaImporter(db, googleSheetValues, this);
|
||||
importer.import(importWorker);
|
||||
Thread.Sleep(5000); // be aware of GSheet API quota
|
||||
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker!.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.import,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
else if (IsImportedLayerUpToDate(importWorker) == false)
|
||||
{
|
||||
MorskaImporter importer = new MorskaImporter(db, googleSheetValues, this);
|
||||
importer.import(importWorker);
|
||||
Thread.Sleep(5000); // be aware of GSheet API quota
|
||||
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker!.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.import,
|
||||
Message = "Success (reimported)",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
logsController.AddEntry(new LogEntry
|
||||
|
||||
|
||||
|
||||
string? startDate = importWorker.Records!.FirstOrDefault(x => x.Code == "StartDate")?.Desc1;
|
||||
if (startDate == null)
|
||||
{
|
||||
Title = $"{importWorker!.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.import,
|
||||
Message = "importLayer records are up of date. Not processed.",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
throw new Exception("StartDate record nod found");
|
||||
}
|
||||
|
||||
string? endDate = importWorker.Records!.Where(x => x.Code == "EndDate").First().Desc1;
|
||||
if (endDate == null)
|
||||
{
|
||||
throw new Exception("EndDate record nod found");
|
||||
}
|
||||
|
||||
var startDateParsed = DateTime.ParseExact(startDate!, "yyyy.MM.dd", null);
|
||||
var endDateParsed = DateTime.ParseExact(endDate!, "yyyy.MM.dd", null);
|
||||
if (startDateParsed.Date <= DateTime.UtcNow.Date &&
|
||||
endDateParsed.Date >= DateTime.UtcNow.Date)
|
||||
{
|
||||
MorskaImporter importer = new MorskaImporter(db, googleSheetValues, this);
|
||||
importer.import(importWorker);
|
||||
Thread.Sleep(5000); // be aware of GSheet API quota
|
||||
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker!.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.info,
|
||||
LogType = LogType.import,
|
||||
Message = "Success",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
else if (IsImportedLayerUpToDate(importWorker) == false)
|
||||
{
|
||||
MorskaImporter importer = new MorskaImporter(db, googleSheetValues, this);
|
||||
importer.import(importWorker);
|
||||
Thread.Sleep(5000); // be aware of GSheet API quota
|
||||
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker!.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.import,
|
||||
Message = "Success (reimported)",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = $"{importWorker!.Name}, {importWorker.Id}",
|
||||
Type = LogEntryType.warning,
|
||||
LogType = LogType.import,
|
||||
Message = "importLayer records are up of date. Not processed.",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user