Beispiel #1
0
 private static void DeleteAsset(MediaClient mediaClient, IAsset asset)
 {
     using (DatabaseClient databaseClient = new DatabaseClient(true))
     {
         string collectionId = Constants.Database.DocumentCollection.Metadata;
         foreach (IAssetFile file in asset.AssetFiles)
         {
             if (file.Name.EndsWith(Constants.Media.FileExtension.Json))
             {
                 string[] fileNameInfo = file.Name.Split(Constants.NamedItemsSeparator);
                 string   documentId   = fileNameInfo[0];
                 databaseClient.DeleteDocument(collectionId, documentId);
             }
         }
     }
     foreach (ILocator locator in asset.Locators)
     {
         locator.Delete();
     }
     for (int i = asset.DeliveryPolicies.Count - 1; i > -1; i--)
     {
         asset.DeliveryPolicies.RemoveAt(i);
     }
     asset.Delete();
 }
        public void IndexerDeleteVideo(string insightId)
        {
            string relativePath = string.Concat("/videos/", insightId);
            string requestUrl   = GetRequestUrl(relativePath, true, insightId);

            using (WebClient webClient = new WebClient(MediaAccount.VideoIndexerKey))
            {
                HttpRequestMessage  webRequest  = webClient.GetRequest(HttpMethod.Delete, requestUrl);
                HttpResponseMessage webResponse = webClient.GetResponse <HttpResponseMessage>(webRequest);
            }
            using (DatabaseClient databaseClient = new DatabaseClient())
            {
                string collectionId = Constant.Database.Collection.MediaJobAccount;
                databaseClient.DeleteDocument(collectionId, insightId);
                collectionId = Constant.Database.Collection.MediaContentInsight;
                databaseClient.DeleteDocument(collectionId, insightId);
            }
        }
        public void DeleteEntity(MediaEntity entityType, string entityName, string parentName = null)
        {
            switch (entityType)
            {
            case MediaEntity.Asset:
                _media.Assets.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName);
                break;

            case MediaEntity.Transform:
                _media.Transforms.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName);
                break;

            case MediaEntity.TransformJob:
                _media.Jobs.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, parentName, entityName);
                using (DatabaseClient databaseClient = new DatabaseClient())
                {
                    string collectionId = Constant.Database.Collection.MediaJobAccount;
                    databaseClient.DeleteDocument(collectionId, entityName);
                }
                break;

            case MediaEntity.ContentKeyPolicy:
                _media.ContentKeyPolicies.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName);
                break;

            case MediaEntity.StreamingPolicy:
                _media.StreamingPolicies.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName);
                break;

            case MediaEntity.StreamingEndpoint:
                _media.StreamingEndpoints.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName);
                break;

            case MediaEntity.StreamingLocator:
                _media.StreamingLocators.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName);
                break;

            case MediaEntity.FilterAccount:
                _media.AccountFilters.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName);
                break;

            case MediaEntity.FilterAsset:
                _media.AssetFilters.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, parentName, entityName);
                break;

            case MediaEntity.LiveEvent:
                LiveEvent liveEvent = GetEntity <LiveEvent>(MediaEntity.LiveEvent, entityName);
                if (liveEvent != null)
                {
                    LiveOutput[] liveOutputs = GetAllEntities <LiveOutput>(MediaEntity.LiveEventOutput, null, entityName);
                    foreach (LiveOutput liveOutput in liveOutputs)
                    {
                        _media.LiveOutputs.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName, liveOutput.Name);
                    }
                    _media.LiveEvents.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, entityName);
                }
                break;

            case MediaEntity.LiveEventOutput:
                _media.LiveOutputs.Delete(MediaAccount.ResourceGroupName, MediaAccount.Name, parentName, entityName);
                break;
            }
        }