Beispiel #1
0
 private void _schedulesDataGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e)
 {
     try
     {
         if (_schedulesDataGridView.SelectedRows.Count > 0)
         {
             DataGridViewRow row = _schedulesDataGridView.SelectedRows[0];
             if (row.Cells[0].Selected &&
                 row.Cells[0].Value != null &&
                 (bool)row.Cells[0].EditedFormattedValue != (bool)row.Cells[0].Value)
             {
                 ScheduleSummary schedule = row.DataBoundItem as ScheduleSummary;
                 schedule.IsActive = (bool)row.Cells[0].EditedFormattedValue;
                 ScheduleSummary modifiedSchedule = Proxies.SchedulerService.SaveScheduleSummary(schedule).Result;
                 SortableBindingList <ScheduleSummary> schedulesList = (SortableBindingList <ScheduleSummary>)_schedulesBindingSource.DataSource;
                 int index = schedulesList.IndexOf(schedule);
                 schedulesList[index] = modifiedSchedule;
                 _schedulesBindingSource.ResetBindings(false);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Save a modified schedule summary.
        /// </summary>
        /// <param name="scheduleSummary">The schedule summary to save.</param>
        /// <returns>The saved schedule.</returns>
        public async Task <ScheduleSummary> SaveScheduleSummary(ScheduleSummary scheduleSummary)
        {
            var request = NewRequest(HttpMethod.Post, "SaveScheduleSummary");

            request.AddBody(scheduleSummary);
            return(await ExecuteAsync <ScheduleSummary>(request).ConfigureAwait(false));
        }
        private void LoadSchedulesComboBox()
        {
            try
            {
                List <ScheduleSummary> schedules = new List <ScheduleSummary>();
                var allSchedules = Proxies.SchedulerService.GetAllSchedules(ChannelType.Television, _scheduleType, false).Result;
                foreach (ScheduleSummary schedule in allSchedules)
                {
                    if (schedule.IsActive)
                    {
                        schedules.Add(schedule);
                    }
                }
                schedules.Sort(
                    delegate(ScheduleSummary s1, ScheduleSummary s2) { return(s1.Name.CompareTo(s2.Name)); });
                ScheduleSummary allSchedulesEntry = new ScheduleSummary();
                allSchedulesEntry.ScheduleId = Guid.Empty;
                allSchedulesEntry.Name       = String.Empty;
                schedules.Insert(0, allSchedulesEntry);

                _schedulesComboBox.DataSource    = schedules;
                _schedulesComboBox.DisplayMember = "Name";
            }
            catch (Exception ex)
            {
                _schedulesComboBox.DataSource = null;
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        protected override void OnPageLoad()
        {
            PluginMain.EnsureConnection();

            base.OnPageLoad();
            if (PluginMain.IsConnected())
            {
                LoadSettings();
                if (GUIWindowManager.GetPreviousActiveWindow() != WindowId.ProgramInfo &&
                    GUIWindowManager.GetPreviousActiveWindow() != WindowId.ManualShedule)
                {
                    _selectedSchedule = null;
                }
                LoadUpcomingPrograms(_selectedSchedule);
                _sortByButton.SortChanged += new SortEventHandler(SortChanged);

                if (this._channelType == ChannelType.Television)
                {
                    GUIPropertyManager.SetProperty("#currentmodule", Utility.GetLocalizedText(TextId.TVScheduler));
                }
                else
                {
                    GUIPropertyManager.SetProperty("#currentmodule", Utility.GetLocalizedText(TextId.RadioScheduler));
                }
            }
        }
        public async Task <IList <ScheduleSummary> > GetSchedulesForJobApplications(IList <string> jobApplicationIds, DateTime startDate)
        {
            if (startDate == null || startDate == default(DateTime))
            {
                startDate = DateTime.UtcNow;
            }

            if (!DateTime.TryParse(startDate.ToString(CultureInfo.InvariantCulture), out startDate))
            {
                throw new InvalidOperationException("Invalid date");
            }

            var scheduleClient = this.cosmosQueryClientProvider.GetCosmosQueryClient("GTAIVSchedule", "GTA");

            var jobApplicationSchedules = await scheduleClient.Get <JobApplicationSchedule>(jas => jobApplicationIds.Contains(jas.JobApplicationID) && jas.ScheduleStatus != ScheduleStatus.Delete && jas.StartDateTime >= startDate && jas.StartDateTime < startDate.AddDays(7));

            jobApplicationSchedules = jobApplicationSchedules?.OrderBy(jas => jas.StartDateTime);

            IList <ScheduleSummary> scheduleSummary = new List <ScheduleSummary>();

            jobApplicationSchedules?.ToList().ForEach(jas =>
            {
                var schedule = new ScheduleSummary
                {
                    JobApplicationId      = jas.JobApplicationID,
                    ScheduleStartDateTime = jas.StartDateTime,
                };
                scheduleSummary.Add(schedule);
            });

            return(scheduleSummary);
        }
        public void ShouldInvokeScheduleServiceToGetEvents()
        {
            var paymentScheduleService    = MockRepository.GenerateMock <IPaymentScheduleService>();
            var eventSummaryMapper        = MockRepository.GenerateMock <IEventSummaryMapper>();
            var webSecurityWrapper        = MockRepository.GenerateMock <IWebSecurityWrapper>();
            var paymentScheduleController = new PaymentScheduleController(paymentScheduleService, eventSummaryMapper, webSecurityWrapper);

            var startDate = new DateTime(2013, 4, 1);
            var endDate   = new DateTime(2013, 4, 30);

            var scheduleSummary   = new ScheduleSummary();
            var eventSummaryJsons =
                new[] { new EventSummaryJson {
                            title = "blah", start = "2013-4-12"
                        } };

            webSecurityWrapper.Stub(w => w.GetUserId()).Return(1234);
            paymentScheduleService.Stub(
                pss => pss.GetSummaryOfDues(Arg <ScheduleRequest> .Matches(
                                                sr => sr.StartDate.Equals(startDate) &&
                                                sr.UserId == 1234)))
            .Return(scheduleSummary);
            eventSummaryMapper.Stub(es => es.Map(scheduleSummary)).Return(eventSummaryJsons);


            var eventSummary = paymentScheduleController.EventSummary(ConvertToTimestamp(startDate).ToString(), ConvertToTimestamp(endDate).ToString());

            Assert.That(eventSummary, Is.AssignableTo <JsonResult>());
            Assert.That(((JsonResult)eventSummary).Data, Is.EqualTo(eventSummaryJsons));
        }
Beispiel #7
0
        private ScheduleSummary GetSelectedSchedule()
        {
            ScheduleSummary schedule = null;

            if (_schedulesDataGridView.SelectedRows.Count == 1)
            {
                schedule = _schedulesDataGridView.SelectedRows[0].DataBoundItem as ScheduleSummary;
            }
            return(schedule);
        }
Beispiel #8
0
        private void SetProperties(UpcomingProgram upcoming, ScheduleSummary schedule)
        {
            string guiPropertyPrefix = this._channelType == ChannelType.Television ? "#TV" : "#Radio";

            if (schedule != null)
            {
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", schedule.Name);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", " ");
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", "defaultFolderBig.png");
            }
            else if (upcoming != null)
            {
                GuideProgram guideProgram = upcoming.GuideProgramId.HasValue ?
                                            Proxies.GuideService.GetProgramById(upcoming.GuideProgramId.Value).Result : null;

                string strTime = string.Format("{0} {1} - {2}",
                                               Utility.GetShortDayDateString(upcoming.StartTime),
                                               upcoming.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                               upcoming.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", upcoming.Channel.DisplayName);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", upcoming.Title);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", upcoming.Category);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", strTime);

                string description = String.Empty;
                if (guideProgram != null)
                {
                    description = guideProgram.CreateCombinedDescription(true);
                }
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", description);

                string logo = Utility.GetLogoImage(upcoming.Channel.ChannelId, upcoming.Channel.DisplayName);
                if (!string.IsNullOrEmpty(logo))
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", logo);
                }
                else
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", "defaultVideoBig.png");
                }
            }
            else
            {
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", " ");
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", String.Empty);
            }
        }
Beispiel #9
0
 private void _schedulesDataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
 {
     foreach (DataGridViewRow row in _schedulesDataGridView.Rows)
     {
         Icon            icon     = Properties.Resources.TransparentIcon;
         ScheduleSummary schedule = row.DataBoundItem as ScheduleSummary;
         if (schedule != null)
         {
             icon = ProgramIconUtility.GetIcon(_scheduleType, !schedule.IsOneTime);
         }
         DataGridViewImageCell cell = (DataGridViewImageCell)row.Cells[1];
         cell.Value       = icon;
         cell.ValueIsIcon = true;
     }
 }
Beispiel #10
0
        private void EditSelectedSchedule()
        {
            ScheduleSummary schedule = GetSelectedSchedule();

            if (schedule != null)
            {
                try
                {
                    EditSchedulePanel editPanel = new EditSchedulePanel();
                    editPanel.Schedule = Proxies.SchedulerService.GetScheduleById(schedule.ScheduleId).Result;
                    editPanel.OpenPanel(this);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #11
0
        private void _exportButton_Click(object sender, EventArgs e)
        {
            try
            {
                List <Schedule> schedules = new List <Schedule>();

                DialogResult result = MessageBox.Show(this,
                                                      "Hit 'Yes' to export all schedules or 'No' to only" + Environment.NewLine + "export the selected schedule(s).",
                                                      "Export", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    foreach (DataGridViewRow row in _schedulesDataGridView.Rows)
                    {
                        ScheduleSummary scheduleSummary = row.DataBoundItem as ScheduleSummary;
                        schedules.Add(Proxies.SchedulerService.GetScheduleById(scheduleSummary.ScheduleId).Result);
                    }
                }
                else if (result == DialogResult.No)
                {
                    foreach (DataGridViewRow selectedRow in _schedulesDataGridView.SelectedRows)
                    {
                        ScheduleSummary scheduleSummary = selectedRow.DataBoundItem as ScheduleSummary;
                        schedules.Add(Proxies.SchedulerService.GetScheduleById(scheduleSummary.ScheduleId).Result);
                    }
                }
                if (schedules.Count > 0)
                {
                    ExportScheduleList exportList = new ExportScheduleList(schedules);

                    _saveFileDialog.FileName = _scheduleType.ToString() + "Schedules_" + DateTime.Today.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmss") + ".xml";
                    if (_saveFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        exportList.Serialize(_saveFileDialog.FileName);

                        MessageBox.Show(this, String.Format("{0} schedule(s) exported.", schedules.Count), "Export",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #12
0
        protected override void OnPageDestroy(int newWindowId)
        {
            if (_isInSubDirectory)
            {
                m_iSelectedItemInFolder = GetSelectedItemNo();
            }
            else
            {
                m_iSelectedItem = GetSelectedItemNo();
            }

            SaveSettings();

            if (newWindowId != WindowId.ProgramInfo &&
                newWindowId != WindowId.ManualShedule)
            {
                _selectedSchedule = null;
            }
            base.OnPageDestroy(newWindowId);
        }
Beispiel #13
0
 private void _schedulesDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.ColumnIndex != 0 &&
         e.RowIndex >= 0 &&
         e.RowIndex < _schedulesBindingSource.Count)
     {
         ScheduleSummary schedule = _schedulesDataGridView.Rows[e.RowIndex].DataBoundItem as ScheduleSummary;
         if (schedule != null &&
             schedule.IsActive)
         {
             e.CellStyle.ForeColor          = Color.Black;
             e.CellStyle.SelectionForeColor = Color.Black;
         }
         else
         {
             e.CellStyle.ForeColor          = Color.DarkGray;
             e.CellStyle.SelectionForeColor = Color.Gray;
         }
     }
 }
Beispiel #14
0
        private void UpdateProperties()
        {
            GUIListItem pItem = GetItem(GetSelectedItemNo());

            if (pItem == null)
            {
                SetProperties(null, null);
                return;
            }

            if (!pItem.IsFolder)
            {
                UpcomingProgram upcoming = pItem.TVTag as UpcomingProgram;
                SetProperties(upcoming, null);
            }
            else
            {
                ScheduleSummary schedule = pItem.TVTag as ScheduleSummary;
                SetProperties(null, schedule);
            }
        }
        private void RefreshUpcomingPrograms()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                UpcomingOrActiveProgramsList upcomingPrograms;
                if (_scheduleType == ScheduleType.Recording)
                {
                    UpcomingRecordingsFilter filter = _showSkippedRecordings.Checked ?
                                                      UpcomingRecordingsFilter.All : UpcomingRecordingsFilter.Recordings | UpcomingRecordingsFilter.CancelledByUser;
                    var allUpcomingRecordings = Proxies.ControlService.GetAllUpcomingRecordings(filter, true).Result;
                    _upcomingProgramsControl.UnfilteredUpcomingRecordings = new UpcomingOrActiveProgramsList(allUpcomingRecordings);
                    upcomingPrograms = new UpcomingOrActiveProgramsList(allUpcomingRecordings);
                    upcomingPrograms.RemoveActiveRecordings(Proxies.ControlService.GetActiveRecordings().Result);
                }
                else
                {
                    _upcomingProgramsControl.UnfilteredUpcomingRecordings = null;
                    upcomingPrograms = new UpcomingOrActiveProgramsList(Proxies.SchedulerService.GetAllUpcomingPrograms(_scheduleType, true).Result);
                }

                ScheduleSummary schedule = _schedulesComboBox.SelectedItem as ScheduleSummary;
                if (schedule != null)
                {
                    upcomingPrograms.ApplyScheduleFilter(schedule.ScheduleId);
                }

                _upcomingProgramsControl.UpcomingPrograms = upcomingPrograms;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Beispiel #16
0
 private void _deleteButton_Click(object sender, EventArgs e)
 {
     if (_schedulesDataGridView.SelectedRows.Count > 0 &&
         DialogResult.Yes == MessageBox.Show(this, "Are you sure you want to delete all the highlighted schedules?", "Delete",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
     {
         try
         {
             foreach (DataGridViewRow selectedRow in _schedulesDataGridView.SelectedRows)
             {
                 ScheduleSummary scheduleSummary = selectedRow.DataBoundItem as ScheduleSummary;
                 Proxies.SchedulerService.DeleteSchedule(scheduleSummary.ScheduleId).Wait();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         LoadAllSchedules(false);
         _schedulesDataGridView.ClearSelection();
     }
 }
Beispiel #17
0
        protected override void OnPageDestroy(int newWindowId)
        {
            if (_isInSubDirectory)
            {
                m_iSelectedItemInFolder = GetSelectedItemNo();
            }
            else
            {
                m_iSelectedItem = GetSelectedItemNo();
            }

            SaveSettings();
            if (_tvSchedulerAgent != null)
            {
                _tvSchedulerAgent.Dispose();
            }
            if (_tvGuideAgent != null)
            {
                _tvGuideAgent.Dispose();
            }
            if (_tvControlAgent != null)
            {
                _tvControlAgent.Dispose();
            }
            if (_configurationAgent != null)
            {
                _configurationAgent.Dispose();
            }

            if (newWindowId != WindowId.ProgramInfo &&
                newWindowId != WindowId.ManualShedule)
            {
                _selectedSchedule = null;
            }
            base.OnPageDestroy(newWindowId);
        }
 public EventSummaryJson[] Map(ScheduleSummary scheduleSummary)
 {
     return(scheduleSummary.Bills.Select(b => new EventSummaryJson {
         title = b.Vendor, start = "2013-05-10"
     }).ToArray());
 }
Beispiel #19
0
        internal static async Task <ScheduleOverviews> MapToScheduleOverviews(
            ScheduleOverviewsRequest request,
            IQueryable <ScheduleEntity> schedules,
            IQueryable <CompanyEntity> companies,
            IQueryable <WellEntity> wells)
        {
            // Build SQL query
            var query1 = from s in schedules.GetByRegions(request.Regions)
                         .GetByOperators(request.Operators)
                         .GetByStartNextDays(request.StartNextDays)
                         join c in companies on s.CompanyId equals c.Id
                         join w in wells on s.WellId equals w.Id
                         select new
            {
                Schedule = s,
                Company  = c,
                Well     = w
            };

            var query = from q1 in query1
                        select new ScheduleOverviewQuery
            {
                Schedule = q1.Schedule,
                Company  = q1.Company,
                Well     = q1.Well
            };

            var sortBy = new SortFields <ScheduleOverviewQuery>
            {
                { "wellName", e => e.Well.Name },
                { "operator", e => e.Company.Name },
                { "fracStartDate", e => e.Schedule.FracStartDate }
            };

            query = query
                    .SortBy(request, sortBy)
                    .GetPage(request);

            // Run SQL query
            var entities = await query.ToArrayAsync();

            var totalCount = await query1.CountAsync();

            // Map entities to models
            var overviews = entities.Select(e => new ScheduleOverview(
                                                e.Schedule.Id,
                                                e.Well.Name,
                                                e.Company.Name,
                                                e.Schedule.FracStartDate,
                                                e.Schedule.FracEndDate,
                                                (e.Schedule.FracEndDate - e.Schedule.FracStartDate).Days,
                                                e.Well.Api,
                                                e.Well.SurfaceLat,
                                                e.Well.SurfaceLong,
                                                e.Well.BottomholeLat,
                                                e.Well.BottomholeLong,
                                                e.Well.Tvd,
                                                e.Schedule.FracStartDate.GetStartInDays(),
                                                e.Schedule.FracStartDate.GetScheduleStatus()));

            var os      = overviews as ScheduleOverview[] ?? overviews.ToArray();
            var summary = new ScheduleSummary(
                os.Count(o => o.Status == ScheduleStatus.Operating),
                os.Count(o => o.Status == ScheduleStatus.Next7Days),
                os.Count(o => o.Status == ScheduleStatus.Next830Days),
                os.Count(o => o.Status == ScheduleStatus.Next3160Days),
                os.Count(o => o.Status == ScheduleStatus.Next60PlusDays));

            return(new ScheduleOverviews(
                       request,
                       totalCount,
                       os,
                       summary));
        }
Beispiel #20
0
        protected override void OnShowContextMenu()
        {
            int         iItem = GetSelectedItemNo();
            GUIListItem pItem = GetItem(iItem);

            if (pItem == null)
            {
                return;
            }
            if (pItem.IsFolder)
            {
                ScheduleSummary schedule = pItem.TVTag as ScheduleSummary;
                if (schedule != null)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(schedule.Name ?? string.Empty);
                    dlg.Add(Utility.GetLocalizedText(TextId.Settings));
                    if (schedule.IsActive)
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.CancelThisSchedule));
                    }
                    else
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.UnCancelThisSchedule));
                    }

                    dlg.Add(Utility.GetLocalizedText(TextId.DeleteThisSchedule));
                    dlg.DoModal(GetID);

                    Schedule _sched = Proxies.SchedulerService.GetScheduleById(schedule.ScheduleId).Result;
                    switch (dlg.SelectedLabel)
                    {
                    case 0:
                        if (_sched != null)
                        {
                            var programs = Proxies.SchedulerService.GetUpcomingPrograms(_sched, true).Result;
                            if (programs != null && programs.Count > 0)
                            {
                                OnEditSchedule(programs[0]);
                            }
                        }
                        break;

                    case 1:
                        if (_sched != null)
                        {
                            if (_sched.IsActive)
                            {
                                _sched.IsActive = false;
                                Proxies.SchedulerService.SaveSchedule(_sched).Wait();
                            }
                            else
                            {
                                _sched.IsActive = true;
                                Proxies.SchedulerService.SaveSchedule(_sched).Wait();
                            }
                        }
                        break;

                    case 2:
                    {
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo != null)
                        {
                            dlgYesNo.Reset();
                            dlgYesNo.SetHeading(schedule.Name);
                            dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.DeleteThisSchedule));
                            dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                            dlgYesNo.SetLine(3, string.Empty);
                            dlgYesNo.SetDefaultToYes(false);
                            dlgYesNo.DoModal(GetID);

                            if (dlgYesNo.IsConfirmed)
                            {
                                Proxies.SchedulerService.DeleteSchedule(schedule.ScheduleId).Wait();
                                _selectedSchedule = null;
                            }
                        }
                    }
                    break;
                    }
                    m_iSelectedItem = GetSelectedItemNo();
                    LoadUpcomingPrograms(null);
                }
            }
            else
            {
                UpcomingProgram upcoming = pItem.TVTag as UpcomingProgram;
                if (upcoming != null)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(upcoming.Title);
                    dlg.Add(Utility.GetLocalizedText(TextId.Settings));
                    dlg.Add(Utility.GetLocalizedText(TextId.Priority));
                    if (upcoming.IsCancelled)
                    {
                        if (upcoming.CancellationReason == UpcomingCancellationReason.Manual)
                        {
                            dlg.Add(Utility.GetLocalizedText(TextId.UncancelThisShow));
                        }
                    }
                    else
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.CancelThisShow));
                    }
                    dlg.DoModal(GetID);

                    switch (dlg.SelectedLabel)
                    {
                    case 0:     // settings/information
                        OnEditSchedule(upcoming);
                        break;

                    case 1:     // Priority
                        OnChangePriority(upcoming);
                        break;

                    case 2:     // (Un)Cancel
                        if (upcoming.IsCancelled)
                        {
                            Proxies.SchedulerService.UncancelUpcomingProgram(upcoming.ScheduleId, upcoming.GuideProgramId, upcoming.Channel.ChannelId, upcoming.StartTime).Wait();
                        }
                        else
                        {
                            Proxies.SchedulerService.CancelUpcomingProgram(upcoming.ScheduleId, upcoming.GuideProgramId, upcoming.Channel.ChannelId, upcoming.StartTime).Wait();
                        }
                        m_iSelectedItem = GetSelectedItemNo();
                        LoadUpcomingPrograms(null);
                        break;
                    }
                }
            }
        }
