控件使用
# 控件使用
以下是在工作流的脚本中可以使用的控件,以及使用方法的说明。
# 1. RestAPI
FastBPM中的RestAPI控件作为客户端使用,可向其它服务发送请求。使用的示例如下:
//回调事件,接收返回的信息
procedure OnRestAPIResultData(Sender:TObject;AResult:String);
begin
ShowMessage(AResult);
end;
//主程序
var
rest: TRestAPI;
begin
rest := TRestAPI.Create(nil);
try
//绑定事件
rest.OnResultData := 'OnRestAPIResultData';
//属性赋值
//API的描述信息
rest.Caption := 'GUID';
//设置RestAPI服务器,格式如下,端口号后面不要加 '/'
rest.Server := 'https://fastweb.isoface.cn:1443';
//如果基础地址后有其它的相对地址,可加至此。
rest.Url := '';
//期望返回的内容类型
rest.ContentType := 'text/html';
//请求方法 rmPOST、rmGET、rmPUT、rmDELETE
rest.Method := rmGET;
//URL参数定义,如有多个参数则分成多行,如下所示。
rest.Params.Add('restapi=script');
rest.Params.Add('apiname=guid');
//调用
rest.Send;
finally
//释放
rest.Free;
end;
end.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 2. 远程打印
远程打印功能由Flying提供,FastBPM中提供了客户端控件TFlying
,方便用户在自定程序中使用。
在使用前,请先参考Flying 报表设计说明设计定义数据源格式,以及需要使用的报表格式。
FastBPM中使用的示例如下:
//配合FastERP2中的远程打印自定按钮实现远程打印的功能
var
F: TFlying;
DA: TRFDataSet;
DB: TRFDataSet;
begin
//创建TFlying控件
F := TFlying.Create(nil);
DA := TRFDataSet.Create(nil);
DB := TRFDataSet.Create(nil);
try
DA.Connection := UGDM.DBConnection;
DB.Connection := UGDM.DBConnection;
DA.ConnectionDefName := 'fasterp2';
DB.ConnectionDefName := 'fasterp2';
//此处的SQL查询,查询的结果中包含的字段与报表设计环节定义的数据源的字段一致
DA.SQL.Text := 'select * from SdShipOrder where shipno = ''IVL20240129001''';
DB.SQL.Text := 'select * from SdShipPart where shipno = ''IVL20240129001''';
//从自定程序的URL参数中获取参数值,并赋值
DA.OpenData;
DB.OpenData;
if (DA.RecordCount > 0) and (DB.RecordCount > 0) then
begin
F.PrintOptions.PrintType := HTTP;
F.PrintOptions.ReportName := 'fasterp2_shiporder.fr3';
F.HTTPOptions.Host := '127.0.0.1';
F.HTTPOptions.Port := 8801;
F.PrintOptions.Data.Add('"AData":'+DA.ToJsonArrayString);
F.PrintOptions.Data.Add('"BData":'+DB.ToJsonArrayString);
F.Print;
end;
finally
//执行完成,释放内存
DA.Free;
DB.Free;
F.Free;
end;
end.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38