예제 #1
0
 private void endSwtichesLog(SwitchesSapOrderProperty switchObj, string id, string tableName, SwitchesSapLineProperty lineSwitch, bool isChanged)
 {
     log.update(tableName,
                new[] { "status", "reason" },
                new[] { isChanged ? "success" : "fail", lineSwitch.reason.Replace("'", "") },
                new[] { "[orderNumber]", "[id]", "[SwitchAutomatic]" },
                new[] { switchObj.orderNumber.ToString(), id, "1" });
 }
예제 #2
0
 private void startSwitchesLog(SwitchesSapOrderProperty switchObj, string id, string tableName)
 {
     log.update(tableName,
                new[] { "startTime" },
                new[] { Strings.Format(DateTime.Now, "yyyyMMdd HH:mm:ss") },
                new[] { "[orderNumber]", "[id]", "[SwitchAutomatic]" },
                new[] { switchObj.orderNumber.ToString(), id, "1" });
 }
예제 #3
0
 private void cmirAction(SwitchesSapOrderProperty switchObj, ITable table, SwitchesSapLineProperty lineSwitch, int sapLineNumber, string cmir)
 {
     if (lineSwitch.isSameBarcode && cmir != "")
     {
         table.setCellValue(sapLineNumber, "Customer Material Numb", cmir);
         log.insert("CMIR",
                    "[salesOrg],[soldTo],[sku],[cmir]",
                    $@"'{switchObj.salesOrg}',{switchObj.soldTo},{lineSwitch.newSku},'{cmir}'");
     }
 }
예제 #4
0
        private void updateOrderLog(string tableName, SwitchesSapOrderProperty switchObj, OrderStatus status)
        {
            switch (status)
            {
            case OrderStatus.success: {
                idaLog.update(
                    tableName,
                    new[] { "endTime" },
                    new[] { Strings.Format(DateTime.Now, "yyyyMMdd HH:mm:ss") },
                    new[] { "[orderNumber]", "[id]", "[SwitchAutomatic]" },
                    new[] { switchObj.orderNumber.ToString(), id, "1" });
                break;
            }

            case OrderStatus.failedToSave: {
                updateFailedOrderLog("Failed to save order", tableName, switchObj.orderNumber);
                break;
            }

            case OrderStatus.bothSkusAreZ4: {
                updateFailedOrderLog("Old and new skus are in Z4", tableName, switchObj.orderNumber);
                break;
            }

            case OrderStatus.blockedByBatchJob: {
                updateFailedOrderLog("Blocked by batch job", tableName, switchObj.orderNumber);
                break;
            }

            case OrderStatus.blockedByUser: {
                updateFailedOrderLog("Blocked by user", tableName, switchObj.orderNumber);
                break;
            }

            case OrderStatus.realeasedOrRejected: {
                updateFailedOrderLog("Order released or rejected", tableName, switchObj.orderNumber);
                break;
            }

            case OrderStatus.bothSkusAreNotApproved: {
                updateFailedOrderLog("Old and new skus are not approved", tableName, switchObj.orderNumber);
                break;
            }

            case OrderStatus.orderMissingPaymentTerms: {
                updateFailedOrderLog("Cannot save order due to missing payment terms", tableName, switchObj.orderNumber);
                break;
            }

            default: {
                throw new NotImplementedException();
            }
            }
        }
예제 #5
0
        public OrderStatus runSwitches(SwitchesSapOrderProperty switchObj, string id, string tableName)
        {
            string csrNote = "";

            startSwitchesLog(switchObj, id, tableName);

            OrderStatus status = va02.enterOrder(switchObj.orderNumber);

            if (status == OrderStatus.blockedByUser || status == OrderStatus.blockedByBatchJob)
            {
                return(status);
            }

            va02.bypassInitialPopups();

            status = va02.isChangeNeeded();

            if (status != OrderStatus.available)
            {
                return(status);
            }

            ITable table = va02.getTable();

            va02.moveRouteCodeColumnToIndexEight(table);

            foreach (var lineSwitch in switchObj.lineDetails)
            {
                int  sapLineNumber = (lineSwitch.lineNumber / 10 - 1);
                bool shouldChange  = isForChange(table, lineSwitch, sapLineNumber);
                bool isChanged     = false;

                if (shouldChange)
                {
                    string unitOfMeasure = table.getCellValue(sapLineNumber, "Un");
                    string itemCategory  = table.getCellValue(sapLineNumber, "ItCa");
                    string routeCode     = table.getCellValue(sapLineNumber, VA02.routeCodeColumnIndex); // have to use by index because the table retains its indexes by name after reordering but not actual indexes within a table
                    string cmir          = table.getCellValue(sapLineNumber, "Customer Material Numb");

                    table.setCellValue(sapLineNumber, "Material", lineSwitch.newSku);
                    sap.pressEnter();
                    sap.getRidOfPopUps();

                    string tempReason = "";
                    isChanged = va02.isLineChanged(table, lineSwitch, sapLineNumber, ref tempReason);

                    if (tempReason != "")
                    {
                        lineSwitch.reason = tempReason;
                    }

                    if (sap.getInfoBarMsg().Contains("Z4"))
                    {
                        return(OrderStatus.bothSkusAreZ4);
                    }

                    if (sap.getInfoBarMsg().Contains("not approved"))
                    {
                        return(OrderStatus.bothSkusAreNotApproved);
                    }

                    unitsOfMeasureAction(table, sapLineNumber, unitOfMeasure);
                    itemCategoryAction(table, sapLineNumber, itemCategory);
                    routeCodeAction(table, sapLineNumber, routeCode);
                    cmirAction(switchObj, table, lineSwitch, sapLineNumber, cmir);
                }

                csrNote += $"sku {lineSwitch.oldSku} has{(isChanged ? " " : " not ")}been switched to {lineSwitch.newSku}. Reason: {lineSwitch.reason}{Constants.vbCr}";

                endSwtichesLog(switchObj, id, tableName, lineSwitch, isChanged);
            }

            va02.soarAction(csrNote, "Line Switches", switchObj.orderNumber);
            va02.save();
            return(va02.getOrderStatusAfterSaving());
        }