123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- $PBExportHeader$uo_email_box.sru
- forward
- global type uo_email_box from nonvisualobject
- end type
- end forward
- global type uo_email_box from nonvisualobject
- end type
- global uo_email_box uo_email_box
- type variables
- long boxid
- string boxname
- long isdefault
- long mailid
- string boxtype
- long parentid
- long picindex
- Transaction commit_tran
- Transaction fj_tran
- PROTECTEDWRITE string C_inbox = '收件箱'
- PROTECTEDWRITE string C_outbox = '发件箱'
- PROTECTEDWRITE string C_sentbox = '已发件箱'
- PROTECTEDWRITE string C_trunkbox = '废件箱'
- PROTECTEDWRITE string C_userDefine = '新邮箱'
- end variables
- forward prototypes
- public function integer uf_newbox (long arg_mailid, long arg_parentid, string arg_name, boolean arg_if_commit, ref string arg_msg)
- public function integer p_getinfo (long arg_boxid, ref string arg_msg)
- public function integer uf_rename (long arg_boxid, string arg_newname, ref string arg_msg)
- public function integer uf_del (long arg_boxid, ref string arg_msg)
- end prototypes
- public function integer uf_newbox (long arg_mailid, long arg_parentid, string arg_name, boolean arg_if_commit, ref string arg_msg);int rslt = 1
- long ll_boxid
- ll_boxid = f_sys_scidentity(0,"u_email_box","boxid",arG_MSG,False, commit_tran)
- if ll_boxid <= 0 then
- rslt = 0
- goto ext
- end if
- long ll_ifdefault
- string ls_boxtype
- long ll_picindex
- if arg_name = C_inbox OR arg_name = C_outbox OR arg_name = C_sentbox OR arg_name = C_trunkbox then
- ll_ifdefault = 1
- ls_boxtype = arg_name
- if arg_name = C_inbox then
- ll_picindex = 3
- elseif arg_name = C_outbox then
- ll_picindex = 4
- elseif arg_name = C_sentbox then
- ll_picindex = 5
- elseif arg_name = C_trunkbox then
- ll_picindex = 6
- end if
- else
- ll_ifdefault = 0
- ls_boxtype = C_userDefine
- ll_picindex = 9
- end if
- INSERT INTO u_email_box
- (boxid
- ,boxname
- ,isdefault
- ,mailid
- ,boxtype
- ,parentid
- ,picindex)
- VALUES
- (:ll_boxid
- ,:arg_name
- ,:ll_ifdefault
- ,:arg_mailid
- ,:ls_boxtype
- ,:arg_parentid
- ,:ll_picindex) using commit_tran;
- if commit_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '新建子目录失败,' + commit_tran.sqlerrtext
- goto ext
- end if
- boxid = ll_boxid
- boxname = arg_name
- isdefault = ll_ifdefault
- mailid = arg_mailid
- boxtype = ls_boxtype
- parentid = arg_parentid
- picindex = ll_picindex
- ext:
- if rslt = 0 then
- rollback using commit_tran;
- elseif arg_if_commit then
- commit using commit_tran;
- end if
- return rslt
- end function
- public function integer p_getinfo (long arg_boxid, ref string arg_msg);int rslt = 1
- if arg_boxid <= 0 then
- rslt = 0
- arg_msg = '非法唯一码'
- goto ext
- end if
- long ll_cnt
- SELECT COUNT(0) INTO :ll_cnt FROM u_email_box WHERE boxid = :arg_boxid using commit_tran;
- if commit_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询邮箱数量失败,' + commit_tran.sqlerrtext
- goto ext
- end if
- if ll_cnt = 0 then
- rslt = 0
- arg_msg = '邮箱不存在'
- goto ext
- end if
- SELECT boxid
- ,boxname
- ,isdefault
- ,mailid
- ,boxtype
- ,parentid
- ,picindex
- INTO :boxid,
- :boxname,
- :isdefault,
- :mailid,
- :boxtype,
- :parentid,
- :picindex
- FROM u_email_box
- WHERE boxid = :arg_boxid 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_rename (long arg_boxid, string arg_newname, ref string arg_msg);int rslt = 1
- if p_getinfo(arg_boxid, arg_msg) <> 1 then
- rslt = 0
- goto ext
- end if
- if isdefault = 1 then
- rslt = 0
- arg_msg = '默认邮箱不能重命名'
- goto ext
- end if
- UPDATE u_email_box SET boxname = :arg_newname WHERE boxid = :arg_boxid using commit_tran;
- if commit_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '目录重命名失败,' + commit_tran.sqlerrtext
- goto ext
- end if
- boxname = arg_newname
- ext:
- if rslt = 0 then
- rollback using commit_tran;
- else
- commit using commit_tran;
- end if
- return rslt
- end function
- public function integer uf_del (long arg_boxid, ref string arg_msg);int rslt = 1
- if p_getinfo(arg_boxid, arg_msg) <> 1 then
- rslt = 0
- goto ext
- end if
- long ll_cnt
- SELECT COUNT(0) INTO :ll_cnt FROM u_email_msg WHERE boxid = :arg_boxid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询邮箱内邮件数量失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- if ll_cnt > 0 then
- rslt = 0
- arg_msg = '邮箱内含有邮件,不能删除'
- goto ext
- end if
- SELECT COUNT(0) INTO :ll_cnt FROM u_email_box WHERE parentid = :arg_boxid using commit_tran;
- if commit_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询子邮箱数量失败,' + commit_tran.sqlerrtext
- goto ext
- end if
- if ll_cnt > 0 then
- rslt = 0
- arg_msg = '邮箱内包含子邮箱,不能删除'
- goto ext
- end if
- if isdefault = 1 then
- rslt = 0
- arg_msg = '默认邮箱不能删除'
- goto ext
- end if
- DELETE FROM u_email_box WHERE boxid = :arg_boxid using commit_tran;
- if commit_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '删除邮箱失败,' + commit_tran.sqlerrtext
- goto ext
- end if
- ext:
- if rslt = 0 then
- rollback using commit_tran;
- else
- commit using commit_tran;
- end if
- return rslt
- end function
- on uo_email_box.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_email_box.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|