/// <summary> /// 登录登出处理 /// </summary> private bool HandleInOut(string labelData, out MsgLoginResult loginResult) { loginResult = new MsgLoginResult(); try { DataTable dt = dbHelp.GetPIVAsDB(" select * from QRcodeLog a inner join DEmployee b on a.DEmployeeID=b.DEmployeeID where QRcode='" + labelData + "' and DelDT is null and b.IsValid=1 ").Tables[0]; short loginStatus = StaticDictionary.DOCTOR_STATUS_FALSE; //0未登录,1登陆成功; if (dt.Rows.Count > 0) //验证手牌合法,进入判断登录状态并保存 { string employeeID = dt.Rows[0]["DEmployeeID"].ToString(); string employeeName = dt.Rows[0]["DEmployeeName"].ToString(); if (dicEmployeeStatus.ContainsKey(employeeID)) { if (dicEmployeeStatus[employeeID])//上一次状态时登录状态 { //登出成功,返回药师信息 loginStatus = StaticDictionary.DOCTOR_STATUS_FALSE; UpdateCurrentEmployee(string.Empty, string.Empty); } else { //登录成功,返回药师信息 loginStatus = StaticDictionary.DOCTOR_STATUS_TRUE; UpdateCurrentEmployee(employeeID, employeeName); } } else { //不存在,添加保存,返回登录成功,返回药师信息 loginStatus = StaticDictionary.DOCTOR_STATUS_TRUE; UpdateCurrentEmployee(employeeID, employeeName); dicEmployeeStatus.Add(employeeID, true); } loginResult.Status = loginStatus; loginResult.EmployeeName = employeeName; return(true);//手牌合法,根据内容判断是登录还是登出 } } catch (Exception ex) { InternalLogger.Log.Error("药师登录登出处理出错:" + ex.Message); } //验证手牌出错或不合法,都将置空 UpdateCurrentEmployee(string.Empty, string.Empty); return(false); }
/// <summary> /// 发送药师登录状态到屏 /// </summary> public void SendLoginStatus(ScreenClientController screenClientController, string screenIp, int screenPort, short status) { smartThreadPool.QueueWorkItem(() => { try { MsgLoginResult msgLoginResult = new MsgLoginResult(); msgLoginResult.MsgType = (short)MsgType.LoginStatus; msgLoginResult.Status = status; //将登陆状态发给屏,微软屏 screenClientController.sendDataEnqueue(new PivasEventArgs <TCPMessage>(new TCPMessage(screenIp, screenPort, msgLoginResult.ToJson()))); } catch (Exception ex) { InternalLogger.Log.Error("发送药师登录状态到屏出错:" + ex.Message); } }); }
public void Login(MsgLoginResult msg) { this.mainPlayerBallId = msg.ballId; for (var i = 0; i < msg.others.Count; ++i) { AddPlayer(msg.others[i]); } for (var i = 0; i < msg.playerballs.Count; ++i) { OnPlayerEnterAOI(msg.playerballs[i]); } for (var i = 0; i < msg.balls.Count; ++i) { OnItemEnterAOI(msg.balls[i]); } }
/// <summary> /// 收到瓶签收据 /// </summary> /// <returns></returns> public bool GetResultByLabelNo(string labelNo, out string result) { result = string.Empty; try { InternalLogger.Log.Info("收到瓶签号:" + labelNo); bool rtn = false; String labelData = String.Empty; if (IsLogionData(labelNo, out labelData)) //员工登录 { InternalLogger.Log.Debug(labelNo + "被判断为登录信息,因7777开头且长度为22"); MsgLoginResult msgLoginResult = null; rtn = HandleInOut(labelData, out msgLoginResult);//登录处理 if (rtn && msgLoginResult != null) { result = msgLoginResult.ToJson(); } } else if (IsLabelNo(labelNo, out labelData))//只对今天和明天的瓶签计费;并校验瓶签长度和瓶签标识 { InternalLogger.Log.Debug(labelNo + "被判断瓶签数据"); MsgLabelResult msgLabelResult = null; rtn = HandleLabelNo(labelData, out msgLabelResult); if (rtn && msgLabelResult != null) { result = msgLabelResult.ToJson(); } } else { InternalLogger.Log.Warn(labelNo + "被判断为非法Moxa数据,不做处理也不显示"); return(false); //跳出数据接收处理方法 } return(rtn); //登录成功与计费成功都返回rtn } catch (Exception ex) { InternalLogger.Log.Error("接收到Moxa数据,处理出错:" + ex.Message); } return(false); }