|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
0 Y. K, ]4 b% @, Qzhangandma 发表于 2013-1-25 10:16 / H( F8 u7 j( r2 p, @ X
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 ) s P+ m; |# _7 G8 ~. l
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
6 Q! m# E# C4 ]4 [. N" {; t2 h" X- z& x7 o& Q0 V+ S5 {. |/ `- y, G8 K
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)* Y& M4 Y5 U" a$ {3 {/ J9 Y+ J4 C
- {3 r' m$ p O2 ^0 P9 k
- string selectedText;
1 L7 @0 F5 c0 W2 ? - IEnumerator enumerator;% A L, h$ S- C. j6 u' E7 i" f
- string str = "";
5 h3 X) T9 M+ g3 H) q) n5 H - ArrayList list = (ArrayList) g_protected[g_projectedCategory];6 I. h1 ?9 u6 i: G
- try
# G8 d$ W+ m% R3 e* a - {4 w* d9 u* N7 k6 n
- enumerator = list.GetEnumerator();
* [7 A! A: c/ Z; H - while (enumerator.MoveNext())
/ G; j3 y% a1 E% m1 u - {
) N8 a; z' G# C - string str4 = Conversions.ToString(enumerator.Current);
' O2 h4 k( G" L: X - str = str + str4.Trim().ToLower() + ",";
7 U j. z6 h+ n. O; e' U! W8 z - }
$ E0 K: y# n V& X - }
. ~6 W+ I) ]/ T! o - finally
3 c$ l; y6 `! t2 t' O# B+ a - {4 `* `$ y! K n8 u! u' Z
- if (enumerator is IDisposable)
5 ]' M x% e2 ?* Q' U; y - {
} d2 `: t0 L9 w - (enumerator as IDisposable).Dispose();+ R" w" W& M- l. U8 Z8 M
- }
3 l( E: |! S% F" v( S) E - }
2 `* L3 W& c" D2 B7 g9 N - if (str.Length > 0)) D1 F' |) A3 Y- _
- {/ {2 p) J) p( H K' ^. r# M( C
- str = str.Substring(0, str.Length - 1);
1 _& v! s$ q1 w - }' G% t. w7 `+ {' ^- V
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)" R$ }& U R) v- |- B* h
- {
+ K8 [0 x3 ?* p/ {/ F' {" L6 k0 I5 b - selectedText = osd.spinTab.spinDoc.artf.SelectedText;$ Q, G' S( W2 i4 g9 ~; x' ~+ j e
- }! ], z' ~2 b$ P/ |- {5 Y
- else' e- F" C1 B! w; T: A8 W
- {, L$ K# @ ] k, ]9 F2 i r, x
- selectedText = osd.spinTab.spinDoc.artf.Text;0 N( h6 A/ ?: s2 T; m
- }: ^! J* R! G! w/ `8 K. z
- 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, ""));
" K3 p2 p- q- i - if (txt.IndexOf("<success>true</success>") > -1)
. D5 v7 Q Q4 \2 \# z - {
- T2 ]: g1 G$ I7 f7 o: H4 v$ d - txt = txt.Substring(txt.IndexOf("<output>") + 8);
6 t4 `, b& S" ^. L, u - txt = txt.Substring(0, txt.IndexOf("</output>"));
4 f ?8 K2 d% V3 f# P. \6 O3 J - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)% }/ O Y6 r e: ~
- {
7 u' ]/ Y( N1 Y. a - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
9 ]& W% B+ M. W. [% {5 _( ? - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
: ]5 N4 c% Y* t9 u2 M/ ` - }% v6 B5 L. C* g* `9 D
- else
3 G8 j; v2 s8 [; X" e - {3 R: G z% i7 ^& E6 w( g- w9 E
- osd.spinTab.spinDoc.artf.Text = "";' { J H) p2 b6 n; O) @. B$ u
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
+ H5 h. u5 t( X, S+ p - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";7 x$ G$ Q) R, t" _5 ~! _% }+ c
- }
/ ?8 I3 T( k9 H( j0 b I% | - }3 _7 P) u. ~+ p4 j
- else if (txt.IndexOf("<error>") > -1)$ u; d. [- j$ T, u# G
- {
# ] k F; H* M0 y7 c, m; U+ p6 h - txt = txt.Substring(txt.IndexOf("<error>") + 7);
' G' y) i, X" ~& l0 L+ u/ L - txt = txt.Substring(0, txt.IndexOf("</error>"));
1 s5 P% R* p: p - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
% i; L! @+ h8 W+ x7 k' ?( I - }
3 f6 K' [- F+ K4 Y/ \) z/ X% n - else
5 u) r" j( ^" N0 Z - {& Z3 X4 `4 c9 I* V1 |! V. 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);' _) N4 J6 g/ q) K _
- 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, ""));2 D. H& @" U) k9 L1 O3 t0 S
- }
& _' J" {( q, M1 u' h! B - }
; S9 W1 K! \1 Z! X
3 X* W0 ?3 ?! q# `0 q5 `0 E% f2 A-
$ l0 O+ t# J2 y. d) l4 |1 [ - * F0 T5 d4 v5 M; _5 S
-
1 r4 C: F/ ?0 s! ~4 n p# S
1 @6 s$ y; {- D; `7 @( h- 2 u; P6 d* p# Y* c7 N
复制代码 |
|