Beispiel #1
0
 /// <summary>
 /// Common method calls an actions for all parsers.
 /// </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="sessionMgr">The client in which holds the information about the sessions.</param>
 /// <param name="sessionAuth">The authentication information for which to access the information from <paramref name="sessionMgr"/>.</param>
 /// <param name="record">The line currently being parsed.</param>
 /// <param name="lineNumber">The line number on the original file.</param>
 /// <param name="schedule">The schedule to update after <paramref name="record"/> is parsed.</param>
 /// <param name="badSchedules">The mappings from line number to error code to be populated, if needed.</param>
 /// <param name="recordingToLine">The mappings from recording to line number.</param>
 public static void ParseCommon(IRemoteRecorderManagement rrMgr,
                                Utilities.RemoteRecorderManagement42.AuthenticationInfo rrAuth,
                                ISessionManagement sessionMgr,
                                Utilities.SessionManagement46.AuthenticationInfo sessionAuth,
                                ScheduleRecording record,
                                int lineNumber,
                                List <ScheduleRecording> schedule,
                                Dictionary <int, RecordingValidityCode> badSchedules,
                                Dictionary <ScheduleRecording, int> recordingToLine)
 {
     // Now grab the IDs if possible and set them in the object
     record.RecorderID = Checker.GetRecorderID(record.RecorderName, rrMgr, rrAuth);
     if (record.FolderName != "" && record.FolderID == Guid.Empty)
     {
         // a specific folder was specified so try to look it up
         record.FolderID = Checker.GetFolderID(record.FolderName, sessionMgr, sessionAuth);
     }
     else if (record.FolderName == "" && record.RecorderID != Guid.Empty)
     {
         // case for a default folder/unspecified folder
         // Each RR has their own default folder, so call that and directly get folderID from that
         record.FolderID = rrMgr.GetDefaultFolderForRecorder(rrAuth, record.RecorderID);
         // Need to update the FolderName if we used the remote recorder's default folder
         Folder[] folder = sessionMgr.GetFoldersById(sessionAuth, new Guid[] { record.FolderID });
         record.FolderName = folder[0].Name;
     }
     if (record.CheckValidity() != RecordingValidityCode.Valid)
     {
         badSchedules.Add(lineNumber, record.CheckValidity());
     }
     recordingToLine.Add(record, lineNumber);
     schedule.Add(record);
 }
Beispiel #2
0
 public static void Parse(CsvReader csvReader,
                          IRemoteRecorderManagement rrMgr,
                          Utilities.RemoteRecorderManagement42.AuthenticationInfo rrAuth,
                          ISessionManagement sessionMgr,
                          Utilities.SessionManagement46.AuthenticationInfo sessionAuth,
                          int lineNumber,
                          List <ScheduleRecording> schedule,
                          Dictionary <int, RecordingValidityCode> badSchedules,
                          Dictionary <ScheduleRecording, int> recordingToLine)
 {
     while (csvReader.Read())
     {
         if (csvReader.Context.Record.Length != Formats[SupportedFileType.Legacy].Length)
         {
             // if the number of fields is not good, then continue to the next record
             badSchedules.Add(lineNumber, RecordingValidityCode.ParseError);
         }
         else
         {
             ScheduleRecording record = csvReader.GetRecord <ScheduleRecording>();
             ParseCommon(rrMgr,
                         rrAuth,
                         sessionMgr,
                         sessionAuth,
                         record,
                         lineNumber,
                         schedule,
                         badSchedules,
                         recordingToLine);
         }
         lineNumber++;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Prints the information of <paramref name="sr"/>.
 /// </summary>
 /// <param name="sr">The ScheduleRecording object of which to print the information of.</param>
 private static void PrintScheduleRecordingInfo(ScheduleRecording sr, TextWriter writer)
 {
     writer.WriteLine("SessionName:               " + sr.SessionName);
     writer.WriteLine("Recorder ID:               " + sr.RecorderID);
     writer.WriteLine("Recorder Name:             " + sr.RecorderName);
     writer.WriteLine("Folder ID:                 " + sr.FolderID);
     writer.WriteLine("Folder Name:               " + sr.FolderName);
     writer.WriteLine("Start Date:                " + sr.StartDate.ToLocalTime());
     writer.WriteLine("Duration:                  " + sr.Duration);
     writer.WriteLine("Presenter:                 " + sr.Presenter);
     writer.WriteLine("Broadcast:                 " + sr.IsBroadcast);
 }
Beispiel #4
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);
        }