public TimeSummaryObservable(TimePeriodType _timePerType, DateTime _date) { switch (_timePerType) { case TimePeriodType._year: break; case TimePeriodType._month: break; case TimePeriodType._week: break; case TimePeriodType._day: DateTime _dtFloor = ServiceMain.DateTimeFloor(_date, TimePeriodType._month); for (DateTime i = _dtFloor; i < _dtFloor.AddMonths(1); i = i.AddDays(1)) { this.Add(new TimeSummary(i, i.AddDays(1))); } break; case TimePeriodType._hour: break; case TimePeriodType._minute: break; case TimePeriodType._second: break; default: break; } }
private void CalcDurationSum(ProblemObservable _problemObs) { foreach (TimeSummary tsum in this) { foreach (Problem prob in _problemObs) { if (tsum.DateStart == ServiceMain.DateTimeFloor(prob.StartDateTime, TimePeriodType._day)) { tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes; } else { if (tsum.DateStart > prob.StartDateTime) { if (prob.Replay) { DateTime _startDateTimeProb = prob.StartDateTime; // каждый день if (prob.ReplayEveryday) { if (prob.EndingNever) { tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes; } if (prob.EndingCount) { // сделать метод умножения TimeSpan DateTime _endDateTimeProb = prob.StartDateTime.Add(TimeSpan.FromTicks(new TimeSpan(1, 0, 0, 0).Ticks *(prob.CountReplays - 1))); if (_endDateTimeProb >= tsum.DateStart) { tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes; } } if (prob.EndingDate) { if (prob.EndDateTime >= tsum.DateStart) { tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes; } } } // каждую неделю if (prob.ReplayEveryweek) { if (prob.EndingNever) { if (prob.DayOfWeekList.Exists(x => x == tsum.DateStart.DayOfWeek)) { tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes; } } if (prob.EndingCount) { for (int i = prob.CountReplays; i > 0;) { if (prob.DayOfWeekList.Exists(x => x == tsum.DateStart.DayOfWeek)) { tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes; i--; } } } if (prob.EndingDate) { if (prob.EndDateTime >= tsum.DateStart) { if (prob.DayOfWeekList.Exists(x => x == tsum.DateStart.DayOfWeek)) { tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes; } } } } // каждый месяц if (prob.ReplayEverymonth) { } // каждый год if (prob.ReplaysEveryyear) { } // другой интервал if (prob.ReplayOther) { } } } } } } }