Esempio n. 1
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            string configFilePath        = Path.Combine(configPath, "InfoscreenConfig.xml");
            string advertisementFilePath = Path.Combine(configPath, "Advertisement.xml");
            string fullScreenAdPath      = Path.Combine(configPath, "FullScreenAdvertisements");

            Logging.ToLog("App - путь к файлу настроек: " + configFilePath);
            Logging.ToLog("App - путь к файлу информационных сообщений: " + advertisementFilePath);
            Logging.ToLog("App - путь к файлам полноэкранных информационных изображений: " + fullScreenAdPath);

            Configuration configuration = new Configuration();
            Advertisement advertisement = new Advertisement();

            await Task.Run(() => {
                Configuration.LoadConfiguration(configFilePath, out configuration);
            });

            await Task.Run(() => {
                Advertisement.LoadAdvertisement(advertisementFilePath, out advertisement);
            });

            if (configuration.IsSystemWorkAsTimetable() && Debugger.IsAttached)
            {
                WindowState = WindowState.Maximized;
            }

            pageChairsRoot   = new PageChairsRoot(configuration, advertisement);
            fullScreenAdList = FullScreenAd.GetAdItems(fullScreenAdPath, true);

            Logging.ToLog("Список изображений для показа: " + Environment.NewLine +
                          string.Join(Environment.NewLine, fullScreenAdList));

            if (fullScreenAdList.Count > 0)
            {
                secondsRoomStatus   = 30;
                secondsFullscreenAd = 10;
                Random random = new Random();
                currentAdId = random.Next(0, fullScreenAdList.Count - 1);

                if (Debugger.IsAttached)
                {
                    secondsRoomStatus   = 5;
                    secondsFullscreenAd = 5;
                }

                Logging.ToLog("Запуск таймера отображения полноэкранных информационных сообщений");
                Logging.ToLog("Значения длительности отображения в секундах, статус кабинета - " +
                              secondsRoomStatus + ", полноэкранные информационные сообщения - " + secondsFullscreenAd);

                timerMain          = new DispatcherTimer();
                timerMain.Interval = TimeSpan.FromSeconds(random.Next(0, secondsRoomStatus));
                timerMain.Tick    += TimerMain_Tick;
                timerMain.Start();
            }

            FrameMain.Navigate(pageChairsRoot);
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
 public ChairsHandler(DataProvider dataProvider,
                      string chairs,
                      bool isLiveQueue,
                      int chairUpdateIntervalInSeconds,
                      int chairRotateIntervalInSeconds,
                      int photoUpdateIntervalInSeconds,
                      PageChairsRoot pageChairsRoot)
 {
     this.dataProvider   = dataProvider;
     this.chairs         = chairs;
     this.pageChairsRoot = pageChairsRoot;
     this.isLiveQueue    = isLiveQueue;
     this.chairUpdateIntervalInSeconds = chairUpdateIntervalInSeconds;
     this.chairRotateIntervalInSeconds = chairRotateIntervalInSeconds;
     this.photoUpdateIntervalInSeconds = photoUpdateIntervalInSeconds;
     isChairPagesCreationCompleted     = false;
     chairPages       = new Dictionary <PageChair, Border>();
     currentPageIndex = 0;
 }
Esempio n. 4
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();
        }
Esempio n. 5
0
 public TimetableHandler(DataProvider dataProvider, int updateIntervalInSeconds, PageChairsRoot pageChairsRoot)
 {
     this.dataProvider            = dataProvider;
     this.updateIntervalInSeconds = updateIntervalInSeconds;
     this.pageChairsRoot          = pageChairsRoot;
 }