예제 #1
0
        public JsonResult List(int page, int rows, int?status, string title, string BeginTime = "", string EndTime = "")
        {
            TechnicalInfoQuery model = new TechnicalInfoQuery();

            model.Title  = title;
            model.Status = status;
            DateTime dt;

            if (DateTime.TryParse(BeginTime, out dt) && DateTime.TryParse(EndTime, out dt))
            {
                model.BeginTime = DateTime.Parse(BeginTime);
                model.EndTime   = DateTime.Parse(EndTime);
                model.PageNo    = page;
                model.PageSize  = rows;
            }
            else
            {
                model.PageNo   = page;
                model.PageSize = rows;
            }
            PageModel <TechnicalInfo> opModel = ServiceHelper.Create <ITechnicalInfoService>().GetTechInfos(model, base.CurrentUser.Id);
            var array =
                from item in opModel.Models.ToArray()
                select new { Id = item.Id, Title = item.Title, PublishTime = item.PublishTime, Status = item.Status };

            return(Json(new { rows = array, total = opModel.Total }));
        }
예제 #2
0
        public PageModel <TechnicalInfo> GetTechInfos(TechnicalInfoQuery model, long?userId)
        {
            int pageNum = 0;
            IQueryable <TechnicalInfo> techInfo = from item in base.context.TechnicalInfo
                                                  select item;

            if (userId.HasValue && userId.Value != 0)
            {
                techInfo = (from a in techInfo where a.PublisherId == userId.Value select a);
            }
            string begin = model.BeginTime.ToString("yyyy/MM/dd");
            string end   = model.EndTime.ToString("yyyy/MM/dd");

            if (!string.IsNullOrWhiteSpace(begin) && !begin.Equals("0001/01/01") && !string.IsNullOrWhiteSpace(end) && !end.Equals("0001/01/01"))
            {
                techInfo = (from a in techInfo where a.PublishTime > model.BeginTime && a.PublishTime < model.EndTime select a);
            }
            if (model.Status.HasValue && model.Status != 0)
            {
                techInfo = (from a in techInfo where a.Status == model.Status select a);
            }
            if (!string.IsNullOrWhiteSpace(model.Title))
            {
                techInfo = (from a in techInfo where a.Title.Contains(model.Title) select a);
            }

            techInfo = techInfo.GetPage(out pageNum, model.PageNo, model.PageSize, (IQueryable <TechnicalInfo> d) =>
                                        from o in d
                                        orderby o.PublishTime descending
                                        select o);
            foreach (TechnicalInfo list in techInfo.ToList())
            {
                if (list != null)
                {
                    UserMemberInfo userInfo = context.UserMemberInfo.FindById(list.PublisherId);
                    list.PublisherName = (userInfo == null ? "" : userInfo.UserName);
                    ManagerInfo manaInfo = context.ManagerInfo.FirstOrDefault((ManagerInfo m) => m.Id == list.Auditor && m.ShopId == 0);
                    list.AuditorName = (manaInfo == null ? "" : manaInfo.UserName);
                    ChemCloud_Dictionaries dicts = context.ChemCloud_Dictionaries.FirstOrDefault((ChemCloud_Dictionaries m) => m.DictionaryTypeId == 10 && m.DValue == list.LanguageType.ToString());
                    list.Language = dicts == null ? "" : dicts.DKey;
                }
            }
            return(new PageModel <TechnicalInfo>
            {
                Models = techInfo,
                Total = pageNum
            });
        }