public void SendIndividualTorrent()
{
DataGridViewSelectedRowCollection rc = dv.SelectedRows;
DataGridViewSelectedCellCollection cc = dv.SelectedCells;
if (rc.Count > 0)
{
foreach (DataGridViewRow r in rc)
{
if (!(bool)r.Cells["Error"].Value && !(bool)r.Cells["Handled"].Value && !r.Cells["Save Structure"].Equals(DBNull.Value) && !r.Cells["File Path"].Equals(DBNull.Value))
{
string save = (string)r.Cells["Save Structure"].Value;
string path = (string)r.Cells["File Path"].Value;
string success = uTorrentHandler.SendTorrent(save, path);
if (success.Equals("SUCCESS"))
{
TorrentXMLHandler.table.Columns["Handled"].ReadOnly = false;
r.Cells["Handled"].Value = true;
TorrentXMLHandler.table.Columns["Handled"].ReadOnly = true;
}
else
{
TorrentXMLHandler.table.Columns["Error"].ReadOnly = false;
r.Cells["Error"].Value = true;
if (!success.Equals("uTorrent.exe does not exist"))
r.Cells["Site Origin"].Value = success;
TorrentXMLHandler.table.Columns["Error"].ReadOnly = false;
}
}
}
}
if (cc.Count > 0)
{
foreach (DataGridViewCell c in cc)
{
if (!(bool)c.OwningRow.Cells["Error"].Value && !(bool)c.OwningRow.Cells["Handled"].Value && !c.OwningRow.Cells["Save Structure"].Value.Equals(DBNull.Value) && !c.OwningRow.Cells["File Path"].Value.Equals(DBNull.Value))
{
string save = (string)c.OwningRow.Cells["Save Structure"].Value;
string path = (string)c.OwningRow.Cells["File Path"].Value;
string success = uTorrentHandler.SendTorrent(save, path);
if (success.Equals("SUCCESS"))
{
TorrentXMLHandler.table.Columns["Handled"].ReadOnly = false;
c.OwningRow.Cells["Handled"].Value = true;
TorrentXMLHandler.table.Columns["Handled"].ReadOnly = true;
}
else
{
TorrentXMLHandler.table.Columns["Error"].ReadOnly = false;
c.OwningRow.Cells["Error"].Value = true;
c.OwningRow.Cells["File"].Value = success;
TorrentXMLHandler.table.Columns["Error"].ReadOnly = false;
}
}
else
{
if (c.OwningRow.Cells["Save Structure"].Value.Equals(DBNull.Value))
{
c.OwningRow.Cells["Site Origin"].Value = "No save structure..";
TorrentXMLHandler.table.Columns["Error"].ReadOnly = false;
c.OwningRow.Cells["Error"].Value = true;
TorrentXMLHandler.table.Columns["Error"].ReadOnly = false;
}
if (c.OwningRow.Cells["File Path"].Value.Equals(DBNull.Value))
{
c.OwningRow.Cells["Site Origin"].Value = "No file path..";
TorrentXMLHandler.table.Columns["Error"].ReadOnly = false;
c.OwningRow.Cells["Error"].Value = true;
TorrentXMLHandler.table.Columns["Error"].ReadOnly = false;
}
}
}
}
}