示例#1
0
        public LoginResponse Login(LoginRequest loginRequest)
        {
            var response = new LoginResponse
            {
                Succeeded = true,
                Error     = string.Empty
            };
            UAFConnector uafConnector = null;

            try
            {
                uafConnector = new UAFConnector(loginRequest.User, loginRequest.Password);
            }
            catch (Exception e)
            {
                response.Succeeded = false;
                response.Error     = e.Message;
                return(response);
            }
            var loginResponse = uafConnector.CallCommand <LoginUser, LoginUser.Response>(new LoginUser {
                User = loginRequest.User
            });

            if (!loginResponse.Succeeded)
            {
                response.Succeeded = false;
                response.Error     = $"Errore {loginResponse.Error.ErrorCode}: {loginResponse.Error.ErrorMessage}";
                return(response);
            }
            response.Equipment = loginResponse.Equipment;
            response.WorkArea  = loginResponse.WorkAreas.First();
            response.Role      = (OTRole)Enum.Parse(typeof(OTRole), loginResponse.Role);
            return(response);
        }
示例#2
0
 public override MaterialDefinitionResponse ImportMaterialDefinition(MaterialDefinitionRequest MaterialDefinition)
 {
     try
     {
         var uafConnector = new UAFConnector();
         var response     = uafConnector.CallCommand <ImportMaterialDefinition, ImportMaterialDefinition.Response>(new ImportMaterialDefinition
         {
             Customized       = MaterialDefinition.Customized,
             Description      = MaterialDefinition.Description,
             MaterialCode     = MaterialDefinition.MaterialCode,
             MaterialFamily   = MaterialDefinition.MaterialFamily,
             MaterialRevision = MaterialDefinition.MaterialRevision,
             Serialized       = MaterialDefinition.Serialized,
             UoM = MaterialDefinition.UoM
         });
         if (!response.Succeeded)
         {
             throw new Exception($"Error {response.Error.ErrorCode}: {response.Error.ErrorMessage}");
         }
         return(new MaterialDefinitionResponse {
             MaterialCode = response.MaterialCode, MaterialRevision = response.MaterialRevision
         });
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#3
0
        public AcceptTeamLeaderCallResponse AcceptTeamLeaderCall(AcceptTeamLeaderCallRequest acceptTeamLeaderCall)
        {
            var response = new AcceptTeamLeaderCallResponse
            {
                Succeeded = true,
                Error     = string.Empty
            };
            UAFConnector uafConnector = null;

            try
            {
                uafConnector = new UAFConnector(acceptTeamLeaderCall.User, acceptTeamLeaderCall.Password);
            }
            catch (Exception e)
            {
                response.Succeeded = false;
                response.Error     = e.Message;
                return(response);
            }
            var uafResponse = uafConnector.CallCommand <DABAcceptTeamLeaderCall, DABAcceptTeamLeaderCall.Response>(new DABAcceptTeamLeaderCall
            {
                Id         = acceptTeamLeaderCall.CallId,
                TeamLeader = acceptTeamLeaderCall.User
            });

            if (!uafResponse.Succeeded)
            {
                response.Succeeded = false;
                response.Error     = $"Errore {uafResponse.Error.ErrorCode}: {uafResponse.Error.ErrorMessage}";
                return(response);
            }
            CallHub.Static_TeamLeaderCallAccepted(acceptTeamLeaderCall.Equipment, acceptTeamLeaderCall.CallId.ToString());
            //SmartWatchConnector.TeamLeaderComing(acceptTeamLeaderCall.Equipment);
            return(response);
        }
示例#4
0
        public GetTeamLeaderCallsResponse GetTeamLeaderCalls(GetTeamLeaderCallsRequest getTeamLeaderCalls)
        {
            var response = new GetTeamLeaderCallsResponse()
            {
                Succeeded       = true,
                Error           = string.Empty,
                TeamLeaderCalls = new List <DataContracts.Call>()
            };
            UAFConnector uafConnector = null;

            try
            {
                uafConnector = new UAFConnector(getTeamLeaderCalls.User, getTeamLeaderCalls.Password);
            }
            catch (Exception e)
            {
                response.Succeeded = false;
                response.Error     = e.Message;
                return(response);
            }

            var teamLeaderCalls = uafConnector.ProjectionQuery <RM.TeamLeaderCall>().Where(mc => mc.WorkArea == getTeamLeaderCalls.WorkArea && !mc.Accepted).ToList();

            response.TeamLeaderCalls.AddRange(teamLeaderCalls.Select(tlc => new Call
            {
                WorkArea = tlc.WorkArea,
                CallDate = tlc.Date.ToLocalTime().DateTime,
                CallId   = tlc.Id,
                //Description = mc.Description,
                Equipment = tlc.Equipment,
                //SerialNumber = mc.SerialNumber,
                Status = tlc.Accepted ? "Accepted" : "Pending"
            }).OrderBy(tlc => tlc.CallDate));
            return(response);
        }
示例#5
0
        public AcceptMaterialCallResponse AcceptMaterialCall(AcceptMaterialCallRequest acceptMaterialCall)
        {
            var response = new AcceptMaterialCallResponse
            {
                Succeeded = true,
                Error     = string.Empty
            };
            UAFConnector uafConnector = null;

            try
            {
                uafConnector = new UAFConnector(acceptMaterialCall.User, acceptMaterialCall.Password);
            }
            catch (Exception e)
            {
                response.Succeeded = false;
                response.Error     = e.Message;
                return(response);
            }
            var uafResponse = uafConnector.CallCommand <DABAcceptMaterialCall, DABAcceptMaterialCall.Response>(new DABAcceptMaterialCall
            {
                Id         = acceptMaterialCall.CallId,
                TeamLeader = acceptMaterialCall.User
            });

            if (!uafResponse.Succeeded)
            {
                response.Succeeded = false;
                response.Error     = $"Errore {uafResponse.Error.ErrorCode}: {uafResponse.Error.ErrorMessage}";
                return(response);
            }
            return(response);
        }
示例#6
0
        static void Main(string[] args)
        {
            var Platform = new UAFConnector();

            while (true)
            {
                Console.ReadLine();
                //Platform.FireEvent(new Events.UpdateAndon("100.DM1.D103"));
                new Program().Update(new AndonEvent());
            }
        }
示例#7
0
 static void Main(string[] args)
 {
     try
     {
         UAFConnector uafConnector = new UAFConnector();
         uafConnector.CallCommand <DABImportDocuments, DABImportDocuments.Response>(new DABImportDocuments());
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         Console.ReadLine();
     }
     Environment.Exit(0);
 }
示例#8
0
        static void Main(string[] args)
        {
            while (true)
            {
                try
                {
                    Console.WriteLine("Enter a Serial Number: ");
                    Console.WriteLine("00000000001");
                    string serialNumber = Console.ReadLine();
                    DABGetTestCard.Response response = UAFConnector.StaticDABGetTestCard(serialNumber);

                    TestResultParameter testResult = new TestResultParameter
                    {
                        CorrenteDiTerra      = 1,
                        CorrenteRigidita     = 1,
                        DescrizioneEsito     = "",
                        Esito                = "PASS",
                        ResistenzaDiTerra    = 1,
                        ResistenzaIsolamento = 1,
                        SerialNumber         = serialNumber,
                        TensioneIsolamento   = 1,
                        TensioneRigidita     = 1,
                    };
                    Console.WriteLine(response.Succeeded ? "DABGetTestCard Succeeded" : $"DABGetTestCard Error {response.Error.ErrorCode}: {response.Error.ErrorMessage}");
                    //per ogni assorbimento
                    testResult.Assorbimenti.Add(new AbsorptionResultParameter
                    {
                        Nome               = "ASS1",
                        AmpereFase1        = 1,
                        AmpereFase2        = 1,
                        AmpereFase3        = 1,
                        FattoreDiPotenza   = 1,
                        Portata            = 1,
                        Watt               = 1,
                        Pressione          = 1,
                        SquilibrioCorrenti = 1,
                        TensioneProva      = 1,
                    });
                    var sendResponse = UAFConnector.StaticDABSendTestResult(testResult);
                    Console.WriteLine(sendResponse.Succeeded ? "DABGetTestCard Succeeded" : $"DABGetTestCard Error {sendResponse.Error.ErrorCode}: {sendResponse.Error.ErrorMessage}");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }
示例#9
0
        public GetSerialsResponse GetSerials(GetSerialsRequest getSerials)
        {
            var response = new GetSerialsResponse
            {
                Succeeded = true,
                Error     = string.Empty,
                Orders    = new List <OrderItem>()
            };
            UAFConnector uafConnector = null;

            try
            {
                uafConnector = new UAFConnector(getSerials.User, getSerials.Password);
            }
            catch (Exception e)
            {
                response.Succeeded = false;
                response.Error     = e.Message;
                return(response);
            }
            var uafResponse = uafConnector.CallCommand <GetSerials, GetSerials.Response>(new GetSerials
            {
                Equipment = getSerials.Equipment
            });

            if (!uafResponse.Succeeded)
            {
                response.Succeeded = false;
                response.Error     = $"Errore {uafResponse.Error.ErrorCode}: {uafResponse.Error.ErrorMessage}";
                return(response);
            }

            response.Orders.AddRange(uafResponse.Orders.Select(o => new OrderItem
            {
                Description = o.Description,
                Operation   = o.Operation,
                OperationId = o.OperationId,
                Order       = o.Order,
                ProductCode = o.ProductCode,
                Serials     = o.Serials.Select(s => new SerialItem {
                    SerialNumber = s.SerialNumber, Status = s.Status
                }).OrderBy(s => s.SerialNumber).ToList()
            }));
            response.Orders = response.Orders.OrderBy(o => o.Order).ToList();
            return(response);
        }
示例#10
0
        public SendMaterialCallResponse SendMaterialCall(SendMaterialCallRequest materialCall)
        {
            var response = new SendMaterialCallResponse
            {
                Succeeded = true,
                Error     = string.Empty
            };
            UAFConnector uafConnector = null;

            try
            {
                uafConnector = new UAFConnector(materialCall.User, materialCall.Password);
            }
            catch (Exception e)
            {
                response.Succeeded = false;
                response.Error     = e.Message;
                return(response);
            }
            var uafResponse = uafConnector.CallCommand <DABCreateMaterialCall, DABCreateMaterialCall.Response>(new DABCreateMaterialCall
            {
                Equipment          = materialCall.Equipment,
                WorkArea           = materialCall.WorkArea,
                Operatore          = materialCall.User,
                MaterialDefinition = string.Empty,
                Operation          = " ",
                WorkOrder          = " "
            });

            if (!uafResponse.Succeeded)
            {
                response.Succeeded = false;
                response.Error     = $"Errore {uafResponse.Error.ErrorCode}: {uafResponse.Error.ErrorMessage}";
                return(response);
            }
            response.Id = uafResponse.Id.Value;
            //SmartWatchConnector.SendMaterialCall(materialCall.WorkArea, materialCall.Equipment, materialCall.SerialNumber, uafResponse.Id.Value);
            CallHub.Static_SendMaterialCall(materialCall.WorkArea, materialCall.Equipment);
            return(response);
        }
示例#11
0
        public SendTeamLeaderCallResponse SendTeamLeaderCall(SendTeamLeaderCallRequest teamLeaderCall)
        {
            var response = new SendTeamLeaderCallResponse
            {
                Succeeded = true,
                Error     = string.Empty
            };
            UAFConnector uafConnector = null;

            try
            {
                uafConnector = new UAFConnector(teamLeaderCall.User, teamLeaderCall.Password);
            }
            catch (Exception e)
            {
                response.Succeeded = false;
                response.Error     = e.Message;
                return(response);
            }
            var uafResponse = uafConnector.CallCommand <DABCreateTeamLeaderCall, DABCreateTeamLeaderCall.Response>(new DABCreateTeamLeaderCall
            {
                Equipment = teamLeaderCall.Equipment,
                WorkArea  = teamLeaderCall.WorkArea,
                Operatore = teamLeaderCall.User
            });

            if (!uafResponse.Succeeded)
            {
                response.Succeeded = false;
                response.Error     = $"Errore {uafResponse.Error.ErrorCode}: {uafResponse.Error.ErrorMessage}";
                return(response);
            }
            response.Id = uafResponse.Id.Value;
            //SmartWatchConnector.SendTeamLeaderlCall(teamLeaderCall.WorkArea, teamLeaderCall.Equipment, uafResponse.Id.Value);
            CallHub.Static_SendTeamLeaderCall(teamLeaderCall.WorkArea, teamLeaderCall.Equipment);
            return(response);
        }
示例#12
0
        public override ERPOrderResponse ImportERPOrder(ERPOrderRequest ERPOrderInfo)
        {
            var uafConnector = new UAFConnector();

            ImportERPOrder input = new ImportERPOrder(new Engineering.DAB.AppDAB.AppDAB.DPPOMModel.Types.ERPOrderRequest()
            {
                ERPId                 = ERPOrderInfo.ERPId,
                FinalMaterialCode     = ERPOrderInfo.FinalMaterialCode,
                FinalMaterialRevision = ERPOrderInfo.FinalMaterialRevision,
                Orders                = new List <ERPOrderPhase> {
                },
                Priority              = ERPOrderInfo.Priority,
                Quantity              = ERPOrderInfo.Quantity,
                Warehouse             = ERPOrderInfo.Warehouse
            });


            foreach (var order in ERPOrderInfo.Orders)
            {
                if (!string.IsNullOrEmpty(order.CycleTime))
                {
                    input.ERPOrderInfo.CycleTime = XmlConvert.ToTimeSpan(order.CycleTime);
                }
                if (!string.IsNullOrEmpty(order.SetupTime))
                {
                    input.ERPOrderInfo.SetupTime = XmlConvert.ToTimeSpan(order.SetupTime);
                }
                DateTime estimatedStart = order.EstimatedStartTime.Year > 1900 ? order.EstimatedStartTime : DateTime.UtcNow.AddMinutes(3);
                DateTime estimatedEnd   = order.EstimatedEndTime.Year > 1900 ? order.EstimatedEndTime : order.EstimatedStartTime.AddMinutes(input.ERPOrderInfo.CycleTime.TotalMinutes * input.ERPOrderInfo.Quantity);


                input.ERPOrderInfo.EstimatedEndTime   = estimatedEnd;
                input.ERPOrderInfo.EstimatedStartTime = estimatedStart;
                input.ERPOrderInfo.Operators          = order.Operators;
                var orderPhase = new ERPOrderPhase
                {
                    Name                  = order.Name,
                    NextOrder             = order.NextOrder,
                    Sequence              = order.Sequence,
                    ToBeConsumedMaterials = new List <ERPConsumedMaterial>(),
                    WorkArea              = order.WorkArea
                };
                foreach (var mat in order.ToBeConsumedMaterials)
                {
                    orderPhase.ToBeConsumedMaterials.Add(new ERPConsumedMaterial
                    {
                        MaterialCode     = mat.MaterialCode,
                        MaterialRevision = mat.MaterialRevision,
                        Quantity         = mat.Quantity,
                        Sequence         = mat.Sequence,
                        UoM = mat.UoM
                    });
                }
                input.ERPOrderInfo.Orders.Add(orderPhase);
            }

            var response = uafConnector.CallCommand <ImportERPOrder, ImportERPOrder.Response>(input);

            if (!response.Succeeded)
            {
                throw new Exception($"Error {response.Error.ErrorCode}: {response.Error.ErrorMessage}");
            }
            return(new ERPOrderResponse {
                WorkOrderId = response.WorkOrderIds.First(), WorkOrderNId = ERPOrderInfo.ERPId
            });
        }
示例#13
0
        public StartSerialResponse StartSerial(StartSerialRequest startSerialRequest)
        {
            var response = new StartSerialResponse
            {
                Succeeded = true,
                Error     = string.Empty
            };
            UAFConnector uafConnector = null;

            try
            {
                uafConnector = new UAFConnector(startSerialRequest.User, startSerialRequest.Password);
            }
            catch (Exception e)
            {
                response.Succeeded = false;
                response.Error     = e.Message;
                return(response);
            }

            if (startSerialRequest.Status == "Active")
            {
                var uafResponse = uafConnector.CallCommand <DABCompleteSerial, DABCompleteSerial.Response>(new DABCompleteSerial
                {
                    //EquipmentNId = startSerialRequest.Equipment,
                    //MaterialDefinitionNId = startSerialRequest.ProductCode,
                    //SerialNumber = startSerialRequest.SerialNumber,
                    //WorkOrderOperationNId = startSerialRequest.Operation
                    CompleteSerializedWoOpParameterList = new List <CompleteSerializedParameterType>
                    {
                        new CompleteSerializedParameterType
                        {
                            EquipmentNId            = startSerialRequest.Equipment,
                            NId                     = startSerialRequest.Operation,
                            Id                      = startSerialRequest.OperationId,
                            ActualProducedMaterials = new List <MaterialItemParameterType>
                            {
                                new MaterialItemParameterType
                                {
                                    EquipmentNId          = startSerialRequest.Equipment,
                                    MaterialDefinitionNId = startSerialRequest.ProductCode,
                                    SerialNumber          = startSerialRequest.SerialNumber,
                                    NId = startSerialRequest.SerialNumber
                                }
                            }
                        }
                    }
                });
                if (!uafResponse.Succeeded)
                {
                    response.Succeeded = false;
                    response.Error     = $"Errore {uafResponse.Error.ErrorCode}: {uafResponse.Error.ErrorMessage}";
                    return(response);
                }
            }
            else
            {
                var uafResponse = uafConnector.CallCommand <DABStartSerial, DABStartSerial.Response>(new DABStartSerial
                {
                    //EquipmentNId = startSerialRequest.Equipment,
                    //MaterialDefinitionNId = startSerialRequest.ProductCode,
                    //SerialNumber = startSerialRequest.SerialNumber,
                    //WorkOrderOperationNId = startSerialRequest.Operation
                    StartWOOperationSerializedParameterTypeList = new List <StartSerializedParameterType>
                    {
                        new StartSerializedParameterType
                        {
                            EquipmentNId = startSerialRequest.Equipment,
                            NId          = startSerialRequest.Operation,
                            Id           = startSerialRequest.OperationId,
                            //EquipmentName = startSerialRequest.Equipment,
                            ToBeProducedMaterials = new List <MaterialItemParameterType>
                            {
                                new MaterialItemParameterType
                                {
                                    EquipmentNId          = startSerialRequest.Equipment,
                                    MaterialDefinitionNId = startSerialRequest.ProductCode,
                                    SerialNumber          = startSerialRequest.SerialNumber,
                                    NId = startSerialRequest.SerialNumber
                                }
                            }
                        }
                    }
                });
                if (!uafResponse.Succeeded)
                {
                    response.Succeeded = false;
                    response.Error     = $"Errore {uafResponse.Error.ErrorCode}: {uafResponse.Error.ErrorMessage}";
                    return(response);
                }
            }
            if (response.Succeeded == true)
            {
                CallHub.Static_SendOperatorCall(startSerialRequest.WorkArea, startSerialRequest.SerialNumber);
                //SmartWatchConnector.RefreshSerials(startSerialRequest.WorkArea);
            }
            return(response);
        }