private void timerGetDataFormDb_Tick(object sender, EventArgs e) { ComWithSqlServer.FindGatherData(GatherDatas); ComWithSqlServer.FindGatherErrors(GatherErrors); ComWithSqlServer.FindStationCode(StationCodes); for (int i = 0; i < GatherDatas.Count; ++i) { getParaValue = new GetParaValue( StationCodes[i].Dictionary, GatherDatas[i].Dictionary, GatherErrors[i].Dictionary ); stationGroups[i].Text = getParaValue.StationName; var labelAlarm = stationGroups[i].Controls[3] as SkinLabel; var labelError = stationGroups[i].Controls[2] as SkinLabel; if (getParaValue.AlarmSign == false && getParaValue.ErrorSign == false) { labelAlarm.Text = "正常"; labelAlarm.BackColor = Color.Lime; labelError.Visible = false; labelAlarm.Visible = true; continue; } if (getParaValue.AlarmSign == false) { labelAlarm.Text = "--"; labelAlarm.BackColor = Color.Gray; labelAlarm.Visible = false; } else { labelAlarm.Text = "报警"; labelAlarm.BackColor = Color.Yellow; labelAlarm.Visible = true; } if (getParaValue.ErrorSign == false) { labelError.Visible = false; labelError.Text = "--"; labelError.BackColor = Color.Gray; } else { labelError.Visible = true; labelError.Text = "故障"; labelError.BackColor = Color.Red; } } }
private void RenewData(bool result) { if (this.InvokeRequired) { this.Invoke(new InvokeCallback(RenewData), new object[] { result }); } else { if (result == true) { MessageBox.Show("数据库连接成功!\r\n点击确定按钮开始上传数据"); } else { MessageBox.Show("数据库连接失败!\r\n软件退出"); this.WindowState = FormWindowState.Minimized; Close(); return; } labelStatus.Text = "数据库连接成功!"; progressBar1.Visible = false; ToolStripMenuItemConnectServer.Enabled = false; panelSqlServer.Enabled = false; StationCodes = new List <StationCode>(); GatherDatas = new List <GatherData>(); GatherErrors = new List <GatherError>(); textBox1.Text = ComWithSqlServer.FindStationCode(StationCodes); textBox2.Text = ComWithSqlServer.FindGatherData(GatherDatas); textBox1.Text = ComWithSqlServer.FindGatherErrors(GatherErrors); UpLoadThread = new Thread(new ThreadStart(() => { while (true) { ComWithSqlServer?.FindStationCode(StationCodes); ComWithSqlServer?.FindGatherData(GatherDatas); ComWithSqlServer?.FindGatherErrors(GatherErrors); FileService.SaveStationsData(GatherDatas, StationCodes, GatherErrors); Thread.Sleep(1000); new QiniuStorage.UpLoad().DoUpLoad(); Thread.Sleep(25000); } })); UpLoadThread.Start(); HideFormToTuoPan(); } }