|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
1 j% k$ E' x7 ]4 Dzhangandma 发表于 2013-1-25 10:16 0 v \& t( r: g4 d. J8 k/ z
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 1 }2 D& }- y$ a w+ R# f" E8 Q
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。+ M7 {( e* k7 W- _# G6 z& ]
1 w3 y+ R4 L2 y% B2 ]3 q
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)
2 t4 m p7 i( k* C - {
0 i$ z, l4 c5 a) L% T) B) l - string selectedText;
1 E- L2 n) C% ~ V' y - IEnumerator enumerator;% V: t! Z( T* L! P, |
- string str = "";
% l9 }2 Y/ J P g. l$ q6 L. e - ArrayList list = (ArrayList) g_protected[g_projectedCategory];0 g. L. e& _; O/ Q5 P) A# a
- try
i9 [* t) U8 |6 X2 s& ]2 { - {
$ H; C$ R9 l( C/ x' z - enumerator = list.GetEnumerator();3 c8 x2 S- m& s& N0 c( y. I
- while (enumerator.MoveNext())7 O3 S5 t/ w0 [& K. k# ? n
- {
: D$ d* E" i. o# D - string str4 = Conversions.ToString(enumerator.Current);( ~9 H+ ~6 s& G/ v4 V9 {: x
- str = str + str4.Trim().ToLower() + ",";
+ X- E$ b+ C( r% F' ~& V - }& W3 ?3 Q- B, g, Z1 g
- }! k: P+ B7 d5 o9 K) {1 N! M# r
- finally7 r! |* u0 }7 Y' @0 ^$ c. R, `
- {
8 t: Q; [- n4 A' G) l# z8 I3 m - if (enumerator is IDisposable)5 S' y: |% e1 Z" K1 T% b
- {: x# Z2 w) o1 t) c( A" h# T
- (enumerator as IDisposable).Dispose();
2 I( R5 j, X" D8 a( R: C - }$ M6 `" G2 n' H8 S$ Q
- }
4 c9 [# _2 H6 H0 N6 x+ v) D9 z - if (str.Length > 0)3 o: t. @$ C" n8 s# V8 v1 ~8 o
- {
8 T4 B& }, v* W8 i - str = str.Substring(0, str.Length - 1);- [$ r- u" ~ H# l2 a* o
- }
+ M; M5 q1 v7 {$ c) X - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)* \5 g5 K2 w, D' F. O0 ]& o8 O1 `; ]
- {: W, ~8 P% k) {; Z
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;1 P) S* ]" W5 P0 i6 _
- }3 Y/ |, s- v1 B% B8 w' B
- else# n5 f- \7 \. S/ m: u ~
- {
7 }' Q o1 ~# j, t - selectedText = osd.spinTab.spinDoc.artf.Text;8 ?( K. X( V( O6 D- a
- }
" U$ |. Y: J( V9 X4 _ - 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, ""));. D5 O, v; o& X8 S9 R& g
- if (txt.IndexOf("<success>true</success>") > -1)! h' z6 J" @3 l! k( B! @ q- b6 f/ D
- {9 X" ?( T* u, O- O) }, b
- txt = txt.Substring(txt.IndexOf("<output>") + 8);
/ ^3 ?1 K$ I) L3 ]# e% H - txt = txt.Substring(0, txt.IndexOf("</output>"));
4 i# ~7 l+ t& u: _ - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
$ C" i7 D* w- U' M) \ - {2 I- Y) k" ^& _/ j! m9 D
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
1 ]9 o$ v1 G" Z% i- E - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";% U7 H4 d! t7 ~0 p& m! y
- } o( |8 l5 p/ b* N: j2 D
- else: L$ n* X8 p6 ^6 A% Y4 l
- {8 U0 W3 I2 M7 R
- osd.spinTab.spinDoc.artf.Text = "";
8 L) J! D0 O4 H6 z* [# C - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);8 v$ ] U# A5 W8 t1 y
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";* X0 b- `" D% b/ i! ^
- }( r6 t% F2 |8 z& `; S6 K
- }8 ]+ r9 e) M- S* b- Y5 D
- else if (txt.IndexOf("<error>") > -1)
. l% [/ }) {1 H& v - {
1 U7 N7 _, y! w" l/ x# d& M, t! E - txt = txt.Substring(txt.IndexOf("<error>") + 7);* X- @, u, F2 [) k, y
- txt = txt.Substring(0, txt.IndexOf("</error>"));
( Y4 n" S/ | W1 R- {) F+ i6 T - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
h0 S9 K" T8 e) L- { - }+ n$ J* J: {( Z# r% c
- else7 [5 q$ x" L( P* `5 W
- {
7 b) O" y j0 O0 g) O1 Y5 [ - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);& r, ?2 _$ W- y3 d; D
- 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 `6 x8 p" _! @0 `$ K4 \" s
- }
3 m* A& _2 e2 `+ @( D& _3 d( ]- i - }2 Z) S6 N2 W, f8 `
- . p8 j' G! e5 b* j5 W
- $ v7 y( N$ K# o* Y+ K; A1 x( ~
, K2 e. f" x) w N9 {5 ?, A3 u4 }-
1 t9 H3 P9 V. ]5 [0 K v# _ - % ?# E* w6 ^. G- t: m, v) z- X
- " u+ `, M( _8 `* @
复制代码 |
|