예제 #1
0
        public ProInterface.Models.Api.ApiPagingDataBean BulletinList(ref ErrorInfo err, ProInterface.Models.Api.ApiRequesPageBean inEnt)
        {
            GlobalUser        gu    = Global.GetUser(inEnt.authToken);
            ApiPagingDataBean reEnt = new ApiPagingDataBean();
            int skip = 0;

            if (inEnt.currentPage > 1)
            {
                skip = (inEnt.currentPage - 1) * inEnt.pageSize;
            }
            using (DBEntities db = new DBEntities())
            {
                var tmpEnt  = db.YL_BULLETIN.AsEnumerable();
                var allData = tmpEnt.Where(x => x.IS_SHOW == 1 && x.ISSUE_DATE < DateTime.Now).OrderByDescending(x => x.IS_URGENT).ThenByDescending(x => x.ISSUE_DATE).AsEnumerable();
                allData = allData.Where(x => x.YL_ROLE.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).AsEnumerable();

                ErrorInfo error = new ErrorInfo();
                #region 过虑条件
                foreach (var filter in inEnt.searchKey)
                {
                    if (filter.K == "CREATE_TIME" && filter.T == ">=" && !string.IsNullOrEmpty(filter.V))
                    {
                        DateTime dt1 = DateTime.ParseExact(filter.V, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
                        allData = allData.Where(x => x.CREATE_TIME >= dt1).AsEnumerable();
                    }
                    else if (filter.K == "CREATE_TIME" && filter.T == "<=" && !string.IsNullOrEmpty(filter.V))
                    {
                        DateTime dt2 = DateTime.ParseExact(filter.V, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
                        allData = allData.Where(x => x.CREATE_TIME <= dt2).AsEnumerable();
                    }
                    else if (filter.V == "全部")
                    {
                        allData = tmpEnt.Where(x => x.IS_SHOW == 1 && x.ISSUE_DATE < DateTime.Now).OrderByDescending(x => x.IS_URGENT).ThenByDescending(x => x.ISSUE_DATE).AsEnumerable();
                    }
                    else
                    {
                        allData = Fun.GetListWhere <YL_BULLETIN>(allData, filter.K, filter.T, filter.V, ref error);
                    }
                }
                #endregion
                var allList = allData.Skip(skip).Take(inEnt.pageSize).ToList();
                reEnt.currentPage = inEnt.currentPage;
                reEnt.pageSize    = inEnt.pageSize;
                reEnt.totalCount  = allData.Count();
                reEnt.totalPage   = reEnt.totalCount / reEnt.pageSize;
                if (reEnt.totalCount % reEnt.pageSize != 0)
                {
                    reEnt.totalPage++;
                }
                IList <TBulletin> reList = new List <TBulletin>();
                foreach (var t in allList)
                {
                    TBulletin tmp = Fun.ClassToCopy <YL_BULLETIN, TBulletin>(t);
                    tmp.CONTENT = Fun.NoHTML(tmp.CONTENT);
                    reList.Add(tmp);
                }
                reEnt.data = reList;
            }
            return(reEnt);
        }
예제 #2
0
 public static dynamic Func(MyAction4 myAction, ref ErrorInfo err, ApiPagingDataBean <outT> inEnt)
 {
     try
     {
         return(myAction(ref err, inEnt));
     }
     catch (Exception e)
     {
         err.IsError = true;
         err.Message = e.Message;
         return(err);
     }
 }
예제 #3
0
        /* 2017-5-6 16:17:41 */
        public ApiPagingDataBean <FA_ELDER> OlderList(ref ErrorInfo err, ApiRequesPageBean <ApiPagingDataBean <FA_ELDER> > inEnt)
        {
            GlobalUser gu = Global.GetUser(inEnt.authToken);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "登录超时";
                return(null);
            }
            using (DBEntities db = new DBEntities())
            {
                ApiPagingDataBean <FA_ELDER> reEnt = new ApiPagingDataBean <FA_ELDER>();
                var allList = db.fa_elder.Where(x => x.FAMILY_ID == inEnt.id).OrderBy(x => x.SORT).ToList();
                reEnt.data = Mapper.Map <List <FA_ELDER> >(allList);
                return(reEnt);
            }
        }
예제 #4
0
        public ApiPagingDataBean <FaUserInfo> UserInfoSingleByName(ref ErrorInfo err, ApiRequesEntityBean <FaUserInfo> inEnt)
        {
            using (DBEntities db = new DBEntities())
            {
                var namePar = inEnt.para.FirstOrDefault(x => x.K == "name");
                if (namePar == null)
                {
                    err.IsError = true;
                    err.Message = "名称不能为空";
                    return(null);
                }
                var userInfo = db.fa_user_info.Where(x => x.fa_user.NAME == namePar.V).ToList();

                var data = Mapper.Map <IList <FaUserInfo> >(userInfo);
                ApiPagingDataBean <FaUserInfo> reEnt = new ApiPagingDataBean <FaUserInfo>();
                reEnt.data        = data;
                reEnt.currentPage = 1;
                reEnt.pageSize    = 10;
                reEnt.totalCount  = data.Count();
                reEnt.totalPage   = 1;
                return(reEnt);
            }
        }
예제 #5
0
        public ApiPagingDataBean <FaUserInfo> UserInfoList(ref ErrorInfo err, ApiRequesPageBean <ApiPagingDataBean <FaUserInfo> > inEnt)
        {
            GlobalUser gu = Global.GetUser(inEnt.authToken);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "登录超时";
                return(null);
            }
            if (inEnt.pageSize == 0)
            {
                inEnt.pageSize = 10;
            }
            if (inEnt == null)
            {
                err.IsError = true;
                err.Message = "参数有误";
                return(null);
            }
            ApiPagingDataBean <FaUserInfo> reEnt = new ApiPagingDataBean <FaUserInfo>();

            int skip = 0;

            if (inEnt.currentPage > 1)
            {
                skip = (inEnt.currentPage - 1) * inEnt.pageSize;
            }
            using (DBEntities db = new DBEntities())
            {
                var    tmpPar  = inEnt.para.SingleOrDefault(x => x.K == "keyWord");
                string keyWord = null;
                if (tmpPar == null)
                {
                    return(reEnt);
                }
                keyWord = tmpPar.V;


                var allData = db.fa_user_info.OrderByDescending(x => x.ID).ToList().AsEnumerable();
                allData = allData.Where(x =>
                                        (x.fa_user.NAME != null && x.fa_user.NAME.IndexOf(keyWord) > -1) ||
                                        (x.fa_user.LOGIN_NAME != null && x.fa_user.LOGIN_NAME.IndexOf(keyWord) > -1)
                                        ).AsEnumerable();

                #region 过虑条件
                if (inEnt.searchKey != null)
                {
                    foreach (var filter in inEnt.searchKey)
                    {
                        allData = Fun.GetListWhere(allData, filter.K, filter.T, filter.V, ref err);
                    }
                }
                #endregion

                #region 排序

                if (allData == null)
                {
                    err.IsError = true;
                    return(null);
                }
                foreach (var filter in inEnt.orderBy)
                {
                    allData = Fun.GetListOrder(allData, filter.K, filter.V, ref err);
                }
                #endregion

                var allList = allData.Skip(skip).Take(inEnt.pageSize).ToList();

                reEnt.currentPage = inEnt.currentPage;
                reEnt.pageSize    = inEnt.pageSize;
                reEnt.totalCount  = allData.Count();
                reEnt.totalPage   = reEnt.totalCount / reEnt.pageSize;
                if (reEnt.totalCount % reEnt.pageSize != 0)
                {
                    reEnt.totalPage++;
                }
                IList <FaUserInfo> reList = new List <FaUserInfo>();
                foreach (var t in allList)
                {
                    var single = Mapper.Map <FaUserInfo>(t);
                    single = Mapper.Map <FaUserInfo>(t);
                    reList.Add(single);
                }
                reEnt.data = reList;
            }
            return(reEnt);
        }
