#250926 术鹏修改为将耗时操作修改为后台线程
This commit is contained in:
@@ -25,6 +25,7 @@ namespace NSAnalysis
|
||||
private DataTable dtVINData = new DataTable();
|
||||
private string strLastVIN = "";
|
||||
CenterControl gCC = null;
|
||||
private BackgroundWorker m_bgwRefreshCar = new BackgroundWorker();
|
||||
#endregion 全局变量
|
||||
|
||||
#region 初始化控件
|
||||
@@ -96,10 +97,95 @@ namespace NSAnalysis
|
||||
InitNextSenseControl();
|
||||
labVIN.Text = "";
|
||||
tmrRefreshData.Interval = 1100;
|
||||
tmrRefreshData.Start();
|
||||
//tmrRefreshData.Start();
|
||||
m_bgwRefreshCar.DoWork += new DoWorkEventHandler(m_bgwRefreshCar_DoWork);
|
||||
m_bgwRefreshCar.RunWorkerAsync();
|
||||
SpecifyScreenDisplay1();
|
||||
}
|
||||
private void m_bgwRefreshCar_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
string strVIN = tmdal.SelectMaintenanceStation7VIN();
|
||||
if (strLastVIN != strVIN)
|
||||
{
|
||||
if (strVIN.ToLower().Contains("empty"))
|
||||
{
|
||||
labVIN.Text = "VIN码为空";
|
||||
Invoke((MethodInvoker)(() =>
|
||||
{
|
||||
labVIN.Text = "VIN码为空";
|
||||
}));
|
||||
InitNextSenseControl();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strVIN.Length == 17)
|
||||
{
|
||||
string strSubVIN = strVIN;//.Substring(0, strVIN.Length - 2);
|
||||
dtVINData.Clear();
|
||||
Invoke((MethodInvoker)(() =>
|
||||
{
|
||||
labVIN.Text = strSubVIN;
|
||||
}));
|
||||
string strCarType = tmdal.SelectCarTypeByVIN(strSubVIN);
|
||||
|
||||
if (strCarType.ToUpper().Contains("EH3"))
|
||||
{
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh m_bgwRefreshCar_DoWork (strVIN.Length==17):strLastVIN:" + strLastVIN + " ;VIN: " + strSubVIN);
|
||||
SpecifyScreenDisplay1();
|
||||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||||
if (dtVINData.Rows.Count > 0)
|
||||
{
|
||||
refreshCarUIData(dtVINData);
|
||||
analysisTitleColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
InitNextSenseControl();
|
||||
}
|
||||
gCC.ShowCarMeasureDataByCarType(1);
|
||||
}
|
||||
}
|
||||
if (strVIN.Length == 21)
|
||||
{
|
||||
string strSubVIN = strVIN.Substring(0, 17);
|
||||
dtVINData.Clear();
|
||||
Invoke((MethodInvoker)(() =>
|
||||
{
|
||||
labVIN.Text = strSubVIN;
|
||||
}));
|
||||
string strCarType = strVIN.Substring(18, 3);
|
||||
|
||||
if (strCarType.ToUpper().Contains("EH3"))
|
||||
{
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh m_bgwRefreshCar_DoWork (strVIN.Length==21):strLastVIN:" + strLastVIN + " ;VIN: " + strSubVIN);
|
||||
SpecifyScreenDisplay1();
|
||||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||||
if (dtVINData.Rows.Count > 0)
|
||||
{
|
||||
refreshCarUIData(dtVINData);
|
||||
analysisTitleColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
InitNextSenseControl();
|
||||
}
|
||||
gCC.ShowCarMeasureDataByCarType(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
strLastVIN = strVIN;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyBase.TraceWriteLine("Left EHY UI Refresh m_bgwRefreshCar_DoWork Error:" + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void btnRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
SpecifyScreenDisplay1();
|
||||
@@ -117,9 +203,10 @@ namespace NSAnalysis
|
||||
dtVINData.Clear();
|
||||
labVIN.Text = strSubVIN;
|
||||
string strCarType = tmdal.SelectCarTypeByVIN(strSubVIN);
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh Button (strVIN.Length==17):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||||
|
||||
if (strCarType.ToUpper().Contains("EH3"))
|
||||
{
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh Button (strVIN.Length==17):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||||
if (dtVINData.Rows.Count > 0)
|
||||
{
|
||||
@@ -138,9 +225,10 @@ namespace NSAnalysis
|
||||
dtVINData.Clear();
|
||||
labVIN.Text = strSubVIN;
|
||||
string strCarType = strVIN.Substring(strVIN.Length - 3, 3);
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh Button (strVIN.Length==21):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||||
|
||||
if (strCarType.ToUpper().Contains("EH3"))
|
||||
{
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh Button (strVIN.Length==21):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||||
if (dtVINData.Rows.Count > 0)
|
||||
{
|
||||
@@ -179,9 +267,10 @@ namespace NSAnalysis
|
||||
dtVINData.Clear();
|
||||
labVIN.Text = strSubVIN;
|
||||
string strCarType = tmdal.SelectCarTypeByVIN(strSubVIN);
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh tmrRefreshData (strVIN.Length==17):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||||
|
||||
if (strCarType.ToUpper().Contains("EH3"))
|
||||
{
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh tmrRefreshData (strVIN.Length==17):strLastVIN:" + strLastVIN + " ;VIN: " + strSubVIN);
|
||||
SpecifyScreenDisplay1();
|
||||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||||
if (dtVINData.Rows.Count > 0)
|
||||
@@ -202,9 +291,10 @@ namespace NSAnalysis
|
||||
dtVINData.Clear();
|
||||
labVIN.Text = strSubVIN;
|
||||
string strCarType = strVIN.Substring(18, 3);
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh tmrRefreshData (strVIN.Length==21):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||||
|
||||
if (strCarType.ToUpper().Contains("EH3"))
|
||||
{
|
||||
MyBase.TraceWriteLine("Right EH3 UI Refresh tmrRefreshData (strVIN.Length==21):strLastVIN:" + strLastVIN + " ;VIN: " + strSubVIN);
|
||||
SpecifyScreenDisplay1();
|
||||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||||
if (dtVINData.Rows.Count > 0)
|
||||
@@ -228,11 +318,6 @@ namespace NSAnalysis
|
||||
{
|
||||
MyBase.TraceWriteLine("Left EHY UI Refresh tmrRefreshData Error:" + ex.Message);
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
tmrRefreshData.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private Color analysisColorbyStatus(string strStatus)
|
||||
@@ -276,25 +361,28 @@ namespace NSAnalysis
|
||||
strNSName = "R" + i.ToString();
|
||||
}
|
||||
ucns = ((UCVWNextSense)MyBase.GetChildControl(this, strNSName));
|
||||
if (ucns != null)
|
||||
Invoke((MethodInvoker)(() =>
|
||||
{
|
||||
if (ucns.tlpFBackColor == Color.Red || ucns.tlpGBackColor == Color.Red)
|
||||
if (ucns != null)
|
||||
{
|
||||
ucns.tlpBackColor = Color.Red;
|
||||
if (ucns.tlpFBackColor == Color.Red || ucns.tlpGBackColor == Color.Red)
|
||||
{
|
||||
ucns.tlpBackColor = Color.Red;
|
||||
}
|
||||
else if (ucns.tlpFBackColor == Color.LightGray && ucns.tlpGBackColor == Color.LightGray)
|
||||
{
|
||||
ucns.tlpBackColor = Color.LightGray;
|
||||
}
|
||||
else if (ucns.tlpFBackColor == Color.Yellow && ucns.tlpGBackColor == Color.Yellow)
|
||||
{
|
||||
ucns.tlpBackColor = Color.Yellow;
|
||||
}
|
||||
else
|
||||
{
|
||||
ucns.tlpBackColor = Color.Lime;
|
||||
}
|
||||
}
|
||||
else if (ucns.tlpFBackColor == Color.LightGray && ucns.tlpGBackColor == Color.LightGray)
|
||||
{
|
||||
ucns.tlpBackColor = Color.LightGray;
|
||||
}
|
||||
else if (ucns.tlpFBackColor == Color.Yellow && ucns.tlpGBackColor == Color.Yellow)
|
||||
{
|
||||
ucns.tlpBackColor = Color.Yellow;
|
||||
}
|
||||
else
|
||||
{
|
||||
ucns.tlpBackColor = Color.Lime;
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,21 +396,25 @@ namespace NSAnalysis
|
||||
strNSName = dtData.Rows[i]["MeasPointName"].ToString().Replace("-", "");
|
||||
strFGName = dtData.Rows[i]["DimensionName"].ToString();
|
||||
ucns = ((UCVWNextSense)MyBase.GetChildControl(this, strNSName));
|
||||
if (ucns != null)
|
||||
Invoke((MethodInvoker)(() =>
|
||||
{
|
||||
if (strFGName == "F")
|
||||
if (ucns != null)
|
||||
{
|
||||
ucns.labFVal = dtData.Rows[i]["MeasureValue"].ToString();
|
||||
ucns.labFLowerUpper = dtData.Rows[i]["LowerTolVal"].ToString() + "/" + dtData.Rows[i]["UpperTolVal"].ToString();
|
||||
ucns.tlpFBackColor = analysisColorbyStatus(dtData.Rows[i]["MeasureItemResult"].ToString());
|
||||
if (strFGName == "F")
|
||||
{
|
||||
ucns.labFVal = dtData.Rows[i]["MeasureValue"].ToString();
|
||||
ucns.labFLowerUpper = dtData.Rows[i]["LowerTolVal"].ToString() + "/" + dtData.Rows[i]["UpperTolVal"].ToString();
|
||||
ucns.tlpFBackColor = analysisColorbyStatus(dtData.Rows[i]["MeasureItemResult"].ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
ucns.labGVal = dtData.Rows[i]["MeasureValue"].ToString();
|
||||
ucns.labGLowerUpper = dtData.Rows[i]["LowerTolVal"].ToString() + "/" + dtData.Rows[i]["UpperTolVal"].ToString();
|
||||
ucns.tlpGBackColor = analysisColorbyStatus(dtData.Rows[i]["MeasureItemResult"].ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ucns.labGVal = dtData.Rows[i]["MeasureValue"].ToString();
|
||||
ucns.labGLowerUpper = dtData.Rows[i]["LowerTolVal"].ToString() + "/" + dtData.Rows[i]["UpperTolVal"].ToString();
|
||||
ucns.tlpGBackColor = analysisColorbyStatus(dtData.Rows[i]["MeasureItemResult"].ToString());
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user