Esempio n. 1
0
        public ActionResult List(RecruitQueryParam queryParam)
        {
            IPageList <RecruitModel> models = GetRecruitList(queryParam);
            List <RecruitModel>      dtos   = models.ToList();

            return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
        public void SaveHaveBeenQuantity(Hr_NeedQueryParam queryParam)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            Expression <Func <THR_Needs, bool> > predicate = SearchPredicate(queryParam);
            IPageList <THR_Needs> models = ctx.THR_Needs
                                           .Where(predicate)
                                           .OrderUsingSortExpression(queryParam.Sort.Replace("deptname", "deptid").Replace("postname", "postid"), queryParam.Order)
                                           .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            List <THR_Needs> dtos = models.ToList();

            //       List<THR_Needs> list = ctx.THR_Needs
            //.Where(c => c.IsDelete == 0 && c.NeedQuantity > 0).ToList();
            foreach (THR_Needs needmodel in dtos)
            {
                int Quantity = ctx.THR_Recruit
                               .Where(c => c.IsDelete == 0 && c.NeedsId == needmodel.Id && c.Status == 82).ToList().Count;//已录用
                needmodel.HaveBeenQuantity = Quantity;
                if (needmodel.NeedQuantity == needmodel.HaveBeenQuantity)
                {
                    needmodel.IsHaveBeen = 1;
                }
                else
                {
                    needmodel.IsHaveBeen = 0;
                }
            }
            ctx.SaveChanges();
        }
Esempio n. 3
0
        /// <summary>
        /// 通用成交备案数据查询接口
        /// </summary>
        /// <param name="nf"></param>
        /// <param name="zc"></param>
        /// <param name="zt"></param>
        /// <param name="qy"></param>
        /// <param name="lpmc"></param>
        /// <param name="yt"></param>
        /// <param name="xfyt"></param>
        /// <param name="hx"></param>
        /// <param name="pagesize"></param>
        /// <param name="pagenow"></param>
        /// <returns></returns>
        public JsonResult cxjg(int nf, int zc, string[] zt, string[] qy, string[] kfs, string[] lpmc, string[] yt, string[] xfyt, string[] hx, int?pagesize, int?pagenow)
        {
            IPageList <Data_Cjba_Default> list = null;

            if (zt != null || qy != null || kfs != null || lpmc != null || yt != null || xfyt != null || hx != null)
            {
                JP_ParamValueModel param = new JP_ParamValueModel();
                param.zt   = zt;
                param.qy   = qy;
                param.kfs  = kfs;
                param.lpmc = lpmc;
                param.yt   = yt;
                param.xfyt = xfyt;
                param.hx   = hx;


                list = Param_DataProvider.GET_JP_CJBAXX(nf, zc, param, pagesize.HasValue ? pagesize.Value : 10, pagenow.HasValue ? pagenow.Value : 1);
            }
            else
            {
                list = Param_DataProvider.GET_JP_CJBAXX(nf, zc, pagesize.HasValue ? pagesize.Value : 10, pagenow.HasValue ? pagenow.Value : 1);
            }
            var s = new
            {
                pagenow   = list.PageNumber,
                datacount = list.TotalPageCount,
                data      = list
            };

            return(Json(s));
        }
