在PeopleSoft系统中,存在某个回写操作时需要调用CI的方式回写,但CI的权限不希望公开授权时,亦或回写数据到某个组件时希望是体现系统自动回写时,此时可以考虑在当前用户操作系统时,使用技术手段切换其他指定的用户来操作,操作完成之后再切换会自己账户。
具体技术方式如下面两个封装的函数。
/*--------------------------------------------------------------*
| UserGUI: 当前用户切换指定用户
*--------------------------------------------------------------*/
method DoSwitchUserByCurrUser
/+ &_operatorid as String +/
/+ Returns String +/
Local string &_return = "";
Local ApiObject &oSession_Imprt;
Local string &suer = &_operatorid;
If None(&suer) Then
&suer = "PS";
End-If;
&oSession_Imprt = GetSession();
&oSession_Imprt.connect(1, "", &suer, "", 0);
SetLanguage("ZHS");
&_return = &suer;
Return &_return;
end-method;
/*--------------------------------------------------------------*
| UserGUI: PS用户切换当前用户
*--------------------------------------------------------------*/
method DoSwitchCurrUserByUser
/+ &_operatorid as String +/
Local ApiObject &oSession_Imprt;
/*结束&oSession_Imprt*/
&oSession_Imprt = GetSession();
&oSession_Imprt.disconnect();
/*重新登录原来session,否则页面直接超时登出*/;
&oSession_Imprt = GetSession();
&oSession_Imprt.connect(1, "", &_operatorid, "", 0);
SetLanguage("ZHS"); /*重新设置登录语言为中文,否则默认为ENG。*/
end-method;