コード例 #1
0
        private string GetWatchDurationString()
        {
            List <WatchTableViewModel> WatchesListDemo = new List <WatchTableViewModel>();
            Watch watch = new Watch();

            if (WatchesList.Count > 0)
            {
                WatchesListDemo = WatchesList.Where(w => w.Watch.PeriodId.Equals(SelectedWatchPeriod) && w.Watch.WatchDate.Equals(SelectedWatchDate)).ToList();
            }
            if (WatchesListDemo.Count > 0)
            {
                watch = WatchesListDemo.FirstOrDefault().Watch;
            }
            if (watch != null)
            {
                return(watch.StartTime.GetValueOrDefault().ToString(@"hh\:mm")
                       + " - "
                       + (watch.StartTime.GetValueOrDefault()
                          + TimeSpan.FromMinutes(Decimal.ToDouble(watch.Duration.GetValueOrDefault()))).ToString(@"hh\:mm"));
            }

            return("");
        }
コード例 #2
0
        public void Initialization()
        {
            WatchDates.Clear();
            PeriodValues.Clear();
            WatchesList.Clear();


            Watches = db.Watches
                      .Include(w => w.Exam)
                      .Include(w => w.WatcherWatches).ThenInclude(ww => ww.Room)
                      .Include(w => w.WatcherWatches).ThenInclude(ww => ww.Watcher)
                      .Where(
                w => w.ExamId == CurrentExamId
                )
                      .OrderByDescending(w => w.WatchDate).ToList();

            SelectedWatch = Watches.FirstOrDefault();

            foreach (DateTime?d in Watches.Select(x => x.WatchDate).Distinct().ToList())
            {
                WatchDates.Add(d);
            }
            foreach (short?p in Watches.Select(x => x.PeriodId).Distinct().ToList())
            {
                PeriodValues.Add(p);
            }
            //WatcherWatchesList = new List<WatcherWatch>();

            WatchTableViewModel row;

            foreach (DateTime date in WatchDates)
            {
                foreach (short p in PeriodValues)
                {
                    foreach (Watch w in Watches)
                    {
                        if (w.PeriodId.Equals(p) && w.WatchDate.Equals(date))
                        {
                            var RoomsWatches =
                                w.WatcherWatches.GroupBy(ww => ww.RoomId)
                                .Select(grp => grp.ToList());

                            foreach (var r in RoomsWatches)
                            {
                                row = new WatchTableViewModel()
                                {
                                    Room  = db.Rooms.Find(r.FirstOrDefault().RoomId),
                                    Watch = w
                                };
                                foreach (var ww in r)
                                {
                                    row.WatcherWatchesList.Add(ww);

                                    if (ww.WatcherType.Equals("1"))
                                    {
                                        row.RoomChiefsList.Add(ww.Watcher.FullName);
                                    }
                                    else if (ww.WatcherType.Equals("2"))
                                    {
                                        row.RoomSecretariesList.Add(ww.Watcher.FullName);
                                    }
                                    else if (ww.WatcherType.Equals("3"))
                                    {
                                        row.RoomWatchersList.Add(ww.Watcher.FullName);
                                    }
                                }

                                row.RoomChiefs      = string.Join(", ", row.RoomChiefsList.ToArray());
                                row.RoomSecretaries = string.Join(", ", row.RoomSecretariesList.ToArray());
                                row.RoomWatchers    = string.Join(", ", row.RoomWatchersList.ToArray());

                                WatchesList.Add(row);
                            }
                        }
                    }
                }
            }
        }