123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- $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
|