Esempio n. 1
0
        public ActionResult Form2(string id)
        {
            DepartmentBLL deptBll = new DepartmentBLL();
            Operator      user    = OperatorProvider.Provider.Current();
            var           dept    = deptBll.GetEntity(user.DeptId);

            if (dept == null)
            {
                user.DeptCode = "0";
            }
            else if (dept.Nature == "部门")
            {
                var pdept = deptBll.GetEntity(dept.ParentId);
                user.DeptCode = pdept == null ? dept.EnCode : pdept.EnCode;
            }
            var model = new ToolInventoryEntity();

            model.ID         = Guid.NewGuid().ToString();
            model.CreateDate = DateTime.Now;
            model.DeptId     = user.DeptId;
            model.DeptCode   = user.DeptCode == null ? "0" : user.DeptCode;
            if (!string.IsNullOrEmpty(id))
            {
                model = tibll.GetEntity(id);
            }
            var entity = new DataItemBLL().GetEntityByName("工器具类型");
            var list   = new DataItemDetailBLL().GetList(entity.ItemId);

            ViewData["types"] = list.Select(x => new SelectListItem()
            {
                Value = x.ItemName, Text = x.ItemName
            });
            return(View(model));
        }
Esempio n. 2
0
        public ActionResult ApproveItem(string id)
        {
            var model = bll.GetLllegalDetail(id);

            var user = OperatorProvider.Provider.Current();

            model.ApproveResult   = "0";
            model.ApprovePersonId = user.UserId;
            model.ApprovePerson   = user.UserName;
            model.ApproveDate     = DateTime.Now;
            model.ApproveReason   = string.Empty;

            var itemdetialbll = new DataItemDetailBLL();
            var itembll       = new DataItemBLL();
            var main          = itembll.GetEntityByName("考核方式");
            var content       = itemdetialbll.GetList(main.ItemId).ToList();

            ViewData["checktype"] = content.Select(x => new SelectListItem()
            {
                Value = x.ItemName, Text = x.ItemName
            });

            if (model.Files == null)
            {
                model.Files = new List <FileInfoEntity>();
            }
            var users = userbll.GetUserList().ToList();

            ViewData["users"] = users;
            return(View(model));
        }
        public object GetHtml([FromBody] JObject json)
        {
            try
            {
                string      res  = json.Value <string>("json");
                dynamic     dy   = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string      name = dy.data.name;
                DataItemBLL di   = new DataItemBLL();
                //先获取到字典项
                DataItemEntity DataItems = di.GetEntityByCode("Standard");

                DataItemDetailBLL did = new DataItemDetailBLL();
                //根据字典项获取值
                IEnumerable <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId);

                List <DataItemDetailEntity> dlist = didList.Where(it => it.ItemName == name).ToList();
                if (dlist.Count > 0)
                {
                    string path = did.GetItemValue("imgUrl") + "/Content/SecurityDynamics/Phone.html?url=" + dlist[0].Description + "&top=" + did.GetItemValue("imgUrl");
                    return(new { Code = 0, Count = 1, Info = "获取数据成功", url = path });
                }
                else
                {
                    return(new { Code = 0, Count = 1, Info = "获取数据成功", url = "" });
                }
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
Esempio n. 4
0
        public ActionResult ApproveList()
        {
            var itemdetialbll = new DataItemDetailBLL();
            var itembll       = new DataItemBLL();
            var main          = itembll.GetEntityByName("违章类型");
            var content       = itemdetialbll.GetList(main.ItemId).ToList();

            content.Insert(0, new Entity.SystemManage.DataItemDetailEntity()
            {
                ItemValue = "全部", ItemName = "全部"
            });
            ViewData["category"] = content.Select(x => new SelectListItem()
            {
                Value = x.ItemName, Text = x.ItemName
            });

            main    = itembll.GetEntityByName("违章等级");
            content = itemdetialbll.GetList(main.ItemId).ToList();
            content.Insert(0, new Entity.SystemManage.DataItemDetailEntity()
            {
                ItemValue = "全部", ItemName = "全部"
            });
            ViewData["level"] = content.Select(x => new SelectListItem()
            {
                Value = x.ItemName, Text = x.ItemName
            });

            return(View());
        }
Esempio n. 5
0
        /// <summary>
        /// 根据ItemName 查询栏目实体
        /// </summary>
        /// <param name="ItemName"></param>
        /// <returns></returns>
        public DataItemEntity QueryDataItemEntityByItemName(string ItemName)
        {
            DataItemBLL dataItemBLL = new DataItemBLL();

            //JsonConvert.SerializeObject(new { ItemName = ItemName }
            return(dataItemBLL.GetByItemName(ItemName));
        }
Esempio n. 6
0
        public ViewResult Detail(string id)
        {
            var categories = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "材料费", Text = "材料费"
                }, new SelectListItem()
                {
                    Value = "修理费", Text = "修理费"
                }
            };

            ViewData["categories"] = categories;

            var user    = OperatorProvider.Provider.Current();
            var deptbll = new DepartmentBLL();
            var dept    = deptbll.GetEntity(user.DeptId);

            if (dept == null)
            {
                dept = deptbll.GetRootDepartment();
            }
            var subdepts = deptbll.GetChildDepartments(user.DeptId);
            var depts    = subdepts.OrderBy(x => x.EnCode).Select(x => new SelectListItem()
            {
                Value = x.DepartmentId, Text = x.FullName
            }).ToList();

            ViewData["depts"] = depts;

            ViewBag.id = id;
            var itemdetialbll = new DataItemDetailBLL();
            var itembll       = new DataItemBLL();
            var main          = itembll.GetEntityByName("费用专业类型");
            var content       = itemdetialbll.GetList(main.ItemId).ToList();
            var professionals = content.Select(x => new SelectListItem()
            {
                Value = x.ItemValue, Text = x.ItemName
            }).ToList();

            professionals.Insert(0, new SelectListItem()
            {
                Value = "", Text = "==请选择=="
            });
            ViewData["professionals"] = professionals;

            var now    = DateTime.Now;
            var record = new CostRecordEntity()
            {
                RecordMonth  = new DateTime(now.Year, now.Month, 1),
                RecordUserId = user.UserId,
                RecordUser   = user.UserName,
                RecordDeptId = dept.DepartmentId,
                RecordDept   = dept.FullName,
                RecordTime   = DateTime.Now
            };

            return(View(record));
        }
