예제 #1
0
        private void DataProvider_OnUpdateCompleted(object sender, EventArgs e)
        {
            if (!dataProvider.IsUpdateSuccessfull)
            {
                pageChairsRoot.ShowErrorPage();
                return;
            }

            if (isChairPagesCreationCompleted)
            {
                return;
            }

            Logging.ToLog("MainWindow - Создание страниц для кресел");
            if (dataProvider.ChairsDict.Count == 0)
            {
                Logging.ToLog("MainWindow - Отсутствует информация о креслах");
                pageChairsRoot.SetupTitle("Кабинет не выбран");
                return;
            }
            else
            {
                foreach (DataProvider.ItemChair itemChair in dataProvider.ChairsDict.Values)
                {
                    PageChair pageChair = new PageChair(itemChair.ChID, itemChair.RNum, isLiveQueue, dataProvider);

                    Border border = PageChairsRoot.CreateIndicator();
                    if (dataProvider.ChairsDict.Count > 1)
                    {
                        pageChairsRoot.StackPanelPageIndicator.Children.Add(border);
                    }

                    chairPages.Add(pageChair, border);
                }

                if (chairPages.Count > 1)
                {
                    StartChairSwitch();
                }

                NavigateToPage();
            }

            isChairPagesCreationCompleted = true;
        }
예제 #2
0
        private async void TimerUpdateTimetable_Tick(object sender, EventArgs e)
        {
            Logging.ToLog("TimetableHandler - Обновление расписания");
            pageChairsRoot.ClearPageIndicator();
            DataProvider.Timetable timetableInitial = dataProvider.GetTimeTable();

            if (timetableInitial.departments.Count == 0)
            {
                Logging.ToLog("TimetableHandler - не удалось получить информацию о расписании");
                pageChairsRoot.ShowErrorPage();
                return;
            }

            pageChairsRoot.SetupTitle("Расписание работы сотрудников");

            if (!(sender is DispatcherTimer dispatcherTimer))
            {
                return;
            }

            dispatcherTimer.Stop();

            DataProvider.Timetable             timetableToShow = new DataProvider.Timetable();
            Dictionary <PageTimetable, Border> pagesTimetable  = new Dictionary <PageTimetable, Border>();
            int row = 0;

            Logging.ToLog("MainWindow - Создание страниц расписания");
            try {
                foreach (KeyValuePair <string, DataProvider.Timetable.Department> departmentPair in timetableInitial.departments)
                {
                    if (row >= 12)
                    {
                        pagesTimetable.Add(new PageTimetable(timetableToShow), PageChairsRoot.CreateIndicator());
                        row = 0;
                        timetableToShow.departments.Clear();
                    }

                    timetableToShow.departments.Add(departmentPair.Key, new DataProvider.Timetable.Department());
                    row++;

                    foreach (KeyValuePair <string, DataProvider.Timetable.DocInfo> docInfoPair in departmentPair.Value.doctors)
                    {
                        timetableToShow.departments[departmentPair.Key].doctors.Add(docInfoPair.Key, docInfoPair.Value);
                        row++;

                        if (row == 13)
                        {
                            pagesTimetable.Add(new PageTimetable(timetableToShow), PageChairsRoot.CreateIndicator());
                            row = 0;
                            timetableToShow.departments.Clear();

                            if (!docInfoPair.Equals(departmentPair.Value.doctors.Last()))
                            {
                                timetableToShow.departments.Add(departmentPair.Key, new DataProvider.Timetable.Department());
                                row++;
                            }
                        }
                    }
                }
            } catch (Exception exc) {
                Logging.ToLog(exc.Message + Environment.NewLine + exc.StackTrace);
                return;
            }

            if (pagesTimetable.Count > 1)
            {
                foreach (Border border in pagesTimetable.Values)
                {
                    pageChairsRoot.StackPanelPageIndicator.Children.Add(border);
                }
            }

            Logging.ToLog("MainWindow - Отображение страниц расписания");
            int currentPageIndex = 0;

            try {
                foreach (KeyValuePair <PageTimetable, Border> pagePair in pagesTimetable)
                {
                    pagesTimetable.Values.ToList()[currentPageIndex].Background = Brushes.Gray;
                    pagesTimetable.Values.ToList()[currentPageIndex].Height     = 10;

                    pageChairsRoot.FrameMain.Navigate(pagePair.Key);
                    await PutTaskDelay();

                    pagesTimetable.Values.ToList()[currentPageIndex].Background = Brushes.LightGray;
                    pagesTimetable.Values.ToList()[currentPageIndex].Height     = 5;
                    currentPageIndex++;

                    if (currentPageIndex == pagesTimetable.Count)
                    {
                        currentPageIndex = 0;
                    }
                }
            } catch (Exception exc) {
                Logging.ToLog(exc.Message + Environment.NewLine + exc.StackTrace);
            }

            dispatcherTimer.Start();
        }