Exemplo n.º 1
0
        /// <summary>
        /// 获取树形页面的数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetTree()
        {
            List <SystemTree> listSystemTree = new List <SystemTree>();

            IBLL.IDepartmentBLL db = new DepartmentBLL();

            DepartmentTreeNodeCollection tree = new DepartmentTreeNodeCollection();

            var trees = db.GetAll().OrderBy(o => o.id);

            if (trees != null)
            {
                string parentId = Request["parentid"];//父节点编号
                if (string.IsNullOrWhiteSpace(parentId))
                {
                    tree.Bind(trees, null, ref listSystemTree);
                }
                else
                {
                    tree.Bind(trees, parentId, ref listSystemTree);
                }
            }
            return(Json(listSystemTree, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        private List <CCardEntity> GetData(Worksheet sheet, int titleIndex, string userid)
        {
            var userbll  = new UserBLL();
            var user     = userbll.GetEntity(userid);
            var deptBll  = new DepartmentBLL();
            var allDept  = deptBll.GetAll();
            var total    = 0;
            var deptuser = userbll.GetList(user.DepartmentId, 10000, 1, out total);
            var result   = new List <CCardEntity>();

            for (int i = titleIndex + 1; i <= sheet.Cells.MaxDataRow; i++)
            {
                var workname = sheet.Cells[i, 1].StringValue;
                if (string.IsNullOrEmpty(workname))
                {
                    throw new Exception(string.Format("行 {0} 工作任务为空!", i + 1));
                }

                var deptList = sheet.Cells[i, 2].StringValue;

                if (string.IsNullOrEmpty(deptList))
                {
                    throw new Exception(string.Format("行 {0} 部门为空!", i + 1));
                }
                foreach (var item in deptList.Split(','))
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }
                    var entity = new CCardEntity();
                    entity.WorkName = workname;
                    var ck = allDept.FirstOrDefault(x => x.FullName == item);
                    if (ck == null)
                    {
                        throw new Exception(string.Format("行 {0} 部门不存在!", i + 1));
                    }
                    var getEntity = result.FirstOrDefault(x => x.WorkName == entity.WorkName && x.DeptName == item);
                    if (getEntity == null)
                    {
                        entity.DeptId   = ck.DepartmentId;
                        entity.DeptCode = ck.EnCode;
                        entity.DeptName = ck.FullName;
                        #region
                        var job          = getNewData(userid, entity.DeptId);
                        var DutyNameList = sheet.Cells[i, 3].StringValue;
                        if (string.IsNullOrEmpty(DutyNameList))
                        {
                            throw new Exception(string.Format("行 {0} 岗位为空!", i + 1));
                        }
                        var DutyId = string.Empty;
                        foreach (var duty in DutyNameList.Split(','))
                        {
                            if (string.IsNullOrEmpty(duty))
                            {
                                continue;
                            }
                            var ckduty = job.FirstOrDefault(x => x.FullName == duty);
                            if (ckduty == null)
                            {
                                throw new Exception(string.Format("行 {0} 岗位不存在!", i + 1));
                            }
                            DutyId += ckduty.RoleId + ",";
                        }
                        DutyId          = DutyId.Substring(0, DutyId.Length - 1);
                        entity.DutyId   = DutyId;
                        entity.DutyName = DutyNameList;
                        var WorkArea = sheet.Cells[i, 4].StringValue;
                        //if (string.IsNullOrEmpty(WorkArea))
                        //{
                        //    throw new Exception(string.Format("行 {0} 区域为空!", i + 1));
                        //}
                        entity.WorkArea = WorkArea;
                        var MainOperation = sheet.Cells[i, 5].StringValue;
                        if (string.IsNullOrEmpty(MainOperation))
                        {
                            throw new Exception(string.Format("行 {0} 主要步骤为空!", i + 1));
                        }
                        entity.MainOperation = MainOperation;
                        var dangers    = new CDangerousEntity();
                        var DangerName = sheet.Cells[i, 6].StringValue;
                        if (string.IsNullOrEmpty(DangerName))
                        {
                            throw new Exception(string.Format("行 {0} 危害名称为空!", i + 1));
                        }
                        dangers.DangerName = DangerName;
                        var DangerSource = sheet.Cells[i, 7].StringValue;
                        if (string.IsNullOrEmpty(DangerName))
                        {
                            throw new Exception(string.Format("行 {0} 风险描述为空!", i + 1));
                        }
                        dangers.DangerSource = DangerSource;
                        var Measurelist = sheet.Cells[i, 8].StringValue;
                        if (string.IsNullOrEmpty(Measurelist))
                        {
                            throw new Exception(string.Format("行 {0} 采取的控制措施为空!", i + 1));
                        }
                        dangers.Measure = new List <CMeasureEntity>();
                        foreach (var Measures in Measurelist.Split('\n'))
                        {
                            if (string.IsNullOrEmpty(Measures))
                            {
                                continue;
                            }
                            var Measure = new CMeasureEntity();
                            Measure.Measure = Measures;
                            dangers.Measure.Add(Measure);
                        }
                        entity.CDangerousList = new List <CDangerousEntity>();
                        entity.CDangerousList.Add(dangers);

                        #endregion
                        result.Add(entity);
                    }
                    else
                    {
                        var dangers    = new CDangerousEntity();
                        var DangerName = sheet.Cells[i, 6].StringValue;
                        if (string.IsNullOrEmpty(DangerName))
                        {
                            throw new Exception(string.Format("行 {0} 危害名称为空!", i + 1));
                        }
                        dangers.DangerName = DangerName;
                        var DangerSource = sheet.Cells[i, 7].StringValue;
                        if (string.IsNullOrEmpty(DangerName))
                        {
                            throw new Exception(string.Format("行 {0} 风险描述为空!", i + 1));
                        }
                        dangers.DangerSource = DangerSource;
                        var Measurelist = sheet.Cells[i, 8].StringValue;
                        if (string.IsNullOrEmpty(Measurelist))
                        {
                            throw new Exception(string.Format("行 {0} 采取的控制措施为空!", i + 1));
                        }
                        dangers.Measure = new List <CMeasureEntity>();
                        foreach (var Measures in Measurelist.Split('\n'))
                        {
                            if (string.IsNullOrEmpty(Measures))
                            {
                                continue;
                            }
                            var Measure = new CMeasureEntity();
                            Measure.Measure = Measures;
                            dangers.Measure.Add(Measure);
                        }

                        getEntity.CDangerousList.Add(dangers);
                    }
                }
            }

            return(result);
        }