示例#1
0
        public static void PurgePublishInsight(TableClient tableClient)
        {
            DocumentClient documentClient = new DocumentClient();
            string         collectionId   = Constant.Database.Collection.ContentInsight;

            JObject[] documents = documentClient.GetDocuments(collectionId);
            foreach (JObject document in documents)
            {
                if (document["accountId"] != null)
                {
                    MediaAccount mediaAccount = new MediaAccount()
                    {
                        Id          = document["accountId"].ToString(),
                        DomainName  = document["accountDomain"].ToString(),
                        EndpointUrl = document["accountEndpoint"].ToString(),
                        ClientId    = document["clientId"].ToString(),
                        ClientKey   = document["clientKey"].ToString()
                    };
                    string assetId = document["assetId"].ToString();

                    MediaClient mediaClient = new MediaClient(mediaAccount);
                    IAsset      asset       = mediaClient.GetEntityById(MediaEntity.Asset, assetId) as IAsset;
                    if (asset == null)
                    {
                        string documentId = document["id"].ToString();
                        documentClient.DeleteDocument(collectionId, documentId);

                        string       tableName      = Constant.Storage.Table.InsightPublish;
                        MediaPublish insightPublish = tableClient.GetEntity <MediaPublish>(tableName, mediaAccount.Id, documentId);
                        if (insightPublish != null)
                        {
                            tableClient.DeleteEntity(tableName, insightPublish);
                        }
                    }
                }
            }
        }
示例#2
0
        private static void DeleteAsset(string authToken, string accountId, MediaClient mediaClient, IAsset asset)
        {
            string documentId = DocumentClient.GetDocumentId(asset, out bool videoIndexer);

            if (!string.IsNullOrEmpty(documentId))
            {
                DocumentClient documentClient = new DocumentClient();
                string         collectionId   = Constant.Database.Collection.ContentInsight;
                documentClient.DeleteDocument(collectionId, documentId);
                if (videoIndexer)
                {
                    IndexerClient indexerClient = new IndexerClient(authToken);
                    if (indexerClient.IndexerEnabled)
                    {
                        indexerClient.DeleteVideo(documentId, true);
                    }

                    TableClient  tableClient    = new TableClient();
                    string       tableName      = Constant.Storage.Table.InsightPublish;
                    MediaPublish insightPublish = tableClient.GetEntity <MediaPublish>(tableName, accountId, documentId);
                    if (insightPublish != null)
                    {
                        tableClient.DeleteEntity(tableName, insightPublish);
                    }
                }
            }
            foreach (ILocator locator in asset.Locators)
            {
                locator.Delete();
            }
            for (int i = asset.DeliveryPolicies.Count - 1; i >= 0; i--)
            {
                asset.DeliveryPolicies.RemoveAt(i);
            }
            asset.Delete();
        }