public JsonResult GetBrandRange(string EnCode)
        {
            var result = new ReturnMessage(false)
            {
                Message = "获取失败!"
            };

            try
            {
                DataItemCache         dataItemCache = new DataItemCache();
                var                   data          = dataItemCache.GetDataItemList(EnCode);
                List <KeyValueEntity> list          = new List <KeyValueEntity>();
                if (data != null)
                {
                    data.Foreach((o) =>
                    {
                        list.Add(new KeyValueEntity()
                        {
                            ItemId = o.ItemDetailId.ToString(), ItemName = o.ItemName
                        });
                    });
                }
                result.IsSuccess          = true;
                result.Message            = "获取成功!";
                result.ResultData["List"] = list;
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "DataItemEnumsController>>GetBrandRange";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        private void RedisTest()
        {
            RedisHelper   redis = new RedisHelper();
            List <string> keys  = redis.GetKeys();

            Console.WriteLine("__TestBaseEntityKey是否存储:" + redis.KeyExists("__TestBaseEntityKey") + "\r\n");

            keys.ForEach(k =>
            {
                bool e = redis.KeyExists(k);
                Console.WriteLine(k + "是否存储:" + e + "\r\n");
            });
            Console.WriteLine("===========================");

            DataItemCache dataItem = new DataItemCache();
            var           res      = dataItem.GetDataItemList();

            Console.WriteLine("res:" + res.Count());

            Console.WriteLine("===========================");
            BaseEntity cache = CacheFactory.GetCacheInstance().GetCache <BaseEntity>("__TestBaseEntityKey");

            if (cache == null)
            {
                cache = new BaseEntity
                {
                    Id = "123",
                    PK = 1
                };
                CacheFactory.GetCacheInstance().WriteCache <BaseEntity>(cache, "__TestBaseEntityKey");
            }
            Console.WriteLine(cache.Id);
        }
 public EC_Income_GetInfoMessageHandler(MessageContext ctx)
     : base(ctx)
 {
     dataItemCache = new DataItemCache();
     cfBll         = new T_CapitalFlowBLL();
     cfnbll        = new T_CapitalFlow_NodeBLL();
     tabll         = new T_AttachmentBLL();
 }
Exemple #4
0
 public EC_Contract_Add_GetInfoMessageHandler(MessageContext ctx)
     : base(ctx)
 {
     dataItemCache = new DataItemCache();
     eprBll        = new EcommerceProjectRelationBLL();
     edpbll        = new EcommerceDiscountProgramBLL();
     op_parcelbll  = new OP_ParcelBLL();
     tabll         = new T_AttachmentBLL();
 }
        public ActionResult GetTreeJson(string queryJson)
        {
            DataItemCache dataItemCache  = new DataItemCache();
            var           formModuleData = formmodulebll.GetList();
            var           data           = dataItemCache.GetDataItemList("FormSort");
            var           treeList       = new List <TreeEntity>();

            foreach (DataItemModel item in data)
            {
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = true;//此处做下判断
                tree.id             = item.ItemDetailId;
                tree.text           = item.ItemName;
                tree.value          = item.ItemValue;
                tree.parentId       = item.ParentId;
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = hasChildren;
                tree.Attribute      = "Sort";
                tree.AttributeValue = "formCategory";
                treeList.Add(tree);
            }
            foreach (FormModuleEntity item in formModuleData)
            {
                #region 部门
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;
                tree.id    = item.FrmId;
                tree.text  = item.FrmName;
                tree.value = item.FrmId;

                tree.parentId        = item.FrmCategory;
                tree.isexpand        = true;
                tree.complete        = true;
                tree.hasChildren     = hasChildren;
                tree.Attribute       = "Sort";
                tree.AttributeValue  = "form";
                tree.AttributeA      = "version";
                tree.AttributeValueA = item.Version;
                treeList.Add(tree);
                #endregion
            }
            //if (!string.IsNullOrEmpty(queryJson))
            //{
            //    treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId");
            //}
            return(Content(treeList.TreeToJson()));
        }
Exemple #6
0
        /// <summary>
        /// 获取时间段
        /// </summary>
        /// <returns></returns>
        public List <KeyValueEntity> GetNormalTimeList()
        {
            DataItemCache         dataItemCache = new DataItemCache();
            var                   data          = dataItemCache.GetDataItemList("sjd");
            List <KeyValueEntity> list          = new List <KeyValueEntity>();

            if (data != null)
            {
                var itemdataList = data.OrderBy(i => i.SortCode).ThenBy(i => i.SortCode).ToList();
                itemdataList.ForEach((o) =>
                {
                    list.Add(new KeyValueEntity()
                    {
                        ItemId = o.ItemDetailId.ToString(), ItemName = o.ItemName, SortNum = o.SortCode ?? 0
                    });
                });
            }
            return(list);
        }
Exemple #7
0
        public JsonResult GetExamList(string EnCode)
        {
            var result = new ReturnMessage(false)
            {
                Message = "获取失败!"
            };

            try
            {
                DataItemCache dataItemCache = new DataItemCache();
                var           data          = dataItemCache.GetDataItemList(EnCode);
                result.IsSuccess          = true;
                result.Message            = "获取成功!";
                result.ResultData["List"] = data;
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "ExamController>>GetExamList";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #8
0
        /// <summary>
        /// 获取工作时间段
        /// </summary>
        /// <returns></returns>
        public ActionResult GetCurrentWorkTimeList()
        {
            var result = new ReturnMessage(false)
            {
                Message = "获取失败!"
            };

            try
            {
                //string[] names = System.Enum.GetNames(typeof(QX360.Model.Enums.WithDrivingTimeSpaceType));
                //int[] values = (int[])System.Enum.GetValues(typeof(QX360.Model.Enums.WithDrivingTimeSpaceType));
                //List<WithDrivingFreeTimeEntity> list = new List<WithDrivingFreeTimeEntity>();
                //for (int i = 0; i < names.Length; i++)
                //{
                //    list.Add(new WithDrivingFreeTimeEntity() { WorkTimeTableId = values[i].ToString(), TimeSection = names[i] });
                //}
                List <WithDrivingFreeTimeEntity> list = new List <WithDrivingFreeTimeEntity>();
                DataItemCache dataItemCache           = new DataItemCache();
                var           dataItemList            = dataItemCache.GetDataItemList("pjsd");
                foreach (var dataitem in dataItemList)
                {
                    list.Add(new WithDrivingFreeTimeEntity()
                    {
                        WorkTimeTableId = dataitem.ItemDetailId.ToString(), TimeSection = dataitem.ItemName, Remark = dataitem.Description, SortNum = dataitem.SortCode
                    });
                }
                list                      = list.OrderBy(p => p.SortNum).ToList();
                result.IsSuccess          = true;
                result.Message            = "获取成功";
                result.ResultData["List"] = list;
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "WithDrivingFreeTimeController>>GetCurrentWorkTimeList";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #9
0
        /// <summary>
        /// 如果是选择了驾校对应插入学车时间信息
        /// </summary>
        /// <param name="monthworklist"></param>
        /// <param name="worktimelist"></param>
        public void AddInitFreeTime(string objectid)
        {
            DateTime firsttime = DateTime.Now;            // Time.CalculateFirstDateOfWeek(DateTime.Now);
            DateTime endTime   = DateTime.Now.AddDays(6); //Time.CalculateLastDateOfWeek(DateTime.Now);
            List <WithDrivingFreeDateEntity> monthworklist = new List <WithDrivingFreeDateEntity>();

            while (true)
            {
                var dateid = Util.NewUpperGuid();
                if (DateTime.Now.DayOfWeek == firsttime.DayOfWeek)
                {
                    monthworklist.Add(new WithDrivingFreeDateEntity()
                    {
                        WithDrivingFreeDateId = dateid, FreeDate = firsttime, IsCurrentDay = true, Week = Convert.ToInt32(firsttime.DayOfWeek)
                    });
                }
                else
                {
                    monthworklist.Add(new WithDrivingFreeDateEntity()
                    {
                        WithDrivingFreeDateId = dateid, FreeDate = firsttime, IsCurrentDay = false, Week = Convert.ToInt32(firsttime.DayOfWeek)
                    });
                }
                firsttime = firsttime.AddDays(1);
                if (firsttime > endTime)
                {
                    break;
                }
            }
            //时间
            //string[] names = System.Enum.GetNames(typeof(RCHL.Model.Enums.WithDrivingTimeSpaceType));
            //int[] values = (int[])System.Enum.GetValues(typeof(RCHL.Model.Enums.WithDrivingTimeSpaceType));
            //List<WithDrivingFreeTimeEntity> worktimelist = new List<WithDrivingFreeTimeEntity>();
            //for (int i = 0; i < names.Length; i++)
            //{
            //    worktimelist.Add(new WithDrivingFreeTimeEntity() { WorkTimeTableId = values[i].ToString(), TimeSection = names[i] });
            //}
            List <WithDrivingFreeTimeEntity> worktimelist = new List <WithDrivingFreeTimeEntity>();
            DataItemCache dataItemCache = new DataItemCache();
            var           dataItemList  = dataItemCache.GetDataItemList("pjsd");

            foreach (var dataitem in dataItemList)
            {
                worktimelist.Add(new WithDrivingFreeTimeEntity()
                {
                    WorkTimeTableId = dataitem.ItemDetailId.ToString(), TimeSection = dataitem.ItemName, Remark = dataitem.Description, SortNum = dataitem.SortCode
                });
            }
            worktimelist = worktimelist.OrderBy(p => p.SortNum).ToList();
            foreach (var monthitem in monthworklist)
            {
                //判断日期是否存在
                var list = WithDrivingFreeDateBLL.Instance.GetList(new WithDrivingFreeDateEntity()
                {
                    ObjectId  = objectid,
                    StartTime = monthitem.FreeDate.ToString(),
                    EndTime   = monthitem.FreeDate.ToString()
                });
                if (list != null && list.Count() > 0)
                {
                    //已存在的不再增加
                }
                else
                {
                    WithDrivingFreeDateEntity freedate = new WithDrivingFreeDateEntity();
                    freedate.WithDrivingFreeDateId = Util.NewUpperGuid();
                    freedate.ObjectId = objectid;
                    freedate.FreeDate = monthitem.FreeDate;
                    freedate.Week     = monthitem.Week;
                    WithDrivingFreeDateBLL.Instance.Add(freedate);
                    foreach (var workitem in worktimelist)
                    {
                        WithDrivingFreeTimeEntity freetime = new WithDrivingFreeTimeEntity();
                        freetime.WithDrivingFreeTimeId = Util.NewUpperGuid();
                        freetime.WithDrivingFreeDateId = freedate.WithDrivingFreeDateId;
                        freetime.TimeSection           = workitem.TimeSection;
                        freetime.FreeStatus            = (int)RCHL.Model.Enums.FreeTimeStatus.空闲;
                        freetime.Remark          = workitem.Remark;
                        freetime.WorkTimeTableId = workitem.WorkTimeTableId;
                        freetime.SortNum         = workitem.SortNum;
                        this.Add(freetime);
                    }
                }
            }
        }
Exemple #10
0
        //[AjaxOnly]
        //[HandlerAuthorize(PermissionMode.Ignore)]
        // [ValidateAntiForgeryToken]
        public string ExcelImport()
        {
            if (OperatorProvider.Provider.Current().IsSystem)
            {
                return("超级管理员无此操作权限");
            }
            string orgId        = OperatorProvider.Provider.Current().OrganizeId;//所属公司
            var    currUser     = OperatorProvider.Provider.Current();
            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 = 2;
                string    orgid = OperatorProvider.Provider.Current().OrganizeId;
                for (int i = 1; i < dt.Rows.Count; i++)
                {
                    FireTroopsEntity item = new FireTroopsEntity();
                    order = i + 1;
                    #region 序号
                    string sortcode = dt.Rows[i][0].ToString();
                    int    tempSortCode;
                    if (!string.IsNullOrEmpty(sortcode))
                    {
                        if (Int32.TryParse(sortcode, out tempSortCode))
                        {
                            item.SortCode = tempSortCode;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,序号必须为整数!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,序号不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 责任部门
                    string deptlist = dt.Rows[i][1].ToString();
                    if (string.IsNullOrEmpty(deptlist))
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,单位(部门)不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    var p1 = string.Empty; var p2 = string.Empty;
                    var array    = deptlist.Split('/');
                    var deptFlag = false;
                    for (int j = 0; j < array.Length; j++)
                    {
                        if (j == 0)
                        {
                            if (currUser.RoleName.Contains("省级") || currUser.RoleName.Contains("集团"))
                            {
                                var entity1 = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && x.FullName == array[j].ToString()).FirstOrDefault();
                                if (entity1 == null)
                                {
                                    //falseMessage += "</br>" + "第" + (i + 3) + "行部门不存在,未能导入.";
                                    //error++;
                                    //deptFlag = true;
                                    //break;
                                    item.Dept = deptlist;
                                    break;
                                }
                                else
                                {
                                    item.Dept     = entity1.FullName;
                                    item.DeptCode = entity1.EnCode;
                                    p1            = entity1.DepartmentId;
                                }
                            }
                            else
                            {
                                var entity = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "厂级" && x.FullName == array[j].ToString()).FirstOrDefault();
                                if (entity == null)
                                {
                                    entity = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && (x.Nature == "部门" || x.Nature == "承包商" || x.Nature == "分包商") && x.FullName == array[j].ToString()).FirstOrDefault();
                                    if (entity == null)
                                    {
                                        entity = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "承包商" && x.FullName == array[j].ToString()).FirstOrDefault();
                                        if (entity == null)
                                        {
                                            //falseMessage += "</br>" + "第" + (i + 3) + "行部门不存在,未能导入.";
                                            //error++;
                                            //deptFlag = true;
                                            //break;
                                            item.Dept = deptlist;
                                            break;
                                        }
                                        else
                                        {
                                            item.Dept     = entity.FullName;
                                            item.DeptCode = entity.EnCode;
                                            p1            = entity.DepartmentId;
                                        }
                                    }
                                    else
                                    {
                                        item.Dept     = entity.FullName;
                                        item.DeptCode = entity.EnCode;
                                        p1            = entity.DepartmentId;
                                    }
                                }
                                else
                                {
                                    p1 = entity.DepartmentId;
                                }
                            }
                        }
                        else if (j == 1)
                        {
                            var entity1 = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && (x.Nature == "专业" || x.Nature == "承包商" || x.Nature == "分包商") && x.FullName == array[j].ToString() && x.ParentId == p1).FirstOrDefault();
                            if (entity1 == null)
                            {
                                entity1 = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "班组" && x.FullName == array[j].ToString() && x.ParentId == p1).FirstOrDefault();
                                if (entity1 == null)
                                {
                                    //falseMessage += "</br>" + "第" + (i + 3) + "行专业/班组不存在,未能导入.";
                                    //error++;
                                    //deptFlag = true;
                                    //break;
                                    item.Dept = deptlist;
                                    break;
                                }
                                else
                                {
                                    item.Dept     = entity1.FullName;
                                    item.DeptCode = entity1.EnCode;
                                    p2            = entity1.DepartmentId;
                                }
                            }
                            else
                            {
                                item.Dept     = entity1.FullName;
                                item.DeptCode = entity1.EnCode;
                                p2            = entity1.DepartmentId;
                            }
                        }
                        else
                        {
                            var entity1 = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && (x.Nature == "班组" || x.Nature == "承包商" || x.Nature == "分包商") && x.FullName == array[j].ToString() && x.ParentId == p2).FirstOrDefault();
                            if (entity1 == null)
                            {
                                //falseMessage += "</br>" + "第" + (i + 3) + "行班组不存在,未能导入.";
                                //error++;
                                //deptFlag = true;
                                //break;
                                item.Dept = deptlist;
                                break;
                            }
                            else
                            {
                                item.Dept     = entity1.FullName;
                                item.DeptCode = entity1.EnCode;
                            }
                        }
                    }
                    if (deptFlag)
                    {
                        continue;
                    }
                    #endregion

                    #region  称
                    string username = dt.Rows[i][2].ToString().Trim();
                    if (string.IsNullOrEmpty(username))
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,姓名不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    if (username != "")
                    {
                        if (item.DeptCode != "" && item.DeptCode != null)
                        {
                            UserInfoEntity userEntity = userbll.GetUserInfoByName(item.Dept, username);
                            if (userEntity == null)
                            {
                                falseMessage += string.Format(@"第{0}行,姓名在【{1}】不存在!</br>", order, item.Dept);
                                error++;
                                continue;
                            }
                            else
                            {
                                item.UserId   = userEntity.UserId;
                                item.UserName = userEntity.RealName;
                            }
                        }
                        else
                        {
                            item.UserName = username;
                        }
                    }
                    #endregion


                    #region 职务
                    string quarters = dt.Rows[i][3].ToString();
                    if (!string.IsNullOrEmpty(quarters))
                    {
                        var data = new DataItemCache().ToItemValue("Quarters", quarters);
                        if (data != null && !string.IsNullOrEmpty(data))
                        {
                            item.Quarters = quarters;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,职务不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,职务不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 性别
                    item.Sex = dt.Rows[i][4].ToString().Trim();
                    #endregion

                    #region 身份证号
                    //身份证号
                    string identity = dt.Rows[i][5].ToString().Trim();
                    if (!string.IsNullOrEmpty(identity))
                    {
                        if (!Regex.IsMatch(identity, @"^(^d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", RegexOptions.IgnoreCase))
                        {
                            falseMessage += string.Format(@"第{0}行身份证号格式有误!</br>", order);
                            error++;
                            continue;
                        }
                        else
                        {
                            item.IdentityCard = identity;
                        }
                    }
                    #endregion

                    #region 学历
                    string degrees = dt.Rows[i][6].ToString().Trim();
                    if (!string.IsNullOrEmpty(degrees))
                    {
                        var data = new DataItemCache().ToItemValue("Degrees", degrees);
                        if (data != null && !string.IsNullOrEmpty(data))
                        {
                            item.DegreesId = degrees;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,学历不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    #endregion

                    #region 持证情况
                    string certificates = dt.Rows[i][7].ToString().Trim();
                    if (!string.IsNullOrEmpty(certificates))
                    {
                        if (certificates.Length > 100)
                        {
                            falseMessage += string.Format(@"第{0}行持证情况字符过长!</br>", order);
                            error++;
                            continue;
                        }
                        else
                        {
                            item.Certificates = certificates;
                        }
                    }
                    #endregion

                    #region 户籍所在地
                    string placedomicile = dt.Rows[i][8].ToString().Trim();
                    if (!string.IsNullOrEmpty(placedomicile))
                    {
                        item.PlaceDomicile = placedomicile;
                    }
                    #endregion

                    #region 手机号
                    string phone = dt.Rows[i][9].ToString().Trim();
                    if (!string.IsNullOrEmpty(phone))
                    {
                        if (!Regex.IsMatch(phone, @"^(\+\d{2,3}\-)?\d{11}$", RegexOptions.IgnoreCase))
                        {
                            falseMessage += string.Format(@"第{0}行手机号格式不正确!</br>", order);
                            error++;
                            continue;
                        }
                        else
                        {
                            item.Certificates = certificates;
                        }
                    }
                    #endregion


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

            return(message);
        }
Exemple #11
0
        public string ImportTeam(string PostId)
        {
            //if (OperatorProvider.Provider.Current().IsSystem)
            //{
            //    return "超级管理员无此操作权限";
            //}
            string orgId        = OperatorProvider.Provider.Current().OrganizeId; //所属公司
            string deptId       = PostId;                                         //所属部门
            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;
                for (int i = 1; i < dt.Rows.Count; i++)
                {
                    order = i;
                    //---****值存在空验证*****--
                    if (string.IsNullOrEmpty(dt.Rows[i][0].ToString()) || string.IsNullOrEmpty(dt.Rows[i][1].ToString()) || string.IsNullOrEmpty(dt.Rows[i][2].ToString()) || string.IsNullOrEmpty(dt.Rows[i][3].ToString()))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行值存在空,未能导入.";
                        error++;
                        continue;
                    }
                    //应急组织机构
                    string        orgname       = dt.Rows[i][0].ToString();
                    DataItemCache dataItemCache = new DataItemCache();
                    var           orgItem       = dataItemCache.GetDataItemList().Where(e => e.EnCode == "MAE_ORG" && e.ItemName == orgname).FirstOrDefault();
                    string        OrgCode       = orgItem == null ? "" : orgItem.ItemCode;
                    //if (orgItem == null)
                    //{
                    //    falseMessage += "第" + i + "行导入失败,应急组织机构不存在!</br>";
                    //    error++;
                    //    continue;
                    //}
                    //应急职务
                    string postname = dt.Rows[i][1].ToString();
                    var    post     = dataItemCache.GetDataItemList().Where(e => e.EnCode == "MAE_TEAM_ZW" && e.ItemName == postname).FirstOrDefault();
                    //if (post == null)
                    //{
                    //    falseMessage += "第" + i + "行导入失败,应急职务不存在!</br>";
                    //    error++;
                    //    continue;
                    //}
                    string postid = post == null ? "" : post.ItemValue;
                    //姓名
                    string usernmae = dt.Rows[i][2].ToString();

                    //所属部门
                    string departname = dt.Rows[i][3].ToString();
                    var    depart     = departBLL.GetList().Where(e => e.FullName == departname && e.OrganizeId == orgId).FirstOrDefault();
                    var    org        = orgBLL.GetList().Where(e => e.FullName == departname && e.OrganizeId == orgId).FirstOrDefault();
                    if (depart == null && org == null)
                    {
                        falseMessage += "第" + i + "行导入失败,所属部门不存在!</br>";
                        error++;
                        continue;
                    }
                    //联系方式
                    string mobile = dt.Rows[i][4].ToString();
                    //备注
                    string remark = dt.Rows[i][5].ToString();

                    Expression <Func <UserEntity, bool> > condition = e => e.OrganizeId == orgId && e.RealName == usernmae && e.DepartmentId == depart.DepartmentId;
                    var user = userBLL.GetListForCon(condition).FirstOrDefault();
                    if (user == null)
                    {
                        falseMessage += "第" + i + "行导入失败,该用户关联信息不存在!</br>";
                        error++;
                        continue;
                    }


                    try
                    {
                        var item = new TeamEntity {
                            OrgName = orgname, OrgCode = OrgCode, MOBILE = mobile, USERFULLNAME = usernmae, POSTNAME = postname, POSTID = postid, DEPARTID = depart == null ? org.OrganizeId : depart.DepartmentId, DEPARTNAME = departname, USERID = user.UserId, Remark = remark
                        };
                        var listcheck = teambll.GetList(string.Format(" and USERFULLNAME='{0}' and Mobile='{1}' and DepartId='{2}' and POSTID='{3}'", item.USERFULLNAME, item.MOBILE, item.DEPARTID, item.POSTID));
                        if (listcheck != null && listcheck.Count() > 0)
                        {
                            falseMessage += "应急职务:" + item.POSTNAME + ",所属部门" + item.DEPARTNAME + ",姓名:" + item.USERFULLNAME + "的信息已经存在!";
                            //return Error("该条数据已存在。");
                        }
                        else
                        {
                            teambll.SaveForm("", item);
                        }
                    }
                    catch
                    {
                        error++;
                    }
                }
                count    = dt.Rows.Count - 1;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }

            return(message);
        }
Exemple #12
0
        //[AjaxOnly]
        //[HandlerAuthorize(PermissionMode.Ignore)]
        // [ValidateAntiForgeryToken]
        public string ImportGenericFirefighting()
        {
            if (OperatorProvider.Provider.Current().IsSystem)
            {
                return("超级管理员无此操作权限");
            }
            string orgId        = OperatorProvider.Provider.Current().OrganizeId;//所属公司
            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;
                string    orgid = OperatorProvider.Provider.Current().OrganizeId;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    KeyPartEntity item = new KeyPartEntity();
                    order = i + 1;
                    #region 重点防火部位名称
                    string partname = dt.Rows[i][0].ToString();
                    if (!string.IsNullOrEmpty(partname))
                    {
                        item.PartName = partname;
                        item.PartNo   = partname;
                        //var data = new DataItemCache().ToItemValue("PartName", partname);
                        //if (data != null && !string.IsNullOrEmpty(data))
                        //    item.PartNo = data;
                        //else
                        //{
                        //    falseMessage += string.Format(@"第{0}行导入失败,重点防火部位名称不存在!</br>", order);
                        //    error++;
                        //    continue;
                        //}
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,重点防火部位名称不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 所在位置
                    string district = dt.Rows[i][1].ToString();
                    if (!string.IsNullOrEmpty(district))
                    {
                        var disItem = new DistrictBLL().GetListForCon(x => x.DistrictName == district && x.OrganizeId == orgid).FirstOrDefault();
                        if (disItem != null)
                        {
                            item.DistrictId   = disItem.DistrictID;
                            item.DistrictCode = disItem.DistrictCode;
                            item.District     = district;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,所在位置不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,所在位置不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 责任部门
                    string dutydept = dt.Rows[i][2].ToString();
                    if (!string.IsNullOrEmpty(dutydept))
                    {
                        var data = departBLL.GetList().FirstOrDefault(e => e.FullName == dutydept && e.OrganizeId == orgid);
                        if (data != null)
                        {
                            item.DutyDept     = dutydept;
                            item.DutyDeptCode = data.EnCode;
                        }

                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,责任部门不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,责任部门不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 责任人
                    string dutyUser = dt.Rows[i][3].ToString();
                    if (!string.IsNullOrEmpty(dutyUser))
                    {
                        var userEntity = userBLL.GetListForCon(x => x.RealName == dutyUser && x.OrganizeId == orgid).FirstOrDefault();
                        if (userEntity != null)
                        {
                            item.DutyUserId = userEntity.UserId;
                            item.DutyUser   = dutyUser;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,责任人不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,责任人不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 责任人电话
                    string dutyTel = dt.Rows[i][4].ToString();
                    if (!string.IsNullOrEmpty(dutyTel))
                    {
                        item.DutyTel = dutyTel;
                    }
                    #endregion

                    #region 建筑结构
                    string structure = dt.Rows[i][5].ToString();
                    if (!string.IsNullOrEmpty(structure))
                    {
                        item.Structure = structure;
                        var data = new DataItemCache().ToItemValue("Structure", structure);
                        if (data != null && !string.IsNullOrEmpty(data))
                        {
                            item.Structure = data;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,建筑结构不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    //else
                    //{
                    //    falseMessage += string.Format(@"第{0}行导入失败,建筑结构不能为空!</br>", order);
                    //    error++;
                    //    continue;
                    //}
                    #endregion

                    #region 建筑面积(m2)
                    string acreage = dt.Rows[i][6].ToString();
                    int    tempAcreage;
                    if (!string.IsNullOrEmpty(acreage))
                    {
                        if (int.TryParse(acreage, out tempAcreage))
                        {
                            item.Acreage = tempAcreage;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,建筑面积(m2)必须为数字!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    //else
                    //{
                    //    falseMessage += string.Format(@"第{0}行导入失败,建筑面积(m2)不能为空!</br>", order);
                    //    error++;
                    //    continue;
                    //}
                    #endregion

                    #region 主要存储物品
                    string storegoods = dt.Rows[i][7].ToString();
                    if (!string.IsNullOrEmpty(storegoods))
                    {
                        item.StoreGoods = storegoods;
                    }
                    #endregion

                    #region 主要灭火器装备
                    string outfireequip = dt.Rows[i][8].ToString();
                    if (!string.IsNullOrEmpty(outfireequip))
                    {
                        item.OutfireEquip = outfireequip;
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,主要灭火器装备不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 重点防火部位人数
                    string peoplenum = dt.Rows[i][9].ToString();
                    int    tempPeopleNum;
                    if (!string.IsNullOrEmpty(peoplenum))
                    {
                        if (int.TryParse(peoplenum, out tempPeopleNum))
                        {
                            item.PeopleNum = tempPeopleNum;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,重点防火部位人数必须为数字!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    #endregion

                    #region 动火级别
                    string rank = dt.Rows[i][10].ToString();
                    if (!string.IsNullOrEmpty(rank))
                    {
                        if (rank == "一级动火区域")
                        {
                            item.Rank = 1;
                        }
                        else if (rank == "二级动火区域")
                        {
                            item.Rank = 2;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,动火级别不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,动火级别不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 最近巡查日期(年月日)
                    string   latelypatroldate = dt.Rows[i][11].ToString();
                    DateTime tempLatelyPatrolDate;
                    if (!string.IsNullOrEmpty(latelypatroldate))
                    {
                        if (DateTime.TryParse(latelypatroldate, out tempLatelyPatrolDate))
                        {
                            item.LatelyPatrolDate = tempLatelyPatrolDate;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,最近巡查日期不对!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    #endregion

                    #region 巡查周期(天)
                    string patrolperiod = dt.Rows[i][12].ToString();
                    int    tempPatrolPeriod;
                    if (!string.IsNullOrEmpty(patrolperiod))
                    {
                        if (int.TryParse(patrolperiod, out tempPatrolPeriod))
                        {
                            item.PatrolPeriod = tempPatrolPeriod;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,巡查周期(天)必须为数字!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    #endregion

                    #region  次巡查日期
                    string   nextpatroldate = dt.Rows[i][13].ToString();
                    DateTime tempNextPatrolDate;
                    if (!string.IsNullOrEmpty(nextpatroldate))
                    {
                        if (DateTime.TryParse(nextpatroldate, out tempNextPatrolDate))
                        {
                            item.NextPatrolDate = tempNextPatrolDate;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,下次巡查日期不对!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,下次巡查日期不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 使用状态
                    string employstate = dt.Rows[i][14].ToString();
                    if (!string.IsNullOrEmpty(employstate))
                    {
                        if (employstate == "在用")
                        {
                            item.EmployState = 0;
                        }
                        else if (employstate == "停用")
                        {
                            item.EmployState = 1;
                        }
                        else if (employstate == "其他")
                        {
                            item.EmployState = 2;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,使用状态不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,使用状态不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 火灾危险性分析
                    string analyze = dt.Rows[i][15].ToString();
                    if (!string.IsNullOrEmpty(analyze))
                    {
                        item.Analyze = analyze;
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,火灾危险性分析不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 防火措施
                    string measure = dt.Rows[i][16].ToString();
                    if (!string.IsNullOrEmpty(measure))
                    {
                        item.Measure = measure;
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,防火措施不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion
                    //管理要求
                    string require = dt.Rows[i][17].ToString();
                    if (!string.IsNullOrEmpty(require))
                    {
                        item.Require = require;
                    }
                    //备注
                    string remark = dt.Rows[i][18].ToString();
                    if (!string.IsNullOrEmpty(remark))
                    {
                        item.Remark = remark;
                    }

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

            return(message);
        }
Exemple #13
0
        //[AjaxOnly]
        //[HandlerAuthorize(PermissionMode.Ignore)]
        // [ValidateAntiForgeryToken]
        public string ExcelImport()
        {
            if (OperatorProvider.Provider.Current().IsSystem)
            {
                return("超级管理员无此操作权限");
            }
            string orgId        = OperatorProvider.Provider.Current().OrganizeId;//所属公司
            var    currUser     = OperatorProvider.Provider.Current();
            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;
                string    orgid = OperatorProvider.Provider.Current().OrganizeId;
                for (int i = 1; i < dt.Rows.Count; i++)
                {
                    DangerChemicalsEntity item = new DangerChemicalsEntity();
                    order = i + 1;
                    #region 危化品名称
                    string name = dt.Rows[i][0].ToString();
                    if (!string.IsNullOrEmpty(name))
                    {
                        item.Name = name;
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,危化品名称不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion
                    //别名
                    string alias = dt.Rows[i][1].ToString();
                    if (!string.IsNullOrEmpty(alias))
                    {
                        item.Alias = alias;
                    }
                    //CAS号
                    string cas = dt.Rows[i][2].ToString();
                    if (!string.IsNullOrEmpty(cas))
                    {
                        item.Cas = cas;
                    }
                    #region 危化品类型
                    string risktype = dt.Rows[i][3].ToString();
                    if (!string.IsNullOrEmpty(risktype))
                    {
                        var data = new DataItemCache().ToItemValue("ChemicalsRiskType", risktype);
                        if (data != null && !string.IsNullOrEmpty(data))
                        {
                            item.RiskType = risktype;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,危化品类型不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,危化品类型不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 规格
                    string  specification = dt.Rows[i][4].ToString();
                    decimal tempSpecification;
                    if (!string.IsNullOrEmpty(specification))
                    {
                        if (decimal.TryParse(specification, out tempSpecification))
                        {
                            item.Specification = tempSpecification.ToString();
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,规格必须为数字(保留两位小数)!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,规格不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 规格单位
                    string specificationunit = dt.Rows[i][5].ToString();
                    if (!string.IsNullOrEmpty(specificationunit))
                    {
                        var data = new DataItemCache().ToItemValue("ChemicalsUnit", specificationunit);
                        if (data != null && !string.IsNullOrEmpty(data))
                        {
                            item.SpecificationUnit = specificationunit;
                            if (specificationunit.IndexOf("/") >= 0)
                            {
                                var index = specificationunit.LastIndexOf("/");
                                item.AmountUnit = specificationunit.Substring(index + 1); //数量单位
                                item.Unit       = specificationunit.Substring(0, index);  //库存单位
                            }
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,规格单位不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,规格单位不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 数量
                    string  amount = dt.Rows[i][6].ToString();
                    decimal tempAmount;
                    if (!string.IsNullOrEmpty(amount))
                    {
                        if (decimal.TryParse(amount, out tempAmount))
                        {
                            item.Amount    = tempAmount.ToString();
                            item.Inventory = (tempSpecification * tempAmount).ToString("#0.00");
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,数量必须为数字(保留两位小数)!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,数量不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 生产日期
                    string   productionDate = dt.Rows[i][7].ToString();
                    DateTime tempProductionDate;
                    if (!string.IsNullOrEmpty(productionDate))
                    {
                        if (DateTime.TryParse(productionDate, out tempProductionDate))
                        {
                            item.ProductionDate = tempProductionDate;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,生产日期不对!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,生产日期不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 存放日期
                    string   depositDate = dt.Rows[i][8].ToString();
                    DateTime tempDepositDate;
                    if (!string.IsNullOrEmpty(depositDate))
                    {
                        if (DateTime.TryParse(depositDate, out tempDepositDate))
                        {
                            item.DepositDate = tempDepositDate;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,入库日期不对!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,入库日期不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 存放地点类型
                    string isscene = dt.Rows[i][9].ToString();
                    if (!string.IsNullOrEmpty(isscene))
                    {
                        if (isscene == "现场存放" || isscene == "仓库存放")
                        {
                            item.IsScene = isscene;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,存放地点类型不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,存放地点类型不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 存放地点
                    string site = dt.Rows[i][10].ToString();
                    if (!string.IsNullOrEmpty(site))
                    {
                        item.Site = site;
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,存放地点不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 存放期限
                    string deadline = dt.Rows[i][11].ToString();
                    int    tempDeadline;
                    if (!string.IsNullOrEmpty(deadline))
                    {
                        if (int.TryParse(deadline, out tempDeadline))
                        {
                            item.Deadline = tempDeadline;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,存放期限必须为数字!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,存放期限不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 发放人
                    string Person = dt.Rows[i][12].ToString();
                    if (!string.IsNullOrEmpty(Person))
                    {
                        var userEntity = userBLL.GetListForCon(x => x.RealName == Person).FirstOrDefault();
                        if (userEntity != null)
                        {
                            item.GrantPersonId = userEntity.UserId;
                            item.GrantPerson   = Person;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,发放人不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,发放人不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 责任人
                    string dutyUser = dt.Rows[i][13].ToString();
                    if (!string.IsNullOrEmpty(dutyUser))
                    {
                        var userEntity = userBLL.GetListForCon(x => x.RealName == dutyUser).FirstOrDefault();
                        if (userEntity != null)
                        {
                            item.DutyUserId = userEntity.UserId;
                            item.DutyUser   = dutyUser;
                        }
                        else
                        {
                            falseMessage += string.Format(@"第{0}行导入失败,责任人不存在!</br>", order);
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        falseMessage += string.Format(@"第{0}行导入失败,责任人不能为空!</br>", order);
                        error++;
                        continue;
                    }
                    #endregion

                    #region 责任部门
                    string deptlist = dt.Rows[i][14].ToString();
                    var    p1 = string.Empty; var p2 = string.Empty;
                    var    array    = deptlist.Split('/');
                    var    deptFlag = false;
                    for (int j = 0; j < array.Length; j++)
                    {
                        if (j == 0)
                        {
                            if (currUser.RoleName.Contains("省级") || currUser.RoleName.Contains("集团"))
                            {
                                var entity1 = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && x.FullName == array[j].ToString()).FirstOrDefault();
                                if (entity1 == null)
                                {
                                    falseMessage += "</br>" + "第" + (i + 3) + "行部门不存在,未能导入.";
                                    error++;
                                    deptFlag = true;
                                    break;
                                }
                                else
                                {
                                    item.DutyDept     = entity1.FullName;
                                    item.DutyDeptCode = entity1.EnCode;
                                    p1 = entity1.DepartmentId;
                                }
                            }
                            else
                            {
                                var entity = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "厂级" && x.FullName == array[j].ToString()).FirstOrDefault();
                                if (entity == null)
                                {
                                    entity = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && (x.Nature == "部门" || x.Nature == "承包商" || x.Nature == "分包商") && x.FullName == array[j].ToString()).FirstOrDefault();
                                    if (entity == null)
                                    {
                                        entity = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "承包商" && x.FullName == array[j].ToString()).FirstOrDefault();
                                        if (entity == null)
                                        {
                                            falseMessage += "</br>" + "第" + (i + 3) + "行部门不存在,未能导入.";
                                            error++;
                                            deptFlag = true;
                                            break;
                                        }
                                        else
                                        {
                                            item.DutyDept     = entity.FullName;
                                            item.DutyDeptCode = entity.EnCode;
                                            p1 = entity.DepartmentId;
                                        }
                                    }
                                    else
                                    {
                                        item.DutyDept     = entity.FullName;
                                        item.DutyDeptCode = entity.EnCode;
                                        p1 = entity.DepartmentId;
                                    }
                                }
                                else
                                {
                                    item.DutyDept     = entity.FullName;
                                    item.DutyDeptCode = entity.EnCode;
                                    p1 = entity.DepartmentId;
                                }
                            }
                        }
                        else if (j == 1)
                        {
                            var entity1 = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && (x.Nature == "专业" || x.Nature == "承包商" || x.Nature == "分包商") && x.FullName == array[j].ToString() && x.ParentId == p1).FirstOrDefault();
                            if (entity1 == null)
                            {
                                entity1 = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "班组" && x.FullName == array[j].ToString() && x.ParentId == p1).FirstOrDefault();
                                if (entity1 == null)
                                {
                                    falseMessage += "</br>" + "第" + (i + 3) + "行专业/班组不存在,未能导入.";
                                    error++;
                                    deptFlag = true;
                                    break;
                                }
                                else
                                {
                                    item.DutyDept     = entity1.FullName;
                                    item.DutyDeptCode = entity1.EnCode;
                                    p2 = entity1.DepartmentId;
                                }
                            }
                            else
                            {
                                item.DutyDept     = entity1.FullName;
                                item.DutyDeptCode = entity1.EnCode;
                                p2 = entity1.DepartmentId;
                            }
                        }
                        else
                        {
                            var entity1 = departmentBLL.GetList().Where(x => x.OrganizeId == currUser.OrganizeId && (x.Nature == "班组" || x.Nature == "承包商" || x.Nature == "分包商") && x.FullName == array[j].ToString() && x.ParentId == p2).FirstOrDefault();
                            if (entity1 == null)
                            {
                                falseMessage += "</br>" + "第" + (i + 3) + "行班组不存在,未能导入.";
                                error++;
                                deptFlag = true;
                                break;
                            }
                            else
                            {
                                item.DutyDept     = entity1.FullName;
                                item.DutyDeptCode = entity1.EnCode;
                            }
                        }
                    }
                    if (deptFlag)
                    {
                        continue;
                    }
                    #endregion

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

            return(message);
        }