private void RenovateRoom(object sender, RoutedEventArgs e)
 {
     setDates();
     if (setDestinationRoomId())
     {
         DestinationRoomComboBox.SelectedIndex = 0;
         try
         {
             RenovationDto renovationDto    = CreateRenovationDto(timeInterval);
             SchedulingDto schDto           = renovationDto.toSchedulingDto();
             List <int>    unavailableRooms = roomServerController.GetUnavailableRooms(schDto).ToList();
             if (unavailableRooms.Count > 0)
             {
                 ShowAlternativeRenovationAppointments(unavailableRooms, renovationDto);
             }
             else
             {
                 ScheduleRenovation(schDto);
             }
         }
         catch
         {
             MessageBox.Show("End time must be after start time!", "");
         }
     }
 }
        private void AddScheduleRenovationButton(int row, RenovationDto renovation)
        {
            Button scheduleBtn = CreateScheduleButton();

            Grid.SetRow(scheduleBtn, row);
            Grid.SetColumn(scheduleBtn, DynamicGrid.ColumnDefinitions.Count - 2);
            DynamicGrid.Children.Add(scheduleBtn);

            SchedulingDto schDto = renovation.toSchedulingDto();

            timeInterval = new TimeInterval(schDto.TimeInterval.Start, schDto.TimeInterval.End);

            scheduleBtn.Click += (s, e) =>
            {
                List <int> doctors = doctorServerController.GetDoctorsByRoomsAndShifts(schDto).ToList();
                foreach (int doctorId in doctors)
                {
                    renovationServerController.ScheduleRenovation(renovation.TimeInterval, doctorId, AllConstants.PatientIdForRenovation);
                }
                MessageBox.Show("Renovation is successfully scheduled!");
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(RoomRenovation))
                    {
                        if ((window as RoomRenovation).RenovationTypeComboBox.Text.Equals("Complex"))
                        {
                            RoomInformation roomInformation = new RoomInformation(schDto);

                            if ((window as RoomRenovation).ComplexRenovationTypeComboBox.Text.Equals("Separate room"))
                            {
                                roomInformation.MergingStackPanel.Visibility  = Visibility.Hidden;
                                roomInformation.DividingStackPanel.Visibility = Visibility.Visible;
                                roomInformation.Room1Name.Text = mapObjectController.GetMapObjectById(renovation.SourceRoomId).Name;
                                int workTime = mapObjectController.GetMapObjectById(renovation.SourceRoomId).MapObjectDescription.Information.Split("=")[1].Length;
                                roomInformation.WorkTime1.Text = mapObjectController.GetMapObjectById(renovation.SourceRoomId).MapObjectDescription.Information.Split("=")[1].Substring(0, workTime - 1);
                            }
                            else if ((window as RoomRenovation).ComplexRenovationTypeComboBox.Text.Equals("Join rooms"))
                            {
                                roomInformation.DividingStackPanel.Visibility = Visibility.Hidden;
                                roomInformation.MergingStackPanel.Visibility  = Visibility.Visible;
                                roomInformation.RoomName.Text = mapObjectController.GetMapObjectById(renovation.SourceRoomId).Name;
                                int workTime = mapObjectController.GetMapObjectById(renovation.SourceRoomId).MapObjectDescription.Information.Split("=")[1].Length;
                                roomInformation.WorkTime.Text = mapObjectController.GetMapObjectById(renovation.SourceRoomId).MapObjectDescription.Information.Split("=")[1].Substring(0, workTime - 1);
                                List <int> doctors1 = doctorServerController.GetDoctorsByRoomsAndShifts(schDto).ToList();
                                foreach (int doctorId in doctors1)
                                {
                                    startDate = schDto.TimeInterval.Start.AddDays(1);
                                    examinationServerController.ScheduleExamination(startDate, doctorId, AllConstants.PatientIdForRelocation);
                                }
                            }
                            roomInformation.ShowDialog();
                        }
                    }
                }
                this.Close();
            };
        }
        private RenovationDto CreateRenovationDto(TimeInterval timeInterval)
        {
            RenovationDto renovationDto = new RenovationDto()
            {
                SourceRoomId      = mapObjectId,
                DestinationRoomId = neighbourMapObjectId,
                TimeInterval      = timeInterval
            };

            return(renovationDto);
        }
예제 #4
0
        public List <SearchResultDTO> GetSearchResult()
        {
            List <RenovationDto>   searchResult        = new SchedulingServerController().GetRenovationAppointments(scheduling);
            IMapObjectController   mapObjectController = new MapObjectController();
            List <SearchResultDTO> retVal = new List <SearchResultDTO>();

            for (int i = 0; i < searchResult.Count(); i++)
            {
                RenovationDto             renovationDto   = searchResult.ElementAt(i);
                MapObject                 mo              = mapObjectController.GetMapObjectById(renovationDto.SourceRoomId);
                string                    timeInterval    = renovationDto.TimeInterval.Start.ToString() + "-" + renovationDto.TimeInterval.End.ToString();
                RenovationSearchResultDTO searchResultDTO = new RenovationSearchResultDTO()
                {
                    Content = renovationDto.SourceRoomId.ToString() + AllConstants.ContentSeparator
                              + timeInterval,
                    RenovationDto = renovationDto
                };
                retVal.Add(searchResultDTO);
            }
            return(retVal);
        }
        private void ShowAlternativeRenovationAppointments(List <int> unavailableRooms, RenovationDto renovationDto)
        {
            SchedulingDto dto = renovationDto.toSchedulingDto();
            AlternativeRenovationAppointments newWindow =
                new AlternativeRenovationAppointments(unavailableRooms[0], this, dto);

            newWindow.Show();
        }