Пример #1
0
 /// <summary>
 /// 拧紧机消息接收
 /// </summary>
 /// <param name="msg"></param>
 private void OnTightenMessage(OpMessage msg)
 {
     try
     {
         _logger.Info($"接收到拧紧机信息{msg.SequenceNumber}");
         if (msg.SequenceNumber == 0061)//SequenceNumber就是Mid
         {
             client.LastTighteningResultDataAcknowledge();
             ReadLastTightenData(msg);
         }
         else if (msg.SequenceNumber == 0052)
         {
             client.VehicleIdNumberAcknowledge();
             string vinnumber = msg.Get <string>("VinNumber").Trim();
             ReadVinNumber(vinnumber);
         }
         else if (msg.SequenceNumber == 0005)
         {
             _logger.Debug("接收到拧紧机0005消息,消息体含命令:" + msg.Get <string>("MidAccepted"));
         }
     }
     catch (Exception ex)
     {
         _logger.Error("OnTightenMessage", ex);
     }
 }
Пример #2
0
        /// <summary>
        /// 获取系统信息
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        protected T RetrieveSystemData <T>(string operation)
        {
            OpMessage opMsg = new OpMessage();

            opMsg.Operation = operation;

            T obj = ServiceHelper.DeserializeFromBytes <T>(USService.GetSystemData(opMsg.ToString()));

            return(obj);
        }
Пример #3
0
        /// <summary>
        /// 执行服务
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public byte[] ExecuteService(string msg)
        {
            try
            {
                OpMessage opMsg = new OpMessage(msg);

                return(ExecuteServiceByMsgObj(new OpMessage(msg)));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// 获取系统数据
        /// </summary>
        /// <returns></returns>
        public byte[] GetSystemData(string msg)
        {
            try
            {
                OpMessage opMsg = new OpMessage(msg);
                opMsg.Lable = "GetSystemData";

                return(ExecuteServiceByMsgObj(opMsg));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Пример #5
0
        public string GetSystemDataJson(string msg)
        {
            try
            {
                OpMessage opMsg = new OpMessage(msg);
                opMsg.Lable = "GetSystemData";

                return(ExecuteServiceByMsgString(opMsg));
            }
            catch (Exception ex)
            {
                return("");
            }
        }
Пример #6
0
 /// <summary>
 /// 读取拧紧数据
 /// </summary>
 /// <param name="msg"></param>
 private void ReadLastTightenData(OpMessage msg)
 {
     try
     {
         TighteningResultModel result = new TighteningResultModel();
         result.EngineCode = msg.Get <string>("VinNumber").Trim();
         result.Torque     = !decimal.TryParse(msg.Get <string>("Torque"), out decimal torque) ? -1 : torque / 100.0m;
         result.Angle      = !decimal.TryParse(msg.Get <string>("Angle"), out decimal angle) ? -1 : angle;
         result.Result     = !int.TryParse(msg.Get <string>("TighteningStatus"), out int status3) ? -1 : status3;
         result.ResultTime = result.CreateTime = DateTime.Now;
         DisplayData(result);
         SaveTightenData(result);
     }
     catch (Exception ex)
     {
         _logger.Error("ReadLastTightenData", ex);
     }
 }
Пример #7
0
        private byte[] ExecuteServiceByMsgObj(OpMessage opMsg)
        {
            try
            {
                byte[] data    = null;
                Object dataObj = null;

                if (String.IsNullOrEmpty(opMsg.Operation))
                {
                    return(null);
                }

                string label = (opMsg.Lable == null ? String.Empty : opMsg.Lable).ToLower();
                string op    = (opMsg.Operation == null ? String.Empty : opMsg.Operation).ToLower();

                if (label == "getuserdata")
                {
                    using (new SessionScope())
                    {
                        UserLogonInfo  logonInfo = Server.GetLogonInfo(opMsg.SessionID);
                        IList <string> ids       = new List <string>();

                        if (logonInfo != null)
                        {
                            if (op == "getlogoninfo")
                            {
                                dataObj = logonInfo;
                            }
                            else if (op == "getalluserauth")
                            {
                                dataObj = logonInfo.User.RetrieveAllAuth();
                            }
                            else if (op == "getallusergroup")
                            {
                                dataObj = logonInfo.User.RetrieveAllGroup();
                            }
                            else if (op == "getalluserrole")
                            {
                                dataObj = logonInfo.User.RetrieveAllRole();
                            }
                            else if (op == "getalluserauthids")
                            {
                                IList <SysAuth>      auths   = logonInfo.User.RetrieveAllAuth();
                                IEnumerable <string> authIDs = auths.Select(ent => { return(ent.AuthID); });

                                dataObj = new List <string>(authIDs);
                            }
                            else if (op == "getallusergroupids")
                            {
                                IList <SysGroup>     grps   = logonInfo.User.RetrieveAllGroup();
                                IEnumerable <string> grpIDs = grps.Select(ent => { return(ent.GroupID); });

                                dataObj = new List <string>(grpIDs);
                            }
                            else if (op == "getalluserroleids")
                            {
                                IList <SysRole>      roles   = logonInfo.User.RetrieveAllRole();
                                IEnumerable <string> roleIDs = roles.Select(ent => { return(ent.RoleID); });

                                dataObj = new List <string>(roleIDs);
                            }
                            else if (op == "getuserinfo")
                            {
                                dataObj = new SimpleUserInfo(logonInfo);
                            }
                            else if (op == "getsysuser")
                            {
                                dataObj = logonInfo.User;
                            }
                        }
                    }
                }
                else if (label == "getsystemdata")
                {
                    using (new SessionScope())
                    {
                        if (opMsg.Operation == "getallapplications")
                        {
                            dataObj = new List <SysApplication>(SysApplicationRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallmodules")
                        {
                            dataObj = new List <SysModule>(SysModuleRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallgroups")
                        {
                            dataObj = new List <SysGroup>(SysGroupRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallusers")
                        {
                            dataObj = new List <SysUser>(SysUserRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallroles")
                        {
                            dataObj = new List <SysRole>(SysRoleRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallauths")
                        {
                            dataObj = new List <SysAuth>(SysAuthRule.FindAll());
                        }
                    }
                }
                else
                {
                    try
                    {
                        if (op == "checkusersession")
                        {
                            dataObj = Server.CheckUserSession(opMsg.SessionID);
                        }
                        else if (op == "releasesession")
                        {
                            dataObj = Server.ReleaseSession(opMsg.SessionID);
                        }
                        else if (op == "setpreprelease")
                        {
                            if (opMsg["logmode"].Type != TypeCode.Empty)
                            {
                                Server.SetPrepRelease(opMsg.SessionID, (LoginTypeEnum)opMsg["logmode"].Value);
                            }
                            else
                            {
                                Server.SetPrepRelease(opMsg.SessionID);
                            }

                            Server.SetPrepRelease(opMsg.SessionID);
                        }
                        else if (op == "refreshsession")
                        {
                            Server.RefreshSession(opMsg.SessionID);
                        }
                    }
                    catch (Exception ex)
                    {
                        dataObj = false;
                    }
                }

                if (dataObj != null)
                {
                    data = ServiceHelper.SerializeToBytes(dataObj);
                }

                return(data);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }