扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
客户端代码:
//发出的数据类型为int类型 ItemID为用户对应的ID ResMessage resMessage = tcpConnnection.SendReceiveObject("ReqResetPsw", "ResResetPsw", 5000, itemID); if (resMessage.Message == "操作成功") { paramHelper.ChangeParam("操作成功"); MessageBox.Show("操作成功,用户密码为:123456"); button1.Enabled = false; } else { MessageBox.Show("出现错误,错误信息为:" + resMessage.Message); }
服务器端代码:
//客户端管理员修改用户的密码 NetworkComms.AppendGlobalIncomingPacketHandler("ReqResetPsw", HandleResetPassword);
处理方法:
//根据管理员提供的用户ID修改相应用户的密码 private void HandleResetPassword(PacketHeader header, Connection connection, int itemID) { Users theUser= DoUsers.GetUsers(itemID); //把密码恢复成123456 theUser.Password = "123456"; DoUsers.Save(theUser); ResMessage theMessage = new ResMessage(); theMessage.Message = "操作成功"; connection.SendObject("ResResetPsw", theMessage); }
操作类:
DoUsers
Users类:
[ProtoContract] public class Users { #region Constructors public Users() { } #endregion #region Private Properties private int id = -1; private string userID = string.Empty; private string name = string.Empty; private string password = string.Empty; private string declaring = string.Empty; private int status = -1; private bool isMale = false; private int userLevel = -1; private bool enabled = false; private DateTime registerTime = DateTime.UtcNow; private DateTime lastLoginTime = DateTime.UtcNow; private int depID = -1; private string department = string.Empty; #endregion #region Public Properties [ProtoMember(1)] public int Id { get { return id; } set { id = value; } } [ProtoMember(2)] public string UserID { get { return userID; } set { userID = value; } } [ProtoMember(3)] public string Name { get { return name; } set { name = value; } } [ProtoMember(4)] public string Password { get { return password; } set { password = value; } } [ProtoMember(5)] public string Declaring { get { return declaring; } set { declaring = value; } } [ProtoMember(6)] public int Status { get { return status; } set { status = value; } } [ProtoMember(7)] public bool IsMale { get { return isMale; } set { isMale = value; } } [ProtoMember(8)] public int UserLevel { get { return userLevel; } set { userLevel = value; } } [ProtoMember(9)] public bool Enabled { get { return enabled; } set { enabled = value; } } [ProtoMember(10)] public DateTime RegisterTime { get { return registerTime; } set { registerTime = value; } } [ProtoMember(11)] public DateTime LastLoginTime { get { return lastLoginTime; } set { lastLoginTime = value; } } [ProtoMember(12)] public int DepID { get { return depID; } set { depID = value; } } [ProtoMember(13)] public string Department { get { return department; } set { department = value; } } #endregion }
创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流