fix - 稳定性提升

master
SoulStar 1 week ago
parent 7bf8791f4d
commit 61fb0b2000

@ -126,6 +126,8 @@ namespace HighWayIot.Winform.Business
/// <param name="dateTime"></param> /// <param name="dateTime"></param>
/// <returns></returns> /// <returns></returns>
public static string DateTimeToString(DateTime? dateTimeStart, DateTime? dateTimeEnd) public static string DateTimeToString(DateTime? dateTimeStart, DateTime? dateTimeEnd)
{
try
{ {
if (dateTimeEnd == null || dateTimeStart == null) if (dateTimeEnd == null || dateTimeStart == null)
{ {
@ -146,6 +148,11 @@ namespace HighWayIot.Winform.Business
} }
return result; return result;
} }
catch (Exception ex)
{
return "";
}
}
} }

@ -72,10 +72,6 @@ namespace HighWayIot.Winform.UserControlPages
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.MonitorDataGridView = new System.Windows.Forms.DataGridView(); this.MonitorDataGridView = new System.Windows.Forms.DataGridView();
this.DataRefresh = new System.Windows.Forms.Timer(this.components);
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.panel6 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.No = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.No = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.VulcanizationNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.VulcanizationNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.StartTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.StartTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
@ -90,7 +86,11 @@ namespace HighWayIot.Winform.UserControlPages
this.TireWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.TireWeight = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsDone = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.IsDone = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DataRefresh = new System.Windows.Forms.Timer(this.components);
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.panel6 = new System.Windows.Forms.Panel();
this.MoveText = new Mesnac.Controls.ChemicalWeighing.HslMoveText(); this.MoveText = new Mesnac.Controls.ChemicalWeighing.HslMoveText();
this.panel3 = new System.Windows.Forms.Panel();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout();
@ -434,45 +434,7 @@ namespace HighWayIot.Winform.UserControlPages
this.MonitorDataGridView.RowTemplate.Height = 32; this.MonitorDataGridView.RowTemplate.Height = 32;
this.MonitorDataGridView.Size = new System.Drawing.Size(2169, 799); this.MonitorDataGridView.Size = new System.Drawing.Size(2169, 799);
this.MonitorDataGridView.TabIndex = 1; this.MonitorDataGridView.TabIndex = 1;
// this.MonitorDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.MonitorDataGridView_DataError);
// DataRefresh
//
this.DataRefresh.Enabled = true;
this.DataRefresh.Interval = 1000;
this.DataRefresh.Tick += new System.EventHandler(this.DataRefresh_Tick);
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Controls.Add(this.panel1, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.panel6, 0, 0);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 2;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(2169, 228);
this.tableLayoutPanel2.TabIndex = 2;
//
// panel6
//
this.panel6.Controls.Add(this.MoveText);
this.panel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel6.Location = new System.Drawing.Point(3, 3);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(2163, 108);
this.panel6.TabIndex = 1;
//
// panel3
//
this.panel3.Controls.Add(this.tableLayoutPanel2);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(2169, 228);
this.panel3.TabIndex = 3;
// //
// No // No
// //
@ -611,6 +573,36 @@ namespace HighWayIot.Winform.UserControlPages
this.IsDone.ReadOnly = true; this.IsDone.ReadOnly = true;
this.IsDone.Width = 80; this.IsDone.Width = 80;
// //
// DataRefresh
//
this.DataRefresh.Enabled = true;
this.DataRefresh.Interval = 1000;
this.DataRefresh.Tick += new System.EventHandler(this.DataRefresh_Tick);
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Controls.Add(this.panel1, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.panel6, 0, 0);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 2;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(2169, 228);
this.tableLayoutPanel2.TabIndex = 2;
//
// panel6
//
this.panel6.Controls.Add(this.MoveText);
this.panel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel6.Location = new System.Drawing.Point(3, 3);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(2163, 108);
this.panel6.TabIndex = 1;
//
// MoveText // MoveText
// //
this.MoveText.BackColor = System.Drawing.Color.Gold; this.MoveText.BackColor = System.Drawing.Color.Gold;
@ -624,6 +616,15 @@ namespace HighWayIot.Winform.UserControlPages
this.MoveText.Text = "欢迎各位领导莅临参观"; this.MoveText.Text = "欢迎各位领导莅临参观";
this.MoveText.DoubleClick += new System.EventHandler(this.MoveText_DoubleClick); this.MoveText.DoubleClick += new System.EventHandler(this.MoveText_DoubleClick);
// //
// panel3
//
this.panel3.Controls.Add(this.tableLayoutPanel2);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(2169, 228);
this.panel3.TabIndex = 3;
//
// MonitorMainPage // MonitorMainPage
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

