Beispiel #1
0
        /// <summary>
        /// Finds a Panopto user by username (creates them if they do not already exist)
        /// </summary>
        private static UserManagement.User GetUser(string sUserID)
        {
            //Note: Panopto supports multiple identity providers (IDP).
            //In this example code, we are going to assume that our users are stored in Active Directory (AD)

            //Identity Provider/Domain
            string sIDP = "essex.ac.uk//";

            //Local variables
            UserManagement.User uPanopto;
            string sUsername;

            //UserID depends on how you are storing Lecturer identities in CMIS. This could be their AD login, StaffID, or something else.
            //Essex gives staff a uniqueID (not their AD login), so we have to lookup each user.
            //For brevity, we'll just assume username = userID
            sUsername = sUserID; //ie. CMIS LecturerIDs are the same as AD logins

            //Create UserManagement Client
            UserManagement.UserManagementClient UMC = new UserManagement.UserManagementClient();

            //We are looking for an individual user by username, Panopto provides a quick method to look this up
            uPanopto = UMC.GetUserByKey(UserAuthentication(), sIDP + sUsername);

            //Check if the returned user object is null. If it it, means user doesn't exist in Panopto.
            if (uPanopto == null)
            {
                //I'm going to be lazy and not duplicate the code used to grab a user from Active Directory
                //There's an excellent guide on importing users from AD into Panopto at http://www.mediaguy.co.uk/panopto-api/panopto-api-301-creating-users-and-groups-from-ad/

                //For this example we will just assume everyone is called Foo Bar
                uPanopto = new UserManagement.User()
                {
                    UserKey   = sIDP + sUsername,
                    FirstName = "Foo",
                    LastName  = "Bar",
                    Email     = sUsername + "@essex.ac.uk",
                    EmailSessionNotifications = false,
                    SystemRole = UserManagement.SystemRole.None,
                    UserBio    = String.Empty,
                };

                //Add the user to Panopto, get back the Guid of the newly added user
                Guid gUser = UMC.CreateUser(UserAuthentication(), uPanopto, String.Empty); //No need for password as user is authenticating via AD

                //Finally, add the now-known guid to our user object and return
                uPanopto.UserId = gUser;
                return(uPanopto);
            }
            else
            {
                //We have the user
                return(uPanopto);
            }
        }
Beispiel #2
0
        private static void Process(int iLookAheadHours)
        {
            //Get the CMIS timetable for the next ?? hours
            IEnumerable <DataRow> dtTimetable = GetTimetable(iLookAheadHours);

            //Iterate through each event in the timetable
            foreach (DataRow drEvent in dtTimetable)
            {
                //Try/Catch. If this particular event has problems, we probably want the loop to continue
                try
                {
                    //Firstly, check there is a remote recorder in this location
                    RemoteRecorderManagement.RemoteRecorder rRecorder = GetRecorder(drEvent.Field <string>("RoomId"));

                    //If we have a recorder, then we can record this room/event
                    if (rRecorder != null)
                    {
                        //Get/create the folder for this recording
                        SessionManagement.Folder fFolder = GetFolder(drEvent.Field <string>("LecturerIds"));

                        //Ensure that the owner of this recording has access to said folder
                        //The data from CMIS stores multiple lecturers as CSV data inside the LecturerIds field. eg. LECT001, LECT002, LECT003
                        //Ideally, we would split this into an array and ensure that each lecturer had creator access on the folder
                        foreach (string sUser in drEvent.Field <string>("LecturerIds").Split(','))
                        {
                            //Another try/catch block - Panopto will throw an exception if user doesn't exist or already has permission
                            try
                            {
                                //Get/create the user
                                UserManagement.User uUser = GetUser(sUser);

                                //Create AccessManagement Client
                                AccessManagement.AccessManagementClient AMC = new AccessManagement.AccessManagementClient();
                                //Give user permission on our folder
                                AMC.GrantUsersAccessToFolder(AccessAuthentication(), fFolder.Id, new Guid[] { uUser.UserId }, AccessManagement.AccessRole.Creator);
                            } catch (Exception ex)
                            {
                                //Do nothing
                            }
                        }

                        //Now, we schedule the recording
                        //Create the RemoteRecorderManagement client
                        RemoteRecorderManagement.RemoteRecorderManagementClient RMC = new RemoteRecorderManagement.RemoteRecorderManagementClient();

                        //Name this recording
                        string sName = drEvent.Field <string>("ModuleIds") + " - " + drEvent.Field <string>("RoomId") + " - " + drEvent.Field <DateTime>("StartTime"); //Module, Location, Time
                        //Build the RemoteRecorderSettings object:
                        RemoteRecorderManagement.RecorderSettings RecorderSetting = new RemoteRecorderManagement.RecorderSettings()
                        {
                            RecorderId = rRecorder.Id
                        };
                        //Schedule the recording
                        //Note that we trim 1 minute from the end of the recording to give the remoterecorder time to recover between back-to-back recordings
                        RemoteRecorderManagement.ScheduledRecordingResult RemoteRecorderResult = RMC.ScheduleRecording(RemoteRecorderAuthentication(), sName, fFolder.Id, false, drEvent.Field <DateTime>("StartTime").ToUniversalTime(), drEvent.Field <DateTime>("StartTime").ToUniversalTime().AddMinutes(-1), new RemoteRecorderManagement.RecorderSettings[] { RecorderSetting });

                        //Check that the event was scheduled properly
                        if (!RemoteRecorderResult.ConflictsExist)
                        {
                            //Nothing clashed

                            //We're only adding a single schedule, so can grab first DeliveryID
                            Guid gDeliveryIGuid = RemoteRecorderResult.SessionIDs.FirstOrDefault();
                            //At this point you could store the Guid in a database somewhere, to keep track of Panopto sessions and CMIS events
                        }
                        else
                        {
                            //The schedule was not created because it clashes with an existing schedule on this remote recorder
                            //Our new schedule has not been added to Panopto
                            //RemoteRecorderResult.ConflictingSessions will tell us the DeliveryIDs of the existing sessions
                        }
                    }
                    ;
                }
                catch (Exception ex)
                {
                    //Something happened whilst retrieving the remoterecorder, creating the folder and user, assigning permissions, or scheduling the recording
                    //Deal with this problem as you deem appropriate
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="users"></param>
        /// <returns></returns>
        private static List <OrderDTO> PopulateOrderList(IEnumerable <OrderManagement.Order> orders, UserManagement.User user)
        {
            var orderList = new List <OrderDTO>();

            foreach (var order in orders)
            {
                orderList.Add(new OrderDTO
                {
                    Id              = order.Id,
                    BuyerFirmName   = user.FirmName,
                    BuyerUsername   = user.UserName,
                    Currency        = order.Currency,
                    PaymentType     = order.PaymentType,
                    Name            = user.FirstName + " " + user.SurName,
                    TransactionDate = order.DateCreated.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)
                });
            }
            return(orderList);
        }
Beispiel #4
0
 public ActionResult ResetPassword(UserManagement.User user)
 {
     return(null);
 }