Esempio n. 7
0
        /// <summary>
        /// 获取字典值
        /// </summary>
        /// <param name="Code">数据字典值</param>
        /// <returns></returns>
        public ActionResult GetCmbJson(string Code)
        {
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity DataItems = di.GetEntityByCode(Code);

            DataItemDetailBLL did = new DataItemDetailBLL();
            //根据字典项获取值
            IEnumerable <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId);

            return(Content(didList.ToJson()));
        }
Esempio n. 8
0
        public ActionResult Index2(string type)
        {
            var itemdetialbll = new DataItemDetailBLL();
            var itembll       = new DataItemBLL();
            var main          = itembll.GetEntityByName("违章类型");
            var content       = itemdetialbll.GetList(main.ItemId).ToList();

            content.Insert(0, new Entity.SystemManage.DataItemDetailEntity()
            {
                ItemValue = "全部", ItemName = "全部"
            });
            ViewData["category"] = content.Select(x => new SelectListItem()
            {
                Value = x.ItemName, Text = x.ItemName
            });

            main    = itembll.GetEntityByName("违章等级");
            content = itemdetialbll.GetList(main.ItemId).ToList();
            content.Insert(0, new Entity.SystemManage.DataItemDetailEntity()
            {
                ItemValue = "全部", ItemName = "全部"
            });
            ViewData["level"] = content.Select(x => new SelectListItem()
            {
                Value = x.ItemName, Text = x.ItemName
            });

            ViewData["state"] = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "全部", Text = "全部"
                }, new SelectListItem()
                {
                    Value = "待核准", Text = "待核准"
                }, new SelectListItem()
                {
                    Value = "待整改", Text = "待整改"
                }, new SelectListItem()
                {
                    Value = "待验收", Text = "待验收"
                }, new SelectListItem()
                {
                    Value = "验收通过", Text = "验收通过"
                }, new SelectListItem()
                {
                    Value = "核准不通过", Text = "核准不通过"
                }
            };
            ViewBag.type = type;
            return(View());
        }
Esempio n. 9
0
        public ActionResult GetLableStatistics()
        {
            var dt = lablemanagebll.GetLableStatistics();
            List <LablemanageEntity> lblist = lablemanagebll.GetList("").Where(it => it.IsBind == 1).ToList();;
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity DataItems = di.GetEntityByCode("LabelType");

            DataItemDetailBLL did = new DataItemDetailBLL();
            //根据字典项获取值
            List <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId).ToList();
            List <KbsEntity>            klist   = new List <KbsEntity>();
            int Znum = 0;

            foreach (var item in didList)
            {
                KbsEntity kbs = new KbsEntity();
                kbs.Name = item.ItemName;
                int num   = 0;
                int zxnum = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["labletypeid"].ToString() == item.ItemValue)
                    {
                        num   = Convert.ToInt32(dt.Rows[i]["cou"]);
                        zxnum = lblist.Where(it => it.LableTypeId == item.ItemValue && it.State == "在线").Count();
                        break;
                    }
                }
                kbs.Num  = num;
                Znum    += num;
                kbs.Num2 = zxnum;
                klist.Add(kbs);
            }
            for (int j = 0; j < klist.Count; j++)
            {
                double Proportion = 0;
                if (Znum != 0)
                {
                    Proportion = (double)klist[j].Num / Znum;
                    Proportion = Proportion * 100;
                }
                klist[j].Proportion = Proportion.ToString("0") + "%";
            }
            return(Content(klist.ToJson()));
        }
Esempio n. 10
0
 /// <summary>
 /// 获取报表文件树
 /// </summary>
 /// <returns></returns>
 public List <TreeModel> GetFileTree()
 {
     try
     {
         List <DataItemDetailEntity>         list     = new DataItemBLL().GetDetailList("ReportSort");
         IEnumerable <LR_RPT_FileInfoEntity> fileList = rptManageService.GetList();
         List <TreeModel> treeList = new List <TreeModel>();
         foreach (var item in list)
         {
             TreeModel node = new TreeModel();
             node.id         = item.F_ItemValue;
             node.text       = item.F_ItemName;
             node.value      = item.F_ItemValue;
             node.showcheck  = false;
             node.checkstate = 0;
             node.isexpand   = true;
             node.parentId   = item.F_ParentId == null ? "0" : item.F_ParentId;
             treeList.Add(node);
         }
         foreach (var file in fileList)
         {
             TreeModel node = new TreeModel();
             node.id         = file.F_Id;
             node.text       = file.F_Name;
             node.value      = file.F_File;
             node.showcheck  = false;
             node.checkstate = 0;
             node.isexpand   = false;
             node.parentId   = file.F_Type;
             treeList.Add(node);
         }
         return(treeList.ToTree());
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
        /// <summary>
        /// 应急预案
        /// </summary>
        /// <returns></returns>
        public ActionResult drillPlan()
        {
            var user          = OperatorProvider.Provider.Current();
            var itemdetialbll = new DataItemDetailBLL();
            var itembll       = new DataItemBLL();
            //test
            // user.UserId = "64465ded-6f94-47a7-83e0-4249721f4e4f";
            //应急预案
            var valueStr = string.Format("\"userid\":\"{0}\"", user.UserId);
            var DataStr  = string.Format("\"enCode\":\"{0}\"", "MAE_DirllMode");

            DataStr  = "{" + DataStr + "}";
            valueStr = "{" + valueStr + ",\"data\":" + DataStr + "}";
            var dyresult = webClientEmergency <EmergencyList>("EmergencyPlatform/GetDataItemListJson", valueStr);
            var content  = new List <DataItemDetailEntity>();

            if (dyresult.data != null && dyresult.data.Count > 0)
            {
                content = dyresult.data.Select(x => new Entity.SystemManage.DataItemDetailEntity {
                    ItemValue = x.ItemValue, ItemName = x.ItemName
                }).ToList();
            }
            content.Insert(0, new Entity.SystemManage.DataItemDetailEntity()
            {
                ItemValue = "全部", ItemName = "全部"
            });
            //编制部门
            var departBll     = new DepartmentBLL();
            var contentDepart = departBll.GetList().ToList();

            contentDepart.Insert(0, new Entity.BaseManage.DepartmentEntity {
                DepartmentId = "全部", FullName = "全部"
            });
            ViewBag.Depart   = contentDepart;
            ViewBag.content  = content;
            ViewData["name"] = "";
            //ViewData["from"] = from;
            //ViewData["to"] = to;
            //获取应急预案列表
            var dyresultS = webClientEmergency <EmergencyDataList>("EmergencyPlatform/GetReserverplanList",
                                                                   "{'userid':'" + user.UserId + "','data':{'name':''},'pageindex':1,pagesize:1000}");

            return(View(dyresultS));
        }
Esempio n. 12
0
        public ActionResult CheckApproveItem(string id)
        {
            var model = bll.GetLllegalDetail(id);

            var user = OperatorProvider.Provider.Current();
            //model.ApproveResult = "0";
            //model.ApprovePersonId = user.UserId;
            //model.ApprovePerson = user.UserName;
            //model.ApproveDate = DateTime.Now;
            //model.ApproveReason = string.Empty;

            var itemdetialbll = new DataItemDetailBLL();
            var itembll       = new DataItemBLL();
            var main          = itembll.GetEntityByName("考核方式");
            var content       = itemdetialbll.GetList(main.ItemId).ToList();

            ViewData["checktype"] = content.Select(x => new SelectListItem()
            {
                Value = x.ItemName, Text = x.ItemName
            });

            if (model.Files == null)
            {
                model.Files = new List <FileInfoEntity>();
            }

            model.refrom = new LllegalRefromBLL().GetEntityByLllegalId(model.ID);
            model.accept = new LllegalAcceptBLL().GetEntityByLllegalId(model.ID);
            if (model.refrom == null)
            {
                model.refrom = new LllegalRefromEntity();

                model.refrom.RefromTime = null;
                model.refrom.Files      = new List <FileInfoEntity>();
            }
            if (model.accept == null)
            {
                model.accept            = new LllegalAcceptEntity();
                model.accept.AcceptTime = null;
                model.accept.Files      = new List <FileInfoEntity>();
            }

            return(View(model));
        }
Esempio n. 13
0
        public ActionResult GetUserOnlineGroupJson()
        {
            string      sql = string.Format("select t.labletypename,t.labletypeid,count(1)as num from bis_lableonlinelog d join bis_lablemanage t on d.lableid=t.lableid where d.isout=0 and t.type=0 and t.state='在线' group by t.labletypename,t.labletypeid ");
            var         dt  = Opertickebll.GetDataTable(sql);
            DataItemBLL di  = new DataItemBLL();
            //先获取到字典项
            DataItemEntity    DataItems = di.GetEntityByCode("LabelType");
            DataItemDetailBLL did       = new DataItemDetailBLL();
            //根据字典项获取值
            List <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId).Where(a => a.ItemName != "厂外车辆" && a.ItemName != "厂内车辆").ToList();
            List <KbsEntity>            klist   = new List <KbsEntity>();
            int Znum = 0;

            foreach (var item in didList)
            {
                KbsEntity kbs = new KbsEntity();
                kbs.Name = item.ItemName;
                int num = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["labletypeid"].ToString() == item.ItemValue)
                    {
                        num = Convert.ToInt32(dt.Rows[i]["num"]);
                        break;
                    }
                }
                kbs.Num = num;
                Znum   += num;
                klist.Add(kbs);
            }
            for (int j = 0; j < klist.Count; j++)
            {
                double Proportion = 0;
                if (Znum != 0)
                {
                    Proportion = (double)klist[j].Num / Znum;
                    Proportion = Proportion * 100;
                }
                klist[j].Num2       = Znum;
                klist[j].Proportion = Proportion.ToString("0.00") + "%";
            }
            return(Content(klist.ToJson()));
        }
 public string GetProductType(string type, string key)
 {
     if (type == "1")
     {
         DataItemEntity entity = new DataItemBLL().GetEntityByCode("KmdcProductType");
         if (entity != null)
         {
             string    sql = string.Format("select d.itemname,d.itemcode,d.itemid from BASE_DATAITEM d where d.parentid='{0}' order by sortcode", entity.ItemId);
             DataTable dt  = operticketmanagerbll.GetDataTable(sql);
             return(dt.ToJson());
         }
     }
     else
     {
         string    sql = string.Format("select d.itemname,d.itemvalue from BASE_DATAITEMDETAIL d  where d.itemid='{0}' order by sortcode", key);
         DataTable dt  = operticketmanagerbll.GetDataTable(sql);
         return(dt.ToJson());
     }
     return("");
 }
Esempio n. 15
0
        public ViewResult Edit(string id)
        {
            var     user    = OperatorProvider.Provider.Current();
            UserBLL userBLL = new UserBLL();
            var     users   = userBLL.GetDeptUsers(user.DeptId).ToList();
            //任务类型
            var itemdetialbll = new DataItemDetailBLL();
            var itembll       = new DataItemBLL();
            var type          = itembll.GetEntityByName("任务库任务类型");
            var content       = itemdetialbll.GetList(type.ItemId).ToList();
            var jobtype       = content.Select(x => new SelectListItem()
            {
                Value = x.ItemId, Text = x.ItemName
            }).ToList();
            WorkSettingBLL settingbll = new WorkSettingBLL();
            var            setting    = settingbll.GetList("");
            //var pDeptid = dept.GetParent(deptid,"部门");
            var setupid      = string.Empty;
            var createuserid = string.Empty;

            //WorkOrderBLL orderbll = new WorkOrderBLL();
            //var banci = orderbll.getSetValue(user.DeptId).Select(x => new SelectListItem() { Text = x.Value, Value = x.Key }).ToList();
            //orderbll.GetWorkSettingByDept(user.DeptId, out setupid, out createuserid);
            //var getbanci = setting.Where(x => x.WorkSetupId == setupid && x.CreateUserId == createuserid);
            //var banci = getbanci.OrderBy(x => x.StartTime).Select(x => new SelectListItem() { Text = x.Name, Value = x.WorkSettingId }).ToList();
            //ViewData["banci"] = banci;
            ViewData["users"]   = users;
            ViewData["jobtype"] = jobtype;
            var job = workmeetingbll.GetJobTemplate(id);

            if (job == null)
            {
                job = new JobTemplateEntity();
                job.JobStartTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, 0, 0);
                job.JobEndTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 30, 0);
                job.Cycle        = "";
            }
            ViewBag.JobTime = string.Format("{0} - {1}", job.JobStartTime.HasValue ? job.JobStartTime.Value.ToString("HH:mm") : string.Empty, job.JobEndTime.HasValue ? job.JobEndTime.Value.ToString("HH:mm") : string.Empty);

            return(View(job));
        }
