uo_email_set.sru 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. $PBExportHeader$uo_email_set.sru
  2. forward
  3. global type uo_email_set from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_email_set from nonvisualobject autoinstantiate
  7. end type
  8. type variables
  9. long mailid
  10. long empid
  11. string mailuser
  12. string mailaddress
  13. string mailpsw
  14. string popset
  15. string smtpset
  16. string opemp
  17. datetime opdate
  18. string dscrp
  19. string othermsg
  20. long mailtype
  21. long popport
  22. long smtpport
  23. long ifdelmsg
  24. long gap
  25. long ifuseSSL
  26. Transaction commit_tran
  27. Transaction fj_tran
  28. end variables
  29. forward prototypes
  30. public function integer p_getinfo (long arg_mailid, ref string arg_msg)
  31. public function integer uf_save (ref string arg_msg)
  32. public function integer uf_del (long arg_mailid, ref string arg_msg)
  33. public function integer wf_ds_getmailbox (long arg_mailid, ref s_email_box arg_box[], ref string arg_msg)
  34. end prototypes
  35. public function integer p_getinfo (long arg_mailid, ref string arg_msg);int rslt = 1
  36. if arg_mailid <= 0 then
  37. rslt = 0
  38. arg_msg = '非法ID'
  39. goto ext
  40. end if
  41. SELECT mailID, mailuser, mailaddress, popset,
  42. popport, smtpset, smtpport, empid, mailtype,
  43. mailpsw, Opemp, Opdate, dscrp, Othermsg, gap, Ifdelmsg,ifuseSSL
  44. INTO :mailID, :mailuser, :mailaddress, :popset,
  45. :popport, :smtpset, :smtpport, :empid, :mailtype,
  46. :mailpsw, :Opemp, :Opdate, :dscrp, :Othermsg, :gap, :Ifdelmsg,:ifuseSSL
  47. FROM u_email_set
  48. WHERE mailID = :arg_mailid using commit_tran;
  49. if commit_tran.sqlcode <> 0 then
  50. rslt = 0
  51. arg_msg = '由于网络或其它原因,查询邮箱账号失败!' + commit_tran.sqlerrtext
  52. goto ext
  53. end if
  54. ext:
  55. return rslt
  56. end function
  57. public function integer uf_save (ref string arg_msg);int rslt = 1
  58. if mailid = 0 then
  59. long ll_mailid = 0
  60. ll_mailid = f_sys_scidentity(0,"u_email_set","mailid",arG_MSG,False, commit_tran)
  61. if ll_mailid <= 0 then
  62. rslt = 0
  63. goto ext
  64. end if
  65. INSERT INTO u_email_set
  66. (mailID
  67. ,empid
  68. ,mailuser
  69. ,mailaddress
  70. ,mailpsw
  71. ,popset
  72. ,smtpset
  73. ,Opemp
  74. ,Opdate
  75. ,dscrp
  76. ,Othermsg
  77. ,mailtype
  78. ,popport
  79. ,smtpport
  80. ,Ifdelmsg
  81. ,gap
  82. ,ifuseSSL)
  83. VALUES
  84. (:ll_mailid
  85. ,:empid
  86. ,:mailuser
  87. ,:mailaddress
  88. ,:mailpsw
  89. ,:popset
  90. ,:smtpset
  91. ,:publ_operator
  92. ,GetDate()
  93. ,:dscrp
  94. ,:Othermsg
  95. ,:mailtype
  96. ,:popport
  97. ,:smtpport
  98. ,:Ifdelmsg
  99. ,:gap
  100. ,:ifuseSSL);
  101. if commit_tran.sqlcode <> 0 then
  102. rslt = 0
  103. arg_msg = '插入邮箱账号失败:' + commit_tran.sqlerrtext
  104. goto ext
  105. end if
  106. // 添加默认邮箱
  107. uo_email_box box
  108. box = create uo_email_box
  109. box.commit_tran = commit_tran
  110. box.fj_tran = fj_tran
  111. // 收件箱
  112. if box.uf_newbox(ll_mailid, 0, box.C_inbox, false, arg_msg) <> 1 then
  113. rslt = 0
  114. destroy box
  115. goto ext
  116. end if
  117. // 发件箱
  118. if box.uf_newbox(ll_mailid, 0, box.C_outbox, false, arg_msg) <> 1 then
  119. rslt = 0
  120. destroy box
  121. goto ext
  122. end if
  123. // 已发件箱
  124. if box.uf_newbox(ll_mailid, 0, box.C_sentbox, false, arg_msg) <> 1 then
  125. rslt = 0
  126. destroy box
  127. goto ext
  128. end if
  129. // 废件箱
  130. if box.uf_newbox(ll_mailid, 0, box.C_trunkbox, false, arg_msg) <> 1 then
  131. rslt = 0
  132. destroy box
  133. goto ext
  134. end if
  135. destroy box
  136. mailid = ll_mailid
  137. else
  138. UPDATE u_email_set
  139. SET empid = :empid
  140. ,mailuser = :mailuser
  141. ,mailaddress = :mailaddress
  142. ,mailpsw = :mailpsw
  143. ,popset = :popset
  144. ,smtpset = :smtpset
  145. ,Opemp = :publ_operator
  146. ,Opdate = GetDate()
  147. ,dscrp = :dscrp
  148. ,Othermsg = :Othermsg
  149. ,mailtype = :mailtype
  150. ,popport = :popport
  151. ,smtpport = :smtpport
  152. ,Ifdelmsg = :Ifdelmsg
  153. ,gap = :gap
  154. ,ifuseSSL=:ifuseSSL
  155. WHERE mailid = :mailid using commit_tran;
  156. if commit_tran.sqlcode <> 0 then
  157. rslt = 0
  158. arg_msg = '更新邮箱账号失败' + commit_tran.sqlerrtext
  159. goto ext
  160. end if
  161. end if
  162. ext:
  163. if rslt = 0 then
  164. rollback using commit_tran;
  165. elseif rslt = 1 then
  166. commit using commit_tran;
  167. end if
  168. return rslt
  169. end function
  170. public function integer uf_del (long arg_mailid, ref string arg_msg);int rslt = 1
  171. if arg_mailid <= 0 then
  172. rslt = 0
  173. arg_msg = '错误账号ID'
  174. goto ext
  175. end if
  176. DELETE FROM u_email_fj
  177. WHERE (relid IN
  178. (SELECT ID
  179. FROM u_email_msg
  180. WHERE (mailid = :arg_mailid))) using fj_tran;
  181. if fj_tran.sqlcode <> 0 then
  182. rslt = 0
  183. arg_msg = '删除帐号内所有附件失败,' + fj_tran.sqlerrtext
  184. goto ext
  185. end if
  186. DELETE FROM u_email_sendmx
  187. WHERE (sendid IN
  188. (SELECT ID
  189. FROM u_email_msg
  190. WHERE (mailid = :arg_mailid))) using fj_tran;
  191. if fj_tran.sqlcode <> 0 then
  192. rslt = 0
  193. arg_msg = '删除帐号内邮件发送明细失败,' + fj_tran.sqlerrtext
  194. goto ext
  195. end if
  196. DELETE FROM u_email_msg
  197. WHERE mailid = :arg_mailid using fj_tran;
  198. if fj_tran.sqlcode <> 0 then
  199. rslt = 0
  200. arg_msg = '删除帐号所有邮件失败,' + fj_tran.sqlerrtext
  201. goto ext
  202. end if
  203. DELETE FROM u_email_uid
  204. WHERE mailid = :arg_mailid using commit_tran;
  205. if commit_tran.sqlcode <> 0 then
  206. rslt = 0
  207. arg_msg = '删除邮件ID失败,' + commit_tran.sqlerrtext
  208. goto ext
  209. end if
  210. DELETE FROM u_email_box
  211. WHERE mailid = :arg_mailid using commit_tran;
  212. if commit_tran.sqlcode <> 0 then
  213. rslt = 0
  214. arg_msg = '删除帐号邮箱失败,' + commit_tran.sqlerrtext
  215. goto ext
  216. end if
  217. delete from u_email_set WHERE mailid = :arg_mailid using commit_tran;
  218. if commit_tran.sqlcode <> 0 then
  219. rslt = 0
  220. arg_msg = '网络原因导致删除账号失败' + commit_tran.sqlerrtext
  221. goto ext
  222. end if
  223. ext:
  224. if rslt = 1 then
  225. commit using fj_tran;
  226. commit using commit_tran;
  227. elseif rslt = 0 then
  228. rollback using fj_tran;
  229. rollback using commit_tran;
  230. end if
  231. return rslt
  232. end function
  233. public function integer wf_ds_getmailbox (long arg_mailid, ref s_email_box arg_box[], ref string arg_msg);int rslt = 1
  234. long boxid
  235. string boxname
  236. long isdefault
  237. long ll_mailid
  238. string boxtype
  239. long parentid
  240. long picindex
  241. s_email_box s_box[]
  242. long i = 0
  243. DECLARE cur1 CURSOR FOR SELECT boxid
  244. ,boxname
  245. ,isdefault
  246. ,mailid
  247. ,boxtype
  248. ,parentid
  249. ,picindex
  250. FROM u_email_box
  251. WHERE mailid = :arg_mailid using Commit_Tran;
  252. OPEN cur1;
  253. FETCH cur1 INTO :boxid, :boxname, :isdefault, :ll_mailid, :boxtype, :parentid, :picindex;
  254. DO WHILE Commit_Tran.sqlcode = 0
  255. i ++
  256. s_box[i].boxid = boxid
  257. s_box[i].boxname = boxname
  258. s_box[i].isdefault = isdefault
  259. s_box[i].mailid = ll_mailid
  260. s_box[i].boxtype = boxtype
  261. s_box[i].parentid = parentid
  262. s_box[i].picindex = picindex
  263. FETCH cur1 INTO :boxid, :boxname, :isdefault, :ll_mailid, :boxtype, :parentid, :picindex;
  264. LOOP
  265. CLOSE cur1;
  266. arg_box = s_box
  267. return rslt
  268. end function
  269. on uo_email_set.create
  270. call super::create
  271. TriggerEvent( this, "constructor" )
  272. end on
  273. on uo_email_set.destroy
  274. TriggerEvent( this, "destructor" )
  275. call super::destroy
  276. end on