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(); if (origin.ScaleUnits != null) { _MyObservStreamingEndpoints[index].ScaleUnits = (int)origin.ScaleUnits; this.Refresh(); } } } }
public void RefreshProgram(string liveeventName, LiveOutput program) { int index = -1; if (_MyObservLiveOutputs != null) { foreach (LiveOutputEntry CE in _MyObservLiveOutputs) // let's search for index { if (CE.Name == program.Name) { index = _MyObservLiveOutputs.IndexOf(CE); break; } } } if (index >= 0) // we found it { // we update the observation collection _client.RefreshTokenIfNeeded(); program = _client.AMSclient.LiveOutputs.Get(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, liveeventName, program.Name); //refresh if (program != null) { try // sometimes, index could be wrong id program has been deleted { _MyObservLiveOutputs[index].State = program.ResourceState; _MyObservLiveOutputs[index].Description = program.Description; _MyObservLiveOutputs[index].ArchiveWindowLength = program.ArchiveWindowLength; _MyObservLiveOutputs[index].LastModified = program.LastModified != null ? (DateTime?)((DateTime)program.LastModified).ToLocalTime() : null; this.Refresh(); } catch { } } } }