Ejemplo n.º 1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (DestinationLocation != null)
                    {
                        DestinationLocation.Clear();
                    }
                    if (SourceLocation != null)
                    {
                        SourceLocation.Clear();
                    }
                    FileList.Clear();
                    FileList = null;
                    ArchiveMemoryStream.Dispose();
                    if (File.Exists(WorkingArchive))
                    {
                        File.Delete(WorkingArchive);
                    }
                }

                disposedValue = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fetch a particular dataset.
        /// </summary>
        protected override void ProcessRecord()
        {
            var listener = new PSListener(this);

            Trace.Listeners.Add(listener);
            try
            {
                // Get the actual dataset name.
                var dataset = DatasetName.Trim();
                if (ParameterSetName == "job")
                {
                    // Get the job, see if it is finished, and then get the output dataset.
                    var job = JobParser.FindJob(JobName, JobVersion);
                    if (job == null)
                    {
                        throw new ArgumentException($"Job {JobName} v{JobVersion} is not known to the system!");
                    }

                    // Get the resulting job name for this guy.
                    var pandaJobName = job.ResultingDataSetName(JobSourceDatasetName, JobIteration) + "/";

                    // Now, to get the output dataset, we need to fetch the job.
                    var pandaTask = pandaJobName.FindPandaJobWithTaskName(true);
                    if (pandaTask == null)
                    {
                        throw new ArgumentException($"No panda task found with name '{pandaJobName}' for job '{JobName}' v{JobVersion}.");
                    }
                    var containers = pandaTask.DataSetNamesOUT();
                    if (containers.Length > 1)
                    {
                        throw new ArgumentException($"There are more than one output container for the panda task {pandaTask.jeditaskid} - can't decide. Need code upgrade!! Thanks for the fish!");
                    }
                    dataset = containers.First();
                }

                // Find all the members of this dataset.
                var allFilesToCopy = DataSetManager.ListOfFilesInDataSetAsync(dataset, m => DisplayStatus($"Listing Files in {dataset}", m), failNow: () => Stopping)
                                     .Result;
                if (nFiles != 0)
                {
                    allFilesToCopy = allFilesToCopy
                                     .OrderBy(u => u.AbsolutePath)
                                     .Take(nFiles)
                                     .ToArray();
                }

                // Turn the source and destination locations into actual locations.
                var locSource = SourceLocation.AsIPlace().Result;
                var locDest   = DestinationLocation.AsIPlace().Result;

                // Do the actual copy. This will fail if one of the files can't be found at the source.
                var resultUris = DataSetManager
                                 .CopyFilesAsync(locSource, locDest, allFilesToCopy, mbox => DisplayStatus($"Downloading {dataset}", mbox), failNow: () => Stopping, timeout: Timeout)
                                 .Result;

                // Dump all the returned files out to whatever is next in the pipeline.
                if (PassThru.IsPresent)
                {
                    using (var pl = listener.PauseListening())
                    {
                        foreach (var ds in resultUris)
                        {
                            WriteObject(ds);
                        }
                    }
                }
            }
            finally
            {
                Trace.Listeners.Remove(listener);
            }
        }
 /// <summary>
 /// Closes the archive.
 /// </summary>
 public void CloseArchive()
 {
     ArchiveMemoryStream.Dispose();
     EncryptedPackageUtilities.CompressArchive(WorkingArchive, DestinationLocation.ToString(), Password);
 }
 /// <summary>
 /// Reloads the archive for editing.
 /// </summary>
 public void ReloadArchive()
 {
     EncryptedPackageUtilities.DecompressArchive(DestinationLocation.ToString(), Password);
     ArchiveMemoryStream = ZipFile.Open(PackageUtilities.TempArchive, ZipArchiveMode.Update);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Reloads the archive for editing.
 /// </summary>
 public void ReloadArchive()
 {
     PackageUtilities.DecompressArchive(DestinationLocation.ToString());
     ArchiveMemoryStream = ZipFile.Open(WorkingArchive, ZipArchiveMode.Update);
 }