/// <summary> /// 사용자 로그인 이력을 조회하기 위한 Criteria를 빌드합니다. /// </summary> /// <param name="productCode">제품 코드</param> /// <param name="companyCode">회사 코드</param> /// <param name="loginId">로그인 ID (사용자 코드가 아니다)</param> /// <param name="localeKey">지역화 정보 (<see cref="CultureInfo.Name"/>)</param> /// <param name="loginTimePeriod">로그인 시간의 검색 범위</param> /// <returns></returns> public QueryOver<UserLoginLog, UserLoginLog> BuildQueryOverOfUserLoginLog(string productCode, string companyCode = null, string loginId = null, string localeKey = null, ITimePeriod loginTimePeriod = null) { if(log.IsDebugEnabled) log.Debug(@"사용자 로그인 이력을 조회하기 위한 Criteria를 빌드합니다... " + @"productCode={0}, companyCode={1}, loginId={2}, localeKey={3}, loginTimePeriod={4}", productCode, companyCode, loginId, localeKey, loginTimePeriod); var query = QueryOver.Of<UserLoginLog>(); if(productCode.IsNotWhiteSpace()) query.AddWhere(ulog => ulog.ProductCode == productCode); if(companyCode.IsNotWhiteSpace()) query.AddWhere(ulog => ulog.CompanyCode == companyCode); if(loginId.IsNotWhiteSpace()) query.AddWhere(ulog => ulog.LoginId == loginId); if(localeKey.IsNotWhiteSpace()) query.AddWhere(ulog => ulog.LocaleKey == localeKey); if(loginTimePeriod != null && loginTimePeriod.IsAnytime == false) query.AddBetween(ulog => ulog.LoginTime, loginTimePeriod.StartAsNullable, loginTimePeriod.EndAsNullable); return query; }
/// <summary> /// <see cref="WorkTimeByDay"/> ������ ��ȸ�ϱ� ���� Criteria�� ����մϴ�. /// </summary> /// <param name="calendarCode"></param> /// <param name="workDay"></param> /// <param name="workPeriod"></param> /// <param name="isWork"></param> /// <returns></returns> public QueryOver<WorkTimeByDay, WorkTimeByDay> BuildQueryOverOfWorkTimeByDay(string calendarCode, DateTime? workDay = null, ITimePeriod workPeriod = null, bool? isWork = null) { if(log.IsDebugEnabled) log.Debug(@"WorkTimeByDay ������ ��ȸ�ϱ� ���� Criteria�� ����մϴ�... " + @"calendarCode={0}, workDay={1}, workRange={2}, isWork={3}", calendarCode, workDay, workPeriod, isWork); var query = QueryOver.Of<WorkTimeByDay>(); if(calendarCode.IsNotWhiteSpace()) query.AddWhere(wt => wt.CalendarCode == calendarCode); if(workDay.HasValue) query.AddWhere(wt => wt.WorkDay == workDay); if(workPeriod.IsAnytime == false) query.AddBetween(wt => wt.WorkDay, workPeriod.StartAsNullable, workPeriod.EndAsNullable); if(isWork.HasValue) query.AddNullAsTrue(wt => wt.IsWork, isWork.Value); return query; }
/// <summary> /// 즐겨찾기를 위한 질의 객체 (<see cref="DetachedCriteria"/>)를 빌드합니다. /// </summary> /// <param name="product">지정된 제품, null이면 검색조건에서 제외합니다.</param> /// <param name="company">지정된 회사, null이면 검색조건에서 제외합니다.</param> /// <param name="ownerCode">소유자 코드, null이면 검색조건에서 제외합니다.</param> /// <param name="ownerKind">소유자 종류, <see cref="ActorKinds.Unknown"/>이면 검색조건에서 제외합니다.</param> /// <param name="registerCode">등록자 코드</param> /// <param name="registTimeRange">등록일 검색 범위</param> /// <returns></returns> public virtual QueryOver<Favorite, Favorite> BuildQueryOverOfFavorite(Product product, Company company, string ownerCode, ActorKinds? ownerKind = null, string registerCode = null, ITimePeriod registTimeRange = null) { if(IsDebugEnabled) log.Debug(@"즐겨찾기 조회를 위한 QueryOver를 생성합니다... " + @"company={0}, product={1}, ownerCode={2}, ownerKind={3}, registerCode={4}, registTimeRange={5}", company, product, ownerCode, ownerKind, registerCode, registTimeRange); var query = QueryOver.Of<Favorite>(); if(product != null) query.AddWhere(f => f.ProductCode == product.Code); if(company != null) query.AddWhere(f => f.CompanyCode == company.Code); if(ownerCode.IsNotWhiteSpace()) query.AddWhere(f => f.OwnerCode == ownerCode); if(ownerKind.HasValue) query.AddWhere(f => f.OwnerKind == ownerKind.Value); if(registerCode.IsNotWhiteSpace()) query.AddWhere(f => f.RegisterCode == registerCode); if(registTimeRange != null && registTimeRange.IsAnytime == false) query.AddBetween(f => f.RegistDate, registTimeRange.StartAsNullable, registTimeRange.EndAsNullable); return query; }
/// <summary> /// Creates a new call /// </summary> /// <param name="number"></param> /// <param name="period"></param> /// <param name="action"></param> public Call(Phone.Number number, ITimePeriod period, Action action) { this.Number = number; this.Period = period; _result = action; }
/// <summary> /// <see cref="WorkTimeByDay"/> ������ ��ȸ�ϱ� ���� Criteria�� ����մϴ�. /// </summary> /// <param name="calendarCode"></param> /// <param name="workDay"></param> /// <param name="workPeriod"></param> /// <param name="isWork"></param> /// <returns></returns> public DetachedCriteria BuildCriteriaOfWorkTimeByDay(string calendarCode, DateTime? workDay = null, ITimePeriod workPeriod = null, bool? isWork = null) { return BuildQueryOverOfWorkTimeByDay(calendarCode, workDay, workPeriod, isWork).DetachedCriteria; }
/// <summary> /// 대상 TimePeriod와 기간이 겹치는 TimePeriod 요소가 존재하는가? /// </summary> /// <param name="target"></param> /// <returns></returns> public virtual bool HasOverlapPeriods(ITimePeriod target) { var result = _periods.Any(p => target.OverlapsWith(p)); if(IsDebugEnabled) log.Debug("target[{0}]과 기간이 겹치는 요소가 존재하는가? [{1}]", target, result); return result; }
/// <summary> /// 사용자 로그인 이력을 조회하기 위한 Criteria를 빌드합니다. /// </summary> /// <param name="productCode">제품 코드</param> /// <param name="companyCode">회사 코드</param> /// <param name="loginId">로그인 ID (사용자 코드가 아니다)</param> /// <param name="localeKey">지역화 정보 (<see cref="CultureInfo.Name"/>)</param> /// <param name="loginTimePeriod">로그인 시간의 검색 범위</param> /// <returns></returns> public DetachedCriteria BuildCriteriaOfUserLoginLog(string productCode, string companyCode = null, string loginId = null, string localeKey = null, ITimePeriod loginTimePeriod = null) { return BuildQueryOverOfUserLoginLog(productCode, companyCode, loginId, localeKey, loginTimePeriod).DetachedCriteria; }
/// <summary> /// 대상 TimePeriod 를 포함하는 TimePeriod 요소가 존재하는가? /// </summary> /// <param name="target"></param> /// <returns></returns> public virtual bool HasInsidePeriods(ITimePeriod target) { var result = _periods.Any(p => target.HasInside(p)); if(IsDebugEnabled) log.Debug("target[{0}]을 포함하는 요소가 존재하는가? [{1}]", target, result); return result; }
/// <summary> /// <paramref name="target"/> 기간과 기간이 교차하는 TimePeriod 요소가 존재하는가? /// </summary> /// <param name="target"></param> /// <returns></returns> public virtual bool HasIntersectionPeriods(ITimePeriod target) { var result = _periods.Any(p => target.IntersectsWith(p)); if(IsDebugEnabled) log.Debug("target[{0}]과 기간이 교차하는 요소가 존재하는가? [{1}]", target, result); return result; }
// ---------------------------------------------------------------------- public void Add( ITimePeriod period ) { if ( period == null ) { throw new ArgumentNullException( "period" ); } AddPeriod( period.Start, period ); AddPeriod( period.End, period ); Sort(); }
// ---------------------------------------------------------------------- public TimeRange( ITimePeriod copy ) { if ( copy == null ) { throw new ArgumentNullException( "copy" ); } start = copy.Start; end = copy.End; isReadOnly = copy.IsReadOnly; }
/// <summary> /// 생성자 /// </summary> /// <param name="calendar"></param> /// <param name="timeRange"></param> /// <param name="previousCumulatedWorkInMinute"></param> public WorkTimeByRange(Calendar calendar, ITimePeriod timeRange, int previousCumulatedWorkInMinute) : base(calendar, timeRange.Start) { timeRange.ShouldNotBeNull("timeRange"); Guard.Assert(timeRange.HasPeriod, @"timeRange는 명시적인 구간을 가져야 합니다."); TimePeriod.Setup(timeRange.Start, timeRange.End); CumulatedInMinute = previousCumulatedWorkInMinute + WorkInMinute; }
public TimeInterval(ITimePeriod src) : base(src) { src.ShouldNotBeNull("src"); var interval = src as ITimeInterval; if(interval != null) { _start = interval.StartInterval; _end = interval.EndInterval; _startEdge = interval.StartEdge; _endEdge = interval.EndEdge; _isIntervalEnabled = interval.IsIntervalEnabled; } }
// ---------------------------------------------------------------------- protected override bool EvaluatePeriod( ITimePeriod period, int periodCount ) { TimeSpan allPeriodDuration = new TimeSpan( period.Duration.Ticks * periodCount ); if ( allPeriodDuration >= remainingDuration ) { targetMoment = period.Start.Add( new TimeSpan( remainingDuration.Ticks / periodCount ) ); return false; } remainingDuration = remainingDuration.Subtract( allPeriodDuration ); return true; }
/// <summary> /// <paramref name="period"/>가 <paramref name="target"/>과의 시간 축으로 선 후행 관계를 판단합니다. /// </summary> /// <param name="period"></param> /// <param name="target"></param> /// <returns></returns> public static PeriodRelation GetReleation(this ITimePeriod period, ITimePeriod target) { period.ShouldNotBeNull("period"); target.ShouldNotBeNull("target"); var relation = PeriodRelation.NoRelation; if(period.Start > target.End) { relation = PeriodRelation.After; } else if(period.End < target.Start) { relation = PeriodRelation.Before; } else if(period.Start == target.Start && period.End == target.End) { relation = PeriodRelation.ExactMatch; } else if(period.Start == target.End) { relation = PeriodRelation.StartTouching; } else if(period.End == target.Start) { relation = PeriodRelation.EndTouching; } else if(HasInside(period, target)) { if(period.Start == target.Start) relation = PeriodRelation.EnclosingStartTouching; else relation = (period.End == target.End) ? PeriodRelation.EnclosingEndTouching : PeriodRelation.Enclosing; } // 기간이 대상 기간 내부에 속할 때 else { var insideStart = HasInside(target, period.Start); var insideEnd = HasInside(target, period.End); if(insideStart && insideEnd) { relation = Equals(period.Start, target.Start) ? PeriodRelation.InsideStartTouching : period.End == target.End ? PeriodRelation.InsideEndTouching : PeriodRelation.Inside; } else if(insideStart) relation = PeriodRelation.StartInside; else if(insideEnd) relation = PeriodRelation.EndInside; } if(IsDebugEnabled) log.Debug("period[{0}]와 target[{1}] 간의 Relation은 [{2}] 입니다.", period.AsString(), target.AsString(), relation); return relation; }
// ---------------------------------------------------------------------- public static PeriodRelation GetRelation( ITimePeriod period, ITimePeriod test ) { if ( test.End < period.Start ) { return PeriodRelation.After; } if ( test.Start > period.End ) { return PeriodRelation.Before; } if ( test.Start == period.Start && test.End == period.End ) { return PeriodRelation.ExactMatch; } if ( test.End == period.Start ) { return PeriodRelation.StartTouching; } if ( test.Start == period.End ) { return PeriodRelation.EndTouching; } if ( HasInside( period, test ) ) { if ( test.Start == period.Start ) { return PeriodRelation.EnclosingStartTouching; } return test.End == period.End ? PeriodRelation.EnclosingEndTouching : PeriodRelation.Enclosing; } bool periodContainsMyStart = HasInside( test, period.Start ); bool periodContainsMyEnd = HasInside( test, period.End ); if ( periodContainsMyStart && periodContainsMyEnd ) { if ( test.Start == period.Start ) { return PeriodRelation.InsideStartTouching; } return test.End == period.End ? PeriodRelation.InsideEndTouching : PeriodRelation.Inside; } if ( periodContainsMyStart ) { return PeriodRelation.StartInside; } if ( periodContainsMyEnd ) { return PeriodRelation.EndInside; } throw new InvalidOperationException( "invalid period relation of '" + period + "' and '" + test + "'" ); }
/// <summary> /// Initializes a new instance of the <see cref="TimeOfDayChangedEventArgs"/> class. /// </summary> /// <param name="transitionFrom">The time period being transitioned from.</param> /// <param name="transitionTo">The time period being transition to.</param> public TimeOfDayChangedEventArgs(ITimePeriod transitionFrom, ITimePeriod transitionTo) { if (transitionTo == null) { throw new ArgumentNullException(nameof(transitionTo), "A state must be provided to transition to."); } else if (transitionFrom == null) { throw new ArgumentNullException(nameof(transitionFrom), "A state must be provided to transition from."); } this.TransitioningFrom = transitionFrom; this.TransitioningTo = transitionTo; }
} // RemoveStart // ---------------------------------------------------------------------- protected virtual void RemoveEnd(DateTime moment, ITimePeriod period) { ITimeLineMoment timeLineMoment = Find(moment); if (timeLineMoment == null) { throw new InvalidOperationException(); } timeLineMoment.RemoveEnd(); if (timeLineMoment.IsEmpty) { timeLineMoments.Remove(moment); } } // RemoveEnd
public TimeInterval(ITimePeriod src) : base(src) { src.ShouldNotBeNull("src"); var interval = src as ITimeInterval; if (interval != null) { _start = interval.StartInterval; _end = interval.EndInterval; _startEdge = interval.StartEdge; _endEdge = interval.EndEdge; _isIntervalEnabled = interval.IsIntervalEnabled; } }
public static ITimePeriodCollection Split(this ITimePeriod timePeriod, TimeSpan duration) { if (timePeriod.Duration <= duration) { return(new TimePeriodCollection(new List <ITimePeriod> { timePeriod })); } var result = new List <ITimePeriod> { new TimeRange(timePeriod.Start, duration) }; result.AddRange(new TimeRange(timePeriod.Start.Add(duration), timePeriod.End).Split(duration)); return(new TimePeriodCollection(result)); }
} // IntersectsWith // ---------------------------------------------------------------------- public virtual ITimeBlock GetIntersection(ITimePeriod period) { CommonMethods.checkNull(period, "period @ GetIntersection"); if (!IntersectsWith(period)) { return(null); } DateTime periodStart = period.Start; DateTime periodEnd = period.End; return(new TimeBlock( periodStart.Ticks > start.Ticks ? periodStart : start, periodEnd.Ticks < end.Ticks ? periodEnd : end, IsReadOnly)); } // GetIntersection
} // AddPeriod // ---------------------------------------------------------------------- private void RemovePeriod(DateTime moment, ITimePeriod period) { ITimeLineMoment timeLineMoment = Find(moment); if (timeLineMoment == null || !timeLineMoment.Periods.Contains(period)) { throw new InvalidOperationException(); } timeLineMoment.Periods.Remove(period); if (timeLineMoment.Periods.Count == 0) { timeLineMoments.Remove(timeLineMoment); } } // RemovePeriod
public void CopyToTest() { DateTime now = ClockProxy.Clock.Now; SchoolDay schoolDay = new SchoolDay(now); TimePeriodCollection timePeriods = new TimePeriodCollection(schoolDay); ITimePeriod[] array = new ITimePeriod[schoolDay.Count]; timePeriods.CopyTo(array, 0); Assert.Equal(array[0], schoolDay.Lesson1); Assert.Equal(array[1], schoolDay.Break1); Assert.Equal(array[2], schoolDay.Lesson2); Assert.Equal(array[3], schoolDay.Break2); Assert.Equal(array[4], schoolDay.Lesson3); Assert.Equal(array[5], schoolDay.Break3); Assert.Equal(array[6], schoolDay.Lesson4); } // CopyToTest
private IEnumerable <IDayAssign> GetByDateCriteria(ITimePeriod period, IChartDataQueryingRestrictions restrictions) { var result = Enumerable.Empty <IDayAssign>(); if (restrictions.CurrentMemberRole == RoleType.Coordinator) { var allowedHousingDepartments = restrictions.AccessibleManagementToHousingDepartmentsRelation.SelectMany(pair => pair.Value); result = dayAssignService.GetForStatisticTimeSpan(period.StartDate, period.EndDate, restrictions.AllowedStatuses, allowedHousingDepartments); } else { result = dayAssignService.GetForStatisticTimeSpan(period.StartDate, period.EndDate, restrictions.AllowedStatuses); } return(result); }
private IChartData <ITaskChartModel> GetSpentTimeChartData(ITimePeriod period, string allowedStatusesConfigKey, string spentTimeChartTypesConfigKey, bool showLastCompletedOrCanceledStatus, QueryingAlgorithmType queryingAlgorithm, IDictionary <Guid, int> categorySortPriority) { var queryingRestrictions = GetUserFilteringCriterias(); queryingRestrictions.AllowedStatuses = GetAllowedStatuses(allowedStatusesConfigKey); queryingRestrictions.ShowLastCompletedOrCanceledStatus = showLastCompletedOrCanceledStatus; queryingRestrictions.QueryingAlgorithm = queryingAlgorithm; var chartConfig = new SpentTimeChartConfig { TaskTypesToInclude = GetTaskTypes(spentTimeChartTypesConfigKey) }; var chartModel = spentTimeChartDataBuilder.Build(queryingRestrictions, chartConfig, period, categorySortPriority); return(chartModel); }
} // Add // ---------------------------------------------------------------------- public bool ContainsPeriod(ITimePeriod test) { if (test == null) { throw new ArgumentNullException("test"); } foreach (ITimePeriod period in periods) { if (period.IsSamePeriod(test)) { return(true); } } return(false); } // ContainsPeriod
public static DateTime?GetFirstDayMatch(this ITimePeriod timePeriod, DayOfWeek dayOfWeek) { var workingDate = timePeriod.FirstDay.Date; while (workingDate <= timePeriod.LastDay) { if (workingDate.DayOfWeek == dayOfWeek) { return(workingDate); } workingDate = workingDate.AddDays(1); } return(null); }
/// <summary> /// 새로운 <paramref name="item"/>을 Chain의 제일 끝에 붙여 넣습니다. <paramref name="item"/>의 기간이 변경됩니다. /// </summary> /// <param name="item"></param> public override void Add(ITimePeriod item) { item.ShouldNotBeNull("item"); item.AssertMutable(); ITimePeriod last = Last; if(last != null) { AssertSpaceAfter(last.End, item.Duration); item.Setup(last.End, last.End.Add(item.Duration)); } if(IsDebugEnabled) log.Debug("Period를 Chain의 끝에 추가합니다. item=[{0}]", item); _periods.Add(item); }
/// <summary> /// 두 기간 교차하거나, <paramref name="period"/>가 <paramref name="target"/> 의 내부 구간이면 true를 반환합니다. /// </summary> /// <param name="period"></param> /// <param name="target"></param> /// <returns></returns> public static bool IntersectsWith(this ITimePeriod period, ITimePeriod target) { target.ShouldNotBeNull("target"); var isIntersected = period.HasInside(target.Start) || period.HasInside(target.End) || (target.Start <period.Start && target.End> period.End); if (IsDebugEnabled) { log.Debug("period[{0}]와 target[{1}]이 교차 구간이 있는지 확인합니다. isIntersected=[{2}]", period.AsString(), target.AsString(), isIntersected); } return(isIntersected); }
/// <summary> /// 두 기간의 겹치는 기간을 반환합니다. /// </summary> /// <param name="other"></param> /// <returns></returns> public new ITimeInterval GetIntersection(ITimePeriod other) { var range = base.GetIntersection(other); if (range == null) { return(null); } return(new TimeInterval(range.Start, range.End, IntervalEdge.Closed, IntervalEdge.Closed, IsIntervalEnabled, IsReadOnly)); }
} // FindNextPeriod // ---------------------------------------------------------------------- private static ITimePeriod FindSuccessorPeriod(IList <ITimePeriod> periods, DateTime endOfPrevious) { ITimePeriod current = FindPeriodByEnd(periods, endOfPrevious); if (current == null) { return(null); } int index = periods.IndexOf(current); if (index == periods.Count - 1) { return(null); } return(periods[index + 1]); } // FindSuccessorPeriod
/// <summary> /// 시작시각과 완료시각을 지정된 기간 정보를 기준으로 변경합니다. /// </summary> /// <param name="period"></param> public void ExpandTo(ITimePeriod period) { period.ShouldNotBeNull("period"); AssertMutable(); if (period.HasStart) { ExpandStartTo(period.Start); } if (period.HasEnd) { ExpandEndTo(period.End); } }
/// <summary> /// TimePeriodChain에서 요소 <paramref name="item"/>을 제거합니다. (제거된 후의 후속 Period들의 시간이 조정됩니다) /// </summary> /// <param name="item"></param> /// <returns></returns> public override bool Remove(ITimePeriod item) { item.ShouldNotBeNull("item"); if (Count <= 0) { return(false); } if (IsDebugEnabled) { log.Debug("요소[{0}] 를 제거하려고 합니다...", item); } var itemDuration = item.Duration; var index = IndexOf(item); ITimePeriod next = null; if (itemDuration > TimeSpan.Zero && index > 0 && index < Count - 1) { next = this[index]; } var removed = _periods.Remove(item); if (removed && next != null) { if (IsDebugEnabled) { log.Debug("요소[{0}]를 제거하고, Chain의 후속 Period 들의 기간을 조정합니다...", item); } for (int i = index; i < Count; i++) { var start = this[i].Start.Subtract(itemDuration); this[i].Setup(start, start.Add(this[i].Duration)); } } if (IsDebugEnabled) { log.Debug("요소[{0}] 를 제거 결과=[{1}]", item, removed); } return(removed); }
} // IntersectionPeriods // ---------------------------------------------------------------------- public virtual bool HasIntersectionPeriods(ITimePeriod test) { if (test == null) { throw new ArgumentNullException("test"); } foreach (ITimePeriod period in periods) { if (period.IntersectsWith(test)) { return(true); } } return(false); } // HasIntersectionPeriods
public bool IntersectsWith(ITimePeriod test) { if (test == null) { throw new ArgumentNullException("test"); } foreach (var period in _timePeriodCollection) { if (period.IntersectsWith(test)) { return(true); } } return(false); }
} // HasGaps // ---------------------------------------------------------------------- public virtual bool HasOverlapPeriods(ITimePeriod test) { if (test == null) { throw new ArgumentNullException("test"); } foreach (ITimePeriod period in periods) { if (test.OverlapsWith(period)) { return(true); } } return(false); } // HasOverlapPeriods
//[TestMethod] public void TestTaskGraphAdjustments() { Activity campaign = null, batch1 = null; Activity[] units = new Activity[2]; Activity[][] opSteps = new Activity[][] { new Activity[3], new Activity[3] }; double[][] durations = new double[][] { new double[] { 30.0, 20.0, 10.0 }, new double[] { 20.0, 30.0, 40.0 } }; ConstructSchedule(ref campaign, ref batch1, ref units, ref opSteps, durations); ITimePeriod tpOp1A = opSteps[0][0].GetTimePeriodAspect(KEY1); ITimePeriod tpOp1B = opSteps[0][1].GetTimePeriodAspect(KEY1); ITimePeriod tpOp1C = opSteps[0][2].GetTimePeriodAspect(KEY1); ITimePeriod tpOp2A = opSteps[1][0].GetTimePeriodAspect(KEY1); ITimePeriod tpOp2B = opSteps[1][1].GetTimePeriodAspect(KEY1); ITimePeriod tpOp2C = opSteps[1][2].GetTimePeriodAspect(KEY1); if (tpOp1B.StartTime < tpOp2B.StartTime) { tpOp1B.StartTime = tpOp2B.StartTime; } if (tpOp2B.StartTime < tpOp1B.StartTime) { tpOp2B.StartTime = tpOp1B.StartTime; } tpOp1B.AddRelationship(TimePeriod.Relationship.StartsOnStartOf, tpOp2B); tpOp2B.AddRelationship(TimePeriod.Relationship.StartsOnStartOf, tpOp1B); if (tpOp1C.StartTime < tpOp2C.StartTime) { tpOp1C.StartTime = tpOp2C.StartTime; } if (tpOp2C.StartTime < tpOp1C.StartTime) { tpOp2C.StartTime = tpOp1C.StartTime; } tpOp1C.AddRelationship(TimePeriod.Relationship.StartsOnStartOf, tpOp2C); tpOp2C.AddRelationship(TimePeriod.Relationship.StartsOnStartOf, tpOp1C); Dump(campaign); }
public bool IsOnTimeLine(ITimePeriod test) { if (test == null) { throw new ArgumentNullException("test"); } foreach (var period in _timePeriodCollection) { if (period.HasInside(test)) { return(true); } } return(false); }
// ------------------------------------------------------------------------ protected CalendarVisitor(TFilter filter, ITimePeriod limits, SeekDirection seekDirection = SeekDirection.Forward, ITimeCalendar calendar = null) { if (filter == null) { throw new ArgumentNullException("filter"); } if (limits == null) { throw new ArgumentNullException("limits"); } this.filter = filter; this.limits = limits; this.seekDirection = seekDirection; this.calendar = calendar; } // CalendarVisitor
/// <summary> /// 지정된 기간을 <paramref name="mapper"/>를 통해 매핑한 기간으로 반환합니다. /// </summary> /// <param name="period"></param> /// <param name="mapper"></param> /// <returns></returns> private static TimeRange ToCalendarTimeRange(ITimePeriod period, ITimePeriodMapper mapper) { period.ShouldNotBeNull("period"); mapper = mapper ?? new TimeCalendar(); var mappedStart = mapper.MapStart(period.Start); var mappedEnd = mapper.MapEnd(period.End); TimeTool.AssertValidPeriod(mappedStart, mappedEnd); var mapped = new TimeRange(mappedStart, mappedEnd); if (IsDebugEnabled) { log.Debug("TimeCalendar 기준의 기간으로 매핑했습니다. period=[{0}], mapped=[{1}]", period, mapped); } return(mapped); }
private void playFromUrl(IUrl ui) { if (ui is ITimePeriod) { ITimePeriod tp = ui as ITimePeriod; playCtrl.ViewModel.UpdateTimePeriod(tp.BeginTime, tp.EndTime); } //更新数据源。 VideoInfoManager.Instance.UpdateSource(ui); int sourceIndex = VideoInfoManager.Instance.SourceIndex; UrlAndIndex uai = new UrlAndIndex(ui, sourceIndex); new Thread(initPlay) { IsBackground = true, Name = "InitPlayVideos" }.Start(uai); }
} // Move // ---------------------------------------------------------------------- public virtual void Add(ITimePeriod item) { if (item == null) { throw new ArgumentNullException("item"); } CheckReadOnlyItem(item); ITimePeriod last = Last; if (last != null) { CheckSpaceAfter(last.End, item.Duration); item.Setup(last.End, last.End.Add(item.Duration)); } periods.Add(item); } // Add
private IEnumerable <IDayAssign> GetByCompletionDateCriteria(ITimePeriod period, IChartDataQueryingRestrictions restrictions) { var dayAssigns = Enumerable.Empty <IDayAssign>(); List <Guid> dayAssignIdList = jobStatusLogService.GetDayAssignIds(period.StartDate, period.EndDate, restrictions.AllowedStatuses).ToList(); if (restrictions.CurrentMemberRole == RoleType.Coordinator) { IEnumerable <Guid> allowedHousingDepartments = restrictions.AccessibleManagementToHousingDepartmentsRelation.SelectMany(pair => pair.Value); dayAssigns = dayAssignService.GetForStatisticByIdsWithRestrictions(dayAssignIdList, allowedHousingDepartments); } else { dayAssigns = dayAssignService.GetForStatisticByIdsWithRestrictions(dayAssignIdList); } return(dayAssigns); }
/// <summary> /// Roughly converts a date period with a time period into one period /// </summary> /// <param name="datePeriod"></param> /// <param name="timePeriod"></param> /// <returns></returns> private ITimePeriod TransformDateTimeComponents(ITimePeriod datePeriod, ITimePeriod timePeriod) { var pointInTime = datePeriod.Start.Add(timePeriod.Start.TimeOfDay); if (timePeriod.HasStart && timePeriod.HasEnd) { return(new Minute(pointInTime)); } else if (timePeriod.HasStart) { return(new TimeRange(pointInTime, new Day(pointInTime).End)); } else if (timePeriod.HasEnd) { return(new TimeRange(pointInTime, timePeriod.End.TimeOfDay)); } return(datePeriod); }
// ---------------------------------------------------------------------- public int Compare(ITimePeriod left, ITimePeriod right) { ITimeInterval leftInterval = left as ITimeInterval; ITimeInterval rightInterval = right as ITimeInterval; int compare; if (leftInterval != null && rightInterval != null) { compare = leftInterval.StartInterval.CompareTo(leftInterval.EndInterval); } else { compare = left.CompareTo(right, TimePeriodStartComparer.Comparer); // compare by start //compare = left.CompareTo( right, TimePeriodDurationComparer.Comparer ); // compare by duration } return(compare); } // Compare
public void CopyToTest() { var now = ClockProxy.Clock.Now; var schoolDay = new SchoolDay(now); var timePeriods = new TimePeriodCollection(schoolDay); var array = new ITimePeriod[schoolDay.Count]; timePeriods.CopyTo(array, 0); array[0].Should().Be(schoolDay.Lesson1); array[1].Should().Be(schoolDay.Break1); array[2].Should().Be(schoolDay.Lesson2); array[3].Should().Be(schoolDay.Break2); array[4].Should().Be(schoolDay.Lesson3); array[5].Should().Be(schoolDay.Break3); array[6].Should().Be(schoolDay.Lesson4); }
} // IntersectsWith // ---------------------------------------------------------------------- public virtual ITimeRange GetIntersection(ITimePeriod period) { if (period == null) { throw new ArgumentNullException("period"); } if (!IntersectsWith(period)) { return(null); } DateTime periodStart = period.Start; DateTime periodEnd = period.End; return(new TimeRange( periodStart > start ? periodStart : start, periodEnd < end ? periodEnd : end, IsReadOnly)); } // GetIntersection
} // TimeGapCalculator // ---------------------------------------------------------------------- private ICalendarTimeRange FindLargestFreeTimeBlock(IEnumerable <ITimePeriod> reservations, ITimePeriod searchLimits = null, bool excludeWeekends = true) { TimePeriodCollection bookedPeriods = new TimePeriodCollection(reservations); if (searchLimits == null) { searchLimits = bookedPeriods; // use boundary of reservations } if (excludeWeekends) { Week currentWeek = new Week(searchLimits.Start); Week lastWeek = new Week(searchLimits.End); do { ITimePeriodCollection days = currentWeek.GetDays(); foreach (Day day in days) { if (!searchLimits.HasInside(day)) { continue; // outside of the search scope } if (day.DayOfWeek == DayOfWeek.Saturday || day.DayOfWeek == DayOfWeek.Sunday) { bookedPeriods.Add(day); // // exclude weekend day } } currentWeek = currentWeek.GetNextWeek(); } while (currentWeek.Start < lastWeek.Start); } // calculate the gaps using the time calendar as period mapper TimeGapCalculator <TimeRange> gapCalculator = new TimeGapCalculator <TimeRange>(new TimeCalendar()); ITimePeriodCollection freeTimes = gapCalculator.GetGaps(bookedPeriods, searchLimits); if (freeTimes.Count == 0) { return(null); } freeTimes.SortByDuration(); // move the largest gap to the start return(new CalendarTimeRange(freeTimes[0])); } // FindLargestFreeTimeBlock
/// <summary> /// Ư�� Calendar�� ������ ������ <see cref="WorkTimeByDay"/> ����� �����ɴϴ�. /// </summary> /// <param name="calendarCode">WorkTime ������ ������ �� Calendar�� �ڵ尪 (null�̸� �ȵȴ�)</param> /// <param name="searchPeriod">�˻� �Ⱓ (null�̰ų� �Ⱓ�� ������� ��� �Ⱓ�� �����´�)</param> /// <param name="firstResult">ù��° ��� ���� �ε��� (0���� ����. null�̸� 0���� ����)</param> /// <param name="maxResults">��� ���� �ִ� ���ڵ� �� (null �Ǵ� 0 ������ ���� ���õȴ�)</param> /// <param name="orders">���� ����</param> /// <returns></returns> public IList<WorkTimeByDay> FindAllWorkTimeByDayInRange(string calendarCode, ITimePeriod searchPeriod, int? firstResult, int? maxResults, params INHOrder<WorkTimeByDay>[] orders) { calendarCode.ShouldNotBeWhiteSpace("calendarCode"); if(log.IsDebugEnabled) log.Debug(@"WorkTimeByDay ������ �ε��մϴ�... " + @"calendarCode={0}, searchPeriod={1}, firstResult={2}, maxResults={3}, orders={4}", calendarCode, searchPeriod, firstResult, maxResults, orders); var query = BuildQueryOverOfWorkTimeByDay(calendarCode, null, searchPeriod).AddOrders(orders); return Repository<WorkTimeByDay>.FindAll(query, firstResult.GetValueOrDefault(), maxResults.GetValueOrDefault()); }
/// <summary> /// 기간 단위에 따라 Category를 생성합니다. /// </summary> /// <param name="categoryCollectionList">생성된 <see cref="CategoriesElement"/> 정보가 담길 객체</param> /// <param name="timePeriod">Gantt에 표현할 전체 기간 (프로젝트 전체 기간)</param> /// <param name="periodFlags">Gantt Chart X축에 나타낼 기간 단위 정보</param> public static void GenerateCategories(IList<CategoriesElement> categoryCollectionList, ITimePeriod timePeriod, PeriodFlags periodFlags) { categoryCollectionList.ShouldNotBeNull("categoryCollectionList"); timePeriod.ShouldNotBeNull("periodRange"); Guard.Assert(timePeriod.HasPeriod, "Gantt에 나타낼 전체 기간은 시작과 끝이 있어야합니다."); if(IsDebugEnabled) log.Debug("Gantt의 기간 부분을 생성합니다. timePeriod=[{0}], periodFlags=[{1}]", timePeriod, periodFlags); categoryCollectionList.Clear(); if((periodFlags & PeriodFlags.Year) > 0) categoryCollectionList.Add(CreateCategories(timePeriod.ForEachYears(), range => range.Start.Year.ToString())); if((periodFlags & PeriodFlags.HalfYear) > 0) categoryCollectionList.Add(CreateCategories(timePeriod.ForEachYears(), range => (range.End.HalfyearOf() == HalfyearKind.First) ? "1st" : "2nd")); if((periodFlags & PeriodFlags.Quarter) > 0) categoryCollectionList.Add(CreateCategories(timePeriod.ForEachQuarters(), range => "Q" + range.End.QuarterOf().GetHashCode().ToString())); if((periodFlags & PeriodFlags.Month) > 0) categoryCollectionList.Add(CreateCategories(timePeriod.ForEachMonths(), range => range.End.GetMonthName())); if((periodFlags & PeriodFlags.Week) > 0) categoryCollectionList.Add(CreateCategories(timePeriod.ForEachWeeks(), range => "W" + range.End.GetYearAndWeek().Week.Value.ToString())); if((periodFlags & PeriodFlags.Day) > 0) categoryCollectionList.Add(CreateCategoriesAsParallel(timePeriod.ForEachDays(), range => range.End.Day.ToString())); if((periodFlags & PeriodFlags.Hour) > 0) categoryCollectionList.Add(CreateCategoriesAsParallel(timePeriod.ForEachHours(), range => "H" + range.End.Hour.ToString())); }
// ---------------------------------------------------------------------- public TimeInterval( ITimePeriod copy ) { if ( copy == null ) { throw new ArgumentNullException( "copy" ); } ITimeInterval timeInterval = copy as ITimeInterval; if ( timeInterval != null ) { startInterval = timeInterval.StartInterval; endInterval = timeInterval.EndInterval; startEdge = timeInterval.StartEdge; endEdge = timeInterval.EndEdge; isIntervalEnabled = timeInterval.IsIntervalEnabled; } else { startInterval = copy.Start; endInterval = copy.End; } isReadOnly = copy.IsReadOnly; }
// ---------------------------------------------------------------------- protected YearCalendarTimeRange( ITimePeriod period, ITimeCalendar calendar ) : base(period, calendar) { }
// ---------------------------------------------------------------------- public override bool IsSamePeriod( ITimePeriod test ) { IPlayTimeRange playTimeRange = (IPlayTimeRange)test; return base.IsSamePeriod( playTimeRange ) && direction == playTimeRange.Direction; }
/// <summary> /// Copy Constructor /// </summary> /// <param name="source">복사할 원본 ITimePeriod</param> protected TimePeriodBase(ITimePeriod source) { source.ShouldNotBeNull("source"); _start = source.Start; _end = source.End; IsReadOnly = source.IsReadOnly; }
/// <summary> /// 현재 개체가 동일한 형식의 다른 개체와 같은지 여부를 나타냅니다. (StartTime, EndTime, IsReadOnly가 같아야 True를 반환합니다) /// </summary> /// <returns> /// 현재 개체가 <paramref name="other"/> 매개 변수와 같으면 true이고, 그렇지 않으면 false입니다. /// </returns> /// <param name="other">이 개체와 비교할 개체입니다.</param> public bool Equals(ITimePeriod other) { return (other != null) && GetHashCode().Equals(other.GetHashCode()); }
public int CompareTo(ITimePeriod other) { return Start.CompareTo(other.Start); }
ITimePeriod ITimePeriod.GetUnion(ITimePeriod other) { return GetUnion(other); }
/// <summary> /// 두 기간의 합집합 기간을 반환합니다. /// </summary> /// <param name="other"></param> /// <returns></returns> public virtual TimePeriodBase GetUnion(ITimePeriod other) { other.ShouldNotBeNull("other"); return TimeTool.GetUnionRange(this, other); }
ITimePeriod ITimePeriod.GetIntersection(ITimePeriod other) { return GetIntersection(other); }
/// <summary> /// 다른 TimePeriod와의 관계를 나타냅니다. /// </summary> /// <param name="other"></param> /// <returns></returns> public virtual PeriodRelation GetRelation(ITimePeriod other) { other.ShouldNotBeNull("other"); return TimeTool.GetReleation(this, other); }