@ -179,6 +179,8 @@ namespace HighWayIot.Winform.UserControlPages
private void BindData() private void BindData()
{ {
lock (GridRefreshLocker) lock (GridRefreshLocker)
{
try
{ {
//取出近两日的报表数据 //取出近两日的报表数据
List<ZxDailyReportEntity> dailyEntity = _zxDailyReportService.GetDailyReportInfos(); List<ZxDailyReportEntity> dailyEntity = _zxDailyReportService.GetDailyReportInfos();
@ -203,12 +205,12 @@ namespace HighWayIot.Winform.UserControlPages
_monitorDataSources.Add(new MonitorDataSource() _monitorDataSources.Add(new MonitorDataSource()
{ {
No = i + 1, No = i + 1,
VulcanizationNo = dailyEntity[i].VulcanizationNo, VulcanizationNo = dailyEntity[i].VulcanizationNo ?? "",
StartTime = dailyEntity[i].StartTime.ToString("HH:mm:ss"), StartTime = dailyEntity[i].StartTime.ToString("HH:mm:ss"),
RecipeName = dailyEntity[i].RecipeName, RecipeName = dailyEntity[i].RecipeName ?? "",
RecipeCode = dailyEntity[i].RecipeCode, RecipeCode = dailyEntity[i].RecipeCode ?? "",
SpecCode = dailyEntity[i].SpecCode, SpecCode = dailyEntity[i].SpecCode ?? "",
DeviceNo = dailyEntity[i].DeviceNo.ToString(), DeviceNo = (dailyEntity[i].DeviceNo ?? 0).ToString(),
StandardWeight = dailyEntity[i].StandardWeight ?? 0, StandardWeight = dailyEntity[i].StandardWeight ?? 0,
RawTireWeight = dailyEntity[i].RawTireWeight ?? 0, RawTireWeight = dailyEntity[i].RawTireWeight ?? 0,
BaseRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].BaseEndTime), BaseRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].BaseEndTime),
@ -250,6 +252,11 @@ namespace HighWayIot.Winform.UserControlPages
} }
RgvNoLabel.Text = first.DeviceNo.ToString(); RgvNoLabel.Text = first.DeviceNo.ToString();
} }
catch(Exception ex)
{
}
}
} }
/// <summary> /// <summary>
@ -260,6 +267,8 @@ namespace HighWayIot.Winform.UserControlPages
private void MonitorDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) private void MonitorDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{ {
// 确保是针对 "IsDone" 列的操作 // 确保是针对 "IsDone" 列的操作
try
{
if (MonitorDataGridView.Columns[e.ColumnIndex].Name == "IsDone" && e.RowIndex >= 0) if (MonitorDataGridView.Columns[e.ColumnIndex].Name == "IsDone" && e.RowIndex >= 0)
{ {
var cell = MonitorDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]; var cell = MonitorDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];
@ -273,6 +282,15 @@ namespace HighWayIot.Winform.UserControlPages
{ {
cell.Style.BackColor = Color.Yellow; // 黄色 cell.Style.BackColor = Color.Yellow; // 黄色
} }
else
{
cell.Style.BackColor = Color.Transparent;
}
}
}
catch
{
} }
} }
@ -289,5 +307,14 @@ namespace HighWayIot.Winform.UserControlPages
MoveText.Text = form.OutValue; MoveText.Text = form.OutValue;
} }
} }
private void MonitorDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
lock (GridRefreshLocker)
{
MonitorDataGridView.DataSource = null;
MonitorDataGridView.DataSource = _monitorDataSources;
}
}
} }
} }

Loading…
Cancel
Save