Esempio n. 16
0
        /// <summary>
        /// 获取数据字典常量类
        /// </summary>
        /// <returns></returns>
        private void GetDataItemConst(out string strcode, out string strvalue)
        {
            var dataList = new DataItemDetailBLL().GetDataItemList();
            var sord     = (from c in dataList orderby c.EnCode select c.EnCode).Distinct();

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("using System.ComponentModel;\r\n");
            sb.AppendLine("namespace LeaRun.Application.Entity\r\n{");

            sb.AppendLine("    /// <summary>");
            sb.AppendLine("    /// 数据字典值变量");
            sb.AppendLine("    /// </summary>");
            sb.AppendLine("    public class DataItemValues");
            sb.AppendLine("    {");

            foreach (string itemSort in sord)
            {
                var dataItemList = dataList.Where(t => t.EnCode.Equals(itemSort)).OrderBy(t => t.SortCode);
                foreach (DataItemModel itemList in dataItemList)
                {
                    string pname = itemList.EnCode + "_" + itemList.ItemValue;
                    pname = Regex.Replace(pname, @"[\s\-\.\;\:]+", "");
                    sb.AppendLine("\r\n        /// <summary>");
                    sb.AppendLine("        ///  " + itemList.EnCode + "." + itemList.ItemName);
                    sb.AppendLine("        /// </summary>");
                    sb.AppendLine("        [Description(\"" + itemList.ItemName + "\")]");
                    sb.AppendLine("        public const string " + pname + " = \"" +
                                  itemList.ItemValue + "\";");
                }
            }

            sb.AppendLine("    }\r\n}");
            strvalue = sb.ToString();


            var its = new DataItemBLL().GetList();

            StringBuilder sb2 = new StringBuilder();

            sb2.AppendLine("using System.ComponentModel;\r\n");
            sb2.AppendLine("namespace LeaRun.Application.Entity\r\n{");

            sb2.AppendLine("    /// <summary>");
            sb2.AppendLine("    /// 数据字典类型常量");
            sb2.AppendLine("    /// </summary>");
            sb2.AppendLine("    public class DataItemCodes");
            sb2.AppendLine("    {");

            foreach (DataItemEntity itemList in its)
            {
                string pname = itemList.ItemCode;
                pname = Regex.Replace(pname, @"[\s\-\.\;\:]+", "");
                sb2.AppendLine("\r\n        /// <summary>");
                sb2.AppendLine("        ///  " + itemList.ItemCode + "." + itemList.ItemName);
                sb2.AppendLine("        /// </summary>");
                sb2.AppendLine("        [Description(\"" + itemList.ItemName + "\")]");
                sb2.AppendLine("        public const string " + pname + " = \"" +
                               pname + "\";");
            }

            sb2.AppendLine("    }\r\n}");
            strcode = sb2.ToString();
        }
Esempio n. 17
0
        public JsonResult DoImport()
        {
            var success = true;
            var message = string.Empty;

            try
            {
                if (this.Request.Files.Count == 0)
                {
                    throw new Exception("请上传文件");
                }
                if (!this.Request.Files[0].FileName.EndsWith(".xlsx"))
                {
                    throw new Exception("请上传 Excel 文件");
                }

                var book  = new Workbook(this.Request.Files[0].InputStream);
                var sheet = book.Worksheets[0];
                var user  = OperatorProvider.Provider.Current();

                var     templates = new List <JobTemplateEntity>();
                var     date      = DateTime.Now;
                UserBLL userBLL   = new UserBLL();
                var     users     = userBLL.GetDeptUsers(user.DeptId).ToList();
                for (int i = 2; i <= sheet.Cells.MaxDataRow; i++)
                {
                    var entity = new JobTemplateEntity();
                    entity.JobId      = Guid.NewGuid().ToString();
                    entity.JobContent = sheet.Cells[i, 0].StringValue;
                    if (string.IsNullOrEmpty(entity.JobContent))
                    {
                        if (templates.Count > 0 && string.IsNullOrEmpty(sheet.Cells[i, 1].StringValue))
                        {
                            break;
                        }
                        success  = false;
                        message += "第" + (i + 1) + "行,未填写工作任务</br>";
                        continue;
                        //return Json(new { success, message });
                    }
                    var sss = sheet.Cells[i, 1].StringValue;
                    if (!string.IsNullOrEmpty(sheet.Cells[i, 1].StringValue))
                    {
                        var itemdetialbll = new DataItemDetailBLL();
                        var itembll       = new DataItemBLL();
                        var type          = itembll.GetEntityByName("任务库任务类型");
                        var content       = itemdetialbll.GetList(type.ItemId).ToList();
                        var typename      = sheet.Cells[i, 1].StringValue.Trim();
                        var gettype       = content.FirstOrDefault(row => row.ItemName == typename);
                        if (gettype == null)
                        {
                            success  = false;
                            message += "第" + (i + 1) + "行,不存在该类型</br>";
                            continue;
                            //return Json(new { success, message });
                        }
                        entity.jobplantype   = gettype.ItemName;
                        entity.jobplantypeid = gettype.ItemId;
                    }
                    else
                    {
                        success  = false;
                        message += "第" + (i + 1) + "行,任务类型不能为空</br>";
                        continue;
                        //return Json(new { success, message });
                    }
                    entity.RiskLevel = sheet.Cells[i, 2].StringValue;
                    if (string.IsNullOrEmpty(entity.RiskLevel))
                    {
                        success  = false;
                        message += "第" + (i + 1) + "行,未填写风险等级</br>";
                        continue;
                        // return Json(new { success, message });
                    }

                    var jobperson = sheet.Cells[i, 3].StringValue;
                    if (jobperson.Contains(","))
                    {
                        var person     = string.Empty;
                        var personid   = string.Empty;
                        var personList = jobperson.Split(',');
                        for (int j = 0; j < personList.Length; j++)
                        {
                            var ckjobperson = users.FirstOrDefault(row => row.RealName == personList[j]);
                            if (ckjobperson == null)
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行," + personList[j] + "作业人错误</br>";
                                continue;
                                //return Json(new { success, message });
                            }
                            if (j >= personList.Length - 1)
                            {
                                person   += personList[j];
                                personid += ckjobperson.DepartmentId;
                            }
                            else
                            {
                                person   += personList[j] + ",";
                                personid += ckjobperson.DepartmentId + ",";
                            }
                        }

                        entity.JobPerson   = person;
                        entity.JobPersonId = personid;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(jobperson))
                        {
                            var ckjobperson = users.FirstOrDefault(row => row.RealName == jobperson);
                            if (ckjobperson == null)
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行," + jobperson + "作业人错误</br>";
                                continue;
                                // return Json(new { success, message });
                            }
                            entity.JobPerson   = jobperson;
                            entity.JobPersonId = ckjobperson == null ? null : ckjobperson.UserId;
                        }
                    }
                    //string otherperson = sheet.Cells[i, 3].StringValue;
                    //if (!string.IsNullOrEmpty(otherperson))
                    //{
                    //    var ckotherperson = users.FirstOrDefault(row => row.RealName == otherperson);
                    //    if (ckotherperson == null)
                    //    {
                    //        success = false;
                    //        message = "选填作业人错误";
                    //        return Json(new { success, message });
                    //    }
                    //}
                    //if (otherperson == jobperson)
                    //{
                    //    success = false;
                    //    message = "作业人不能相同";
                    //    return Json(new { success, message });
                    //}
                    //entity.otherperson = otherperson;
                    entity.Device = sheet.Cells[i, 4].StringValue;
                    var getNow = DateTime.Now.ToString("yyyy-MM-dd");
                    //entity.JobStartTime = sheet.Cells[i, 5].StringValue == "" ? Convert.ToDateTime(getNow + " 08:30") : Convert.ToDateTime(getNow + " " + sheet.Cells[i, 5].StringValue);
                    //entity.JobEndTime = sheet.Cells[i, 6].StringValue == "" ? Convert.ToDateTime(getNow + " 17:30") : Convert.ToDateTime(getNow + " " + sheet.Cells[i, 6].StringValue);
                    entity.JobStartTime = Convert.ToDateTime(getNow + " 08:30");
                    entity.JobEndTime   = Convert.ToDateTime(getNow + " 17:30");
                    if (!string.IsNullOrEmpty(sheet.Cells[i, 5].StringValue))
                    {
                        //每年,二月、九月,15日,白班  每月,第一个、第三个,星期五,白班
                        var Cycle = sheet.Cells[i, 5].StringValue.Trim();

                        var cycleType = Cycle.Split(',');
                        if (cycleType[0] != "每天" && cycleType[0] != "每周" && cycleType[0] != "每月" && cycleType[0] != "每年")
                        {
                            success  = false;
                            message += "第" + (i + 1) + "行,周期规则错误</br>";
                            continue;
                            // return Json(new { success, message });
                        }

                        entity.Cycle = cycleType[0];
                        var ck   = false;
                        var data = string.Empty;
                        for (int j = 1; j < cycleType.Length; j++)
                        {
                            //if (cycleType[j] == "白班" || cycleType[j] == "夜班")
                            //{
                            //    entity.worksetname = cycleType[j];

                            //}
                            //else
                            if (cycleType[j] == "截止")
                            {
                                entity.isend = true;
                            }
                            else
                            if (cycleType[j] == "最后一天")
                            {
                                if ((Cycle.Contains("每月") || Cycle.Contains("每年")) && Cycle.Contains("日"))
                                {
                                    entity.islastday = true;
                                }
                                else
                                {
                                    success  = false;
                                    message += "第" + (i + 1) + "行,周期规则错误</br>";
                                    continue;
                                    //return Json(new { success, message });
                                }
                            }
                            else
                            if (cycleType[j].Contains("双休"))
                            {
                                if ((Cycle.Contains("每月") || Cycle.Contains("每年")) && Cycle.Contains("日"))
                                {
                                    entity.isweek = true;
                                }
                                else if (Cycle.Contains("每天"))
                                {
                                    entity.isweek = true;
                                }
                                else
                                {
                                    success  = false;
                                    message += "第" + (i + 1) + "行,周期规则错误</br>";
                                    continue;
                                    //return Json(new { success, message });
                                }
                            }
                            else
                            {
                                data += cycleType[j].Replace('日', ' ').Trim().Replace('、', ',') + ";";
                                ck    = true;
                            }
                        }

                        if (ck)
                        {
                            data             = data.Substring(0, data.Length - 1);
                            entity.CycleDate = data;
                        }
                        else
                        {
                            entity.CycleDate = data;
                        }
                    }
                    else
                    {
                        if (entity.jobplantype != "临时任务")
                        {
                            success  = false;
                            message += "第" + (i + 1) + "行,周期不能为空</br>";
                            continue;
                            //return Json(new { success, message });
                        }
                    }
                    entity.Dangerous = sheet.Cells[i, 6].StringValue;
                    entity.Measure   = sheet.Cells[i, 7].StringValue;
                    var EnableTraining = sheet.Cells[i, 8].StringValue;
                    entity.EnableTraining = EnableTraining == "是";
                    //entity.EnableTraining = false;
                    entity.worksetname = sheet.Cells[i, 9].StringValue;
                    if (entity.jobplantype == "设备巡回检查")
                    {
                        entity.TaskType = "巡回检查";
                    }
                    else if (entity.jobplantype == "定期工作")
                    {
                        entity.TaskType = "定期工作";
                    }
                    else
                    {
                        entity.TaskType = "日常工作";
                    }
                    var          setupid      = string.Empty;
                    var          createuserid = string.Empty;
                    WorkOrderBLL orderbll     = new WorkOrderBLL();
                    orderbll.GetWorkSettingByDept(user.DeptId, out setupid, out createuserid);
                    WorkSettingBLL settingbll = new WorkSettingBLL();
                    var            setting    = settingbll.GetList("");
                    var            getbanci   = setting.Where(x => x.WorkSetupId == setupid && x.CreateUserId == createuserid);
                    if (entity.worksetname.Contains(","))
                    {
                        var setname   = string.Empty;
                        var setnameid = string.Empty;
                        var setList   = entity.worksetname.Split(',');
                        for (int j = 0; j < setList.Length; j++)
                        {
                            var ckset = getbanci.FirstOrDefault(x => x.Name == entity.worksetname);
                            if (ckset == null)
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行,不存在该班次" + setList[j] + "</br>";
                                continue;
                                //return Json(new { success, message });
                            }
                            if (j >= setList.Length - 1)
                            {
                                setname   += setList[j];
                                setnameid += ckset.WorkSettingId;
                            }
                            else
                            {
                                setname   += setList[j] + ",";
                                setnameid += ckset.WorkSettingId + ",";
                            }
                        }

                        entity.worksetname = setname;
                        entity.worksetid   = setnameid;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(entity.worksetname))
                        {
                            if (entity.jobplantype != "临时任务")
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行,班次不能为空</br>";
                                continue;
                                //return Json(new { success, message });
                            }
                        }
                        else
                        {
                            var ckset = getbanci.FirstOrDefault(x => x.Name == entity.worksetname);
                            if (ckset == null)
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行,不存在该班次" + entity.worksetname + "</br>";
                                continue;
                                //return Json(new { success, message });
                            }
                            entity.worksetname = ckset.Name;
                            entity.worksetid   = ckset.WorkSettingId;
                        }
                    }
                    entity.DeptId     = user.DeptId;
                    entity.CreateDate = date.AddMinutes(i);
                    entity.DangerType = "job";
                    templates.Add(entity);
                }
                if (!success)
                {
                    return(Json(new { success, message }));
                }
                foreach (var item in templates)
                {
                    if (item.DangerousList == null)
                    {
                        item.DangerousList = new List <JobDangerousEntity>();
                    }
                    if (!string.IsNullOrEmpty(item.Dangerous))
                    {
                        var dangerArray        = item.Dangerous.Split('。');
                        var dangerMeasureArray = item.Measure?.Split('。');
                        for (int i = 0; i < dangerArray.Length; i++)
                        {
                            var danger = dangerArray[i];
                            if (string.IsNullOrEmpty(danger))
                            {
                                continue;
                            }
                            var templateDangerousEntity = new JobDangerousEntity {
                                Content = danger
                            };
                            if (dangerMeasureArray != null && dangerMeasureArray.Length > i)
                            {
                                templateDangerousEntity.MeasureList = new List <JobMeasureEntity>();
                                var dangerMeasure = dangerMeasureArray[i];
                                if (!string.IsNullOrEmpty(dangerMeasure))
                                {
                                    var measureArray = dangerMeasure.Split(';');
                                    foreach (var measure in measureArray)
                                    {
                                        if (string.IsNullOrEmpty(measure))
                                        {
                                            continue;
                                        }
                                        templateDangerousEntity.MeasureList.Add(new JobMeasureEntity {
                                            Content = measure
                                        });
                                    }
                                }
                            }
                            item.DangerousList.Add(templateDangerousEntity);
                        }
                    }
                    foreach (var item1 in item.DangerousList)
                    {
                        if (string.IsNullOrEmpty(item1.JobDangerousId))
                        {
                            item1.JobDangerousId = Guid.NewGuid().ToString();
                        }
                        item1.CreateTime = DateTime.Now;
                        item1.JobId      = item.JobId;
                        if (item1.MeasureList == null)
                        {
                            item1.MeasureList = new List <JobMeasureEntity>();
                        }
                        foreach (var item2 in item1.MeasureList)
                        {
                            if (string.IsNullOrEmpty(item2.JobMeasureId))
                            {
                                item2.JobMeasureId = Guid.NewGuid().ToString();
                            }
                            item2.CreateTime     = DateTime.Now;
                            item2.JobDangerousId = item1.JobDangerousId;
                        }
                    }

                    item.CreateUserId = user.UserId;
                    item.CreateUser   = user.UserName;
                    workmeetingbll.UpdateJobTemplate(item);
                }
                // workmeetingbll.AddJobTemplates(templates);
            }
            catch (Exception ex)
            {
                success = false;
                message = HttpUtility.JavaScriptStringEncode(ex.Message);
            }

            return(Json(new { success, message }));
        }