예제 #6
0
        public ApiPagingDataBean <FILES> FileList(ref ErrorInfo err, ApiRequesPageBean <ApiPagingDataBean <FILES> > inEnt)
        {
            GlobalUser gu = Global.GetUser(inEnt.authToken);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "登录超时";
                return(null);
            }
            if (inEnt.pageSize == 0)
            {
                inEnt.pageSize = 10;
            }
            if (inEnt == null)
            {
                err.IsError = true;
                err.Message = "参数有误";
                return(null);
            }
            ApiPagingDataBean <FILES> reEnt = new ApiPagingDataBean <FILES>();

            int skip = 0;

            if (inEnt.currentPage > 1)
            {
                skip = (inEnt.currentPage - 1) * inEnt.pageSize;
            }
            using (DBEntities db = new DBEntities())
            {
                var allData = db.fa_files.Where(x => x.USER_ID == gu.UserId).OrderByDescending(x => x.ID).AsEnumerable();

                #region 过虑条件
                if (inEnt.searchKey != null)
                {
                    foreach (var filter in inEnt.searchKey)
                    {
                        allData = Fun.GetListWhere(allData, filter.K, filter.T, filter.V, ref err);
                    }
                }
                #endregion

                #region 排序

                if (allData == null)
                {
                    err.IsError = true;
                    return(null);
                }
                foreach (var filter in inEnt.orderBy)
                {
                    allData = Fun.GetListOrder(allData, filter.K, filter.V, ref err);
                }
                #endregion

                var allList = allData.Skip(skip).Take(inEnt.pageSize).ToList();

                reEnt.currentPage = inEnt.currentPage;
                reEnt.pageSize    = inEnt.pageSize;
                reEnt.totalCount  = allData.Count();
                reEnt.totalPage   = reEnt.totalCount / reEnt.pageSize;
                if (reEnt.totalCount % reEnt.pageSize != 0)
                {
                    reEnt.totalPage++;
                }
                IList <FILES> reList = new List <FILES>();
                foreach (var t in allList)
                {
                    var single = Fun.ClassToCopy <fa_files, FILES>(t);
                    reList.Add(single);
                }
                reEnt.data = reList;
            }
            return(reEnt);
        }