起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 243|回复: 4

[分享]功能和功能代理

[复制链接]
发表于 2007-12-6 15:13:08 | 显示全部楼层 |阅读模式
功能代理一般作用不大,就是在功能上代理当前功能,很少用于其他情况

功能可以定义主窗体,也可以在运行期指定主窗体
例如:
设置功能的主窗体属性(MianFormName)为空,重载功能的DoRun方法来创建一个窗体作为功能主窗体
type
  TDLKJGN = class(TFunc)
  private
    {private declarations}
  public
    {public declarations}
    procedure DoRun; override;
  end;

implementation

procedure TDLKJGN.DoRun;
var
  lBizClassURL: TBizClassURL;
begin
  lBizClassURL := TBizClassURL.Create;
  lBizClassURL.BizURL.URL := 'Biz:\LZ\DLKJGN.Func\MainForm.Form';
  MainForm := Context.GetBizObject(lBizClassURL) as TForm;
  lBizClassURL.Free;
  inherited;
end;
回复

使用道具 举报

 楼主| 发表于 2007-12-6 15:18:16 | 显示全部楼层
设置功能的主窗体属性(MianFormName)为空,重载功能的DoRun方法在这个方法中,可以把功能下定义的窗体ID给MainFormName属性赋值,这样就会把相应的窗体作为功能的主窗体,用于功能下有多个窗体,根据某种条件决定谁是主窗体
type
  TBDYGN = class(TFunc)
  private
    {private declarations}
  public
    {public declarations}
    procedure DoRun; override;
  end;

implementation

procedure TBDYGN.DoRun;
begin
  if Length(Parameters)=0 then
    MainFormName := 'MAINFORM'
  else
    MainFormName := 'CT1';
  inherited;
end;
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-12-6 15:29:25 | 显示全部楼层

功能中运行另外一个功能

运行功能一般是调用系统核心库的RunFunc函数

例如,在A功能要运行B功能
1  在Studio中打开A功能,在项目管理中引入 系统空间\系统运行库\系统核心库
2  在代码中,用B功能的BizURL作为参数调用RunFunc函数,SystemCore.TSystemCore.FuncManager.RunFunc(Context, '', 'Biz:\LZ\B.Func', '', nil, False);

函数说明:
    function RunFunc(AContext: TContext; const AUniqueID, AFuncURL, AParams: string; BeforeRunFunc: TFuncNotifyEvent; Modal: Boolean): TFunc; overload;
    procedure RunFunc(AContext: TContext; const AUniqueID, AFuncURL, AParams: string; UseUI: Boolean; BeforeRunFunc: TFuncNotifyEvent; Modal: Boolean); overload;

AContext 为被运行功能的环境
AUniqueID 功能的唯一ID,首先按照这个参数在内存中找,如果找到了,就直接返回这个功能,如果找不到,则创建一个新的功能
  每一个运行起来的功能,如果没有指定这个参数,那么就会按照下面的规则生成一个唯一ID
  AFuncURL + '||' + AParams + '||' + ADeptID + '||' + APositionID + '||' + APersonID
  功能URL + '||' + 运行功能时传递的参数 + '||' + 功能环境的部门ID + '||' + 功能环境的岗位ID + '||' + 功能环境的人员ID
AFuncURL 被运行功能的BizURL
AParams 传递给被运行功能的参数,可以用Func.Parameters得到
BeforeRunFunc 在功能运行前,先执行这个事件,一般传递nil
Modal  是否模态运行,如果True,这个功能窗体就ShowModal,关闭这个功能前,不能操作其他的窗体了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-12-6 15:41:24 | 显示全部楼层
举例1:
传递参数给被运行功能
  SystemCore.TSystemCore.FuncManager.RunFunc(Context, '', 'Biz:\LZ\B.Func', edtParams.Text, nil, False);
这个edtParams.Text就是传递给B功能的参数,在B功能上
type
  TB = class(TFunc)
  private
    {private declarations}
  public
    {public declarations}
    procedure DoRun; override;
  end;

implementation

procedure TB.DoRun;
begin
  if Length(Parameters)=0 then
    MainFormName := 'MAINFORM'
  else
    MainFormName := 'CT1';
  inherited;
end;

在B功能的窗体上,可以用
FuncBroker.Func.Params得到这个传递的参数
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-12-6 15:45:38 | 显示全部楼层
举例2:在被运行功能执行之前,执行一个事件
procedure TMAINFORM.Button2Click(Sender: TObject);
begin
  SystemCore.TSystemCore.FuncManager.RunFunc(Context.GetParentContext(BizSys.IL_POSITION), '', 'Biz:\LZ\B.Func', edtParams.Text, BeforeRunSubFunc, False);
end;

procedure TMAINFORM.BeforeRunSubFunc(Sender: TObject; Func: TFunc);
var
  lPolicy: TSememicDataPolicy;
begin
  lPolicy := TSememicDataPolicy.Create(Func);
  lPolicy.BizRange.Text := '&[Biz:\OPERATION\BFDBizList.ElementGroup\BEProduct.Element]=''1''';
end;
这个BeforeRunSubFunc就会在B功能创建以后,B功能运行前执行
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-1 17:39 , Processed in 0.047226 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表