コード例 #1
0
        private void SaveBackupDepartmentsInfo(List <Department> Deplst)
        {
            DepartmentInfoBackupList backUpList = new DepartmentInfoBackupList();

            backUpList.DepList = new List <DepartmentInfoBackup>();
            foreach (var item in Deplst)
            {
                DepartmentInfoBackup Dep = new DepartmentInfoBackup();
                if (item.Abutment_Id != null)
                {
                    Dep.Abutment_Id = (int)item.Abutment_Id;
                }
                else
                {
                    Dep.Abutment_Id = -1;
                }

                Dep.Name = item.Name;

                if (item.ParentId != null)
                {
                    Dep.ParentId = (int)item.ParentId;
                }
                else
                {
                    Dep.ParentId = -1;
                }


                if (item.Abutment_ParentId != null)
                {
                    Dep.Abutment_ParentId = (int)item.Abutment_ParentId;
                }
                else
                {
                    Dep.Abutment_ParentId = -1;
                }

                Dep.ShowOrder   = item.ShowOrder;
                Dep.Type        = item.Type;
                Dep.Description = item.Description;

                backUpList.DepList.Add(Dep);
            }

            string initFile = InitPaths.GetBackupDepartmentsInfo();

            XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
        }
コード例 #2
0
        public void InitDepartments_Mock()
        {
            Log.InfoStart(LogTags.DbInit, "InitDepartments");

            bool r1 = LocationCardToPersonnels.Clear();
            bool r2 = LocationCardPositions.Clear();
            bool r3 = Personnels.Clear();
            bool r4 = Departments.Clear();

            Log.Info(LogTags.DbInit, "导入部门信息");
            string filePath = InitPaths.GetBackupDepartmentsInfo();
            bool   value    = DepartmentsBackupHelper.ImportDepartmentInfoFromFile(filePath, _bll);

            Log.Info(LogTags.DbInit, string.Format("导入部门信息结果:{0}", value));

            Posts.Clear();
            Post post1 = new Post()
            {
                Name = "前台"
            };
            Post post2 = new Post()
            {
                Name = "电工"
            };
            Post post3 = new Post()
            {
                Name = "维修工"
            };
            Post post4 = new Post()
            {
                Name = "保安"
            };
            Post post5 = new Post()
            {
                Name = "经理"
            };
            Post post6 = new Post()
            {
                Name = "电工"
            };
            Post post7 = new Post()
            {
                Name = "访客"
            };
            Post post8 = new Post()
            {
                Name = "检修"
            };
            var posts = new List <Post>()
            {
                post1, post2, post3, post4, post5, post6, post7, post8
            };

            Posts.AddRange(posts);
            List <LocationCard> tagsT = LocationCards.ToList();
            RandomTool          rt    = new RandomTool();


            //Log.Info(LogTags.DbInit, "导入人员信息");
            //var basePath = AppDomain.CurrentDomain.BaseDirectory;
            //filePath = InitPaths.GetBackupPersonnelInfo();
            //value = PersonBackupHelper.ImportPersonInfoFromFile(filePath, _bll);
            //Log.Info(LogTags.DbInit, string.Format("导入人员信息结果:{0}", value));

            //List<Personnel> pList = Personnels.ToList();


            //Log.Info(LogTags.DbInit, "开始  导入人员和定位卡关联关系");
            ////人员和定位卡关联关系
            //filePath = InitPaths.GetPersonAndCard();
            //LocationCardToPersonnelsBackupHelper.ImportRelationFromFile(new FileInfo(filePath));
            //Log.Info(LogTags.DbInit, "结束 导入人员和定位卡关联关系");
            //List<LocationCardToPersonnel> rList = LocationCardToPersonnels.ToList();

            //List<LocationCard> tagsTemp = new List<LocationCard>();
            //foreach (LocationCardToPersonnel ctp in rList)
            //{
            //    LocationCard card = tagsT.Find((item) => item.Id == ctp.LocationCardId);
            //    if (card != null)
            //    {
            //        card.IsActive = true;
            //        tagsTemp.Add(card);
            //    }
            //}
            //LocationCards.EditRange(tagsTemp);

            List <Department> deps = Departments.ToList();

            for (int i = 0; i < maxPersonCount && i < tagsT.Count; i++)
            {
                var tag = tagsT[i];

                int n     = i % 2;
                var post  = posts[r.Next(posts.Count)];
                var dep   = deps[r.Next(deps.Count)];
                int model = r.Next(4);
                if (n == 0)
                {
                    AddPerson(rt.GetWomanName(), Sexs.女, tag, dep, post, i.ToString(), rt.GetRandomTel(), model);
                }
                else
                {
                    AddPerson(rt.GetManName(), Sexs.男, tag, dep, post, i.ToString(), rt.GetRandomTel(), model);
                }
            }
        }
コード例 #3
0
        public void InitDepartments()
        {
            Log.InfoStart(LogTags.DbInit, "InitDepartments");

            bool r1 = LocationCardToPersonnels.Clear();
            bool r2 = LocationCardPositions.Clear();
            bool r3 = Personnels.Clear();
            bool r4 = Departments.Clear();

            Log.Info(LogTags.DbInit, "导入部门信息");
            string filePath = InitPaths.GetBackupDepartmentsInfo();
            bool   value    = DepartmentsBackupHelper.ImportDepartmentInfoFromFile(filePath, _bll);

            Log.Info(LogTags.DbInit, string.Format("导入部门信息结果:{0}", value));

            //Department dep0 = new Department() { Name = "根节点", ShowOrder = 0, Parent = null, Type = DepartType.本厂 };
            //Departments.Add(dep0);
            //Department dep11 = new Department() { Name = "四会电厂", ShowOrder = 0, Parent = dep0, Type = DepartType.本厂 };
            //Departments.Add(dep11);
            //Department dep12 = new Department() { Name = "维修部门", ShowOrder = 0, Parent = dep11, Type = DepartType.本厂 };
            //Departments.Add(dep12);//单个添加可以只是设置Parent
            //Department dep13 = new Department() { Name = "发电部门", ShowOrder = 1, ParentId = dep11.Id, Type = DepartType.本厂 };//批量添加必须设置ParentId
            //Department dep14 = new Department() { Name = "外委人员", ShowOrder = 2, ParentId = dep11.Id, Type = DepartType.本厂 };
            //Department dep15 = new Department() { Name = "访客", ShowOrder = 0, ParentId = dep11.Id, Type = DepartType.本厂 };
            //Department dep16 = new Department() { Name = "未绑定", ShowOrder = 0, ParentId = null, Type = DepartType.本厂 };


            // List<Department> subDeps = new List<Department>() { dep12,dep13, dep14,dep15,dep16};
            // List<Department> subDeps2 = new List<Department>() { dep13, dep14, dep15 };
            // Departments.AddRange(subDeps2);
            //Departments.Add(dep16);

            Posts.Clear();
            Post post1 = new Post()
            {
                Name = "前台"
            };
            Post post2 = new Post()
            {
                Name = "电工"
            };
            Post post3 = new Post()
            {
                Name = "维修工"
            };
            Post post4 = new Post()
            {
                Name = "保安"
            };
            Post post5 = new Post()
            {
                Name = "经理"
            };
            Post post6 = new Post()
            {
                Name = "电工"
            };
            Post post7 = new Post()
            {
                Name = "访客"
            };
            Post post8 = new Post()
            {
                Name = "检修"
            };
            var posts = new List <Post>()
            {
                post1, post2, post3, post4, post5, post6, post7, post8
            };

            Posts.AddRange(posts);
            List <LocationCard> tagsT = LocationCards.ToList();
            RandomTool          rt    = new RandomTool();


            Log.Info(LogTags.DbInit, "导入人员信息");
            var basePath = AppDomain.CurrentDomain.BaseDirectory;

            filePath = InitPaths.GetBackupPersonnelInfo();
            value    = PersonBackupHelper.ImportPersonInfoFromFile(filePath, _bll);
            Log.Info(LogTags.DbInit, string.Format("导入人员信息结果:{0}", value));

            List <Personnel> pList = Personnels.ToList();


            Log.Info(LogTags.DbInit, "开始  导入人员和定位卡关联关系");
            //人员和定位卡关联关系
            filePath = InitPaths.GetPersonAndCard();
            LocationCardToPersonnelsBackupHelper.ImportRelationFromFile(new FileInfo(filePath));
            Log.Info(LogTags.DbInit, "结束 导入人员和定位卡关联关系");
            List <LocationCardToPersonnel> rList = LocationCardToPersonnels.ToList();

            List <LocationCard> tagsTemp = new List <LocationCard>();

            foreach (LocationCardToPersonnel ctp in rList)
            {
                LocationCard card = tagsT.Find((item) => item.Id == ctp.LocationCardId);
                if (card != null)
                {
                    card.IsActive = true;
                    tagsTemp.Add(card);
                }
            }
            LocationCards.EditRange(tagsTemp);
        }