Esempio n. 1
0
 public static void Parse(CsvReader csvReader,
                          IRemoteRecorderManagement rrMgr,
                          Utilities.RemoteRecorderManagement42.AuthenticationInfo rrAuth,
                          ISessionManagement sessionMgr,
                          Utilities.SessionManagement46.AuthenticationInfo sessionAuth,
                          DateTime startDate,
                          DateTime endDate,
                          int lineNumber,
                          string term,
                          List <ScheduleRecording> schedule,
                          Dictionary <int, RecordingValidityCode> badSchedules,
                          Dictionary <ScheduleRecording, int> recordingToLine)
 {
     while (csvReader.Read())
     {
         // maybe problem due to inconsistent header lengths (with/without exclusion date header) or can just ignore and continue
         // and the Sunday sheet example where there is nothing, header check might catch and ignore this case though
         if (csvReader.Context.Record.Length != Formats[SupportedFileType.Georgetown].Length)
         {
             // if the number of fields is not good, then continue to the next record
             badSchedules.Add(lineNumber, RecordingValidityCode.ParseError);
         }
         else if (csvReader.Context.Record[1] == "")
         {
             // skip it: this line was probably scheduled manually
         }
         else
         {
             RecurringRecording record = csvReader.GetRecord <RecurringRecording>();
             record.FolderName += "." + term;
             ParseCommon(rrMgr,
                         rrAuth,
                         sessionMgr,
                         sessionAuth,
                         record,
                         lineNumber,
                         schedule,
                         badSchedules,
                         recordingToLine);
         }
         lineNumber++;
         if (lineNumber % 10 == 0)
         {
             Console.WriteLine(lineNumber);
         }
     }
 }
Esempio n. 2
0
 public static void Parse(CsvReader csvReader,
                          IRemoteRecorderManagement rrMgr,
                          Utilities.RemoteRecorderManagement42.AuthenticationInfo rrAuth,
                          ISessionManagement sessionMgr,
                          Utilities.SessionManagement46.AuthenticationInfo sessionAuth,
                          int lineNumber,
                          DateTime startDate,
                          DateTime endDate,
                          string term,
                          List <ScheduleRecording> schedule,
                          Dictionary <int, RecordingValidityCode> badSchedules,
                          Dictionary <ScheduleRecording, int> recordingToLine)
 {
     while (csvReader.Read())
     {
         if (csvReader.Context.Record.Length != Formats[SupportedFileType.Banner].Length)
         {
             // if the number of fields is not good, then continue to the next record
             badSchedules.Add(lineNumber, RecordingValidityCode.ParseError);
         }
         else
         {
             RecurringRecording record = csvReader.GetRecord <RecurringRecording>();
             // Put in start date and end date record index 6 and 7 for times
             // Don't adjust the start date onto the cadence here, adjust at schedule time.
             record.StartDate = ParseTime(startDate, csvReader.Context.Record[6], BannerTimeFormat);
             record.EndDate   = ParseTime(endDate, csvReader.Context.Record[7], BannerTimeFormat);
             // Use local time to calculate recording duration due to UTC conversion causing negative durations
             // with the use of TimeOfDay. Alternate solutions include subtracting days from end and start so that they are
             // on the same day but that introduces lots of overhead and more calculations.
             record.Duration    = record.EndDate.ToLocalTime().TimeOfDay - record.StartDate.ToLocalTime().TimeOfDay;
             record.FolderName += term;
             ParseCommon(rrMgr,
                         rrAuth,
                         sessionMgr,
                         sessionAuth,
                         record,
                         lineNumber,
                         schedule,
                         badSchedules,
                         recordingToLine);
         }
         lineNumber++;
     }
 }
Esempio n. 3
0
        private void onShowUpClick(object sender, EventArgs e)
        {
            int index = this.mChannelsListBox.SelectedIndex;
            RecurringRecordingList list = this.mRecurringChannels[index];

            index = this.mShowsListBox.SelectedIndex;
            if (index == 0)
            {
                return;
            }

            object display = this.mShowsListBox.Items[index];

            this.mShowsListBox.Items[index]     = this.mShowsListBox.Items[index - 1];
            this.mShowsListBox.Items[index - 1] = display;

            RecurringRecording rec = list[index];

            list[index]     = list[index - 1];
            list[index - 1] = rec;

            this.mShowsListBox.SelectedIndex = index - 1;
        }
