private void UpdateDbWithResult(Dictionary <string, int> allScores, List <int> totalQuestions, Dictionary <string, double> allPercents) // Request.QueryString["userName"] & Request.QueryString["typeofTest"] { DatabaseConnection db = new DatabaseConnection(); string userName = Request.QueryString["userName"]; //string typeOfTest = Request.QueryString["typeofTest"]; string id = db.GetUserId("stare"); //will be userName later string typeOfTest = "LST"; //will be typeOfTest later string totalScore = String.Format("{0}/{1}", allScores["Totalt"], totalQuestions[0]); db.UpdateAfterTestIsComplete(id, DateTime.Today, totalScore, IsTestPassed(allPercents), typeOfTest); }
/// <summary> /// Updated to only get latest test from one specific user. /// </summary> /// <returns></returns> private XDocument GetUserXmlFromDb() { DatabaseConnection db = new DatabaseConnection(); string userName = lblUserName.Text; string id = db.GetUserId(userName); List <string> userXmls = db.GetUserLatestTest(id); XDocument xDoc = XDocument.Parse(userXmls[0]); XDeclaration xDec = xDoc.Declaration; //for some reason postgres changes encoding to utf-16, changing it back! xDec.Encoding = "utf-8"; string fileName = GetUserXmlFileName(); xDoc.Save(Server.MapPath(fileName)); return(xDoc); }
private void SendUserXmlToDb() //Request.QueryString["userName"] { DatabaseConnection db = new DatabaseConnection(); string userName = Request.QueryString["userName"]; string id = db.GetUserId("stare"); //will be userName later, not "stare" List <string> userXmls = db.RetrieveXmlDocument(id, DateTime.Today); if (userXmls.Count < 1) { string fileName = GetUserXmlFileName(); XDocument xDoc = XDocument.Load(Server.MapPath(fileName)); db.SaveUserXml(id, xDoc, DateTime.Today); } else { //person has already done a test today } }
private XDocument GetUserXmlFromDb() //Request.QueryString["userName"] { DatabaseConnection db = new DatabaseConnection(); string userName = Request.QueryString["userName"]; string id = db.GetUserId(userName); List <string> userXmls = db.RetrieveXmlDocument(id, DateTime.Today); XDocument xDoc = XDocument.Parse(userXmls[0]); XDeclaration xDec = xDoc.Declaration; //for some reason postgres changes encoding to utf-16, changing it back! xDec.Encoding = "utf-8"; string fileName = GetUserXmlFileName(); xDoc.Save(Server.MapPath(fileName)); return(xDoc); }
// Request.QueryString["userName"] & Request.QueryString["typeofTest"] private void UpdateDbWithResult(Dictionary<string, int> allScores, List<int> totalQuestions, Dictionary<string, double> allPercents) { DatabaseConnection db = new DatabaseConnection(); string userName = Request.QueryString["userName"]; string id = db.GetUserId(userName); string typeOfTest = Request.QueryString["typeofTest"]; //string typeOfTest = "LST"; //will be typeOfTest later string totalScore = String.Format("{0}/{1}", allScores["Totalt"], totalQuestions[0]); db.UpdateAfterTestIsComplete(id, DateTime.Today, totalScore, IsTestPassed(allPercents), typeOfTest); }
//Request.QueryString["userName"] private void SendUserXmlToDb() { DatabaseConnection db = new DatabaseConnection(); string userName = Request.QueryString["userName"]; string id = db.GetUserId(userName); List<string> userXmls = db.RetrieveXmlDocument(id, DateTime.Today); if (userXmls.Count < 1) { string fileName = GetUserXmlFileName(); XDocument xDoc = XDocument.Load(Server.MapPath(fileName)); db.SaveUserXml(id, xDoc, DateTime.Today); } else { //person has already done a test today } }
//Request.QueryString["userName"] private XDocument GetUserXmlFromDb() { DatabaseConnection db = new DatabaseConnection(); string userName = Request.QueryString["userName"]; string id = db.GetUserId(userName); List<string> userXmls = db.RetrieveXmlDocument(id, DateTime.Today); XDocument xDoc = XDocument.Parse(userXmls[0]); XDeclaration xDec = xDoc.Declaration; //for some reason postgres changes encoding to utf-16, changing it back! xDec.Encoding = "utf-8"; string fileName = GetUserXmlFileName(); xDoc.Save(Server.MapPath(fileName)); return xDoc; }
//Session["userName"] /// <summary> /// Updated to only get latest test from one specific user. /// </summary> /// <returns></returns> private XDocument GetUserXmlFromDb() { DatabaseConnection db = new DatabaseConnection(); string userName = Session["userName"].ToString(); string id = db.GetUserId(userName); List<string> userXmls = db.GetUserLatestTest(id); XDocument xDoc = XDocument.Parse(userXmls[0]); XDeclaration xDec = xDoc.Declaration; //for some reason postgres changes encoding to utf-16, changing it back! xDec.Encoding = "utf-8"; string fileName = GetUserXmlFileName(); xDoc.Save(Server.MapPath(fileName)); return xDoc; }