123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497 |
- $PBExportHeader$uo_email.sru
- forward
- global type uo_email from nonvisualobject
- end type
- end forward
- global type uo_email from nonvisualobject
- event ue_revemail ( )
- end type
- global uo_email uo_email
- type variables
- //string fjfilepathname = 'fjtemp'
- //s_email_set s_set[],cur_set
- //long sumcnt
- //long finishcnt
- Transaction commit_tran
- Transaction fj_tran
- string C_Sys_admsg_fj = 'Sys_admsg_fj'
- string C_u_email_fj = 'u_email_fj'
- string C_from_file = 'from_file'
- end variables
- forward prototypes
- public function integer f_update_send (long arg_sendid, datetime arg_senddate, long arg_mailsize, ref string arg_msg)
- public function integer f_check_rep (ref s_email_sendmx arg_sendmx, ref string arg_msg)
- public function integer f_send (s_email_set arg_set, s_email_send arg_send, s_email_sendmx arg_sendmx, s_email_fj arg_fj, ref string arg_msg)
- public function integer uf_get_send (long arg_sendid, ref s_email_send arg_s_send, ref string arg_msg)
- public subroutine wf_str_replace (ref string arg_source, string arg_str1, string arg_str2)
- public function integer wf_mail_gethtml (long arg_msgid, ref string arg_text, ref string arg_msg)
- public function integer uf_get_sendmx (long arg_sendid, ref s_email_sendmx arg_sendmx[], ref string arg_msg)
- public function integer wf_mail_getfjblob (long arg_fjid, ref blob arg_fjblob, ref string arg_msg)
- public function integer uf_get_fj (long arg_relid, ref s_email_lvfj arg_lvfj[], ref string arg_msg, boolean arg_withblob)
- public function integer wf_admsg_getfjblob (long arg_fjid, ref blob arg_fjblob, ref string arg_msg)
- public function integer f_del (long arg_id, ref string arg_msg)
- public function integer wf_ds_get_mail_set (long arg_mailid, ref s_email_set arg_set, ref string arg_msg)
- public function long wf_ds_gettrunkbox (long arg_mailid)
- public function long wf_ds_getsendbox (long arg_mailid)
- public function string wf_ds_getuser (long arg_id)
- public function string wf_ds_getaddress (long arg_id)
- public function string wf_ds_getuseraddress (long arg_id)
- public function integer wf_ds_move_msg_box (long arg_id, long arg_boxid, ref string arg_msg)
- public function integer f_del_move_msg (long arg_id, ref string arg_msg)
- public function integer f_unread (long arg_revid, ref string arg_msg)
- public function integer f_read (long arg_revid, ref string arg_msg)
- public function long f_save (ref s_email_send arg_send, s_email_sendmx arg_sendmx[], s_email_lvfj arg_fj[], ref string arg_msg)
- public function long f_import_eml (ref s_email_send arg_send, s_email_lvfj arg_fj[], ref string arg_msg)
- public function integer f_change_id (long arg_fromid, long arg_toid, ref string arg_msg)
- end prototypes
- event ue_revemail();//Long i
- //string ls_msg
- //FOR i = 1 TO sumcnt
- // IF pf_revemail(s_set[i],ls_msg) = 0 THEN
- //
- // END IF
- //NEXT
- //
- end event
- public function integer f_update_send (long arg_sendid, datetime arg_senddate, long arg_mailsize, ref string arg_msg);Long rslt = 1
- //UPDATE u_email_send
- // SET senddate = :arg_senddate,
- // mailsize = :arg_mailsize,
- // mailtype = 1
- // Where u_email_send.sendid = :arg_sendid
- // and not exists (select 0 from u_email_sendmx where sendid = u_email_send.sendID and status = 0)
- // using commit_tran;
- //IF commit_tran.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = '更新邮件信息失败'
- //END IF
- RETURN rslt
- end function
- public function integer f_check_rep (ref s_email_sendmx arg_sendmx, ref string arg_msg);Long cnt,rslt = 1,ll_id
- cnt = 0
- SELECT count(*)
- INTO :cnt
- FROM u_email_rep
- WHERE empid = :sys_empid AND
- LTRIM(RTRIM(Lower(mailAddress))) = LTRIM(RTRIM(Lower(:arg_sendmx.revaddress))) Using commit_tran;
- IF commit_tran.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询联系人列表失败~n"+commit_tran.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- ll_id = f_sys_scidentity(0,"u_email_rep","repID",arG_MSG,True, commit_tran) //数据commit事务)
- IF ll_id <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- INSERT INTO u_email_rep
- ( repID,
- empid,
- mailname,
- mailaddress,
- Opemp,
- Opdate,
- reptype )
- VALUES ( :ll_id,
- :sys_empid,
- :arg_sendmx.revname ,
- LTRIM(RTRIM(LOWER(:arg_sendmx.revaddress))),
- :publ_operator,
- getdate(),
- 1 ) Using commit_tran ;
- IF commit_tran.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "插入联系人列表失败~n"+commit_tran.SQLErrText
- GOTO ext
- END IF
- arg_sendmx.reltype = 0
- arg_sendmx.relid = ll_id
- ELSE
- IF arg_sendmx.reltype = 0 Or arg_sendmx.reltype = 3 THEN//类型为通讯录和手动的查询联系人表
- SELECT top 1 repID,
- mailname
- INTO :arg_sendmx.relid,
- :arg_sendmx.revname
- FROM u_email_rep
- WHERE empid = :sys_empid AND
- LTRIM(RTRIM(Lower(mailAddress))) = LTRIM(RTRIM(Lower(:arg_sendmx.revaddress))) Using commit_tran;
- arg_sendmx.reltype = 0
- END IF
- END IF
- ext:
- RETURN rslt
- end function
- public function integer f_send (s_email_set arg_set, s_email_send arg_send, s_email_sendmx arg_sendmx, s_email_fj arg_fj, ref string arg_msg);Long rslt = 1,k,l
- //Blob lb_fj
- //String ls_pathname[]
- //Long ll_fjid ,it_max
- //arg_msg = ''
- //it_max = 0
- //oleobject jmail
- //jmail = CREATE oleobject
- //jmail.ConnectToNewObject("JMail.Message")
- //jmail.Charset = 'GB2312'
- //jmail.ISOEncodeHeaders = TRUE
- //jmail.silent = TRUE
- //jmail.Logging = TRUE
- //
- //jmail.FROM = arg_set.mailAddress //发件人邮箱
- //jmail.FromName = arg_set.mailuser //发件人
- //jmail.Subject = Trim(arg_send.Subject) //邮件主题
- //jmail.MailServerUserName = arg_set.mailAddress //发件邮箱登录账户
- //jmail.MailServerPassword = arg_set.mailpsw //发件邮箱用户密码
- //jmail.Priority = arg_send.Priority //优先级
- ////jmail.Body = Trim(arg_send.Textbody) + "~r~n" //邮件内容
- //jmail.htmlbody = string(arg_send.htmlbody)
- //FOR l = 1 TO UpperBound(arg_fj.fjid)
- // if arg_fj.fjid[l] = 0 then continue
- // ll_fjid = arg_fj.fjid[l]
- // SELECTBLOB Fileblob
- // INTO :lb_fj
- // FROM u_email_fj
- // Where (fjid = :ll_fjid) using fj_tran;
- //
- // IF fj_tran.SQLCode <> 0 THEN
- // arg_msg = '下载附件失败'
- //
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // it_max ++
- // ls_pathname[it_max] = sys_cur_path+fjfilepathname+'\'+arg_fj.Filename[l]
- // IF FileExists(ls_pathname[it_max]) THEN FileDelete(ls_pathname[it_max])
- // IF f_blobtofile(ls_pathname[it_max],lb_fj,arg_msg) = 0 THEN
- //
- // rslt = 0
- // GOTO ext
- // ELSE
- // jmail.AddAttachment(ls_pathname[it_max])
- // END IF
- //NEXT
- //
- //////添加联系人
- //long ll_sent_num = 0
- //if arg_send.normal_flag = 2 then
- // FOR k = 1 TO UpperBound(arg_sendmx.revaddress)
- // IF Trim(arg_sendmx.revaddress[k]) <> '' THEN
- // jmail.AddRecipient(Trim(arg_sendmx.revaddress[k]))
- // if not jmail.send(arg_set.smtpset) then
- // rslt = 0
- // arg_msg = arg_msg + "发送[" + Trim(arg_sendmx.revaddress[k]) + "]失败![" + arg_set.mailAddress + "]邮箱设置不正确或者没有连接网络~r~n"
- // else
- // // DONE : 修改收件人列表状态
- // ll_sent_num ++
- // update u_email_sendmx
- // set u_email_sendmx.status = 1
- // where u_email_sendmx.sendid = :arg_send.sendid and u_email_sendmx.printid = :arg_sendmx.printid[k] using commit_tran;
- // if commit_tran.sqlcode <> 0 then
- // rslt = 0
- // arg_msg = arg_msg + "更新收件人[" + Trim(arg_sendmx.revaddress[k]) + "]状态失败~r~n"
- // else
- // commit;
- // end if
- //
- // end if
- // jmail.ClearRecipients()
- // END IF
- // NEXT
- //else
- // jmail.ClearRecipients()
- // for k = 1 to upperBound(arg_sendmx.revaddress)
- // IF Trim(arg_sendmx.revaddress[k]) <> '' THEN
- //// Messagebox('', arg_sendmx.revaddress[k])
- // if arg_send.normal_flag = 0 then
- // jmail.AddRecipient(Trim(arg_sendmx.revaddress[k]))
- // elseif arg_send.normal_flag = 1 then
- // jmail.AddRecipientBCC(Trim(arg_sendmx.revaddress[k]))
- // end if
- // end if
- // next
- //
- // //// debug///////
- //// oleobject stream
- //// stream = CREATE oleobject
- //// stream.ConnectToNewObject("Adodb.Stream")
- //// stream.Type = 1
- //// stream.open()
- //// jmail.SaveToStream(stream)
- //// stream.position = 0
- //// blob lb_message
- //// setnull(lb_message)
- //// lb_message = stream.read(stream.size)
- //// stream.close()
- //// stream.disconnectobject( )
- //// destroy stream
- //// messagebox('', string(lb_message))
- // //// debug///////
- //
- // if not jmail.send(arg_set.smtpset) then
- // rslt = 0
- // arg_msg = arg_msg + "发送失败![" + arg_set.mailAddress + "]邮箱设置不正确或者没有连接网络~r~n"
- // else
- // // DONE : 修改收件人列表状态
- // for k = 1 to upperBound(arg_sendmx.revaddress)
- // ll_sent_num ++
- // update u_email_sendmx
- // set u_email_sendmx.status = 1
- // where u_email_sendmx.sendid = :arg_send.sendid and u_email_sendmx.printid = :arg_sendmx.printid[k] using commit_tran;
- // if commit_tran.sqlcode <> 0 then
- // rslt = 0
- // arg_msg = arg_msg + "更新收件人[" + Trim(arg_sendmx.revaddress[k]) + "]状态失败~r~n"
- // else
- // commit;
- // end if
- // next
- // end if
- // jmail.ClearRecipients()
- //end if
- //
- //// DONE: 删除临时文件
- //for l = 1 to it_max
- // IF FileExists(ls_pathname[l]) THEN FileDelete(ls_pathname[l])
- //next
- //// DONE: 更改邮件状态
- //if ll_sent_num > 0 then
- // if f_update_send(arg_send.sendid, jmail.date, jmail.size, arg_msg) = 0 then
- // rslt = 0
- // arg_msg = arg_msg + "更改邮件状态失败~r~n"
- // goto ext
- // end if
- //else
- // rslt = 0
- // arg_msg = arg_msg + "没有更改邮件发送状态"
- // GOTO ext
- //end if
- //
- //
- ////IF jmail.Send(arg_set.smtpset) THEN //ls_host为发件邮箱服务器
- ////
- //// jmail.ClearAttachments()
- //// jmail.ClearRecipients()
- ////
- //// IF f_update_send(arg_send.sendid,jmail.Date,jmail.size,arg_msg) = 0 THEN
- //// rslt = 0
- //// GOTO ext
- //// END IF
- ////
- //// for l = 1 to it_max
- //// IF FileExists(ls_pathname[l]) THEN FileDelete(ls_pathname[l])
- //// next
- ////
- ////ELSE
- //// arg_msg = "发送失败![" + arg_set.mailAddress + "]邮箱设置不正确或者没有连接网络"
- //// rslt = 0
- //// GOTO ext
- ////END IF
- //
- //ext:
- //jmail.Close()
- //DESTROY jmail
- RETURN rslt
- end function
- public function integer uf_get_send (long arg_sendid, ref s_email_send arg_s_send, ref string arg_msg);integer rslt = 1
- string ls_html
- SELECT u_email_msg.ID,
- u_email_msg.boxid,
- u_email_msg.mailID,
- u_email_msg.mailaddress,
- u_email_msg.mailtype,
- u_email_msg.Subject,
- u_email_msg.Priority,
- u_email_msg.senddate,
- u_email_msg.Opdate,
- u_email_msg.opemp,
- u_email_msg.mailsize,
- u_email_msg.sendOption,
- u_email_msg.senduser,
- u_email_msg.sendaddress,
- u_email_msg.revdate
- INTO :arg_s_send.sendid,
- :arg_s_send.boxid,
- :arg_s_send.mailid,
- :arg_s_send.mailaddress,
- :arg_s_send.mailtype,
- :arg_s_send.Subject,
- :arg_s_send.Priority,
- :arg_s_send.senddate,
- :arg_s_send.opdate,
- :arg_s_send.opemp,
- :arg_s_send.mailsize,
- :arg_s_send.normal_flag,
- :arg_s_send.senduser,
- :arg_s_send.sendaddress,
- :arg_s_send.revdate
- FROM u_email_msg
- where u_email_msg.ID = :arg_sendID using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = "获取邮件失败,id:" + string(arg_sendid)
- goto ext
- end if
- if wf_mail_gethtml(arg_sendid, arg_s_send.htmlbody, arg_msg) <> 1 then
- rslt = 0
- goto ext
- end if
- // DONE: revlist
- ext:
- return rslt
- end function
- public subroutine wf_str_replace (ref string arg_source, string arg_str1, string arg_str2);long ll_pos
- ll_pos = pos(arg_source, arg_str1, 1)
- do while ll_pos > 0
- arg_source = Replace(arg_source, ll_pos, len(arg_str1), arg_str2)
- ll_pos = pos(arg_source, arg_str1,1)
- LOOP
- end subroutine
- public function integer wf_mail_gethtml (long arg_msgid, ref string arg_text, ref string arg_msg);int rslt = 1
- long len
- BLOB lb
- SELECT DATALENGTH(htmlbody) INTO :len FROM u_email_msg
- WHERE ID = :arg_msgid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询html长度失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- if len = 0 then
- SELECT DATALENGTH(textbody) INTO :len FROM u_email_msg
- WHERE ID = :arg_msgid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询text长度失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- if len > 2048 then
- SELECTBLOB textbody INTO :lb FROM u_email_msg
- WHERE ID = :arg_msgid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询text失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- arg_text = string(lb)
- wf_str_replace(arg_text, '~r~n', '<BR>')
- wf_str_replace(arg_text, '~r', '<BR>')
- wf_str_replace(arg_text, '~n', '<BR>')
- else
- SELECT textbody INTO :arg_text FROM u_email_msg
- WHERE ID = :arg_msgid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询text失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- wf_str_replace(arg_text, '~r~n', '<BR>')
- wf_str_replace(arg_text, '~r', '<BR>')
- wf_str_replace(arg_text, '~n', '<BR>')
- end if
- elseif len > 2048 then
- SELECTBLOB htmlbody INTO :lb FROM u_email_msg
- WHERE ID = :arg_msgid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询html失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- arg_text = string(lb)
- else
- SELECT htmlbody INTO :arg_text FROM u_email_msg
- WHERE ID = :arg_msgid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询html失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- end if
- ext:
- return rslt
- end function
- public function integer uf_get_sendmx (long arg_sendid, ref s_email_sendmx arg_sendmx[], ref string arg_msg);Int rslt = 1,i,NO_MXCHECK
- i = 0
- s_email_sendmx s_sendmx[]
- long sendid, printid, reltype, relid
- string revaddress, revname
- DECLARE CUR_INWAERMX CURSOR FOR
- SELECT u_email_sendmx.sendid,
- u_email_sendmx.printid,
- u_email_sendmx.reltype,
- u_email_sendmx.relid,
- u_email_sendmx.revaddress,
- u_email_sendmx.revname
- FROM u_email_sendmx
- where u_email_sendmx.sendid = :arg_sendid using fj_tran;
- OPEN CUR_INWAERMX;
- FETCH CUR_INWAERMX INTO :sendid,
- :printid,
- :reltype,
- :relid,
- :revaddress,
- :revname;
- DO WHILE fj_tran.SQLCode = 0
- i++
- s_sendmx[i].sendid = sendid
- s_sendmx[i].printid = printid
- s_sendmx[i].reltype = reltype
- s_sendmx[i].relid = relid
- s_sendmx[i].revaddress = revaddress
- s_sendmx[i].revname = revname
- FETCH CUR_INWAERMX INTO :sendid,
- :printid,
- :reltype,
- :relid,
- :revaddress,
- :revname;
- LOOP
- CLOSE CUR_INWAERMX;
- arg_sendmx = s_sendmx
- RETURN rslt
- end function
- public function integer wf_mail_getfjblob (long arg_fjid, ref blob arg_fjblob, ref string arg_msg);int rslt = 1
- SELECTBLOB fileblob INTO :arg_fjblob FROM u_email_fj
- WHERE fjid = :arg_fjid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '获取附件失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- ext:
- return rslt
- end function
- public function integer uf_get_fj (long arg_relid, ref s_email_lvfj arg_lvfj[], ref string arg_msg, boolean arg_withblob);Int rslt = 1,i
- i = 0
- long fjid, fjtype, relid
- string filename, filetype,cid
- s_email_lvfj l_s_lvfj[]
- DECLARE CUR_INWAERMX CURSOR FOR
- SELECT u_email_fj.fjid,
- u_email_fj.fjtype,
- u_email_fj.Relid,
- u_email_fj.filename,
- u_email_fj.filetype ,
- u_email_fj.cid
- FROM u_email_fj
- where u_email_fj.Relid = :arg_Relid using fj_tran;
- OPEN CUR_INWAERMX;
- FETCH CUR_INWAERMX INTO :fjid,
- :fjtype,
- :Relid,
- :filename,
- :filetype,
- :cid;
- DO WHILE fj_tran.SQLCode = 0
- i++
- l_s_lvfj[i].fjid = fjid
- l_s_lvfj[i].fjtype = fjtype
- l_s_lvfj[i].Relid = Relid
- l_s_lvfj[i].filename = filename
- l_s_lvfj[i].filetype = C_u_email_fj
- l_s_lvfj[i].cid = cid
- FETCH CUR_INWAERMX INTO :fjid,
- :fjtype,
- :Relid,
- :filename,
- :filetype,
- :cid;
- LOOP
- CLOSE CUR_INWAERMX;
- if arg_withBlob then
- for i = 1 to UPPERBOUND(l_s_lvfj)
- if wf_mail_getfjblob(l_s_lvfj[i].fjid, l_s_lvfj[i].fileblob, arg_msg) <> 1 then
- rslt = 0
- goto ext
- end if
- next
- end if
- arg_lvfj = l_s_lvfj
- ext:
- RETURN rslt
- end function
- public function integer wf_admsg_getfjblob (long arg_fjid, ref blob arg_fjblob, ref string arg_msg);int rslt = 1
- SELECTBLOB fileblob INTO :arg_fjblob FROM Sys_admsg_fj
- WHERE fjid = :arg_fjid 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 f_del (long arg_id, ref string arg_msg);Int rslt = 1
- // fjtype : 0:发件箱 1:收件箱
- // mailtype : 0:未发,未读1:已发,已读2:废件箱
- DELETE FROM u_email_msg WHERE ID = :arg_id 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 = :arg_id using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '删除收件人列表失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- DELETE FROM u_email_fj WHERE relid = :arg_id using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '删除附件失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING fj_tran;
- ELSE
- COMMIT USING fj_tran;
- END IF
- RETURN rslt
- end function
- public function integer wf_ds_get_mail_set (long arg_mailid, ref s_email_set arg_set, ref string arg_msg);int rslt = 1
- SELECT mailuser, mailaddress
- INTO :arg_set.mailuser, :arg_set.mailaddress
- 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
- arg_set.mailid = arg_mailid
- ext:
- return rslt
- end function
- public function long wf_ds_gettrunkbox (long arg_mailid);long rslt = -1
- SELECT TOP 1 boxid INTO :rslt
- FROM u_email_box
- WHERE mailid = :arg_mailid AND boxtype = '废件箱' using Commit_Tran;
- if Commit_Tran.sqlcode <> 0 then
- return -1
- end if
- return rslt
- end function
- public function long wf_ds_getsendbox (long arg_mailid);long rslt = -1
- SELECT TOP 1 boxid INTO :rslt
- FROM u_email_box
- WHERE mailid = :arg_mailid AND boxtype = '发件箱' using Commit_Tran;
- if Commit_Tran.sqlcode <> 0 then
- return -1
- end if
- return rslt
- end function
- public function string wf_ds_getuser (long arg_id);string rslt = ''
- long ll_cnt
- SELECT COUNT(0) INTO :ll_cnt FROM u_email_sendmx
- WHERE sendid = :arg_id using fj_tran;
- if fj_tran.sqlcode <> 0 then
- return rslt
- end if
- if ll_cnt = 0 then
- return rslt
- end if
- string revname
- declare cur1 CURSOR FOR
- SELECT revname FROM u_email_sendmx
- WHERE sendid = :arg_id ORDER BY printid using fj_tran;
- open cur1;
- fetch cur1 INTO :revname;
- do while fj_tran.sqlcode = 0
- rslt = rslt + revname + ';'
- fetch cur1 INTO :revname;
- LOOP
- close cur1;
- rslt = left(rslt, len(rslt) - 1)
- return rslt
- end function
- public function string wf_ds_getaddress (long arg_id);string rslt = ''
- long ll_cnt
- SELECT COUNT(0) INTO :ll_cnt FROM u_email_sendmx
- WHERE sendid = :arg_id using fj_tran;
- if fj_tran.sqlcode <> 0 then
- return rslt
- end if
- if ll_cnt = 0 then
- return rslt
- end if
- string revname
- declare cur1 CURSOR FOR
- SELECT revaddress FROM u_email_sendmx
- WHERE sendid = :arg_id ORDER BY printid using fj_tran;
- open cur1;
- fetch cur1 INTO :revname;
- do while fj_tran.sqlcode = 0
- rslt = rslt + revname + ';'
- fetch cur1 INTO :revname;
- LOOP
- close cur1;
- rslt = left(rslt, len(rslt) - 1)
- return rslt
- end function
- public function string wf_ds_getuseraddress (long arg_id);string rslt = ''
- long ll_cnt
- SELECT COUNT(0) INTO :ll_cnt FROM u_email_sendmx
- WHERE sendid = :arg_id using fj_tran;
- if fj_tran.sqlcode <> 0 then
- return rslt
- end if
- if ll_cnt = 0 then
- return rslt
- end if
- string revname
- declare cur1 CURSOR FOR
- SELECT revname + '<' + revaddress + '>' as address FROM u_email_sendmx
- WHERE sendid = :arg_id ORDER BY printid using fj_tran;
- open cur1;
- fetch cur1 INTO :revname;
- do while fj_tran.sqlcode = 0
- rslt = rslt + revname + ';'
- fetch cur1 INTO :revname;
- LOOP
- close cur1;
- rslt = left(rslt, len(rslt) - 1)
- return rslt
- end function
- public function integer wf_ds_move_msg_box (long arg_id, long arg_boxid, ref string arg_msg);int rslt = 1
- long mailid
- SELECT mailid INTO :mailid
- 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
- UPDATE u_email_msg SET boxid = :arg_boxid, mailid = :mailid
- WHERE ID = :arg_id using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '移动邮件失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- if fj_tran.SQLNRows <> 1 then
- rslt = 0
- arg_msg = '原邮件已经不存在'
- goto ext
- end if
- ext:
- if rslt = 0 then
- rollback using fj_tran;
- else
- commit using fj_tran;
- end if
- return rslt
- end function
- public function integer f_del_move_msg (long arg_id, ref string arg_msg);int rslt = 1
- long mailid, boxid
- SELECT mailid, boxid INTO :mailid, :boxid
- FROM u_email_msg WHERE ID = :arg_id using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询邮件失败,邮件可能不存在,' + fj_tran.sqlerrtext
- goto ext
- end if
- long trunkboxid
- trunkboxid = wf_ds_gettrunkbox(mailid)
- if trunkboxid <= 0 then
- rslt = 0
- arg_msg = '获取默认废件箱失败'
- goto ext
- end if
- if boxid = trunkboxid then
- if f_del(arg_id, arg_msg) <> 1 then
- rslt = 0
- goto ext
- end if
- else
- if wf_ds_move_msg_box(arg_id, trunkboxid, arg_msg) <> 1 then
- rslt = 0
- goto ext
- end if
- end if
- ext:
- if rslt = 0 then
- rollback using fj_tran;
- else
- commit using fj_tran;
- end if
- return rslt
- end function
- public function integer f_unread (long arg_revid, ref string arg_msg);Long rslt = 1
- UPDATE u_email_msg
- SET status = '未读'
- Where u_email_msg.ID = :arg_revid using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "更新收件标记失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK using fj_tran;
- ELSE
- COMMIT using fj_tran;
- END IF
- RETURN rslt
- end function
- public function integer f_read (long arg_revid, ref string arg_msg);Long rslt = 1
- UPDATE u_email_msg
- SET status = '已读'
- Where u_email_msg.ID = :arg_revid using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "更新收件标记失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK using fj_tran;
- ELSE
- COMMIT using fj_tran;
- END IF
- RETURN rslt
- end function
- public function long f_save (ref s_email_send arg_send, s_email_sendmx arg_sendmx[], s_email_lvfj arg_fj[], ref string arg_msg);Int rslt = 1
- Long i,totalSize = 0
- Long cnt,ll_id = 0
- Long ll_fjid
- String ls_msg
- Boolean has_copy = False
- COMMIT Using fj_tran;
- fj_tran.AutoCommit = True
- IF UpperBound(arg_fj) > 0 THEN
- FOR cnt = 1 To UpperBound(arg_fj)
-
- totalSize+= arg_fj[cnt].filesize
- IF totalSize > 100*1024*1024 THEN
- //附件超过100M
- rslt = 0
- arg_msg = '附件大于100m,不能发送!'
- GOTO ext
- END IF
- NEXT
- // MessageBox('',String(totalSize))
- END IF
- s_email_set s_set
- IF wf_ds_get_mail_set(arg_send.mailid, s_set, arg_msg) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- arg_send.mailAddress = s_set.mailAddress
- arg_send.senduser = s_set.mailuser
- arg_send.sendaddress = s_set.mailAddress
- IF arg_send.NTFlag = 1 THEN
- arg_send.NTMail = arg_send.mailAddress
- END IF
- IF arg_send.sendid = 0 THEN
- ll_id = f_sys_scidentity(0,"u_email_msg","ID",arg_msg,True, commit_tran) //数据commit事务)
- IF ll_id <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- arg_send.boxid = wf_ds_getsendbox(arg_send.mailid)
- IF arg_send.boxid = -1 THEN
- rslt = 0
- arg_msg = '获取默认发件箱失败'
- GOTO ext
- END IF
-
-
- INSERT INTO u_email_msg
- ( ID,
- boxid,
- mailID,
- mailaddress,
- mailtype,
- Subject,
- Priority,
- // senddate,
- Opdate,
- opemp,
- mailsize,
- SendOption,
- textbody,
- htmlbody,
- senduser,
- sendaddress,
- ntflag,
- ntname,
- ntmail
-
- )
- VALUES ( :ll_id,
- :arg_send.boxid,
- :arg_send.mailID,
- :arg_send.mailaddress,
- :arg_send.mailtype,
- :arg_send.Subject,
- :arg_send.Priority,
- // :arg_send.senddate,
- getdate(),
- :publ_operator,
- :arg_send.mailsize,
- :arg_send.normal_flag,
- :arg_send.textbody,
- :arg_send.htmlbody,
- :s_set.mailuser,
- :s_set.mailAddress,
- :arg_send.ntflag,
- :arg_send.ntname,
- :arg_send.NTMail) Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入发送邮件失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
- ///////// //
- IF arg_send.senddate > DateTime(Today(),Now()) THEN
- UPDATE u_email_msg Set senddate = :arg_send.senddate,mailtype='定时发件' where ID=:ll_id Using fj_tran;
- END IF
-
- /////// //
-
-
- IF UpperBound(arg_sendmx) = 0 THEN
- rslt = 0
- arg_msg = "发送邮件收件人不能为空~n"
- GOTO ext
- END IF
-
- FOR i = 1 To UpperBound(arg_sendmx)
- INSERT INTO u_email_sendmx
- ( sendid,
- printid,
- reltype,
- relid,
- revaddress,
- revname ,
- repname,
- addtype)
- VALUES ( :ll_id,
- :arg_sendmx[i].printid,
- :arg_sendmx[i].reltype,
- :arg_sendmx[i].relid,
- :arg_sendmx[i].revaddress,
- :arg_sendmx[i].revname ,
- :arg_sendmx[i].repname,
- :arg_sendmx[i].addtype
- ) Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入发送邮件收件人明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- // IF UpperBound(arg_fj.Filename) = 0 THEN GOTO ext
- FOR i = 1 To UpperBound(arg_fj)
- ll_fjid = f_sys_scidentity(0,"u_email_fj","fjid",arg_msg,True, commit_tran) //数据commit事务)
- IF ll_fjid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- // DONE filesize
- IF arg_fj[i].FileType = C_Sys_admsg_fj THEN
- IF wf_admsg_getfjblob(arg_fj[i].fjid, arg_fj[i].fileblob, arg_msg) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSEIF arg_fj[i].FileType = C_u_email_fj THEN
- IF wf_mail_getfjblob(arg_fj[i].fjid, arg_fj[i].fileblob, arg_msg) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSEIF arg_fj[i].FileType = C_from_file THEN
-
- END IF
-
- arg_fj[i].filesize = Len(arg_fj[i].fileblob)
-
-
- INSERT INTO u_email_fj
- ( fjid,
- fjtype,
- Relid,
- filename,
- filesize,
- cid
- ) VALUES
- ( :ll_fjid,
- 0,
- :ll_id,
- :arg_fj[i].filename,
- :arg_fj[i].filesize,
- :arg_fj[i].cid
- ) Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入发送邮件的附件明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
-
- IF arg_fj[i].filesize > 0 THEN
- COMMIT Using fj_tran;
- UpdateBlob u_email_fj
- Set fileblob = :arg_fj[i].fileblob
- Where fjid = :ll_fjid Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入发送邮件的附件明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
- COMMIT Using fj_tran;
- END IF
- NEXT
-
- arg_send.sendid = ll_id
-
- ELSE
-
- ll_id = f_sys_scidentity(0,"u_email_msg","ID",arg_msg,True, commit_tran) //数据commit事务)
- IF ll_id <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- // 备份邮件
- INSERT INTO u_email_msg
- (ID, boxid, mailid, mailaddress, subject, mailsize, textbody, htmlbody, orgdata, senduser, sendaddress, sendOption, priority, senddate, opdate, opemp,
- revdate, tuid, mailtype, status)
- SELECT :ll_id AS Expr1, boxid, mailid, mailaddress, subject, mailsize, textbody, htmlbody, orgdata, senduser, sendaddress, sendOption, priority, senddate,
- opdate, opemp, revdate, tuid, mailtype, status
- FROM u_email_msg AS u_email_msg_1
- Where (ID = :arg_send.sendid) Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '备份邮件失败,' + fj_tran.SQLErrText
- f_del(ll_id, ls_msg)
- GOTO ext
- END IF
-
- // 备份发件明细
- INSERT INTO u_email_sendmx
- (sendid, printid, reltype, relid, revaddress, revname, dscrp, status)
- SELECT :ll_id AS Expr1, printid, reltype, relid, revaddress, revname, dscrp, status
- FROM u_email_sendmx AS u_email_sendmx_1
- Where (sendid = :arg_send.sendid) Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '备份邮件明细失败,' + fj_tran.SQLErrText
- f_del(ll_id, ls_msg)
- GOTO ext
- END IF
-
- // 备份附件
- Long arr_fjid[]
- i = 0
- DECLARE cur1 CURSOR FOR
- SELECT fjid FROM u_email_fj
- Where relid = :arg_send.sendid Using fj_tran;
- OPEN cur1;
- FETCH cur1 Into :ll_fjid;
- DO WHILE fj_tran.SQLCode = 0
- i++
- arr_fjid[i] = ll_fjid
- FETCH cur1 Into :ll_fjid;
- LOOP
- CLOSE cur1;
-
- FOR i = 1 To UpperBound(arr_fjid)
- ll_fjid = f_sys_scidentity(0,"u_email_fj","fjid",arg_msg,True, commit_tran) //数据commit事务)
- IF ll_fjid <= 0 THEN
- rslt = 0
- f_del(ll_id, ls_msg)
- GOTO ext
- END IF
-
- INSERT INTO u_email_fj
- (fjid, fjtype, Relid, filename, fileblob, filesize, filetype)
- SELECT :ll_fjid AS Expr1, fjtype, :ll_id, filename, fileblob, filesize, filetype
- FROM u_email_fj AS u_email_fj_1
- Where (fjid = :arr_fjid[i]) Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '备份附件失败,' + fj_tran.SQLErrText
- f_del(ll_id, ls_msg)
- GOTO ext
- END IF
-
- NEXT
-
- has_copy = True
-
-
- UPDATE u_email_msg
- SET mailID = :arg_send.mailID,
- boxid = :arg_send.boxid,
- mailaddress = :arg_send.mailaddress,
- Subject = :arg_send.Subject,
- Priority = :arg_send.Priority,
- Opdate = getdate(),
- opemp = :publ_operator,
- mailsize = :arg_send.mailsize,
- mailtype = :arg_send.mailtype,
- sendOption = :arg_send.normal_flag,
- textbody = :arg_send.textbody,
- htmlbody = :arg_send.htmlbody,
- senduser = :s_set.mailuser,
- sendaddress = :s_set.mailaddress
- Where ID = :ll_id Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "更新发送邮件失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
-
- DELETE FROM u_email_sendmx
- Where sendid = :ll_id Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除发送邮件收件人明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
-
- IF UpperBound(arg_sendmx) = 0 THEN
- rslt = 0
- arg_msg = '没有收件人'
- GOTO ext
- END IF
-
- FOR i = 1 To UpperBound(arg_sendmx)
-
- INSERT INTO u_email_sendmx
- ( sendid,
- printid,
- reltype,
- relid,
- revaddress,
- revname ,
- addtype
- )
- VALUES ( :ll_id,
- :arg_sendmx[i].printid,
- :arg_sendmx[i].reltype,
- :arg_sendmx[i].relid,
- :arg_sendmx[i].revaddress,
- :arg_sendmx[i].revname,
- :arg_sendmx[i].addtype
- ) Using fj_tran ;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入发送邮件收件人明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- DELETE FROM u_email_fj
- Where relid = :ll_id Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除发送邮件的附件明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
-
- // IF UpperBound(arg_fj.Filename) = 0 THEN GOTO ext
- FOR i = 1 To UpperBound(arg_fj)
- ll_fjid = f_sys_scidentity(0,"u_email_fj","fjid",arg_msg,True, commit_tran) //数据commit事务)
- IF ll_fjid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- // DONE filesize
- IF arg_fj[i].FileType = C_Sys_admsg_fj THEN
- IF wf_admsg_getfjblob(arg_fj[i].fjid, arg_fj[i].fileblob, arg_msg) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSEIF arg_fj[i].FileType = C_u_email_fj THEN
- IF wf_mail_getfjblob(arg_fj[i].fjid, arg_fj[i].fileblob, arg_msg) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSEIF arg_fj[i].FileType = C_from_file THEN
-
- END IF
-
- arg_fj[i].filesize = Len(arg_fj[i].fileblob)
-
- //////////// //
- INSERT INTO u_email_fj
- ( fjid,
- fjtype,
- Relid,
- filename,
- filesize,
- cid
- ) VALUES
- ( :ll_fjid,
- 0,
- :ll_id,
- :arg_fj[i].filename,
- :arg_fj[i].filesize,
- :arg_fj[i].cid
- ) Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入发送邮件的附件明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- ELSE
- COMMIT Using fj_tran;
- END IF
-
- IF arg_fj[i].filesize > 0 THEN
- UpdateBlob u_email_fj
- Set fileblob = :arg_fj[i].fileblob
- Where fjid = :ll_fjid Using fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入发送邮件的附件明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
- END IF
- NEXT
-
- fj_tran.AutoCommit = False
- f_del(arg_send.sendid, ls_msg)
- f_change_id(ll_id, arg_send.sendid, ls_msg)
-
- END IF
- ext:
- fj_tran.AutoCommit = False
- IF rslt = 0 THEN
- IF arg_send.sendid = 0 And ll_id > 0 THEN
- f_del(ll_id, ls_msg)
- END IF
-
- IF has_copy And arg_send.sendid > 0 THEN
- f_del(ll_id, ls_msg)
- END IF
-
- ELSE
-
- END IF
- RETURN rslt
- end function
- public function long f_import_eml (ref s_email_send arg_send, s_email_lvfj arg_fj[], ref string arg_msg);Int rslt = 1
- Long i
- Long cnt,ll_id = 0
- long ll_fjid
- string ls_msg
- IF arg_send.sendid = 0 THEN
- ll_id = f_sys_scidentity(0,"u_email_msg","ID",arG_MSG,TRUE, commit_tran) //数据commit事务)
- IF ll_id <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- INSERT INTO u_email_msg
- ( ID,
- boxid,
- mailID,
- mailaddress,
- mailtype,
- Subject,
- Priority,
- // senddate,
- Opdate,
- opemp,
- mailsize,
- SendOption,
- textbody,
- htmlbody,
- senduser,
- sendaddress,
- status,
- revdate)
- VALUES ( :ll_id,
- :arg_send.boxid,
- :arg_send.mailID,
- :arg_send.mailaddress,
- :arg_send.mailtype,
- :arg_send.Subject,
- :arg_send.Priority,
- // :arg_send.senddate,
- getdate(),
- :publ_operator,
- :arg_send.mailsize,
- :arg_send.normal_flag,
- :arg_send.textbody,
- :arg_send.htmlbody,
- :arg_send.senduser,
- :arg_send.sendaddress,
- :arg_send.status,
- GETDATE()) USING fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "插入发送邮件失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
-
- commit using fj_tran;
- UPDATEBLOB u_email_msg set orgdata = :arg_send.orgdata WHERE id = :ll_id using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '更新原始数据失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- commit using fj_tran;
-
- // IF UpperBound(arg_fj.Filename) = 0 THEN GOTO ext
- FOR i = 1 TO UpperBound(arg_fj)
- ll_fjid = f_sys_scidentity(0,"u_email_fj","fjid",arG_MSG,TRUE, commit_tran) //数据commit事务)
- IF ll_fjid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- // DONE filesize
- if arg_fj[i].filetype = C_Sys_admsg_fj then
- if wf_admsg_getfjblob(arg_fj[i].fjid, arg_fj[i].fileblob, arg_msg) <> 1 then
- rslt = 0
- goto ext
- end if
- elseif arg_fj[i].filetype = C_u_email_fj then
- if wf_mail_getfjblob(arg_fj[i].fjid, arg_fj[i].fileblob, arg_msg) <> 1 then
- rslt = 0
- goto ext
- end if
- elseif arg_fj[i].filetype = C_from_file then
-
- end if
-
- arg_fj[i].filesize = len(arg_fj[i].fileblob)
-
- INSERT INTO u_email_fj
- ( fjid,
- fjtype,
- Relid,
- filename,
- filesize,
- cid
- ) VALUES
- ( :ll_fjid,
- 0,
- :ll_id,
- :arg_fj[i].filename,
- :arg_fj[i].filesize,
- :arg_fj[i].cid
- ) USING fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "插入发送邮件的附件明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
-
- IF arg_fj[i].filesize > 0 THEN
- COMMIT USING fj_tran;
- UPDATEBLOB u_email_fj
- Set fileblob = :arg_fj[i].fileblob
- Where fjid = :ll_fjid USING fj_tran;
- IF fj_tran.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "插入发送邮件的附件明细失败~n"+fj_tran.SQLErrText
- GOTO ext
- END IF
- Commit using fj_tran;
- END IF
- NEXT
-
- arg_send.sendid = ll_id
- ELSE
- rslt = 0
- arg_msg = '导入邮件必须新建邮件'
- goto ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_tran;
- ROLLBACK USING fj_tran;
- if arg_send.sendid = 0 AND ll_id > 0 then
- f_del(ll_id, ls_msg)
- end if
- ELSE
- COMMIT USING commit_tran;
- COMMIT USING fj_tran;
- END IF
- RETURN rslt
- end function
- public function integer f_change_id (long arg_fromid, long arg_toid, ref string arg_msg);int rslt = 1
- UPDATE u_email_msg SET ID = :arg_toid WHERE ID = :arg_fromid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '更新邮件ID失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- UPDATE u_email_sendmx SET sendid = :arg_toid WHERE sendid = :arg_fromid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '更新邮件明细sendid失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- UPDATE u_email_fj SET Relid = :arg_toid WHERE Relid = :arg_fromid using fj_tran;
- if fj_tran.sqlcode <> 0 then
- rslt = 0
- arg_msg = '更新附件相关失败,' + fj_tran.sqlerrtext
- goto ext
- end if
- ext:
- if rslt = 0 then
- rollback using fj_tran;
- else
- commit using fj_tran;
- end if
- return rslt
- end function
- on uo_email.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_email.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|