public ListBoxBOMInstItem(BOMInst inst, BOMComp comp) { BOMInst = inst; BOMComp = comp; }
private void button1_Click(object sender, EventArgs e) { try { TOtests.Clear(); if (File.Exists(Sel_TOTB.Text)) { string[] TOfile = File.ReadAllLines(Sel_TOTB.Text); foreach (string TOComp in TOfile) { //string tempcomp = ""; string testname = ""; // Extract Test Name if (TOComp.Trim().ToLower().Contains("test ") || TOComp.Trim().ToLower().Contains("skip ")) { //tempcomp = tempcomp + TOComp.Substring(TOComp.IndexOf("\"", 0) + 1, TOComp.IndexOf("\"", TOComp.IndexOf("\"", 0) + 1) - TOComp.IndexOf("\"", 0) - 1); if (TOComp.Trim().ToLower().Substring(0,TOComp.IndexOf("\"") - 1).Contains("test ")) { testname = testname + TOComp.Substring(0, TOComp.IndexOf("test ", 0) + 4).Trim() + "\t"; testname = testname + TOComp.Substring(TOComp.IndexOf("test ", 0) + 4, TOComp.IndexOf("\"", TOComp.IndexOf("test ", 0)) - TOComp.IndexOf("test ", 0) - 4).Trim() + "\t"; testname = testname + TOComp.Substring(TOComp.IndexOf("\"", 0) + 1, TOComp.IndexOf("\"", TOComp.IndexOf("\"", 0) + 1) - TOComp.IndexOf("\"", 0) - 1); } if (TOComp.Trim().ToLower().Substring(0, TOComp.IndexOf("\"") - 1).Contains("skip ")) { testname = testname + TOComp.Substring(0, TOComp.IndexOf("skip ", 0) + 4).Trim() + "\t"; testname = testname + TOComp.Substring(TOComp.IndexOf("skip ", 0) + 4, TOComp.IndexOf("\"", TOComp.IndexOf("skip ", 0)) - TOComp.IndexOf("skip ", 0) - 4).Trim() + "\t"; testname = testname + TOComp.Substring(TOComp.IndexOf("\"", 0) + 1, TOComp.IndexOf("\"", TOComp.IndexOf("\"", 0) + 1) - TOComp.IndexOf("\"", 0) - 1); } //testname = TOComp.Substring(0, TOComp.IndexOf("\"", TOComp.IndexOf("\"", 0) + 1) + 1).Trim(); TOtests.Add(testname + "\t"); // Extract Version Name //tempcomp = tempcomp + "\t"; testname = testname + "\t"; string versionname = "Base"; if (TOComp.ToLower().Contains("version")) //tempcomp = tempcomp + TOComp.Substring(TOComp.IndexOf("\"", TOComp.ToLower().IndexOf("version", 0)) + 1, TOComp.IndexOf("\"", TOComp.IndexOf("\"", TOComp.ToLower().IndexOf("version", 0)) + 1) - TOComp.IndexOf("\"", TOComp.ToLower().IndexOf("version", 0)) - 1); versionname = TOComp.Substring(TOComp.IndexOf("\"", TOComp.ToLower().IndexOf("version", 0)) + 1, TOComp.IndexOf("\"", TOComp.IndexOf("\"", TOComp.ToLower().IndexOf("version", 0)) + 1) - TOComp.IndexOf("\"", TOComp.ToLower().IndexOf("version", 0)) - 1).Trim(); // Extract Options //tempcomp = tempcomp + "\t"; testname = TOtests[TOtests.FindIndex(item => item == testname)] = TOtests.Find(item => item == testname) + versionname + "\t"; string optionsname = ""; if (TOComp.Contains(";")) { if (TOComp.Contains("!")) //tempcomp = tempcomp + TOComp.Substring(TOComp.IndexOf(";", 0) + 1, TOComp.IndexOf("!", 0) - TOComp.IndexOf(";", 0) - 1); optionsname = TOComp.Substring(TOComp.IndexOf(";", 0) + 1, TOComp.IndexOf("!", 0) - TOComp.IndexOf(";", 0) - 1).Trim(); else //tempcomp = tempcomp + TOComp.Substring(TOComp.IndexOf(";", 0) + 1, TOComp.Length - TOComp.IndexOf(";", 0) - 1); optionsname = TOComp.Substring(TOComp.IndexOf(";", 0) + 1, TOComp.Length - TOComp.IndexOf(";", 0) - 1).Trim(); } testname = TOtests[TOtests.FindIndex(item => item == testname)] = TOtests.Find(item => item == testname) + optionsname + "\t"; // Exrtact Comment //tempcomp = tempcomp + "\t"; string comments = ""; if (TOComp.Contains("!")) //tempcomp = tempcomp + TOComp.Substring(TOComp.IndexOf("!", 0) + 1, TOComp.Length - TOComp.IndexOf("!", 0) - 1); comments = TOComp.Substring(TOComp.IndexOf("!", 0) + 1, TOComp.Length - TOComp.IndexOf("!", 0) - 1).Trim(); testname = TOtests[TOtests.FindIndex(item => item == testname)] = TOtests.Find(item => item == testname) + comments; } } //WriteToExcel(@"C:\Users\uidw8018\Desktop\ICTCOMP.xlsx", "Testorder", TOtests); //FileStream myWriteStream = new FileStream(Path.GetFullPath(@"C:\Users\uidw8018\Desktop\Testorder" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".xls"), FileMode.Append, FileAccess.Write); //byte[] newLine = Encoding.Default.GetBytes(Environment.NewLine); //foreach (string writeline in tests) //{ // myWriteStream.Write(Encoding.ASCII.GetBytes(writeline.Trim()), 0, Encoding.ASCII.GetByteCount(writeline.Trim())); // myWriteStream.Write(newLine, 0, newLine.Length); //} //myWriteStream.Close(); StatusL.Text = "Testorder Extraction Complete"; } else { MessageBox.Show("Testorder file does not exists"); } if (File.Exists(Sel_TPTB.Text)) { TPtests.Clear(); string[] TPfile = File.ReadAllLines(Sel_TPTB.Text); foreach (string TPComp in TPfile) { //string tempcomp = ""; string testname = ""; // Extract Test Name if (TPComp.Trim().ToLower().Contains("test \"")) { bool valid = (TPComp.Trim().ToLower()[0] == 't'); testname = TPComp.Substring(TPComp.IndexOf("\"", 0) + 1, TPComp.IndexOf("\"", TPComp.IndexOf("\"", 0) + 1) - TPComp.IndexOf("\"", 0) - 1); if (testname.Contains("\\")) testname = testname.Substring(testname.IndexOf("\\", 0) + 1); if (testname.Contains("/")) testname = testname.Substring(testname.IndexOf("/", 0) + 1); if (testname.Trim().IndexOf("1%") == 0) testname = testname.Substring(testname.IndexOf("1%", 0) + 2); if (testname.Trim().IndexOf("2%") == 0) testname = testname.Substring(testname.IndexOf("2%", 0) + 2); if (testname != "") { // Extract Version Name //tempcomp = tempcomp + "\t"; if (valid) { TPtests.Add(testname + "\t" + "\t"); testname = testname + "\t" + "\t"; } else { TPtests.Add(testname + "\t" + TPComp.Trim().Substring(0, TPComp.IndexOf("test \"", 0)).Trim() + "\t"); testname = testname + "\t" + TPComp.Trim().Substring(0, TPComp.IndexOf("test \"", 0)).Trim() + "\t"; } // Exrtact Comment //tempcomp = tempcomp + "\t"; string comments = ""; if (TPComp.Substring(TPComp.IndexOf("test ", 0)).Contains("!")) //tempcomp = tempcomp + TOComp.Substring(TOComp.IndexOf("!", 0) + 1, TOComp.Length - TOComp.IndexOf("!", 0) - 1); comments = TPComp.Substring(TPComp.IndexOf("!", TPComp.IndexOf("test ", 0)), TPComp.Length - TPComp.IndexOf("!", TPComp.IndexOf("test ", 0))).Trim(); testname = TPtests[TPtests.FindIndex(item => item == testname)] = TPtests.Find(item => item == testname) + comments; } // else // TPtests.Add(TPComp.Trim()); } } //WriteToExcel(@"C:\Users\uidw8018\Desktop\ICTCOMP.xlsx", "Testplan", TPtests); //FileStream myWriteStream = new FileStream(Path.GetFullPath(@"C:\Users\uidw8018\Desktop\Testplan" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".xls"), FileMode.Append, FileAccess.Write); //byte[] newLine = Encoding.Default.GetBytes(Environment.NewLine); //foreach (string writeline in tests) //{ // myWriteStream.Write(Encoding.ASCII.GetBytes(writeline.Trim()), 0, Encoding.ASCII.GetByteCount(writeline.Trim())); // myWriteStream.Write(newLine, 0, newLine.Length); //} //myWriteStream.Close(); StatusL.Text = "Testplan Extraction Complete"; } else MessageBox.Show("Testplan file does not exists"); if (File.Exists(Sel_TOTB.Text)) { BOMtests.Clear(); string[] BOMfile = File.ReadAllLines(Select_BomTB.Text); foreach (string BOMComp in BOMfile) { BOMtests.Add(BOMComp.Trim()); } StatusL.Text = "BOM File Extraction Complete"; } else MessageBox.Show("BOM file does not exists"); if (File.Exists(Select_LogTB.Text)) { LOGtests.Clear(); string[] Logfile = File.ReadAllLines(Select_LogTB.Text); foreach (string LogComp in Logfile) { //string tempcomp = ""; string testname = ""; // Extract Test Name if (LogComp.Trim().ToLower().Contains("@block|") || LogComp.Trim().ToLower().Contains("@d-t|")) { if (LogComp.Trim().ToLower().Contains("@block")) testname = LogComp.Split('|').ElementAt(1); if (LogComp.Trim().ToLower().Contains("@d-t")) testname = LogComp.Split('|').ElementAt(5); if (testname.Trim().IndexOf("1%") == 0) testname = testname.Substring(testname.IndexOf("1%", 0) + 2); if (testname.Trim().IndexOf("2%") == 0) testname = testname.Substring(testname.IndexOf("2%", 0) + 2); LOGtests.Add(testname.Trim()); } } //WriteToExcel(@"C:\Users\uidw8018\Desktop\ICTCOMP.xlsx"); //FileStream myWriteStream = new FileStream(Path.GetFullPath(@"C:\Users\uidw8018\Desktop\Log" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".xls"), FileMode.Append, FileAccess.Write); //byte[] newLine = Encoding.Default.GetBytes(Environment.NewLine); //foreach (string writeline in tests) //{ // myWriteStream.Write(Encoding.ASCII.GetBytes(writeline.Trim()), 0, Encoding.ASCII.GetByteCount(writeline.Trim())); // myWriteStream.Write(newLine, 0, newLine.Length); //} //myWriteStream.Close(); StatusL.Text = "Log File Extraction Complete"; } else MessageBox.Show("Log file does not exists"); WriteToExcel(@"C:\Users\uidw8018\Desktop\ICTCOMP"+DateTime.Now.ToString("YYMMddHHmmss")+".xlsx"); } catch (Exception exp) { MessageBox.Show(exp.ToString()); } }