W
wackyphill
I keep getting this error on a scheduling program I'm working on and
don't know why. It seems to be the last row in the view always that
gets the error.
The Code W/ The Error: (_db is a wrapper around some ADO Objects)
int freq;
int days;
DateTime now = DateTime.Now;
string where = string.Format("runTime <= '{0}'", now);
bool bEnabled = false;
string path = null;
DataView runView = new DataView( _db.DS.Tables["task"], where, null,
DataViewRowState.CurrentRows);
foreach( DataRowView row in runView )
{
//Pull Values
freq = (int)row["freq"];
dt = (DateTime)row["runTime"];
days = (int)row["days"];
bEnabled = (bool)row["enabled"];
path = (string)row["path"];
//Update Time For Task To Run Next
if( freq == 0 ) { dt = dt.AddDays(1); }
else { dt = dt.AddMinutes(freq); }
row.BeginEdit();
row["runTime"] = dt;
row.EndEdit();
//Test If Task Should Run Today
int todayMask = (int)Math.Pow(2, (double)now.DayOfWeek);
if( (todayMask & days) == 0 ) { continue; }
//Run, If Enabled
if( bEnabled ) { RunProcess( path ); }
}
_db.Task_ApplyChanges();
RefreshTasks();
don't know why. It seems to be the last row in the view always that
gets the error.
The Code W/ The Error: (_db is a wrapper around some ADO Objects)
int freq;
int days;
DateTime now = DateTime.Now;
string where = string.Format("runTime <= '{0}'", now);
bool bEnabled = false;
string path = null;
DataView runView = new DataView( _db.DS.Tables["task"], where, null,
DataViewRowState.CurrentRows);
foreach( DataRowView row in runView )
{
//Pull Values
freq = (int)row["freq"];
dt = (DateTime)row["runTime"];
days = (int)row["days"];
bEnabled = (bool)row["enabled"];
path = (string)row["path"];
//Update Time For Task To Run Next
if( freq == 0 ) { dt = dt.AddDays(1); }
else { dt = dt.AddMinutes(freq); }
row.BeginEdit();
row["runTime"] = dt;
row.EndEdit();
//Test If Task Should Run Today
int todayMask = (int)Math.Pow(2, (double)now.DayOfWeek);
if( (todayMask & days) == 0 ) { continue; }
//Run, If Enabled
if( bEnabled ) { RunProcess( path ); }
}
_db.Task_ApplyChanges();
RefreshTasks();