Beispiel #1
0
        private void UpdateWeekRecords(TagItem tagItem)
        {
            UpdateMonthRecordsByTag(tagItem);

            var weekRecords = new ObservableCollection <WeekRecord>();
            var startDateOfSelectedMonth = SelectedMonth;
            var startDateOfWeek          = new DateTime(startDateOfSelectedMonth.Year, startDateOfSelectedMonth.Month, 1, 0, 0, 0);

            while (startDateOfWeek.Date.DayOfWeek != DayOfWeek.Monday)
            {
                startDateOfWeek = startDateOfWeek.AddDays(-1);
            }

            var startDateOfMonth = startDateOfWeek;

            while (startDateOfMonth.Ticks <= startDateOfSelectedMonth.Ticks)
            {
                var RecordsOfWeek = MonthRecordsByTag.FindAll(r => startDateOfWeek.Ticks < r.DateTime.Ticks && r.DateTime.Ticks <= startDateOfWeek.AddDays(7).Ticks);

                var weekRecord = new WeekRecord()
                {
                    StartDateOfWeek = startDateOfWeek,
                    DayRecords      = RecordsOfWeek
                };

                if (weekRecord.HasRecord)
                {
                    weekRecords.Add(weekRecord);
                }

                startDateOfWeek  = startDateOfWeek.AddDays(7);
                startDateOfMonth = new DateTime(startDateOfWeek.Year, startDateOfWeek.Month, 1, 0, 0, 0);
            }

            // 여기에 태그 관련 리스트 뽑아내게 수정해야 함

            WeekRecords.Clear();

            WeekRecords = weekRecords;

            RefreshRecordChart();

            OnPropertyChanged(nameof(SuccessChart));
            OnPropertyChanged(nameof(HasNoWeekRecords));
        }
Beispiel #2
0
        private void UpdateWeekRecords()
        {
            var weekRecords = new List <WeekRecord>();
            var startDateOfSelectedMonth = SelectedMonth;
            var startDateOfWeek          = new DateTime(startDateOfSelectedMonth.Year, startDateOfSelectedMonth.Month, 1, 0, 0, 0);

            while (startDateOfWeek.Date.DayOfWeek != DayOfWeek.Sunday)
            {
                startDateOfWeek = startDateOfWeek.AddDays(-1);
            }

            var startDateOfMonth = startDateOfWeek;

            while (startDateOfMonth.Ticks <= startDateOfSelectedMonth.Ticks)
            {
                var RecordsOfWeek = Records.FindAll(r => startDateOfWeek.Ticks <= r.RecordTime.Ticks && r.RecordTime.Ticks < startDateOfWeek.AddDays(7).Ticks);

                var weekRecord = new WeekRecord()
                {
                    SelectedMonth   = SelectedMonth.Month,
                    StartDateOfWeek = startDateOfWeek,
                    DayRecords      = RecordsOfWeek.OrderBy(r => r.RecordTime).ToList()
                };

                weekRecords.Add(weekRecord);

                startDateOfWeek = startDateOfWeek.AddDays(7);

                startDateOfMonth = new DateTime(startDateOfWeek.Year, startDateOfWeek.Month, 1, 0, 0, 0);
            }
            ResetSuccessRate();

            WeekRecords.Clear();

            WeekRecords = weekRecords;
            OnPropertyChanged(nameof(WeekRecords));
            OnPropertyChanged(nameof(RoutineNumOfThisMonth));
            OnPropertyChanged(nameof(SuccessRoutineNumOfThisMonth));
        }