From a1ef3159870682725edcd6743bbd234c8914f98b Mon Sep 17 00:00:00 2001 From: Asher Finkel Date: Thu, 20 Jul 2023 17:37:15 -0400 Subject: [PATCH] Add TemplateId as an option for scheduling recordings --- .gitignore | 3 +- .../RecorderScheduleCSVParser.cs | 17 ++-- .../RecorderScheduleXmlElement.cs | 2 + .../RecorderScheduleXmlParser.cs | 7 +- PanoptoScheduleUploader.Core/Recording.cs | 1 + .../SetRecordingSchedules.cs | 6 +- .../RemoteRecorderManagementWrapper.cs | 10 ++- .../RemoteRecorderManagement/Reference.cs | 86 ++++++++++++++++++- .../PanoptoScheduleUploader.Test.csproj | 24 +++++- .../WhenCsvUploaded.cs | 31 +++++++ .../WhenXmlUploaded.cs | 70 +++++++++++---- PanoptoScheduleUploader.Test/app.config | 6 ++ PanoptoScheduleUploader.Test/packages.config | 4 + PanoptoScheduleUploader.Test/validCsv.csv | 3 + PanoptoScheduleUploader.Test/validXml.xml | 10 ++- .../validXml_BadTemplateId.xml | 13 +++ PanoptoScheduleUploader.UI/MainWindow.xaml | 4 +- PanoptoScheduleUploader.UI/MainWindow.xaml.cs | 6 +- sample.xml | 8 ++ sample2.csv | 1 + 20 files changed, 276 insertions(+), 36 deletions(-) create mode 100644 PanoptoScheduleUploader.Test/WhenCsvUploaded.cs create mode 100644 PanoptoScheduleUploader.Test/app.config create mode 100644 PanoptoScheduleUploader.Test/packages.config create mode 100644 PanoptoScheduleUploader.Test/validCsv.csv create mode 100644 PanoptoScheduleUploader.Test/validXml_BadTemplateId.xml diff --git a/.gitignore b/.gitignore index 3de1dda..38c3c77 100644 --- a/.gitignore +++ b/.gitignore @@ -359,4 +359,5 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +.idea diff --git a/PanoptoScheduleUploader.Core/RecorderScheduleCSVParser.cs b/PanoptoScheduleUploader.Core/RecorderScheduleCSVParser.cs index c293872..3380ffb 100644 --- a/PanoptoScheduleUploader.Core/RecorderScheduleCSVParser.cs +++ b/PanoptoScheduleUploader.Core/RecorderScheduleCSVParser.cs @@ -20,7 +20,8 @@ public class RecorderScheduleCSVParser private int endTimeIndex = 4; private int presenterIndex = 5; private int folderIndex = 6; - private int webcast = 7; + private int webcastIndex = 7; + private int templateIdIndex = 8; /// /// Initializes a new instance of the RecorderScheduleCSVParser class. @@ -71,18 +72,23 @@ public IEnumerable ExtractRecordings() var startTime = DateTime.Parse(string.Format("{0} {1}", elements[dateIndex], elements[startTimeIndex])); var endTime = DateTime.Parse(string.Format("{0} {1}", elements[dateIndex], elements[endTimeIndex])); bool b = false; - if (elements[webcast] == "1") + if (elements[webcastIndex] == "1") { b = true; } - else if (elements[webcast] == "0") + else if (elements[webcastIndex] == "0") { b = false; } else { - bool.TryParse(elements[webcast], out b); + bool.TryParse(elements[webcastIndex], out b); } + + var templateId = elements.Length <= templateIdIndex + ? (Guid?)null + : Guid.Parse(elements[templateIdIndex]); + recorderSchedules.Add(new Recording { Title = elements[titleIndex], @@ -93,7 +99,8 @@ public IEnumerable ExtractRecordings() EndTime = endTime, Presenter = elements[presenterIndex], CourseTitle = elements[folderIndex], - RecordingDate = elements[dateIndex] + RecordingDate = elements[dateIndex], + TemplateId = templateId }); } } diff --git a/PanoptoScheduleUploader.Core/RecorderScheduleXmlElement.cs b/PanoptoScheduleUploader.Core/RecorderScheduleXmlElement.cs index 384cd2e..484d286 100644 --- a/PanoptoScheduleUploader.Core/RecorderScheduleXmlElement.cs +++ b/PanoptoScheduleUploader.Core/RecorderScheduleXmlElement.cs @@ -29,6 +29,7 @@ public RecorderScheduleXmlElement(XmlNode recorderScheduleNode) this.RecordingEndTime = recorderScheduleNode.SelectSingleNode("RecordingEndTime") != null ? recorderScheduleNode.SelectSingleNode("RecordingEndTime").InnerText : ""; this.Presenter = recorderScheduleNode.SelectSingleNode("Presenter") != null ? recorderScheduleNode.SelectSingleNode("Presenter").InnerText : ""; this.CourseTitle = recorderScheduleNode.SelectSingleNode("CourseTitle") != null ? recorderScheduleNode.SelectSingleNode("CourseTitle").InnerText : ""; + this.TemplateId = recorderScheduleNode.SelectSingleNode("TemplateId") != null ? recorderScheduleNode.SelectSingleNode("TemplateId").InnerText : ""; if (!this.HasAllValues) { @@ -43,6 +44,7 @@ public RecorderScheduleXmlElement(XmlNode recorderScheduleNode) public string RecordingEndTime { get; set; } public string Presenter { get; set; } public string CourseTitle { get; set; } + public string TemplateId { get; set; } /// /// Gets a value indicating whether the node contains values for all the expected properties on a RecorderSchedule node. diff --git a/PanoptoScheduleUploader.Core/RecorderScheduleXmlParser.cs b/PanoptoScheduleUploader.Core/RecorderScheduleXmlParser.cs index b558b62..adae8c3 100644 --- a/PanoptoScheduleUploader.Core/RecorderScheduleXmlParser.cs +++ b/PanoptoScheduleUploader.Core/RecorderScheduleXmlParser.cs @@ -54,6 +54,10 @@ public IEnumerable ExtractRecordings() var startTime = DateTime.Parse(string.Format("{0} {1}", recorderScheduleXmlElement.RecordingDate, recorderScheduleXmlElement.RecordingStartTime)); var endTime = DateTime.Parse(string.Format("{0} {1}", recorderScheduleXmlElement.RecordingDate, recorderScheduleXmlElement.RecordingEndTime)); + var templateId = string.IsNullOrWhiteSpace(recorderScheduleXmlElement.TemplateId) + ? (Guid?)null + : Guid.Parse(recorderScheduleXmlElement.TemplateId); + recorderSchedules.Add(new Recording { Title = recorderScheduleXmlElement.Class, @@ -64,7 +68,8 @@ public IEnumerable ExtractRecordings() EndTime = endTime, Presenter = recorderScheduleXmlElement.Presenter, CourseTitle = recorderScheduleXmlElement.CourseTitle, - RecordingDate = recorderScheduleXmlElement.RecordingDate + RecordingDate = recorderScheduleXmlElement.RecordingDate, + TemplateId = templateId }); } } diff --git a/PanoptoScheduleUploader.Core/Recording.cs b/PanoptoScheduleUploader.Core/Recording.cs index 45f6131..96eb590 100644 --- a/PanoptoScheduleUploader.Core/Recording.cs +++ b/PanoptoScheduleUploader.Core/Recording.cs @@ -16,5 +16,6 @@ public class Recording public string Presenter { get; set; } public string CourseTitle { get; set; } public string RecordingDate { get; set; } + public Guid? TemplateId { get; set; } } } diff --git a/PanoptoScheduleUploader.Core/SetRecordingSchedules.cs b/PanoptoScheduleUploader.Core/SetRecordingSchedules.cs index 106cced..2c7d064 100644 --- a/PanoptoScheduleUploader.Core/SetRecordingSchedules.cs +++ b/PanoptoScheduleUploader.Core/SetRecordingSchedules.cs @@ -47,10 +47,10 @@ public static IEnumerable Execute(string username, string pass count++; Trace.WriteLine($"{count}: {recording.Title}"); - RecorderSettings settings; + RecorderTemplatesWithSettings settings; try { - settings = remoteRecorderService.GetSettingsByRecorderName(recording.RecorderName); + settings = remoteRecorderService.GetSettingsByRecorderName(recording.RecorderName, recording.TemplateId); } catch (Exception) { @@ -102,7 +102,7 @@ public static IEnumerable Execute(string username, string pass throw new Exception(string.Format("The folder named '{0}' does not exist. This folder must exist as the default location for recordings.", defaultFolderName)); } } - var result = remoteRecorderService.ScheduleRecording(recording.Title, folderId, recording.IsBroadCast, recording.StartTime, recording.EndTime, new List { settings }, overwritten); + var result = remoteRecorderService.ScheduleRecording(recording.Title, folderId, recording.IsBroadCast, recording.StartTime, recording.EndTime, new List { settings }, overwritten); if (result.SessionId != Guid.Empty) { sessionManager.UpdateSessionDescription(result.SessionId, "Presented by " + recording.Presenter); diff --git a/PanoptoScheduleUploader.Services/RemoteRecorderManagementWrapper.cs b/PanoptoScheduleUploader.Services/RemoteRecorderManagementWrapper.cs index d4c5002..165fde1 100644 --- a/PanoptoScheduleUploader.Services/RemoteRecorderManagementWrapper.cs +++ b/PanoptoScheduleUploader.Services/RemoteRecorderManagementWrapper.cs @@ -42,7 +42,7 @@ public RemoteRecorderManagementWrapper(string user, string password) this.dateTimeFormat = ConfigurationManager.AppSettings["dateTimeFormat"] ?? "dd-MMM-yyyy hh:mm tt"; } - public RecorderSettings GetSettingsByRecorderName(string name) + public RecorderTemplatesWithSettings GetSettingsByRecorderName(string name, Guid? templateId) { try { @@ -52,7 +52,11 @@ public RecorderSettings GetSettingsByRecorderName(string name) return null; } - return new RecorderSettings { RecorderId = recorder.Id }; + return new RecorderTemplatesWithSettings + { + TemplateId = templateId, + RecorderSettings = new RecorderSettings { RecorderId = recorder.Id } + }; } catch (Exception) { @@ -130,7 +134,7 @@ private void EnsureRecorders() } } - public SchedulingResult ScheduleRecording(string name, Guid folderId, bool isBroadcast, DateTime startTime, DateTime endTime, List settings, bool overwritten) + public SchedulingResult ScheduleRecording(string name, Guid folderId, bool isBroadcast, DateTime startTime, DateTime endTime, List settings, bool overwritten) { if (!folderId.Equals(Guid.Empty)) { diff --git a/PanoptoScheduleUploader.Services/Service References/RemoteRecorderManagement/Reference.cs b/PanoptoScheduleUploader.Services/Service References/RemoteRecorderManagement/Reference.cs index 328987e..e49d32e 100644 --- a/PanoptoScheduleUploader.Services/Service References/RemoteRecorderManagement/Reference.cs +++ b/PanoptoScheduleUploader.Services/Service References/RemoteRecorderManagement/Reference.cs @@ -603,7 +603,67 @@ protected void RaisePropertyChanged(string propertyName) { } } } - + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] + [System.Runtime.Serialization.DataContractAttribute(Name="RecorderTemplatesWithSettings", Namespace="http://schemas.datacontract.org/2004/07/Panopto.Server.Services.PublicAPI.V40")] + [System.SerializableAttribute()] + public partial class RecorderTemplatesWithSettings : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged { + [System.NonSerializedAttribute()] + private System.Runtime.Serialization.ExtensionDataObject extensionDataField; + + [global::System.ComponentModel.BrowsableAttribute(false)] + public System.Runtime.Serialization.ExtensionDataObject ExtensionData { + get { + return this.extensionDataField; + } + set { + this.extensionDataField = value; + } + } + + [System.Runtime.Serialization.OptionalFieldAttribute()] + private System.Nullable TemplateIdField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public System.Nullable TemplateId { + get { + return this.TemplateIdField; + } + set { + if ((object.ReferenceEquals(this.TemplateIdField, value) != true)) { + this.TemplateIdField = value; + this.RaisePropertyChanged("TemplateId"); + } + } + } + + [System.Runtime.Serialization.OptionalFieldAttribute()] + private PanoptoScheduleUploader.Services.RemoteRecorderManagement.RecorderSettings RecorderSettingsField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public PanoptoScheduleUploader.Services.RemoteRecorderManagement.RecorderSettings RecorderSettings { + get { + return this.RecorderSettingsField; + } + set { + if ((object.ReferenceEquals(this.RecorderSettingsField, value) != true)) { + this.RecorderSettingsField = value; + this.RaisePropertyChanged("RecorderSettings"); + } + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] [System.Runtime.Serialization.DataContractAttribute(Name="ScheduledRecordingResult", Namespace="http://schemas.datacontract.org/2004/07/Panopto.Server.Services.PublicAPI.V42.Soa" + @@ -797,6 +857,9 @@ public interface IRemoteRecorderManagement { [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRemoteRecorderManagement/ScheduleRecording", ReplyAction="http://tempuri.org/IRemoteRecorderManagement/ScheduleRecordingResponse")] PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult ScheduleRecording(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, string name, System.Guid folderId, bool isBroadcast, System.DateTime start, System.DateTime end, System.Collections.Generic.List recorderSettings); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRemoteRecorderManagement/ScheduleRecording", ReplyAction="http://tempuri.org/IRemoteRecorderManagement/ScheduleRecordingResponse")] + PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult ScheduleRecording(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, string name, System.Guid folderId, bool isBroadcast, System.DateTime start, System.DateTime end, System.Collections.Generic.List recorderTemplatesWithSettings); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRemoteRecorderManagement/ScheduleRecurringRecording", ReplyAction="http://tempuri.org/IRemoteRecorderManagement/ScheduleRecurringRecordingResponse")] PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult ScheduleRecurringRecording(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid scheduledSessionId, System.Collections.Generic.List daysOfWeek, System.DateTime end); @@ -806,11 +869,17 @@ public interface IRemoteRecorderManagement { [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRemoteRecorderManagement/UpdateRecordingSettings", ReplyAction="http://tempuri.org/IRemoteRecorderManagement/UpdateRecordingSettingsResponse")] PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult UpdateRecordingSettings(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid sessionId, System.Collections.Generic.List recorderSettings); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRemoteRecorderManagement/UpdateRecordingSettings", ReplyAction="http://tempuri.org/IRemoteRecorderManagement/UpdateRecordingSettingsResponse")] + PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult UpdateRecordingSettings(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid sessionId, System.Collections.Generic.List recorderTemplatesWithSettings); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRemoteRecorderManagement/GetDefaultFolderForRecorder", ReplyAction="http://tempuri.org/IRemoteRecorderManagement/GetDefaultFolderForRecorderResponse")] System.Guid GetDefaultFolderForRecorder(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid remoteRecorderId); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRemoteRecorderManagement/GetMachineSidForRecorder", ReplyAction="http://tempuri.org/IRemoteRecorderManagement/GetMachineSidForRecorderResponse")] string GetMachineSidForRecorder(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid remoteRecorderId); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRemoteRecorderManagement/GetRemoteRecorderTemplateIds", ReplyAction="http://tempuri.org/IRemoteRecorderManagement/GetRemoteRecorderTemplateIds")] + string GetRemoteRecorderTemplateIds(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid remoteRecorderId); } [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] @@ -860,6 +929,11 @@ public PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecord return base.Channel.ScheduleRecording(auth, name, folderId, isBroadcast, start, end, recorderSettings); } + + public PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult ScheduleRecording(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, string name, System.Guid folderId, bool isBroadcast, System.DateTime start, System.DateTime end, System.Collections.Generic.List recorderTemplatesWithSettings) { + return base.Channel.ScheduleRecording(auth, name, folderId, isBroadcast, start, end, recorderTemplatesWithSettings); + } + public PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult ScheduleRecurringRecording(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid scheduledSessionId, System.Collections.Generic.List daysOfWeek, System.DateTime end) { return base.Channel.ScheduleRecurringRecording(auth, scheduledSessionId, daysOfWeek, end); } @@ -871,7 +945,11 @@ public PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecord public PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult UpdateRecordingSettings(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid sessionId, System.Collections.Generic.List recorderSettings) { return base.Channel.UpdateRecordingSettings(auth, sessionId, recorderSettings); } - + + public PanoptoScheduleUploader.Services.RemoteRecorderManagement.ScheduledRecordingResult UpdateRecordingSettings(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid sessionId, System.Collections.Generic.List recorderTemplatesWithSettings) { + return base.Channel.UpdateRecordingSettings(auth, sessionId, recorderTemplatesWithSettings); + } + public System.Guid GetDefaultFolderForRecorder(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid remoteRecorderId) { return base.Channel.GetDefaultFolderForRecorder(auth, remoteRecorderId); } @@ -879,5 +957,9 @@ public System.Guid GetDefaultFolderForRecorder(PanoptoScheduleUploader.Services. public string GetMachineSidForRecorder(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid remoteRecorderId) { return base.Channel.GetMachineSidForRecorder(auth, remoteRecorderId); } + + public string GetRemoteRecorderTemplateIds(PanoptoScheduleUploader.Services.RemoteRecorderManagement.AuthenticationInfo auth, System.Guid remoteRecorderId) { + return base.Channel.GetRemoteRecorderTemplateIds(auth, remoteRecorderId); + } } } diff --git a/PanoptoScheduleUploader.Test/PanoptoScheduleUploader.Test.csproj b/PanoptoScheduleUploader.Test/PanoptoScheduleUploader.Test.csproj index 9537e45..d77f4fd 100644 --- a/PanoptoScheduleUploader.Test/PanoptoScheduleUploader.Test.csproj +++ b/PanoptoScheduleUploader.Test/PanoptoScheduleUploader.Test.csproj @@ -1,5 +1,6 @@  + Debug AnyCPU @@ -36,7 +37,9 @@ false - + + ..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll + 3.5 @@ -49,6 +52,7 @@ + @@ -61,9 +65,15 @@ Always + + Always + Always + + Always + Always @@ -71,7 +81,19 @@ Always + + + Designer + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + +