Exemplo n.º 1
0
        /// <summary>
        /// 保存登陆用户票据
        /// </summary>
        /// <param name="key"></param>
        public void saveTicket(string key)
        {
            CacheLib.Cookie cookie = new CacheLib.Cookie();
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "auth", DateTime.Now, DateTime.Now.AddMinutes(60), false, key, FormsAuthentication.FormsCookiePath);

            string encTicket = FormsAuthentication.Encrypt(ticket);
            //清除老的票据
            cookie.Delete("auth");

            cookie.AddCookie("auth", encTicket);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取票据
        /// </summary>
        /// <returns></returns>
        public string getTicket()
        {
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string encTicket = cookie.GetCookie("auth");

            if (CommonLib.Common.Validate.IsNullString(encTicket) == "")
                return null;

            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(encTicket);

            return ticket.UserData;
        }
Exemplo n.º 3
0
        public ActionResult ExamMenu()
        {
            JxLib.UserExamController userExamController = new JxLib.UserExamController();
            JxLib.ExamController examController = new JxLib.ExamController();

            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string user_id = cookie.GetCookie("user_id");

            System.Collections.Hashtable item = userExamController.getMySequenceExamLog(user_id);
            int count = examController.getAll().Count;

            ViewData["count"] = count;

            if (item == null)
                ViewData["exam_id"] = "1";
            else
                ViewData["exam_id"] = item["ExamID"].ToString();

            ViewData["title"] = "科目一考试练习";

            return View();
        }
Exemplo n.º 4
0
        public void Save()
        {
            CacheLib.Cache cache = new CacheLib.Cache();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string key = cache.Add<DataTable>("codes", this.Codes);

            cookie.AddCookie("codes", key);
        }
Exemplo n.º 5
0
        public void Load()
        {
            CacheLib.Cache cache = new CacheLib.Cache();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string key = cookie.GetCookie("codes");

            this._Codes = cache.Get<DataTable>(key);
        }
