public void updateResultSheet(ResultSheet ResultSheet) { SMSContext sMSContext = new SMSContext(); sMSContext.Entry(ResultSheet).State = System.Data.Entity.EntityState.Modified; sMSContext.SaveChanges(); }
public void saveResultSheet(ResultSheet ResultSheet) { SMSContext sMSContext = new SMSContext(); sMSContext.ResultSheet.Add(ResultSheet); sMSContext.SaveChanges(); }
public ActionResult SaveResultSheet(int classID, int subID, int examID, string[] RollNumbers, int[] markslist) { try { for (int i = 0; i < RollNumbers.Length; i++) { string r = RollNumbers[i]; ResultSheet rs1 = db.ResultSheets.Where(m => m.Subject == subID && m.RollNumber == r && m.Results.FirstOrDefault().ExamID == examID).FirstOrDefault(); if (rs1 == null) { ResultSheet r123 = new ResultSheet { MarksObtained = markslist[i], RollNumber = RollNumbers[i], Subject = subID }; db.Results.Where(m => m.ExamID == examID).FirstOrDefault().ResultSheets.Add(r123); //db.ResultSheets.Add(r123); } else { db.ResultSheets.Where(m => m.Subject == subID && m.RollNumber == r && m.Results.FirstOrDefault().ExamID == examID).FirstOrDefault().MarksObtained = markslist[i]; } } db.SaveChanges(); int rID = db.Results.Where(m => m.ExamID == examID).First().Id; return(RedirectToAction("AddResult", new { resultID = rID })); } catch (Exception e) { int rID = db.Results.Where(m => m.ExamID == examID).First().Id; return(RedirectToAction("AddResult", new { resultID = rID })); } }
public static void ReadDictionaryFile() { string CurrentProjectPath = ResultSheet.CurrentProjectPath(); string Repositorypath = CurrentProjectPath + "Mercer.US.Ben.Automation" + Path.DirectorySeparatorChar + "Repository" + Path.DirectorySeparatorChar + "OR.txt"; Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (string line in File.ReadAllLines(Repositorypath)) { if ((!string.IsNullOrEmpty(line)) && (!line.StartsWith(";")) && (!line.StartsWith("#")) && (!line.StartsWith("'")) && (line.Contains('='))) { int index = line.IndexOf('='); string key = line.Substring(0, index).Trim(); string value = line.Substring(index + 1).Trim(); if ((value.StartsWith("\"") && value.EndsWith("\"")) || (value.StartsWith("'") && value.EndsWith("'"))) { value = value.Substring(1, value.Length - 2); } dictionary.Add(key, value); } } }
public ActionResult GeneratePdfPreview() { int studentId = Global.Id; ResultSheet aResultSheet = aStudentManager.GenerateResultForStudentId(studentId); //int id = (int)TempData["id"]; ViewBag.ResultSheet = aResultSheet; return(View()); }
public ResultSheet GenerateResultForStudentId(int studentId) { ResultSheet aResultSheet = new ResultSheet(); Query = "Select Name, RegNo, Email, DeptId From Student Where Id = '" + studentId + "' "; Command = new SqlCommand(Query, Connection); Connection.Open(); Reader = Command.ExecuteReader(); int deptId = 0; while (Reader.Read()) { aResultSheet.Name = Reader["Name"].ToString(); aResultSheet.RegNo = Reader["RegNo"].ToString(); aResultSheet.Email = Reader["Email"].ToString(); deptId = (int)Reader["DeptId"]; } Reader.Close(); Connection.Close(); Query = "Select Name From Department Where Id = '" + deptId + "'"; Command = new SqlCommand(Query, Connection); Connection.Open(); Reader = Command.ExecuteReader(); while (Reader.Read()) { aResultSheet.DeptName = Reader["Name"].ToString(); } Reader.Close(); Connection.Close(); Query = "Select * From CourseTakenByStudentView Where StudentId = '" + studentId + "' And Valid = 'true'"; Command = new SqlCommand(Query, Connection); Connection.Open(); Reader = Command.ExecuteReader(); while (Reader.Read()) { CourseResult aCourseResult = new CourseResult(); aCourseResult.CourseCode = Reader["CourseCode"].ToString(); aCourseResult.CourseName = Reader["CourseName"].ToString(); aCourseResult.Grade = Reader["Grade"].ToString(); aResultSheet.CourseResults.Add(aCourseResult); } Reader.Close(); Connection.Close(); return(aResultSheet); }
public ActionResult AddResult(FormCollection fc) { //string[] ids = fc["classid"].Split(','); string[] ids = fc["AssignmentMakrs"].Split(','); string[] roll = fc["rollno"].Split(','); string[] finall = fc["FinalTerm"].Split(','); string[] sessionid = fc["MidMarks"].Split(','); string[] clas = fc["classesID"].Split(','); string[] term = fc["TermsID"].Split(','); string[] ses = fc["SessionsID"].Split(','); string[] sec = fc["SectionID"].Split(','); string[] sub = fc["ID"].Split(','); int clases = Convert.ToInt32(clas[0]); int terms = Convert.ToInt32(term[0]); int sess = Convert.ToInt32(ses[0]); int subs = Convert.ToInt32(sub[0]); int secs = Convert.ToInt32(sub[0]); IEnumerable <Tuple <string, string, string> > result = ids .Zip(roll, (e1, e2) => new { e1, e2 }) .Zip(sessionid, (z1, e3) => Tuple.Create(z1.e1, z1.e2, e3)); foreach (var tuple in result) { ResultSheet resultSheet = new ResultSheet(); resultSheet.AssignmentMakrs = Convert.ToInt32(tuple.Item1); resultSheet.Studentid = Convert.ToInt32(tuple.Item2); resultSheet.MidMarks = Convert.ToInt32(tuple.Item3); resultSheet.TermsID = terms; resultSheet.classesID = clases; resultSheet.SectionID = secs; resultSheet.SessionsID = sess; resultSheet.FinalTerm = 10; resultSheet.Subjectid = subs; resultSheet.AddDetails = DateTime.Now; SMSContext sMSContext = new SMSContext(); sMSContext.ResultSheet.Add(resultSheet); sMSContext.SaveChanges(); } return(RedirectToAction("FindallStudentResults")); }
public ActionResult edit(FormCollection fc) { //string[] ids = fc["classid"].Split(','); string[] assimarks = fc["AssignmentMakrs"].Split(','); string[] rollno = fc["rollno"].Split(','); string[] finall = fc["FinalTerm"].Split(','); string[] midterm = fc["MidMarks"].Split(','); string[] id = fc["classid"].Split(','); string[] clas = fc["classesID"].Split(','); string[] term = fc["TermsID"].Split(','); string[] ses = fc["SessionsID"].Split(','); string[] sec = fc["SectionID"].Split(','); string[] sub = fc["ID"].Split(','); int clases = Convert.ToInt32(clas[0]); int terms = Convert.ToInt32(term[0]); int sess = Convert.ToInt32(ses[0]); int subs = Convert.ToInt32(sub[0]); int secs = Convert.ToInt32(sub[0]); int a = -1; Tuple <string[], string[], string[], string[]>[] statesData = { Tuple.Create(finall, assimarks, rollno, id) }; //IEnumerable<Tuple<string, string, string, string, string>> result = assimarks // .Zip(rollno, (e1, e2) => new { e1, e2 }) // .Zip(assimarks, (e4, e5) => new { e4, e5 }) // .Zip(finall, (z1, e5) => Tuple.Create(z1.e4,z1.e4,z1.e4,z1.e4)) var tuple = new Tuple <string[], string[], string[], string[]>(finall, assimarks, rollno, id); for (int i = 0; i < ses.Length; i++) { assimarks[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(Id => Convert.ToString((Id))).ToList(); id[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(Id => Convert.ToString((Id))).ToList(); finall[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(Id => Convert.ToString((Id))).ToList(); midterm[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(Id => Convert.ToString((Id))).ToList(); ResultSheet resultSheet = new ResultSheet(); resultSheet.AssignmentMakrs = Convert.ToDecimal(assimarks[i]); resultSheet.Studentid = Convert.ToInt32(rollno[i]); resultSheet.MidMarks = Convert.ToDecimal(midterm[i]); resultSheet.TermsID = terms; resultSheet.classesID = clases; resultSheet.SectionID = secs; resultSheet.SessionsID = sess; resultSheet.FinalTerm = Convert.ToDecimal(finall[i]); resultSheet.Subjectid = subs; resultSheet.ID = Convert.ToInt32(id[i]); resultSheet.AddDetails = DateTime.Now; SMSContext sMSContext = new SMSContext(); ResultSheetService.updateResultSheet(resultSheet); sMSContext.SaveChanges(); } return(RedirectToAction("FindallStudentResults")); }
public void RunTest(String TestType) { try { Logger.createLogFile(); ActualStartTime = DateTime.Now.ToString("hh:mm:ss tt", System.Globalization.DateTimeFormatInfo.InvariantInfo); CurrentProjectPath = ResultSheet.CurrentProjectPath(); OutputfilePath = ResultSheet.ResultFilePath_Name(); Email_Outlook.sendEMailThroughOUTLOOK(); ResultSheet.CreateExcelReport(OutputfilePath); BrowserDriverPath = CurrentProjectPath + "Mercer.US.Ben.Automation" + Path.DirectorySeparatorChar + "BrowserDrivers"; switch (TestType) { case "Smoke": ResourcePath = CurrentProjectPath + "Mercer.US.Ben.Automation" + Path.DirectorySeparatorChar + "Resources" + Path.DirectorySeparatorChar + "Smoke"; Logger.info("Framing Smoke test Rresource path :" + ResourcePath); break; case "Regression": ResourcePath = CurrentProjectPath + "Mercer.US.Ben.Automation" + Path.DirectorySeparatorChar + "Resources" + Path.DirectorySeparatorChar + "Regression"; Logger.info("Framing Regression test Resource path :" + ResourcePath); break; } fileName = ResourcePath + Path.DirectorySeparatorChar + "MODULES.xlsx"; Logger.info("Module sheet path is :" + fileName); // ModuleList for loading various module names List <string> ModuleList = new List <string>(); List <string> BrowserType = new List <string>(); { //open Modules Excel sheet Logger.info("Following Excel sheet loaded successfuly " + fileName); FileStream MasterExcel = new FileStream(fileName, FileMode.Open); Aspose.Cells.LoadOptions loadOptions = new Aspose.Cells.LoadOptions(LoadFormat.Xlsx); Workbook wb = new Workbook(MasterExcel, loadOptions); Worksheet ws = wb.Worksheets[0]; // Number of Rows in Module Sheet Row_count = ws.Cells.Rows.Count; Logger.info("Total number of Modules listed in the modul execution sheet" + Row_count); for (int i = 1; (i <= Row_count); i++) { if (((ws.Cells[i, 0]).StringValue).Equals("Y")) { //Getting Module names string strModuleName = (ws.Cells[i, 1]).StringValue; //strBrowserName = ; BrowserType.Add(((ws.Cells[i, 2]).StringValue)); Logger.info("Selected Browser name is : " + ((ws.Cells[i, 2]).StringValue)); Logger.info("Currently loadding module is : " + strModuleName); ModuleList.Add(strModuleName); } } } //For loop for Executing Various selected Modules for (int h = 0; h <= (ModuleList.Count) - 1; h++) { Sheet_Name = ModuleList[h]; string strCurrentDataSheetName = ResourcePath + Path.DirectorySeparatorChar + ModuleList[h] + ".xlsx"; Logger.info("The following test data sheet loaded successfuly" + strCurrentDataSheetName); List <string> Scenario_List = new List <string>(); List <string> ScenarioDescription_List = new List <string>(); { FileStream ModuleExcel = new FileStream(strCurrentDataSheetName, FileMode.Open); Aspose.Cells.LoadOptions loadOptions_1 = new Aspose.Cells.LoadOptions(LoadFormat.Xlsx); Workbook wb_1 = new Workbook(ModuleExcel, loadOptions_1); Worksheet ws_1 = wb_1.Worksheets[0]; int Row_count_1 = ws_1.Cells.Rows.Count; Logger.info(" Total number of scenarios to be executed as per Test Data sheet" + Row_count_1); //Loop for getting Scenario Names with Y for (int a = 1; (a <= Row_count_1); a++) { if (((ws_1.Cells[a, 0]).StringValue).Equals("Y")) { Scenario_List.Add((ws_1.Cells[a, 1]).StringValue); Logger.info("Current executable Scenario name :" + ((ws_1.Cells[a, 1]).StringValue)); ScenarioDescription_List.Add((ws_1.Cells[a, 2]).StringValue); Logger.info("The Scenario Description is:" + ((ws_1.Cells[a, 2]).StringValue)); } } // for loop for Iterating over Various Scenarios for (int s = 0; s <= (Scenario_List.Count) - 1; s++) { String value = Scenario_List[s]; Scinario_Name = ScenarioDescription_List[s]; Logger.info("Navigating to sheet and taking function name into Function_Name_List : " + value); // start the Browser invoke code //For opening Browser Logger.info("Launching Browser window"); //Get the browser type to be executed //browserconfig > Object containing browsersettings.config file values XDocument browserconfig = XDocument.Load(CurrentProjectPath + "Mercer.Us.Ben.Automation" + Path.DirectorySeparatorChar + "BrowserSettings.config"); Browser_Type = browserconfig.Root.Element("BrowserSelection").Element("Browser").Attribute("Type").Value; if (Browser_Type == null || Browser_Type == "") { Browser_Type = "InternetExplorer"; Logger.info("Default Browser Setting is not set in BrowserSettingConfig file so its taking Firefox as default browser"); } if (BrowserType[h] != null || BrowserType[h] != "") { Browser_Type = BrowserType[h]; } Logger.info("Current Module is execuing agains Browser as :" + Browser_Type); switch (Browser_Type) { case "Firefox": BrowserName = "Firefox"; //Attempt to start Firefox. Tries consumer Firefox first, then attempts ESR version. FirefoxBinary binary = new FirefoxBinary(browserconfig.Root.Element("BrowserDriver").Element("Firefox").Attribute("Path").Value); FirefoxProfile profile = new FirefoxProfile(); driver = new FirefoxDriver(binary, profile); ICapabilities cap = ((RemoteWebDriver)driver).Capabilities; String browserName = cap.BrowserName.ToString(); Console.WriteLine("*************" + browserName); string version = cap.Version.ToString(); Console.WriteLine("*************" + version); Logger.info("FireFox driver is loaded"); break; case "InternetExplorer": //driver = new InternetExplorerDriver(BrowserDriverPath); //Logger.info("IE driver is selected"); BrowserName = "IE"; var options = new InternetExplorerOptions() { EnsureCleanSession = Convert.ToBoolean(browserconfig.Root.Element("BrowserDriver") .Element("InternetExplorer").Attribute("EnsureCleanSession").Value), InitialBrowserUrl = browserconfig.Root.Element("BrowserDriver") .Element("InternetExplorer").Attribute("InitialBrowserUrl").Value, IntroduceInstabilityByIgnoringProtectedModeSettings = Convert.ToBoolean(browserconfig.Root .Element("BrowserDriver").Element("InternetExplorer").Attribute("IgnoreProtectedMode").Value) }; //Optional for Driver path---> browserconfig.Root.Element("BrowserDriver").Element("InternetExplorer").Attribute("Path").Value driver = new InternetExplorerDriver(BrowserDriverPath, options); Logger.info("IE driver is loaded"); break; case "Chrome": BrowserName = "Chrome"; Logger.info("Chrome driver is selected"); break; } //Navigating to sheet and taking function name into Function_Name_List Worksheet worksheet = wb_1.Worksheets[value]; { int Row_count_2 = worksheet.Cells.Rows.Count; Logger.info("Getting row count of Test methods to be executed sheet: " + Row_count_2); int col_Count_2 = worksheet.Cells.Columns.Count; Logger.info("Getting column count of Test methods to be executed sheet: " + col_Count_2); for (int j = 1; (j <= Row_count_2); j++) { if (((worksheet.Cells[j, 0]).StringValue).Equals("Y")) { //Getting functionm names for getting test data //for Clearing the values of Dictionary for Each iteration values.Clear(); FunctionName = (worksheet.Cells[j, 2]).StringValue; values.Add("Function_Name_Value", FunctionName); Logger.info("Current executing function name is : " + FunctionName); string ClassName = (worksheet.Cells[j, 1]).StringValue; values.Add("Class_Name", ClassName); Logger.info("Current executing class name is : " + ClassName); TestDescription = (worksheet.Cells[j, 3]).StringValue; Logger.info("Test scenario description is : " + TestDescription); for (int k = 7; k <= col_Count_2; k++) { string Test_Value = (worksheet.Cells[j, k]).StringValue; string Test_Data = (worksheet.Cells[j + 1, k]).StringValue; if (Test_Value == null || Test_Value == "") { Logger.info("Getting out from the scenario test data collection list"); break; } values.Add(Test_Value, Test_Data); Logger.info("The Parameter Name is : " + Test_Value + " and value is : " + Test_Data); string Exit_Test_Value = (worksheet.Cells[j, k + 1]).StringValue; if (Exit_Test_Value == null || Exit_Test_Value == "") { Logger.info("Getting out from the scenario execution list"); break; } } // end Browser invoke code string ClassNameValue = values["Class_Name"]; string MethodName = values["Function_Name_Value"]; Logger.info("the name of the class : " + ClassNameValue); Logger.info("the name of the Function or Method Name : " + MethodName); string TypeName = "Mercer.Us.Ben.Automation.Test_Methods.MBC." + ClassNameValue; Type type = Type.GetType(TypeName); // ConstructorInfo ctor = type.GetConstructor(new[] { typeof(IWebDriver) }); // object instance = ctor.Invoke(new object[] { driver }); object classInstance = Activator.CreateInstance(type, null); MethodInfo methodInfo = type.GetMethod(MethodName); ParameterInfo[] parameters = methodInfo.GetParameters(); //Navigate to Method //Reflection //result = (string)methodInfo.Invoke(instance, null); // methodInfo.Invoke(instance, null); Starttime = DateTime.Now.ToString("hh:mm:ss tt", System.Globalization.DateTimeFormatInfo.InvariantInfo); methodInfo.Invoke(classInstance, null); if (Constants.ApplicationLaunchFlag == false) { driver.Close(); break; } Logger.info(" Status of the current execution"); } j++;//loop increment for row } } } driver.Quit(); } } } catch (Exception e) { Console.WriteLine(e); Test.Result("Page should be loaded", " Waiting for page load/Failed to page load", "Failed"); Logger.error(e); } finally { ResultSheet.DesignChart(OutputfilePath, Passed, Failed, ActualStartTime, BrowserName); Email_Outlook.send_Report_EMailThroughOUTLOOK(); Console.WriteLine("Test Execution is Completed"); } }
private void CompletePaper() { UploadingPanel.Visibility = Visibility.Visible; //Animate the uploading panel to preview the spinner var da = new DoubleAnimation(1, TimeSpan.FromMilliseconds(500)); da.EasingFunction = new QuinticEase(); UploadingPanel.BeginAnimation(OpacityProperty, da); _recognizer.RecognizeAsyncCancel(); _recognizer.Dispose(); // Dispose the recognizer object //Start the uploading functionality var threadstart = new ThreadStart(() => { var result = Scholar.Class.PostMCQPaper(Context.previousPaper[0], Context.previousPaper[1], _answers, Properties.Settings.Default.scholarUsername, Properties.Settings.Default.scholarPassword); Application.Current.Dispatcher.Invoke(() => { //Do this in the user interface thread var da2 = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500)); da2.EasingFunction = new QuinticEase(); da2.Completed += (a, b) => { //Show the results ResultSheet.Visibility = Visibility.Visible; ResultSheet.BeginAnimation(OpacityProperty, da); PaperNameResults.Content = Context.currentPaper.name; var correct = 0; var incorrect = 0; var skipped = 0; for (int i = 0; i < _answers.Length; i++) { var given_answer = _answers[i]; var correct_answer = Context.currentPaper.questions[i].correct; if (given_answer == 0) { skipped++; } else { if (given_answer == correct_answer) { //Answer is correct correct++; } else { incorrect++; } } } //Set the numbers correct_count.Content = correct.ToString(); incorrect_count.Content = incorrect.ToString(); unanswered_count.Content = skipped.ToString(); //Set the event handlers OkayButton.Clicked = () => { _recognizer.RecognizeAsyncCancel(); _recognizer = null; ViewControllerConnector.PaperStarted = false; AISAHandler.Start(); ViewControllerConnector.Opaque(); Close(); }; _recognizer = new SpeechRecognitionEngine(); _recognizer.SetInputToDefaultAudioDevice(); _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices( new string[] { "Okay", "OK", "Close", "Exit" } )))); _recognizer.SpeechRecognized += (x, y) => { _recognizer.RecognizeAsyncCancel(); _recognizer = null; ViewControllerConnector.PaperStarted = false; AISAHandler.Start(); ViewControllerConnector.Opaque(); Close(); }; _recognizer.RecognizeAsync(); }; //Fade the uploading panel out UploadingPanel.BeginAnimation(OpacityProperty, da2); }); }); var thread = new Thread(threadstart); thread.Start(); }