public void SelectOntapeFile() { DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) // Test result. { MyTapeReader = new OntapeReader(); tvDBList.Nodes.Clear(); dataGridView1.Rows.Clear(); dataGridView1.Columns.Clear(); toolStripProgressBar1.Visible = true; BackgroundWorker worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.DoWork += new DoWorkEventHandler(LoadOntapeFile); worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); worker.RunWorkerAsync(); } }
public void ProcessRow(OntapeReader.DBValue[] rowData) { int dvRecIndex = dataGridView1.Rows.Add(); DataGridViewRow thisRecord = dataGridView1.Rows[dvRecIndex]; for (int k = 0; k < rowData.Count(); k++) { OntapeReader.DBValue thisValue = rowData[k]; string ColDataValue = ""; // Output column data if (thisValue.dataLen > 0 && thisValue.isNull == 0) { switch (thisValue.dataType) { case 0x0000: // TEXT if (thisValue.dataVal[0] != 0x00) { ColDataValue = System.Text.Encoding.UTF8.GetString(thisValue.dataVal); } else { ColDataValue = "<EMPTY>"; } break; case 0x0001: // SMALLINT //thisValue.dataVal.Reverse(); ColDataValue = "0x" + (OntapeReader.ReverseInt16((ushort)BitConverter.ToInt16(thisValue.dataVal, 0))).ToString("X4"); break; case 0x0002: // INT //thisValue.dataVal.Reverse(); ColDataValue = "0x" + (OntapeReader.ReverseInt32((uint)BitConverter.ToInt32(thisValue.dataVal, 0))).ToString("X8"); break; case 0x0003: // FLOAT break; case 0x0009: // NULL break; case 0x000A: // DATETIME break; case 0x0029: // BOOL ColDataValue = (BitConverter.ToBoolean(thisValue.dataVal, 0)).ToString(); break; case 0x0034: // LONG //thisValue.dataVal.Reverse(); ColDataValue = "0x" + (OntapeReader.ReverseInt64((ulong)BitConverter.ToInt64(thisValue.dataVal, 0))).ToString("X16"); break; case 0x1029: // BINARY FILE POINTER DATA ColDataValue = (BitConverter.ToString(thisValue.dataVal)).Replace("-", ""); break; } } if (String.IsNullOrEmpty(ColDataValue)) { ColDataValue = "<NULL>"; } thisRecord.Cells[dataGridView1.Columns[k].Name].Value = ColDataValue; } }