Beispiel #1
0
        private void FillStartingDashboardContent()
        {
            //get info from data base to use it later
            List <Guest> currentGuests = HotelManagmentLogic.Entity.CommonOperations.DatabaseOperations
                                         .GetFullTableBaseOnType <Guest>()
                                         .ReturnedData
                                         .ConvertToGenericList <Guest>();

            List <Booking> bookingTable = HotelManagmentLogic.Entity.CommonOperations.DatabaseOperations
                                          .GetFullTableBaseOnType <Booking>()
                                          .ReturnedData
                                          .ConvertToGenericList <Booking>();

            //fill box about last booked guest and store that variable
            Guest lastBookedGuest = FillLastBookedGuestOutput(currentGuests);

            //fill box which represent logged user name
            UsernameTextBoxWelcome.Text = ProgramManagement.GetLoggedUser().Name;

            //booked guest amount - fill x/x format and also progress bar
            FillGuestCurrentGuestCountOutput(currentGuests);

            //inner join booking and guests table to get data about closest booking end date
            FillClosestBookEndingOutput(bookingTable, currentGuests, lastBookedGuest);
        }
 private void ForceLogin_Click(object sender, RoutedEventArgs e)
 {
     //TODO remove it after finish end
     ProgramManagement.SetLoggedUser(new User()
     {
         Name = "Test user", UserType = HotelManagmentLogic.Enums.UserType.Administrator
     });
     PrecedeToMainWindow();
 }
Beispiel #3
0
        private void AdministrationButton_Click(object sender, RoutedEventArgs e)
        {
            if (ProgramManagement.GetLoggedUser().UserType == HotelManagmentLogic.Enums.UserType.Administrator)
            {
                InnerFrame.Content = CheckIfContentActive <AdministrationControl>() ? WindowsManagement.GetAdministrationControlInstance()
                                                                                   : InnerFrame.Content;

                AdministrationButton.Background = activeButtonColor;
            }
            else
            {
                MessageBox.Show(HotelManagmentLogic.Configuration.OutputMessages.CantAccessToThatContent);
            }
        }
        private void PerformLoginAction()
        {
            UserLogin userLogin = new UserLogin();

            LoginResult loginResult = userLogin.Login(this.UserTextBox.Text, this.UserPasswordTextBox.Password);

            MessageBox.Show(loginResult.Message);

            if (loginResult.OperationSuccess)
            {
                ProgramManagement.SetLoggedUser(loginResult.AccessingUser);
                PrecedeToMainWindow();
            }
        }
        public override bool GetProgramsForSchedule(ISchedule schedule, out IList <IProgram> programs)
        {
            programs = new List <IProgram>();
            Schedule scheduleEntity = ScheduleManagement.GetSchedule(schedule.ScheduleId);

            if (scheduleEntity == null)
            {
                return(false);
            }
            IList <Program> programEntities = ProgramManagement.GetProgramsForSchedule(scheduleEntity);

            programs = programEntities.Select(p => p.ToProgram()).Distinct(ProgramComparer.Instance).ToList();
            return(true);
        }
Beispiel #6
0
        public override Task <AsyncResult <IList <IProgram> > > GetProgramsForScheduleAsync(ISchedule schedule)
        {
            var      programs       = new List <IProgram>();
            Schedule scheduleEntity = ScheduleManagement.GetSchedule(schedule.ScheduleId);

            if (scheduleEntity == null)
            {
                return(Task.FromResult(new AsyncResult <IList <IProgram> >(false, null)));
            }
            IList <Program> programEntities = ProgramManagement.GetProgramsForSchedule(scheduleEntity);

            programs = programEntities.Select(p => GetProgram(p)).Distinct(ProgramComparer.Instance).ToList();
            var success = programs.Count > 0;

            return(Task.FromResult(new AsyncResult <IList <IProgram> >(success, programs)));
        }
Beispiel #7
0
        public bool GetProgramsForSchedule(ISchedule schedule, out IList <IProgram> programs)
        {
            programs = new List <IProgram>();
#if TVE3
            var tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId);
            if (tvSchedule == null)
            {
                return(false);
            }

            programs = TvDatabase.Schedule.GetProgramsForSchedule(tvSchedule).Select(p => p.ToProgram()).ToList();
            return(programs.Count > 0);
#else
            Schedule scheduleEntity = ScheduleManagement.GetSchedule(schedule.ScheduleId);
            if (scheduleEntity == null)
            {
                return(false);
            }
            IList <Program> programEntities = ProgramManagement.GetProgramsForSchedule(scheduleEntity);
            programs = programEntities.Select(p => p.ToProgram()).Distinct(ProgramComparer.Instance).ToList();
            return(true);
#endif
        }
Beispiel #8
0
        public override void LoadSubtitle(Subtitle subtitle, List <string> lines, string fileName)
        {
            const int startPosition = 256 * 3; // First 256 bytes block is just id, two next blocks are ProgramManagementInformation, then comes the list of PageManagementInformations

            _errorCount = 0;
            subtitle.Paragraphs.Clear();
            subtitle.Header = null;
            var    buffer = FileUtil.ReadAllBytesShared(fileName);
            int    index  = startPosition;
            string label  = Encoding.ASCII.GetString(buffer, 0, 8);

            if (label != "DCAPTION" && label != "BCAPTION" && label != "MCAPTION")
            {
                return;
            }

            var programManagementInformation = new ProgramManagement(buffer, 256 + 4);

            while (index + 255 < buffer.Length)
            {
                if (buffer[index + 4] == 0x2a) // Page management information
                {
                    int blockstart = index;
                    int length     = (buffer[index + 2] << 8) + buffer[index + 3];
                    index += 5;
                    var pageManagementInformationLength = (buffer[index++] << 8) + buffer[index++];
                    var pageManagementInformation       = new PageManagement(buffer, index);
                    index += pageManagementInformationLength;
                    if (buffer[index] == 0x3a) // Caption text page management data
                    {
                        index++;
                        var captionTextPageManagementLength = (buffer[index++] << 8) + buffer[index++];
                        var captionTextPageManagement       = new CaptionTextPageManagement(buffer, index);
                        index += captionTextPageManagementLength;

                        if (buffer[index] == 0x4a) // Caption text data
                        {
                            index++;
                            var subtitleDataLength = (buffer[index++] << 8) + buffer[index++];
                            try
                            {
                                var captionText = new CaptionText(buffer, index, captionTextPageManagement.Iso639LanguageCode);
                                var p           = new Paragraph
                                {
                                    StartTime = pageManagementInformation.GetStartTime(),
                                    EndTime   = pageManagementInformation.GetEndTime()
                                };
                                foreach (var unit in captionText.CaptionTextUnits)
                                {
                                    foreach (var text in unit.AribText.Texts)
                                    {
                                        p.Text = (p.Text + Environment.NewLine + text.Text).Trim();
                                    }
                                }
                                subtitle.Paragraphs.Add(p);
                            }
                            catch
                            {
                                _errorCount++;
                            }
                        }
                    }
                    index = RoundUp(blockstart + length, 256);
                }
                else
                {
                    index += 256;
                }
            }
            for (int i = 0; i < subtitle.Paragraphs.Count - 1; i++)
            {
                var paragraph = subtitle.Paragraphs[i];
                if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.001)
                {
                    var next = subtitle.Paragraphs[i + 1];
                    paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
                }
            }
            if (subtitle.Paragraphs.Count > 0 && Math.Abs(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds) < 0.001)
            {
                var p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1];
                p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
            }

            subtitle.Renumber();
        }
Beispiel #9
0
        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            const int startPosition = 256 * 3; // First 256 bytes block is just id, two next blocks are ProgramManagementInformation, then comes the list of PageManagementInformations
            _errorCount = 0;
            subtitle.Paragraphs.Clear();
            subtitle.Header = null;
            var buffer = FileUtil.ReadAllBytesShared(fileName);
            int index = startPosition;
            string label = Encoding.ASCII.GetString(buffer, 0, 8);
            if (label != "DCAPTION" && label != "BCAPTION" && label != "MCAPTION")
                return;

            var programManagementInformation = new ProgramManagement(buffer, 256 + 4);
            while (index + 255 < buffer.Length)
            {
                if (buffer[index + 4] == 0x2a) // Page management information
                {
                    int blockstart = index;
                    int length = (buffer[index + 2] << 8) + buffer[index + 3];
                    index += 5;
                    var pageManagementInformationLength = (buffer[index++] << 8) + buffer[index++];
                    var pageManagementInformation = new PageManagement(buffer, index);
                    index += pageManagementInformationLength;
                    if (buffer[index] == 0x3a) // Caption text page management data
                    {
                        index++;
                        var captionTextPageManagementLength = (buffer[index++] << 8) + buffer[index++];
                        var captionTextPageManagement = new CaptionTextPageManagement(buffer, index);
                        index += captionTextPageManagementLength;

                        if (buffer[index] == 0x4a) // Caption text data
                        {
                            index++;
                            var subtitleDataLength = (buffer[index++] << 8) + buffer[index++];
                            try
                            {
                                var captionText = new CaptionText(buffer, index, captionTextPageManagement.Iso639Languagecode);
                                var p = new Paragraph
                                {
                                    StartTime = pageManagementInformation.GetStartTime(),
                                    EndTime = pageManagementInformation.GetEndTime()
                                };
                                foreach (var unit in captionText.CaptionTextUnits)
                                {
                                    foreach (var text in unit.AribText.Texts)
                                    {
                                        p.Text = (p.Text + Environment.NewLine + text.Text).Trim();
                                    }
                                }
                                subtitle.Paragraphs.Add(p);
                            }
                            catch
                            {
                                _errorCount++;
                            }
                        }
                    }
                    index = RoundUp(blockstart + length, 256);
                }
                else
                {
                    index += 256;
                }
            }
            for (int i = 0; i < subtitle.Paragraphs.Count - 1; i++)
            {
                var paragraph = subtitle.Paragraphs[i];
                if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.001)
                {
                    var next = subtitle.Paragraphs[i + 1];
                    paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
                }
            }
            if (subtitle.Paragraphs.Count > 0 && Math.Abs(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds) < 0.001)
            {
                var p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1];
                p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
            }

            subtitle.Renumber();
        }
 //starting point of whole program
 public LoginWindow()
 {
     InitializeComponent();
     ProgramManagement.Initialize(this);
 }