Beispiel #1
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJob(
            string ownerUri,
            string originalJobName,
            AgentJobInfo jobInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, originalJobName, out dataContainer, out jobData, configAction, jobInfo);

                    using (JobActions actions = new JobActions(dataContainer, jobData, configAction))
                    {
                        ExecuteAction(actions, runType);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
        internal async Task <Tuple <bool, string> > ConfigureAgentJob(
            string ownerUri,
            AgentJobInfo jobInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, jobInfo.Name, out dataContainer, out jobData, jobInfo);

                    using (JobActions jobActions = new JobActions(dataContainer, jobData, configAction))
                    {
                        var executionHandler = new ExecutonHandler(jobActions);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Beispiel #3
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJob(
            string ownerUri,
            string originalJobName,
            AgentJobInfo jobInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(async() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, originalJobName, out dataContainer, out jobData, configAction, jobInfo);

                    using (JobActions actions = new JobActions(dataContainer, jobData, configAction))
                    {
                        ExecuteAction(actions, runType);
                    }

                    // Execute step actions if they exist
                    if (jobInfo.JobSteps != null && jobInfo.JobSteps.Length > 0)
                    {
                        foreach (AgentJobStepInfo step in jobInfo.JobSteps)
                        {
                            await ConfigureAgentJobStep(ownerUri, step, configAction, runType);
                        }
                    }

                    // Execute schedule actions if they exist
                    if (jobInfo.JobSchedules != null && jobInfo.JobSchedules.Length > 0)
                    {
                        foreach (AgentScheduleInfo schedule in jobInfo.JobSchedules)
                        {
                            await ConfigureAgentSchedule(ownerUri, schedule, configAction, runType);
                        }
                    }

                    // Execute alert actions if they exist
                    if (jobInfo.Alerts != null && jobInfo.Alerts.Length > 0)
                    {
                        foreach (AgentAlertInfo alert in jobInfo.Alerts)
                        {
                            alert.JobId = jobData.Job.JobID.ToString();
                            await ConfigureAgentAlert(ownerUri, alert.Name, alert, configAction, runType);
                        }
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }