public static void LoadTitles(Character pUser) { CqTitleRepository tempRepo = new CqTitleRepository(); IList <DbTitle> titles = tempRepo.GetUserTitle(pUser.Identity); if (titles != null) { int nNow = UnixTimestamp.Timestamp(); foreach (DbTitle title in titles) { if (title.Timestamp < nNow) { tempRepo.Delete(title); continue; } pUser.Titles.TryAdd(title.Title, title); } } if (pUser.Titles.Count > 0) { MsgTitle pTitle = new MsgTitle { Identity = pUser.Identity, Action = TitleAction.QUERY_TITLE }; foreach (var title in pUser.Titles.Values) { pTitle.Append(title.Title); } pUser.Send(pTitle); } if (pUser.Titles.ContainsKey(pUser.Title)) { MsgTitle pTitle = new MsgTitle { Identity = pUser.Identity, Action = TitleAction.ADD_TITLE, SelectedTitle = (UserTitle)pUser.Title }; pUser.Send(pTitle); } else { pUser.Title = 0; } }
public static void HandleTitlePacket(Character pUser, MsgTitle pMsg) { switch (pMsg.Action) { #region Query Title case TitleAction.QUERY_TITLE: { if (pUser.Titles.Count > 0) { foreach (var title in pUser.Titles.Values) { pMsg.Append(title.Title); } pUser.Send(pMsg); } break; } #endregion #region Select Title case TitleAction.SELECT_TITLE: { if (pMsg.SelectedTitle == UserTitle.NONE) { pUser.Title = 0; pUser.Send(pMsg); } else if (pUser.Titles.ContainsKey((byte)pMsg.SelectedTitle)) { pUser.Title = (byte)pMsg.SelectedTitle; pUser.Send(pMsg); } else { return; } pUser.Screen.RefreshSpawnForObservers(); break; } #endregion } }
private void Btn_Submit_Click(object sender, EventArgs e) { MsgContent.CheckInput(); MsgTitle.CheckInput(); if (!MsgTitle.ValidateState) { return; } Hashtable ht = new SqlServerHelper().GetHashTableByControl(this.P8.Controls); ht["LOGINID"] = loginid; ht["USERNAME"] = AppDomain.CurrentDomain.GetData("USERNAME").ToString(); bool result = new SqlServerHelper().Submit_AddOrEdit("User_FeedBack", "MsgID", "", ht); string _info = result ? "提交成功!" : "提交失败!"; MsgTitle.Text = ""; MsgContent.Text = ""; UnsubscribeID.Text = ""; Msg.Show(_info); }