private IEnumerable <CloudBlockBlob> ListJobOutputsFromStorage(Guid jobId, CancellationToken ct)
        {
            var containerRef = _blobClient.GetContainerReference(StorageConstants.GetJobOutputContainer(jobId));

            if (!containerRef.Exists())
            {
                return(Enumerable.Empty <CloudBlockBlob>());
            }

            return(containerRef.ListBlobs().Select(b => ((CloudBlockBlob)b)));
        }
        private string GetJobOutputDirectory(Guid jobId, string outputPath)
        {
            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            var jobDir = Path.Combine(outputPath, StorageConstants.GetJobOutputContainer(jobId));

            if (!Directory.Exists(jobDir))
            {
                Directory.CreateDirectory(jobDir);
            }

            return(jobDir);
        }
예제 #3
0
        public void DeleteJob(Guid jobId)
        {
            var blobClient = _storageAccount.CreateCloudBlobClient();

            blobClient.DefaultRequestOptions.RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(3), 10);
            var containerRef = blobClient.GetContainerReference(StorageConstants.GetJobOutputContainer(jobId));

            if (containerRef.Exists())
            {
                containerRef.Delete();
            }

            var job = GetJob(jobId);

            if (job != null)
            {
                _batchClient.JobOperations.DeleteJob(jobId.ToString());
            }
        }
예제 #4
0
        private string GetStorageContainerUrl(Guid jobId)
        {
            var container = StorageConstants.GetJobOutputContainer(jobId);

            return(string.Format("https://{0}.blob.core.windows.net/{1}", _storageCredentials.Account, container));
        }
예제 #5
0
        /// <summary>
        /// Asks the user for confirmation and then deletes a list of jobs.
        /// </summary>
        /// <param name="jobIds">ID of the job.</param>
        public void DeleteJobs(List <string> jobIds)
        {
            if (jobIds.Count < 1)
            {
                MainPresenter.ShowMessage("Unable to delete jobs: no jobs are selected.", Simulation.ErrorLevel.Information);
                return;
            }

            bool restart = FetchJobs.IsBusy;

            // cancel the fetch jobs worker
            if (restart)
            {
                FetchJobs.CancelAsync();
            }
            //while (FetchJobs.IsBusy);
            view.HideLoadingProgressBar();


            // get the grammar right when asking for confirmation
            bool   deletingMultiple = jobIds.Count > 1;
            string msg   = "Are you sure you want to delete " + (deletingMultiple ? "these " + jobIds.Count + " jobs?" : "this job?");
            string label = deletingMultiple ? "Delete these jobs?" : "Delete this job?";

            // if user says no to the popup, no further action required
            if (!AskQuestion(msg))
            {
                return;
            }
            Guid parsedId;

            foreach (string id in jobIds)
            {
                try
                {
                    if (!Guid.TryParse(id, out parsedId))
                    {
                        continue;
                    }
                    // delete the job from Azure
                    CloudBlobContainer containerRef;

                    containerRef = blobClient.GetContainerReference(StorageConstants.GetJobOutputContainer(parsedId));
                    if (containerRef.Exists())
                    {
                        containerRef.Delete();
                    }

                    containerRef = blobClient.GetContainerReference(StorageConstants.GetJobContainer(parsedId));
                    if (containerRef.Exists())
                    {
                        containerRef.Delete();
                    }

                    containerRef = blobClient.GetContainerReference(parsedId.ToString());
                    if (containerRef.Exists())
                    {
                        containerRef.Delete();
                    }

                    var job = GetJob(id);
                    if (job != null)
                    {
                        batchClient.JobOperations.DeleteJob(id);
                    }

                    // remove the job from the locally stored list of jobs
                    jobList.RemoveAt(jobList.IndexOf(GetJob(id)));
                } catch (Exception e)
                {
                    ShowError(e.ToString());
                }
            }
            // refresh the tree view
            view.UpdateJobTable(jobList);

            // restart the fetch jobs worker
            if (restart)
            {
                FetchJobs.RunWorkerAsync();
            }
        }