Exemplo n.º 1
0
        internal async Task <Tuple <bool, string> > ConfigureAgentAlert(
            string ownerUri,
            string alertName,
            AgentAlertInfo alert,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("alert", alertName);

                    if (alert != null)
                    {
                        using (AgentAlertActions actions = new AgentAlertActions(dataContainer, alertName, alert, configAction))
                        {
                            ExecuteAction(actions, runType);
                        }
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Exemplo n.º 2
0
        internal async Task <Tuple <bool, string> > ConfigureAgentAlert(
            string ownerUri,
            AgentAlertInfo alert,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("alert", alert.JobName);

                    if (alert != null && !string.IsNullOrWhiteSpace(alert.JobName))
                    {
                        using (AgentAlertActions agentAlert = new AgentAlertActions(dataContainer, alert, configAction))
                        {
                            var executionHandler = new ExecutonHandler(agentAlert);
                            executionHandler.RunNow(runType, this);
                        }
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Exemplo n.º 3
0
        internal async Task <Tuple <bool, string> > ConfigureAgentAlert(
            string ownerUri,
            string alertName,
            AgentAlertInfo alert,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    CDataContainer dataContainer;
                    JobData jobData = null;
                    // If the alert is being created outside of a job
                    if (string.IsNullOrWhiteSpace(alert.JobName))
                    {
                        ConnectionInfo connInfo;
                        ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                        dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    }
                    else
                    {
                        // If the alert is being created inside a job
                        CreateJobData(ownerUri, alert.JobName, out dataContainer, out jobData);
                    }
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("alert", alertName);
                    if (alert != null)
                    {
                        using (AgentAlertActions actions = new AgentAlertActions(dataContainer, alertName, alert, configAction, jobData))
                        {
                            ExecuteAction(actions, runType);
                        }
                    }

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