/// <summary> /// <paramref name="calendar"/>의 Rules 컬렉션에 <paramref name="rule"/>을 추가합니다. /// </summary> /// <param name="calendar"></param> /// <param name="rule"></param> public void AddCalendarRule(Calendar calendar, CalendarRule rule) { calendar.ShouldNotBeNull("calendar"); rule.ShouldNotBeNull("rule"); rule.Calendar = calendar; if(calendar.Rules.Contains(rule) == false) calendar.Rules.Add(rule); Session.SaveOrUpdate(calendar); Session.SaveOrUpdate(rule); }
/// <summary> /// 특정 날짜를 공휴일로 지정하는 룰을 만듭니다. /// </summary> /// <param name="calendar"></param> /// <param name="holyday"></param> /// <returns></returns> public CalendarRule CreateHolyDayCalendarRule(Calendar calendar, DateTime holyday) { calendar.ShouldNotBeNull("calendar"); if(log.IsDebugEnabled) log.Debug(@"Calendar[{0}] 에 공휴일에 대한 Rule을 추가합니다 공휴일=[{1}]", calendar.Code, holyday); var rule = new CalendarRule(calendar, "Holyday"); rule.RulePeriod.Setup(holyday.StartTimeOfDay(), holyday.EndTimeOfDay()); rule.DayOrException = 0; rule.IsWorking = 0; rule.ViewOrder = rule.DayOrException; calendar.Rules.Add(rule); Session.SaveOrUpdate(rule); return rule; }
/// <summary> /// 특정 Calendar에 CalendarRule을 새로 만든다. /// </summary> /// <param name="calendar"></param> /// <param name="name"></param> /// <param name="dayOfWeek"></param> /// <param name="isWorking"></param> /// <param name="timePeriod"></param> /// <returns></returns> public CalendarRule CreateCalendarRule(Calendar calendar, string name, DayOfWeek dayOfWeek, int? isWorking, ITimePeriod timePeriod) { calendar.ShouldNotBeNull("calendar"); if(log.IsDebugEnabled) log.Debug(@"새로운 CalendarRule (Working Time 규칙)을 생성합니다... " + @"calendar={0}, name={1}, dayOfWeek={2}, isWorking={3}, timePeriod={4}", calendar, name, dayOfWeek, isWorking, timePeriod); var rule = new CalendarRule(calendar, name); if(timePeriod != null && timePeriod.IsAnytime == false) rule.RulePeriod.Setup(timePeriod.StartAsNullable, timePeriod.EndAsNullable); rule.DayOrException = dayOfWeek.GetHashCode() + 1; rule.IsWorking = isWorking; calendar.Rules.Add(rule); Session.SaveOrUpdate(calendar); return Repository<CalendarRule>.SaveOrUpdate(rule); }
/// <summary> /// 특정 Calendar에 CalendarRule을 새로 만든다. /// </summary> /// <param name="calendar">규칙이 적용될 <see cref="Calendar"/></param> /// <param name="name">규칙 명</param> /// <returns></returns> public CalendarRule CreateCalendarRule(Calendar calendar, string name) { calendar.ShouldNotBeNull("calendar"); name.ShouldNotBeWhiteSpace("name"); if(log.IsDebugEnabled) log.Debug(@"새로운 CalendarRule (Working Time 규칙)을 생성합니다. calendar={0}, name={1}", calendar, name); var calendarRule = new CalendarRule(calendar, name); calendar.Rules.Add(calendarRule); Session.SaveOrUpdate(calendar); return Repository<CalendarRule>.SaveOrUpdate(calendarRule); }
/// <summary> /// 지정된 Calendar에 속한 모든 Calendar Rule을 삭제합니다. /// </summary> /// <param name="calendar"></param> public void ClearCalendarRulesOf(Calendar calendar) { calendar.ShouldNotBeNull("calendar"); if(log.IsDebugEnabled) log.Debug(@"Calendar의 모든 규칙 정보(CalendarRule)를 삭제합니다... " + calendar); // 안해도 cascade delete가 된다. //foreach(var rule in calendar.Rules.ToArray()) // Repository<CalendarRule>.Delete(rule); calendar.Rules.Clear(); Repository<Calendar>.SaveOrUpdate(calendar); }
/// <summary> /// ������ ��¥�� WorkTimeByDay ������ �ε��մϴ�. /// </summary> /// <param name="calendar">DayCalendar�� ���� Calendar ����</param> /// <param name="workDay">�˻��� ��¥</param> /// <returns></returns> public WorkTimeByDay FindOneWorkTimeByDayByWorkDay(Calendar calendar, DateTime workDay) { calendar.ShouldNotBeNull("calendar"); if(log.IsDebugEnabled) log.Debug("Load WorkTimeByDay. calendar={0}, day={1}", calendar, workDay); var query = BuildQueryOverOfWorkTimeByDay(calendar.Code, workDay); return Repository<WorkTimeByDay>.FindOne(query); }