コード例 #1
0
ファイル: ReplyMsg.ashx.cs プロジェクト: mildrock/wechat
        public void QueryReceiveInfo(HttpContext context)
        {
            var hashtable = new Hashtable();
            var bll = new ReceiveMsgBll();
            var keyWords = context.Request.Params["keyWords"];
            var unReply = context.Request["UnReply"] ?? "2";//1-没有回复,2-已回复
            string tmp = context.Request["dateBegin"] ?? "";
            DateTime dateBegin = DateTime.Now.AddDays(-1).Date;
            DateTime dateEnd = DateTime.Now.AddDays(1).Date;
            if (!string.IsNullOrEmpty(tmp))
            {
                dateBegin = DateTime.Parse(tmp);
            }
            tmp = context.Request["dateEnd"] ?? "";
            if (!string.IsNullOrEmpty(tmp))
            {
                dateEnd = DateTime.Parse(tmp);
            }

            //获取分页数据
            var total = 0;
            var page = int.Parse(context.Request["page"] ?? "1");
            var rows = int.Parse(context.Request["rows"] ?? "20");
            try
            {
                var data = bll.QueryByPage(new ReceiveMsg()
                {
                    DateBegin = dateBegin,
                    DateEnd = dateEnd,
                    KeyWords = keyWords,
                    bak1 = unReply,
                }, page, rows, ref total);
                var list = ConvertHelper<ReceiveMsg>.ConvertToList(data);
                hashtable["rows"] = list.ToList();
                hashtable["total"] = total;
                var json = _jss.Serialize(hashtable);
                context.Response.Write(json);
            }
            catch (Exception e)
            {
                hashtable["error"] = true;
                var json = _jss.Serialize(hashtable);
                context.Response.Write(json);
                Log.Error(e);
            }
        }