コード例 #1
0
        private static ContentProtection GetContentProtection(string jobId, string taskId)
        {
            TableClient tableClient = new TableClient();
            string      tableName   = Constant.Storage.Table.ContentProtection;

            return(tableClient.GetEntity <ContentProtection>(tableName, jobId, taskId));
        }
コード例 #2
0
ファイル: Account.cs プロジェクト: lulzzz/SkyMedia
        private static void DeleteJob(string accountId, IJob job)
        {
            TableClient  tableClient    = new TableClient();
            string       tableName      = Constant.Storage.Table.ContentPublish;
            MediaPublish contentPublish = tableClient.GetEntity <MediaPublish>(tableName, accountId, job.Id);

            if (contentPublish != null)
            {
                tableClient.DeleteEntity(tableName, contentPublish);
                MediaClient.DeleteContentProtections(tableClient, contentPublish.RowKey);
            }
            job.Delete();
        }
コード例 #3
0
        public void UploadBlock(Stream readStream, string containerName, string directoryPath, string fileName,
                                string partitionKey, int blockIndex, bool lastBlock)
        {
            string blockId = Convert.ToBase64String(BitConverter.GetBytes(blockIndex));

            CloudBlockBlob blob = GetBlob(containerName, directoryPath, fileName);

            blob.PutBlock(blockId, readStream, null);

            string tableName = Constant.Storage.Table.FileUpload;
            string rowKey    = blob.Name;

            if (blockIndex == 0)
            {
                BlockUpload blockUpload = new BlockUpload()
                {
                    PartitionKey = partitionKey,
                    RowKey       = rowKey,
                    BlockIds     = new string[] { blockId }
                };
                _tracker.UpsertEntity(tableName, blockUpload);
            }
            else
            {
                BlockUpload   blockUpload = _tracker.GetEntity <BlockUpload>(tableName, partitionKey, rowKey);
                List <string> blockIds    = new List <string>(blockUpload.BlockIds);
                blockIds.Add(blockId);
                blockUpload.BlockIds = blockIds.ToArray();
                _tracker.UpdateEntity(tableName, blockUpload);
            }

            if (lastBlock)
            {
                BlockUpload blockUpload = _tracker.GetEntity <BlockUpload>(tableName, partitionKey, rowKey);
                blob.PutBlockList(blockUpload.BlockIds);
                _tracker.DeleteEntity(tableName, blockUpload);
            }
        }
コード例 #4
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);
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: Account.cs プロジェクト: lulzzz/SkyMedia
        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();
        }