public ActionResult SearchImport(ApplyQualifySevenSearchModel model)
        {
            DhtmlxGrid grid      = new DhtmlxGrid();
            var        precadite = PredicateBuilder.True <t_bp_Equipment>();

            precadite = precadite.And(r => r.approvalstatus == "3");
            if (!model.CustomId.IsNullOrEmpty())
            {
                precadite = precadite.And(tt => tt.customid == model.CustomId.Trim());
            }
            int pos   = model.posStart.HasValue ? model.posStart.Value : 0;
            int count = model.count.HasValue ? model.count.Value : 30;

            var paging = new PagingOptions <t_bp_Equipment>(pos, count, t => t.id);

            var datas = equipRep.GetByConditonPage(precadite, paging);

            var totalCount = (int)paging.TotalItems;

            grid.AddPaging(totalCount, pos);

            var index     = 1;
            var allcustom = checkUnitService.GetAllCheckUnit();


            foreach (var item in datas)
            {
                string dateStr = string.Empty;
                if (item.checkenddate.HasValue && item.checkstartdate.HasValue)
                {
                    dateStr = GetUIDtString(item.checkstartdate, "yyyy-MM-dd") + "~" + GetUIDtString(item.checkenddate, "yyyy-MM-dd");
                }
                if (item.repairstartdate.HasValue && item.repairenddate.HasValue)
                {
                    dateStr = GetUIDtString(item.repairstartdate, "yyyy-MM-dd") + "~" + GetUIDtString(item.repairenddate, "yyyy-MM-dd");
                }

                DhtmlxGridRow row = new DhtmlxGridRow(item.id);
                row.AddCell(string.Empty);
                row.AddCell(index++);
                row.AddCell(item.equnum);
                row.AddCell(item.EquName + "/" + item.equtype + "/" + item.equspec);
                row.AddCell(item.testrange);
                row.AddCell(item.degree + "/" + item.uncertainty);
                row.AddCell(checkUnitService.GetCheckUnitByIdFromAll(allcustom, item.customid));
                row.AddCell(item.checkunit.IsNullOrEmpty() ? item.repairunit : item.checkunit);
                row.AddCell(dateStr);
                if (item.repairenddate.HasValue || item.checkenddate.HasValue)
                {
                    var datee    = item.repairenddate.HasValue ? item.repairenddate : item.checkenddate;
                    var dateDiff = datee.Value - DateTime.Now;
                    var totalDay = (int)dateDiff.TotalDays;
                    if (totalDay < 0)
                    {
                        row.AddCell(new DhtmlxGridCell("已经超期{0}天".Fmt(0 - totalDay), false).AddCellAttribute("style", "color:red"));
                    }
                    else
                    {
                        row.AddCell("{0}天".Fmt(totalDay));
                    }
                }
                else
                {
                    row.AddCell(string.Empty);
                }
                row.AddCell(item.checkcerfnumpath.IsNullOrEmpty()?item.repaircerfnumpath:item.checkcerfnumpath);

                row.AddCell(string.Empty);



                grid.AddGridRow(row);
            }

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

            return(Content(str, "text/xml"));
        }
        public ActionResult SearchEdit(ApplyQualifySevenSearchModel model)
        {
            DhtmlxGrid grid      = new DhtmlxGrid();
            var        precadite = PredicateBuilder.True <t_D_UserTableSeven>();

            if (!model.PId.IsNullOrEmpty())
            {
                precadite = precadite.And(tt => tt.pid == model.PId.Trim());
            }
            if (!model.CustomId.IsNullOrEmpty())
            {
                precadite = precadite.And(tt => tt.unitcode == model.CustomId.Trim());
            }

            int pos    = model.posStart.HasValue ? model.posStart.Value : 0;
            int count  = model.count.HasValue ? model.count.Value : 30;
            var pagine = new PagingOptions <t_D_UserTableSeven>(pos, count, tt => tt.id);

            var datas      = repSeven.GetByConditonPage(precadite, pagine);
            var totalCount = (int)pagine.TotalItems;

            grid.AddPaging(totalCount, pos);
            int index = 1;

            List <int?> equipIds = new List <int?>();

            foreach (var item in datas)
            {
                equipIds.Add(item.EquipId);
            }

            Dictionary <int, string> fileUrls = new Dictionary <int, string>();

            using (var db = dbFactory.Open())
            {
                fileUrls = db.Dictionary <int, string>(db.From <t_bp_Equipment>().Where(t => equipIds.Contains(t.id)).Select(t => new { t.id, t.repaircerfnumpath }));
            }
            var currentUserRole = GetCurrentUserRole();

            foreach (var item in datas)
            {
                var equip = JsonConvert.DeserializeObject <ApplyQualifySevenEquipModel>(item.gzjl);
                if (equip != null)
                {
                    DhtmlxGridRow row     = new DhtmlxGridRow(item.EquipId.HasValue ? item.EquipId.Value : item.id);
                    var           fileUrl = string.Empty;
                    if (item.EquipId.HasValue)
                    {
                        fileUrls.TryGetValue(item.EquipId.Value, out fileUrl);
                    }
                    row.AddCell(index++);
                    row.AddCell(equip.jcxm);
                    row.AddCell(equip.zyyqsb);
                    row.AddCell(equip.clfw);
                    row.AddCell(equip.zqddj);
                    row.AddCell(equip.jdxzjg);
                    row.AddCell(GetUIDtString(equip.yxrq));
                    row.AddCell(equip.zjxxm);
                    row.AddCell(equip.zjxgfmcjbh);
                    row.AddCell(equip.bz);
                    row.AddLinkJsCell("检定/校准文件查看", "uploadFile(\"{0}\")".Fmt(fileUrl));

                    row.AddCell(new DhtmlxGridCell("删除", false).AddCellAttribute("title", "删除"));

                    grid.AddGridRow(row);
                }
            }

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

            return(Content(str, "text/xml"));
        }