|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
5 b( V* g! ], w; f, Q- j yzhangandma 发表于 2013-1-25 10:16 
c5 v6 \: {' z# a/ w, ?& M; S发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 2 d) k' V* w2 X( i
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
' d+ Y* Q8 X4 }; s7 t! ?/ n* X% A! R
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)0 `" {# G2 ^5 D/ Q' \" d2 ]
- {2 v! e' D0 t9 Z( j* T9 e% `* f
- string selectedText;
5 O9 S o$ w1 g2 r6 j - IEnumerator enumerator;
& j2 Z* ^8 W& E% I1 ? - string str = "";; W# l0 [! t# t. E* j; I, q0 `
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];# T& o; p4 c- l
- try0 X) l" l+ g; e( g/ I ^2 C! ]' J7 b
- {) p+ ?3 y3 C! I9 M" U
- enumerator = list.GetEnumerator();
+ \, M2 }: J3 t# g - while (enumerator.MoveNext())
$ R7 K( L5 S7 _) v4 { - {
6 T( V: H3 ?( z9 Q2 _ - string str4 = Conversions.ToString(enumerator.Current);
2 R- G5 k; v' W/ \ - str = str + str4.Trim().ToLower() + ",";4 K4 h9 V* ~ V @+ I
- }
% R) Q$ h5 z* @/ N$ B7 N# e. X - }
) J+ J, n) |& m; F$ Z+ k1 k - finally
! I9 ^- B+ p/ Y/ Z) \$ I$ b# v - {
" X2 \# {& R) w1 w8 d - if (enumerator is IDisposable)
2 w" w9 T+ i6 u- X! ` - {( \ C0 |8 v% D2 y# U8 b1 Z
- (enumerator as IDisposable).Dispose();
e; ]. r; X" G8 }2 j" C - }
! c! i, V S2 p5 W - }+ h. F) x9 |5 Q6 k1 Q/ _
- if (str.Length > 0)
4 D `) H$ @ C& S u - {3 m3 X# k7 m' \1 X' X
- str = str.Substring(0, str.Length - 1);5 B5 D* r* k" y; U
- }# B6 c/ ]/ F4 S( T9 d
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
7 j& @3 _5 r# D ~% D - {
/ J/ }& d; Y+ X2 P% y& B - selectedText = osd.spinTab.spinDoc.artf.SelectedText;
5 m. b4 W O' c# V) x% Y. M; ` - }
- G7 G; s+ L2 o! F - else) z% v+ T$ J+ s% z; }) M
- {
. I$ L! H% C, ? A! z# Z9 W - selectedText = osd.spinTab.spinDoc.artf.Text;) Z' D( l3 M* k* ?! l# x7 {$ f2 s
- }) H: b6 }/ @. H1 m1 \
- 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, ""));
4 ]: k$ B" ~$ R - if (txt.IndexOf("<success>true</success>") > -1)
. J. W, j6 B# f6 |) f c - {
, |6 N8 ]. e) g - txt = txt.Substring(txt.IndexOf("<output>") + 8);
& }, T& m( |6 }( [( m3 a - txt = txt.Substring(0, txt.IndexOf("</output>"));$ `( ?4 p; C" u. G7 v5 f4 `; s4 @; Q
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
6 t. c- c7 `0 ?) F9 G - {' d6 K; P/ L* C
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
. e3 W7 B& n$ e6 ^ - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";' |* Y) h+ t( v$ |3 B
- }
1 } e5 X7 x! a' G - else
3 ?/ l: }$ d1 P: _' b - {: P5 k# N# S' ] S
- osd.spinTab.spinDoc.artf.Text = "";- N/ |6 r+ a. R3 ]) y0 I
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);, k8 Y/ \8 g/ X5 X2 U7 u) T
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
% q, D/ M5 _$ B0 }& ]1 r - }1 H& l" b4 e5 `) e8 ]% M! I
- }1 i8 O' Z% O) s% i# x' g
- else if (txt.IndexOf("<error>") > -1)
" r: A# _" L- W8 J- y6 Y" D - {8 y# X2 X( p9 Z6 p+ i" ]) O e
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
% c& o' ?* x8 J% c; O, C$ T1 \2 L - txt = txt.Substring(0, txt.IndexOf("</error>"));
" y! M% o1 E3 a1 |' x3 y6 D* C: ? - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);5 {0 z% o$ X! {( n' U8 v
- }
9 z/ \4 y, ]7 ]% {" S* u - else
1 n5 s- i0 N5 l5 Z' L+ H W - {
1 b0 Y2 B$ Q6 L - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
1 o7 k! ~# e9 {5 _9 | - 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, ""));
5 e% j& j8 m& ? - }' ?9 u) y0 t- e. o. Z* {- `, S+ {/ v+ n
- }6 `' T) k3 i2 A- ?: D8 ^! I- l
- 2 q$ ~8 d% C+ c k& L% a" ^
- + R. L) X6 j$ ]8 ]2 ~' u/ N' S' w
- 3 L' r/ r) I, ?
- 0 I, H- @4 ]9 V) w+ l x
, r0 K P/ W+ K; S" j. B/ n- ( p3 {: Z- ^! O% a& j) K
复制代码 |
|