uo_email_sign.sru 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. $PBExportHeader$uo_email_sign.sru
  2. forward
  3. global type uo_email_sign from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_email_sign from nonvisualobject
  7. end type
  8. global uo_email_sign uo_email_sign
  9. type variables
  10. long id
  11. string ownerid=''
  12. string signname=''
  13. string signcontent=''
  14. private:
  15. transaction fj_tran
  16. end variables
  17. forward prototypes
  18. public subroutine uf_settrans (transaction arg_tran)
  19. public function integer uf_save (ref string arg_msg)
  20. public function integer uf_delete (integer arg_id, ref string arg_msg)
  21. public subroutine uf_reset ()
  22. public function integer uf_set_sign (integer arg_id, string arg_ownerid, ref string arg_msg)
  23. public function integer uf_get_signinfo (integer arg_id, ref string arg_signname, ref string arg_signcontent, ref string arg_msg)
  24. public function integer uf_changesign (string arg_sign, ref string arg_html, ref string arg_msg)
  25. end prototypes
  26. public subroutine uf_settrans (transaction arg_tran);fj_tran=arg_tran
  27. end subroutine
  28. public function integer uf_save (ref string arg_msg);Int rslt = 1
  29. Long cnt
  30. if id=0 then
  31. goto new
  32. end if
  33. SELECT count(*)
  34. INTO :cnt
  35. FROM U_email_signature
  36. WHERE id = :id
  37. Using fj_tran;
  38. IF cnt > 0 THEN
  39. UPDATE u_email_signature
  40. SET signname = :signname,signcontent = :signcontent
  41. WHERE id = :id
  42. Using fj_tran;
  43. IF fj_tran.SQLCode <> 0 THEN
  44. ROLLBACK using fj_tran;
  45. rslt = 0
  46. arg_msg = '更新签名失败!'
  47. ELSE
  48. COMMIT using fj_tran;
  49. END IF
  50. ELSE
  51. new:
  52. DateTime dat
  53. dat = DateTime(Today(),Now())
  54. SELECT count(*)+1
  55. INTO :id
  56. FROM u_email_signature
  57. Using fj_tran;
  58. // messagebox('',string(id))
  59. IF id > 1 THEN
  60. SELECT max(id)+1
  61. INTO :id
  62. FROM u_email_signature
  63. Using fj_tran;
  64. END IF
  65. INSERT INTO u_email_signature(id,ownerid,signname,signcontent,opdate)
  66. VALUES(:id,:ownerid,:signname,:signcontent,:dat)
  67. Using fj_tran;
  68. IF fj_tran.SQLCode <> 0 THEN
  69. ROLLBACK using fj_tran;
  70. arg_msg = '保存签名失败'
  71. rslt = 0
  72. ELSE
  73. COMMIT using fj_tran;
  74. END IF
  75. END IF
  76. RETURN rslt
  77. end function
  78. public function integer uf_delete (integer arg_id, ref string arg_msg);int rslt=1
  79. long cnt
  80. select count(*)
  81. into :cnt
  82. from u_email_signature
  83. where id=:arg_id
  84. and ownerid= :ownerid
  85. using fj_tran;
  86. if cnt=0 then
  87. rslt=0
  88. arg_msg='未找到签名,或者你不是签名持有人!'
  89. goto ext
  90. end if
  91. delete u_email_signature
  92. where id=:arg_id
  93. using fj_tran;
  94. if fj_tran.sqlcode<>0 then
  95. rslt=0
  96. arg_msg='删除签名失败!'
  97. rollback using fj_tran;
  98. else
  99. commit using fj_tran;
  100. end if
  101. ext:
  102. return rslt
  103. end function
  104. public subroutine uf_reset (); id=0
  105. signname=''
  106. signcontent='<DIV id=signName style="MARGIN-TOP: 0px; cellpadding: 0px; cellspacing: 0px" width="100%" height="100%" valign="top">签名内容 &nbsp; </DIV id=signName>'
  107. end subroutine
  108. public function integer uf_set_sign (integer arg_id, string arg_ownerid, ref string arg_msg);int rslt=1
  109. uf_reset()
  110. id=arg_id
  111. ownerid=arg_ownerid
  112. rslt=uf_get_signinfo(arg_id,ref signname,ref signcontent,ref arg_msg)
  113. return rslt
  114. end function
  115. public function integer uf_get_signinfo (integer arg_id, ref string arg_signname, ref string arg_signcontent, ref string arg_msg);int rslt=1
  116. select signcontent,signname
  117. into :arg_signcontent,:arg_signname
  118. from u_email_signature
  119. where id=:arg_id
  120. using fj_tran;
  121. if fj_tran.sqlcode<>0 then
  122. rslt=0
  123. arg_msg='获取签名内容失败!'+fj_tran.sqlerrtext
  124. end if
  125. return rslt
  126. end function
  127. public function integer uf_changesign (string arg_sign, ref string arg_html, ref string arg_msg);Int rslt = 1,cnt1,cnt2
  128. String old,tmp, signhead
  129. s_email_indexof s_rslt[]
  130. String parm[]
  131. parm[1] = '<div'
  132. parm[2] = '</div'
  133. Long st,en,st1,be = 0,fin = 0
  134. tmp = Lower(arg_html)
  135. f_all_indexof(tmp,parm,Ref s_rslt)
  136. s_email_indexof row1,row2
  137. row1 = s_rslt[1]
  138. row2 = s_rslt[2]
  139. //配对标记
  140. FOR cnt1 = 1 To UpperBound(row2.list)
  141. FOR cnt2 = UpperBound(row1.list) To 1 Step -1
  142. IF row2.list[cnt1] > row1.list[cnt2] And row1.Match[cnt2] = -1 THEN
  143. row2.Match[cnt1] = row1.list[cnt2]
  144. row1.Match[cnt2] = row2.list[cnt1]
  145. goto con
  146. END IF
  147. NEXT
  148. con:
  149. NEXT
  150. st = Pos(tmp,'id=signname')
  151. IF st > 0 THEN
  152. //已有签名
  153. // messagebox('','有')
  154. FOR cnt1 = UpperBound(row1.list) to 1 step -1
  155. IF st >= row1.list[cnt1] THEN
  156. st = row1.list[cnt1]
  157. en = pos(tmp,'>',row1.Match[cnt1])
  158. goto con1
  159. END IF
  160. NEXT
  161. con1:
  162. arg_html = Replace(arg_html,st,en - st+1,arg_sign)
  163. ELSE
  164. //没有签名
  165. // messagebox('','无')
  166. st = Pos(tmp,'id=divlereplybody')
  167. IF st > 0 THEN
  168. FOR cnt1 = 1 To UpperBound(row1.list)
  169. IF st >= row1.list[cnt1] THEN
  170. st = row1.Match[cnt1]
  171. goto con2
  172. END IF
  173. NEXT
  174. con2:
  175. arg_html = Replace(arg_html,st,1,arg_sign+'<')
  176. END IF
  177. END IF
  178. RETURN rslt
  179. end function
  180. on uo_email_sign.create
  181. call super::create
  182. TriggerEvent( this, "constructor" )
  183. end on
  184. on uo_email_sign.destroy
  185. TriggerEvent( this, "destructor" )
  186. call super::destroy
  187. end on