|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
3 R( k. v. x/ ^- Q# P' ?- Azhangandma 发表于 2013-1-25 10:16
8 f- p) y; D: u发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 5 W0 O' {7 e, {/ T! U
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
: e$ ^$ k. O; K7 A# r
- m* i' W1 s* x6 J1 O l$ Ostring 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)
+ G7 h/ k( A3 P" ` - {
( J' W, X) m( \/ ]# P4 l6 E1 k - string selectedText;% y% o: ^# ^" k( o& Y! a7 A
- IEnumerator enumerator;
" v4 J0 y4 U& j* ~. ~% z' w - string str = "";# s& @) }, S c
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];
N6 c) |6 V& w Z% |+ i" C - try7 c5 Z7 w D9 d3 ~) n% {% \
- {
6 A6 f' {+ p6 U; n J# W/ G - enumerator = list.GetEnumerator();1 g% \& S$ X, c! x4 }
- while (enumerator.MoveNext())
6 R7 k% O9 s/ j2 o' S! z - {& u" f( s7 l, q7 b* }4 l
- string str4 = Conversions.ToString(enumerator.Current);
, V' c, u4 @( U, a& ^5 j: p - str = str + str4.Trim().ToLower() + ",";6 E$ j+ S- c7 ^2 r( T
- }; J) g# V; Y: I
- }1 E# p, ^" B5 l* l0 Q, c4 O7 X
- finally
: r2 A$ K9 `7 Q' v0 \ J8 c7 h - {
/ y8 `8 O' z$ b - if (enumerator is IDisposable)
8 }' O: e8 ~, l5 X+ q$ P) h/ P - {
' ^7 i" }6 [1 Q0 k" i - (enumerator as IDisposable).Dispose();( |9 r0 o5 k% {6 l( j3 I1 T
- }
; U+ u4 U9 M' A - }- }( H$ o' R1 h" N. Y- }& w
- if (str.Length > 0)$ p" g6 p% w2 E) y: U" p! W' m h8 x/ d! b
- {
( r, \; L# t- n ^4 } - str = str.Substring(0, str.Length - 1);3 ~6 i4 n2 G, `7 U) M" V. j
- }
" B5 W# k w5 j9 `: Z } - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
# C6 p+ |: z$ P3 r* ?1 v - {! Z3 R. t, L k$ a! a$ C
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;
% v5 A! ~* z' j# Q& | - }4 p. j" P& o+ u; s$ m7 N7 Y9 a" c- A. d
- else
- k) `% D3 z/ {* h+ B& N; N - {, b' o6 y/ k9 @( c; s7 b p
- selectedText = osd.spinTab.spinDoc.artf.Text;, O7 d4 T9 N# D
- }2 S0 n$ w6 \# x5 V6 [+ E7 m1 D
- 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, ""));
3 Q5 W* y; i# p6 J5 P - if (txt.IndexOf("<success>true</success>") > -1)
- y/ ?# c1 o2 o% V- H& p& `3 [ - {
$ B& ]8 U3 t7 d( O) N - txt = txt.Substring(txt.IndexOf("<output>") + 8);# Q/ B# W4 p. a& _9 o
- txt = txt.Substring(0, txt.IndexOf("</output>"));
. q6 w- v' [) E& ]3 {& l- ] - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)0 @; }1 J: z% b# N' ?9 u; B
- {8 m0 @9 a" u# _5 Z2 ]! l' C
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
6 f: H+ D( z& i% f" V4 ? - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";) G; V0 n9 Q, ^5 k, N1 ^& W8 F& l
- }/ u f3 v$ e' V. r
- else4 N) W2 L! p( r; u3 ]7 n
- { M Q/ N- P2 S" c8 i5 X' j: N
- osd.spinTab.spinDoc.artf.Text = "";
# m6 R; r) S5 L& l - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);; i9 X& K5 q* |- q5 u
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
5 H1 P) x* e+ X& z" L# h9 `2 W5 N$ r8 A - }, n& q3 t3 F( q' c
- }
5 J! E8 i. S1 e# ?5 ^& c - else if (txt.IndexOf("<error>") > -1)
# B' Q# \& c$ T+ z, r" X - {/ t! D1 e6 Q0 e
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
* J* U- ^# Q+ a# Y - txt = txt.Substring(0, txt.IndexOf("</error>"));% @' W, o% b; M% J' u6 _
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);) j6 }* @2 G0 K4 g1 a' A; \
- }. A2 Y/ Z: l: ?9 _* d
- else
! c* |# L% u y+ t - {# d) o4 u' w9 S: z4 R5 {6 P% ~: n+ B
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); Y! o M6 E3 q$ [4 Q& B
- 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, ""));. G; b/ m1 X/ o( y! X
- }- R9 ] i9 V* X
- }, m) {4 C2 O4 V, F+ J
- 9 Z/ ?2 {" s# _0 U0 Y0 \
- ( J5 j* b' Y7 r; R. k1 n6 m4 g' n
- ; N1 s2 V ?8 I9 O
-
V0 x; e( I) w" `
6 r% _9 B' p' z8 N
8 }3 j; z* ]2 m3 x, a" `
复制代码 |
|