Exemple #1
0
        public BlobClient(string authToken, string accountName)
        {
            CloudStorageAccount storageAccount = Storage.GetUserAccount(authToken, accountName);

            BindContext(storageAccount);
            _tracker = new EntityClient(authToken, accountName);
        }
Exemple #2
0
        public static string PublishJob(MediaJobNotification jobNotification, bool webHook)
        {
            string jobPublication = string.Empty;

            if (jobNotification != null && jobNotification.EventType == MediaJobNotificationEvent.JobStateChange &&
                (jobNotification.Properties.NewState == JobState.Error ||
                 jobNotification.Properties.NewState == JobState.Canceled ||
                 jobNotification.Properties.NewState == JobState.Finished))
            {
                if (webHook)
                {
                    string        settingKey    = Constants.AppSettingKey.MediaJobNotificationStorageQueueName;
                    string        queueName     = AppSetting.GetValue(settingKey);
                    MessageClient messageClient = new MessageClient();
                    messageClient.AddMessage(queueName, jobNotification);
                }
                else
                {
                    EntityClient entityClient = new EntityClient();
                    string       tableName    = Constants.Storage.TableName.JobPublish;
                    string       partitionKey = jobNotification.Properties.AccountName;
                    string       rowKey       = jobNotification.Properties.JobId;
                    JobPublish   jobPublish   = entityClient.GetEntity <JobPublish>(tableName, partitionKey, rowKey);
                    if (jobPublish != null)
                    {
                        tableName = Constants.Storage.TableName.JobPublishProtection;
                        ContentProtection contentProtection = entityClient.GetEntity <ContentProtection>(tableName, partitionKey, rowKey);
                        string            accountName       = jobPublish.PartitionKey;
                        string            accountKey        = jobPublish.MediaAccountKey;
                        MediaClient       mediaClient       = new MediaClient(accountName, accountKey);
                        IJob job = mediaClient.GetEntityById(MediaEntity.Job, rowKey) as IJob;
                        if (job != null)
                        {
                            mediaClient.SetProcessorUnits(job, ReservedUnitType.Basic);
                            if (jobNotification.Properties.NewState == JobState.Finished)
                            {
                                PublishContent(mediaClient, job, jobPublish, contentProtection);
                            }
                            string messageText = GetNotificationMessage(accountName, job);
                            MessageClient.SendText(messageText, jobPublish.MobileNumber);
                        }
                        if (contentProtection != null)
                        {
                            tableName = Constants.Storage.TableName.JobPublishProtection;
                            entityClient.DeleteEntity(tableName, contentProtection);
                        }
                        tableName = Constants.Storage.TableName.JobPublish;
                        entityClient.DeleteEntity(tableName, jobPublish);
                    }
                }
            }
            return(jobPublication);
        }
Exemple #3
0
        public static DateTime?GetEventStart(string accountName, string channelName)
        {
            DateTime?      eventStart   = null;
            EntityClient   entityClient = new EntityClient();
            string         tableName    = Constants.Storage.TableName.LiveEvent;
            MediaLiveEvent liveEvent    = entityClient.GetEntity <MediaLiveEvent>(tableName, accountName, channelName);

            if (liveEvent != null)
            {
                eventStart = liveEvent.EventStart;
            }
            return(eventStart);
        }
Exemple #4
0
        internal static void TrackJob(string authToken, IJob job, string storageAccount, ContentProtection[] contentProtections)
        {
            string attributeName = Constants.UserAttribute.MediaAccountName;
            string accountName   = AuthToken.GetClaimValue(authToken, attributeName);

            attributeName = Constants.UserAttribute.MediaAccountKey;
            string accountKey = AuthToken.GetClaimValue(authToken, attributeName);

            attributeName = Constants.UserAttribute.UserId;
            string userId = AuthToken.GetClaimValue(authToken, attributeName);

            attributeName = Constants.UserAttribute.MobileNumber;
            string mobileNumber = AuthToken.GetClaimValue(authToken, attributeName);

            JobPublish jobPublish = new JobPublish();

            jobPublish.PartitionKey = accountName;
            jobPublish.RowKey       = job.Id;

            jobPublish.MediaAccountKey    = accountKey;
            jobPublish.StorageAccountName = storageAccount;
            jobPublish.StorageAccountKey  = Storage.GetUserAccountKey(authToken, storageAccount);
            jobPublish.UserId             = userId;
            jobPublish.MobileNumber       = mobileNumber;

            EntityClient entityClient = new EntityClient();

            string tableName = Constants.Storage.TableName.JobPublish;

            entityClient.InsertEntity(tableName, jobPublish);

            tableName = Constants.Storage.TableName.JobPublishProtection;
            foreach (ContentProtection contentProtection in contentProtections)
            {
                contentProtection.PartitionKey = jobPublish.PartitionKey;
                contentProtection.RowKey       = jobPublish.RowKey;
                entityClient.InsertEntity(tableName, contentProtection);
            }
        }