123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- $PBExportHeader$uo_email_sign.sru
- forward
- global type uo_email_sign from nonvisualobject
- end type
- end forward
- global type uo_email_sign from nonvisualobject
- end type
- global uo_email_sign uo_email_sign
- type variables
- long id
- string ownerid=''
- string signname=''
- string signcontent=''
- private:
- transaction fj_tran
- end variables
- forward prototypes
- public subroutine uf_settrans (transaction arg_tran)
- public function integer uf_save (ref string arg_msg)
- public function integer uf_delete (integer arg_id, ref string arg_msg)
- public subroutine uf_reset ()
- public function integer uf_set_sign (integer arg_id, string arg_ownerid, ref string arg_msg)
- public function integer uf_get_signinfo (integer arg_id, ref string arg_signname, ref string arg_signcontent, ref string arg_msg)
- public function integer uf_changesign (string arg_sign, ref string arg_html, ref string arg_msg)
- end prototypes
- public subroutine uf_settrans (transaction arg_tran);fj_tran=arg_tran
- end subroutine
- public function integer uf_save (ref string arg_msg);Int rslt = 1
- Long cnt
- if id=0 then
- goto new
- end if
- SELECT count(*)
- INTO :cnt
- FROM U_email_signature
- WHERE id = :id
- Using fj_tran;
-
- IF cnt > 0 THEN
- UPDATE u_email_signature
- SET signname = :signname,signcontent = :signcontent
- WHERE id = :id
- Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- ROLLBACK using fj_tran;
- rslt = 0
- arg_msg = '更新签名失败!'
- ELSE
- COMMIT using fj_tran;
- END IF
- ELSE
- new:
- DateTime dat
- dat = DateTime(Today(),Now())
-
- SELECT count(*)+1
- INTO :id
- FROM u_email_signature
- Using fj_tran;
- // messagebox('',string(id))
- IF id > 1 THEN
- SELECT max(id)+1
- INTO :id
- FROM u_email_signature
- Using fj_tran;
- END IF
-
- INSERT INTO u_email_signature(id,ownerid,signname,signcontent,opdate)
- VALUES(:id,:ownerid,:signname,:signcontent,:dat)
- Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- ROLLBACK using fj_tran;
- arg_msg = '保存签名失败'
- rslt = 0
- ELSE
- COMMIT using fj_tran;
- END IF
- END IF
- RETURN rslt
- end function
- public function integer uf_delete (integer arg_id, ref string arg_msg);int rslt=1
- long cnt
- select count(*)
- into :cnt
- from u_email_signature
- where id=:arg_id
- and ownerid= :ownerid
- using fj_tran;
- if cnt=0 then
- rslt=0
- arg_msg='未找到签名,或者你不是签名持有人!'
- goto ext
- end if
- delete u_email_signature
- where id=:arg_id
- using fj_tran;
- if fj_tran.sqlcode<>0 then
- rslt=0
- arg_msg='删除签名失败!'
- rollback using fj_tran;
- else
- commit using fj_tran;
- end if
- ext:
- return rslt
- end function
- public subroutine uf_reset (); id=0
- signname=''
- signcontent='<DIV id=signName style="MARGIN-TOP: 0px; cellpadding: 0px; cellspacing: 0px" width="100%" height="100%" valign="top">签名内容 </DIV id=signName>'
-
- end subroutine
- public function integer uf_set_sign (integer arg_id, string arg_ownerid, ref string arg_msg);int rslt=1
- uf_reset()
- id=arg_id
- ownerid=arg_ownerid
- rslt=uf_get_signinfo(arg_id,ref signname,ref signcontent,ref arg_msg)
- return rslt
- end function
- public function integer uf_get_signinfo (integer arg_id, ref string arg_signname, ref string arg_signcontent, ref string arg_msg);int rslt=1
- select signcontent,signname
- into :arg_signcontent,:arg_signname
- from u_email_signature
- where id=:arg_id
- using fj_tran;
- if fj_tran.sqlcode<>0 then
- rslt=0
- arg_msg='获取签名内容失败!'+fj_tran.sqlerrtext
- end if
- return rslt
- end function
- public function integer uf_changesign (string arg_sign, ref string arg_html, ref string arg_msg);Int rslt = 1,cnt1,cnt2
- String old,tmp, signhead
- s_email_indexof s_rslt[]
- String parm[]
- parm[1] = '<div'
- parm[2] = '</div'
- Long st,en,st1,be = 0,fin = 0
- tmp = Lower(arg_html)
- f_all_indexof(tmp,parm,Ref s_rslt)
- s_email_indexof row1,row2
- row1 = s_rslt[1]
- row2 = s_rslt[2]
- //配对标记
- FOR cnt1 = 1 To UpperBound(row2.list)
- FOR cnt2 = UpperBound(row1.list) To 1 Step -1
- IF row2.list[cnt1] > row1.list[cnt2] And row1.Match[cnt2] = -1 THEN
- row2.Match[cnt1] = row1.list[cnt2]
- row1.Match[cnt2] = row2.list[cnt1]
- goto con
- END IF
- NEXT
- con:
- NEXT
- st = Pos(tmp,'id=signname')
- IF st > 0 THEN
- //已有签名
- // messagebox('','有')
- FOR cnt1 = UpperBound(row1.list) to 1 step -1
- IF st >= row1.list[cnt1] THEN
- st = row1.list[cnt1]
- en = pos(tmp,'>',row1.Match[cnt1])
- goto con1
- END IF
- NEXT
- con1:
- arg_html = Replace(arg_html,st,en - st+1,arg_sign)
- ELSE
- //没有签名
- // messagebox('','无')
- st = Pos(tmp,'id=divlereplybody')
- IF st > 0 THEN
-
- FOR cnt1 = 1 To UpperBound(row1.list)
- IF st >= row1.list[cnt1] THEN
- st = row1.Match[cnt1]
- goto con2
- END IF
- NEXT
- con2:
- arg_html = Replace(arg_html,st,1,arg_sign+'<')
-
- END IF
- END IF
- RETURN rslt
- end function
- on uo_email_sign.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_email_sign.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|