Esempio n. 4
0
        private void onTrashDownClick(object sender, EventArgs e)
        {
            int index = this.mChannelsListBox.SelectedIndex;
            RecurringRecordingList recList = this.mRecurringChannels[index];

            index = this.mShowsListBox.SelectedIndex;
            RecurringRecording rec = recList[index];
            RecurringChannel   channel;

            if (this.mRecurringTrashCount == 0)
            {
                channel = new RecurringChannel(rec.ChannelOID, rec.ChannelName, recList);
                channel.Shows.Add(rec);
                this.mRecurringTrash[this.mRecurringTrashCount++] = channel;
                this.mTrashChannelsListBox.Items.Add(string.Concat(channel.Name, " | 1"));
            }
            else
            {
                int i = 0;
                channel = this.mRecurringTrash[i];
                while (i < this.mRecurringTrashCount && channel.OID != rec.ChannelOID)
                {
                    channel = this.mRecurringTrash[++i];
                }
                if (i == this.mRecurringTrashCount)
                {
                    channel = new RecurringChannel(rec.ChannelOID, rec.ChannelName, recList);
                    channel.Shows.Add(rec);
                    this.mRecurringTrash[this.mRecurringTrashCount++] = channel;
                    this.mTrashChannelsListBox.Items.Add(string.Concat(channel.Name, " | 1"));
                }
                else
                {
                    channel.Shows.Add(rec);
                    this.mTrashChannelsListBox.Items[i] = string.Concat(channel.Name, " | ", channel.Shows.Count.ToString());
                }
            }
            if (recList.Count > 1)
            {
                this.mShowsListBox.SelectedIndex = index == 0 ? 1 : index - 1;
            }
            recList.RemoveAt(index);
            this.mShowsListBox.Items.RemoveAt(index);
            if (recList.Count == 0)
            {
                index = this.mChannelsListBox.SelectedIndex;
                if (this.mRecurringChannelCount > 1)
                {
                    this.mChannelsListBox.SelectedIndex = index == 0 ? 1 : index - 1;
                }
                this.mRecurringChannelCount--;
                for (int j = index; j < this.mRecurringChannelCount; j++)
                {
                    this.mRecurringChannels[j] = this.mRecurringChannels[j + 1];
                }
                this.mChannelsListBox.Items.RemoveAt(index);
            }
            this.mChannelUpButton.Enabled   = this.mRecurringChannelCount > 1;
            this.mChannelDownButton.Enabled = this.mRecurringChannelCount > 1;
            this.mTrashUpButton.Enabled     = true;
            this.mTrashDownButton.Enabled   = this.mRecurringChannelCount == 0;
        }
Esempio n. 5
0
        private void onTrashUpClick(object sender, EventArgs e)
        {
            int index = this.mTrashChannelsListBox.SelectedIndex;
            RecurringChannel channel = this.mRecurringTrash[index];

            index = this.mTrashShowsListBox.SelectedIndex;
            RecurringRecording     show = channel.Shows[index];
            RecurringRecordingList recList;

            if (this.mRecurringChannelCount == 0)
            {
                recList = channel.List;
                recList.Add(show);
                this.mRecurringChannels[this.mRecurringChannelCount++] = recList;
                this.mChannelsListBox.Items.Add(string.Concat(channel.Name, " | 1"));
            }
            else
            {
                int i = 0;
                recList = this.mRecurringChannels[i];
                while (i < this.mRecurringChannelCount && recList.ChannelOID != channel.OID)
                {
                    recList = this.mRecurringChannels[++i];
                }
                if (i == this.mRecurringChannelCount)
                {
                    recList = channel.List;
                    recList.Add(show);
                    this.mRecurringChannels[this.mRecurringChannelCount++] = recList;
                    this.mChannelsListBox.Items.Add(string.Concat(channel.Name, " | 1"));
                }
                else
                {
                    recList.Add(show);
                    this.mChannelsListBox.Items[i] = string.Concat(channel.Name, " | ", recList.Count.ToString());
                }
            }
            if (channel.Shows.Count > 1)
            {
                this.mTrashShowsListBox.SelectedIndex = index == 0 ? 1 : index - 1;
            }
            channel.Shows.RemoveAt(index);
            this.mTrashShowsListBox.Items.RemoveAt(index);
            if (channel.Shows.Count == 0)
            {
                index = this.mTrashChannelsListBox.SelectedIndex;
                if (this.mRecurringTrashCount > 0)
                {
                    this.mTrashChannelsListBox.SelectedIndex = index == 0 ? 1 : index - 1;
                }
                this.mRecurringTrashCount--;
                for (int j = index; j < this.mRecurringTrashCount; j++)
                {
                    this.mRecurringTrash[j] = this.mRecurringTrash[j + 1];
                }
                this.mTrashChannelsListBox.Items.RemoveAt(index);
            }
            this.mChannelUpButton.Enabled   = this.mRecurringChannelCount > 1;
            this.mChannelDownButton.Enabled = this.mRecurringChannelCount > 1;
            this.mTrashUpButton.Enabled     = this.mRecurringTrashCount == 0;
            this.mTrashDownButton.Enabled   = true;
        }
Esempio n. 6
0
        /// <summary>
        /// Takes the recording client and authentication, and attempts to schedule sessions provided in <paramref name="schedule"/>.
        /// </summary>
        /// <param name="rrMgr">The client in which holds the information about the recorders available.</param>
        /// <param name="rrAuth">The authentication information for which to access the information from <paramref name="rrMgr"/>.</param>
        /// <param name="schedule">The recording schedule.</param>
        /// <param name="sender">The BackgroundWorker to make this method asynchronous.</param>
        /// <returns>The results of the scheduling attempt.</returns>
        public static Dictionary <ScheduleRecording, ScheduledRecordingResult> ScheduleRecordings(
            IRemoteRecorderManagement rrMgr,
            Utilities.RemoteRecorderManagement42.AuthenticationInfo rrAuth,
            List <ScheduleRecording> schedule,
            BackgroundWorker sender)
        {
            Dictionary <ScheduleRecording, ScheduledRecordingResult> result = new Dictionary <ScheduleRecording, ScheduledRecordingResult>();

            for (int i = 0; i < schedule.Count; i++)
            {
                if (sender != null)
                {
                    sender.ReportProgress(i + 1);
                }
                else
                {
                    Console.WriteLine("Scheduling recording " + (i + 1) + "/" + schedule.Count + "...");
                }
                ScheduleRecording scheduleRecording = schedule[i];
                try
                {
                    // Currently only concerned with 1 RR for each session
                    RecorderSettings rs = new RecorderSettings()
                    {
                        RecorderId = scheduleRecording.RecorderID
                    };
                    RecurringRecording recurring = null;
                    // need to check to make sure start date is on cadence and adjust as needed if recurring.
                    if ((scheduleRecording as RecurringRecording) != null)
                    {
                        scheduleRecording.StartDate = AdjustDateOntoCadence(
                            scheduleRecording.StartDate,
                            ((RecurringRecording)scheduleRecording).Cadence);
                        // since we need to schedule the first occurrence, this is for accurate success/conflict counting
                        recurring = new RecurringRecording((RecurringRecording)scheduleRecording);
                    }
                    ScheduledRecordingResult scheduledResult = rrMgr.ScheduleRecording(
                        rrAuth,
                        scheduleRecording.SessionName,
                        scheduleRecording.FolderID,
                        scheduleRecording.IsBroadcast || Properties.Settings.Default.ScheduleBroadcasts,
                        scheduleRecording.StartDate,
                        scheduleRecording.StartDate + scheduleRecording.Duration,
                        new RecorderSettings[] { rs });
                    result.Add(scheduleRecording, scheduledResult);
                    if ((scheduleRecording as RecurringRecording) != null && !result[scheduleRecording].ConflictsExist)
                    {
                        // need to transform recurring.Cadence to a DayOfWeek[]
                        DayOfWeek[] days = CadenceToArray(recurring.Cadence);
                        // update the dictionary since this is recurring recording.
                        scheduledResult = rrMgr.ScheduleRecurringRecording(rrAuth,
                                                                           result[scheduleRecording].SessionIDs[0],
                                                                           days,
                                                                           recurring.EndDate);
                        result.Add(recurring, scheduledResult);
                    }
                }
                catch
                {
                    // Since something went wrong with scheduling, still log it in result to report it later.
                    result.Add(scheduleRecording, new ScheduledRecordingResult()
                    {
                        ConflictsExist = true
                    });
                }
            }
            return(result);
        }