private ReportConsumedMaterial.Response ReportConsumedMaterialHandler(ReportConsumedMaterial command)
        {
            var  response         = new ReportConsumedMaterial.Response();
            var  consumedMaterial = command.ConsumedMaterial;
            bool customized       = Platform.Query <IMaterialDefinitionExt>().Where(cust => cust.MaterialDefinitionId == consumedMaterial.MaterialDefinitionId).Select(cust => cust.Customized).FirstOrDefault();


            IToBeConsumedMaterialExt consumedMaterialExt = Platform.Query <IToBeConsumedMaterialExt>().FirstOrDefault(cms => cms.ToBeConsumedMaterialId == consumedMaterial.ToBeConsumedMaterialId && cms.WorkOrderOperationId == consumedMaterial.WorkOrderOperationId);

            UnplannedMat reportConsumedMaterial = new UnplannedMat(consumedMaterial.ERPOrder, consumedMaterial.OrderSequence, consumedMaterial.MaterialDefinitionNId, customized, consumedMaterialExt.Sequence, consumedMaterial.ConsumedQuantity, consumedMaterial.MaterialDefinitionUoM, consumedMaterial.Plant);

            var result = InforConnector.ReportConsumedMaterial(reportConsumedMaterial);

            if (result.InforCallSucceeded == false)
            {
                response.SetError(-1001, result.Error);
                Platform.Tracer.Write("Siemens-SimaticIT-Trace-UADMRuntime", result.Error);
            }
            else if (!string.IsNullOrEmpty(result.Error))
            {
                response.SetError(-1002, result.Error);
                Platform.Tracer.Write("Siemens-SimaticIT-Trace-UADMRuntime", result.Error);
            }

            if (response.Succeeded)
            {
                consumedMaterialExt.DeclaredQuantity = consumedMaterialExt.DeclaredQuantity + consumedMaterial.ConsumedQuantity;

                Platform.Submit(consumedMaterialExt);
            }

            return(response);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.Write("Inserire ERPOrder (string): ");
            string erpOrder = Console.ReadLine();

            Console.Write("Inserire Sequence (int): ");
            int         sequence = Int32.Parse(Console.ReadLine());
            InforResult result   = new InforResult();

            while (true)
            {
                Console.WriteLine("Selezionare richiesta:\n\n 1) Report Production\n 2) Unplanned Material\n 3) Material Non Conformance \n 4) Operation Progress\n");

                int choice = Int32.Parse(Console.ReadLine());


                InvTransfer materialNonConf = new InvTransfer("TestOrderNumber", "TransIdTest;ToWarehouseTest", "StorageUnitTest", Convert.ToDecimal(1.2), "100", "002612155", true);
                try
                {
                    if ((choice > 0) && (choice < 5))
                    {
                        if (choice == 1)
                        {
                            ReportProduction reportProd = new ReportProduction(erpOrder, true, "100");

                            result = InforConnector.ReportProducedQuantity(reportProd);
                        }
                        else if (choice == 2)
                        {
                            Console.Write("\nDammi il consumedMaterialSequence (int): ");
                            int consumedMaterialSequence = Int32.Parse(Console.ReadLine());
                            Console.Write("Dammi il consumedMaterialDef (string): ");
                            string consumedMaterialDef = (Console.ReadLine());
                            Console.Write("Dammi la UoM (string): ");
                            string unit = (Console.ReadLine());
                            Console.Write("Dammi il customized (0/1): ");
                            bool customized = Console.ReadLine() == "0" ? false : true;
                            Console.Write("Dammi la quantity (decimal): ");
                            decimal qty = decimal.Parse(Console.ReadLine());

                            UnplannedMat unplannedMat = new UnplannedMat(erpOrder, sequence, consumedMaterialDef, customized, consumedMaterialSequence, Convert.ToDecimal(qty), unit, "100");

                            result = InforConnector.ReportConsumedMaterial(unplannedMat);
                        }
                        else if (choice == 3)
                        {
                            result = InforConnector.ReportMaterialNonConformance(materialNonConf);
                        }
                        else if (choice == 4)
                        {
                            Console.Write("\nDammi il closeOrder (0/1): ");
                            bool closeOrder = Console.ReadLine() == "0" ? false : true;

                            OperatorOperation operationProg = new OperatorOperation(erpOrder, sequence, 1, "100", closeOrder);

                            result = InforConnector.ReportOperationProgress(operationProg);
                        }

                        Console.WriteLine("Test passed: " + result.InforCallSucceeded.ToString() + " with message: " + result.Error);
                    }
                    else
                    {
                        Console.WriteLine("\nScelta errata");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }