示例#1
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0 ||
                res["MessageID"] == null || res["MessageID"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                uid       = res["UID"].ToString().Trim();
                messageid = res["MessageID"].ToString().Trim();
                Hashtable userreadmessage = new Hashtable();
                userreadmessage["ID"]        = CommonHelper.GetGuid;
                userreadmessage["UserID"]    = uid;
                userreadmessage["MessageID"] = messageid;
                userreadmessage["IsRead"]    = 1;
                userreadmessage["ReadTime"]  = SiteHelper.GetWebServerCurrentTime().ToString();
                MessageReadLogManager mrlm = new MessageReadLogManager();
                int num = 0;
                if (!mrlm.IsUserReadMessages(uid, messageid))
                {
                    num = mrlm.AddMessageReadLog(userreadmessage);
                }
                else
                {
                    num = 1;
                }
                if (num > 0)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "success", "消息已读标记成功"));
                }
                else
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "消息已读标记失败"));
                }
            }
        }
示例#2
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0 ||
                res["CurrentPage"] == null || res["CurrentPage"].ToString().Trim().Length <= 0 ||
                res["PageNum"] == null || res["PageNum"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                try
                {
                    uid = res["UID"].ToString().Trim();
                    if (res["MessageType"] != null && res["MessageType"].ToString().Trim().Length > 0)
                    {
                        //消息类型,1:系统消息,2:公告、通知
                        messagetype = res["MessageType"].ToString().Trim();
                    }
                    pagenum     = int.Parse(res["PageNum"].ToString().Trim());
                    currentpage = int.Parse(res["CurrentPage"].ToString().Trim());
                }
                catch
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "数据格式不正确"));
                }
                MessageManager mm       = new MessageManager();
                DataTable      messages = mm.GetMessageInfoPageByUser(uid, messagetype, currentpage, pagenum);
                if (messages == null || messages.Rows.Count <= 0)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "没有数据了"));
                }
                else
                {
                    messages.Columns.Add("IsRead");
                    foreach (DataRow message in messages.Rows)
                    {
                        string messageid = message["ID"].ToString();
                        if (message["ImageUrl"].ToString().Trim().Length > 0)
                        {
                            message["ImageUrl"] = SiteHelper.GetFileServer() + message["ImageUrl"].ToString().Trim();
                        }
                        message["MessageUrl"] = string.Format("{0}/Manage/InformationManage/Notification.aspx?id={1}", SiteHelper.GetFileServer(), message["ID"].ToString());
                        message["IsRead"]     = "0";
                        MessageReadLogManager mrlm = new MessageReadLogManager();
                        if (!mrlm.IsUserReadMessages(uid, messageid))
                        {
                            //系统消息设置为已读
                            if (message["MessageType"].ToString() == "1")
                            {
                                Hashtable userreadmessage = new Hashtable();
                                userreadmessage["ID"]        = CommonHelper.GetGuid;
                                userreadmessage["UserID"]    = uid;
                                userreadmessage["MessageID"] = messageid;
                                userreadmessage["IsRead"]    = 1;
                                userreadmessage["ReadTime"]  = SiteHelper.GetWebServerCurrentTime().ToString();
                                mrlm.AddMessageReadLog(userreadmessage);

                                message["IsRead"] = "1";
                            }
                        }
                        else
                        {
                            message["IsRead"] = "1";
                        }
                        if (message["MessageType"].ToString() == "2")
                        {
                            message["MessageContent"] = "";
                        }

                        message["Summary"] = message["Summary"].ToString().Replace("\r\n", "");
                    }
                    return(JsonHelper.DataTableToJson("success", "获取数据成功", messages, "Messages"));
                }
            }
        }