在这一点上我很困惑,我有以下代码:
while (dal.Read())
{
if (FiltersAppliedForThisJob(dal.GetInt(0)))
continue;
var j = 0;
if (SettingsManager.OpsMgrSettings.JobViewServiceList.IsNotNull() &&
SettingsManager.OpsMgrSettings.JobViewServiceList.Count > 0)
if (!ThisJobHasASupportedService(dal.GetInt(0)))
continue;
var newJobGridRow = AddRowToJobGridWithJobID(dal.GetInt(0),
ref j);
BoldThisJobGridRowIfItIsUpdated(newJobGridRow, dal);
var jobno = dal2.GetJobNo(dal.GetInt(0).ToString());
if (locns2view.Length > 0)
_jobgrid.Rows[newJobGridRow].Visible = locns2view.Contains(jobno.Substring(0, 2));
var col = 2;
if (j < _jobgrid.ColumnCount)
for (i = 0; i < str1.Length; i++)
{
if (str1[i].Length <= 0)
continue;
if (!dal.IsFieldNull(col))
PlaceValuesInJobGridCells(dtype, i, dal2, str1, jobno, newJobGridRow, j, dal, col);
j++;
col++;
}
if (_jobgrid[0, newJobGridRow].Value.ToString() == prevjobid)
_jobgrid.Rows[newJobGridRow].Selected = true;
}
SortJobGridColumns();
}
似乎内存不足错误来自上面的代码。但是,如果我在调用之前放置 MessageBox ,则FiltersAppliedForThisJob(dal.GetInt(0)
不会出错。例如下面的代码:
while (dal.Read())
{
MessageBox.Show("Done"); // for debugging purposes
if (FiltersAppliedForThisJob(dal.GetInt(0)))
continue;
var j = 0;
if (SettingsManager.OpsMgrSettings.JobViewServiceList.IsNotNull() &&
SettingsManager.OpsMgrSettings.JobViewServiceList.Count > 0)
if (!ThisJobHasASupportedService(dal.GetInt(0)))
continue;
var newJobGridRow = AddRowToJobGridWithJobID(dal.GetInt(0),
ref j);
BoldThisJobGridRowIfItIsUpdated(newJobGridRow, dal);
var jobno = dal2.GetJobNo(dal.GetInt(0).ToString());
if (locns2view.Length > 0)
_jobgrid.Rows[newJobGridRow].Visible = locns2view.Contains(jobno.Substring(0, 2));
var col = 2;
if (j < _jobgrid.ColumnCount)
for (i = 0; i < str1.Length; i++)
{
if (str1[i].Length <= 0)
continue;
if (!dal.IsFieldNull(col))
PlaceValuesInJobGridCells(dtype, i, dal2, str1, jobno, newJobGridRow, j, dal, col);
j++;
col++;
}
if (_jobgrid[0, newJobGridRow].Value.ToString() == prevjobid)
_jobgrid.Rows[newJobGridRow].Selected = true;
}
SortJobGridColumns();
}
此外,如果我删除函数调用FiltersAppliedForThisJob(dal.GetInt(0)
,我不会收到错误消息。
这是功能代码:
private bool FiltersAppliedForThisJob(int p)
{
var filter_datefrom = SettingsManager.OpsMgrSettings.MainView_DateFrom;
var filter_dateto = SettingsManager.OpsMgrSettings.MainView_DateTo;
var filter_status = SettingsManager.OpsMgrSettings.MainView_JobStatus;
var jobNumTbl = dal.Get_JobNumber(p);
var jobStatus = GetJobStatus(p);
var jobdate = jobNumTbl.Date;
var jobdate_res = false;
var jobstat_res = false;
var isFiltered = false;
if (jobdate.HasValue)
{
//both have values
if (filter_datefrom.HasValue && filter_dateto.HasValue)
{
if (DateTime.Compare(jobdate.Value.Date, filter_datefrom.Value.Date) < 0 ||
DateTime.Compare(jobdate.Value.Date, filter_dateto.Value.Date) > 0)
jobdate_res = true;
}
//only datefrom has value
else if (filter_datefrom.HasValue)
{
if (DateTime.Compare(jobdate.Value.Date, filter_datefrom.Value.Date) < 0)
jobdate_res = true;
}
//only datato has value
else if (filter_dateto.HasValue)
{
if (DateTime.Compare(jobdate.Value.Date, filter_dateto.Value.Date) > 0)
jobdate_res = true;
}
}
if (jobStatus.HasValue)
{
if (!filter_status.Equals(2))
if (!filter_status.Equals(jobStatus))
jobstat_res = true;
}
if (jobdate_res || jobstat_res)
isFiltered = true;
return isFiltered;
}
不确定这是否足够的信息。如果您需要我提供更多信息,请告诉我。