Exemplo n.º 6
0
        public ActionResult StudentEnterSave()
        {
            JxLib.StudentController studentController = new JxLib.StudentController();
            DatabaseLib.Tools tools = new DatabaseLib.Tools();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string strParam = Request.Form.ToString();

            System.Collections.Hashtable data = tools.paramToData(strParam);

            string user_id = cookie.GetCookie("user_id");
            //深大驾校测试代码
            data.Add("SchoolID", "1");
            //data.Add("StudentID", "00001");
            data.Add("StudentID", user_id);

            data.Add("EnterDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            studentController.save(data);

            studentController.saveEnter(data);

            if (studentController.Result)
            {
                return RedirectToRoute("enter-success");
            }
            else
            {
                return RedirectToRoute("home");
            }
        }
Exemplo n.º 7
0
        public ActionResult SimulateExamStart()
        {
            JxLib.ExamController examController = new JxLib.ExamController();
            JxLib.UserExamController userExamController = new JxLib.UserExamController();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            System.Collections.Hashtable data = new System.Collections.Hashtable();
            string user_id = cookie.GetCookie("user_id");
            //深大驾校测试代码
            //data.Add("SchoolID", "1");
            //data.Add("StudentID", "00001");
            data.Add("StudentID", user_id);
            //插入数据,考试结束
            string strExamID = userExamController.ExamStart(data);

            List<System.Collections.Hashtable> list = examController.getTestExam();

            System.Text.StringBuilder strExams = new System.Text.StringBuilder();

            int index = 1;

            foreach (System.Collections.Hashtable item in list)
            {
                Models.ExamA exam_a = null;
                Models.ExamB exam_b = null;

                if (CommonLib.Common.Validate.IsNullString(item["OptionC"]) == "")
                {
                    Models.Answer answerA = null;

                    if (item["Answer"].ToString().IndexOf("A") > -1)
                    {
                        answerA = new Models.Answer
                        {
                            title = item["OptionA"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerA = new Models.Answer
                        {
                            title = item["OptionA"].ToString(),
                            correct = false
                        };

                    }

                    string strAnswerA = Newtonsoft.Json.JsonConvert.SerializeObject(answerA);

                    Models.Answer answerB = null;

                    if (item["Answer"].ToString().IndexOf("B") > -1)
                    {
                        answerB = new Models.Answer
                        {
                            title = item["OptionB"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerB = new Models.Answer
                        {
                            title = item["OptionB"].ToString(),
                            correct = false
                        };

                    }

                    Models.AnswersA answers = new Models.AnswersA
                    {
                        A = answerA,
                        B = answerB
                    };

                    exam_a = new Models.ExamA
                    {
                        no = index.ToString(),
                        exam_id = item["ExamID"].ToString(),
                        total = this.EXAMCOUNT.ToString(),
                        title = item["ExamText"].ToString(),
                        img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]),
                        video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]),
                        answers = answers
                    };

                    if (index > 1)
                        strExams.Append(",");

                    strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_a));
                }
                else
                {
                    Models.Answer answerA = null;

                    if (item["Answer"].ToString().IndexOf("A") > -1)
                    {
                        answerA = new Models.Answer
                        {
                            title = item["OptionA"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerA = new Models.Answer
                        {
                            title = item["OptionA"].ToString(),
                            correct = false
                        };

                    }

                    Models.Answer answerB = null;

                    if (item["Answer"].ToString().IndexOf("B") > -1)
                    {
                        answerB = new Models.Answer
                        {
                            title = item["OptionB"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerB = new Models.Answer
                        {
                            title = item["OptionB"].ToString(),
                            correct = false
                        };

                    }

                    Models.Answer answerC = null;

                    if (item["Answer"].ToString().IndexOf("C") > -1)
                    {
                        answerC = new Models.Answer
                        {
                            title = item["OptionC"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerC = new Models.Answer
                        {
                            title = item["OptionC"].ToString(),
                            correct = false
                        };

                    }

                    Models.Answer answerD = null;

                    if (item["Answer"].ToString().IndexOf("D") > -1)
                    {
                        answerD = new Models.Answer
                        {
                            title = item["OptionD"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerD = new Models.Answer
                        {
                            title = item["OptionD"].ToString(),
                            correct = false
                        };

                    }

                    Models.AnswersB answers = new Models.AnswersB
                    {
                        A = answerA,
                        B = answerB,
                        C = answerC,
                        D = answerD
                    };

                    exam_b = new Models.ExamB
                    {
                        no = index.ToString(),
                        exam_id = item["ExamID"].ToString(),
                        total = this.EXAMCOUNT.ToString(),
                        title = item["ExamText"].ToString(),
                        img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]),
                        video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]),
                        answers = answers
                    };

                    if (index > 1)
                        strExams.Append(",");

                    strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_b));
                }

                index++;
            }

            string tmp = strExams.ToString().Replace("[", "{").Replace("]", "}");

            ViewData["exams"] = tmp;
            ViewData["exam_id"] = strExamID;
            ViewData["title"] = "开始考试";

            return View();
        }
Exemplo n.º 8
0
        public ActionResult SequenceExam()
        {
            JxLib.ExamController examController = new JxLib.ExamController();

            List<System.Collections.Hashtable> list = examController.getAll();

            //System.Text.StringBuilder strExams = new System.Text.StringBuilder();

            //int index = 1;

            //foreach (System.Collections.Hashtable item in list)
            //{
            //    Models.ExamA exam_a = null;
            //    Models.ExamB exam_b = null;

            //    if (CommonLib.Common.Validate.IsNullString(item["OptionC"]) == "")
            //    {
            //        Models.Answer answerA = null;

            //        if (item["Answer"].ToString().IndexOf("A") > -1)
            //        {
            //            answerA = new Models.Answer
            //            {
            //                title = item["OptionA"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerA = new Models.Answer
            //            {
            //                title = item["OptionA"].ToString(),
            //                correct = false
            //            };

            //        }

            //        string strAnswerA = Newtonsoft.Json.JsonConvert.SerializeObject(answerA);

            //        Models.Answer answerB = null;

            //        if (item["Answer"].ToString().IndexOf("B") > -1)
            //        {
            //            answerB = new Models.Answer
            //            {
            //                title = item["OptionB"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerB = new Models.Answer
            //            {
            //                title = item["OptionB"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.AnswersA answers = new Models.AnswersA
            //        {
            //            A = answerA,
            //            B = answerB
            //        };

            //        exam_a = new Models.ExamA
            //        {
            //            no = index.ToString(),
            //            exam_id = item["ExamID"].ToString(),
            //            total = list.Count.ToString(),
            //            title = item["ExamText"].ToString(),
            //            img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]),
            //            video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]),
            //            answers = answers
            //        };

            //        if (index > 1)
            //            strExams.Append(",");

            //        strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_a));
            //    }
            //    else
            //    {
            //        Models.Answer answerA = null;

            //        if (item["Answer"].ToString().IndexOf("A") > -1)
            //        {
            //            answerA = new Models.Answer
            //            {
            //                title = item["OptionA"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerA = new Models.Answer
            //            {
            //                title = item["OptionA"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.Answer answerB = null;

            //        if (item["Answer"].ToString().IndexOf("B") > -1)
            //        {
            //            answerB = new Models.Answer
            //            {
            //                title = item["OptionB"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerB = new Models.Answer
            //            {
            //                title = item["OptionB"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.Answer answerC = null;

            //        if (item["Answer"].ToString().IndexOf("C") > -1)
            //        {
            //            answerC = new Models.Answer
            //            {
            //                title = item["OptionC"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerC = new Models.Answer
            //            {
            //                title = item["OptionC"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.Answer answerD = null;

            //        if (item["Answer"].ToString().IndexOf("D") > -1)
            //        {
            //            answerD = new Models.Answer
            //            {
            //                title = item["OptionD"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerD = new Models.Answer
            //            {
            //                title = item["OptionD"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.AnswersB answers = new Models.AnswersB
            //        {
            //            A = answerA,
            //            B = answerB,
            //            C = answerC,
            //            D = answerD
            //        };

            //        exam_b = new Models.ExamB
            //        {
            //            no = index.ToString(),
            //            exam_id = item["ExamID"].ToString(),
            //            total = list.Count.ToString(),
            //            title = item["ExamText"].ToString(),
            //            img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]),
            //            video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]),
            //            answers = answers
            //        };

            //        if (index > 1)
            //            strExams.Append(",");

            //        strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_b));
            //    }

            //    index++;
            //}

            //string tmp = strExams.ToString().Replace("[", "{").Replace("]", "}");

            //ViewData["exams"] = tmp;

            CacheLib.Cookie cookie = new CacheLib.Cookie();
            JxLib.UserExamController userExamController = new JxLib.UserExamController();

            //实际运行代码
            string user_id = cookie.GetCookie("user_id");
            //开发测试代码
            //string user_id = "00001";

            //cookie.AddCookie("user_id", "00001");

            System.Collections.Hashtable sequenceExamLog = userExamController.getMySequenceExamLog(user_id);

            string exam_id = "1";

            if (sequenceExamLog != null)
            {
                exam_id = sequenceExamLog["ExamID"].ToString();
            }

            ViewData["index"] = exam_id;
            ViewData["count"] = list.Count;
            ViewData["title"] = "训练习题";

            return View();
        }
Exemplo n.º 9
0
        public ActionResult RegUser()
        {
            string code = this.HttpContext.Request.QueryString["code"];
            string tmp_web_url = this.HttpContext.Request.QueryString["web_url"];

            string web_url = System.Web.HttpUtility.UrlDecode(tmp_web_url);

            if (CommonLib.Common.Validate.IsNullString(web_url) != "")
            {
                if (web_url == "http://wx.yune-jia.com/")
                {
                    web_url = "/";
                }
                else
                {
                    web_url = web_url.Replace("http://wx.yune-jia.com/", "/");
                }
            }
            else
            {
                web_url = "/";
            }

            string open_id = this.getOpenId(code);

            Models.Student stu = this.getUserInfo(open_id);

            string student_id = this.addStudent(stu);

            if (student_id == null)
                ViewData["data"] = "用户注册失败!";
            else
            {
                JxLib.StudentController studentController = new JxLib.StudentController();
                JxLib.CouponController couponController = new JxLib.CouponController();

                System.Collections.Hashtable item = studentController.load(student_id);

                //System.Collections.Hashtable coupon = new System.Collections.Hashtable();

                //coupon.Add("CouponText", "98元学车体验券");
                //coupon.Add("Amount", "98");
                //coupon.Add("Password", "");
                //coupon.Add("StudentID", student_id);
                //coupon.Add("CreateAt", DateTime.Now.ToString("yyyy-MM-dd"));
                //coupon.Add("ModifyAt", DateTime.Now.ToString("yyyy-MM-dd"));

                //couponController.add(coupon);

                if (item["SchoolID"].ToString() == "")
                {
                    System.Collections.Hashtable coupon1 = new System.Collections.Hashtable();

                    coupon1.Add("CouponText", "300元学车券");
                    coupon1.Add("Amount", "300");
                    coupon1.Add("Password", couponController.getPassword());
                    coupon1.Add("StudentID", student_id);
                    coupon1.Add("CreateAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    coupon1.Add("ModifyAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                    couponController.add(coupon1);
                }

                CacheLib.Cookie cookie = new CacheLib.Cookie();

                cookie.AddCookie("user_id", student_id);

                ViewData["data"] = student_id;
                ViewData["url"] = web_url;
            }

            return View();
        }
Exemplo n.º 10
0
        public ActionResult MyIndex()
        {
            JxLib.StudentController studentController = new JxLib.StudentController();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string user_id = cookie.GetCookie("user_id");

            ViewData["data"] = studentController.load(user_id);
            ViewData["user_id"] = user_id;
            ViewData["title"] = "我的首页";

            return View();
        }
Exemplo n.º 11
0
        public ActionResult MyExam()
        {
            JxLib.UserExamController userExamController = new JxLib.UserExamController();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string user_id = cookie.GetCookie("user_id");

            List<System.Collections.Hashtable> list = userExamController.getMyExam(user_id);

            ViewData["data"] = list;

            int ok_count = 0;

            foreach (System.Collections.Hashtable item in list)
            {
                string score = CommonLib.Common.Validate.IsNullString(item["Score"]);

                if (score == "")
                    continue;

                if (Int32.Parse(score) > this.PASSSCORE)
                {
                    ok_count++;
                }
            }

            ViewData["need_count"] = 3 - ok_count;
            ViewData["ok_count"] = ok_count;
            ViewData["title"] = "我的成绩";

            return View();
        }
Exemplo n.º 12
0
        public ActionResult MyCoupon()
        {
            JxLib.CouponController couponController = new JxLib.CouponController();
            DatabaseLib.Tools tools = new DatabaseLib.Tools();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string user_id = cookie.GetCookie("user_id");

            List<System.Collections.Hashtable> list = couponController.getByStuentId(user_id);

            ViewData["data"] = list;

            ViewData["title"] = "我的优惠卷";

            return View();
        }