|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
1 E" L- w! p2 ?( k( F9 U7 U" F! B) E2 ^zhangandma 发表于 2013-1-25 10:16 ) W1 _; v4 Z; w+ S, ?3 J3 p8 x( |
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
# t1 I+ b, Q% {' I1 W" O* N因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。 W" a; f2 @" H8 I% ]7 G' e
, F q, t9 _3 l( M& rstring 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)4 `' p: O3 b5 j) K1 @
- {
7 z0 a/ N# ? Q. }. P0 r - string selectedText;
9 [1 D" A4 w. s- c: V, k. f - IEnumerator enumerator;
: ~% Z2 r# e0 X - string str = "";' V6 m& x+ }, W. F! l% |) S
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];
! _% f' t; B; f2 H - try! |2 n* T1 P k( B( [# |0 {! p: h3 a2 w9 H
- {
: C/ m) W! R8 G5 c( y9 A8 g2 l/ O - enumerator = list.GetEnumerator();9 e" k _8 ]) v) Y1 A
- while (enumerator.MoveNext())
+ S0 k% R h3 p - {
( Z: J) E4 L- \3 L1 { H( _ - string str4 = Conversions.ToString(enumerator.Current);* f' D. x$ T @" b/ h9 l
- str = str + str4.Trim().ToLower() + ",";8 _! j# Z8 c7 T" N/ O+ r
- }* ^; I4 N; W- D
- }1 A+ r7 d# v) n
- finally W8 L/ u! R, Z8 U4 P& K
- {
9 |2 x) R f8 b5 J - if (enumerator is IDisposable)
" \) T% N# ]9 m9 [" j - {
3 g4 ?. W. s4 C - (enumerator as IDisposable).Dispose();# V. p! t8 K5 z7 P& w5 B3 E1 S
- }* h% w' Y4 H. B# E" P
- }
- y7 B; c! L9 \% p6 \ - if (str.Length > 0)- U7 a! b5 g. `( y9 E
- {
# B* z' D, F& G7 n; l8 Q! ^ - str = str.Substring(0, str.Length - 1);3 z1 P: U+ ~- l
- }
$ n, T8 w5 X% [! l7 Q; A& ~ - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
' m6 B& e7 b1 u - {
+ f) z7 D$ @5 \$ {. l - selectedText = osd.spinTab.spinDoc.artf.SelectedText;
) e' X; t" o6 L- f* w- s - }3 a: ^+ c2 h9 C! a# y0 L" ]3 N8 K
- else4 W; d# {- c7 i# x1 f7 ]- k
- {! b; x2 r n1 }5 F: |- k
- selectedText = osd.spinTab.spinDoc.artf.Text;# u4 F2 b0 v3 R
- }
" z9 \% j9 Q, T$ c! q3 u+ I - 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( [/ J$ p% y+ h- E+ o9 @3 m
- if (txt.IndexOf("<success>true</success>") > -1)
" M6 A7 T1 b$ b% l" P - {
3 K0 u1 B: p; S1 F6 i - txt = txt.Substring(txt.IndexOf("<output>") + 8);; A' I" B: B, z. R( z; l
- txt = txt.Substring(0, txt.IndexOf("</output>"));
( |+ A! H4 H, _/ b9 y - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)3 e) C. p% a. k0 t W2 L: m7 b8 B
- {9 P" o# O& P6 q
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);+ F7 F% R% \3 i* M8 t! K$ ^ }
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
$ w, m' x# ^/ Q! C$ s F& C/ y$ M* ~/ l - }( q1 \! I& ]; h3 F0 S2 f- | C
- else, a I7 p1 J% I3 I5 A2 z$ r% W) e8 }
- {9 J& f- t; e1 N' m
- osd.spinTab.spinDoc.artf.Text = "";( y( M/ r' ^* h: i& O v& H
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);5 i- J8 Y; \9 X s3 v
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";& X+ ?# C3 `7 s# f- J: b9 N
- }
; {/ i6 Z& K* d: y - }4 i6 l8 Z' A3 r
- else if (txt.IndexOf("<error>") > -1)
' C" L W3 z* | q6 j G* _! P9 b) b - {# V9 ] x1 q' r' b$ J
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
0 x& k3 ], R! ]7 G# f - txt = txt.Substring(0, txt.IndexOf("</error>"));3 u/ K; { u* S8 I, X/ q
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);4 Q4 I) P6 j8 o3 c5 b8 N
- }" F" _2 r$ R# G1 V$ w6 U" J
- else
# J5 f! ^ ^0 g - {
) [7 N( n' K' M# I - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
& O9 z( J. [" W+ E& w% a8 C- b e - 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, ""));) ]0 @1 j8 h1 P. p8 F
- }/ \3 B9 ~4 Y7 p/ O: s' I
- }
. |4 @9 ]5 T6 Q) D- g4 v# l
4 Z* t1 V1 F" i- ) u" }5 K5 Q- o( r1 i2 ]9 s: ]
- * u' q0 U+ y4 k3 s1 a, w
-
" h+ r. s9 `& R
* w! I7 x* ~5 w+ F0 w- 7 A* M, M, \+ O- H' H
复制代码 |
|