|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
9 Q8 z* d4 P0 Z4 s) `zhangandma 发表于 2013-1-25 10:16 + [$ x# P# _4 {3 c+ o* o
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 & F; r: N9 ^) i1 |" O
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
8 I. X3 S% ~6 }' U, |
& ^4 {3 ^" p1 k' l# P3 S' Vstring 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)
1 Q7 J' Q+ N( r3 C+ m - {8 \7 c) m* h$ @# g8 i) U8 l$ j
- string selectedText;; m7 v8 p4 E j
- IEnumerator enumerator;, s: R% J$ c0 a( s/ F" Z
- string str = "";
' ?* n% T' T: A* d) x! _ - ArrayList list = (ArrayList) g_protected[g_projectedCategory];. @ Q( Y3 T: H* N3 r
- try
$ `. b. y" K0 x" X' J3 u; p5 ]* G - {
1 e- @' C4 _& M. `4 I- c - enumerator = list.GetEnumerator();
/ A6 g$ r! z) y. K' Z* A - while (enumerator.MoveNext())6 q4 t5 j* O/ M t0 l. S8 }! C: s5 w
- {1 G3 V2 j- b" z1 h1 P( u" Z1 k
- string str4 = Conversions.ToString(enumerator.Current);7 C( p5 H, Z: D$ c
- str = str + str4.Trim().ToLower() + ",";
* i0 ~; Q3 h" T |/ { - }
7 l0 }' K( W% U/ J6 ?* U) F - }
- m o' \; c) \ - finally
' B) _0 h# k/ \$ K! \- Y' n - {
/ a1 B* q* f+ ~8 r - if (enumerator is IDisposable)
7 A6 h! G# h, s+ w j3 l, i - {6 g% H0 _7 L4 l6 j! `+ v9 e1 P
- (enumerator as IDisposable).Dispose();
9 D) p7 N% L1 Q- Y @% A' N" Q8 n3 c - }0 \. {* K) u) l$ x2 Q* _ r
- }! A# N8 V4 r9 D+ i4 y& C2 \6 ] t/ T
- if (str.Length > 0)
( C( l7 \) X; y; z4 {. R$ |$ f: b - {
; {! n- i0 X, a7 k; T - str = str.Substring(0, str.Length - 1);" q5 j7 I$ P" R6 S' C) ~
- }$ S) }/ x1 I! R, l( U
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
9 z6 ]. Z% }9 n6 M - {9 A& c ~( P9 t& C7 h7 [. y
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;
5 D) a& z6 t, J6 X! W0 F" ~ - }
4 y; f9 }+ a4 i5 d% h6 \5 C - else: }' N4 p0 R8 X3 z. ~5 K) F- M* d) B
- {
& n5 l6 C/ {2 }- F0 Z, F - selectedText = osd.spinTab.spinDoc.artf.Text;+ L0 S# M0 T! }% e) f$ e- T5 Q
- }
5 [, y& G& J% z2 M - 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, ""));
( l1 j( W: ]; i8 @: b7 `* g - if (txt.IndexOf("<success>true</success>") > -1)/ [" a+ A* `4 m( e# A. p- s; k+ F
- {
# v- o1 s6 l' n* @) M1 @! K/ ?3 F - txt = txt.Substring(txt.IndexOf("<output>") + 8);
' i+ k& l$ J; F( l8 E0 ` - txt = txt.Substring(0, txt.IndexOf("</output>"));# [9 S! ?/ F% }" g$ {* T
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
, a% s; p( K. g2 k: I& V; J- v - {& G1 I# C) b& g! |4 W, y
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
5 c k5 Z5 G3 ?, E% Z - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";" X8 K9 {5 x# L6 O# Y
- }
% j" t' _9 \- {* y# ] e$ N ?! C - else
}8 Q) _. d$ [- N+ R+ k - {
e: l$ D" G# f5 Y2 ]. F - osd.spinTab.spinDoc.artf.Text = "";
9 V% r' B b, T5 H& |8 o - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
7 N/ P5 y" Z5 U# I' k6 [ - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";# Z& B1 B. w+ _- ^! j1 }/ \
- }' W3 T' G* q5 I( B) |3 R( U; e
- }# o% D! X* b! G% m1 q" d
- else if (txt.IndexOf("<error>") > -1)- s! W$ J7 t/ A! l- l
- {& p: @4 j9 h/ z( c, t. ^
- txt = txt.Substring(txt.IndexOf("<error>") + 7);; |% B+ V B0 ~2 e" f" c, r/ b
- txt = txt.Substring(0, txt.IndexOf("</error>"));
' s0 L/ e! h8 r9 P+ B9 H/ C* r - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
$ t5 ^! P7 {# X5 i C - }3 P1 L0 Q4 e$ e5 v9 d* [
- else) W1 v" L/ T0 Q9 y' G
- {% l8 W# e# g1 E4 _+ Q& x O5 [3 f
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);% ]! l. I& g3 S" D% K; X1 ~& f
- 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, ""));! q3 |. J1 ?8 ^3 B ?
- }. [$ B4 H! @: f$ p# a& E( }
- }
" ]+ L$ G1 d9 S' ?2 ]; F1 |# Q - : {" L" j/ b" n; P
-
4 e. s5 z* |# l: w/ G, D
r: l. v; [8 i! \, l7 f-
, \; K: k/ Y- T - 2 y9 e1 G5 X! T: O& m4 _; P- k
- * R8 I" h$ I5 }! f8 j! n
复制代码 |
|