Esempio n. 4
0
        /// <summary>
        /// 根据查询条件、每页数量,返回分页数据集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="condition">查询条件</param>
        /// <param name="pageSize">每页需要显示的数据量</param>
        /// <returns>分页数据列表,包括当前页、总记录数、分页条等</returns>
        public static DataPage <T> findPage <T>(String condition, int pageSize) where T : IEntity
        {
            if (pageSize <= 0)
            {
                pageSize = 20;
            }

            ObjectInfo state = new ObjectInfo(typeof(T));

            state.includeAll();
            state.Pager.setSize(pageSize);

            IPageList result = ObjectPool.FindPage(typeof(T), condition, state.Pager);

            if (result == null)
            {
                IList      list = ObjectDB.FindPage(state, condition);
                PageHelper p    = state.Pager;
                ObjectPool.AddPage(typeof(T), condition, p, list);

                result             = new DataPageInfo();
                result.Results     = list;
                result.PageCount   = p.PageCount;
                result.RecordCount = p.RecordCount;
                result.Size        = p.getSize();
                result.PageBar     = p.PageBar;
                result.Current     = p.getCurrent();
            }
            else
            {
                result.PageBar = new PageHelper(result.RecordCount, result.Size, result.Current).PageBar;
            }

            return(new DataPage <T>(result));
        }
        public void Search()
        {
            checkTypeName();

            String t = ctx.Get("t");
            String q = ctx.Get("q");

            if (isInputValid(t, q) == false)
            {
                redirect(List);
                return;
            }

            //------------------------------------------------------

            set("searchTarget", to(Search));
            set("typeFullName", ctx.Get("type"));
            set("filterLink", to(List) + "?type=" + ctx.Get("type"));

            q = strUtil.SqlClean(q, getInputMaxLength());

            set("searchKey", q);
            setDroplist(t);

            String condition = getCondition(q, t);

            initService();
            IPageList list = commentService.GetPageAll(condition);

            bindList("list", "c", list.Results, bindLink);
            set("page", list.PageBar);
        }
Esempio n. 6
0
        public ActionResult List(PostQueryParam queryParam)
        {
            Expression <Func <TErp_Post, bool> > predicate = c => c.IsDelete == 0;

            if (queryParam.DeptId > 0)
            {
                predicate = predicate.And(c => c.DeptId == queryParam.DeptId);
            }
            HKSJRecruitmentContext ctx    = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            IPageList <PostDto>    models = ctx.TErp_Post
                                            .Where(predicate)
                                            .OrderUsingSortExpression(queryParam.Sort, queryParam.Order)
                                            .Select(c => new PostDto
            {
                DeptId        = c.DeptId,
                DeptName      = c.TErp_Department.DeptName,
                PositionId    = c.PositionId,
                PositionLevel = c.TErp_Position.PositionLevel,
                PostDesc      = c.PostDesc,
                PostName      = c.PostName,
                Id            = c.Id,
                PositionName  = c.TErp_Position.PositionName
            })
                                            .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            List <PostDto> dtos = models.ToList();

            return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
        public ActionResult List(Hr_NeedQueryParam queryParam)
        {
            SaveHaveBeenQuantity(queryParam);
            IPageList <Hr_NeedDto> models = GetNeedData(queryParam);
            List <Hr_NeedDto>      dtos   = models.ToList();

            return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
Esempio n. 8
0
 public void CopyStats(IPageList list)
 {
     this.Current     = list.Current;
     this.Size        = list.Size;
     this.PageCount   = list.PageCount;
     this.PageBar     = list.PageBar;
     this.RecordCount = list.RecordCount;
 }
Esempio n. 9
0
        /// <summary>
        /// 获取表格数据
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task <IActionResult> GetAll(SerachLabelDtoInput dto)
        {
            IPageList <Classify> result = await _service.GetAll(dto);

            return(Json(result, new Newtonsoft.Json.JsonSerializerSettings()
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            }));
        }
Esempio n. 10
0
 public DataPage(IPageList list)
 {
     this.Current     = list.Current;
     this.Size        = list.Size;
     this.PageCount   = list.PageCount;
     this.PageBar     = list.PageBar;
     this.RecordCount = list.RecordCount;
     this.Results     = db.getResults <T>(list.Results);
 }
Esempio n. 11
0
        public async Task <IActionResult> GetAll(ArticleSreachDto data)
        {
            IPageList <Article> result = await _service.GetAllToPageList(data);

            return(Json(result, new Newtonsoft.Json.JsonSerializerSettings()
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            }));
        }
