D1 importer - handle not completed data
This commit is contained in:
@@ -338,6 +338,7 @@ public class LayersController : Controller
|
|||||||
x.Name != null && x.Name.Contains(nameFilter) &&
|
x.Name != null && x.Name.Contains(nameFilter) &&
|
||||||
x.Records!.Any(y => y.Code == "Type" && y.Desc1 == "ImportWorker") &&
|
x.Records!.Any(y => y.Code == "Type" && y.Desc1 == "ImportWorker") &&
|
||||||
x.Records!.Any(y => y.Code == "IsEnabled" && y.Desc1 == "True")
|
x.Records!.Any(y => y.Code == "IsEnabled" && y.Desc1 == "True")
|
||||||
|
&& x.Number == 5375
|
||||||
)
|
)
|
||||||
.OrderByDescending(x => x.CreatedAt)
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
###
|
###
|
||||||
GET http://localhost:5400/api/Layers/AutoImport/10763478CB738D4ecb2h76g803478CB738D4e/D3-
|
GET http://localhost:5400/api/Layers/AutoImport/10763478CB738D4ecb2h76g803478CB738D4e/D1-
|
||||||
|
|
||||||
|
|||||||
@@ -60,26 +60,26 @@ public class MorskaD1Importer(
|
|||||||
var dataRangeResponse = googleSheetValues.Get(sheetId, $"{sheetTabName}!{dataRange}").Execute();
|
var dataRangeResponse = googleSheetValues.Get(sheetId, $"{sheetTabName}!{dataRange}").Execute();
|
||||||
var data = dataRangeResponse.Values;
|
var data = dataRangeResponse.Values;
|
||||||
var newRecords = (from t in data
|
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
|
select new Record
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
Code = t[0].ToString(),
|
Code = t[0].ToString(),
|
||||||
Value1 = ParseValue(t[3].ToString()),
|
Value1 = IndexExists(t, 3) ? ParseValue(t[3]?.ToString()) : null,
|
||||||
Value2 = ParseValue(t[4].ToString()),
|
Value2 = IndexExists(t, 4) ? ParseValue(t[4]?.ToString()) : null,
|
||||||
Value3 = ParseValue(t[5].ToString()),
|
Value3 = IndexExists(t, 5) ? ParseValue(t[5]?.ToString()) : null,
|
||||||
Value4 = ParseValue(t[6].ToString()),
|
Value4 = IndexExists(t, 6) ? ParseValue(t[6]?.ToString()) : null,
|
||||||
Value5 = ParseValue(t[7].ToString()),
|
Value5 = IndexExists(t, 7) ? ParseValue(t[7]?.ToString()) : null,
|
||||||
Value6 = ParseValue(t[8].ToString()),
|
Value6 = IndexExists(t, 8) ? ParseValue(t[8]?.ToString()) : null,
|
||||||
Value7 = ParseValue(t[9].ToString()),
|
Value7 = IndexExists(t, 9) ? ParseValue(t[9]?.ToString()) : null,
|
||||||
Value8 = ParseValue(t[10].ToString()),
|
Value8 = IndexExists(t, 10) ? ParseValue(t[10]?.ToString()) : null,
|
||||||
Value9 = ParseValue(t[11].ToString()),
|
Value9 = IndexExists(t, 11) ? ParseValue(t[11]?.ToString()) : null,
|
||||||
Value10 = ParseValue(t[12].ToString()),
|
Value10 = IndexExists(t, 12) ? ParseValue(t[12]?.ToString()) : null,
|
||||||
Value11 = ParseValue(t[13].ToString()),
|
Value11 = IndexExists(t, 13) ? ParseValue(t[13]?.ToString()) : null,
|
||||||
Value12 = ParseValue(t[14].ToString()),
|
Value12 = IndexExists(t, 14) ? ParseValue(t[14]?.ToString()) : null,
|
||||||
Value13 = ParseValue(t[15].ToString()),
|
Value13 = IndexExists(t, 15) ? ParseValue(t[15]?.ToString()) : null,
|
||||||
Value14 = ParseValue(t[16].ToString()),
|
Value14 = IndexExists(t, 16) ? ParseValue(t[16]?.ToString()) : null,
|
||||||
Value15 = ParseValue(t[17].ToString()),
|
Value15 = IndexExists(t, 17) ? ParseValue(t[17]?.ToString()) : null,
|
||||||
CreatedAt = DateTime.UtcNow,
|
CreatedAt = DateTime.UtcNow,
|
||||||
ModifiedAt = DateTime.UtcNow
|
ModifiedAt = DateTime.UtcNow
|
||||||
}).ToList();
|
}).ToList();
|
||||||
@@ -102,4 +102,8 @@ public class MorskaD1Importer(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private bool IndexExists(IList<object> array, int index)
|
||||||
|
{
|
||||||
|
return array != null && index >= 0 && index < array.Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user