public List <PSSchedulerJob> GetJob(string region, string jobCollection, string job = "", string state = "")
        {
            if (!this.AvailableRegions.Contains(region, StringComparer.OrdinalIgnoreCase))
            {
                throw new Exception(Resources.SchedulerInvalidLocation);
            }

            List <PSSchedulerJob> lstJob = new List <PSSchedulerJob>();

            string cloudService = region.ToCloudServiceName();

            if (!string.IsNullOrEmpty(job))
            {
                PSJobDetail jobDetail = GetJobDetail(jobCollection, job, cloudService);
                if (string.IsNullOrEmpty(state) || (!string.IsNullOrEmpty(state) && jobDetail.Status.Equals(state, StringComparison.OrdinalIgnoreCase)))
                {
                    lstJob.Add(jobDetail);
                    return(lstJob);
                }
            }
            else if (string.IsNullOrEmpty(job))
            {
                GetSchedulerJobs(cloudService, jobCollection).ForEach(x =>
                {
                    if (string.IsNullOrEmpty(state) || (!string.IsNullOrEmpty(state) && x.Status.Equals(state, StringComparison.OrdinalIgnoreCase)))
                    {
                        lstJob.Add(x);
                    }
                });
            }
            return(lstJob);
        }
Ejemplo n.º 2
0
        public List <PSSchedulerJob> GetJob(string region, string jobCollection, string job = "", string state = "")
        {
            List <PSSchedulerJob> lstJob = new List <PSSchedulerJob>();

            string cloudService = region.ToCloudServiceName();

            if (!string.IsNullOrEmpty(job))
            {
                PSJobDetail jobDetail = GetJobDetail(jobCollection, job, cloudService);
                if (string.IsNullOrEmpty(state) || (!string.IsNullOrEmpty(state) && jobDetail.Status.Equals(state, StringComparison.OrdinalIgnoreCase)))
                {
                    lstJob.Add(jobDetail);
                    return(lstJob);
                }
            }
            else if (string.IsNullOrEmpty(job))
            {
                GetSchedulerJobs(cloudService, jobCollection).ForEach(x =>
                {
                    if (string.IsNullOrEmpty(state) || (!string.IsNullOrEmpty(state) && x.Status.Equals(state, StringComparison.OrdinalIgnoreCase)))
                    {
                        lstJob.Add(x);
                    }
                });
            }
            return(lstJob);
        }