$PBExportHeader$uo_email_set.sru forward global type uo_email_set from nonvisualobject end type end forward global type uo_email_set from nonvisualobject autoinstantiate end type type variables long mailid long empid string mailuser string mailaddress string mailpsw string popset string smtpset string opemp datetime opdate string dscrp string othermsg long mailtype long popport long smtpport long ifdelmsg long gap long ifuseSSL Transaction commit_tran Transaction fj_tran end variables forward prototypes public function integer p_getinfo (long arg_mailid, ref string arg_msg) public function integer uf_save (ref string arg_msg) public function integer uf_del (long arg_mailid, ref string arg_msg) public function integer wf_ds_getmailbox (long arg_mailid, ref s_email_box arg_box[], ref string arg_msg) end prototypes public function integer p_getinfo (long arg_mailid, ref string arg_msg);int rslt = 1 if arg_mailid <= 0 then rslt = 0 arg_msg = '非法ID' goto ext end if SELECT mailID, mailuser, mailaddress, popset, popport, smtpset, smtpport, empid, mailtype, mailpsw, Opemp, Opdate, dscrp, Othermsg, gap, Ifdelmsg,ifuseSSL INTO :mailID, :mailuser, :mailaddress, :popset, :popport, :smtpset, :smtpport, :empid, :mailtype, :mailpsw, :Opemp, :Opdate, :dscrp, :Othermsg, :gap, :Ifdelmsg,:ifuseSSL FROM u_email_set WHERE mailID = :arg_mailid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '由于网络或其它原因,查询邮箱账号失败!' + commit_tran.sqlerrtext goto ext end if ext: return rslt end function public function integer uf_save (ref string arg_msg);int rslt = 1 if mailid = 0 then long ll_mailid = 0 ll_mailid = f_sys_scidentity(0,"u_email_set","mailid",arG_MSG,False, commit_tran) if ll_mailid <= 0 then rslt = 0 goto ext end if INSERT INTO u_email_set (mailID ,empid ,mailuser ,mailaddress ,mailpsw ,popset ,smtpset ,Opemp ,Opdate ,dscrp ,Othermsg ,mailtype ,popport ,smtpport ,Ifdelmsg ,gap ,ifuseSSL) VALUES (:ll_mailid ,:empid ,:mailuser ,:mailaddress ,:mailpsw ,:popset ,:smtpset ,:publ_operator ,GetDate() ,:dscrp ,:Othermsg ,:mailtype ,:popport ,:smtpport ,:Ifdelmsg ,:gap ,:ifuseSSL); if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '插入邮箱账号失败:' + commit_tran.sqlerrtext goto ext end if // 添加默认邮箱 uo_email_box box box = create uo_email_box box.commit_tran = commit_tran box.fj_tran = fj_tran // 收件箱 if box.uf_newbox(ll_mailid, 0, box.C_inbox, false, arg_msg) <> 1 then rslt = 0 destroy box goto ext end if // 发件箱 if box.uf_newbox(ll_mailid, 0, box.C_outbox, false, arg_msg) <> 1 then rslt = 0 destroy box goto ext end if // 已发件箱 if box.uf_newbox(ll_mailid, 0, box.C_sentbox, false, arg_msg) <> 1 then rslt = 0 destroy box goto ext end if // 废件箱 if box.uf_newbox(ll_mailid, 0, box.C_trunkbox, false, arg_msg) <> 1 then rslt = 0 destroy box goto ext end if destroy box mailid = ll_mailid else UPDATE u_email_set SET empid = :empid ,mailuser = :mailuser ,mailaddress = :mailaddress ,mailpsw = :mailpsw ,popset = :popset ,smtpset = :smtpset ,Opemp = :publ_operator ,Opdate = GetDate() ,dscrp = :dscrp ,Othermsg = :Othermsg ,mailtype = :mailtype ,popport = :popport ,smtpport = :smtpport ,Ifdelmsg = :Ifdelmsg ,gap = :gap ,ifuseSSL=:ifuseSSL WHERE mailid = :mailid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '更新邮箱账号失败' + commit_tran.sqlerrtext goto ext end if end if ext: if rslt = 0 then rollback using commit_tran; elseif rslt = 1 then commit using commit_tran; end if return rslt end function public function integer uf_del (long arg_mailid, ref string arg_msg);int rslt = 1 if arg_mailid <= 0 then rslt = 0 arg_msg = '错误账号ID' goto ext end if DELETE FROM u_email_fj WHERE (relid IN (SELECT ID FROM u_email_msg WHERE (mailid = :arg_mailid))) using fj_tran; if fj_tran.sqlcode <> 0 then rslt = 0 arg_msg = '删除帐号内所有附件失败,' + fj_tran.sqlerrtext goto ext end if DELETE FROM u_email_sendmx WHERE (sendid IN (SELECT ID FROM u_email_msg WHERE (mailid = :arg_mailid))) using fj_tran; if fj_tran.sqlcode <> 0 then rslt = 0 arg_msg = '删除帐号内邮件发送明细失败,' + fj_tran.sqlerrtext goto ext end if DELETE FROM u_email_msg WHERE mailid = :arg_mailid using fj_tran; if fj_tran.sqlcode <> 0 then rslt = 0 arg_msg = '删除帐号所有邮件失败,' + fj_tran.sqlerrtext goto ext end if DELETE FROM u_email_uid WHERE mailid = :arg_mailid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '删除邮件ID失败,' + commit_tran.sqlerrtext goto ext end if DELETE FROM u_email_box WHERE mailid = :arg_mailid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '删除帐号邮箱失败,' + commit_tran.sqlerrtext goto ext end if delete from u_email_set WHERE mailid = :arg_mailid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '网络原因导致删除账号失败' + commit_tran.sqlerrtext goto ext end if ext: if rslt = 1 then commit using fj_tran; commit using commit_tran; elseif rslt = 0 then rollback using fj_tran; rollback using commit_tran; end if return rslt end function public function integer wf_ds_getmailbox (long arg_mailid, ref s_email_box arg_box[], ref string arg_msg);int rslt = 1 long boxid string boxname long isdefault long ll_mailid string boxtype long parentid long picindex s_email_box s_box[] long i = 0 DECLARE cur1 CURSOR FOR SELECT boxid ,boxname ,isdefault ,mailid ,boxtype ,parentid ,picindex FROM u_email_box WHERE mailid = :arg_mailid using Commit_Tran; OPEN cur1; FETCH cur1 INTO :boxid, :boxname, :isdefault, :ll_mailid, :boxtype, :parentid, :picindex; DO WHILE Commit_Tran.sqlcode = 0 i ++ s_box[i].boxid = boxid s_box[i].boxname = boxname s_box[i].isdefault = isdefault s_box[i].mailid = ll_mailid s_box[i].boxtype = boxtype s_box[i].parentid = parentid s_box[i].picindex = picindex FETCH cur1 INTO :boxid, :boxname, :isdefault, :ll_mailid, :boxtype, :parentid, :picindex; LOOP CLOSE cur1; arg_box = s_box return rslt end function on uo_email_set.create call super::create TriggerEvent( this, "constructor" ) end on on uo_email_set.destroy TriggerEvent( this, "destructor" ) call super::destroy end on