起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 2732|回复: 2

如何获取当前操作员相关信息

[复制链接]
发表于 2006-7-28 19:04:38 | 显示全部楼层 |阅读模式
在系统中获取当前操作员信息有两种方式:(第二种方法只适用于X3的版本,COM+不适用)
1、通过当前环境来获取,要求当前环境链中必须要有人员信息
var
lContextCurrent: Business.Model.TContextCurrent;
begin
  lContextCurrent := Business.Model.TContextCurrent.Create(Self.Context);
  try
    cPersonID := lContextCurrent.Operator.ID;           //当前操作者ID
    cGW       := lContextCurrent.PositionMember.ID;  //当前操作者岗位ID
    cDeptID   := lContextCurrent.Dept.ID;               //当前操作者部门ID
  finally
    lContextCurrent.Free;

      以上方法在系统中很多地方都用到,例如:表达式编辑器中用来作表达式参数的组织机构函数等,都是通过环境来取人员相关信息的。

2、使用系统函数
   在“ 业务模型\系统空间\系统运行库\系统核心库”中
   TSystemCore.Operator
      在主界面中需要获取用户信息时,由于还没有环境信息,所以必须使用此种方法。
  TSystemCore.Operator.Positions[0].PersonMember.ID  //当前操作者ID
    TSystemCore.Operator.Positions[0].PositionMember.ID  //当前操作者岗位ID
    TSystemCore.Operator.Positions[0].PositionMember.Parent.ID  //当前操作者部门ID
  TSystemCore.Operator.Positions[0].PositionMember.Parent.Parent.ID //当前操作者机构ID


注:以下的方法已经过时,不能正确执行。
  //业务模型\系统空间\用户界面基础\库\公共组件库
  TCommonComponentLibrary.UserSystem.CurrentUser.ID
回复

使用道具 举报

发表于 2007-3-8 09:28:21 | 显示全部楼层
1楼中,TSystemCore.Operator.Positions[0]取的是当前人员所有身份中的第一个

如果在登录时选择了岗位,在主界面中可以通过FDefaultPosition来获取当前登录的岗位。
如果用自动方式登录,FDefaultPosition是空值nil
回复 支持 反对

使用道具 举报

发表于 2007-3-14 09:37:23 | 显示全部楼层
procedure TCurrentOperator.GetOperator;
var
  lContextCurrent : TContextCurrent;
  lPassWord : string;
begin
  lContextCurrent := TContextCurrent.Create(FContext);
  try
    FID := lContextCurrent.Operator.ID ;
    FPassWord :=  OrgSys.OrgSystem.GetPerson(FID).Password;
    FDisplayName := lContextCurrent.Operator.DisplayName;
    FChamberID := SystemUtils.TContextUtils.GetDept(FContext).ID;
    FChamberName := SystemUtils.TContextUtils.GetDept(FContext).DisplayName;
    FPositionID :=  SystemUtils.TContextUtils.GetPositionMember(FContext).ID;
    FPositionName :=  SystemUtils.TContextUtils.GetPositionMember(FContext).DisplayName;
    FDeptID := SystemUtils.TContextUtils.GetDept(FContext).Parent.ID;
    FDeptName := SystemUtils.TContextUtils.GetDept(FContext).Parent.DisplayName;

  finally
    lContextCurrent.Free;
  end;
end;
回复 支持 反对

使用道具 举报

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

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-4-20 13:40 , Processed in 0.049395 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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