private void ExportAssetExcel(IAsset asset, Excel.Worksheet xlWorkSheet, int row, bool detailed, bool localtime) { xlWorkSheet.Cells[row, 1] = asset.Name; xlWorkSheet.Cells[row, 2] = asset.Id; xlWorkSheet.Cells[row, 3] = localtime ? asset.LastModified.ToLocalTime() : asset.LastModified; xlWorkSheet.Cells[row, 4] = AssetInfo.GetAssetType(asset); xlWorkSheet.Cells[row, 5] = AssetInfo.GetSize(asset); var url = AssetInfo.GetValidOnDemandURI(asset); xlWorkSheet.Cells[row, 6] = url != null?url.ToString() : string.Empty; if (localtime) { xlWorkSheet.Cells[row, 7] = asset.Locators.Any() ? (DateTime?)asset.Locators.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, 7] = asset.Locators.Any() ? (DateTime?)asset.Locators.Max(l => l.ExpirationDateTime) : null; } if (detailed) { xlWorkSheet.Cells[row, 8] = asset.AlternateId; xlWorkSheet.Cells[row, 9] = asset.StorageAccount.Name; var streamingloc = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin); xlWorkSheet.Cells[row, 10] = streamingloc.Count(); if (localtime) { xlWorkSheet.Cells[row, 11] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null; xlWorkSheet.Cells[row, 12] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, 11] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime) : null; xlWorkSheet.Cells[row, 12] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime) : null; } var sasloc = asset.Locators.Where(l => l.Type == LocatorType.Sas); xlWorkSheet.Cells[row, 13] = sasloc.Count(); if (localtime) { xlWorkSheet.Cells[row, 14] = sasloc.Any() ? (DateTime?)sasloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null; xlWorkSheet.Cells[row, 15] = sasloc.Any() ? (DateTime?)sasloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, 14] = sasloc.Any() ? (DateTime?)sasloc.Min(l => l.ExpirationDateTime) : null; xlWorkSheet.Cells[row, 15] = sasloc.Any() ? (DateTime?)sasloc.Max(l => l.ExpirationDateTime) : null; } xlWorkSheet.Cells[row, 16] = asset.GetEncryptionState(AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash).ToString(); } }
private void listBoxOutputs_SelectedIndexChanged(object sender, EventArgs e) { JobOutput output = MyJob.Outputs.Skip(listBoxOutputs.SelectedIndex).Take(1).FirstOrDefault(); DGOutputs.Rows.Clear(); // DGTasks.Rows.Add(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_Name, task.Name); /* * int i = DGOutputs.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_Configuration, ""); * DataGridViewButtonCell btn = new DataGridViewButtonCell(); * DGOutputs.Rows[i].Cells[1] = btn; * DGOutputs.Rows[i].Cells[1].Value = AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_SeeClearValue; * DGOutputs.Rows[i].Cells[1].Tag = task.GetClearConfiguration(); */ /* * i = DGOutputs.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_Body, ""); * btn = new DataGridViewButtonCell(); * DGOutputs.Rows[i].Cells[1] = btn; * DGOutputs.Rows[i].Cells[1].Value = AMSExplorer.Properties.Resources.AssetInformation_DoDisplayAuthorizationPolicyOption_SeeValue; * DGOutputs.Rows[i].Cells[1].Tag = task.TaskBody; */ DGOutputs.Rows.Add("Progress", output.Progress); DGOutputs.Rows.Add("State", output.State); if (output.GetType() == typeof(JobOutputAsset)) { JobOutputAsset outputA = output as JobOutputAsset; DGOutputs.Rows.Add("Asset name", outputA.AssetName); DGOutputs.Rows.Add("Asset type", AssetInfo.GetAssetType(outputA.AssetName, _client)?.Type); } if (output.Error != null && output.Error.Details != null) { for (int j = 0; j < output.Error.Details.Count(); j++) { DGOutputs.Rows.Add("Error", output.Error.Details[j].Code + ": " + output.Error.Details[j].Message); } } }
private void listBoxInput_SelectedIndexChanged(object sender, EventArgs e) { dataGridInput.Rows.Clear(); if (MyJob.Input.GetType() == typeof(JobInputAsset)) { JobInputAsset inputA = MyJob.Input as JobInputAsset; dataGridInput.Rows.Add("Input type", "asset"); dataGridInput.Rows.Add("Asset name", inputA.AssetName); dataGridInput.Rows.Add("Asset type", AssetInfo.GetAssetType(inputA.AssetName, _client)?.Type); if (inputA.Start != null && inputA.Start.GetType() == typeof(AbsoluteClipTime)) { AbsoluteClipTime startA = inputA.Start as AbsoluteClipTime; dataGridInput.Rows.Add("Absolute Clip Time Start", startA.Time.ToString()); } if (inputA.End != null && inputA.End.GetType() == typeof(AbsoluteClipTime)) { AbsoluteClipTime endA = inputA.End as AbsoluteClipTime; dataGridInput.Rows.Add("Absolute Clip Time End", endA.Time.ToString()); } dataGridInput.Rows.Add("Label", inputA.Label); dataGridInput.Rows.Add("Files", string.Join(Constants.endline, inputA.Files)); } else if (MyJob.Input.GetType() == typeof(JobInputHttp)) { JobInputHttp inputH = MyJob.Input as JobInputHttp; dataGridInput.Rows.Add("Input type", "http"); dataGridInput.Rows.Add("Base Url", inputH.BaseUri); if (inputH.Start != null && inputH.Start.GetType() == typeof(AbsoluteClipTime)) { AbsoluteClipTime startA = inputH.Start as AbsoluteClipTime; dataGridInput.Rows.Add("Absolute Clip Time Start", startA.Time.ToString()); } if (inputH.End != null && inputH.End.GetType() == typeof(AbsoluteClipTime)) { AbsoluteClipTime endA = inputH.End as AbsoluteClipTime; dataGridInput.Rows.Add("Absolute Clip Time End", endA.Time.ToString()); } dataGridInput.Rows.Add("Label", inputH.Label); dataGridInput.Rows.Add("Files", string.Join(Constants.endline, inputH.Files)); } }
private void ListJobAssets() { listViewInputAssets.BeginUpdate(); try { foreach (IAsset asset in MyJob.InputMediaAssets) { ListViewItem item = new ListViewItem(asset.Name, 0); item.SubItems.Add(AssetInfo.GetAssetType(asset)); listViewInputAssets.Items.Add(item); } } catch { ListViewItem item = new ListViewItem(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_ErrorDeleted, 0); listViewInputAssets.Items.Add(item); } listViewInputAssets.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); listViewInputAssets.EndUpdate(); listViewOutputAssets.BeginUpdate(); try { foreach (IAsset asset in MyJob.OutputMediaAssets) { ListViewItem item = new ListViewItem(asset.Name, 0); item.SubItems.Add(AssetInfo.GetAssetType(asset)); listViewOutputAssets.Items.Add(item); } } catch { ListViewItem item = new ListViewItem(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_ErrorDeleted, 0); listViewOutputAssets.Items.Add(item); } listViewOutputAssets.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); listViewOutputAssets.EndUpdate(); }
private void ListJobAssets() { listViewInputAssets.BeginUpdate(); try { foreach (IAsset asset in MyJob.InputMediaAssets) { ListViewItem item = new ListViewItem(asset.Name, 0); item.SubItems.Add(AssetInfo.GetAssetType(asset)); listViewInputAssets.Items.Add(item); } } catch { ListViewItem item = new ListViewItem("<error, deleted?>", 0); listViewInputAssets.Items.Add(item); } listViewInputAssets.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); listViewInputAssets.EndUpdate(); listViewOutputAssets.BeginUpdate(); try { foreach (IAsset asset in MyJob.OutputMediaAssets) { ListViewItem item = new ListViewItem(asset.Name, 0); item.SubItems.Add(AssetInfo.GetAssetType(asset)); listViewOutputAssets.Items.Add(item); } } catch { ListViewItem item = new ListViewItem("<error, deleted?>", 0); listViewOutputAssets.Items.Add(item); } listViewOutputAssets.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); listViewOutputAssets.EndUpdate(); }
private StringBuilder GetStats() { StringBuilder sb = new StringBuilder(); if (SelectedAssets.Count > 0) { // Asset Stats foreach (IAsset theAsset in SelectedAssets) { string MyAssetType = AssetInfo.GetAssetType(theAsset); bool bfileinasset = (theAsset.AssetFiles.Count() == 0) ? false : true; long size = -1; if (bfileinasset) { size = 0; foreach (IAssetFile file in theAsset.AssetFiles) { size += file.ContentFileSize; } } sb.AppendLine("Asset Name : " + theAsset.Name); sb.AppendLine("Asset Type : " + theAsset.AssetType); sb.AppendLine("Asset Id : " + theAsset.Id); sb.AppendLine("Alternate ID : " + theAsset.AlternateId); if (size != -1) { sb.AppendLine("Size : " + FormatByteSize(size)); } sb.AppendLine("State : " + theAsset.State); sb.AppendLine("Created : " + theAsset.Created.ToLongDateString() + " " + theAsset.Created.ToLongTimeString()); sb.AppendLine("Last Modified : " + theAsset.LastModified.ToLongDateString() + " " + theAsset.LastModified.ToLongTimeString()); sb.AppendLine("Creations Options : " + theAsset.Options); if (theAsset.State != AssetState.Deleted) { sb.AppendLine("IsStreamable : " + theAsset.IsStreamable); sb.AppendLine("SupportsDynEnc : " + theAsset.SupportsDynamicEncryption); sb.AppendLine("Uri : " + theAsset.Uri.ToString()); sb.AppendLine(""); sb.AppendLine("Storage Name : " + theAsset.StorageAccountName); sb.AppendLine("Storage Bytes used: " + FormatByteSize(theAsset.StorageAccount.BytesUsed)); sb.AppendLine("Storage IsDefault : " + theAsset.StorageAccount.IsDefault); sb.AppendLine(""); foreach (IAsset p_asset in theAsset.ParentAssets) { sb.AppendLine("Parent asset Name : " + p_asset.Name); sb.AppendLine("Parent asset Id : " + p_asset.Id); } sb.AppendLine(""); foreach (IContentKey key in theAsset.ContentKeys) { sb.AppendLine("Content key : " + key.Name); sb.AppendLine("Content key Id : " + key.Id); sb.AppendLine("Content key Type : " + key.ContentKeyType); } sb.AppendLine(""); foreach (var pol in theAsset.DeliveryPolicies) { sb.AppendLine("Deliv policy Name : " + pol.Name); sb.AppendLine("Deliv policy Id : " + pol.Id); sb.AppendLine("Deliv policy Type : " + pol.AssetDeliveryPolicyType); sb.AppendLine("Deliv pol Protocol: " + pol.AssetDeliveryProtocol); } sb.AppendLine(""); foreach (IAssetFile fileItem in theAsset.AssetFiles) { if (fileItem.IsPrimary) { sb.AppendLine("Primary"); } sb.AppendLine("Name : " + fileItem.Name); sb.AppendLine("Id : " + fileItem.Id); sb.AppendLine("File size : " + fileItem.ContentFileSize + " Bytes"); sb.AppendLine("Mime type : " + fileItem.MimeType); sb.AppendLine("Init vector : " + fileItem.InitializationVector); sb.AppendLine("Created : " + fileItem.Created); sb.AppendLine("Last modified : " + fileItem.LastModified); sb.AppendLine("Encrypted : " + fileItem.IsEncrypted); sb.AppendLine("EncryptionScheme : " + fileItem.EncryptionScheme); sb.AppendLine("EncryptionVersion : " + fileItem.EncryptionVersion); sb.AppendLine("Encryption key id : " + fileItem.EncryptionKeyId); sb.AppendLine("InitializationVector : " + fileItem.InitializationVector); sb.AppendLine("ParentAssetId : " + fileItem.ParentAssetId); sb.AppendLine("=============="); sb.AppendLine(""); } foreach (ILocator locator in theAsset.Locators) { sb.AppendLine("Locator Name : " + locator.Name); sb.AppendLine("Locator Type : " + locator.Type.ToString()); sb.AppendLine("Locator Id : " + locator.Id); sb.AppendLine("Locator Path : " + locator.Path); if (locator.StartTime != null) { sb.AppendLine("Start Time : " + ((DateTime)locator.StartTime).ToLongDateString() + " " + ((DateTime)locator.StartTime).ToLongTimeString()); } if (locator.ExpirationDateTime != null) { sb.AppendLine("Expiration Time : " + ((DateTime)locator.ExpirationDateTime).ToLongDateString() + " " + ((DateTime)locator.ExpirationDateTime).ToLongTimeString()); } sb.AppendLine(""); if (locator.Type == LocatorType.OnDemandOrigin) { sb.AppendLine(_prog_down_http + " : "); foreach (IAssetFile IAF in theAsset.AssetFiles) { sb.AppendLine(locator.Path + IAF.Name); } sb.AppendLine(""); if (MyAssetType.StartsWith("HLS")) // It is a static HLS asset, so let's propose only the standard HLS V3 locator { sb.AppendLine(AssetInfo._hls_v3 + " : "); sb.AppendLine(locator.GetHlsUri().ToString().Replace("format=m3u8-aapl", "format=m3u8-aapl-v3")); sb.AppendLine(""); } else // It's not Static HLS { if (locator.GetSmoothStreamingUri() != null) { sb.AppendLine(AssetInfo._smooth + " : "); sb.AppendLine(locator.GetSmoothStreamingUri().ToString()); sb.AppendLine(AssetInfo._smooth_legacy + " : "); sb.AppendLine(AssetInfo.GetSmoothLegacy(locator.GetSmoothStreamingUri().ToString())); } if (locator.GetMpegDashUri() != null) { sb.AppendLine(AssetInfo._dash + " : "); sb.AppendLine(locator.GetMpegDashUri().ToString()); } if (locator.GetHlsUri() != null) { sb.AppendLine(AssetInfo._hls_v4 + " : "); sb.AppendLine(locator.GetHlsUri().ToString()); sb.AppendLine(AssetInfo._hls_v3 + " : "); sb.AppendLine(locator.GetHlsv3Uri().ToString()); sb.AppendLine(""); } } } if (locator.Type == LocatorType.Sas) { List <Uri> ProgressiveDownloadUris; IEnumerable <IAssetFile> MyAssetFiles; sb.AppendLine(AssetInfo._prog_down_https + " : "); MyAssetFiles = theAsset.AssetFiles.ToList(); // Generate the Progressive Download URLs for each file. ProgressiveDownloadUris = MyAssetFiles.Select(af => af.GetSasUri(locator)).ToList(); ProgressiveDownloadUris.ForEach(uri => sb.AppendLine(uri.ToString())); } sb.AppendLine(""); sb.AppendLine("=============================================================================="); sb.AppendLine(""); } } sb.AppendLine(""); sb.AppendLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); sb.AppendLine(""); } } return(sb); }
private void ExportAssetExcel(IAsset asset, Excel.Worksheet xlWorkSheet, int row, bool detailed, bool localtime) { int index = 1; xlWorkSheet.Cells[row, index++] = asset.Name; xlWorkSheet.Cells[row, index++] = asset.Id; xlWorkSheet.Cells[row, index++] = localtime ? asset.LastModified.ToLocalTime() : asset.LastModified; xlWorkSheet.Cells[row, index++] = AssetInfo.GetAssetType(asset); xlWorkSheet.Cells[row, index++] = AssetInfo.GetSize(asset); int backindex = index; var urls = AssetInfo.GetURIs(asset); if (urls != null) { foreach (var url in urls) { xlWorkSheet.Cells[row, index++] = url != null?url.ToString() : string.Empty; } } index = backindex + _context.StreamingEndpoints.Count(); var streamlocators = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin); if (streamlocators.Any()) { if (localtime) { xlWorkSheet.Cells[row, index++] = (DateTime?)streamlocators.Max(l => l.ExpirationDateTime).ToLocalTime(); } else { xlWorkSheet.Cells[row, index++] = (DateTime?)streamlocators.Max(l => l.ExpirationDateTime); } } else { xlWorkSheet.Cells[row, index++] = string.Empty; } // SAS locator var saslocators = asset.Locators.Where(l => l.Type == LocatorType.Sas); var saslocator = saslocators.ToList().OrderByDescending(l => l.ExpirationDateTime).FirstOrDefault(); if (saslocator != null && asset.AssetFiles.Count() > 0) { if (asset.AssetFiles.Count() == 1) { var ProgressiveDownloadUri = asset.AssetFiles.FirstOrDefault().GetSasUri(saslocator); xlWorkSheet.Cells[row, index++] = ProgressiveDownloadUri.AbsoluteUri; } else { xlWorkSheet.Cells[row, index++] = saslocator.Path; } if (localtime) { xlWorkSheet.Cells[row, index++] = saslocator.ExpirationDateTime.ToLocalTime(); } else { xlWorkSheet.Cells[row, index++] = saslocator.ExpirationDateTime; } } else { xlWorkSheet.Cells[row, index++] = string.Empty; xlWorkSheet.Cells[row, index++] = string.Empty; } if (detailed) { xlWorkSheet.Cells[row, index++] = asset.AlternateId; xlWorkSheet.Cells[row, index++] = asset.StorageAccount.Name; xlWorkSheet.Cells[row, index++] = asset.Uri == null ? string.Empty : asset.Uri.ToString(); var streamingloc = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin); xlWorkSheet.Cells[row, index++] = streamingloc.Count(); if (localtime) { xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null; xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime) : null; xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime) : null; } // SAS xlWorkSheet.Cells[row, index++] = saslocators.Count(); if (localtime) { xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Min(l => l.ExpirationDateTime).ToLocalTime() : null; xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Min(l => l.ExpirationDateTime) : null; xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Max(l => l.ExpirationDateTime) : null; } xlWorkSheet.Cells[row, index++] = asset.GetEncryptionState(AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash).ToString(); xlWorkSheet.Cells[row, index++] = asset.AssetFilters.Count().ToString(); } }
private string ExportAssetCSVLine(IAsset asset, bool detailed, bool localtime) { List <string> linec = new List <string>(); linec.Add(asset.Name); linec.Add(asset.Id); linec.Add(localtime ? asset.LastModified.ToLocalTime().ToString() : asset.LastModified.ToString()); linec.Add(AssetInfo.GetAssetType(asset)); linec.Add(AssetInfo.GetSize(asset).ToString()); var urls = AssetInfo.GetURIs(asset); if (urls != null && urls.Count() > 0) { foreach (var url in urls) { linec.Add(url != null ? url.ToString() : string.Empty); } } else { for (int i = 0; i < _context.StreamingEndpoints.Count(); i++) { linec.Add(string.Empty); } } var streamlocators = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin); if (streamlocators.Any()) { if (localtime) { linec.Add(streamlocators.Max(l => l.ExpirationDateTime).ToLocalTime().ToString()); } else { linec.Add(streamlocators.Max(l => l.ExpirationDateTime).ToString()); } } else { linec.Add(string.Empty); } // SAS locator var saslocators = asset.Locators.Where(l => l.Type == LocatorType.Sas); var saslocator = saslocators.ToList().OrderByDescending(l => l.ExpirationDateTime).FirstOrDefault(); if (saslocator != null && asset.AssetFiles.Count() > 0) { if (asset.AssetFiles.Count() == 1) { var ProgressiveDownloadUri = asset.AssetFiles.FirstOrDefault().GetSasUri(saslocator); linec.Add(ProgressiveDownloadUri.AbsoluteUri); } else { linec.Add(saslocator.Path); } if (localtime) { linec.Add(saslocator.ExpirationDateTime.ToLocalTime().ToString()); } else { linec.Add(saslocator.ExpirationDateTime.ToString()); } } else { linec.Add(string.Empty); linec.Add(string.Empty); } if (detailed) { linec.Add(asset.AlternateId); linec.Add(asset.StorageAccount.Name); linec.Add(asset.Uri == null ? string.Empty : asset.Uri.ToString()); var streamingloc = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin); linec.Add(streamingloc.Count().ToString()); if (localtime) { linec.Add(streamingloc.Any() ? streamingloc.Min(l => l.ExpirationDateTime).ToLocalTime().ToString() : null); linec.Add(streamingloc.Any() ? streamingloc.Max(l => l.ExpirationDateTime).ToLocalTime().ToString() : null); } else { linec.Add(streamingloc.Any() ? streamingloc.Min(l => l.ExpirationDateTime).ToString() : null); linec.Add(streamingloc.Any() ? streamingloc.Max(l => l.ExpirationDateTime).ToString() : null); } // SAS linec.Add(saslocators.Count().ToString()); if (localtime) { linec.Add(saslocators.Any() ? saslocators.Min(l => l.ExpirationDateTime).ToLocalTime().ToString() : null); linec.Add(saslocators.Any() ? saslocators.Max(l => l.ExpirationDateTime).ToLocalTime().ToString() : null); } else { linec.Add(saslocators.Any() ? saslocators.Min(l => l.ExpirationDateTime).ToString() : null); linec.Add(saslocators.Any() ? saslocators.Max(l => l.ExpirationDateTime).ToString() : null); } linec.Add(asset.GetEncryptionState(AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash).ToString()); linec.Add(asset.AssetFilters.Count().ToString()); } return(convertCSVLine(linec)); }
private void ExportAssetExcel(IAsset asset, Excel.Worksheet xlWorkSheet, int row, bool detailed, bool localtime) { int index = 1; xlWorkSheet.Cells[row, index++] = asset.Name; xlWorkSheet.Cells[row, index++] = asset.Id; xlWorkSheet.Cells[row, index++] = localtime ? asset.LastModified.ToLocalTime() : asset.LastModified; xlWorkSheet.Cells[row, index++] = AssetInfo.GetAssetType(asset); xlWorkSheet.Cells[row, index++] = AssetInfo.GetSize(asset); int backindex = index; var urls = AssetInfo.GetURIs(asset); if (urls != null) { foreach (var url in urls) { xlWorkSheet.Cells[row, index++] = url != null?url.ToString() : string.Empty; } } index = backindex + _context.StreamingEndpoints.Count(); if (localtime) { xlWorkSheet.Cells[row, index++] = asset.Locators.Any() ? (DateTime?)asset.Locators.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, index++] = asset.Locators.Any() ? (DateTime?)asset.Locators.Max(l => l.ExpirationDateTime) : null; } if (detailed) { xlWorkSheet.Cells[row, index++] = asset.AlternateId; xlWorkSheet.Cells[row, index++] = asset.StorageAccount.Name; xlWorkSheet.Cells[row, index++] = asset.Uri == null ? string.Empty : asset.Uri.ToString(); var streamingloc = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin); xlWorkSheet.Cells[row, index++] = streamingloc.Count(); if (localtime) { xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null; xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime) : null; xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime) : null; } var sasloc = asset.Locators.Where(l => l.Type == LocatorType.Sas); xlWorkSheet.Cells[row, index++] = sasloc.Count(); if (localtime) { xlWorkSheet.Cells[row, index++] = sasloc.Any() ? (DateTime?)sasloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null; xlWorkSheet.Cells[row, index++] = sasloc.Any() ? (DateTime?)sasloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, index++] = sasloc.Any() ? (DateTime?)sasloc.Min(l => l.ExpirationDateTime) : null; xlWorkSheet.Cells[row, index++] = sasloc.Any() ? (DateTime?)sasloc.Max(l => l.ExpirationDateTime) : null; } xlWorkSheet.Cells[row, index++] = asset.GetEncryptionState(AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash).ToString(); xlWorkSheet.Cells[row, index++] = asset.AssetFilters.Count().ToString(); } }
private void WorkerAnalyzeAssets_DoWork(object sender, DoWorkEventArgs e) { Debug.WriteLine("WorkerAnalyzeAssets_DoWork"); BackgroundWorker worker = sender as BackgroundWorker; Asset asset = null; var listae = _MyObservAssetV3.OrderBy(a => cacheAssetentriesV3.ContainsKey(a.Name)).ToList(); // as priority, assets not yet analyzed // test - let analyze only visible assets var visibleRowsCount = this.DisplayedRowCount(true); var firstDisplayedRowIndex = (this.FirstDisplayedCell != null) ? this.FirstDisplayedCell.RowIndex : 0; var lastvisibleRowIndex = (firstDisplayedRowIndex + visibleRowsCount) - 1; var VisibleAssets = new List <String>(); for (int rowIndex = firstDisplayedRowIndex; rowIndex <= lastvisibleRowIndex; rowIndex++) { var row = this.Rows[rowIndex]; var assetname = row.Cells[this.Columns["Name"].Index].Value.ToString(); VisibleAssets.Add(assetname); } var query = from ae in listae join visAsset in VisibleAssets on ae.Name equals visAsset select ae; var listae2 = query.ToList(); _client.RefreshTokenIfNeeded(); foreach (AssetEntryV3 AE in listae2) { System.Threading.Thread.Sleep(1000); try { asset = _client.AMSclient.Assets.Get(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, AE.Name); /* * var firstPage = await MediaServicesArmClient.Assets.ListAsync(TestSettings.CustomerResourceGroup, TestSettings.CustomerAccountName); * * var currentPage = firstPage; * while (currentPage.NextPageLink != null) * { * currentPage = await MediaServicesArmClient.Assets.ListNextAsync(currentPage.NextPageLink); * } */ if (asset != null) { //AssetInfo myAssetInfo = new AssetInfo(asset); AE.AlternateId = asset.AlternateId; AE.Description = asset.Description; AE.Created = asset.Created.ToLocalTime().ToString("G"); AE.LastModified = asset.LastModified.ToLocalTime().ToString("G"); AE.Name = asset.Name; // AE.StorageAccountName = asset.StorageAccountName; var assetBitmapAndText = DataGridViewAssets.BuildBitmapPublication(asset.Name, _client); AE.Publication = assetBitmapAndText.bitmap; AE.PublicationMouseOver = assetBitmapAndText.MouseOverDesc; // var assetfiles = asset.AssetFiles.ToList(); var data = AssetInfo.GetAssetType(asset.Name, _client); AE.Type = data.Type; AE.SizeLong = data.Size; AE.Size = AssetInfo.FormatByteSize(AE.SizeLong); AE.AssetWarning = (AE.SizeLong == 0);// || assetfiles.Any(f => f.ContentFileSize == 0)); assetBitmapAndText = BuildBitmapDynEncryption(asset.Name, _client); AE.DynamicEncryption = assetBitmapAndText.bitmap; //AE.DynamicEncryptionMouseOver = assetBitmapAndText.MouseOverDesc; if (assetBitmapAndText.Locators != null) { DateTime?LocDate = assetBitmapAndText.Locators.Any() ? (DateTime?)assetBitmapAndText.Locators.Min(l => l.EndTime).ToLocalTime() : null; AE.LocatorExpirationDate = LocDate.HasValue ? ((DateTime)LocDate).ToLocalTime().ToString() : null; AE.LocatorExpirationDateWarning = LocDate.HasValue ? (LocDate < DateTime.Now.ToLocalTime()) : false; } //assetBitmapAndText = BuildBitmapAssetFilters(asset.Name, _client); int?afcount = ReturnNumberAssetFilters(asset.Name, _client); AE.Filters = afcount > 0 ? afcount : null; //AE.FiltersMouseOver = assetBitmapAndText.MouseOverDesc; cacheAssetentriesV3[asset.Name] = AE; // let's put it in cache (or update the cache) } } catch // in some case, we have a timeout on Assets.Where... { } if (worker.CancellationPending == true) { e.Cancel = true; return; } } this.BeginInvoke(new Action(() => this.Refresh()), null); }