コード例 #1
0
 public static IAsyncResult BeginResume(this Job job, OrchestratorApi orchestratorApi, AsyncCallback callback, object state, string label = null)
 {
     return(ActionExtensions.BeginJobAction(job, orchestratorApi, "Resume", callback, state, new OperationParameter[]
     {
         new BodyOperationParameter("label", label)
     }));
 }
コード例 #2
0
ファイル: SMAInterop.cs プロジェクト: tryinmybest/scorch
        private static Job initiateRunbookJob(OrchestratorApi sma, String runbookName, List <NameValuePair> runbookParameters)
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(
                delegate
            {
                return(true);
            });
            List <string> parameterNames = new List <string>();
            var           runbook        = (from rb in sma.Runbooks
                                            where rb.RunbookName == runbookName
                                            select rb).AsEnumerable().FirstOrDefault();

            if (runbook == null)
            {
                var msg = string.Format(CultureInfo.InvariantCulture, "{0}: {1}", refStrings.RunbookNotFound, runbookName);
                throw new Exception(msg);
            }

            OperationParameter operationParameters = new BodyOperationParameter(refStrings.JobParameterName, runbookParameters);
            string             uri = string.Concat(sma.Runbooks, string.Format("(guid'{0}')/{1}", runbook.RunbookID, refStrings.StartRunbookActionName));
            Uri uriSMA             = new Uri(uri, UriKind.Absolute);

            // Create the job
            var jobIdValue = sma.Execute <Guid>(uriSMA, refStrings.HttpPost, true, operationParameters) as QueryOperationResponse <Guid>;
            var jobId      = jobIdValue.Single();

            var job = sma.Jobs.Where(j => j.JobID == jobId).AsEnumerable().FirstOrDefault();

            if (job == null)
            {
                throw new Exception(refStrings.JobNotStarted);
            }
            return(job);
        }
コード例 #3
0
        public List <OpsLogix.WAP.RunPowerShell.ApiClient.DataContracts.Runbook> GetSMARunbookList()
        {
            smaRunbooks = new List <OpsLogix.WAP.RunPowerShell.ApiClient.DataContracts.Runbook>();
            System.Configuration.ConnectionStringSettings url = System.Configuration.ConfigurationManager.ConnectionStrings["SMAUrl"];
            var api = new OrchestratorApi(new Uri(url.ConnectionString));

            //var api = new OrchestratorApi(new Uri(url.ConnectionString));

            /*
             * var api = new OrchestratorApi(new Uri("https://sma.lab.local/00000000-0000-0000-0000-000000000000"));*/
            ((DataServiceContext)api).Credentials = CredentialCache.DefaultCredentials;
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); });

            //var runbooks = api.Runbooks.Where(r => r.Tags.Contains("TenantRunbook")).AsEnumerable();
            var runbooks = api.Runbooks.AsEnumerable();

            foreach (OpsLogix.WAP.RunPowerShell.Api.ServiceReference.SMAWebservice.Runbook runbook in runbooks)
            {
                smaRunbooks.Add(new OpsLogix.WAP.RunPowerShell.ApiClient.DataContracts.Runbook {
                    RunbookId = runbook.RunbookID.ToString(), RunbookName = runbook.RunbookName, RunbookTag = runbook.Tags
                });
            }

            return(smaRunbooks);
        }
コード例 #4
0
 public static IAsyncResult BeginStartRunbook(this Runbook runbook, OrchestratorApi orchestratorApi, AsyncCallback callback, object state, List <NameValuePair> jobParameters = null)
 {
     return(ActionExtensions.BeginRunbookAction <Guid>(runbook, orchestratorApi, "Start", callback, state, new OperationParameter[]
     {
         new BodyOperationParameter("parameters", jobParameters)
     }));
 }
コード例 #5
0
 private static void EndJobAction(OrchestratorApi orchestratorApi, IAsyncResult asyncResult)
 {
     if (!(ActionExtensions.EndExecute <Guid>(orchestratorApi, asyncResult) is QueryOperationResponse <Guid>))
     {
         string message = string.Format("The {0} action did not return the expected response type: QueryOperationResponse<{1}>", new StackFrame(1).GetMethod().Name, typeof(Guid).Name);
         throw new InvalidOperationException(message);
     }
 }
コード例 #6
0
 public static SmaClient GetForWorkflow(Uri url, string username, string password)
 {
     return(GetClient(url.ToString(), ClientType.Workflow, () =>
     {
         var ctx = new OrchestratorApi(url);
         (ctx as DataServiceContext).Credentials = new NetworkCredential(username, password);
         return new SmaClient(ctx);
     }));
 }
コード例 #7
0
 public static SmaClient GetForUser(Uri url)
 {
     return(GetClient(url.ToString(), ClientType.Workflow, () =>
     {
         var ctx = new OrchestratorApi(url);
         (ctx as DataServiceContext).Credentials = CredentialCache.DefaultNetworkCredentials;
         return new SmaClient(ctx);
     }));
 }
コード例 #8
0
        private static TElement EndRunbookAction <TElement>(OrchestratorApi orchestratorApi, IAsyncResult asyncResult)
        {
            QueryOperationResponse <TElement> queryOperationResponse = ActionExtensions.EndExecute <TElement>(orchestratorApi, asyncResult) as QueryOperationResponse <TElement>;

            if (queryOperationResponse == null)
            {
                string message = string.Format("The {0} action did not return the expected response type: QueryOperationResponse<{1}>", new StackFrame(1).GetMethod().Name, typeof(TElement).Name);
                throw new InvalidOperationException(message);
            }
            return(queryOperationResponse.Single <TElement>());
        }
コード例 #9
0
ファイル: RunBookOperations.cs プロジェクト: vrosnet/Phoenix
        public RunBookOperations(string uri)
        {
            if (string.IsNullOrEmpty(uri))
            {
                throw new Exception("Invalid Service Uri");
            }

            this.serviceRoot = uri;

            this.api = new OrchestratorApi(new Uri(this.serviceRoot));
            ((DataServiceContext)this.api).Credentials = CredentialCache.DefaultCredentials;
        }
コード例 #10
0
ファイル: RunBookOperations.cs プロジェクト: vrosnet/Phoenix
        /// <summary>
        ///  Constructor
        /// </summary>

        public RunBookOperations()
        {
            if (String.IsNullOrEmpty(this.serviceRoot))
            {
                this.serviceRoot = ConfigurationManager.AppSettings.Get("SMAService");
                if (string.IsNullOrEmpty(this.serviceRoot))
                {
                    throw new Exception("Invalid Service Uri");
                }
            }

            this.api = new OrchestratorApi(new Uri(serviceRoot));
            ((DataServiceContext)this.api).Credentials = CredentialCache.DefaultCredentials;
        }
        public RunbookService(string username, string password, string orchestratorApiAddress, string runbookId)
        {
            this.username        = username;
            this.password        = password;
            this.runbookId       = runbookId;
            this.orchestratorApi = new OrchestratorApi(new Uri(orchestratorApiAddress));
            ((DataServiceContext)orchestratorApi).Credentials = new NetworkCredential(username, password);

            //This is used here to ignore certificate errors as you might be using test certificates. You can remove this if you are using trusted certificates.
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(
                delegate
            {
                return(true);
            });
        }
コード例 #12
0
 private static IAsyncResult BeginJobAction(Job job, OrchestratorApi orchestratorApi, string action, AsyncCallback callback, object state, params OperationParameter[] operationParameters)
 {
     if (job == null || job.JobID == Guid.Empty)
     {
         throw new ArgumentNullException("job");
     }
     if (orchestratorApi == null)
     {
         throw new ArgumentNullException("orchestratorApi");
     }
     if (!ActionExtensions.JobActions.Contains(action))
     {
         throw new ArgumentOutOfRangeException("action", action, "An invalid job action was requested.");
     }
     return(orchestratorApi.BeginExecute <Guid>(ActionExtensions.GetActionUri(orchestratorApi.Jobs.RequestUri, job.JobID, action), callback, state, "POST", true, operationParameters));
 }
コード例 #13
0
 private static IAsyncResult BeginRunbookAction <TElement>(Runbook runbook, OrchestratorApi orchestratorApi, string action, AsyncCallback callback, object state, params OperationParameter[] operationParameters)
 {
     if (runbook == null || runbook.RunbookID == Guid.Empty)
     {
         throw new ArgumentNullException("runbook");
     }
     if (orchestratorApi == null)
     {
         throw new ArgumentNullException("orchestratorApi");
     }
     if (!ActionExtensions.RunbookActions.Contains(action))
     {
         throw new ArgumentOutOfRangeException("action", action, "An invalid Runbook action was requested.");
     }
     return(orchestratorApi.BeginExecute <TElement>(ActionExtensions.GetActionUri(orchestratorApi.Runbooks.RequestUri, runbook.RunbookID, action), callback, state, "POST", true, operationParameters));
 }
コード例 #14
0
 public static IAsyncResult BeginStartOnSchedule(this Runbook runbook, OrchestratorApi orchestratorApi, AsyncCallback callback, object state, Schedule schedule, List <NameValuePair> jobParameters = null)
 {
     if (schedule == null)
     {
         throw new ArgumentNullException("schedule");
     }
     if (schedule.ScheduleID == Guid.Empty)
     {
         orchestratorApi.AddToSchedules(schedule);
         orchestratorApi.SaveChanges();
     }
     return(ActionExtensions.BeginRunbookAction <Guid>(runbook, orchestratorApi, "StartOnSchedule", callback, state, new OperationParameter[]
     {
         new BodyOperationParameter("parameters", jobParameters),
         new BodyOperationParameter("scheduleId", schedule.ScheduleID)
     }));
 }
コード例 #15
0
        public void Connect()
        {
            if (IsConnected)
            {
                return;
            }

            Settings.Default.WebServiceUri = WebService;
            Settings.Default.Save();

            api = new OrchestratorApi(new Uri(WebService));
            ((DataServiceContext)api).Timeout     = 10;
            ((DataServiceContext)api).Credentials = System.Net.CredentialCache.DefaultCredentials;
            api.MergeOption = MergeOption.OverwriteChanges;

            var runbookCount = api.Runbooks.Count();

            AppendOutput("#### Connected ####");

            IsConnected = true;
        }
コード例 #16
0
ファイル: SMAInterop.cs プロジェクト: tryinmybest/scorch
        /// <summary>
        /// Starts a Job for the given Runbook, Waits up to timeout for job to complete
        /// </summary>
        /// <param name="sma">Orchestrator Environment Reference</param>
        /// <param name="runbookName">Path to Runbook</param>
        /// <param name="runbookParameters">Input Parameters [Parameter Name] [Parameter Value]</param>
        /// <param name="timeOut">Timespan to wait for job to complete before timing out</param>
        /// <returns>Job</returns>
        public static Job startRunbookJob(OrchestratorApi sma, String runbookName, List <NameValuePair> runbookParameters, TimeSpan timeOut)
        {
            Job      job       = initiateRunbookJob(sma, runbookName, runbookParameters);
            var      jobId     = job.JobID;
            var      jobStatus = job.JobStatus;
            DateTime startTime = DateTime.Now;

            while (jobStatus != "Completed" && jobStatus != "Failed")
            {
                // Wait 5 seconds between polling
                Thread.Sleep(new TimeSpan(0, 0, 0, 5));

                jobStatus = sma.Jobs.Where(j => j.JobID == jobId).Select(j => j.JobStatus).AsEnumerable().First();
                if (TimeSpan.Compare(DateTime.Now - startTime, timeOut) > 0)
                {
                    break;
                }
            }

            return(sma.Jobs.Where(j => j.JobID == jobId).AsEnumerable().First());
        }
コード例 #17
0
        public String Index([FromBody] GoogleCloudDialogflowV2WebhookRequest request)
        {
            string jsonstring = "";

            OrchestratorApi oApi = new OrchestratorApi("https://platform.uipath.com", "admin", "shan999km", "shanslab");
            JObject         jobj = new JObject();
            JsonSerializer  js   = new JsonSerializer();
            //String jsonstring = "{\"fulfillmentText\": \"response text\",\"fulfillmentMessages\": [{\"simpleResponses\": {\"simpleResponses\": [   {\"textToSpeech\": \"response text\",\"displayText\": \"response text\"}]}}]}";


            // String jsonstring = "{\"fulfillmentText\": \"This is a text response\",\"fulfillmentMessages\": [{\"simpleResponses\": {\"textToSpeech\": \"this is text to speech\",\"ssml\": \"this is ssml\",\"displayText\": \"this is display text\"}}]}";
            // String jsonstring = "{\"payload\": {\"google\": {\"expectUserResponse\": true,\"richResponse\": {\"items\": [{\"simpleResponse\": {\"textToSpeech\": \"this is a simple response\"}}]}}}}";
            //request.QueryResult.Parameters.Add("email", "Testmail");
            var j = JsonConvert.SerializeObject(request.QueryResult.Parameters);

            Console.WriteLine(j);
            //////ViewData["req"] = ViewData["req"]+request.QueryResult.Parameters["Ops"].ToString()+Environment.NewLine;
            if (request.QueryResult.Parameters["Ops"].Equals("join"))
            {
                oApi.addObjectToQueue(j.ToString(), "Test");
            }

            string username  = request.QueryResult.Parameters["username"].ToString().Trim();;
            string pin       = request.QueryResult.Parameters["pin"].ToString().Trim();
            string useremail = checkUser(username, pin);

            if (!useremail.Equals(""))
            {
                j          = j.Replace("\"}", ",\"email\":\"" + useremail + "\"}");
                jsonstring = "{\"fulfillmentText\": \"response text\",\"fulfillmentMessages\": [{\"simpleResponses\": {\"simpleResponses\": [   {\"textToSpeech\": \"response text\",\"displayText\": \"response text\"}]}}],\"followupEventInput\": {\"name\": \"Dummy\",\"languageCode\": \"en-US\",\"parameters\": {\"msg\": \"password is sent to:" + useremail + "\"}}}";
                Console.WriteLine(j.ToString());
                oApi.addObjectToQueue(j.ToString(), "Test");
            }
            else
            {
                jsonstring = "{\"fulfillmentText\": \"response text\",\"fulfillmentMessages\": [{\"simpleResponses\": {\"simpleResponses\": [   {\"textToSpeech\": \"response text\",\"displayText\": \"response text\"}]}}],\"followupEventInput\": {\"name\": \"AD_Pass_Reset\",\"languageCode\": \"en-US\",\"parameters\": {\"msg\": \"Please check your pin!\"}}}";
            }

            return(jsonstring);
        }
コード例 #18
0
        public void ExecuteRunbook(string subscriptionId, OpsLogix.WAP.RunPowerShell.ApiClient.DataContracts.RunbookParameter rbParameter)
        {
            System.Configuration.ConnectionStringSettings url = System.Configuration.ConfigurationManager.ConnectionStrings["SMAUrl"];

            /*
             * var api = new OrchestratorApi(new Uri("https://sma.lab.local/00000000-0000-0000-0000-000000000000"));*/
            //var api = new OrchestratorApi(new Uri(url.ConnectionString));
            var api = new OrchestratorApi(new Uri(url.ConnectionString));

            ((DataServiceContext)api).Credentials = CredentialCache.DefaultCredentials;
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); });


            var runbook = api.Runbooks.Where(r => r.RunbookName == rbParameter.RunbookName).AsEnumerable().FirstOrDefault();

            if (runbook == null)
            {
                return;
            }


            var runbookParams = new List <NameValuePair>

            {
                new NameValuePair()
                {
                    Name = "Upn", Value = rbParameter.Upn
                },
                new NameValuePair()
                {
                    Name = "RunbookName", Value = rbParameter.RunbookName
                },
                new NameValuePair()
                {
                    Name = "SubscriptionId", Value = rbParameter.SubscriptionId
                },
                new NameValuePair()
                {
                    Name = "SelectedVmId", Value = rbParameter.SelectedVmId
                },
                new NameValuePair()
                {
                    Name = "ParamBool", Value = rbParameter.ParamBool
                },
                new NameValuePair()
                {
                    Name = "ParamString", Value = rbParameter.ParamString
                },
                new NameValuePair()
                {
                    Name = "ParamInt", Value = rbParameter.ParamInt
                },
                new NameValuePair()
                {
                    Name = "ParamDate", Value = rbParameter.ParamDate
                },
                new NameValuePair()
                {
                    Name = "ParamStringArray", Value = rbParameter.ParamStringArray
                }
            };



            OperationParameter operationParameters = new BodyOperationParameter("parameters", runbookParams);
            var uriSma     = new Uri(string.Concat(api.Runbooks, string.Format("(guid'{0}')/{1}", runbook.RunbookID, "Start")), UriKind.Absolute);
            var jobIdValue = api.Execute <Guid>(uriSma, "POST", true, operationParameters) as QueryOperationResponse <Guid>;

            if (jobIdValue == null)
            {
                return;
            }


            var jobId = jobIdValue.Single();

            Task.Factory.StartNew(() => QueryJobCompletion(jobId));
        }
コード例 #19
0
 public static Statistics GetStatistics(this Runbook runbook, OrchestratorApi orchestratorApi, List <NameValuePair> jobParameters = null)
 {
     return(runbook.EndGetStatistics(orchestratorApi, runbook.BeginGetStatistics(orchestratorApi, null, null, jobParameters)));
 }
コード例 #20
0
 public static Guid Edit(this Runbook runbook, OrchestratorApi orchestratorApi)
 {
     return(runbook.EndEdit(orchestratorApi, runbook.BeginEdit(orchestratorApi, null, null)));
 }
コード例 #21
0
 public static Guid Publish(this Runbook runbook, OrchestratorApi orchestratorApi)
 {
     return(runbook.EndPublish(orchestratorApi, runbook.BeginPublish(orchestratorApi, null, null)));
 }
コード例 #22
0
 public SmaClient(OrchestratorApi ctx)
 {
     _ctx = ctx;
 }
コード例 #23
0
 public static IAsyncResult BeginEdit(this Runbook runbook, OrchestratorApi orchestratorApi, AsyncCallback callback, object state)
 {
     return(ActionExtensions.BeginRunbookAction <Guid>(runbook, orchestratorApi, "Edit", callback, state, null));
 }
コード例 #24
0
 public static void Resume(this Job job, OrchestratorApi orchestratorApi, string label = null)
 {
     job.EndResume(orchestratorApi, job.BeginResume(orchestratorApi, null, null, label));
 }
コード例 #25
0
 public static Guid TestRunbook(this Runbook runbook, OrchestratorApi orchestratorApi, List <NameValuePair> jobParameters = null)
 {
     return(runbook.EndTestRunbook(orchestratorApi, runbook.BeginTestRunbook(orchestratorApi, null, null, jobParameters)));
 }
コード例 #26
0
ファイル: SMAInterop.cs プロジェクト: tryinmybest/scorch
 /// <summary>
 /// Starts a Job for the given Runbook, Does not wait for job to complete
 /// </summary>
 /// <param name="sma">Orchestrator Environment Reference</param>
 /// <param name="runbookName">Path to Runbook</param>
 /// <param name="runbookParameters">Input Parameters [Parameter Name] [Parameter Value]</param>
 /// <returns>Job</returns>
 public static Job startRunbookJob(OrchestratorApi sma, String runbookName, List <NameValuePair> runbookParameters)
 {
     return(initiateRunbookJob(sma, runbookName, runbookParameters));
 }
コード例 #27
0
 public static void EndResume(this Job job, OrchestratorApi orchestratorApi, IAsyncResult asyncResult)
 {
     ActionExtensions.EndJobAction(orchestratorApi, asyncResult);
 }
コード例 #28
0
 public static Guid StartOnSchedule(this Runbook runbook, OrchestratorApi orchestratorApi, Schedule schedule, List <NameValuePair> jobParameters = null)
 {
     return(runbook.EndStartOnSchedule(orchestratorApi, runbook.BeginStartOnSchedule(orchestratorApi, null, null, schedule, jobParameters)));
 }
コード例 #29
0
 public static Guid EndStartRunbook(this Runbook runbook, OrchestratorApi orchestratorApi, IAsyncResult asyncResult)
 {
     return(ActionExtensions.EndRunbookAction <Guid>(orchestratorApi, asyncResult));
 }
コード例 #30
0
 public static Statistics EndGetStatistics(this Runbook runbook, OrchestratorApi orchestratorApi, IAsyncResult asyncResult)
 {
     return(ActionExtensions.EndRunbookAction <Statistics>(orchestratorApi, asyncResult));
 }