public static MediaPublished PublishInsight(MediaPublish insightPublish)
        {
            string accountId = insightPublish.PartitionKey;
            string indexId   = insightPublish.RowKey;

            IndexerClient indexerClient = new IndexerClient(accountId, insightPublish.MediaAccount.IndexerKey);
            JObject       index         = indexerClient.GetIndex(indexId, null, false);

            MediaPublished mediaPublished = null;
            string         assetId        = IndexerClient.GetAssetId(index);

            if (!string.IsNullOrEmpty(assetId))
            {
                MediaClient mediaClient = new MediaClient(insightPublish.MediaAccount);
                IAsset      asset       = mediaClient.GetEntityById(MediaEntity.Asset, assetId) as IAsset;

                DocumentClient documentClient = new DocumentClient();
                index = DocumentClient.SetContext(index, insightPublish.MediaAccount, assetId);
                string documentId = UpsertDocument(documentClient, index, MediaProcessor.VideoIndexer, asset, null);

                mediaPublished = new MediaPublished
                {
                    AssetId       = assetId,
                    IndexId       = indexId,
                    DocumentId    = documentId,
                    UserId        = insightPublish.UserId,
                    MobileNumber  = insightPublish.MobileNumber,
                    StatusMessage = string.Empty
                };
            }
            return(mediaPublished);
        }
示例#2
0
        public static MediaPublished PublishContent(string queueName)
        {
            MediaPublished mediaPublished = null;
            QueueClient    queueClient    = new QueueClient();
            MediaPublish   contentPublish = queueClient.GetMessage <MediaPublish>(queueName, out string messageId, out string popReceipt);

            if (contentPublish != null)
            {
                mediaPublished = PublishContent(contentPublish);
                queueClient.DeleteMessage(queueName, messageId, popReceipt);
            }
            return(mediaPublished);
        }
示例#3
0
        public static MediaPublished PublishContent(MediaPublish contentPublish)
        {
            string accountId = contentPublish.PartitionKey;
            string jobId     = contentPublish.RowKey;

            MediaClient mediaClient = new MediaClient(contentPublish.MediaAccount);
            IJob        job         = mediaClient.GetEntityById(MediaEntity.Job, jobId) as IJob;

            MediaPublished mediaPublished = null;

            if (job != null)
            {
                mediaClient.SetProcessorUnits(job, null, ReservedUnitType.Basic, false);
                PublishJob(mediaClient, job, contentPublish);
                mediaPublished = new MediaPublished()
                {
                    UserId        = contentPublish.UserId,
                    MobileNumber  = contentPublish.MobileNumber,
                    StatusMessage = GetNotificationMessage(accountId, job)
                };
            }
            return(mediaPublished);
        }