ImportResult result = new ();
OrderImporter orderImporter = new OrderImporterBuilder(Spreadsheet, TimeZone)
.ConfigureSheets(options =>
{
options
.UseAllSheets();
})
.OrderNumberFrom("Order")
.AddLineCode(options =>
{
options
.LineCodeFrom("Line")
.UseCustomLineCodeMapping("PACKS1", "SC3")
.UseCustomLineCodeMapping("PACKS2", "SC3")
.UseCustomLineCodeMapping("PACKS3", "SC3")
.UseCustomLineCodeMapping("PACKS4", "SC3")
.UseCustomLineCodeMapping("PACKS5", "SC3")
.UseCustomLineCodeMapping("PACKS6", "SC3")
.UseCustomLineCodeMapping("PACKS7", "SC3")
.UseCustomLineCodeMapping("PACKS8", "SC3")
.UseCustomLineCodeMapping("PACKS9", "SC3")
.UseCustomLineCodeMapping("PACK01", "SC3")
.UseCustomLineCodeMapping("PACK02", "SC3")
.UseCustomLineCodeMapping("PACK03", "SC3")
.UseCustomLineCodeMapping("PACK04", "SC3")
.UseCustomLineCodeMapping("PACK05", "SC3")
.UseCustomLineCodeMapping("PACK06", "SC3")
.UseCustomLineCodeMapping("PACK07", "SC3")
.UseCustomLineCodeMapping("PACK08", "SC3")
.UseCustomLineCodeMapping("PACK09", "SC3")
.UseCustomLineCodeMapping("PACK10", "SC3")
.UseCustomLineCodeMapping("PACK11", "SC3")
.UseCustomLineCodeMapping("PACK12", "SC3");
})
.ProductNumberFrom("SKU")
.AddStartDate(options =>
{
options
.AddCustomValueProvider((_, sheet, _) =>
{
DateTime parsedDateTime = DateTime.ParseExact(
$"{sheet.SheetName}",
new[] { "dd.MM.yyyy" },
CultureInfo.InvariantCulture,
DateTimeStyles.None);
return TimeZoneInfo
.ConvertTimeBySystemTimeZoneId(parsedDateTime, TimeZone, "UTC")
.ToString("G");
});
})
.UseFixedQuantityUnit("Gross")
.QuantityFrom("GROSS")
.AddAdditionalFields(options =>
options
.UseSelectedAdditionalFields()
.AdditionalFieldFrom("CAR")
.AdditionalFieldFrom("BATCH"))
.UseSkipImportCondition((cells) =>
{
ICellRepresentationModel? isToBeImported = cells.SingleOrDefault(x => SpreadsheetUtils.FindColumn(x, "Is to be imported?"));
string? isToBeImportedValue = isToBeImported?.GetValue<string>();
return isToBeImported is null ||
!string.Equals("yes", isToBeImportedValue, StringComparison.OrdinalIgnoreCase);
})
.Build();
result.Orders = orderImporter
.Import()
.ToList();
return result; |