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 ? "CDN" : string.Empty, ScaleUnits = c.ScaleUnits, State = c.State, LastModified = c.LastModified.ToLocalTime(), }; _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; }
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, ScaleUnits = o.ScaleUnits, 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 = 100; this.Columns["Description"].Width = 230; this.Columns["ScaleUnits"].Width = 100; this.Columns["LastModified"].Width = 150; WorkerRefreshStreamingEndpoints = new BackgroundWorker(); WorkerRefreshStreamingEndpoints.WorkerSupportsCancellation = true; WorkerRefreshStreamingEndpoints.DoWork += new System.ComponentModel.DoWorkEventHandler(this.WorkerRefreshStreamingEndpoints_DoWork); _initialized = true; }
public void Init(AMSClientV3 client) { IEnumerable <LiveEventEntry> channelquery; _client = client; var liveevents = _client.AMSclient.LiveEvents.List(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName); channelquery = from c in liveevents.Take(0) orderby c.LastModified descending select new LiveEventEntry { Name = c.Name, Description = c.Description, InputProtocol = string.Format("{0} ({1})", c.Input.StreamingProtocol.ToString() /*Program.ReturnNameForProtocol(c.Input.StreamingProtocol)*/, c.Input.Endpoints.Count), Encoding = ReturnChannelBitmap(c), EncodingPreset = (c.Encoding != null && c.Encoding.EncodingType != LiveEventEncodingType.None) ? c.Encoding.PresetName : string.Empty, InputUrl = c.Input.Endpoints.Count > 0 ? c.Input.Endpoints.FirstOrDefault().Url : string.Empty, PreviewUrl = c.Preview.Endpoints.Count > 0 ? c.Preview.Endpoints.FirstOrDefault().Url : string.Empty, State = c.ResourceState, LastModified = c.LastModified != null ? (DateTime?)((DateTime)c.LastModified).ToLocalTime() : null }; /* * channelquery = from c in _context.Channels.Take(0) * orderby c.LastModified descending * select new ChannelEntry * { * Name = c.Name, * Id = c.Id, * Description = c.Description, * InputProtocol = string.Format("{0} ({1})", Program.ReturnNameForProtocol(c.Input.StreamingProtocol), c.Input.Endpoints.Count), * Encoding = ReturnChannelBitmap(c), * EncodingPreset = (c.EncodingType != ChannelEncodingType.None && c.Encoding != null) ? c.Encoding.SystemPreset : string.Empty, * InputUrl = c.Input.Endpoints.FirstOrDefault().Url, * PreviewUrl = c.Preview.Endpoints.FirstOrDefault().Url, * State = c.State, * LastModified = c.LastModified.ToLocalTime() * }; */ DataGridViewCellStyle cellstyle = new DataGridViewCellStyle() { NullValue = null, Alignment = DataGridViewContentAlignment.MiddleCenter }; DataGridViewImageColumn imageCol = new DataGridViewImageColumn() { DefaultCellStyle = cellstyle, Name = _encoded, DataPropertyName = _encoded, }; this.Columns.Add(imageCol); SortableBindingList <LiveEventEntry> MyObservChannelsInPage = new SortableBindingList <LiveEventEntry>(channelquery.Take(0).ToList()); this.DataSource = MyObservChannelsInPage; this.Columns["InputUrl"].HeaderText = "Primary Input Url"; this.Columns["InputUrl"].Width = 140; this.Columns["InputUrl"].SortMode = DataGridViewColumnSortMode.NotSortable; this.Columns["InputProtocol"].HeaderText = "Input Protocol (input nb)"; this.Columns["InputProtocol"].Width = 180; this.Columns["PreviewUrl"].Width = 120; this.Columns["PreviewUrl"].SortMode = DataGridViewColumnSortMode.NotSortable; this.Columns[_encoded].DisplayIndex = this.ColumnCount - 4; this.Columns[_encoded].DefaultCellStyle.NullValue = null; this.Columns[_encoded].HeaderText = "Cloud Encoding"; this.Columns[_encoded].Width = 100; this.Columns[_encodedPreset].DisplayIndex = this.ColumnCount - 3; this.Columns[_encodedPreset].DefaultCellStyle.NullValue = null; this.Columns[_encodedPreset].HeaderText = "Preset"; this.Columns[_encodedPreset].Width = 100; this.Columns["LastModified"].Width = 140; this.Columns["LastModified"].HeaderText = "Last modified"; this.Columns["State"].Width = 75; this.Columns["Description"].Width = 110; WorkerRefreshChannels = new BackgroundWorker(); WorkerRefreshChannels.WorkerSupportsCancellation = true; WorkerRefreshChannels.DoWork += new System.ComponentModel.DoWorkEventHandler(this.WorkerRefreshChannels_DoWork); _initialized = true; }
public async Task RefreshLiveOutputsAsync(int pagetodisplay) // all assets are refreshed { if (!_initialized) { return; } if (idsList.Count == 0) { return; } Debug.WriteLine("RefreshPrograms : start"); this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); await _client.RefreshTokenIfNeededAsync(); IEnumerable <LiveEvent> ListEvents; if (_anyChannel == enumDisplayProgram.None) { ListEvents = new List <LiveEvent>(); } else { ListEvents = (await _client.AMSclient.LiveEvents.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName)) .ToList() .Where(l => _anyChannel == enumDisplayProgram.Any || (_anyChannel == enumDisplayProgram.Selected && LiveEventSourceNames.Contains(l.Name))); } List <Program.LiveOutputExt> LOList = new List <Program.LiveOutputExt>(); foreach (var le in ListEvents) { var plist = (await _client.AMSclient.LiveOutputs.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, le.Name)) .ToList(); plist.ForEach(p => LOList.Add(new Program.LiveOutputExt() { LiveOutputItem = p, LiveEventName = le.Name })); } var programquery = from c in (LOList) //orderby c.LastModified descending select new LiveOutputEntry { Name = c.LiveOutputItem.Name, State = c.LiveOutputItem.ResourceState, Description = c.LiveOutputItem.Description, ArchiveWindowLength = c.LiveOutputItem.ArchiveWindowLength, LastModified = c.LiveOutputItem.LastModified != null ? (DateTime?)((DateTime)c.LiveOutputItem.LastModified).ToLocalTime() : null, Published = DataGridViewAssets.BuildBitmapPublication(c.LiveOutputItem.AssetName, _client).bitmap, LiveEventName = c.LiveEventName }; _MyObservLiveOutputs = new SortableBindingList <LiveOutputEntry>(programquery.ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservLiveOutputs)); _refreshedatleastonetime = true; this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); Debug.WriteLine("RefreshPrograms : end"); }
public void Init(AMSClientV3 client) { IEnumerable <LiveOutputEntry> programquery; client.RefreshTokenIfNeeded(); _client = client; _client.RefreshTokenIfNeeded(); var ListEvents = _client.AMSclient.LiveEvents.List(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName).ToList(); List <Program.LiveOutputExt> LOList = new List <Program.LiveOutputExt>(); foreach (var le in ListEvents) { var plist = _client.AMSclient.LiveOutputs.List(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, le.Name).ToList(); plist.ForEach(p => LOList.Add(new Program.LiveOutputExt() { LiveOutputItem = p, LiveEventName = le.Name })); } programquery = from c in (LOList.Take(0)) //orderby c.LastModified descending select new LiveOutputEntry { Name = c.LiveOutputItem.Name, State = c.LiveOutputItem.ResourceState, Description = c.LiveOutputItem.Description, ArchiveWindowLength = c.LiveOutputItem.ArchiveWindowLength, LastModified = c.LiveOutputItem.LastModified != null ? (DateTime?)((DateTime)c.LiveOutputItem.LastModified).ToLocalTime() : null, Published = null, LiveEventName = c.LiveEventName }; DataGridViewCellStyle cellstyle = new DataGridViewCellStyle() { NullValue = null, Alignment = DataGridViewContentAlignment.MiddleCenter }; DataGridViewImageColumn imageCol = new DataGridViewImageColumn() { DefaultCellStyle = cellstyle, Name = _published, DataPropertyName = _published, }; this.Columns.Add(imageCol); SortableBindingList <LiveOutputEntry> MyObservProgramInPage = new SortableBindingList <LiveOutputEntry>(programquery.Take(0).ToList()); this.DataSource = MyObservProgramInPage; //this.Columns["LiveEventName"].Visible = false; this.Columns[_published].DisplayIndex = this.ColumnCount - 3; this.Columns[_published].DefaultCellStyle.NullValue = null; this.Columns[_published].HeaderText = _published; this.Columns["LastModified"].Width = 130; this.Columns["LastModified"].HeaderText = "Last modified"; this.Columns["Description"].Width = 150; this.Columns["ArchiveWindowLength"].Width = 130; this.Columns["ArchiveWindowLength"].HeaderText = "Archive window"; this.Columns["LiveEventName"].HeaderText = "Live event name"; WorkerRefreshChannels = new BackgroundWorker(); WorkerRefreshChannels.WorkerSupportsCancellation = true; WorkerRefreshChannels.DoWork += new System.ComponentModel.DoWorkEventHandler(this.WorkerRefreshChannels_DoWork); _initialized = true; }