本文整理汇总了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();
}
示例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);
}