Beispiel #1
0
        public ActionResult Search(DistributeExpertSearchModel searchModel)
        {
            var data = GetSearchResult(searchModel);

            DhtmlxGrid grid = new DhtmlxGrid();
            int        pos  = searchModel.posStart.HasValue ? searchModel.posStart.Value : 0;

            grid.AddPaging(data.TotalCount, pos);
            var buttons         = GetCurrentUserPathActions();
            var currentUserRole = GetCurrentUserRole();

            for (int i = 0; i < data.Results.Count; i++)
            {
                var           rowData = data.Results[i];
                DhtmlxGridRow row     = new DhtmlxGridRow(rowData.id);
                row.AddCell(string.Empty);
                row.AddCell((pos + i + 1).ToString());//序号

                var tbOne = repOne.GetById(rowData.pid);
                if (tbOne != null)
                {
                    row.AddCell(tbOne.unitname);
                }
                else
                {
                    row.AddCell("");
                }

                var zj = string.Empty;
                if (!string.IsNullOrEmpty(rowData.zjsp1))
                {
                    zj += rowData.zjsp1;
                }
                if (!string.IsNullOrEmpty(rowData.zjsp2))
                {
                    zj += "," + rowData.zjsp2;
                }
                if (!string.IsNullOrEmpty(zj))
                {
                    var userDic = userService.ApiGetUserNameByUserIds(zj.Split(',').ToList());
                    row.AddCell(userDic.Values.Join(","));
                }
                else
                {
                    row.AddCell("");
                }

                if (HaveButtonFromAll(buttons, "Distribute") && (rowData.@static == 1 || rowData.@static == 2))
                {
                    row.AddLinkJsCell("分配专家", "DistributeExpert(\"{0}\",\"{1}\")".Fmt(rowData.id, rowData.pid));
                }
                else
                {
                    row.AddCell(string.Empty);
                }

                grid.AddGridRow(row);
            }
            string str = grid.BuildRowXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }
Beispiel #2
0
        private SearchResult <DistributeExpertUIModel> GetSearchResult(DistributeExpertSearchModel searchModel)
        {
            var predicate = PredicateBuilder.True <t_D_UserTableTen>();

            #region 动态查询

            //var instFilter = GetCurrentInstFilter();
            //if (instFilter.NeedFilter && instFilter.FilterInstIds.Count() > 0)
            //{
            //    predicate = predicate.And(t => instFilter.FilterInstIds.Contains(t.unitcode));
            //}

            //if (IsCurrentSuperVisor())
            //{
            //    var area = GetCurrentAreas();
            //    var userInArea = checkUnitService.GetUnitByArea(area);
            //    var insts = userInArea.Select(t => t.Key).ToList();
            //    if (insts != null && insts.Count >= 0)
            //    {
            //        predicate = predicate.And(t => insts.Contains(t.unitcode));
            //    }
            //}

            #endregion

            int pos   = searchModel.posStart.HasValue ? searchModel.posStart.Value : 0;
            int count = searchModel.count.HasValue ? searchModel.count.Value : 30;

            string orderby      = string.Empty;
            string orderByAcs   = string.Empty;
            bool   isDes        = true;
            string sortProperty = "id";

            //string[] columns = { "CheckBox", "SeqNo", "NAME", "UNITNAME" };
            //if (searchModel.orderColInd.HasValue
            //    && !string.IsNullOrWhiteSpace(searchModel.direct)
            //    && searchModel.orderColInd.Value <= columns.Length)
            //{
            //    if (searchModel.direct == "asc")
            //    {
            //        sortProperty = orderby = columns[searchModel.orderColInd.Value];
            //        isDes = false;
            //    }
            //    if (searchModel.direct == "des")
            //    {
            //        sortProperty = orderByAcs = columns[searchModel.orderColInd.Value];
            //        isDes = true;
            //    }
            //}

            PagingOptions <t_D_UserTableTen> pagingOption = new PagingOptions <t_D_UserTableTen>(pos, count, sortProperty, isDes);

            var customs = rep.GetByConditionSort <DistributeExpertUIModel>(predicate, r => new
            {
                r.id,
                r.pid,
                r.zjsp1,
                r.zjsp2,
                r.@static
            },
                                                                           pagingOption);

            return(new SearchResult <Models.DistributeExpertUIModel>(pagingOption.TotalItems, customs));
        }