private bool CreateBatchConnectionList(List <FileInfo> fileInfoList, ref List <BatchConnection> batchConnectionList) { batchConnectionList = new List <BatchConnection>(); for (int i = 0; i < fileInfoList.Count; i++) { try { FileStream fs = new FileStream(fileInfoList[i].FullName, FileMode.Open); StreamReader sr = new StreamReader(fs); BatchConnection bConn = new BatchConnection(sr.ReadToEnd(), fileInfoList[i].FullName); batchConnectionList.Add(bConn); sr.Close(); fs.Close(); fillTableWithStartData(batchConnectionList); } catch (Exception ex) { richTextBox1.Text = "При чтении файлов и создании BatchConnection возникла ошибка"; return(false); } } if (batchConnectionList.Count == 0) { return(false); } return(true); }
private void connPrmsTSMI_Click(object sender, EventArgs e) { if (connectionParamForm.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { BatchConnection bCon = new BatchConnection(connectionParamForm.connectionParams.strResultConnectionString); BatchConnectionList = new List <BatchConnection>(); BatchConnectionList.Add(bCon); InitBatchMode(); } }
private void btnExecFile_Click(object sender, EventArgs e) { if (BatchConnectionList.Count == 0) { richTextBox1.Text = "Список BatchConnectionList пуст"; } BatchConnection tmpBatchConn = BatchConnectionList[(int)numBatchFileNum.Value - 1]; List <BatchConnection> tmpBatchConnList = new List <BatchConnection>(); tmpBatchConnList.Add(tmpBatchConn); StartExecutingThread(tmpBatchConnList); }
private void btnShowFile_Click(object sender, EventArgs e) { if (BatchConnectionList.Count == 0) { richTextBox1.Text = "Список BatchConnectionList пуст"; } BatchConnection tmpBatchConn = BatchConnectionList[(int)numBatchFileNum.Value - 1]; string fileCaption = tmpBatchConn.HasSourceFile ? tmpBatchConn.SourceName : tmpBatchConn.SerialNumber; richTextBox1.Text = "*** " + fileCaption + " ***\n\n"; if (tmpBatchConn.HasSourceFile) { richTextBox1.Text += "Исходный файл:\n"; richTextBox1.Text += tmpBatchConn.CommandOriginal + "\n\n"; } richTextBox1.Text += "Интерпретированный:\n"; richTextBox1.Text += tmpBatchConn.Command + "\n"; }
//выполняется в отдельном потоке public void ExecuteBatchConnectionList(object batchConnectionListObject) { List <BatchConnection> batchConnectionList = (List <BatchConnection>)batchConnectionListObject; if (batchConnectionList.Count == 0) { return; } ExecutionStartedEvent.Invoke(null, new EventArgs()); for (int i = 0; i < batchConnectionList.Count; i++) { if (StopFlag) { ExecutionEnded_EventHandler(null, new EventArgs()); return; } BatchConnection bConn = batchConnectionList[i]; string tmpCmd = bConn.Command; if (!bConn.ExistsRDS) { PrintMsg(String.Format("{1}: файл 'rdslib.exe, необходимый для подключения, не найден. Дирректория поиска: {0}\n\n", bConn.FileNameRDSLib, bConn.SerialNumber)); ExecutionEnded_EventHandler(null, new EventArgs()); return; } this.Invoke((MethodInvoker) delegate() { timerProgressBar.Maximum = 60; timerProgressBar.Value = 0; }); bool fileExecutionResult = sayaniKombik.ExecuteBatchConnection(bConn); if (fileExecutionResult) { if (loadDumpFile(bConn.FileNameDump, false)) { if (tmpMeterInfo.sayaniMeterTypeInt != (int)SayaniMeterTypes.RMDImpulse2Channel) { this.Invoke((MethodInvoker) delegate() { PrintLastRecord((int)numericUpDown1.Value, false, dt, i + 1); PrintMsg("\n"); }); } else { loadDumpFile(bConn.FileNameDump, true); } } if (fStreamDump != null) { fStreamDump.Close(); } sayaniKombik.DeleteDumpFileAndLogs(bConn.FileNameDump); } else { PrintMsg(String.Format("{0}: не найден файл дампа {1}, ошибка чтения.\n\n", bConn.SerialNumberDec2Bytes, bConn.FileNameDump)); } BatchFileTriedEvent.Invoke(null, new EventArgs()); } ExecutionEndedEvent.Invoke(null, new EventArgs()); }