Exemplo n.º 1
0
        /// <summary>
        /// Do the lookup!
        /// </summary>
        protected override void ProcessRecord()
        {
            // Setup for verbosity if we need it.
            var listener = new PSListener(this);

            Trace.Listeners.Add(listener);
            try
            {
                PandaTask t            = null;
                bool      needdatasets = OutputContainerNames.IsPresent || InputContainerNames.IsPresent;

                if (ParameterSetName == "TaskID")
                {
                    t = TaskID.FindPandaJobWithTaskName(needdatasets);
                }
                if (ParameterSetName == "TaskObject")
                {
                    t = PandaTaskObject.ID.FindPandaJobWithTaskName(needdatasets);
                }
                if (ParameterSetName == "TaskName")
                {
                    t = TaskName.FindPandaJobWithTaskName(needdatasets);
                }
                if (ParameterSetName == "DatasetGRIDJob")
                {
                    // Get the job and resulting dataset name.
                    var job = JobParser.FindJob(JobName, JobVersion);
                    var ds  = job.ResultingDataSetName(DatasetName.Trim(), JobIteration);

                    // Now, look up the job itself.
                    t = (ds + "/").FindPandaJobWithTaskName();
                }

                // We really can't deal with a bad task below. The returned objects are sufficiently complex.
                if (t == null)
                {
                    throw new ArgumentException("Unable to find the task in panda: was it ever submitted?");
                }

                // Dump the info to the output pipeline as requested.
                if (JobStatus.IsPresent)
                {
                    WriteObject(t.status);
                }
                if (InputContainerNames.IsPresent)
                {
                    WriteObject(t.DataSetNamesIN());
                }
                if (OutputContainerNames.IsPresent)
                {
                    WriteObject(t.DataSetNamesOUT());
                }
            } finally
            {
                Trace.Listeners.Remove(listener);
            }
        }