Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();

            rrMgr = new RemoteRecorderManagementClient();

            if (selfSigned)
            {
                // For self-signed servers
                EnsureCertificateValidation();
            }
        }
Exemple #2
0
        /// <summary>
        /// Get full list of remote recorders the user has access to
        /// </summary>
        /// <param name="userID">User name</param>
        /// <param name="userKey">User password</param>
        /// <returns>Full list of remote recorders to their ID in a Dictionary</returns>
        public static Dictionary <string, Guid> GetRemoteRecorders(string userID, string userKey)
        {
            // Variable used to get data
            PanoptoRemoteRecorderManagement.RemoteRecorderManagementClient recorderMgr      = new RemoteRecorderManagementClient();
            PanoptoRemoteRecorderManagement.AuthenticationInfo             recorderAuthInfo = new PanoptoRemoteRecorderManagement.AuthenticationInfo()
            {
                UserKey  = userID,
                Password = userKey
            };
            PanoptoRemoteRecorderManagement.Pagination recorderPagination = new PanoptoRemoteRecorderManagement.Pagination {
                MaxNumberResults = resultPerPage, PageNumber = 0
            };

            // Get data once
            PanoptoRemoteRecorderManagement.ListRecordersResponse recorderResponse = recorderMgr.ListRecorders(recorderAuthInfo,
                                                                                                               recorderPagination,
                                                                                                               PanoptoRemoteRecorderManagement.RecorderSortField.Name);

            Dictionary <string, Guid> remoteRecorderInfo = new Dictionary <string, Guid>();

            System.Collections.ArrayList duplicates = new System.Collections.ArrayList();
            foreach (RemoteRecorder rr in recorderResponse.PagedResults)
            {
                recorderAdd(remoteRecorderInfo, rr, duplicates);
            }

            // While there are more data remaining, get data
            int totalResults   = recorderResponse.TotalResultCount;
            int currentResults = resultPerPage;

            while (currentResults < totalResults)
            {
                recorderPagination.PageNumber += 1;
                recorderResponse = recorderMgr.ListRecorders(recorderAuthInfo,
                                                             recorderPagination,
                                                             PanoptoRemoteRecorderManagement.RecorderSortField.Name);
                foreach (RemoteRecorder rr in recorderResponse.PagedResults)
                {
                    recorderAdd(remoteRecorderInfo, rr, duplicates);
                }
                currentResults += resultPerPage;
            }

            return(remoteRecorderInfo);
        }
Exemple #3
0
        /// <summary>
        /// Sets up the access to the server.
        /// </summary>
        /// <param name="userName">The username of the account that has access to schedule recordings.</param>
        /// <param name="password">The password associated with the account <paramref name="userName"/>.</param>
        /// <param name="siteName">The name of the site in which to gain access to.</param>
        /// <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>
        public static void SetupSiteAccess(string userName,
                                           string password,
                                           string siteName,
                                           out IRemoteRecorderManagement rrMgr,
                                           out Utilities.RemoteRecorderManagement42.AuthenticationInfo rrAuth,
                                           out ISessionManagement sessionMgr,
                                           out Utilities.SessionManagement46.AuthenticationInfo sessionAuth)
        {
            if (siteName == "")
            {
                // sitename was not configured
                throw new System.Configuration.ConfigurationErrorsException("Sitename was not configured.");
            }
            // rr manager setup
            rrMgr = new RemoteRecorderManagementClient(
                new BasicHttpBinding(BasicHttpSecurityMode.Transport)
            {
                MaxReceivedMessageSize = Properties.Settings.Default.HttpBindingMessageSize,
                SendTimeout            = Properties.Settings.Default.HttpBindingTimeout,
                ReceiveTimeout         = Properties.Settings.Default.HttpBindingTimeout
            },
                new EndpointAddress("https://" + siteName + "/Panopto/PublicAPI/4.2/RemoteRecorderManagement.svc")
                );

            // rr auth info setup
            rrAuth          = new Utilities.RemoteRecorderManagement42.AuthenticationInfo();
            rrAuth.UserKey  = userName;
            rrAuth.Password = password;

            // session manager setup
            sessionMgr = new SessionManagementClient(
                new BasicHttpBinding(BasicHttpSecurityMode.Transport)
            {
                MaxReceivedMessageSize = Properties.Settings.Default.HttpBindingMessageSize,
                SendTimeout            = Properties.Settings.Default.HttpBindingTimeout,
                ReceiveTimeout         = Properties.Settings.Default.HttpBindingTimeout
            },
                new EndpointAddress("https://" + siteName + "/Panopto/PublicAPI/4.6/SessionManagement.svc")
                );

            // session auth info
            sessionAuth          = new Utilities.SessionManagement46.AuthenticationInfo();
            sessionAuth.UserKey  = userName;
            sessionAuth.Password = password;
        }
        // RemoteRecorderManagement.ListRecorders() (Gets the list of all recorders and allows filtering by recorder name.)
        // RemoteRecorderManagement.ScheduleRecording() (Creates a new recording on a particular remote recorder.)
        // RemoteRecorderManagement.UpdateRecordingTime() (Allows modification of a previously scheduled recording.)

        public RemoteRecorderManagementWrapper(string user, string password)
        {
            // Instantiate service clients
            this.remoteRecorderManager = new RemoteRecorderManagementClient();


            // Ensure server certificate is validated
            CertificateValidation.EnsureCertificateValidation();

            // Create auth info. For this sample, we will be passing auth info into all of the PublicAPI web service calls
            // instead of using IAuth.LogonWithPassword() (which is the alternative method).
            this.authenticationInfo = new AuthenticationInfo()
            {
                UserKey  = user,
                Password = password
            };

            // Set default DateTime format
            this.dateTimeFormat = ConfigurationManager.AppSettings["dateTimeFormat"] ?? "dd-MMM-yyyy hh:mm tt";
        }
