$PBExportHeader$uo_comhelper.sru
forward
global type uo_comhelper from nonvisualobject
end type
end forward

shared variables
oleobject ComMrpProxy

oleobject sv_FXAppCom // 协同模块使用

oleobject sv_ErpAppCom // 暂时用于ERP成品预测单的异步处理

oleobject sv_P1ClientCom // 后台服务连接
boolean sv_p1Connected = false
boolean sv_p1Inited = false

oleobject sv_DingTalkCom // 钉钉考勤机读数

oleobject sv_RegCom // 注册服务连接
end variables

global type uo_comhelper from nonvisualobject
end type
global uo_comhelper uo_comhelper

forward prototypes
public function oleobject uf_get_erpappcom (ref string arg_msg)
public function oleobject uf_get_p1clientcom (ref string arg_msg)
public function oleobject uf_get_dingtalkcom (ref string arg_msg)
end prototypes

public function oleobject uf_get_erpappcom (ref string arg_msg);arg_msg = ''
IF IsValid(sv_ErpAppCom) THEN
	RETURN sv_ErpAppCom
END IF
uo_reghelper lo_helper

Int rslt = 1
lo_helper = Create uo_reghelper
sv_ErpAppCom = Create oleobject
IF lo_helper.ConnectToNewObject("SanrossDll.ErpAppCom", "SanrossDll.dll", Ref sv_ErpAppCom, Ref arg_msg) <> 1 THEN
	rslt = 0
	GOTO ext
END IF

ext:
Destroy lo_helper
IF rslt = 0 THEN
	Destroy sv_ErpAppCom
END IF
RETURN sv_ErpAppCom

end function

public function oleobject uf_get_p1clientcom (ref string arg_msg);arg_msg = ''
IF sv_p1Inited THEN
	RETURN sv_P1ClientCom
END IF

uo_reghelper lo_helper

IF Not sv_p1Connected THEN
	lo_helper = Create uo_reghelper
	sv_P1ClientCom = Create oleobject
	
	IF lo_helper.ConnectToNewObject("SanrossDll.P1ClientCom", "SanrossDll.dll", Ref sv_P1ClientCom, Ref arg_msg) <> 1 THEN
		IF arg_msg = '' THEN arg_msg = "ConnectToNewObject[SanrossDll.P1ClientCom]失败"
	ELSE
		IF arg_msg <> '' THEN arg_msg = ''
	END IF
	Destroy lo_helper
	IF arg_msg = '' THEN
		sv_p1Connected = True
	ELSE
		Destroy sv_P1ClientCom
		RETURN sv_P1ClientCom
	END IF
END IF

//IF Not sv_p1Inited THEN
//	IF sys_oa_ip = '' THEN
//		arg_msg = '未开通业务后台服务,本功能不能使用'
//		RETURN sv_P1ClientCom
//	END IF
//	
//	IF sys_user_token = '' THEN
//		arg_msg = '后台服务未更新,没有用户登录信息,本功能不能使用'
//		RETURN sv_P1ClientCom
//	END IF
//	
//	Boolean lb_inited
//	lb_inited = sv_P1ClientCom.Init(sys_oa_ip, sys_oa_port, Ref arg_msg)
//	
//	IF Not lb_inited THEN
//		RETURN sv_P1ClientCom
//	END IF
//	
//	sv_p1Inited = True
//END IF

RETURN sv_P1ClientCom




end function

public function oleobject uf_get_dingtalkcom (ref string arg_msg);arg_msg = ''
IF IsValid(sv_DingTalkCom) THEN
	RETURN sv_DingTalkCom
END IF
uo_reghelper lo_helper

Int rslt = 1
lo_helper = Create uo_reghelper
sv_DingTalkCom = Create oleobject
IF lo_helper.ConnectToNewObject("SanrossDll.DingTalkCom", "SanrossDll.dll", Ref sv_DingTalkCom, Ref arg_msg) <> 1 THEN
	rslt = 0
	GOTO ext
END IF

ext:
Destroy lo_helper
IF rslt = 0 THEN
	Destroy sv_DingTalkCom
END IF
RETURN sv_DingTalkCom

end function

on uo_comhelper.create
call super::create
TriggerEvent( this, "constructor" )
end on

on uo_comhelper.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

