예제 #1
0
        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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        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
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        // 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);
        }
예제 #6
0
        //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
            }
        }
예제 #7
0
        //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;
        }
예제 #8
0
        //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;
        }