public void ShouldDeleteJobInFinishedState()
        {
            IMediaProcessor processor = GetMediaProcessor(_mediaContext, WindowsAzureMediaServicesTestConfiguration.MpEncoderName);
            IAsset          asset     = AssetTests.CreateAsset(_mediaContext, _smallWmv, AssetCreationOptions.StorageEncrypted);
            IJob            job       = CreateAndSubmitOneTaskJob(_mediaContext, GenerateName("ShouldDeleteJobInFinishedState"), processor, GetWamePreset(processor), asset, TaskOptions.None);

            WaitForJob(job.Id, JobState.Finished, (string id) => { });
            job.Delete();
        }
Esempio n. 2
0
        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();
        }
        public void DeleteJob(string jobId)
        {
            bool jobDeleted = false;

            while (!jobDeleted)
            {
                IJob theJob = GetJob(jobId);

                // Check and handle various possible job states. You can
                // only delete a job whose state is Finished, Error, or Canceled.
                // You can cancel jobs that are Queued, Scheduled, or Processing,
                // and then delete after they are canceled.
                switch (theJob.State)
                {
                case JobState.Finished:
                case JobState.Canceled:
                    theJob.Delete();
                    jobDeleted = true;
                    Console.WriteLine("Job has been deleted.");
                    break;

                case JobState.Canceling:
                    Console.WriteLine("Job is cancelling and will be deleted "
                                      + "when finished.");
                    Console.WriteLine("Wait while job finishes canceling...");
                    Thread.Sleep(5000);
                    break;

                case JobState.Queued:
                case JobState.Scheduled:
                case JobState.Processing:
                    theJob.Cancel();
                    Console.WriteLine("Job is pending or processing and will "
                                      + "be canceled, then deleted.");
                    break;

                case JobState.Error:
                    // Log error as needed.
                    break;

                default:
                    break;
                }
            }
        }