none
Running an Orchestrator Runbook with C# RRS feed

  • Question

  • Hello everybody,

    I'm trying to start a runbook with given parameters from a web form. I have the web form built out, but my c# code isn't working. I followed the guide here but the runbook never kicks off.

    I still have to run the orchestrator console and runbook designer as Administrator so it could be that I don't have the required permissions to kick it off.

    Here is my C# code:

             var scorchSVC = new Microsoft.SystemCenter.Orchestrator.WebService.OrchestratorContext(new Uri(@"http://contoso:81/orchestrator2012/orchestrator.svc"));
             scorchSVC.Credentials = new System.Net.NetworkCredential("username", "password", "domain");
     
             var runbooks = (from rbData in scorchSVC.Runbooks
                             where rbData.Name == "Create SR from Form"
                             select rbData).ToList();
     
             var runbookpars = (from rbData in scorchSVC.RunbookParameters
                                where rbData.RunbookId == runbooks.Single().Id
                                select rbData).ToList();
     
             var input1param = (from rbData in runbookpars
                                where rbData.Name == "Title"
                                select rbData).Single();
     
             var input2param = (from rbData in runbookpars
                                where rbData.Name == "FirstName"
                                select rbData).Single();
     
             var input3param = (from rbData in runbookpars
                                where rbData.Name == "LastName"
                                select rbData).Single();
     
             var paramxml = new XDocument(
                            new XElement("Data",
                               new XElement("Parameter",
                                  new XElement("Name", input1param.Name),
                                  new XElement("ID", input1param.Id.ToString("B")),
                                  new XElement("Value", txtBox1.Text)
                                        ),
                                new XElement("Parameter",
                                  new XElement("Name", input2param.Name),
                                  new XElement("ID", input2param.Id.ToString("B")),
                                  new XElement("Value", txtBox2.Text)
                                        ),
                                new XElement("Parameter",
                                  new XElement("Name", input3param.Name),
                                  new XElement("ID", input3param.Id.ToString("B")),
                                  new XElement("Value", txtBox3.Text)
                                        )));
     
             var job = Microsoft.SystemCenter.Orchestrator.WebService.Job.CreateJob(System.Guid.NewGuid(), runbooks.Single().Id, "user1", DateTime.Now, "user1", DateTime.Now);
     
             string strParam = paramxml.Document.ToString();
     
             job.Parameters = strParam;
             scorchSVC.AddToJobs(job);
             scorchSVC.SaveChanges();

    If anyone can give me some guidance or lead me to other methods of kicking off a runbook from a web form, I'd really appreciate it.

    Thank you,

    Gary Winhoven


    Friday, July 21, 2017 2:46 PM

Answers

  • Hello,

    I've gone through both of these blogs with no luck.

    I am trying to start the runbooks via web yes.

    Thank you,

    Gary Winhoven

    Wednesday, October 11, 2017 7:19 PM

All replies