通过接口(API)部署任务

无论是UiPath, Automation Anywhere, BluePrism都提供了接口(API)来部署任务到机器人。

Automation Anywhere Control Room APIs

Automation Anywhere的接口分为以下几种:

  1. Authentication 认证接口
  2. Bot Login Credentials 可以更改control room上的 credential vault
  3. Bot Deployment 部署任务到runner
  4. Export and Import Bots for Bot Lifecycle Management
  5. Export Import Workload Management Configuration
  6. Get list of all queues
  7. Get list of all work items in a given queue
  8. Insert work item data to a given queue

UiPath Orchestrator APIs

UiPath的API是基于 OData (Open Data Protocol)协议的;套路基本上跟AA一样的:

  1. 先获取Authentication token;
  2. Get Release Key
  3. Get Bot Id
  4. 就可以部署一个任务到特定一个或几个机器人了;
    image.png

    image.png

    image.png

    image.png

    image.png

    image.png

    详细请参考:Swagger
    https://platform.uipath.com/swagger/ui/index#/

C#调用console发起BluePrism任务

没有找到BluePrism调用API的接口,只能通过cmd命令行的方式来发起一个任务。命令行如下:

cd C:\Program Files (x86)\Blue Prism Limited\Blue Prism Automate
AutomateC /run "HelloWorld" /resource YourPCHostName /user admin password /startp "<inputs><input name='Comment' type='text' value='Hello World' /></inputs>"

其中,input就是任务所需的参数;
最终还是要用Java或者C#来实现接口的调用或者是命令行的方式。


image.png

Tips: C# Json String转XML

首先,我们需要NewtonSoft.json这样一个NuGet的包,如果是visual studio 2017,可以直接搜索安装:

当然,如果像我一样用的是Visual Studio 2012,那么需要从网上找一下Newtonsoft.Json.dll (https://www.newtonsoft.com/json), 然后本地项目我们用的是.NET Framework4.5。

String  jsonData = "{ \"name\":\"Jane\",\"age\":\"20\",\"English\":\"70\",\"Math\":\"80\" }"; 
dynamic obj = JsonConvert.DeserializeObject<dynamic>(jsonData );
            foreach (var item in obj)
            {
                var name = item.Name;
                var value = item.Value;
                Console.WriteLine(name + ":" + value);
            }

将json string序列化转为xml的目的是作为Blue Prism的输入,从console上调起一个BP的任务:

    string strCmdText1;
            strCmdText1 = "cd C:\\Program Files\\Blue Prism Limited\\Blue Prism Automate";
            string inputParameters = "\"<inputs><input name='Comment' type='text' value='Hello World' /></inputs>\"";
            string strCmdText2 = "AutomateC /run "+taskname+" /resource robotname /user username password /startp  " + inputParameters;
            ExecuteCommand(strCmdText1, strCmdText2);

public void ExecuteCommand(string command1,string command2)
        {
            Process process = new Process();
            process.StartInfo.FileName = "cmd.exe";
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardInput = true;
            // The following commands are needed to redirect the standard output.
            // This means that it will be redirected to the Process.StandardOutput StreamReader.
            process.StartInfo.RedirectStandardOutput = true;
            process.Start();
            process.StandardInput.WriteLine(command1);
            process.StandardInput.WriteLine(command2);
            process.StandardInput.Flush();
            process.StandardInput.Close();
            process.WaitForExit();
            Console.WriteLine(process.StandardOutput.ReadToEnd());
            /*Console.ReadKey();*/
        }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容