Esempio n. 18
0
        /// <summary>
        /// 导出到Excel
        /// </summary>
        /// <param name="queryJson"></param>
        /// <returns></returns>
        public ActionResult Excel(string queryJson)
        {
            string column       = "IDNUM,OCCDETAILID,USERNAME,USERNAMEPINYIN,INSPECTIONTIME,ISSICK,SICKTYPE,ISENDEMIC,ISUNUSUAL,UNUSUALNOTE";
            string stringcolumn = "ISSICK,SICKTYPE";

            string[] columns       = column.Split(',');
            string[] stringcolumns = stringcolumn.Split(',');

            string   wheresql = "";
            Operator user     = ERCHTMS.Code.OperatorProvider.Provider.Current();

            if (user.IsSystem)
            {
                wheresql = "";
            }
            else
            {
                string where = new ERCHTMS.Busines.AuthorizeManage.AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value);
                wheresql    += " and " + where;
            }

            DataTable dt    = occupationalstaffdetailbll.GetTable(queryJson, wheresql);
            DataTable Newdt = AsposeExcelHelper.UpdateDataTable(dt, columns, stringcolumns);//把所有字段转换成string 方便修改

            //先获取职业病数据
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity    DataItems = di.GetEntityByCode("SICKTYPE");
            DataItemDetailBLL did       = new DataItemDetailBLL();
            //根据字典项获取值
            IEnumerable <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId);

            //循环修改信息
            for (int i = 0; i < Newdt.Rows.Count; i++)
            {
                Newdt.Rows[i]["IDNUM"]          = i + 1;
                Newdt.Rows[i]["INSPECTIONTIME"] = Convert.ToDateTime(Newdt.Rows[i]["INSPECTIONTIME"]).ToString("yyyy-MM-dd");
                if (Convert.ToInt32(Newdt.Rows[i]["ISSICK"]) == 1)
                {
                    Newdt.Rows[i]["ISSICK"] = "是";
                    foreach (DataItemDetailEntity item in didList)
                    {
                        if (item.ItemValue == Newdt.Rows[i]["SICKTYPE"].ToString())
                        {
                            Newdt.Rows[i]["SICKTYPE"] = item.ItemName;
                        }
                    }
                }
                else
                {
                    Newdt.Rows[i]["ISSICK"]   = "否";
                    Newdt.Rows[i]["SICKTYPE"] = "";
                }
            }

            string FileUrl = "";

            var    queryParam = queryJson.ToJObject();
            string keyord     = queryParam["keyword"].ToString();

            if (keyord.ToInt() == 1) //查询职业病
            {
                FileUrl = @"\Resource\ExcelTemplate\职业健康职业病人员列表_导出模板.xlsx";
                AsposeExcelHelper.ExecuteResult(Newdt, FileUrl, "职业病人员列表", "职业病人员列表");
            }
            else if (keyord.ToInt() == 2)  //查询异常人员
            {
                FileUrl = @"\Resource\ExcelTemplate\职业健康异常人员列表_导出模板.xlsx";
                AsposeExcelHelper.ExecuteResult(Newdt, FileUrl, "异常人员列表", "异常人员列表");
            }
            else if (keyord.ToInt() == 3)  //查询体检人员
            {
                FileUrl = @"\Resource\ExcelTemplate\职业健康体检人员列表_导出模板.xlsx";
                AsposeExcelHelper.ExecuteResult(Newdt, FileUrl, "体检人员列表", "体检人员列表");
            }



            return(Success("导出成功。"));
        }
