Example #1
0
        public ResResultModel GetPandianList(PdaPandianModel model)
        {
            try
            {
                object userId = null;
                SecurityService.DoCheckLogin(model.AppKey, model.UserName, out userId);

                if (model.PageIndex < 1)
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize < 10)
                {
                    model.PageSize = 10;
                }
                int totalRecord = 0;

                var sqlWhere = new StringBuilder(100);
                var parms    = new ParamsHelper();

                sqlWhere.AppendFormat("and CHARINDEX(AllowUsers,'{0}') > -1 ", userId.ToString());

                if (model.PandianId != null)
                {
                    var pandianId = Guid.Empty;
                    Guid.TryParse(model.PandianId.ToString(), out pandianId);
                    if (!pandianId.Equals(Guid.Empty))
                    {
                        sqlWhere.Append("and Id = @PandianId ");
                        var parm = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);
                        parm.Value = pandianId;
                        parms.Add(parm);
                    }
                }

                var bll = new Pandian();

                var list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere.ToString(), parms.ToArray());
                if (totalRecord == 0)
                {
                    return(ResResult.Response(true, "", "{\"total\":0,\"rows\":[]}"));
                }

                var pdaList = new List <PdaPandianInfo>();
                foreach (var item in list)
                {
                    pdaList.Add(new PdaPandianInfo {
                        Id = item.Id, Name = item.Named, SCreateDate = item.CreateDate.ToString("yyyy年MM月dd日"), CreateUserName = item.UserName, IsDown = item.IsDown, TotalQty = item.TotalQty
                    });
                }

                var dgData = "{\"total\":" + pdaList.Count + ",\"rows\":" + JsonConvert.SerializeObject(pdaList) + "}";
                return(ResResult.Response(true, "", dgData));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #2
0
        public ResResultModel GetPandianList(PdaPandianModel model)
        {
            try
            {
                var userId = WebCommon.GetUserId();
                if (userId.Equals(Guid.Empty))
                {
                    return(ResResult.Response((int)ResCode.未登录, MC.Login_NotExist, ""));
                }

                if (model.PageIndex < 1)
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize < 10)
                {
                    model.PageSize = 10;
                }
                int totalRecord = 0;

                var sqlWhere = new StringBuilder(300);
                var parms    = new ParamsHelper();

                Auth.CreateSearchItem(ref sqlWhere, ref parms, new string[] { "pd.DepmtId" });

                sqlWhere.AppendFormat("and pd.Status < {0} ", (int)EnumPandianStatus.已完成);

                if (model.PandianId != null)
                {
                    var pandianId = Guid.Empty;
                    Guid.TryParse(model.PandianId.ToString(), out pandianId);
                    if (!pandianId.Equals(Guid.Empty))
                    {
                        sqlWhere.Append("and Id = @PandianId ");
                        var parm = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);
                        parm.Value = pandianId;
                        parms.Add(parm);
                    }
                }

                var bll = new Pandian();

                var list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere.ToString(), parms.ToArray());
                if (totalRecord == 0)
                {
                    return(ResResult.Response(true, "", "{\"total\":0,\"rows\":[]}"));
                }

                var dgData = "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + "}";
                return(ResResult.Response(true, "", dgData));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }