public static void SendAllTorrents()
{
try
{
ErrorWindow ew = new ErrorWindow();
if (!DirectoryHandler.GetFileExists(SettingsHandler.GetTorrentClientFolder() + "\\uTorrent.exe"))
{
ew.IssueGeneralWarning("Be sure uTorrent folder is correct", "uTorrent.exe does not exist", null);
}
else
{
table.Columns["Handled"].ReadOnly = false;
table.Columns["Error"].ReadOnly = false;
foreach (DataRow row in dataset.Tables[0].Rows)
{
try
{
if (!(bool)row["Error"] && !(bool)row["Handled"] && !row["File Path"].Equals(DBNull.Value))
{
if (DirectoryHandler.GetFileExists((string)row["File Path"]))
{
try
{
Process sendTorrentProcess = new Process();
//torrentClient.exe /directory "C:\Save Path" "D:\Some folder\your.torrent"
string fullArgument = "/directory " + "\"" + row["Save Structure"] + "\" "
+ "\"" + row["File Path"] + "\"";
sendTorrentProcess.StartInfo.WorkingDirectory = SettingsHandler.GetTorrentClientFolder();
sendTorrentProcess.StartInfo.Arguments = fullArgument;
sendTorrentProcess.StartInfo.FileName = SettingsHandler.GetTorrentClient();
sendTorrentProcess.Start();
Thread.Sleep(100);
sendTorrentProcess.Dispose();
sendTorrentProcess.Close();
row.BeginEdit();
row["Handled"] = true;
row.EndEdit();
}
catch (Exception e)
{
Debug.Print(e.ToString());
}
}
else
{
row.BeginEdit();
row["Error"] = true;
row["Birth"] = "File does not exist";
row.EndEdit();
}
}
else if (row["File Path"].Equals(DBNull.Value))
{
row.BeginEdit();
row["Error"] = true;
row["Site Origin"] = "No file path";
row.EndEdit();
}
}
catch (Exception e)
{
row.BeginEdit();
row["Error"] = true;
row["Birth"] = e.Message;
row.EndEdit();
}
}
TorrentXMLHandler.table.Columns["Handled"].ReadOnly = true;
TorrentXMLHandler.table.Columns["Error"].ReadOnly = true;
TorrentXMLHandler.table.AcceptChanges();
}
}
catch (Exception e)
{
ErrorWindow ew = new ErrorWindow();
ew.IssueGeneralWarning("Fatal Error", "Please report", e.Message + "\n" + e.StackTrace);
}
}