Esempio n. 12
0
 public static IPageList FindPage(Type t, String condition, PageHelper pager)
 {
     foreach (IObjectPool pool in pools)
     {
         IPageList result = pool.FindPage(t, condition, pager);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
        public ActionResult List(QueryParam queryParam)
        {
            Expression <Func <TErp_Position, bool> > predicate = c => c.IsDelete == 0;
            HKSJRecruitmentContext    ctx    = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            IPageList <TErp_Position> models = ctx.TErp_Position
                                               .Where(predicate)
                                               .OrderUsingSortExpression(queryParam.Sort, queryParam.Order)
                                               .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            List <TErp_Position> dtos = models.ToList();

            return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
Esempio n. 14
0
 public static TagBuilder CompleteUlBefore(TagBuilder ul, IPageList list, Func <int, string> generatePageUrl)
 {
     if (list.PageCount >= list.PageNumber && list.PageNumber > 1)
     {
         TagBuilder nextLi = new TagBuilder("li");
         TagBuilder LastA  = new TagBuilder("a");
         LastA.Attributes["href"] = generatePageUrl(list.PageNumber - 1);
         LastA.InnerHtml.SetContent("上一页");
         nextLi.InnerHtml.SetContent(LastA);
         ul.InnerHtml.Append(nextLi);
     }
     return(ul);
 }
Esempio n. 15
0
 public static TagBuilder CompleteUlAfter(TagBuilder ul, IPageList list, Func <int, string> generatePageUrl)
 {
     if (list.PageCount > list.PageNumber && list.PageNumber >= 1)
     {
         TagBuilder nextLi = new TagBuilder("li");
         TagBuilder nextA  = new TagBuilder("a");
         nextA.Attributes["href"] = generatePageUrl(list.PageNumber + 1);
         nextA.InnerHtml.SetContent("下一页");
         nextLi.InnerHtml.SetHtmlContent(nextA);
         ul.InnerHtml.AppendHtml(nextLi);
     }
     return(ul);
 }
Esempio n. 16
0
        public ActionResult List(PanramQueryParam queryParam)
        {
            Expression <Func <Tapp_Param, bool> > predicate = c => true;

            predicate = predicate.And(c => c.Parentid == queryParam.Parentid && c.IsDelete == 0);
            HKSJRecruitmentContext ctx    = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            IPageList <Tapp_Param> models = ctx.Tapp_Param
                                            .Where(predicate)
                                            .OrderUsingSortExpression("parentid asc, sort asc")
                                            .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            List <Tapp_Param> dtos = models.ToList();

            return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
Esempio n. 17
0
        public static IHtmlContent PagedListPager(this IHtmlHelper html,
                                                  IPageList list,
                                                  Func <int, string> generatePageUrl)
        {
            TagBuilder ul = new TagBuilder("ul");

            ul.AddCssClass("pagination");
            ul = CompleteUlBefore(ul, list, generatePageUrl);
            for (int i = 1; i <= list.PageCount; i++)
            {
                string temp = generatePageUrl(i);
                ul.InnerHtml.AppendHtml(GenerateItem(temp, i, list.PageNumber));
            }
            ul = CompleteUlAfter(ul, list, generatePageUrl);
            return(ul);
        }
        public ActionResult List(EmployeeQueryParam queryParam)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            string sql = @"SELECT A.ID,A.uid,A.pwd,A.name,A.idcard,A.idcard,A.birthday,A.dptid,B.DeptName as dptname,A.postid,C.PositionName post,A.sex,A.tel,A.status,A.EntryDate,A.address,A.education,A.schools 
from HR_Employee A LEFT join TErp_Department B ON A.dptid=B.Id
left join TErp_Position C ON A.postid=C.Id where (A.isDelete is null or A.isDelete = 0) ";

            if (!string.IsNullOrEmpty(queryParam.name))
            {
                sql += string.Format("and A.name like {0}", SQLHelper.ToSQLParamLikeStr(queryParam.name));
            }
            sql += "order by A.ID desc";
            IPageList <HKSJRecruitment.Models.proModels.HR_Employee> dtoss = ctx.Database.SqlQuery <HKSJRecruitment.Models.proModels.HR_Employee>(sql).ToPagedList(queryParam.PageIndex, queryParam.PageSize);

            return(Content(this.GetJSON(new { total = dtoss.PageInfo.TotalCount, rows = dtoss }), this.JsonContentType()));
        }
Esempio n. 19
0
        public ActionResult List(ButtonQueryParam queryParam)
        {
            Expression <Func <Tapp_Button, bool> > predicate = c => true;

            if (queryParam.MenuId > 0)
            {
                predicate = predicate.And(c => c.MenuId == queryParam.MenuId);
            }
            HKSJRecruitmentContext  ctx    = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            IPageList <Tapp_Button> models = ctx.Tapp_Button
                                             .Where(predicate)
                                             .OrderUsingSortExpression(queryParam.Sort, queryParam.Order)
                                             .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            List <Tapp_Button> dtos = models.ToList();

            return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
Esempio n. 20
0
        public ActionResult List(RoleQueryParam queryParam)
        {
            Expression <Func <Tapp_Role, bool> > predicate = c => true;

            if (!string.IsNullOrEmpty(queryParam.RoleName))
            {
                predicate = predicate.And(c => c.RoleName.Contains(queryParam.RoleName));
            }
            HKSJRecruitmentContext ctx    = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            IPageList <Tapp_Role>  models = ctx.Tapp_Role
                                            .Where(predicate)
                                            .OrderUsingSortExpression(queryParam.Sort, queryParam.Order)
                                            .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            List <Tapp_Role> dtos = models.ToList();

            return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
 public void ListUpdate()
 {
     userViews = employeeService.SearchEmployeeList(search);
     EmployeeList.Items.Clear();  //只移除所有的项。
     for (int i = 0; i < userViews.Data.Count(); i++)
     {
         userViews.Data[i].Index = i + 1;
         EmployeeList.Items.Add(userViews.Data[i]);
     }
     Index.Content = string.Format("{0} / {1}", userViews.PageIndex + 1, userViews.TotalPage);
     if (userViews.PageIndex == 0)
     {
         PreviousPageButton.IsEnabled = false;
     }
     if (userViews.PageIndex >= userViews.TotalPage - 1)
     {
         NextPageButton.IsEnabled = false;
     }
 }
        public ActionResult ListEmployee(EmployeeQueryParam queryParam)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            Expression <Func <HR_Employee, bool> > predicate = c => c.isDelete == null || c.isDelete == 0;

            if (queryParam.deptid > 0)
            {
                predicate = predicate.And(c => c.dptid == queryParam.deptid);
            }
            if (!string.IsNullOrEmpty(queryParam.name))
            {
                predicate = predicate.And(c => c.name.Contains(queryParam.name) || c.uid.Contains(queryParam.name));
            }
            IPageList <EmployeeData> dtos = ctx.HR_Employee.Where(predicate).OrderBy(c => c.ID).Select(c => new EmployeeData {
                Id = c.ID, Name = c.name, Uid = c.uid
            }).ToPagedList(queryParam.PageIndex, queryParam.PageSize);

            return(Content(this.GetJSON(new { total = dtos.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
Esempio n. 23
0
 public ApplicationManager(ILogger <ApplicationManager> logger, IMiddlewareActionHandler actionHandler, IEnumerable <IManagerCommand> commands,
                           ITranslationLookup translationLookup, IConfigurationHandler <CommandConfiguration> commandConfiguration,
                           IConfigurationHandler <ApplicationConfiguration> appConfigHandler, IGameServerInstanceFactory serverInstanceFactory,
                           IEnumerable <IPlugin> plugins, IParserRegexFactory parserRegexFactory, IEnumerable <IRegisterEvent> customParserEvents,
                           IEventHandler eventHandler, IScriptCommandFactory scriptCommandFactory, IDatabaseContextFactory contextFactory, IMetaService metaService,
                           IMetaRegistration metaRegistration, IScriptPluginServiceResolver scriptPluginServiceResolver, ClientService clientService, IServiceProvider serviceProvider,
                           ChangeHistoryService changeHistoryService, ApplicationConfiguration appConfig, PenaltyService penaltyService)
 {
     MiddlewareActionHandler = actionHandler;
     _servers               = new ConcurrentBag <Server>();
     MessageTokens          = new List <MessageToken>();
     ClientSvc              = clientService;
     PenaltySvc             = penaltyService;
     ConfigHandler          = appConfigHandler;
     StartTime              = DateTime.UtcNow;
     PageList               = new PageList();
     AdditionalEventParsers = new List <IEventParser>()
     {
         new BaseEventParser(parserRegexFactory, logger, _appConfig)
     };
     AdditionalRConParsers = new List <IRConParser>()
     {
         new BaseRConParser(serviceProvider.GetRequiredService <ILogger <BaseRConParser> >(), parserRegexFactory)
     };
     TokenAuthenticator           = new TokenAuthentication();
     _logger                      = logger;
     _metaService                 = metaService;
     _tokenSource                 = new CancellationTokenSource();
     _commands                    = commands.ToList();
     _translationLookup           = translationLookup;
     _commandConfiguration        = commandConfiguration;
     _serverInstanceFactory       = serverInstanceFactory;
     _parserRegexFactory          = parserRegexFactory;
     _customParserEvents          = customParserEvents;
     _eventHandler                = eventHandler;
     _scriptCommandFactory        = scriptCommandFactory;
     _metaRegistration            = metaRegistration;
     _scriptPluginServiceResolver = scriptPluginServiceResolver;
     _serviceProvider             = serviceProvider;
     _changeHistoryService        = changeHistoryService;
     _appConfig                   = appConfig;
     Plugins                      = plugins;
 }
Esempio n. 24
0
 private ApplicationManager()
 {
     _servers               = new List <Server>();
     Commands               = new List <Command>();
     TaskStatuses           = new List <AsyncStatus>();
     MessageTokens          = new List <MessageToken>();
     ClientSvc              = new ClientService();
     AliasSvc               = new AliasService();
     PenaltySvc             = new PenaltyService();
     ConfigHandler          = new BaseConfigurationHandler <ApplicationConfiguration>("IW4MAdminSettings");
     StartTime              = DateTime.UtcNow;
     OnQuit                 = new ManualResetEventSlim();
     PageList               = new PageList();
     AdditionalEventParsers = new List <IEventParser>();
     AdditionalRConParsers  = new List <IRConParser>();
     OnServerEvent         += OnGameEvent;
     OnServerEvent         += EventApi.OnGameEvent;
     _authenticator         = new TokenAuthentication();
     _metaService           = new MetaService();
 }
        public void List()
        {
            checkTypeName();

            set("ActionLink", to(Admin) + "?type=" + ctx.Get("type"));
            set("searchTarget", to(Search));
            set("typeFullName", ctx.Get("type"));
            set("filterLink", to(List) + "?type=" + ctx.Get("type"));

            set("searchKey", ctx.Get("q"));
            setDroplist(ctx.Get("t"));

            String condition = getCondition();

            initService();
            IPageList list = commentService.GetPageAll(condition);

            bindList("list", "c", list.Results, bindLink);
            set("page", list.PageBar);
        }
Esempio n. 26
0
        public virtual void Index()
        {
            set("addUrl", to(Add));

            IPageList list = GetPage();

            IBlock block = getBlock("list");

            foreach (T f in list.Results)
            {
                block.Set("f.Id", f.Id);
                block.Set("f.Title", f.Title);
                block.Set("f.Url", f.Url);
                block.Set("f.ImgUrl", f.ImgUrl);
                block.Set("f.Created", f.Created);
                block.Set("f.EditLink", to(Edit, f.Id));
                block.Set("f.DeleteLink", to(Delete, f.Id));
                block.Next();
            }
            set("page", list.PageBar);
        }
Esempio n. 27
0
        public virtual void My()
        {
            set("lnkCustom", to(Add));

            IList myskins = skinService.GetMy(ctx.owner.Id);

            ctx.SetItem("list", myskins);
            load("mylist", List);

            IBlock lbl = getBlock("lbl");

            if (myskins.Count > 0)
            {
                lbl.Next();
            }

            IPageList pages = skinService.GetPage();

            ctx.SetItem("list", pages.Results);
            load("list", List);
            set("page", pages.PageBar);
        }
Esempio n. 28
0
        private IPageList <Hr_NeedDto> GetNeedData(Hr_NeedQueryParam queryParam)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            Expression <Func <THR_Needs, bool> > predicate = SearchPredicate(queryParam);


            //var models = ctx.THR_Needs
            //    .Join(ctx.HR_Employee, left => left.CreateBy, right => right.uid, (left, right) => new Hr_NeedDto
            //    {
            //        Id = left.Id,
            //        DeptId = left.DeptId,
            //        DeptName = left.TErp_Department.DeptName,
            //        PostId = left.PostId,
            //        PostName = left.TErp_Position.PositionName,
            //        CutTime = left.CutTime,
            //        Demander = left.Demander,
            //        NeedQuantity = left.NeedQuantity,
            //        Remarks = left.Remarks,
            //        CreateBy = right.name,
            //        CreateTime = left.CreateTime,
            //        IsDelete = left.IsDelete,
            //        DeleteBy = left.DeleteBy,
            //        DeleteTime = left.DeleteTime,
            //        EditBy = left.EditBy,
            //        EditTime = left.EditTime,
            //        HaveBeenQuantity = left.HaveBeenQuantity,
            //        FileWord = left.FileWord
            //    })
            //    .Where(predicate)
            //    .OrderUsingSortExpression(queryParam.Sort, queryParam.Order)
            //    .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            IPageList <Hr_NeedDto> models = ctx.THR_Needs
                                            .Where(predicate)
                                            .OrderUsingSortExpression(queryParam.Sort.Replace("deptname", "deptid").Replace("postname", "postid"), queryParam.Order)
                                            .Select(c => new Hr_NeedDto
            {
                Id                = c.Id,
                DeptId            = c.DeptId,
                DeptName          = c.TErp_Department.DeptName,
                PostId            = c.PostId,
                PostName          = c.TErp_Position.PositionName,
                CutTime           = c.CutTime,
                Demander          = c.Demander,
                NeedQuantity      = c.NeedQuantity,
                Remarks           = c.Remarks,
                CreateBy          = c.CreateBy,
                CreateTime        = c.CreateTime,
                IsDelete          = c.IsDelete,
                DeleteBy          = c.DeleteBy,
                DeleteTime        = c.DeleteTime,
                EditBy            = c.EditBy,
                EditTime          = c.EditTime,
                HaveBeenQuantity  = c.HaveBeenQuantity,
                FileWord          = c.FileWord,
                JobResponsibility = c.JobResponsibility,
                PostRequest       = c.PostRequest,
                IsHaveBeen        = c.IsHaveBeen.Value,
                InterviewAddress  = c.InterviewAddress,
                Principal         = c.Principal
            })
                                            .ToPagedList(queryParam.PageIndex, queryParam.PageSize);

            foreach (var item in models)
            {
                HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == item.CreateBy);
                if (emp != null)
                {
                    item.CreateBy = emp.name;
                }
            }
            return(models);
        }
Esempio n. 29
0
        public static MvcHtmlString PageHelper <T>(this HtmlHelper helper, IPageList <T> list)
        {
            if (list == null || list.Count() <= 0)
            {
                return(null);
            }

            TagBuilder ul = new TagBuilder("ul");

            ul.MergeAttribute("class", "pagination");

            //上一頁
            if (list.pageinfo.NowPage != 1)
            {
                TagBuilder liFirst   = new TagBuilder("li");
                TagBuilder aFirst    = new TagBuilder("a");
                TagBuilder spanFirst = new TagBuilder("span");
                spanFirst.AddCssClass("fa fa-angle-double-left");

                if (list.pageinfo.NowPage == 2)
                {
                    aFirst.AddCssClass("noactive");
                }

                aFirst.InnerHtml = spanFirst.ToString();
                aFirst.MergeAttribute("index", "1");
                liFirst.InnerHtml += aFirst.ToString();
                ul.InnerHtml      += liFirst;

                TagBuilder aPrev    = new TagBuilder("a");
                TagBuilder liPrev   = new TagBuilder("li");
                TagBuilder spanPrev = new TagBuilder("span");
                spanPrev.AddCssClass("fa fa-angle-left");

                aPrev.InnerHtml = spanPrev.ToString();
                aPrev.AddCssClass("arrow");
                aPrev.MergeAttribute("index", (list.pageinfo.NowPage - 1).ToString());
                liPrev.InnerHtml = aPrev.ToString();
                ul.InnerHtml    += liPrev.ToString();
            }

            var max = (list.pageinfo.NowPage + 5) >= list.pageinfo.MaxPage ? list.pageinfo.MaxPage : list.pageinfo.MaxPage + 5;
            var min = (list.pageinfo.NowPage - 5) > 0 ? list.pageinfo.NowPage - 5 : 1;

            for (int i = min; i <= max; i++)
            {
                TagBuilder li = new TagBuilder("li");
                TagBuilder a  = new TagBuilder("a");
                a.InnerHtml = i + "";

                if (i == list.pageinfo.NowPage)
                {
                    a.AddCssClass("active nowpage");
                    a.MergeAttribute("index", i.ToString());
                }

                else
                {
                    a.MergeAttribute("index", i.ToString());

                    if (i == list.pageinfo.NowPage - 1 || i == list.pageinfo.NowPage + 1)
                    {
                        a.AddCssClass("active");
                    }
                    else if (i == list.pageinfo.NowPage - 2 || i == list.pageinfo.NowPage + 2)
                    {
                        a.AddCssClass("active");
                    }
                    else
                    {
                        a.AddCssClass("noactive");
                    }
                }
                li.InnerHtml  = a.ToString();
                ul.InnerHtml += li;
            }

            //下一頁
            if (list.pageinfo.NowPage != list.pageinfo.MaxPage)
            {
                TagBuilder aNext    = new TagBuilder("a");
                TagBuilder liNext   = new TagBuilder("li");
                TagBuilder spanNext = new TagBuilder("span");
                spanNext.AddCssClass("fa fa-angle-right");

                aNext.InnerHtml = spanNext.ToString();
                aNext.AddCssClass("arrow");
                aNext.MergeAttribute("index", (list.pageinfo.NowPage + 1).ToString());
                liNext.InnerHtml += aNext.ToString();
                ul.InnerHtml     += liNext;

                TagBuilder aLast    = new TagBuilder("a");
                TagBuilder liLast   = new TagBuilder("li");
                TagBuilder spanLast = new TagBuilder("span");
                spanLast.AddCssClass("fa fa-angle-double-right");

                if (list.pageinfo.NowPage == list.pageinfo.MaxPage - 1)
                {
                    aLast.AddCssClass("noactive");
                }

                aLast.InnerHtml = spanLast.ToString();
                aLast.MergeAttribute("index", list.pageinfo.MaxPage.ToString());
                liLast.InnerHtml += aLast.ToString();
                ul.InnerHtml     += liLast;
            }

            return(MvcHtmlString.Create(ul.ToString()));
        }
        public void Model()
        {
            String typeName = ctx.Get("typeName");

            if (strUtil.IsNullOrEmpty(typeName))
            {
                actionContent(getWelcome());
                return;
            }

            EntityInfo ei = Entity.GetInfo(typeName);

            if (ei == null)
            {
                actionContent(getWelcome());
                return;
            }

            string condition        = "";
            string strPropertyValue = "";
            string pName            = ctx.Get("p");
            int    objId            = ctx.GetInt("id");

            if (strUtil.HasText(pName) && (objId > 0))
            {
                EntityPropertyInfo property = ei.GetProperty(pName);
                if ((property != null) && property.IsEntity)
                {
                    condition = pName + ".Id=" + objId;
                    IEntity pValue = ndb.findById(property.Type, objId);
                    if (pValue != null)
                    {
                        if (property.EntityInfo.GetProperty("Name") != null)
                        {
                            strPropertyValue = pValue.get("Name").ToString();
                        }
                        else if (property.EntityInfo.GetProperty("Title") != null)
                        {
                            strPropertyValue = pValue.get("Title").ToString();
                        }
                    }
                }
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("<div class='codeCmd'><a href=\"{0}\">+ 添加 {1}</a>", to(Add) + "?typeName=" + typeName, ei.Label);
            if (strPropertyValue.Length > 0)
            {
                sb.Append("<span style=\"margin-left:15px;\">当前过滤:<span style=\"color:red;\">");
                sb.Append(strPropertyValue);
                sb.Append("</span></span>");
                sb.AppendFormat("<a href=\"{0}\" style=\"margin-left:10px;\">全部</a>", to(Model) + "?typeName=" + typeName);
            }
            sb.Append("</div>");
            this.setHeader(ei, sb);

            IPageList pages = ndb.findPage(Entity.GetInfo(typeName).Type, condition);

            foreach (IEntity obj in pages.Results)
            {
                this.setRow(ei, sb, obj);
            }
            sb.Append("</table>");
            sb.AppendFormat("<div class=\"pagebar\">{0}</div>", pages.PageBar);
            actionContent(sb.ToString());
        }