您好,登錄后才能下訂單哦!
客戶端代碼:
//發出的數據類型為int類型 ItemID為用戶對應的ID ResMessage resMessage = tcpConnnection.SendReceiveObject<ResMessage>("ReqResetPsw", "ResResetPsw", 5000, itemID); if (resMessage.Message == "操作成功") { paramHelper.ChangeParam("操作成功"); MessageBox.Show("操作成功,用戶密碼為:123456"); button1.Enabled = false; } else { MessageBox.Show("出現錯誤,錯誤信息為:" + resMessage.Message); }
服務器端代碼:
//客戶端管理員修改用戶的密碼 NetworkComms.AppendGlobalIncomingPacketHandler<int>("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 }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。