Exemple #5
0
        /// <summary>
        /// Starts a new recording session.
        /// </summary>
        /// <param name="recorder">Recorder Client to schedule the new session.</param>
        /// <param name="authInfo">Panopto user Authentication info.</param>
        /// <param name="sessionLength">The session duration in minutes.</param>
        /// <param name="sessionName">The new session name.</param>
        /// <param name="folderId">The id of the folder where the new session will be located.</param>
        /// <param name="recorderId">The id of the remote recorder that will be used to record the new session.</param>
        /// <returns>Returns the schedule result.</returns>
        public static ScheduledRecordingResult StartRecordingSession(RemoteRecorderManagementClient recorder, AuthenticationInfo authInfo, int sessionLength, string sessionName, Guid folderId, Guid recorderId)
        {
            // Creates the recording settings list
            List <RecorderSettings>  recorderSettings = new List <RecorderSettings>();
            ScheduledRecordingResult sr = null;

            try
            {
                // Sets the remote recording id in the recording settings
                recorderSettings.Add(new RecorderSettings {
                    RecorderId = recorderId
                });

                // Schedules a new recording session that will start at the current time.
                sr = recorder.ScheduleRecording(authInfo, sessionName, folderId, false, DateTime.Now, DateTime.Now.AddMinutes(sessionLength), recorderSettings.ToArray());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(sr);
        }
Exemple #6
0
        /// <summary>
        /// Constructor to create a RemoteRecorderManagement including
        /// necessary information to create the SOAP API calls
        /// </summary>
        /// <param name="site">Panopto Site</param>
        /// <param name="username">admin username</param>
        /// <param name="password">password associated with username</param>
        public RemoteRecorderManagementWrapper(string site, string username, string password)
        {
            // Update Service endpoint to reflect specified server name
            UriBuilder userManagementUriBuilder = new UriBuilder();

            userManagementUriBuilder.Scheme = "https";
            userManagementUriBuilder.Host   = site;
            userManagementUriBuilder.Path   = @"Panopto/PublicAPI/4.2/RemoteRecorderManagement.svc";

            this.remoteRecorderManager = new RemoteRecorderManagementClient(
                new BasicHttpBinding(BasicHttpSecurityMode.Transport)
            {
                MaxReceivedMessageSize = 10000000,
                SendTimeout            = TimeSpan.FromMinutes(10),
                ReceiveTimeout         = TimeSpan.FromMinutes(10)
            },
                new EndpointAddress(userManagementUriBuilder.Uri));

            this.authentication = new AuthenticationInfo()
            {
                UserKey  = username,
                Password = password
            };
        }
Exemple #7
0
 /// <summary>
 /// Stops the recording of a session that is currently recording.
 /// </summary>
 /// <param name="recorder">Recorder Client that is executing the session.</param>
 /// <param name="authInfo">Panopto user Authenticaion info.</param>
 /// <param name="sessionId">The session to be stopped.</param>
 /// <returns>Returns the schedule result.</returns>
 public static ScheduledRecordingResult StopSessionRecording(RemoteRecorderManagementClient recorder, AuthenticationInfo authInfo, Guid sessionId)
 {
     // Updates the recording setting the current time as the finish time. That will stop the current session recording.
     return(recorder.UpdateRecordingTime(authInfo, sessionId, DateTime.Now, DateTime.Now));
 }
Exemple #8
0
        /// <summary>
        /// Main application method
        /// </summary>
        static void Main(string[] args)
        {
            try
            {
                // Parse args
                if (!ParseArgs(args))
                {
                    Usage();
                    return;
                }

                // Instantiate service clients
                ISessionManagement sessionMgr = new SessionManagementClient();
                IRemoteRecorderManagement rrMgr = new RemoteRecorderManagementClient();

                // Ensure server certificate is validated
                EnsureCertificateValidation();

                // Create auth info. For this sample, we will be passing auth info into all of the PublicAPI web service calls
                // instead of using IAuth.LogonWithPassword() (which is the alternative method).
                SessionManagementService.AuthenticationInfo sessionAuthInfo = new SessionManagementService.AuthenticationInfo()
                                                                              {
                                                                                  UserKey = user,
                                                                                  Password = password
                                                                              };

                RemoteRecorderManagementService.AuthenticationInfo rrAuthInfo = new RemoteRecorderManagementService.AuthenticationInfo()
                                                                                {
                                                                                    UserKey = user,
                                                                                    Password = password
                                                                                };

                int resultPerPage = 10;
                int totalResult = 0;
                int readResult = 0;
                int pageNumber = 0;
                Folder folder = null;
                // Find folder
                do
                {
                    ScheduleTool.SessionManagementService.Pagination pagination = new ScheduleTool.SessionManagementService.Pagination { MaxNumberResults = resultPerPage, PageNumber = pageNumber };
                    ListFoldersResponse response = sessionMgr.GetFoldersList(sessionAuthInfo, new ListFoldersRequest { Pagination = pagination }, null);
                    folder = response.Results.FirstOrDefault(a => a.Name == folderName);

                    totalResult = response.TotalNumberResults;
                    readResult += resultPerPage;
                    pageNumber++;

                    if (folder != null)
                    {
                        break;
                    }
                } while (readResult < totalResult);

                Assert(folder != null, "Could not find specified folder - " + folderName);

                // Find RR
                totalResult = 0;
                readResult = 0;
                pageNumber = 0;
                RemoteRecorder recorder = null;
                do
                {
                    ScheduleTool.RemoteRecorderManagementService.Pagination rrPagination = new ScheduleTool.RemoteRecorderManagementService.Pagination { MaxNumberResults = resultPerPage, PageNumber = pageNumber };
                    ListRecordersResponse rrResponse = rrMgr.ListRecorders(rrAuthInfo, rrPagination, RecorderSortField.Name);
                    recorder = rrResponse.PagedResults.FirstOrDefault(a => a.Name == rrName);

                    totalResult = rrResponse.TotalResultCount;
                    readResult += resultPerPage;
                    pageNumber++;

                    if (recorder != null)
                    {
                        break;
                    }
                } while (readResult < totalResult);

                Assert(recorder != null, "Could not find specified recorder - " + rrName);
                List<ScheduleTool.RemoteRecorderManagementService.RecorderSettings> recorderSettings = new List<RecorderSettings>();
                recorderSettings.Add(new RecorderSettings { RecorderId = recorder.Id });

                // Schedule back-to-back recordings
                DateTime timeBase = DateTime.UtcNow;

                for (int i = 0; i < numRecordings; i++)
                {
                    DateTime startTime = timeBase + TimeSpan.FromMinutes(recordingMins * i);
                    DateTime endTime = timeBase + TimeSpan.FromMinutes(recordingMins * (i + 1));
                    ScheduledRecordingResult result = rrMgr.ScheduleRecording(rrAuthInfo, "TestRecording" + (i+1).ToString(), folder.Id, false, startTime, endTime, recorderSettings.ToArray());
                    Assert(!result.ConflictsExist, "Unable to schedule test recording due to conflicts");
                }

                Console.WriteLine("Recordings have been scheduled");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }