public static void executeCustomerMissingReport(string salesOrg) { var idaLog = new IdaLog(); string id = $"{DateTime.Now} {Environment.MachineName}"; IDBServerConnector dbServer = Create.dbServer(); ISAPLib sap = Create.sapLib(); idaLog.insertToActivityLog("missingCustomers", "startTime", id, salesOrg); var dcServer = new DataCollectorServer(dbServer); var dcSap = new DataCollectorSap(sap, Create.exportParses()); var distList = new DistributionListCalculator(dbServer); var dc = new DataCollectorServiceMCR(dcServer, dcSap); var dcService = new DataCollectorServiceMCR(dcServer, dcSap); var customerMissingList = dcService.getMissingCustomers(salesOrg); IMailUtil mu = Create.mailUtil(); string email = distList.getDistList(salesOrg, "missingCustomers"); if (customerMissingList is null) { idaLog.insertToActivityLog("missingCustomers", "empty list", id, salesOrg); mu.mailSimple(email, $"{salesOrg} Customers missing in the Database {DateTime.Now}", $"Hello<br><br>There are no orders in ZV04HN<br><br>Kind Regards<br>IDA"); return; } if (customerMissingList.Count > 0) { mu.mailSimple(email, $"{salesOrg} Customers missing in the Database {DateTime.Now}", $"Hello<br><br><br>{mu.listToHTMLtable(customerMissingList)}<br><br>Kind Regards<br>IDA"); idaLog.insertToActivityLog("missingCustomers", "success", id, salesOrg); } else { idaLog.insertToActivityLog("missingCustomers", "empty list", id, salesOrg); mu.mailSimple(email, $"{salesOrg} Customers missing in the Database {DateTime.Now}", $"Hello<br><br><br>There are no missing customers in the database<br><br>Kind Regards<br>IDA"); } }
public static void executeDistressReport(string salesOrg) { IDBServerConnector dbServer = Create.dbServer(); ISAPLib sap = Create.sapLib(); IDataCollectorServer dcServer = new DataCollectorServer(dbServer); IDataCollectorSap dcSap = new DataCollectorSap(sap, Create.exportParses()); IDataCollectorServiceDistress dc = new DataCollectorServiceDistress(dcServer, dcSap); IDistributionListCalculator distList = new DistributionListCalculator(dbServer); string email = distList.getDistList(salesOrg, "distress"); var executor = new DistressReportExecutor(salesOrg); executor.startLogs(); if (!(executor.calculateGenericDistress(dc))) { executor.emptyListAction(email); return; } if (executor.calculateSalesOrgSpecifficDistress()) { executor.sendInfo(email); executor.finishLogs(); } else { executor.emptyListAction(email); } }
public RejectionsVA02Runner(ISAPLib sap, IIdaLog log, IVA02 va02, bool isRelease, bool isLog) { this.sap = sap; this.log = log; this.va02 = va02; this.isRelease = isRelease; this.isLog = isLog; }
public static void executeDeliveryBlocks(string salesOrg) { string id = $"{DateTime.Now} {Environment.MachineName}"; IDBServerConnector dbServer = Create.dbServer(); ISAPLib sap = Create.sapLib(); IDataCollectorServer dcServer = new DataCollectorServer(dbServer); IDataCollectorSap dcSap = new DataCollectorSap(sap, Create.exportParses()); IDataCollectorServiceDeliveryBlocks dc = new DataCollectorServiceDeliveryBlocks(id: id, dataCollectorServer: dcServer, dataCollectorSap: dcSap, salesOrg: salesOrg); IDistributionListCalculator distList = new DistributionListCalculator(dbServer); IMailUtil mu = Create.mailUtil(); string email = distList.getDistList(salesOrg, "deliveryBlocks"); var executor = new DeliveryBlocksExecutor(salesOrg: salesOrg, id: id); string[] salesOrgsWithNoDelBlockAction = { "ES01", "PT01" }; executor.startLog(); if (executor.calculateDeliveryBlockList(dc)) { executor.populateDeliveryBlocksLog(dbServer); executor.sendEmail(email: email, mu: mu, isEmptyList: false); executor.runDeliveryBlocksInVA02(); executor.finishLog(isEmpty: false); } else { if (!salesOrgsWithNoDelBlockAction.Contains(salesOrg)) { executor.sendEmail(email: email, mu: mu, isEmptyList: true); executor.finishLog(isEmpty: true); } } executor.sendFailedDeliveryBlocks(salesOrg, email, dbServer, mu); executor.rejectLastReleaseBlockedOrders(dbServer, dcSap, dcServer, mu, email); executor.sendCurrentBlocksInSystem(mu, dcSap, email); if (salesOrgsWithNoDelBlockAction.Contains(salesOrg)) { executor.finishLog(isEmpty: false); } }
public void runVA02(ISAPLib sap) { string tableName = "DeliveryDatesLog"; IVA02 va02 = new VA02(sap, idaLog); foreach (var item in calculatedRDDList) { RDDVA02Runner va02RDDRunner = new RDDVA02Runner(sap, idaLog, va02); va02RDDRunner.runRDDChange(item.orderNumber, item.oldRdd, item.newRecommendedRdd, item.id, item.reason, tableName); } foreach (var item in calculatedDelBlockList) { DeliveryBlockVA02Runner va02DelBlockRunner = new DeliveryBlockVA02Runner(sap, idaLog, va02); va02DelBlockRunner.runDeliveryBlockChange(item.orderNumber, item.id, item.reason, item.delBlock, tableName); } foreach (var item in calculatedRouteCodeList) { RouteCodeVA02Runner va02RouteCodeRunner = new RouteCodeVA02Runner(sap, idaLog, va02); va02RouteCodeRunner.runRouteCodeChange(item.orderNumber, item.id, item.reason, item.newRecommendedRouteCode, tableName, salesOrg.ToUpper()); } }
public WE05(ISAPLib sapLib, IWinUtil winUtil) { this.sapLib = sapLib; this.winUtil = winUtil; }
public QuantityConversionVA02Runner(ISAPLib sap, IdaLog log, IVA02 va02) { this.sap = sap; this.log = log; this.va02 = va02; }
public SwitchesVA02Runner(ISAPLib sap, IdaLog log, IVA02 va02) { this.sap = sap; this.log = log; this.va02 = va02; }
public DeliveryBlockVA02Runner(ISAPLib sap, IdaLog log, IVA02 va02) { this.sap = sap; this.log = log; this.va02 = va02; }
public VA02(ISAPLib sap, IIdaLog log) { this.sap = sap; this.log = log; }
public static void executeRejections(string salesOrg, bool isRelease) { #region properties string id = $"{DateTime.Now} {Environment.MachineName}"; IIdaLog idaLog = new IdaLog(); IDBServerConnector dbServer = Create.dbServer(); ISAPLib sap = Create.sapLib(); IMailUtil mu = Create.mailUtil(); IDataCollectorServer dcServer = new DataCollectorServer(dbServer); IDataCollectorSap dcSap = new DataCollectorSap(sap, Create.exportParses()); IDataCollectorServiceRejections dataCollector = new DataCollectorServiceRejections(dcServer, dcSap); IDataCalculatorServiceRejections dataCalculator = new DataCalculatorServiceRejections(id); IDistributionListCalculator dlc = new DistributionListCalculator(dbServer); RejectionsOrderPropertyFactory rejectionOrderObj = new RejectionsOrderPropertyFactory(); string email = dlc.getDistList(salesOrg, "rejections"); var executor = new RejectionsTaskExecutor(salesOrg, id, isRelease, idaLog); #endregion executor.startLogs(salesOrg, isRelease ? "Release Rejections" : "After Release Rejections", "start"); if (!executor.calculateLists(dataCollector, dataCalculator)) { string tempText = isRelease ? " " : " after "; mu.mailSimple(email, $"{salesOrg} No Rejections {DateTime.Now}", $"Hello<br><br>There are no{tempText}release rejections<br><br>Kind Regards<br>IDA"); executor.endLogs(salesOrg, isRelease ? "Release Rejections" : "After Release Rejections", "empty list"); return; } if (isRelease) { #region releaseExecution executor.populateRejectionLog(dbServer); if (executor.afterReleaseRejectionList.Count > 0) { mu.mailSimple(email, $"{salesOrg} After release rejections {DateTime.Now}", $"Hello<br><br>Here are the rejections that will be executed after last release today:<br><br>{mu.listToHTMLtable(executor.afterReleaseRejectionList)}<br><br>Kind Regards<br>IDA"); } else { mu.mailSimple(email, $"{salesOrg} No after release rejections {DateTime.Now}", $"Hello<br><br>There are no after release rejections found in this release<br><br>Kind Regards<br>IDA"); executor.endLogs(salesOrg, "After Release Rejections", "empty list"); } if (executor.releaseRejectionList.Count > 0) { executor.createAutomaticRejectionObjectList(rejectionOrderObj); mu.mailSimple(email, $"{salesOrg} Release rejections {DateTime.Now}", $"Hello<br><br>Here are the rejections during release:<br><br>{mu.listToHTMLtable(executor.releaseRejectionList)}<br><br>Kind Regards<br>IDA"); executor.runRejectionsInVA02(email, dbServer, mu); executor.endLogs(salesOrg, "Release Rejections", "success"); } else { mu.mailSimple(email, $"{salesOrg} No release rejections {DateTime.Now}", $"Hello<br><br>There are no rejections found for this release<br><br>Kind Regards<br>IDA"); executor.endLogs(salesOrg, "Release Rejections", "empty list"); } #endregion } else { #region afterReleaseExecution executor.createAutomaticRejectionObjectList(rejectionOrderObj); mu.mailSimple(email, $"{salesOrg} After release rejections {DateTime.Now}", $"Hello<br><br>Here are the after release rejections gathered throughout the day that are about to be executed:<br><br>{mu.listToHTMLtable(executor.afterReleaseRejectionList)}<br><br>Kind Regards<br>IDA"); executor.runRejectionsInVA02(email, dbServer, mu); executor.endLogs(salesOrg, "After Release Rejections", "success"); #endregion } }
public static void Main() { var log = Create.serverLogger(135); var idaLog = new IdaLog(); string salesOrg = "ZA01"; IDBServerConnector dbServer = Create.dbServer(); string id = $"{DateTime.Now} {Environment.MachineName}"; idaLog.insertToActivityLog("KiwiConversions", "start", id, salesOrg); log.start(); ISAPLib sapLib = Create.sapLib(); DataCollectorSap dataCollector = new DataCollectorSap(sapLib, Create.exportParses()); List <ZV04IProperty> zv04IList = dataCollector.getZV04IList(salesOrg, IDAEnum.Task.quantityConversion); KiwiConversionException kiwiExceptionObj = new KiwiConversionException(); //removes lines that match exception criteria from zv04iList for furthur calculation zv04IList = zv04IList.Where(x => !(kiwiExceptionObj.material.Contains(x.material) && kiwiExceptionObj.soldTo.Contains(x.soldTo))).ToList(); var orderList = zv04IList.Select(x => x.order); long maxOrder = orderList.Max(); long minOrder = orderList.Min(); var conversionDAO = new ConversionDAO(dbServer); var materialConversionList = conversionDAO.getQuantityConversionMaterialList(); var shipToConversionList = conversionDAO.getQuantityConversionShipToList(); var logConversionList = conversionDAO.getQuantityConversionLogList(minOrder, maxOrder); var dataCompareService = new DataCompareService(); var salesDocumetList = dataCompareService.getSalesDocumentToChangeQuantity(zv04IList, shipToConversionList, materialConversionList); dataCompareService.removeAlreadyConvertedLines(logConversionList, ref salesDocumetList); var mailUtil = Create.mailUtil(); var emailService = new EmailService(mailUtil); var distList = new DistributionListCalculator(dbServer); string emails = distList.getDistList(salesOrg, "quantityConversions"); if (salesDocumetList.Count > 0) { try { emailService.sendEmailNotification(emails, "", "ZA01 Kiwi conversion", salesDocumetList); } catch (Exception) { mailUtil.mailSimple(IDAConsts.adminEmail, $"{salesOrg} Kiwi Conv: Error {Information.Err().Description}", $"Empty mail list for this task"); } IVA02 va02 = new VA02(sapLib, idaLog); QuantityConversionVA02Runner va02Runner = new QuantityConversionVA02Runner(sapLib, idaLog, va02); try { foreach (var document in salesDocumetList) { va02Runner.runQuantityChange(document); } } catch (Exception ex) { string filepath = $"{IDAConsts.Paths.errorFilePath}{salesOrg} Kiwi error: {DateTime.Now}"; var sTextFile = new System.Text.StringBuilder(); if (!System.IO.File.Exists(filepath)) { System.IO.File.Create(filepath).Dispose(); } sTextFile.AppendLine(ex.StackTrace); System.IO.File.AppendAllText(filepath, sTextFile.ToString()); mailUtil.mailSimple(IDAConsts.adminEmail, $"{salesOrg} Kiwi Conv: Error {Information.Err().Number}", $"{mailUtil.getLink(filepath, "Your error info is here")}"); log.finish("fail"); idaLog.insertToActivityLog("KiwiConversions", "fail", id, salesOrg); return; } log.finish("success"); idaLog.insertToActivityLog("KiwiConversions", "success", id, salesOrg); logConversionList = conversionDAO.getQuantityConversionLogList(minOrder, maxOrder); dataCompareService.removeAlreadyConvertedLines(logConversionList, ref salesDocumetList); if (salesDocumetList.Count > 0) { emailService.sendEmailNotification(emails, "", "ZA01 Kiwi conversion failed items", salesDocumetList); } } else { try { mailUtil.mailSimple(emails, $"ZA01 Kiwi conversion {DateTime.Now}", "No Kiwi conversions found"); } catch (Exception) { mailUtil.mailSimple($"{IDAConsts.adminEmail};{Environment.UserName}", $"{salesOrg} Kiwi Conv: Error {Information.Err().Description}", $"Empty mail list for this task"); } idaLog.insertToActivityLog("KiwiConversions", "empty list", id, salesOrg); log.finish("empty list"); } }
public CO09(ISAPLib saplib) { sap = saplib; }
public MD04(ISAPLib saplib) { sap = saplib; }
public ZV04(ISAPLib sap, string salesOrg, IDAEnum.Task task) { this.sap = sap; this.salesOrg = salesOrg; this.task = task; }
public ZV04P(ISAPLib sap, string salesOrg, IDAEnum.Task task) : base(sap, salesOrg, task) { tCode = "ZV04P"; }
public DataCollectorSap(ISAPLib sap, IExportParser parser) { this.sap = sap; this.parser = parser; }
public ZPURRS(ISAPLib saplib) { sap = saplib; }
public RouteCodeVA02Runner(ISAPLib sap, IdaLog log, IVA02 va02) { this.sap = sap; this.log = log; this.va02 = va02; }
public FullOrderRejectionVA02Runner(ISAPLib sap, IdaLog log, IVA02 va02) { this.sap = sap; this.log = log; this.va02 = va02; }