Пример #1
0
        public object GetMessageList([FromBody] JObject json)
        {
            try
            {
                string  res       = json.Value <string>("json");
                dynamic dy        = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId    = dy.userid;
                long    pageIndex = dy.pageindex;
                long    pageSize  = dy.pagesize;
                string  action    = dy.data.action;  //0待提交 1全部

                OperatorProvider.AppUserId = userId; //设置当前用户
                Operator   user       = OperatorProvider.Provider.Current();
                Pagination pagination = new Pagination();
                pagination.page           = int.Parse(pageIndex.ToString());
                pagination.rows           = int.Parse(pageSize.ToString());
                pagination.p_kid          = "t.id";
                pagination.p_fields       = @"t.title,d.status,t.senduser";
                pagination.sidx           = "t.sendtime"; //排序字段
                pagination.sord           = "desc";       //排序方式
                pagination.conditionJson += " 1=1 ";
                //未查看的数据
                if (action == "0")
                {
                    pagination.p_tablename    = string.Format(@"base_message t left join (select t.messageid,t.status,t.useraccount from base_messagedetail t where t.useraccount='{0}' and t.status=0) d on d.messageid=t.id", curUser.Account);
                    pagination.conditionJson += string.Format(" and d.useraccount='{0}' and d.status=0 ", curUser.Account);
                }
                else
                {
                    pagination.p_tablename    = string.Format(@"base_message t left join (select t.messageid,t.status,t.useraccount from base_messagedetail t where t.useraccount='{0}' and t.status=1) d on d.messageid=t.id", curUser.Account);
                    pagination.conditionJson += string.Format(" and ((d.useraccount='{0}' and d.status=1) or t.senduser='******') ", curUser.Account);
                }
                string queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                {
                });
                var data = messagebll.GetPageList(pagination, queryJson);
                return(new { code = 0, count = pagination.records, info = "获取数据成功", data = data });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
Пример #2
0
        public ActionResult GetPageListJson(Pagination pagination, string queryJson)
        {
            try
            {
                Operator currUser = OperatorProvider.Provider.Current();
                var      watch    = CommonHelper.TimerStart();
                pagination.p_kid       = "t.id";
                pagination.p_fields    = @"t.username,t.sendtime,t.userid,t.title,t.content,d.status,t.readtime,t.remark,t.category,t.sendusername,t.senduser,nvl(d.undonenum,0) undonenum";
                pagination.p_tablename = string.Format(@"base_message t 
                                                    left join (select count(id) undonenum,d.messageid from  base_messagedetail d where d.status=0 group by d.messageid) d on d.messageid=t.id
                                                        left join (
                                                        select distinct messageid, status from base_messagedetail where useraccount ='{0}'
                                                    ) d on d.messageid=t.id ", currUser.Account);
                //pagination.sidx = "t.sendtime";//排序字段
                //pagination.sord = "desc";//排序方式

                if (currUser.IsSystem)
                {
                    pagination.conditionJson = "  1=1 ";
                }
                else
                {
                    pagination.conditionJson = string.Format(@" ((',' || t.userid || ',') like '%,{0},%' or t.senduser = '******')", currUser.Account);
                }
                var data     = messagebll.GetPageList(pagination, queryJson);
                var jsonData = new
                {
                    rows     = data,
                    total    = pagination.total,
                    page     = pagination.page,
                    records  = pagination.records,
                    costtime = CommonHelper.TimerEnd(watch)
                };
                return(ToJsonResult(jsonData));
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }