private async void DoDisplayProgramInfo(List<IProgram> programs) { bool multiselection = programs.Count > 1; if (programs.FirstOrDefault() != null) { try { this.Cursor = Cursors.WaitCursor; ProgramInformation form = new ProgramInformation(this, _context) { MyProgram = programs.FirstOrDefault(), MyStreamingEndpoints = dataGridViewStreamingEndpointsV.DisplayedStreamingEndpoints, // we pass this information if user open asset info from the program info dialog box MultipleSelection = multiselection }; if (form.ShowDialog() == DialogResult.OK) { var modifications = form.Modifications; if (multiselection) { var formSettings = new SettingsSelection("programs", modifications); if (formSettings.ShowDialog() != DialogResult.OK) { return; } else { modifications = (ExplorerProgramModifications)formSettings.SettingsObject; } } foreach (var program in programs) { if (modifications.ArchiveWindow) { program.ArchiveWindowLength = form.archiveWindowLength; } if (modifications.Description) { program.Description = form.ProgramDescription; } await Task.Run(() => ProgramExecuteAsync(program.UpdateAsync, program, "updated")); } } } finally { this.Cursor = Cursors.Arrow; } } }
private async void DoDisplayStreamingEndpointInfo(List<IStreamingEndpoint> streamingendpoints) { // Refresh the context _context = Program.ConnectAndGetNewContext(_credentials); bool multiselection = streamingendpoints.Count > 1; StreamingEndpointInformation form = new StreamingEndpointInformation() { MyStreamingEndpoint = streamingendpoints.FirstOrDefault(), MyContext = _context, MultipleSelection = multiselection }; if (form.ShowDialog() == DialogResult.OK) { var modifications = form.Modifications; if (multiselection) { var formSettings = new SettingsSelection("streaming endpoints", modifications); if (formSettings.ShowDialog() != DialogResult.OK) { return; } else { modifications = (ExplorerSEModifications)formSettings.SettingsObject; } } foreach (var streamingendpoint in streamingendpoints) { if (modifications.CustomHostNames) { streamingendpoint.CustomHostNames = form.GetStreamingCustomHostnames; } if (modifications.StreamingAllowedIPAddresses) { if (form.GetStreamingAllowList != null) { if (streamingendpoint.AccessControl == null) { streamingendpoint.AccessControl = new StreamingEndpointAccessControl(); } streamingendpoint.AccessControl.IPAllowList = form.GetStreamingAllowList; } else { if (streamingendpoint.AccessControl != null) { streamingendpoint.AccessControl.IPAllowList = null; } } } if (modifications.AkamaiSignatureHeaderAuthentication) { if (form.GetStreamingAkamaiList != null) { if (streamingendpoint.AccessControl == null) { streamingendpoint.AccessControl = new StreamingEndpointAccessControl(); } streamingendpoint.AccessControl.AkamaiSignatureHeaderAuthenticationKeyList = form.GetStreamingAkamaiList; } else { if (streamingendpoint.AccessControl != null) { streamingendpoint.AccessControl.AkamaiSignatureHeaderAuthenticationKeyList = null; } } } if (modifications.MaxCacheAge) { if (form.MaxCacheAge != null) { if (streamingendpoint.CacheControl == null) { streamingendpoint.CacheControl = new StreamingEndpointCacheControl(); } streamingendpoint.CacheControl.MaxAge = form.MaxCacheAge; } else { if (streamingendpoint.CacheControl != null) { streamingendpoint.CacheControl.MaxAge = null; } } } // Client Access Policy if (modifications.ClientAccessPolicy) { if (form.GetOriginClientPolicy != null) { if (streamingendpoint.CrossSiteAccessPolicies == null) { streamingendpoint.CrossSiteAccessPolicies = new CrossSiteAccessPolicies(); } streamingendpoint.CrossSiteAccessPolicies.ClientAccessPolicy = form.GetOriginClientPolicy; } else { if (streamingendpoint.CrossSiteAccessPolicies != null) { streamingendpoint.CrossSiteAccessPolicies.ClientAccessPolicy = null; } } } // Cross domain Policy if (modifications.CrossDomainPolicy) { if (form.GetOriginCrossdomaintPolicy != null) { if (streamingendpoint.CrossSiteAccessPolicies == null) { streamingendpoint.CrossSiteAccessPolicies = new CrossSiteAccessPolicies(); } streamingendpoint.CrossSiteAccessPolicies.CrossDomainPolicy = form.GetOriginCrossdomaintPolicy; } else { if (streamingendpoint.CrossSiteAccessPolicies != null) { streamingendpoint.CrossSiteAccessPolicies.CrossDomainPolicy = null; } } } if (modifications.Description) { streamingendpoint.Description = form.GetOriginDescription; } // Let's take actions now if (modifications.StreamingUnits && streamingendpoint.ScaleUnits != form.GetScaleUnits) { Task.Run(async () => { await StreamingEndpointExecuteOperationAsync(streamingendpoint.SendUpdateOperationAsync, streamingendpoint, "updated"); await ScaleStreamingEndpoint(streamingendpoint, form.GetScaleUnits); }); } else // no scaling { Task.Run(async () => { await StreamingEndpointExecuteOperationAsync(streamingendpoint.SendUpdateOperationAsync, streamingendpoint, "updated"); }); } } } }
private async void DoDisplayChannelInfo(List<IChannel> channels) { var firstchannel = channels.FirstOrDefault(); bool multiselection = channels.Count > 1; if (firstchannel != null) { ChannelInformation form = new ChannelInformation(this) { MyChannel = firstchannel, MyContext = _context, MultipleSelection = multiselection }; if (form.ShowDialog() == DialogResult.OK) { var modifications = form.Modifications; if (multiselection) { var formSettings = new SettingsSelection("channels", modifications); if (formSettings.ShowDialog() != DialogResult.OK) { return; } else { modifications = (ExplorerChannelModifications)formSettings.SettingsObject; } } foreach (var channel in channels) { TextBoxLogWriteLine("Channel '{0}' : updating...", channel.Name); if (modifications.Description) // let' update description if needed { channel.Description = form.GetChannelDescription; } if (modifications.KeyFrameInterval) { channel.Input.KeyFrameInterval = form.KeyframeInterval; } if (channel.EncodingType == firstchannel.EncodingType) { if (channel.EncodingType != ChannelEncodingType.None && channel.Encoding != null && channel.State == ChannelState.Stopped) { if (modifications.SystemPreset) { channel.Encoding.SystemPreset = form.SystemPreset; // we update the system preset } if (modifications.AudioStreams) // user modified it { channel.Encoding.AudioStreams = form.AudioStreamList; } if (modifications.VideoStreams) // user modified it { channel.Encoding.VideoStreams = form.VideoStreamList; } } else if (channel.EncodingType != ChannelEncodingType.None && channel.State != ChannelState.Stopped) { TextBoxLogWriteLine("Channel '{0}' : must be stoped to update the encoding settings", channel.Name); } else if (channel.EncodingType != ChannelEncodingType.None && channel.Encoding == null) { TextBoxLogWriteLine("Channel '{0}' : configured as encoding channel but settings are null", channel.Name, true); } } if (modifications.HLSFragPerSegment) { // HLS Fragment per segment if (form.HLSFragPerSegment != null) { if (channel.Output == null) { channel.Output = new ChannelOutput() { Hls = new ChannelOutputHls() { FragmentsPerSegment = form.HLSFragPerSegment } }; } else if (channel.Output.Hls == null) { channel.Output.Hls = new ChannelOutputHls() { FragmentsPerSegment = form.HLSFragPerSegment }; } else { channel.Output.Hls.FragmentsPerSegment = form.HLSFragPerSegment; } } else // form.HLSFragPerSegment is null { if (channel.Output != null && channel.Output.Hls != null && channel.Output.Hls.FragmentsPerSegment != null) { channel.Output.Hls.FragmentsPerSegment = null; } } } if (modifications.InputIPAllowList) { // Input allow list if (form.GetInputIPAllowList != null) { if (channel.Input.AccessControl == null) { channel.Input.AccessControl = new ChannelAccessControl(); } channel.Input.AccessControl.IPAllowList = form.GetInputIPAllowList; } else { if (channel.Input.AccessControl != null) { channel.Input.AccessControl.IPAllowList = null; } } } if (modifications.PreviewIPAllowList) { // Preview allow list if (form.GetPreviewAllowList != null) { if (channel.Preview.AccessControl == null) { channel.Preview.AccessControl = new ChannelAccessControl(); } channel.Preview.AccessControl.IPAllowList = form.GetPreviewAllowList; } else { if (channel.Preview.AccessControl != null) { channel.Preview.AccessControl.IPAllowList = null; } } } if (modifications.ClientAccessPolicy) { // Client Access Policy if (form.GetChannelClientPolicy != null) { if (channel.CrossSiteAccessPolicies == null) { channel.CrossSiteAccessPolicies = new CrossSiteAccessPolicies(); } channel.CrossSiteAccessPolicies.ClientAccessPolicy = form.GetChannelClientPolicy; } else { if (channel.CrossSiteAccessPolicies != null) { channel.CrossSiteAccessPolicies.ClientAccessPolicy = null; } } } if (modifications.CrossDomainPolicy) { // Cross domain Policy if (form.GetChannelCrossdomainPolicy != null) { if (channel.CrossSiteAccessPolicies == null) { channel.CrossSiteAccessPolicies = new CrossSiteAccessPolicies(); } channel.CrossSiteAccessPolicies.CrossDomainPolicy = form.GetChannelCrossdomainPolicy; } else { if (channel.CrossSiteAccessPolicies != null) { channel.CrossSiteAccessPolicies.CrossDomainPolicy = null; } } } await Task.Run(() => ChannelInfo.ChannelExecuteOperationAsync(channel.SendUpdateOperationAsync, channel, "updated", _context, this, dataGridViewChannelsV)); } } } }