Exemplo n.º 1
0
        /// <summary>
        /// 显示短消息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="response"></param>
        /// <param name="user"></param>
        public static void ShowMessage(Message message, HttpResponse response, User user)
        {
            response.WriteTagWithValue("ID", message.ID);
            response.WriteTagWithValue("Receiver", message.Receiver.Name);
            response.WriteTagWithValue("ReceiverID", message.ReceiverID);
            response.WriteTagWithValue("Sender", message.Sender == null ? string.Empty : message.Sender.Name);
            response.WriteTagWithValue("SenderID", message.SenderID);
            response.WriteTagWithValue("Title", message.Title);
            response.WriteTagWithValue("Content", message.Information);
            response.WriteTagWithValue("DateTime", message.CreateTime);
            response.WriteTagWithValue("IsRead", message.IsRead);

            //添加短消息包系列通知类型
            response.WriteTagWithValue("Type", message.GetPackageType(message.Information));
            response.WriteTagWithValue("TypeID", message.GetPackageID(message.Information));
            response.WriteTagWithValue("ShowInGrid", message.IsShowInGrid(message.Information));

            //if (message.IsShowInGrid(message.Information))
            //    response.WriteTagWithValue("MessageType", "系统自动发送");
            //else
            //{
            //    if (message.Sender == user)
            //        response.WriteTagWithValue("MessageType", "发信");
            //    else
            //        response.WriteTagWithValue("MessageType", "收信");
            //}
            response.WriteTagWithValue("MessageType", message.MessageType);
            //permission
            response.WriteTagWithValue("HasPermission_ShowMessage", user.HasPermission_ShowMessage(message));
            response.WriteTagWithValue("HasPermission_EditMessage", user.HasPermission_EditMessage(message));
            response.WriteTagWithValue("HasPermission_DeleteMessage", user.HasPermission_DeleteMessage(message));

            //can
            response.WriteTagWithValue("CanShowMessage", user.CanShowMessage(message));
            response.WriteTagWithValue("CanEditMessage", user.CanEditMessage(message));
            response.WriteTagWithValue("CanDeleteMessage", user.CanDeleteMessage(message));
        }
Exemplo n.º 2
0
        private static Message getMessage(this HttpRequest request, IDatabase database, User user)
        {
            var id = request.GetInt("id");
            if (id.HasValue)
                return database.Messages.GetByID(id.Value);

            Message message = new Message();
            message.Sender = user;
            message.CreateTime = DateTime.Now;
            message.IsRead = false;
            return message;
        }