private async void Templet_Load(object sender, RibbonUIEventArgs e) { if (FileHelper.FileExist(userFileName)) { try { UserMsg userMsg = await FileHelper.ReadObject <UserMsg>(userFileName); FormFactory.JWTToken = await WebHelper.GetJson <UserMsg, Token>(userMsg, userMsg.IPAddress + "/JsonAPI/GetUser/"); if (FormFactory.JWTToken.StateCode != StateCode.normal) { MessageBox.Show(FormFactory.JWTToken.StateDescription); FormFactory.JWTToken = null; } else { UserName.Text = userMsg.UserName; PassWord.Text = userMsg.UserPassword; IPAddr.Text = userMsg.IPAddress; FormFactory.userMsg = userMsg; } } catch { await FileHelper.DeleteFile(userFileName); IPAddr.Text = "http://office.xiaowenyu.top"; } } else { IPAddr.Text = "http://office.xiaowenyu.top"; } }
/// <summary> /// 服务器端收到信息事件 /// </summary> /// <param name="netMsg">Net message.</param> private void ServerGet(NetworkMessage netMsg) { UserMsg Msg = netMsg.ReadMessage <UserMsg>(); //test ssd= netMsg.ReadMessage<test>(); ShowMsg("Server get:" + Msg.message); }
private void button1_Click(object sender, EventArgs e) { //数据采集 UserMsg um = new UserMsg(); string loginId = textBox1.Text; string psw1 = textBox2.Text; string psw2 = textBox3.Text; string userName = textBox4.Text; if (psw1 != psw2) { MessageBox.Show("两次输入不正确"); return; } else { um.CC_LoginId = loginId; um.CC_UserName = userName; um.CC_LoginPassWord = psw1; T_SeatsBll bll = new T_SeatsBll(); if (bll.Register(um) > 0) { MessageBox.Show("注册成功"); } } }
public DataTable GetData(int year) { try { IBaseDAO baseDAOSQLite = BaseDAOFactory.GetBaseDAOSQLite(); Dictionary <string, object> dictionary = new Dictionary <string, object>(); string str = year.ToString(); dictionary.Add("Year", str); UserMsg msg = new UserMsg(); if (msg.IsAdmin) { dictionary.Add("AdminBz", 1); } else { dictionary.Add("AdminBz", 0); } dictionary.Add("Admin", msg.MC); return(baseDAOSQLite.querySQLDataTable("aisino.fwkp.fpkj.YFCX", dictionary)); } catch (BaseException exception) { this.loger.Error(exception.Message); MessageManager.ShowMsgBox(exception.Message); return(null); } catch (Exception exception2) { this.loger.Error(exception2.Message); MessageManager.ShowMsgBox(exception2.Message); return(null); } }
/// <summary> /// 客户端接收到服务器端信息事件 /// </summary> /// <param name="netMsg">Net message.</param> private void ClientGet(NetworkMessage netMsg) { UserMsg Msg = netMsg.ReadMessage <UserMsg> (); Camera.main.transform.localPosition = Msg.message; Camera.main.fieldOfView = Msg.sendFOV; ShowMsg("Client get:" + Msg.message); }
public void SetHexView(object obj) { if (obj != null) { UserMsg m = obj as UserMsg; string strHex = ""; int sub = m.Msg.Length % 16; for (int i = 0; i < m.Msg.Length; i++) { strHex += String.Format("{0:X2} ", m.Msg[i]); if ((i + 1) % 16 == 0) { for (int j = 0; j < 0x10; j++) { char c = (char)(m.Msg[i - 15 + j]); if (c >= 32 && c <= 126) { strHex += c; } else { strHex += '.'; } } strHex += '\n'; } } if (sub != 0) { //最后一行字符 int len = 16 - sub; for (int i = 0; i < len; i++) { strHex += ' '; strHex += ' '; strHex += ' '; } for (int i = 0; i < sub; i++) { char c = (char)(m.Msg[m.Msg.Length - sub + i]); if (c >= 32 && c <= 126) { strHex += c; } else { strHex += '.'; } } } HexContent = strHex; base.OnPropertyChanged("HexContent"); } }
/// <summary> /// 根据用户信息注册 /// </summary> /// <param name="um"></param> /// <returns></returns> public int Register(UserMsg um) { //CC_AutoId,CC_LoginId,CC_LoginPassWord,CC_UserName,CC_ErrorTimes,CC_LockDateTime,CC_TestInt string sql = "insert into T_seats(CC_LoginId,CC_LoginPassWord,CC_UserName) values(@uid,@psw,@username)"; SqlParameter[] pars = new SqlParameter[]{ new SqlParameter("@uid",um.CC_LoginId), new SqlParameter("@psw",um.CC_LoginPassWord), new SqlParameter("@username",um.CC_UserName) }; return SqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text, pars); }
/// <summary> /// 客户端向服务器端发送信息 /// </summary> public void ClientSend() { if (myClient.isConnected) { UserMsg um = new UserMsg(); um.message = send.text; if (myClient.Send(userMsg, um)) { ShowMsg("Client send:" + um.message); } } }
/// <summary> /// 客户端向服务器端发送信息 /// </summary> public void ClientSend() { if (myClient.isConnected) { UserMsg um = new UserMsg(); um.message = sendPos; um.sendFOV = sendFOV; if (myClient.Send(userMsg, um)) { ShowMsg("Client send:" + sendPos); } } }
public IActionResult InsertMessage([FromForm] UserMsg messages) { try { Logger.Info("CreateChannel method is called..."); var data = _saveData.InsertMessage(messages); return(Ok(data)); } catch (Exception ex) { Logger.Error("Error has occured in GetUserFCMToken method " + ex.Message); throw ex; } }
private MainMessage HandleUserMsg(MainMessage msg) { UserMsg userMsg = msg.UserMngMsg.UserMsg; switch (userMsg.UserMsgTypeCase) { case UserMsg.UserMsgTypeOneofCase.UserRequestMsg: return(HandleUserRequest(msg)); default: return(ISystemService.CreateErrorMessage(0, 0, 0, this.GetType().Name + ": Cannot handle this type of message.")); } }
//--------------------------------------------------------------------------- static public bool fn_UserMsgClose() { if (!UserMsg.IsVisible) { return(false); } // UserMsg.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { UserMsg.Hide(); })); return(true); }
/// <summary> /// 服务器端向所有客户端发送信息 /// </summary> public void ServerSend() { if (NetworkServer.active) { UserMsg um = new UserMsg(); sendPos = GetComponent <Camera> ().transform.localPosition; sendFOV = GetComponent <Camera> ().fieldOfView; um.message = sendPos; um.sendFOV = sendFOV; if (NetworkServer.SendToAll(userMsg, um)) { ShowMsg("Server send:" + sendPos); } } }
public ActionResult GetUser(UserMsg user) { UserInfo userInfo = ServiceSessionFactory.ServiceSession.UserInfoService.LoadEntity(u => u.UserName == user.UserName).FirstOrDefault();//验证用户名并取用户实体 if (userInfo == null) { return(Json(new Token() { StateCode = StateCode.noUser, StateDescription = "用户不存在" })); } if (userInfo.UserPwd != user.UserPassword) { return(Json(new Token() { StateCode = StateCode.wrongPassword, StateDescription = "用户名或密码错误" })); } userInfo.Organization = userInfo.Organization ?? new OrganizationInfo() { ID = new Guid() }; Claim[] claims = new Claim[] { //新建证书 new Claim(ClaimTypes.Sid, userInfo.ID.ToString()), //用户ID new Claim(ClaimTypes.Name, user.UserName), //用户名 new Claim(ClaimTypes.GroupSid, userInfo.Organization.ID.ToString()), //用户所在组织ID new Claim(ClaimTypes.Role, userInfo.UserAuth.ToString()) //用户权限 }; SymmetricSecurityKey key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(token.SecretKey)); //创建秘钥 SigningCredentials sign = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); //从秘钥创建签名 JwtSecurityToken jwtToken = new JwtSecurityToken( //创建TOKEN token.Issuer, token.Audience, claims, DateTime.Now, DateTime.Now.AddMinutes(30), sign ); return(Json(new Token() { StateCode = StateCode.normal, StateDescription = "登陆成功", TokenValue = new JwtSecurityTokenHandler().WriteToken(jwtToken) })); //返回生成的Token }
public void SendPacket(ushort packet_type, TransmitParameters.ToPackArgu toPackArgu = null) { TransmitParameters.CallArgus mCallArgus1 = new TransmitParameters.CallArgus(); mCallArgus1.pack_argu = new TransmitParameters.PackArgus(); mCallArgus1.pack_argu.toPackArgu = new TransmitParameters.ToPackArgu(); if (toPackArgu == null) { mCallArgus1.pack_argu.toPackArgu = new TransmitParameters.ToPackArgu(); } else { mCallArgus1.pack_argu.toPackArgu = toPackArgu; } mCallArgus1.pack_argu.toPackArgu.type = packet_type; MemoryStream ms1 = new MemoryStream(); ProtoBuf.Serializer.Serialize(ms1, mCallArgus1); byte[] msg = new byte[1024]; uint size = (uint)msg.Length; MyLibInterface.PackPacket(ms1.ToArray(), (uint)ms1.Length, ref msg, ref size); MemoryStream ms2 = new MemoryStream(); ms2.Write(msg, 0, (int)size); ms2.Position = 0; TransmitParameters.CallArgus mCallArgus = ProtoBuf.Serializer.Deserialize <TransmitParameters.CallArgus>(ms2); MyLibInterface.SendPacket(mCallBackFuctions._Socket, mCallArgus.pack_argu.pack_data.msg, (uint)mCallArgus.pack_argu.pack_data.msg.Length); System.Threading.ThreadPool.QueueUserWorkItem(delegate { UserMsg userMsg = new UserMsg(); userMsg.isSend = true; userMsg.cTime = DateTime.Now.ToString("HH:mm:ss"); userMsg.Code = packet_type; userMsg.Msg = mCallArgus.pack_argu.pack_data.msg; Application.Current.Dispatcher.Invoke(new AddAStudentEvent(this.AddAStudent), userMsg); }); }
private async void btnSaveSetting_Click(object sender, RibbonControlEventArgs e) { UserMsg userMsg = new UserMsg() { UserName = UserName.Text, UserPassword = PassWord.Text, IPAddress = IPAddr.Text }; FormFactory.JWTToken = await WebHelper.GetJson <UserMsg, Token>(userMsg, IPAddr.Text + @"/JsonAPI/GetUser"); if (FormFactory.JWTToken.StateCode != StateCode.normal) { MessageBox.Show(FormFactory.JWTToken.StateDescription); FormFactory.JWTToken = null; } else { MessageBox.Show("登陆成功"); await FileHelper.SaveObject(userMsg, userFileName); FormFactory.userMsg = userMsg; } }
static public bool fn_UserMsg(string msg, EN_MSG_TYPE type, string caption, EN_SHOW_MODE modal) { bool rtn = false; if (SEQ._bRun && (SEQ._iStep > 13 && SEQ._iStep < 16)) { return(false); //JUNG/200418/Check Run } if (UserMsg.IsVisible) { //UserMsg.Topmost = true; //UserMsg.Show(); fn_UserMsgClose(); //return false; } // UserMsg.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { UserMsg.fn_SetMsg(msg, caption, type); fn_WriteLog(msg); //JUNG/200922 //사용할 메서드 및 동작 if (modal == EN_SHOW_MODE.Modal || type == EN_MSG_TYPE.Check) { UserMsg.ShowDialog(); } else { //UserMsg.Topmost = true; UserMsg.Show(); } rtn = UserMsg._bResult || (UserMsg.DialogResult.HasValue && UserMsg.DialogResult.Value); })); return(rtn); }
public void PacketMessageHander(TransmitParameters.CallArgus mCallArgu) { if (!mCallArgu.isCallSucess) { return; } System.Threading.ThreadPool.QueueUserWorkItem(delegate { UserMsg userMsg = new UserMsg(); userMsg.isSend = false; userMsg.cTime = DateTime.Now.ToString("HH:mm:ss"); userMsg.Code = mCallArgu.pack_argu.unpack_data.type; userMsg.Msg = mCallArgu.pack_argu.unpack_data.data; Application.Current.Dispatcher.Invoke(new AddAStudentEvent(this.AddAStudent), userMsg); }); switch (mCallArgu.pack_argu.unpack_data.type) { case 0x0825: { if (mCallArgu.pack_argu.unpack_data.isTurnIp) { //需要中转IP MyLibInterface.OnDisconnect(mCallBackFuctions._Socket); GlobalVar.mLocalConfig.strServerIp = Config.LocalConfig.IntToIp(mCallArgu.pack_argu.unpack_data.serverip); uint ip = (uint)Config.LocalConfig.IpToInt(GlobalVar.mLocalConfig.strServerIp); MyLibInterface._InitServer(ip, (uint)(GlobalVar.mLocalConfig.iServerPort), 1); char[] strIp = new char[20]; GlobalVar.mLocalConfig.strServerIp.CopyTo(0, strIp, 0, GlobalVar.mLocalConfig.strServerIp.Length); MyLibInterface.OnConnectA(mCallBackFuctions.mNetLibCallback, strIp, GlobalVar.mLocalConfig.iServerPort, 1); } else { SendPacket(0x0836); } } break; case 0x0836: { if (!mCallArgu.pack_argu.unpack_data.is0836Suc) { if (mCallArgu.loginresult.notifyMsg == "NEED_LOGINVERIFYAGAIN") { SendPacket(0x0836); break; } else { System.Windows.MessageBox.Show(mCallArgu.loginresult.notifyMsg); return; } } else { SendPacket(0x0828); } } break; case 0x0828: { if (!mCallArgu.pack_argu.unpack_data.is0828Suc) { System.Windows.MessageBox.Show(mCallArgu.loginresult.notifyMsg); return; } else { TransmitParameters.ToPackArgu toPackArgu = new TransmitParameters.ToPackArgu(); toPackArgu.type = 0x001D; toPackArgu.msg = new byte[] { 0x34 }; SendPacket(0x001D, toPackArgu); toPackArgu.msg = new byte[] { 0x12 }; SendPacket(0x001D, toPackArgu); toPackArgu.msg = new byte[] { 0x26 }; SendPacket(0x001D, toPackArgu); toPackArgu.type = 0x01BB; toPackArgu.msg = new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; SendPacket(0x01BB, toPackArgu); toPackArgu.msg = new byte[] { 0x03, 0x00, 0x01, 0x00, 0x00 }; SendPacket(0x01BB, toPackArgu); //SendPacket(0x0422); SendPacket(0x0134); //发送00EC导致下线 SendPacket(0x00EC); SendPacket(0x00D1); toPackArgu.type = 0x001D; toPackArgu.msg = new byte[] { 0x20 }; SendPacket(0x001D, toPackArgu); toPackArgu.msg = new byte[] { 0x21 }; SendPacket(0x001D, toPackArgu); toPackArgu.msg = new byte[] { 0x22 }; SendPacket(0x001D, toPackArgu); toPackArgu.msg = new byte[] { 0x31 }; SendPacket(0x001D, toPackArgu); SendPacket(0x0001); } } break; case 0x00EC: { _User.LoginUser(); base.OnPropertyChanged("IsLogin"); System.Windows.MessageBox.Show("登陆成功"); dispatcherTimer.Start(); } break; case 0x0017: { TransmitParameters.ToPackArgu toPackArgu = new TransmitParameters.ToPackArgu(); toPackArgu.type = 0x0017; toPackArgu.msg = new byte[0x10]; toPackArgu.seq = mCallArgu.pack_argu.unpack_data.seq; Array.Copy(mCallArgu.pack_argu.unpack_data.data, toPackArgu.msg, 0x10); SendPacket(0x0017, toPackArgu); } break; default: { //消息 } break; } }
private void AddAStudent(UserMsg si) { _User.SyncMSG(_User, si); }
/** * Removes one usermessage hook. * * @param msg_id Message index. * @param hook Function used for the hook. * @param intercept Specifies whether the hook was an intercept hook or not. * @error Invalid message index. */ public static void UnhookUserMessage(UserMsg msg_id, MsgHook hook, bool intercept = false) { throw new NotImplementedException(); }
/** * Hooks a user message. * * @param msg_id Message index. * @param hook Function to use as a hook. * @param intercept If intercept is true, message will be fully intercepted, * allowing the user to block the message. Otherwise, * the hook is normal and ignores the return value. * @param post Notification function. * @error Invalid message index. */ public static void HookUserMessage(UserMsg msg_id, MsgHook hook, bool intercept = false, MsgPostHook post = INVALID_FUNCTION) { throw new NotImplementedException(); }
/** * Starts a usermessage (network message). * * @note Only one message can be active at a time. * @note It is illegal to send any message while a non-intercept hook is in progress. * * @param msg Message index to start. * @param clients Array containing player indexes to broadcast to. * @param numClients Number of players in the array. * @param flags Optional flags to set. * @return A handle to a bf_write bit packing structure, or * INVALID_HANDLE on failure. * @error Invalid message name, unable to start a message, invalid client, * or client not connected. */ public static Handle StartMessageEx(UserMsg msg, /*const*/ int[] clients, int numClients, int flags = 0) { throw new NotImplementedException(); }
/** * Retrieves the name of a message by ID. * * @param msg_id Message index. * @param msg Buffer to store the name of the message. * @param maxlength Maximum length of string buffer. * @return True if message index is valid, false otherwise. */ public static bool GetUserMessageName(UserMsg msg_id, string msg, int maxlength) { throw new NotImplementedException(); }
public void QueryUserMsgFinish(UserMsg datas) { msgData = datas; PlayAction(); }
public int Register(UserMsg um) { T_SeatsDal dal=new T_SeatsDal(); um.CC_LoginPassWord = CommonHelper.GetMD5FromString(um.CC_LoginPassWord); return dal.Register(um); }
private MainMessage HandleUserRequest(MainMessage msg) { _log.Debug("In HandleUserRequest method."); try { // TODO needs enhancemnets UserRequestMsg userRequest = msg.UserMngMsg.UserMsg.UserRequestMsg; switch (userRequest.UserRequestTypeCase) { // create new User case UserRequestMsg.UserRequestTypeOneofCase.CreateQuery: _log.Debug("Creating new user: "******"User sucessfuly created."); return(new MainMessage { UserMngMsg = userMngMsg }); // List users (Username LIKE '%msg.username%') case UserRequestMsg.UserRequestTypeOneofCase.ListQuery: _log.Debug("Looking for user like: " + userRequest.ListQuery.Username); UserDetailMsg userDetail = userRequest.ListQuery; UserDetailMsg[] users = User.List(userDetail) .Select(x => new UserDetailMsg { Password = "", UserId = x.Id, Username = x.Username }) .ToArray(); UserListMsg userList = new UserListMsg(); userList.Users.AddRange(users); UserMngMsg userMngMsg1 = new UserMngMsg(); userMngMsg1.UserMsg = new UserMsg { UserListMsg = userList }; _log.Debug($"Found {users.Length} records."); return(new MainMessage { UserMngMsg = userMngMsg1 }); // Change password, where old and new password are in same filed, separated by newline case UserRequestMsg.UserRequestTypeOneofCase.UpdateQuery: _log.Debug("Changing password to user: "******"Password sucessfuly changed."); return(ISystemService.CreateOkMessage(msg.MsgId)); // show user by its Id case UserRequestMsg.UserRequestTypeOneofCase.UserIdDetail: _log.Debug($"Looking for user with id {userRequest.UserIdDetail}"); User user2 = User.Get(userRequest.UserIdDetail); UserDetailMsg userDetail1 = new UserDetailMsg(); userDetail1.UserId = user2.Id; userDetail1.Password = ""; userDetail1.Username = user2.Username; UserMsg userMsg1 = new UserMsg(); userMsg1.UserDetailMsg = userDetail1; return(new MainMessage { UserMngMsg = new UserMngMsg { UserMsg = userMsg1 } }); case UserRequestMsg.UserRequestTypeOneofCase.UserByClientId: _log.Debug($"Looking for user with client id {userRequest.UserByClientId}"); if (msg.SenderIdCase != MainMessage.SenderIdOneofCase.ServerId) { return(ISystemService.CreateErrorMessage(msg.MsgId, 0, 0, "Not enough permissions.")); } ulong clientId = userRequest.UserByClientId; if (clientId >= (ulong)_clientMachines.Count || _clientMachines[(int)clientId] == null) { return(ISystemService.CreateErrorMessage(msg.MsgId, 0, 0, "Unable to find user with this client ID")); } MainMessage respUserDetail = new MainMessage(); respUserDetail.UserMngMsg = new UserMngMsg(); respUserDetail.UserMngMsg.UserMsg = new UserMsg(); respUserDetail.UserMngMsg.UserMsg.UserDetailMsg = _clientMachines[(int)clientId].ToMessage(); return(respUserDetail); default: throw new ErrorMsgException("This message cannot be empty."); } } catch (Exception ex) { _log.Error(ex); return(ISystemService.CreateErrorMessage(0, 0, 0, ex.Message)); } }
public UserMSGEventArgs(UserMsg _userMsg) { this.userMsg = _userMsg; }