public void Load_Option(string line, Exam_Board eb, string season, string series, string year, string syl_file, string path, int JCQ_Version) { //to load from line (from basedata file) to make a new option string component_file = "c" + syl_file.Substring(1, syl_file.Length - 1); string link_file = "l" + syl_file.Substring(1, syl_file.Length - 1); ExamBaseOption ebo1 = new ExamBaseOption(); ExamSyllabus syl = new ExamSyllabus(); string s = line.Substring(0, 2); if (s == "O5") { if (!ebo1.Load(line, JCQ_Version)) { return; } syl = Find_SyllabusID(ebo1.m_SyllabusCode, year, season, eb, path + syl_file); // will find or make if (syl == null) { return; } s = "INSERT INTO dbo.tbl_Exams_Options (SyllabusID ,OptionCode , OptionTitle, "; s += "OptionQualification, OptionLevel, OptionItem, OptionProcess, "; s += "QCAClassificationCode, QCAAccreditationNumber, OptionFee, OptionMaximumMark, YearCode, SeasonCode, SeriesIdentifier, Version )"; s += "VALUES ('" + syl.m_SyllabusId.ToString() + "' , '"; s += ebo1.m_OptionEntryCode + "' , '" + ebo1.m_Title + "' , '" + ebo1.m_Qualification + "' , '"; s += ebo1.m_Level + "' , '" + ebo1.m_Item + "' , '" + ebo1.m_Process + "' , '"; s += ebo1.m_QCACode + "' , '" + ebo1.m_QCANumber + "' , '"; if (ebo1.m_FeeValid) { s += ebo1.m_Fee.ToString(); } else { s += "-"; } s += "' , '" + ebo1.m_MaximiumMark + "' ,'"; s += year + "' , '" + season + "' , '" + series + "', '2' ) "; ExecuteSQL(s); Install_Components(ebo1.m_OptionEntryCode, path + link_file, path + component_file, eb, season, year); } }
public System.Collections.ArrayList ExamsOptionsFromBaseData(Exam_Board eb, string season, string year) { System.Collections.ArrayList temp = new System.Collections.ArrayList(); while (year.Length > 2) { year = year.Substring(1, year.Length - 1); } string search = "O" + season + "?" + year + "_" + eb.m_LegacyExamBdId + ".X??"; string[] filelist = System.IO.Directory.GetFiles(path, search); foreach (string f in filelist) { Stream myStream; string line; int JCQ_Version = 0; if ((myStream = File.Open(f, FileMode.Open)) != null) { using (StreamReader sr = new StreamReader(myStream)) { while ((line = sr.ReadLine()) != null) { if (line.Substring(0, 2) == "O1") { JCQ_Version = System.Convert.ToInt32(line.Substring(24, 2)); } if (line.Substring(0, 2) == "O5") { ExamBaseOption ebo1 = new ExamBaseOption(); if (ebo1.Load(line, JCQ_Version)) { ebo1.m_file_path = f.Substring(path.Length); temp.Add(ebo1); } } } } } } temp.Sort(); return(temp); }
protected void Button1_Click(object sender, EventArgs e) { //create table... List <ExamSyllabus> syllabuses = new List <ExamSyllabus>(); List <ExamComponent> components = new List <ExamComponent>(); List <ExamBaseOption> options = new List <ExamBaseOption>(); List <ExamLinkComponent> Links = new List <ExamLinkComponent>(); string s = TextBox1.Text; Label1.Text = ""; Label1.BackColor = System.Drawing.Color.White; string[] s1 = new string[20]; char[] c1 = new char[2]; char c2 = (char)0x09; c1[0] = c2; c1[1] = ','; string[] s2 = new string[1]; s2[0] = Environment.NewLine; string [] s3 = new string[10]; s1 = s.Split(s2, StringSplitOptions.RemoveEmptyEntries); int n = -1; bool correct = true; string errorstring = ""; foreach (string s5 in s1) { n++; if (n == 0) { //so this needs to be Subject Option Component CODE Date Length AM/PM s3 = s5.Split(c1); correct = (s3[0].ToUpper() == "SUBJECT") && (s3[1].ToUpper() == "OPTION") && (s3[2].ToUpper() == "COMPONENT"); correct = correct && (s3[3].ToUpper() == "CODE"); correct = correct && (s3[4].ToUpper() == "DATE") && (s3[5].ToUpper() == "LENGTH") && (s3[6].ToUpper() == "AM/PM"); } if (!correct) { errorstring = "Header Row incorrect; should be Subject Option Component Date Length AM/PM"; break; } if (n > 0) { s3 = s5.Split(c1); int k = 1; //so s3[0] has subject ExamSyllabus es1 = new ExamSyllabus(); es1.m_Syllabus_Title = s3[0]; es1.m_Syllabus_Code = s3[0].Substring(0, 2) + k.ToString(); while (es1.m_Syllabus_Code.Length < 6) { es1.m_Syllabus_Code += " "; } while (es1.m_Syllabus_Title.Length < 36) { es1.m_Syllabus_Title += " "; } //check code unique foreach (ExamSyllabus es in syllabuses) { if ((es.m_Syllabus_Code == es1.m_Syllabus_Code) && (es.m_Syllabus_Title != es1.m_Syllabus_Title)) { k++; es1.m_Syllabus_Code = s3[0].Substring(0, 2) + k.ToString(); while (es1.m_Syllabus_Code.Length < 6) { es1.m_Syllabus_Code += " "; } } } syllabuses.Add(es1); ExamBaseOption ebo1 = new ExamBaseOption(); ebo1.m_Title = s3[1]; k = 1; if (s3[1].Contains("[")) { //use defined code after [ int i1 = s3[1].IndexOf("["); int i2 = s3[1].IndexOf("]"); ebo1.m_OptionEntryCode = s3[1].Substring(i1 + 1, i2 - i1 - 1); ebo1.m_Title = s3[1].Substring(0, i1); } else { ebo1.m_OptionEntryCode = s3[1].Substring(0, 2) + k.ToString(); //check code unique foreach (ExamBaseOption ebo in options) { if ((ebo.m_OptionEntryCode == ebo1.m_OptionEntryCode) && (ebo.m_Title != ebo1.m_Title)) { k++; ebo1.m_OptionEntryCode = s3[1].Substring(0, 2) + k.ToString(); while (ebo1.m_OptionEntryCode.Length < 6) { ebo1.m_OptionEntryCode += " "; } } } } ebo1.m_SyllabusCode = es1.m_Syllabus_Code; while (ebo1.m_OptionEntryCode.Length < 6) { ebo1.m_OptionEntryCode += " "; } while (ebo1.m_Title.Length < 36) { ebo1.m_Title += " "; } options.Add(ebo1); ExamComponent ec1 = new ExamComponent(); k = 1; int t1 = 0; ec1.m_ComponentCode = s3[3]; ec1.m_ComponentTitle = s3[2]; ec1.m_Time = s3[5]; ec1.m_TimetableDate = new DateTime(); try { ec1.m_TimetableDate = System.Convert.ToDateTime(s3[4]); }catch { errorstring = "Time must be in format dd/mm/yyyy"; correct = false; break; } ec1.m_TimetableSession = s3[6]; try { t1 = Convert.ToInt16(s3[5]); } catch { errorstring = "Length must be an integer."; correct = false; break; } while (ec1.m_Time.Length < 3) { ec1.m_Time = "0" + ec1.m_Time; } while (ec1.m_ComponentCode.Length < 12) { ec1.m_ComponentCode += " "; } while (ec1.m_ComponentTitle.Length < 36) { ec1.m_ComponentTitle += " "; } //check code unique foreach (ExamComponent ec in components) { if ((ec.m_ComponentCode == ec1.m_ComponentCode) && (ec.m_ComponentTitle != ec1.m_ComponentTitle)) { k++; ec1.m_ComponentCode = s3[2].Substring(0, 2) + k.ToString(); while (ec1.m_ComponentCode.Length < 12) { ec1.m_ComponentCode += " "; } } } components.Add(ec1); ExamLinkComponent el0 = new ExamLinkComponent(); el0.m_ComponentCode = ec1.m_ComponentCode; el0.m_OptionCode = ebo1.m_OptionEntryCode; Links.Add(el0); TableRow r = new TableRow(); Table1.Rows.Add(r); TableCell cell1 = new TableCell(); cell1.Text = es1.m_Syllabus_Title; r.Cells.Add(cell1); TableCell cell2 = new TableCell(); cell2.Text = es1.m_Syllabus_Code; r.Cells.Add(cell2); TableCell cell3 = new TableCell(); cell3.Text = ebo1.m_Title; r.Cells.Add(cell3); TableCell cell4 = new TableCell(); cell4.Text = ebo1.m_OptionEntryCode; r.Cells.Add(cell4); TableCell cell5 = new TableCell(); cell5.Text = ec1.m_ComponentTitle; r.Cells.Add(cell5); TableCell cell6 = new TableCell(); cell6.Text = ec1.m_ComponentCode; r.Cells.Add(cell6); TableCell cell7 = new TableCell(); cell7.Text = ec1.m_TimetableDate.ToShortDateString(); r.Cells.Add(cell7); TableCell cell8 = new TableCell(); cell8.Text = ec1.m_Time.ToString(); r.Cells.Add(cell8); TableCell cell9 = new TableCell(); cell9.Text = ec1.m_TimetableSession; r.Cells.Add(cell9); } } if (correct) { Table1.Visible = true; Label1.Text = "Data Correctly Parsed....."; Button_Upload.Visible = true; ViewState["syllabuses"] = syllabuses; ViewState["components"] = components; ViewState["options"] = options; ViewState["Links"] = Links; } else { Label1.Text = errorstring; Label1.BackColor = System.Drawing.Color.Red; } }