Thành viên:AlphamaBot/External Processing
Giao diện
External Processing
[sửa | sửa mã nguồn] public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
string OrigText = ArticleText;
string OrigTitle = ArticleTitle;
Skip = false;
Summary = "";
try
{
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.WorkingDirectory = @"I:\Sammi\AutoWikiBrowser5400_AlphamaBot\WikiTool\AlphamaGeneralFixes\AlphamaGeneralFixes\bin\Debug";
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.FileName = "AlphamaGeneralFixes.exe";
psi.Arguments = "";
string path = psi.WorkingDirectory + "\\input.txt";
string FileContent = String.Empty;
if (System.IO.File.Exists(path)) System.IO.File.Delete(path);
FileContent += ArticleTitle + "\r\n";
FileContent += wikiNamespace + "\r\n";
if (Summary == "" || Summary == null) Summary = "";
FileContent += Summary + "\r\n";
if (Skip == null) Skip = false;
FileContent += Skip + "\r\n";
FileContent += ArticleText;
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(psi.WorkingDirectory + "\\input.txt"))
writer.Write(FileContent);
System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
if (p.WaitForExit(60000) == false)
{
p.Kill();
}
FileContent = String.Empty;
if (System.IO.File.Exists(psi.WorkingDirectory + "\\output.txt"))
{
using (System.IO.StreamReader reader = System.IO.File.OpenText(psi.WorkingDirectory + "\\output.txt"))
{
ArticleTitle = reader.ReadLine();
Summary = reader.ReadLine();
ArticleText = reader.ReadToEnd();
}
if (ArticleTitle != OrigTitle) Skip = true;
if (ArticleText == OrigText) Skip = true;
}
else
Skip = true;
return ArticleText;
}
catch
{
Skip = true;
return OrigText;
}
}