Esempio n. 19
0
        public ActionResult GetOccpuationalTreeJson(string Code, int checkMode = 0, int mode = 0, string deptIds = "0")
        {
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity DataItems = di.GetEntityByCode(Code);

            DataItemDetailBLL did = new DataItemDetailBLL();
            //根据字典项获取值
            List <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId).OrderBy(t => t.ItemValue).ToList();


            string      parentId = "0";
            OrganizeBLL orgBLL   = new OrganizeBLL();
            var         treeList = new List <TreeEntity>();

            //获取所有父节点集合
            List <DataItemDetailEntity> parentList = didList.Where(it => it.ItemValue.Length == 3).ToList();

            //获取所有子节点节点集合
            List <DataItemDetailEntity> SunList = didList.Where(it => it.ItemValue.Length > 3).ToList();

            foreach (DataItemDetailEntity oe in parentList)
            {
                treeList.Add(new TreeEntity
                {
                    id              = oe.ItemValue,
                    text            = oe.ItemName,
                    value           = oe.ItemValue,
                    parentId        = "0",
                    isexpand        = true,
                    complete        = true,
                    showcheck       = false,
                    hasChildren     = true,
                    Attribute       = "Sort",
                    AttributeValue  = "Parent",
                    AttributeA      = "manager",
                    AttributeValueA = "" + "," + "" + ",1"
                });
            }

            foreach (DataItemDetailEntity item in SunList)
            {
                int      chkState = 0;
                string[] arrids   = deptIds.Split(',');
                if (arrids.Contains(item.ItemValue))
                {
                    chkState = 1;
                }
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;
                tree.id              = item.ItemValue;
                tree.text            = item.ItemName;
                tree.value           = item.ItemValue;
                tree.isexpand        = true;
                tree.complete        = true;
                tree.checkstate      = chkState;
                tree.showcheck       = checkMode == 0 ? false : true;
                tree.hasChildren     = hasChildren;
                tree.parentId        = item.ItemValue.Substring(0, 3);
                tree.Attribute       = "Sort";
                tree.AttributeValue  = "Sun";
                tree.AttributeA      = "manager";
                tree.AttributeValueA = "" + "," + "" + "," + "2";
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson()));
        }
