public void RunTransactions() { // Execute PowerShell script that runs COBOL programs var psScript = new StringBuilder(); var path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os"; psScript.AppendLine($"$WorkingDir = \"{path}\""); //psScript.AppendLine("$CurrMasterDataFile = Join-Path $WorkingDir \"\\data\\students.dat\""); //psScript.AppendLine("$fileExist = Test-Path $CurrMasterDataFile"); //psScript.AppendLine("if ($fileExist) {Remove-Item $CurrMasterDataFile}"); //psScript.AppendLine("$OrigMasterDataFile = Join-Path $WorkingDir \"\\data\\students_orig.dat\""); //psScript.AppendLine("$DestinationFile = Join-Path $WorkingDir \"\\data\\students.dat\""); //psScript.AppendLine("Copy-Item $OrigMasterDataFile -Destination $DestinationFile"); psScript.AppendLine("$Executable = Join-Path $WorkingDir \"\\studentwrite.exe\""); psScript.AppendLine("& $Executable"); // remove students.dat file and rename students1.dat //psScript.AppendLine("Remove-Item $CurrMasterDataFile"); //psScript.AppendLine("$NewMasterDataFile = Join-Path $WorkingDir \"\\data\\students1.dat\""); //psScript.AppendLine("Rename-Item -Path $NewMasterDataFile -NewName \"students.dat\""); List <string> results = RunScript(psScript.ToString()); path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os\data\students1.dat"; var recs = new StudentRecords(path); var allrecs = recs.GetAllRecords(); Assert.IsTrue(allrecs.Count == 39); }
private void Dashboard_Load(object sender, EventArgs e) { var path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os\data\students.dat"; var recs = new StudentRecords(path); var allrecs = recs.GetAllRecords(); dgvStudentRecords.DataSource = null; //ds.Dispose(); ds = new DataSet(); ds.Tables.Add(); ds.Tables[0].Columns.Add("StudentId"); ds.Tables[0].Columns.Add("LastName"); ds.Tables[0].Columns.Add("Initials"); ds.Tables[0].Columns.Add("DOB"); ds.Tables[0].Columns.Add("PhoneNo"); ds.Tables[0].Columns.Add("ProgramCode"); ds.Tables[0].Columns.Add("Gender"); ds.Tables[0].Columns.Add("LoanAmount"); foreach (var rec in allrecs) { ds.Tables[0].Rows.Add(rec.StudentId, rec.LastName, rec.Initials, rec.DOB, rec.PhoneNo, rec.ProgramCode, rec.Gender, rec.LoanAmount); } ds.Tables[0].AcceptChanges(); dgvStudentRecords.DataSource = ds.Tables[0]; }
public void ReadAllRecords() { var path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os\data\students.dat"; var recs = new StudentRecords(path); var allrecs = recs.GetAllRecords(); Assert.IsTrue(allrecs.Count > 0); }
private void bnRefreshData_Click(object sender, EventArgs e) { var path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os\data\students.dat"; var recs = new StudentRecords(path); var allrecs = recs.GetAllRecords(); ds.Tables[0].Rows.Clear(); foreach (var rec in allrecs) { ds.Tables[0].Rows.Add(rec.StudentId, rec.LastName, rec.Initials, rec.DOB, rec.PhoneNo, rec.ProgramCode, rec.Gender, rec.LoanAmount); } ds.Tables[0].AcceptChanges(); //dgvStudentRecords.DataSource = ds.Tables[0]; }