当前位置: 首页>>代码示例>>C#>>正文


C# Department.SetParent方法代码示例

本文整理汇总了C#中Department.SetParent方法的典型用法代码示例。如果您正苦于以下问题:C# Department.SetParent方法的具体用法?C# Department.SetParent怎么用?C# Department.SetParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Department的用法示例。


在下文中一共展示了Department.SetParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildUserEntities

        protected static void BuildUserEntities() {
            //
            // Company
            //
            var company = new Company
                          {
                              Name = "리얼웹",
                              Code = CompanyCode
                          };

            Repository<Company>.SaveOrUpdate(company);
            UnitOfWork.Current.TransactionalFlush();

            //
            // Department
            //
            Department parent = null;
            foreach(var code in GetCodes("Dept", 5)) {
                var dept = new Department(company, code)
                           {
                               Name = "부서." + code
                           };

                if(parent != null)
                    dept.SetParent(parent);

                Repository<Department>.SaveOrUpdate(dept);

                parent = dept;
            }
            UnitOfWork.Current.TransactionalFlush();

            //
            // User 
            //
            var i = 0;
            foreach(var code in GetCodes("User", 25)) {
                var user = new User(company, code, code)
                           {
                               Password = Password
                           };

                company.AddUser(user);

                user.Data = "동해물과 백두산이 마르고 닳도록, 하느님이 보우하사 우리나라 만세".Replicate(10);
                user.Blob = Encoding.UTF8.GetBytes(user.Data);

                user.ActivePeriod = (i++ % 2 == 0)
                                        ? new TimeRange(DateTime.Now.AddDays(-1), null)
                                        : new TimeRange(null, DateTime.Now.AddDays(1));

                user.ActiveYearWeek = new YearAndWeek(2009, 1);

                user.PeriodTime = new PeriodTime
                                  {
                                      Period = new MonthRange(DateTime.Now),
                                      //DateTime.Now.GetRelativeMonthRange(1),
                                      YearWeek = new YearAndWeek(2009, 50)
                                  };

                Repository<User>.SaveOrUpdate(user);
            }

            UnitOfWork.Current.TransactionalFlush();

            //
            // DepartmentMember
            //
            var depts = Repository<Department>.FindAll();
            var users = Repository<User>.FindAll();

            foreach(var dept in depts) {
                foreach(var user in users) {
                    var deptMember = new DepartmentMember(dept, user) { IsActive = true };
                    Repository<DepartmentMember>.SaveOrUpdate(deptMember);
                }
            }
            UnitOfWork.Current.TransactionalFlush();
        }
开发者ID:debop,项目名称:NFramework,代码行数:79,代码来源:NHRepositoryTestFixtureBase.cs

示例2: CreateDepartmentOf

        /// <summary>
        /// 지정된 상위 부서 밑으로 부서를 추가합니다. 이때, 상위부서는 null이면 안됩니다. (최상위 부서는 <see cref="GetOrCreateDepartment"/> 메소드를 사용하세요)
        /// </summary>
        public Department CreateDepartmentOf(Department parent, string childCode)
        {
            parent.ShouldNotBeNull("parent");
            childCode.ShouldNotBeWhiteSpace("childCode");

            if(IsDebugEnabled)
                log.Debug("부서[{0}] 하위로 새로운 부서를 추가합니다. 추가할 부서 Id=[{1}] 입니다.", parent.Code, childCode);

            var child = new Department(parent.Company, childCode);

            child.SetParent(parent);
            child.UpdateNodePosition();

            Repository<Department>.SaveOrUpdate(parent);
            return Repository<Department>.SaveOrUpdate(child);
        }
开发者ID:debop,项目名称:NAccess,代码行数:19,代码来源:OrganizationRepository.Department.cs


注:本文中的Department.SetParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。