Esempio n. 20
0
        public string ImportDept()
        {
            int    error        = 0;
            string message      = "请选择格式正确的文件再导入!";
            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            if (count > 0)
            {
                HttpPostedFileBase file = HttpContext.Request.Files[0];
                if (string.IsNullOrEmpty(file.FileName))
                {
                    return(message);
                }
                if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx")))
                {
                    return(message);
                }
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName));
                DataTable dt    = ExcelHelper.ExcelImport(Server.MapPath("~/Resource/temp/" + fileName));
                int       order = 1;

                //先获取字典
                DataItemBLL di          = new DataItemBLL();
                DistrictBLL districtbll = new DistrictBLL();
                IEnumerable <DataItemDetailEntity> ReskList = di.GetList("Risk");
                IEnumerable <DistrictEntity>       AreaList = districtbll.GetOrgList(OperatorProvider.Provider.Current().OrganizeId);

                Expression <Func <UserEntity, bool> > condition;
                if (OperatorProvider.Provider.Current().IsSystem)
                {
                    condition = it => it.Account != "System" && it.IsPresence == "1";//如果是管理员
                }
                else
                {
                    string orgid = OperatorProvider.Provider.Current().OrganizeId;
                    condition = it => it.Account != "System" && it.IsPresence == "1" && it.OrganizeId == orgid;//不是管理员则查到所有本机构下的用户
                }

                //先获取到该用户下可以选择的用户
                List <UserEntity> userlist = new UserBLL().GetListForCon(condition).ToList();

                for (int i = 1; i < dt.Rows.Count; i++)
                {
                    //区域
                    string AreaName  = dt.Rows[i][0].ToString();
                    string AreaValue = "";

                    //危险源
                    string   RiskName = dt.Rows[i][1].ToString();//危险源名称
                    Operator user     = ERCHTMS.Code.OperatorProvider.Provider.Current();
                    //验证同一公司范围内是否有重复数据
                    if (!hazardfactorsbll.ExistDeptJugement(AreaName, user.OrganizeCode, RiskName))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行数据存在重复,未能导入.";
                        error++;
                        continue;
                    }

                    //验证区域是否有匹配项
                    if (!GetAreaIsTrue(AreaList, AreaName.Trim(), out AreaValue))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行值区域值不在可选范围内,未能导入.";
                        error++;
                        continue;
                    }



                    string RiskValue = "";
                    //if (Risks.Length == 0)
                    //{
                    //    falseMessage += "</br>" + "第" + (i + 2) + "行值职业病危害因素名称值为空,未能导入.";
                    //    error++;
                    //    continue;
                    //}
                    if (!GetIsTrue(ReskList, RiskName, out RiskValue))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行值职业病危害因素名称值不在可选范围内,未能导入.";
                        error++;
                        continue;
                    }

                    ////危险源
                    //string Num = dt.Rows[i][2].ToString();//接触人数量

                    //string pattern = "^[0-9]+$";
                    //int Contactnumber = 0;


                    ////验证是否是数字
                    //if (Regex.IsMatch(Num, pattern))
                    //{
                    //    Contactnumber = Convert.ToInt32(Num);
                    //}
                    //else if (Num.Trim() == "")
                    //{

                    //}
                    //else
                    //{
                    //    falseMessage += "</br>" + "第" + (i + 2) + "行值接触人数只能填写数字或者不填,值类型错误,未能导入.";
                    //    error++;
                    //    continue;
                    //}

                    string users = dt.Rows[i][2].ToString();
                    if (users.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行值接触人员不能为空,未能导入.";
                        error++;
                        continue;
                    }

                    users = users.Replace(',', ',');//把所有大写,替换成小写,

                    string[] uses      = users.Split(',');
                    string   userids   = "";
                    string   errorname = "";
                    for (int j = 0; j < uses.Length; j++)
                    {
                        UserEntity ue = userlist.Where(it => it.RealName == uses[j]).FirstOrDefault();
                        if (ue == null)//如果用户不存在
                        {
                            if (errorname == "")
                            {
                                errorname = uses[j];
                            }
                            else
                            {
                                errorname += "," + uses[j];
                            }
                            continue;
                        }

                        if (j == 0)
                        {
                            userids = ue.UserId;
                        }
                        else
                        {
                            userids += "," + ue.UserId;
                        }
                    }

                    if (errorname.Trim() != "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行值接触人员:" + errorname + ",值不在可选范围内,未能导入.";
                        error++;
                        continue;
                    }

                    HazardfactorsEntity hf = new HazardfactorsEntity();
                    hf.AreaId    = AreaValue;
                    hf.AreaValue = AreaName;
                    hf.Riskid    = RiskValue;
                    hf.RiskValue = RiskName;
                    if (uses.Length > 0)
                    {
                        hf.ContactNumber = uses.Length;
                    }


                    try
                    {
                        hazardfactorsbll.SaveForm("", hf, users, userids);
                    }
                    catch
                    {
                        error++;
                    }
                }
                count    = dt.Rows.Count - 1;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }

            return(message);
        }
Esempio n. 21
0
        public string ImportDataItem()
        {
            int    error        = 0;
            string message      = "请选择格式正确的文件再导入!";
            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            if (count > 0)
            {
                HttpPostedFileBase file = HttpContext.Request.Files[0];
                if (string.IsNullOrEmpty(file.FileName))
                {
                    return(message);
                }
                if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx")))
                {
                    return(message);
                }
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName));
                DataTable dt    = ExcelHelper.ExcelImport(Server.MapPath("~/Resource/temp/" + fileName));
                int       order = 1;

                //先获取字典
                DataItemBLL       di         = new DataItemBLL();
                DataItemEntity    Resk       = di.GetEntityByCode("Risk");
                DataItemDetailBLL detabll    = new DataItemDetailBLL();
                string[]          names      = { "粉尘", "化学因素", "物理因素", "放射性因素", "生物因素", "其他因素" };
                string[]          namevalues = { "01", "02", "03", "04", "05", "06" };

                string value = "";
                int    index = 1;
                string fname = file.FileName.Substring(0, file.FileName.IndexOf('.'));
                for (int i = 0; i < names.Length; i++)
                {
                    if (fname == names[i])
                    {
                        value = namevalues[i];
                    }
                }

                if (value != "")
                {
                    DataItemDetailEntity dide = new DataItemDetailEntity();
                    dide.ItemId    = Resk.ItemId;
                    dide.ItemValue = value;
                    dide.ItemName  = fname;
                    dide.SortCode  = index;
                    dide.ParentId  = "0";
                    try
                    {
                        detabll.SaveForm("", dide);
                    }
                    catch (Exception)
                    {
                        error++;
                    }

                    foreach (DataRow dr in dt.Rows)
                    {
                        DataItemDetailEntity did = new DataItemDetailEntity();
                        did.ItemId = Resk.ItemId;
                        if (index < 10)
                        {
                            did.ItemValue = value + "00" + index;
                        }
                        else if (index < 100)
                        {
                            did.ItemValue = value + "0" + index;
                        }
                        else
                        {
                            did.ItemValue = value + index;
                        }
                        did.ItemName = dr[0].ToString();
                        did.SortCode = index;
                        did.ParentId = "0";
                        index++;
                        try
                        {
                            detabll.SaveForm("", did);
                        }
                        catch (Exception)
                        {
                            error++;
                        }
                    }
                }



                count    = dt.Rows.Count - 1;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }
            return(message);
        }