Files
FA/ClientEdiOrdersGeneratorReport/Program.cs
2023-02-14 21:13:09 +01:00

79 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using FaKrosnoDataModel;
using SytelineSaAppDataModel;
namespace ClientEdiOrdersGeneratorReport
{
class Program
{
static int Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
int result = 0;
FaKrosnoDataProvider faKrosnoDataProvider = new FaKrosnoDataProvider(new FaKrosnoDataContext());
SytelineDataProvider sytelineDataProvider = new SytelineDataProvider(new SytelineSaAppDataContext());
try
{
DateTime currentDate = DateTime.Now;
if (!args.Any())
{
throw new Exception("Parametr z nazwą konfiguracji jest wymagany!");
}
IList<string> logs = new List<string>();
switch (args[0])
{
case "SendOrders":
SendOrderStep sendOrderStep = new SendOrderStep(faKrosnoDataProvider, sytelineDataProvider, currentDate);
sendOrderStep.SendOrder(out logs);
string join = logs.Any() ? string.Join("*", logs) : "OK";
EdiLog ediLog = new EdiLog
{
ProcessName = "ClientEdiOrdersGenerator",
ConfigurationName = args[0],
Date = DateTime.Now,
Status = result,
LogText = join
};
sytelineDataProvider.SaveLog(ediLog);
break;
default:
throw new Exception($"Niepoprawny parametr konfiguracji: {args[0]}");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
result = 555;
EdiLog ediLog = new EdiLog
{
ProcessName = "ClientEdiOrdersGeneratorReport",
ConfigurationName = args[0],
Date = DateTime.Now,
Status = result,
LogText = string.Join("*", ex.ToString())
};
sytelineDataProvider.SaveLog(ediLog);
}
return result;
}
}
}