public StringBuilder GetStatsTxt() { 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(""); } var assetFilesALL = theAsset.AssetFiles.ToList(); 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) { var ismfile = assetFilesALL.Where(f => f.Name.ToLower().EndsWith(".ism", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); sb.AppendLine(_prog_down_http + " : "); foreach (IAssetFile IAF in theAsset.AssetFiles) { sb.AppendLine(locator.Path + IAF.Name); } sb.AppendLine(""); sb.AppendLine(AssetInfo._smooth + " : "); sb.AppendLine(locator.Path + ismfile.Name + "/manifest"); sb.AppendLine(AssetInfo._dash + " : "); sb.AppendLine(locator.Path + ismfile.Name + "/Manifest(format=mpd-time-csf)"); sb.AppendLine(AssetInfo._hls_v4 + " : "); sb.AppendLine(locator.Path + ismfile.Name + "/Manifest(format=m3u8-aapl)"); sb.AppendLine(AssetInfo._hls_v3 + " : "); sb.AppendLine(locator.Path + ismfile.Name + "/Manifest(format=m3u8-aapl-v3)"); } if (locator.Type == LocatorType.Sas) { sb.AppendLine(AssetInfo._prog_down_https + " : "); var mp4Files = assetFilesALL.Where(f => f.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)).ToList(); foreach (var assetfilemp4 in mp4Files) { var mp4Uri = new UriBuilder(locator.Path); mp4Uri.Path += "/" + assetfilemp4.Name; sb.AppendLine(mp4Uri.ToString()); } } sb.AppendLine(""); sb.AppendLine("=============================================================================="); sb.AppendLine(""); } } sb.AppendLine(""); sb.AppendLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); sb.AppendLine(""); } } return(sb); }
public string GetStatJson() { Hashtable allInfo = new Hashtable(); if (SelectedAssets.Count > 0) { // Asset Stats foreach (IAsset theAsset in SelectedAssets) { Hashtable AssetDetail = new Hashtable(); 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; } } AssetDetail.Add("Asset Name", theAsset.Name); AssetDetail.Add("Asset Type", theAsset.AssetType); AssetDetail.Add("Asset Id", theAsset.Id); AssetDetail.Add("Alternate ID", theAsset.AlternateId); if (size != -1) { AssetDetail.Add("Size", FormatByteSize(size)); } else { AssetDetail.Add("Size", FormatByteSize(0)); } AssetDetail.Add("State", theAsset.State); AssetDetail.Add("Created", theAsset.Created.ToLongDateString() + " " + theAsset.Created.ToLongTimeString()); AssetDetail.Add("Last Modified", theAsset.LastModified.ToLongDateString() + " " + theAsset.LastModified.ToLongTimeString()); AssetDetail.Add("Creations Options", theAsset.Options); if (theAsset.State != AssetState.Deleted) { AssetDetail.Add("IsStreamable", theAsset.IsStreamable); AssetDetail.Add("SupportsDynEnc", theAsset.SupportsDynamicEncryption); AssetDetail.Add("Uri", theAsset.Uri.ToString()); AssetDetail.Add("Storage Name", theAsset.StorageAccountName); AssetDetail.Add("Storage Bytes used", FormatByteSize(theAsset.StorageAccount.BytesUsed)); AssetDetail.Add("Storage IsDefault", theAsset.StorageAccount.IsDefault); Hashtable ParentAssets = new Hashtable(); foreach (IAsset p_asset in theAsset.ParentAssets) { ParentAssets.Add(p_asset.Id, p_asset.Name); } AssetDetail.Add("ParentAsset", ParentAssets); Hashtable ContentKeys = new Hashtable(); foreach (IContentKey key in theAsset.ContentKeys) { string[] ContentKey = new string[3] { key.Name, key.Id, key.ContentKeyType.ToString() }; ContentKeys.Add(key.Id, ContentKey); } AssetDetail.Add("ContentKeys", ContentKeys); Hashtable DeliveryPolicies = new Hashtable(); foreach (var pol in theAsset.DeliveryPolicies) { string[] DeliveryPolicie = new string[4] { pol.Name, pol.Id, pol.AssetDeliveryPolicyType.ToString(), pol.AssetDeliveryProtocol.ToString() }; DeliveryPolicies.Add(pol.Id, DeliveryPolicie); } AssetDetail.Add("DeliveryPolicies", DeliveryPolicies); Hashtable AssetFiles = new Hashtable(); foreach (IAssetFile fileItem in theAsset.AssetFiles) { string defaultTxt; if (fileItem.IsPrimary) { defaultTxt = "True"; } else { defaultTxt = "False"; } string[] xAssetFile = new string[14] { defaultTxt, fileItem.Name, fileItem.Id, fileItem.ContentFileSize + " Bytes", fileItem.MimeType, fileItem.InitializationVector, fileItem.Created.ToString(), fileItem.LastModified.ToString(), fileItem.IsEncrypted.ToString(), fileItem.EncryptionScheme, fileItem.EncryptionVersion, fileItem.EncryptionKeyId, fileItem.InitializationVector, fileItem.ParentAssetId }; AssetFiles.Add(fileItem.Id, xAssetFile); } AssetDetail.Add("AssetFiles", AssetFiles); var assetFilesALL = theAsset.AssetFiles.ToList(); Hashtable Locators = new Hashtable(); foreach (ILocator locator in theAsset.Locators) { string StartTime = ""; if (locator.StartTime != null) { StartTime = ((DateTime)locator.StartTime).ToLongDateString() + " " + ((DateTime)locator.StartTime).ToLongTimeString(); } string ExpirationDateTime = ""; if (locator.ExpirationDateTime != null) { ExpirationDateTime = ((DateTime)locator.ExpirationDateTime).ToLongDateString() + " " + ((DateTime)locator.ExpirationDateTime).ToLongTimeString(); } string[] Locator = new string[8] { locator.Name, locator.Type.ToString(), locator.Id, locator.Path, StartTime, ExpirationDateTime, "{}", //OnDemandOrigin "{}" //Sas origin }; if (locator.Type == LocatorType.OnDemandOrigin) { string[] OnDemandOrigin = new string[4]; var ismfile = assetFilesALL.Where(f => f.Name.ToLower().EndsWith(".ism", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); OnDemandOrigin[0] = locator.Path + ismfile.Name + "/manifest"; OnDemandOrigin[1] = locator.Path + ismfile.Name + "/Manifest(format=mpd-time-csf)"; OnDemandOrigin[2] = locator.Path + ismfile.Name + "/Manifest(format=m3u8-aapl)"; OnDemandOrigin[3] = locator.Path + ismfile.Name + "/Manifest(format=m3u8-aapl-v3)"; Locator[6] = Newtonsoft.Json.JsonConvert.SerializeObject(OnDemandOrigin); } if (locator.Type == LocatorType.Sas) { List <string> sas = new List <string>(); var mp4Files = assetFilesALL.Where(f => f.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)).ToList(); foreach (var assetfilemp4 in mp4Files) { var mp4Uri = new UriBuilder(locator.Path); mp4Uri.Path += "/" + assetfilemp4.Name; sas.Add(mp4Uri.ToString()); } Locator[7] = Newtonsoft.Json.JsonConvert.SerializeObject(sas); } Locators.Add(locator.Id, Locator); } AssetDetail.Add("Locators", Locators); } allInfo.Add(theAsset.Id, AssetDetail); } } return(Newtonsoft.Json.JsonConvert.SerializeObject(allInfo, Newtonsoft.Json.Formatting.Indented)); }