Beispiel #21
0
        private void LoadUpcomingPrograms(ScheduleSummary schedule)
        {
            GUIControl.ClearControl(GetID, _viewsList.GetID);

            if (schedule == null)
            {
                _isInSubDirectory = false;
                bool group = false;
                if (_groupBySchedButton != null)
                {
                    group = _groupBySchedButton.Selected;
                }

                if (group)
                {
                    var schedules = Proxies.SchedulerService.GetAllSchedules(this._channelType, _currentProgramType, true).Result;
                    foreach (ScheduleSummary sched in schedules)
                    {
                        GUIListItem item = CreateListItem(null, null, sched);
                        _viewsList.Add(item);
                    }
                }
                else
                {
                    if (_currentProgramType == ScheduleType.Recording)
                    {
                        List <UpcomingRecording> upcomingRecordings = new List <UpcomingRecording>(
                            Proxies.ControlService.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings | UpcomingRecordingsFilter.CancelledByUser, false).Result);
                        foreach (UpcomingRecording recording in upcomingRecordings)
                        {
                            if (recording.Program.Channel.ChannelType == this._channelType)
                            {
                                GUIListItem item = CreateListItem(recording.Program, recording, null);
                                _viewsList.Add(item);
                            }
                        }
                    }
                    else
                    {
                        List <UpcomingProgram> upcomingPrograms = new List <UpcomingProgram>(
                            Proxies.SchedulerService.GetAllUpcomingPrograms(_currentProgramType, true).Result);
                        foreach (UpcomingProgram program in upcomingPrograms)
                        {
                            if (program.Channel.ChannelType == this._channelType)
                            {
                                GUIListItem item = CreateListItem(program, null, null);
                                _viewsList.Add(item);
                            }
                        }
                    }
                }
            }
            else if (schedule != null)
            {
                //add prev directory folder
                GUIListItem item = new GUIListItem();
                item.Label    = _parentDirectoryLabel;
                item.IsFolder = true;
                Utils.SetDefaultIcons(item);
                _viewsList.Add(item);

                _selectedSchedule = schedule;
                if (_currentProgramType == ScheduleType.Recording)
                {
                    var upcomingRecordings = Proxies.ControlService.GetUpcomingRecordings(schedule.ScheduleId, true).Result;
                    foreach (UpcomingRecording recording in upcomingRecordings)
                    {
                        item = CreateListItem(recording.Program, recording, null);
                        _viewsList.Add(item);
                    }
                }
                else
                {
                    Schedule sched            = Proxies.SchedulerService.GetScheduleById(schedule.ScheduleId).Result;
                    var      upcomingPrograms = Proxies.SchedulerService.GetUpcomingPrograms(sched, true).Result;
                    foreach (UpcomingProgram upcomingProgram in upcomingPrograms)
                    {
                        item = CreateListItem(upcomingProgram, null, null);
                        _viewsList.Add(item);
                    }
                }

                _isInSubDirectory = true;
            }

            string strObjects = string.Format("{0}", _viewsList.Count - (_viewsList.Count > 0 && _viewsList[0].Label == _parentDirectoryLabel ? 1 : 0));

            GUIPropertyManager.SetProperty("#itemcount", strObjects);

            OnSort();
            UpdateButtonStates();
            UpdateProperties();

            if (GetItemCount() > 0)
            {
                if (_isInSubDirectory)
                {
                    while (m_iSelectedItemInFolder >= GetItemCount() && m_iSelectedItemInFolder > 0)
                    {
                        m_iSelectedItemInFolder--;
                    }
                    GUIControl.SelectItemControl(GetID, _viewsList.GetID, m_iSelectedItemInFolder);
                }
                else
                {
                    while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0)
                    {
                        m_iSelectedItem--;
                    }
                    GUIControl.SelectItemControl(GetID, _viewsList.GetID, m_iSelectedItem);
                }
            }
        }
