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);
        }
        private ReportMaterialNonConformance.Response ReportMaterialNonConformanceHandler(ReportMaterialNonConformance command)
        {
            var  response   = new ReportMaterialNonConformance.Response();
            bool customized = Platform.Query <IMaterialDefinitionExt>().Where(cust => cust.MaterialDefinitionId == command.MaterialDefinitionId).Select(cust => cust.Customized).FirstOrDefault();

            if (command.InforIntegration)
            {
                InvTransfer reportMaterialNonConformance = new InvTransfer(command.OrderNumber, command.RefNum, command.StorageUnit, command.StorageQuantity, command.Plant, command.MaterialDefinitionNId, customized);

                var result = InforConnector.ReportMaterialNonConformance(reportMaterialNonConformance);

                if (result.InforCallSucceeded == false)
                {
                    response.SetError(-1001, result.Error);
                    return(response);
                }
                else if (!string.IsNullOrEmpty(result.Error))
                {
                    response.SetError(-1002, result.Error);
                    return(response);
                }
            }


            var createTBEResponse = Platform.CallCommand <CreateToBeConsumedMaterialExt, CreateToBeConsumedMaterialExt.Response>(new CreateToBeConsumedMaterialExt
            {
                ToBeConsumedMaterials = new List <Types.ToBeConsumedMaterialExtParameter>
                {
                    new Types.ToBeConsumedMaterialExtParameter
                    {
                        Sequence = command.Sequence,
                        ToBeConsumedMaterialId = command.ToBeConsumedMaterialId
                    }
                },
                WorkOrderOperationId = command.WorkOrderOperationid
            });

            var declareTBEQuantityResponse = Platform.CallCommand <DeclareQuantity, DeclareQuantity.Response>(new DeclareQuantity
            {
                ToBeConsumedMaterialId = command.ToBeConsumedMaterialId,
                DeclaredQuantity       = command.StorageQuantity,
                WorkOrderOperationId   = command.WorkOrderOperationid
            });

            return(response);
        }
Exemplo n.º 3
0
        private ReportProducedQuantity.Response ReportProducedQuantityHandler(ReportProducedQuantity command)
        {
            var response = new ReportProducedQuantity.Response();
            ReportProduction reportProduction = new ReportProduction(command.ErpOrder, command.CloseOrder, command.Plant, command.Warehouse);

            var result = InforConnector.ReportProducedQuantity(reportProduction);

            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);
            }

            return(response);
        }
        private ReportConsumedMaterials.Response ReportConsumedMaterialsHandler(ReportConsumedMaterials command)
        {
            var response      = new ReportConsumedMaterials.Response();
            var unplannedMats = new List <UnplannedMat>();
            var matExts       = new Dictionary <int, IToBeConsumedMaterialExt>();

            foreach (var consumedMat in command.ConsumedMaterials)
            {
                bool customized = Platform.Query <IMaterialDefinitionExt>().Where(cust => cust.MaterialDefinitionId == consumedMat.MaterialDefinitionId).Select(cust => cust.Customized).FirstOrDefault();


                IToBeConsumedMaterialExt consumedMaterialExt = Platform.Query <IToBeConsumedMaterialExt>().FirstOrDefault(cms => cms.ToBeConsumedMaterialId == consumedMat.ToBeConsumedMaterialId && cms.WorkOrderOperationId == consumedMat.WorkOrderOperationId);
                matExts.Add(consumedMat.ToBeConsumedMaterialId, consumedMaterialExt);
                unplannedMats.Add(new UnplannedMat(consumedMat.ERPOrder, consumedMat.OrderSequence, consumedMat.MaterialDefinitionNId, customized, consumedMaterialExt.Sequence, consumedMat.ConsumedQuantity, consumedMat.MaterialDefinitionUoM, consumedMat.Plant));
            }


            var result = InforConnector.ReportConsumedMaterials(unplannedMats);

            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)
            {
                foreach (var matEx in command.ConsumedMaterials)
                {
                    matExts[matEx.ToBeConsumedMaterialId].DeclaredQuantity = matExts[matEx.ToBeConsumedMaterialId].DeclaredQuantity + matEx.ConsumedQuantity;
                    Platform.Submit(matExts[matEx.ToBeConsumedMaterialId]);
                }
            }

            return(response);
        }
        private ReportOperationProgress.Response ReportOperationProgressHandler(ReportOperationProgress command)
        {
            var response = new ReportOperationProgress.Response();

            OperatorOperation reportOperationProgress = new OperatorOperation(command.ErpOrder, command.OperationSequence, command.ProducedQuantity, command.Plant, command.IsComplete);

            var result = InforConnector.ReportOperationProgress(reportOperationProgress);

            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);
            }

            return(response);
        }
Exemplo n.º 6
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());
                }
            }
        }