public void RefreshStreamingEndpoint(IStreamingEndpoint origin) { int index = -1; foreach (StreamingEndpointEntry CE in _MyObservStreamingEndpoints) // let's search for index { if (CE.Id == origin.Id) { index = _MyObservStreamingEndpoints.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection origin = _context.StreamingEndpoints.Where(o => o.Id == origin.Id).FirstOrDefault(); //refresh if (origin != null) { _MyObservStreamingEndpoints[index].State = origin.State; _MyObservStreamingEndpoints[index].Description = origin.Description; _MyObservStreamingEndpoints[index].LastModified = origin.LastModified.ToLocalTime(); _MyObservStreamingEndpoints[index].Type = StreamingEndpointInformation.ReturnTypeSE(origin); _MyObservStreamingEndpoints[index].CDN = origin.CdnEnabled ? StreamingEndpointInformation.ReturnDisplayedProvider(origin.CdnProvider) ?? "CDN" : string.Empty; _MyObservStreamingEndpoints[index].ScaleUnits = StreamingEndpointInformation.ReturnTypeSE(origin) != StreamingEndpointInformation.StreamEndpointType.Premium ? "" : ((int)origin.ScaleUnits).ToString(); this.Refresh(); } } }
public async Task RefreshStreamingEndpointAsync(StreamingEndpoint streamingEndpoint) { int index = -1; foreach (StreamingEndpointEntry CE in _MyObservStreamingEndpoints) // let's search for index { if (CE.Id == streamingEndpoint.Id) { index = _MyObservStreamingEndpoints.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection await _client.RefreshTokenIfNeededAsync(); streamingEndpoint = await _client.AMSclient.StreamingEndpoints.GetAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, streamingEndpoint.Name); //refresh if (streamingEndpoint != null) { _MyObservStreamingEndpoints[index].State = (StreamingEndpointResourceState)streamingEndpoint.ResourceState; _MyObservStreamingEndpoints[index].Description = streamingEndpoint.Description; _MyObservStreamingEndpoints[index].LastModified = ((DateTime)streamingEndpoint.LastModified).ToLocalTime(); _MyObservStreamingEndpoints[index].Type = StreamingEndpointInformation.ReturnTypeSE(streamingEndpoint); _MyObservStreamingEndpoints[index].CDN = ((bool)streamingEndpoint.CdnEnabled) ? StreamingEndpointInformation.ReturnDisplayedProvider(streamingEndpoint.CdnProvider) ?? "CDN" : string.Empty; _MyObservStreamingEndpoints[index].ScaleUnits = StreamingEndpointInformation.ReturnTypeSE(streamingEndpoint) != StreamingEndpointInformation.StreamEndpointType.Premium ? string.Empty : ((int)streamingEndpoint.ScaleUnits).ToString(); this.BeginInvoke(new Action(() => this.Refresh())); } } }
public void RefreshStreamingEndpoints(CloudMediaContext context) { if (!_initialized) { return; } this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); _context = context; IEnumerable <StreamingEndpointEntry> endpointquery; streamingendpoints = context.StreamingEndpoints; _context = context; try { int c = streamingendpoints.Count(); } catch (Exception e) { MessageBox.Show("There is a problem when connecting to Azure Media Services. Application will close. " + e.Message); Environment.Exit(0); } endpointquery = from c in streamingendpoints select new StreamingEndpointEntry { Name = c.Name, Id = c.Id, Description = c.Description, CDN = c.CdnEnabled ? StreamingEndpointInformation.ReturnDisplayedProvider(c.CdnProvider) ?? "CDN" : string.Empty, ScaleUnits = StreamingEndpointInformation.ReturnTypeSE(c) != StreamingEndpointInformation.StreamEndpointType.Premium ? "" : ((int)c.ScaleUnits).ToString(), State = c.State, LastModified = c.LastModified.ToLocalTime(), Type = StreamingEndpointInformation.ReturnTypeSE(c) }; _MyObservStreamingEndpoints = new SortableBindingList <StreamingEndpointEntry>(endpointquery.ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservStreamingEndpoints)); _refreshedatleastonetime = true; this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); }
public async Task RefreshStreamingEndpointsAsync() { if (!_initialized) { return; } this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); IEnumerable <StreamingEndpointEntry> endpointquery; await _client.RefreshTokenIfNeededAsync(); streamingendpoints = await _client.AMSclient.StreamingEndpoints.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName); try { int c = streamingendpoints.Count(); } catch (Exception e) { MessageBox.Show("There is a problem when connecting to Azure Media Services. Application will close. " + e.Message); Environment.Exit(0); } endpointquery = from c in streamingendpoints select new StreamingEndpointEntry { Name = c.Name, Id = c.Id, Description = c.Description, CDN = (bool)c.CdnEnabled ? StreamingEndpointInformation.ReturnDisplayedProvider(c.CdnProvider) ?? "CDN" : string.Empty, ScaleUnits = StreamingEndpointInformation.ReturnTypeSE(c) != StreamingEndpointInformation.StreamEndpointType.Premium ? string.Empty : ((int)c.ScaleUnits).ToString(), State = (StreamingEndpointResourceState)c.ResourceState, LastModified = ((DateTime)c.LastModified).ToLocalTime(), Type = StreamingEndpointInformation.ReturnTypeSE(c) }; _MyObservStreamingEndpoints = new SortableBindingList <StreamingEndpointEntry>(endpointquery.ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservStreamingEndpoints)); this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); }
public void Init(CredentialsEntry credentials, CloudMediaContext context) { IEnumerable <StreamingEndpointEntry> originquery; _credentials = credentials; _context = context; originquery = from o in _context.StreamingEndpoints orderby o.LastModified descending select new StreamingEndpointEntry { Name = o.Name, Id = o.Id, Description = o.Description, CDN = o.CdnEnabled ? StreamingEndpointInformation.ReturnDisplayedProvider(o.CdnProvider) ?? "CDN" : string.Empty, ScaleUnits = StreamingEndpointInformation.ReturnTypeSE(o) != StreamingEndpointInformation.StreamEndpointType.Premium ? "" : ((int)o.ScaleUnits).ToString(), Type = StreamingEndpointInformation.ReturnTypeSE(o), State = o.State, LastModified = o.LastModified.ToLocalTime() }; SortableBindingList <StreamingEndpointEntry> MyObservOriginInPage = new SortableBindingList <StreamingEndpointEntry>(originquery.Take(0).ToList()); this.DataSource = MyObservOriginInPage; this.Columns["Id"].Visible = Properties.Settings.Default.DisplayOriginIDinGrid; this.Columns["Name"].Width = 300; this.Columns["State"].Width = 100; this.Columns["CDN"].Width = 120; this.Columns["Description"].Width = 230; this.Columns["ScaleUnits"].Width = 100; this.Columns["ScaleUnits"].HeaderText = "Streaming Units"; this.Columns["LastModified"].Width = 150; this.Columns["LastModified"].HeaderText = "Last modified"; WorkerRefreshStreamingEndpoints = new BackgroundWorker(); WorkerRefreshStreamingEndpoints.WorkerSupportsCancellation = true; WorkerRefreshStreamingEndpoints.DoWork += new System.ComponentModel.DoWorkEventHandler(this.WorkerRefreshStreamingEndpoints_DoWork); _initialized = true; }
public void Init(AMSClientV3 client) { IEnumerable <StreamingEndpointEntry> originquery; _client = client; _client.RefreshTokenIfNeeded(); originquery = _client.AMSclient.StreamingEndpoints.List(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName).Select(o => new StreamingEndpointEntry { Name = o.Name, Id = o.Id, Description = o.Description, CDN = ((bool)o.CdnEnabled) ? StreamingEndpointInformation.ReturnDisplayedProvider(o.CdnProvider) ?? "CDN" : string.Empty, ScaleUnits = StreamingEndpointInformation.ReturnTypeSE(o) != StreamingEndpointInformation.StreamEndpointType.Premium ? string.Empty : ((int)o.ScaleUnits).ToString(), Type = StreamingEndpointInformation.ReturnTypeSE(o), State = (StreamingEndpointResourceState)o.ResourceState, LastModified = ((DateTime)o.LastModified).ToLocalTime() }); SortableBindingList <StreamingEndpointEntry> MyObservOriginInPage = new SortableBindingList <StreamingEndpointEntry>(originquery.Take(0).ToList()); this.DataSource = MyObservOriginInPage; this.Columns["Name"].Width = 300; this.Columns["State"].Width = 100; this.Columns["CDN"].Width = 120; this.Columns["Description"].Width = 230; this.Columns["ScaleUnits"].Width = 100; this.Columns["ScaleUnits"].HeaderText = "Streaming Units"; this.Columns["LastModified"].Width = 150; this.Columns["LastModified"].HeaderText = "Last modified"; WorkerRefreshStreamingEndpoints = new BackgroundWorker(); WorkerRefreshStreamingEndpoints.WorkerSupportsCancellation = true; WorkerRefreshStreamingEndpoints.DoWork += new System.ComponentModel.DoWorkEventHandler(this.WorkerRefreshStreamingEndpoints_DoWork); _initialized = true; }
private void ChooseStreamingEndpoint_Load(object sender, EventArgs e) { label.Text = string.Format(label.Text, _asset.Name); // SE List IStreamingEndpoint BestSE = AssetInfo.GetBestStreamingEndpoint(_context); foreach (var se in _context.StreamingEndpoints) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnit, se.Name, se.State, StreamingEndpointInformation.ReturnTypeSE(se)), se.Id + "|" + se.HostName)); if (se.Id == BestSE.Id) { listBoxSE.SelectedIndex = listBoxSE.Items.Count - 1; } foreach (var custom in se.CustomHostNames) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnitCustomHostname3, se.Name, se.State, StreamingEndpointInformation.ReturnTypeSE(se), custom), se.Id + "|" + custom)); } } // Filters // asset filters var afilters = _asset.AssetFilters.ToList(); var afiltersnames = afilters.Select(a => a.Name).ToList(); afilters.ForEach(f => { var lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_AssetFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter) { lvitem.Checked = true; } listViewFilters.Items.Add(lvitem); } ); // global filters _context.Filters.ToList().ForEach(f => { var lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_GlobalFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter && listViewFilters.CheckedItems.Count == 0) // only if not already selected (asset filter priority > global filter) { lvitem.Checked = true; } if (afiltersnames.Contains(f.Name)) // global filter with same name than asset filter { lvitem.ForeColor = Color.Gray; } listViewFilters.Items.Add(lvitem); } ); if (_playertype == PlayerType.DASHIFRefPlayer) { radioButtonDASHCSF.Checked = true; } comboBoxBrowser.Items.Add(new Item(AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_DefaultBrowser, string.Empty)); if (_displayBrowserSelection) { // let's add the browser options to lplayback the content (IE, Edge, Chrome...) if (IsWindows10()) { comboBoxBrowser.Items.Add(new Item(Constants.BrowserEdge[0], Constants.BrowserEdge[1])); } comboBoxBrowser.Items.Add(new Item(Constants.BrowserIE[0], Constants.BrowserIE[1])); comboBoxBrowser.Items.Add(new Item(Constants.BrowserChrome[0], Constants.BrowserChrome[1])); comboBoxBrowser.SelectedIndex = 0; } comboBoxBrowser.Visible = _displayBrowserSelection; UpdatePreviewUrl(); }
private async void ChooseStreamingEndpoint_Load(object sender, EventArgs e) { DpiUtils.InitPerMonitorDpi(this); label.Text = string.Format(label.Text, _asset.Name); // SE List await _amsClient.RefreshTokenIfNeededAsync(); // StreamingEndpoint BestSE = Task.Run(async () => await AssetInfo.GetBestStreamingEndpointAsync(_client)).Result; StreamingEndpoint BestSE = await AssetInfo.GetBestStreamingEndpointAsync(_amsClient); var myStreamingEndpoints = Task.Run(() => _amsClient.AMSclient.StreamingEndpoints.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName)).GetAwaiter().GetResult(); foreach (StreamingEndpoint se in myStreamingEndpoints) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnit, se.Name, se.ResourceState, StreamingEndpointInformation.ReturnTypeSE(se)), se.Name + "|" + se.HostName)); if (se.Id == BestSE.Id) { listBoxSE.SelectedIndex = listBoxSE.Items.Count - 1; } foreach (string custom in se.CustomHostNames) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnitCustomHostname3, se.Name, se.ResourceState, StreamingEndpointInformation.ReturnTypeSE(se), custom), se.Name + "|" + custom)); } } // Filters // asset filters Microsoft.Rest.Azure.IPage <AssetFilter> assetFilters = await _amsClient.AMSclient.AssetFilters.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName, _asset.Name); List <string> afiltersnames = assetFilters.Select(a => a.Name).ToList(); listViewFilters.BeginUpdate(); assetFilters.ToList().ForEach(f => { ListViewItem lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_AssetFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter) { lvitem.Checked = true; } listViewFilters.Items.Add(lvitem); } ); // account filters IPage <AccountFilter> acctFilters = await _amsClient.AMSclient.AccountFilters.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName); acctFilters.ToList().ForEach(f => { ListViewItem lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_GlobalFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter && listViewFilters.CheckedItems.Count == 0) // only if not already selected (asset filter priority > account filter) { lvitem.Checked = true; } if (afiltersnames.Contains(f.Name)) // global filter with same name than asset filter { lvitem.ForeColor = Color.Gray; } listViewFilters.Items.Add(lvitem); } ); listViewFilters.EndUpdate(); if (_playertype == PlayerType.DASHIFRefPlayer) { radioButtonDASHCSF.Checked = true; } comboBoxBrowser.Items.Add(new Item(AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_DefaultBrowser, string.Empty)); if (_displayBrowserSelection) { // let's add the browser options to lplayback the content (IE, Edge, Chrome...) if (IsWindows10()) { comboBoxBrowser.Items.Add(new Item(Constants.BrowserEdge[0], Constants.BrowserEdge[1])); } comboBoxBrowser.Items.Add(new Item(Constants.BrowserIE[0], Constants.BrowserIE[1])); comboBoxBrowser.Items.Add(new Item(Constants.BrowserChrome[0], Constants.BrowserChrome[1])); comboBoxBrowser.SelectedIndex = 0; } comboBoxBrowser.Visible = _displayBrowserSelection; UpdatePreviewUrl(); FillLocatorComboInPolicyTab(); }