Beispiel #22
0
        private GUIListItem CreateListItem(UpcomingProgram upcomingProgram, UpcomingRecording recording, ScheduleSummary schedule)
        {
            GUIListItem item = new GUIListItem();

            if (schedule != null)
            {
                //create list with schedules
                item.Label    = schedule.Name;
                item.IsFolder = true;
                Utils.SetDefaultIcons(item);
                item.PinImage = Utility.GetLogoForSchedule(schedule.ScheduleType, schedule.IsOneTime, schedule.IsActive);
                item.TVTag    = schedule;
                item.IsPlayed = !schedule.IsActive;
            }
            else
            {
                //create list with Upcoming Programs
                string title = upcomingProgram.CreateProgramTitle();
                item.Label = title;
                string logoImagePath = Utility.GetLogoImage(upcomingProgram.Channel);
                if (!Utils.FileExistsInCache(logoImagePath))
                {
                    item.Label    = String.Format("[{0}] {1}", upcomingProgram.Channel.DisplayName, title);
                    logoImagePath = "defaultVideoBig.png";
                }
                item.PinImage = Utility.GetIconImageFileName(_currentProgramType, upcomingProgram.IsPartOfSeries,
                                                             upcomingProgram.CancellationReason, recording);
                item.TVTag          = upcomingProgram;
                item.ThumbnailImage = logoImagePath;
                item.IconImageBig   = logoImagePath;
                item.IconImage      = logoImagePath;
                item.Label2         = String.Format("{0} {1} - {2}", Utility.GetShortDayDateString(upcomingProgram.StartTime),
                                                    upcomingProgram.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                    upcomingProgram.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));
                item.IsPlayed = upcomingProgram.IsCancelled;
            }
            return(item);
        }
Beispiel #23
0
        public int Compare(GUIListItem item1, GUIListItem item2)
        {
            int result = 0;

            int resultLower = m_bSortAscending ? -1 : 1;
            int resultUpper = -resultLower;

            if (item1 == item2 || item1 == null || item2 == null)
            {
                return(0);
            }
            if (item1.IsFolder && !item2.IsFolder)
            {
                return(-1);
            }
            else if (!item1.IsFolder && item2.IsFolder)
            {
                return(1);
            }
            else if (item1.IsFolder && item2.IsFolder)
            {
                switch (_currentSortMethod)
                {
                case SortMethod.Channel:
                case SortMethod.Date:
                case SortMethod.Name:
                    result = resultUpper * String.Compare(item1.Label, item2.Label, true);
                    if (result == 0)
                    {
                        ScheduleSummary schedule1 = item1.TVTag as ScheduleSummary;
                        ScheduleSummary schedule2 = item2.TVTag as ScheduleSummary;
                        result = (schedule1.LastModifiedTime < schedule2.LastModifiedTime) ? resultUpper : resultLower;
                    }
                    break;
                }
            }
            else
            {
                UpcomingProgram Upcoming1 = item1.TVTag as UpcomingProgram;
                UpcomingProgram Upcoming2 = item2.TVTag as UpcomingProgram;

                switch (_currentSortMethod)
                {
                case SortMethod.Name:
                    result = resultUpper * String.Compare(Upcoming1.Title, Upcoming2.Title, true);
                    if (result == 0)
                    {
                        goto case SortMethod.Channel;
                    }
                    break;

                case SortMethod.Channel:
                    result = resultUpper * String.Compare(Upcoming1.Channel.CombinedDisplayName, Upcoming2.Channel.DisplayName, true);
                    if (result == 0)
                    {
                        goto case SortMethod.Date;
                    }
                    break;

                case SortMethod.Date:
                    if (Upcoming1.StartTime != Upcoming2.StartTime)
                    {
                        result = (Upcoming1.StartTime < Upcoming2.StartTime) ? resultUpper : resultLower;
                    }
                    break;
                }
            }
            return(result);
        }