|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
0 F3 Z' I$ `0 [, t# Zzhangandma 发表于 2013-1-25 10:16 + H2 d9 U0 ~7 p4 K+ d1 v# w$ q6 K
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 - ]9 S9 _6 \& I X
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。2 q: o3 @ C8 g1 S' K
: N; P( e; F: U* Estring 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)& t7 A6 q. e, _/ {. @
- {$ |, V o' c* X6 f
- string selectedText;
5 h# \' `' l; T) _5 _* u; D - IEnumerator enumerator;! Z7 m: K4 R7 |4 z* q
- string str = "";
! @8 y: F' u2 S, _7 N' ~ - ArrayList list = (ArrayList) g_protected[g_projectedCategory];
7 g p% [2 w3 O, V - try
. ]4 Y G6 z: J4 ]! } - {7 f! X0 w" I; t |
- enumerator = list.GetEnumerator();
% s7 B: `8 p2 A% y1 N% \ - while (enumerator.MoveNext())
, H% A5 j5 S Y+ O3 X5 G - {
) _1 x8 _! L# }, R, A - string str4 = Conversions.ToString(enumerator.Current);
- q* r% m8 c% f, D6 h% n, I8 m0 Z - str = str + str4.Trim().ToLower() + ",";2 S X1 s: h/ f, x- Q0 Y F' \
- }
2 h3 F9 S+ m& Z) d - }
. ~! p1 J: M$ @; e* y* ] - finally
- o5 k+ @8 U5 e% ^9 N- F( U/ A - {& m; U7 U! g( W$ U3 l6 V/ L
- if (enumerator is IDisposable)
. k! I9 |5 ~; s( e8 Q" K - {2 \5 P$ G: t* K* C* [$ D: r9 P2 C
- (enumerator as IDisposable).Dispose();& s( A% k8 [- I% g4 k+ z9 z# o
- }7 ]; |# o2 u6 O) Z6 I
- }9 u4 }) W4 T* X) x9 ~9 n) U
- if (str.Length > 0)
! {; b% U% p: k8 t9 U5 A - {
3 N" D: `9 B& H6 }. Z1 f/ B. ^4 I - str = str.Substring(0, str.Length - 1); q- {% |7 E4 C" ]
- }6 l( a' }1 H ?$ D/ E2 Q% q4 Q$ S
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
0 k- Y X0 Z! {+ ]: K/ t, z - {
! s9 a( i- W$ E3 c$ J - selectedText = osd.spinTab.spinDoc.artf.SelectedText;0 s3 ^% L0 n, V# U3 ` P% Q& F0 X* J
- }4 d- C8 N' q7 v* J1 ?( H' x
- else% z& e# w* P6 `+ q
- {
5 m4 ]' a6 j* |, w( i [* b* f - selectedText = osd.spinTab.spinDoc.artf.Text;
$ B9 s) i3 g* `% @1 {2 K5 h: X - }0 p6 v# _. L8 u
- 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, ""));' f; E- S1 n9 K% ~
- if (txt.IndexOf("<success>true</success>") > -1)( \' y9 V+ K* h' K# K4 y, n
- {
2 ]7 g5 V/ y) p6 I9 f - txt = txt.Substring(txt.IndexOf("<output>") + 8);' b5 L5 j t3 g* x' G: Y0 A
- txt = txt.Substring(0, txt.IndexOf("</output>"));. r, h& S9 d. E
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
9 D8 R" X* O" X9 P5 r* L - {
; d% }6 r- j* k8 i& _" S - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
" I5 {6 N2 g. b: R. J4 f. W. R5 N: X - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";/ U+ S0 z" J/ n9 x/ g+ P) T
- }3 b- \' u' H6 W" g3 D
- else
$ ]( p- j" J( @ - {
9 u/ K( L3 Q7 n U$ q% t" W - osd.spinTab.spinDoc.artf.Text = "";, F. N, P% ]" Y0 M( \3 a
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);6 a! D6 W6 g+ f8 ~
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";- S+ J( v2 {6 J. E
- }% O( I' U! _! P0 Q# [
- }
7 F( L5 H+ Y, M' u, J, F& j - else if (txt.IndexOf("<error>") > -1)
$ n. i1 a+ B2 k5 H; W - {3 Q! v& Y3 f( c8 h9 n! M
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
! S. k. a9 Q+ E2 g6 u5 x) E" M - txt = txt.Substring(0, txt.IndexOf("</error>"));7 P. O t' c# X D- y$ @" e( U
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);; F5 K) c3 F9 s% `/ j! \5 i& J$ ]5 `
- }0 [' a6 d% l6 s k5 f" a6 [) ^
- else& K/ g; Y, p& i; o# s
- {
, H! E% L* }( D% y Z - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); ?6 ~! o+ P- k2 m
- 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, ""));; T* g9 p$ Y6 h/ Y% r2 e: t
- }, t! d* ]5 [+ O% L' `: U
- }
$ H- J6 j1 {" w9 \& v! _+ h
: x1 t# Q+ s% i& m) `- * b* x. @* h x4 ?! _; o
- ' w. i. F+ g' S7 A2 _2 {
-
4 C& V t/ [1 |) E1 t - : Y8 I6 U2 X0 d/ e/ ] d* L$ B; ~ H
- $ o5 z1 |3 l; e4 P0 P
复制代码 |
|