|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
. O3 `. N* o" j hzhangandma 发表于 2013-1-25 10:16 R+ F4 B4 w. ?* Z6 d' m9 I
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
0 e! M" ~' I# F. U$ \! k因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。% @' {- ~8 T" t0 F
6 J! a$ o1 h; M9 j# J. S, L/ q4 {5 |string txt = Conversions.ToString(EasyHttp.Send("http://thebestspinner.com/api.php", "action=rewriteText&inapp=1&session=" + g_uniq + "&protectedterms=" + HttpUtility.UrlEncode(str) + "&text=" + HttpUtility.UrlEncode(selectedText), EasyHttp.HTTPMethod.HTTP_POST, ""));- internal static void AutoRewrite(ref OpenSpinDocument osd)
; }2 x6 Z8 k) H& Y1 {3 a" O - {
+ F3 B6 `1 R! \# V: ~ - string selectedText;7 s8 F |# u/ H) j+ j! r" {
- IEnumerator enumerator;
% E3 A6 n- Z+ z - string str = "";
1 [! C4 z' _; K& H - ArrayList list = (ArrayList) g_protected[g_projectedCategory];- c9 Y; \+ `0 S2 f1 m C/ p; ]
- try$ E# c# W i8 h- }
- {
! S% T _. b- s - enumerator = list.GetEnumerator();) j+ t' z& z. I: I3 x
- while (enumerator.MoveNext())3 o' n5 E f9 @" |
- {
2 @4 d: V, S' i; I9 Z; @: p4 D, P - string str4 = Conversions.ToString(enumerator.Current);
) U# F( \4 s# H" `5 a0 v! p: w - str = str + str4.Trim().ToLower() + ",";
( _! S$ ~! S. Q/ S, e- X+ Z) ]! ] - }4 P( B9 G* Y; r% a: p
- }# q: x: C. V/ X$ {7 C
- finally6 y& L; j& i9 B4 c8 p
- {
8 z7 J' X# C: G* q% V+ l$ H - if (enumerator is IDisposable)# G8 ~" [, V! N0 Q" o0 G& B/ T* u# @
- {, Q% S, P- l3 s$ z8 ?
- (enumerator as IDisposable).Dispose();2 O3 C9 J- Q1 @* g2 Q: r" O; ~
- }
2 v" u! h" h6 h2 | - }
" D, L: j+ S/ P' H - if (str.Length > 0)) s9 m/ a7 {0 a3 N/ [' H( @. t
- {9 C, v3 U, `& w1 {3 R8 C
- str = str.Substring(0, str.Length - 1);
( G, a# ~* e3 c; k - }" [# b4 @: D* Z
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)" T& l3 F1 ^- b* N* p k& q2 l- k$ d
- {
3 M; ^+ h6 Q7 m! t! B! t - selectedText = osd.spinTab.spinDoc.artf.SelectedText;# Y1 X" l Q& e) V+ M% u
- }
1 ?, s% j) l( ~* C6 Y( m& ] - else
9 Y# s+ L' w+ b9 a0 ?# v- P1 T - {
, X- ^4 I2 R. V - selectedText = osd.spinTab.spinDoc.artf.Text;
7 C$ j3 Q" q s8 v - }' n0 N ~1 e1 o; Q
- string txt = Conversions.ToString(EasyHttp.Send("http://thebestspinner.com/api.php", "action=rewriteText&inapp=1&session=" + g_uniq + "&protectedterms=" + HttpUtility.UrlEncode(str) + "&text=" + HttpUtility.UrlEncode(selectedText), EasyHttp.HTTPMethod.HTTP_POST, ""));
5 F) m E5 q& K) Z, i) L. f - if (txt.IndexOf("<success>true</success>") > -1)0 q+ [0 x9 u( j( c- q/ ]- W$ y" n X
- {; A: h% m: \' }1 m
- txt = txt.Substring(txt.IndexOf("<output>") + 8);
/ b1 h8 I6 ]% o7 j( @) { - txt = txt.Substring(0, txt.IndexOf("</output>"));* H6 b. y. Y$ F' ?5 Q& H6 ?7 \
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
4 v( R. e* g; h$ \$ r8 z# } - {! u( D# D& n+ u. p( Q
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);! O, Y8 o. d, {6 v2 ~3 ~
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
; ?& u K7 b: t; M F - }
B: o) D* n5 j0 b N; _0 v - else3 v( L; J& t) V) O* ]! e
- {/ T! L& V6 }; N4 t4 W7 H
- osd.spinTab.spinDoc.artf.Text = "";% x! N/ k8 j& @% k
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
8 x! ?8 ~3 y9 p6 ^5 w! d3 D( J - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
- ~9 u5 o j7 |+ u' X - }
0 W; e7 [1 N- S0 e c, j7 w/ d5 a+ M% f# W - }% V8 o2 M0 G' m2 g' ^
- else if (txt.IndexOf("<error>") > -1)
% @ Y6 t/ b. M - {- V+ I2 |" W& [, Y$ d# [
- txt = txt.Substring(txt.IndexOf("<error>") + 7);* M# h7 x) W9 ^* u) S5 f. F
- txt = txt.Substring(0, txt.IndexOf("</error>"));% H' f' J4 p( n6 [1 h1 a1 C
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);) R6 f7 U# ]/ L2 {: K/ T; [. o0 r- B) B
- }
1 U- c- p/ R, _ ]' \& o - else }5 g. K% \7 X3 I/ [1 {
- {
1 O q" ^4 k$ N; |! |) J8 C - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
, P9 x- ]8 H2 D; r - txt = Conversions.ToString(EasyHttp.Send("http://thebestspinner.com/", "action=app_rewrite_error&uniq=" + g_uniq + "&protectedterms=" + HttpUtility.UrlEncode(str) + "&text=" + HttpUtility.UrlEncode(selectedText), EasyHttp.HTTPMethod.HTTP_POST, ""));
, L; i, A/ S) O* h- e+ |2 I' [ - }4 |% A7 ?5 e( i
- }
! C4 U" Y1 N: g5 D& K
8 ^- B: M3 ]* w9 Y3 y-
$ q. g W. Z6 I/ W
% V' b) |, M2 D-
- R+ l4 v2 l& w. d - / y' I* G- Q, p. [" w% J1 Q6 T# R! [
- / H# q2 S' \' P# K; X/ Z& ~
复制代码 |
|