|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
9 H( P1 t% t9 Y' r& Mzhangandma 发表于 2013-1-25 10:16 
+ \: `: Y B! c# ^* Q A发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
- ^/ K8 x P1 Z, }2 I' N7 Q7 O因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
. ?1 T& o, X: [( f
" k2 }- H+ l( q4 D! s! Lstring 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 R* g- i2 o! L' L3 A
- {$ b/ ^2 e- ?0 G4 N+ U4 E& B. k
- string selectedText;
, Z4 H: U- ^% F2 o8 P: A/ s - IEnumerator enumerator;
: A( U/ a1 p# J4 T3 U7 J" i, X* U+ s - string str = "";
H! L+ w& N6 H - ArrayList list = (ArrayList) g_protected[g_projectedCategory];9 W, i" j- m: i% `5 ?' c1 J
- try
" _: ]* P. X, e; u7 ]. l - {3 }8 b+ d+ u: T. [: i0 v5 s$ Z
- enumerator = list.GetEnumerator();
, p3 d7 R% e" d7 V - while (enumerator.MoveNext())) n& C2 _4 e8 Q+ _* A" N
- {; R- H' g. t/ Q6 X% v
- string str4 = Conversions.ToString(enumerator.Current);
8 z. X4 X0 I; _! N - str = str + str4.Trim().ToLower() + ",";
" U! V( B/ h$ R. P+ @% p7 ] - }
. J) O, K: T3 e4 d - }" \5 {, n+ Q/ w2 ~0 u
- finally
4 } h4 j/ \* P {! C - {
v2 G- R' U8 o2 r - if (enumerator is IDisposable)
- ?. ^$ l' v; v) s - {
0 q5 o7 J) p/ z* A - (enumerator as IDisposable).Dispose();5 _- |' p6 x' m/ U, \
- }& M: @2 j5 ^7 Z: |: c0 v% Y- N
- } x4 r! p) ?1 Y( k
- if (str.Length > 0)
& h7 P6 L6 N7 ~: }' z' V8 J- P+ r - {
5 b# ~* b2 u1 Q+ } - str = str.Substring(0, str.Length - 1);1 a0 {( g! {2 s" Z0 ?6 Q
- }
3 Y7 Y; B6 H$ i0 F( d2 w' ?! p - if (osd.spinTab.spinDoc.artf.SelectionLength > 0). L1 V! N0 a" _0 H( M0 b2 n- @
- {
: q2 l3 h$ m m4 C - selectedText = osd.spinTab.spinDoc.artf.SelectedText;
4 G- y+ X* ~$ n - }
1 n4 K9 F% `1 ]4 d. Z - else* [/ h8 t# J8 z
- {
5 c0 g( O, D) H4 L+ K - selectedText = osd.spinTab.spinDoc.artf.Text;
$ i3 F- b5 Z f - }
3 r9 Y+ L2 |2 s5 y - 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, ""));
# c- l; V' I# q ~; \, \- E" m3 D - if (txt.IndexOf("<success>true</success>") > -1)
+ k9 w5 v) N) t1 e - {! Q# {. c$ B U6 j- {
- txt = txt.Substring(txt.IndexOf("<output>") + 8);
0 U% o5 Y; O& ?" b+ a/ p - txt = txt.Substring(0, txt.IndexOf("</output>"));/ c% W [5 f8 K6 a }
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0) J3 {6 x+ Z7 L6 T
- {2 C& m) t q+ \% x8 i. m9 b" _
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true); p; f5 Y* ~! k* c
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
0 ]" c& c8 |1 z h& r - }
" ~$ |" e; f3 J6 f - else4 t* b# l# z% M% D: T' {$ C
- {
! m! A" k! {' N4 M% D$ B) x: _ - osd.spinTab.spinDoc.artf.Text = "";
# U+ }0 a( c5 G* ~9 x5 i - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
) \8 L ?3 Q3 ~ - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
$ J! l9 t7 E3 W5 F) ^# ^ P, b - }
j2 {0 T7 T( \9 r2 t# Q - }% ]% B8 t: ^6 Q% K+ w
- else if (txt.IndexOf("<error>") > -1)
! A( s6 u' D- v9 m6 T! W9 }1 @# n% ^ - {' w9 t7 i5 V" f1 G& B) d
- txt = txt.Substring(txt.IndexOf("<error>") + 7);: B; S K P0 L6 K9 V+ g
- txt = txt.Substring(0, txt.IndexOf("</error>"));
* z; X0 @; t, C+ k( ~ R, ] - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
, K6 @2 x& @5 D+ E7 O2 x$ j - }: e8 }# M6 ]4 v, [% a
- else3 Q" z( d7 m) i* R3 Q
- {
6 x& U, A6 J) Z3 J2 x, y - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
( s2 W @- r5 {! |5 i) _/ C* F" v - 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, ""));( P8 a8 l \) u. V6 _4 Q
- }9 Y1 M& r; i L- n4 x- X& V
- }0 J6 z7 v+ Y, S1 t& \
& h: U; n# g- o- ! t) X/ k4 J% s/ j" y* {" U& M
$ ?: D; f/ N2 t% e0 q! b- 2 x, I W; ^! W6 Y! V( h3 N9 v, ^# L
- $ [5 j5 m8 C! n
) S W6 I- g- ^' S8 M7 I1 c
复制代码 |
|