private string GetMessage(HttpContext context) { int msgId; string result = String.Empty; if (!int.TryParse(context.Request["msgId"], out msgId)) { msgId = 0; } MessageBll mbll = new MessageBll(); MessageModel model = mbll.GetModel(msgId); if (model != null && model.UserType == 1 && ((model.UserId == context.User.Identity.Name && model.MsgType == 0) || (context.User.IsInRole(model.UserId) && model.MsgType == 2) || model.MsgType == 1)) { JavaScriptSerializer jss = new JavaScriptSerializer(); result = jss.Serialize(model); if (model.MsgType == 0) { mbll.SetIsReaded(model.MsgId); } } return(result); }
private void ShowMsg(int msgId) { MessageBll mbll = new MessageBll(); MessageModel model = mbll.GetModel(msgId); if (model != null) { lblContent.Text = model.Content; lblMsgId.Text = model.MsgId.ToString(); lblSender.Text = model.SenderId; lblSendTime.Text = model.InsertTime.ToString("yyyy-MM-dd HH:mm"); lblSubject.Text = model.Subject; mbll.SetIsReaded(model.MsgId); } else { Response.Write("消息不存在"); Response.End(); } }