diff --git a/WebAPI/Controllers/LayersController.cs b/WebAPI/Controllers/LayersController.cs index e3e0677..22b733d 100644 --- a/WebAPI/Controllers/LayersController.cs +++ b/WebAPI/Controllers/LayersController.cs @@ -338,6 +338,7 @@ public class LayersController : Controller x.Name != null && x.Name.Contains(nameFilter) && x.Records!.Any(y => y.Code == "Type" && y.Desc1 == "ImportWorker") && x.Records!.Any(y => y.Code == "IsEnabled" && y.Desc1 == "True") + && x.Number == 5375 ) .OrderByDescending(x => x.CreatedAt) .AsNoTracking() diff --git a/WebAPI/Helpers/HttpRequests/AutoImport.http b/WebAPI/Helpers/HttpRequests/AutoImport.http index 90de1de..d8cfd30 100644 --- a/WebAPI/Helpers/HttpRequests/AutoImport.http +++ b/WebAPI/Helpers/HttpRequests/AutoImport.http @@ -1,3 +1,3 @@ ### -GET http://localhost:5400/api/Layers/AutoImport/10763478CB738D4ecb2h76g803478CB738D4e/D3- +GET http://localhost:5400/api/Layers/AutoImport/10763478CB738D4ecb2h76g803478CB738D4e/D1- diff --git a/WebAPI/dataImporters/morska.d1.importer.cs b/WebAPI/dataImporters/morska.d1.importer.cs index bc45152..97c62f7 100644 --- a/WebAPI/dataImporters/morska.d1.importer.cs +++ b/WebAPI/dataImporters/morska.d1.importer.cs @@ -60,26 +60,26 @@ public class MorskaD1Importer( var dataRangeResponse = googleSheetValues.Get(sheetId, $"{sheetTabName}!{dataRange}").Execute(); var data = dataRangeResponse.Values; var newRecords = (from t in data - where t.Count > 17 && (string)t[0] != string.Empty + where t.Count > 1 && (string)t[0] != string.Empty select new Record { Id = Guid.NewGuid(), Code = t[0].ToString(), - Value1 = ParseValue(t[3].ToString()), - Value2 = ParseValue(t[4].ToString()), - Value3 = ParseValue(t[5].ToString()), - Value4 = ParseValue(t[6].ToString()), - Value5 = ParseValue(t[7].ToString()), - Value6 = ParseValue(t[8].ToString()), - Value7 = ParseValue(t[9].ToString()), - Value8 = ParseValue(t[10].ToString()), - Value9 = ParseValue(t[11].ToString()), - Value10 = ParseValue(t[12].ToString()), - Value11 = ParseValue(t[13].ToString()), - Value12 = ParseValue(t[14].ToString()), - Value13 = ParseValue(t[15].ToString()), - Value14 = ParseValue(t[16].ToString()), - Value15 = ParseValue(t[17].ToString()), + Value1 = IndexExists(t, 3) ? ParseValue(t[3]?.ToString()) : null, + Value2 = IndexExists(t, 4) ? ParseValue(t[4]?.ToString()) : null, + Value3 = IndexExists(t, 5) ? ParseValue(t[5]?.ToString()) : null, + Value4 = IndexExists(t, 6) ? ParseValue(t[6]?.ToString()) : null, + Value5 = IndexExists(t, 7) ? ParseValue(t[7]?.ToString()) : null, + Value6 = IndexExists(t, 8) ? ParseValue(t[8]?.ToString()) : null, + Value7 = IndexExists(t, 9) ? ParseValue(t[9]?.ToString()) : null, + Value8 = IndexExists(t, 10) ? ParseValue(t[10]?.ToString()) : null, + Value9 = IndexExists(t, 11) ? ParseValue(t[11]?.ToString()) : null, + Value10 = IndexExists(t, 12) ? ParseValue(t[12]?.ToString()) : null, + Value11 = IndexExists(t, 13) ? ParseValue(t[13]?.ToString()) : null, + Value12 = IndexExists(t, 14) ? ParseValue(t[14]?.ToString()) : null, + Value13 = IndexExists(t, 15) ? ParseValue(t[15]?.ToString()) : null, + Value14 = IndexExists(t, 16) ? ParseValue(t[16]?.ToString()) : null, + Value15 = IndexExists(t, 17) ? ParseValue(t[17]?.ToString()) : null, CreatedAt = DateTime.UtcNow, ModifiedAt = DateTime.UtcNow }).ToList(); @@ -102,4 +102,8 @@ public class MorskaD1Importer( return null; } } + private bool IndexExists(IList array, int index) + { + return array != null && index >= 0 && index < array.Count; + } } \ No newline at end of file