procedure TPersonInfoInfo.CreatePersonAndAllocate(APersonID, APersonDisplayName,
ADeptURL, APositionID: string);
var
lDeptURL: string;
lDeptBizURL, lPositionBizURL: TBizURL;
lPerson: TPerson;
lPositionMember: TOrgUnit;
begin
{ 存储时候没有'Org:', 对象使用时候都有前缀名 }
lDeptURL := FileSys.cOrgFilePrefix + ADeptURL;
lDeptBizURL := TBizURL.Create;
lPositionBizURL := TBizURL.Create;
try
lDeptBizURL.URL := lDeptURL;
lPositionBizURL:= Org.OrgSys.OrgSystem.FindPosition(APositionID).BizURL;
lPerson := Org.OrgSys.OrgSystem.CreatePerson(lDeptBizURL, APersonID, APersonDisplayName);
lPositionMember := GetPositionMember(lDeptBizURL, APositionID);
{ 如果指定岗位在指定部门下还没有,需要先分配岗位成员 }
if lPositionMember = nil then
lPositionMember := Org.OrgSys.OrgSystem.AssignPosition(lDeptBizURL, lPositionBizURL);
Org.OrgSys.OrgSystem.AssignPerson(lPositionMember.BizURL, lPerson.BizURL);
finally
lPositionBizURL.Free;
lDeptBizURL.Free;
end;
end; |