示例#1
0
        /// <summary>
        /// /Doctor/GetUserList
        /// </summary>
        /// <returns></returns>
        public ActionResult GetUserList()
        {
            string        connString = "Data Source=127.0.0.1;Initial Catalog=BlogSystem;Persist Security Info=True;User ID=sa;PWD=st";
            SqlliteHelp   database   = /*new SqlDatabase(connString)*/ CommonController.database;;
            var           dt         = database.QueryTable("select * from t_ybsUser");
            StringBuilder re         = new StringBuilder();

            if (dt == null || dt.Rows.Count < 1)
            {
                return(null);
            }
            re.Append("[");
            bool isStart = true;

            foreach (DataRow row in dt.Rows)
            {
                string uid = "";
                try
                {
                    uid = row["uid"].ToString();
                }
                catch { }
                re.Append(isStart ? "{" : ",{");
                isStart = false;
                re.Append(string.Format("\"uid\":\"{0}\"", uid));
                re.Append("}");
            }
            re.Append("]");
            return(Content(re.ToString()));
        }
示例#2
0
        public ImageDevide()
        {
            InitializeComponent();
            string databaseFileName = System.Windows.Forms.Application.StartupPath + "\\..\\..\\SqliteFile\\imageInfo.db";

            m_database = new SqlliteHelp(databaseFileName);
        }
示例#3
0
        public ActionResult GetAnsByQuestionList()
        {
            string err = "{'result':'0'}";

            try
            {
                string      connString = "Data Source=127.0.0.1;Initial Catalog=BlogSystem;Persist Security Info=True;User ID=sa;PWD=st";
                SqlliteHelp database   = /*new SqlDatabase(connString)*/ CommonController.database;;
                HttpHelper  http       = Session["http"] as HttpHelper;

                string        nameList = Request.Form["nameList"];
                string[]      nList    = nameList.Split(',');
                StringBuilder result   = new StringBuilder();
                bool          isStart  = true;
                result.Append("[");
                foreach (string name in nList)
                {
                    string ans = "数据库无答案";
                    try
                    {
                        DataTable dt = database.QueryTable("select * from t_answer where name = '" + name + "'");
                        if (dt == null || dt.Rows.Count < 1)
                        {
                            throw new Exception();
                        }
                        var row = dt.Rows[0];
                        ans = row["ans"].ToString();
                    }
                    catch {
                    }
                    result.Append(isStart?"{":",{");
                    isStart = false;
                    result.Append("\"name\":\"" + name + "\",");
                    result.Append("\"ans\":\"" + ans + "\"");
                    result.Append("}");
                }
                result.Append("]");

                return(Content(result.ToString()));
            }
            catch (Exception ex)
            {
                return(Content(err));
            }
        }
示例#4
0
 /// <summary>
 /// /Doctor/DownAnswer
 /// </summary>
 /// <returns></returns>
 public ActionResult DownAnswer()
 {
     try
     {
         string      connString = "Data Source=127.0.0.1;Initial Catalog=BlogSystem;Persist Security Info=True;User ID=sa;PWD=st";
         SqlliteHelp database   = /*new SqlDatabase(connString)*/ CommonController.database;;
         DataTable   dt         = database.QueryTable("select * from t_question ");
         if (dt == null || dt.Rows.Count < 1)
         {
             return(null);
         }
         IWorkbook wb = new XSSFWorkbook();
         new OfficeHelper().ImportToWorkbook(dt, ref wb);
         string target = System.AppDomain.CurrentDomain.BaseDirectory + "Files\\"
                         + Guid.NewGuid().ToString() + ".xlsx";
         FileStream fs = null;
         try
         {
             using (fs = new FileStream(target, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite))
             {
                 wb.Write(fs);
             }
         }
         catch (Exception ex)
         {
         }
         finally
         {
             if (fs != null)
             {
                 fs.Close();
             }
         }
         return(File(target, "application/xls"));
     }
     catch
     {
         return(null);
     }
 }
示例#5
0
        public ActionResult Login()
        {
            string      connString = "Data Source=127.0.0.1;Initial Catalog=BlogSystem;Persist Security Info=True;User ID=sa;PWD=st";
            SqlliteHelp database   = CommonController.database;;
            /*new SqlDatabase(connString)*/

            string    err = "{\"result\":\"0\"}";
            string    uid = Request.Form["uid"];
            string    pwd = Request.Form["pwd"];
            string    str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            DataTable dts = null;

            try
            {
                dts = database.QueryTable("select * from t_ybsUser where uid = '" + uid + "'");
            }
            catch (Exception ex) {
            }
            try
            {
                pwd = dts.Rows[0]["pwd"].ToString();
            }
            catch (Exception ex) { }

            string password = pwd;

            if (string.IsNullOrWhiteSpace(uid) || string.IsNullOrWhiteSpace(pwd))
            {
                return(Content(err));
            }
            string     loginUrl = "http://api.yiboshi.com/api/study/student/login";
            HttpHelper http     = new HttpHelper();

            pwd = EncriptHelper.MD5Encrypt32(pwd);
            //pwd = "a008aa83f9f52700237f9ecb93159a5b";
            //      "a08aa83f9f5270237f9ecb93159a5b"
            Dictionary <string, string> paramList = new Dictionary <string, string>()
            {
                { "username", uid },
                { "password", pwd }
                //"54ea5aec6ebb71a07ece56aae5c7deaa" 391122
                //e10adc3949ba59abbe56e057f20f883e 391122
                // 54ea5aec6ebb71a07ece56aae5c7deaa
            };

            try
            {
                string result = http.SendPost(loginUrl, paramList);
                Session["http"] = http;
                //登陆成功,用户名入库
                if (result.Contains("studentInfo"))
                {
                    string    sql = "select * from t_ybsUser where uid = '{0}'";
                    DataTable dt  = database.QueryTable(string.Format(sql, uid));
                    if (dt.Rows.Count > 0)
                    {
                        sql = "update t_ybsUser set pwd = '{0}' where uid = '{1}' ";
                        int reInt = database.ExecuteSql(string.Format(sql, password, uid));
                    }
                    else
                    {
                        sql = "insert into t_ybsUser (uid,pwd) values('{0}','{1}')";
                        int reInt = database.ExecuteSql(string.Format(sql, uid, password));
                    }
                }
                return(Content(result));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }
示例#6
0
        public ActionResult PassExam()
        {
            string err = "{\"result\":\"0\"}";

            try
            {
                string      connString = "Data Source=127.0.0.1;Initial Catalog=BlogSystem;Persist Security Info=True;User ID=sa;PWD=st";
                SqlliteHelp database   = /*new SqlDatabase(connString)*/ CommonController.database;



                int count;
                if (!int.TryParse(Request.Form["count"], out count))
                {
                    return(Content(err));
                }
                string     submitUtl = "http://api.yiboshi.com/api/WebApp/commitCoursePracticeScore";
                HttpHelper http      = Session["http"] as HttpHelper;
                List <Dictionary <string, string> > scoreList = new List <Dictionary <string, string> >();
                int    success = 0, fail = 0;
                string tid = Request.Form["tid"];
                string uid = Request.Form["uid"];

                StringBuilder ansSb = new StringBuilder();
                string        target = @"C:\Users\wyb\Desktop\秋秋\" + Guid.NewGuid() + ".txt";

                for (int i = 0; i < count; i++)
                {
                    string pid           = Request.Form["pid" + i];
                    string cid           = Request.Form["cid" + i];
                    string courseFieldId = Request.Form["courseFieldId" + i];
                    string result        = http.SendGet(submitUtl, new Dictionary <string, string>()
                    {
                        { "trainingId", tid },
                        { "projectId", pid },
                        { "userId", uid },
                        { "courseId", cid },
                        { "score", 100 + "" },
                        { "versionId", "3.1" },
                    });
                    //提取答案
                    string ans = http.SendGet("http://examapi.yiboshi.com/course/practices/" +
                                              courseFieldId + "?callback=P");
                    int ss = ans.IndexOf('{');
                    try
                    {
                        string temp     = ans.Substring(ss, ans.Length - 2 - ss);
                        var    ansDic   = JSONHelper.JsonToDictionary(temp);
                        var    dataList = ansDic["data"] as ArrayList;
                        var    dl       = ansDic["data"] as ArrayList;
                        foreach (object item in dataList)
                        {
                            var itemDic  = item as Dictionary <string, object>;
                            var ana      = itemDic["ana"];
                            var answer   = itemDic["ans"];
                            var qid      = itemDic["qid"];
                            var stem     = itemDic["stem"];
                            var optsList = itemDic["opts"] as ArrayList;
                            ansSb.Append(stem + ":");
                            ansSb.Append(answer + "----");
                            string[] ansNameList = new string[5];
                            int      ansIndex    = 0;
                            foreach (var opt in optsList)
                            {
                                var optDic  = opt as Dictionary <string, object>;
                                var selects = optDic["opt"];
                                var isans   = optDic["isAns"];
                                var ctnt    = optDic["ctnt"];
                                var optid   = optDic["id"];

                                ansSb.Append(selects + ":" + ctnt + ",");
                                ansNameList[ansIndex++] = ctnt.ToString();
                            }
                            string sql   = @"
                            delete from t_question where
                            name = '{0}';
                            insert into t_question 
                            ([name],[ans],[A],[B],[C],[D],[E],[qid],[ana]) values
                            ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}');";
                            int    reInt = database.ExecuteSql(string.Format(sql,
                                                                             stem, answer, ansNameList[0], ansNameList[1],
                                                                             ansNameList[2], ansNameList[3], ansNameList[4],
                                                                             qid, ana));
                            ansSb.Append("\r\n");
                            //
                            DataTable dt = database.QueryTable
                                               ("select * from t_answer where name = '" + stem + "'");
                            if (dt.Rows.Count < 1)
                            {
                                int r = database.Execute(
                                    "INSERT INTO[t_answer]([name],[ans])VALUES('" + stem + "','" + answer + "')");
                            }
                        }
                    }
                    catch { }



                    if (result.Contains("1"))
                    {
                        success++;
                    }
                    else
                    {
                        fail++;
                    }
                }

                StringBuilder sb = new StringBuilder();
                sb.Append("{\"result\":\"1\",\"success\":\"" + success + "\",\"fail\":\"" + fail + "\"}");
                return(Content(sb.ToString()));
            }
            catch (Exception ex)
            {
                return(Content(err));
            }
        }
示例#7
0
        public ActionResult TestExam()
        {
            string      connString = "Data Source=127.0.0.1;Initial Catalog=BlogSystem;Persist Security Info=True;User ID=sa;PWD=st";
            SqlliteHelp database   = /*new SqlDatabase(connString)*/ CommonController.database;;

            database = CommonController.database;
            HttpHelper http = Session["http"] as HttpHelper;
            string     uid  = Request.Form["uid"];
            string     url  = "http://api.yiboshi.com/api/study/student/usercenter/validateUserCreditBindingTerm"
                              + "?trainingIds=363-0&userId=185313";
            string s1 = http.SendGet(url, new Dictionary <string, string>());

            url = "http://api.yiboshi.com/api/study/student/getServerNowTime";
            string s2 = http.SendGet(url, new Dictionary <string, string>());

            url = "http://api.yiboshi.com/api/study/student/validateTrainingExam?trainingStatus=363-0&userId=185313";
            string s3 = http.SendGet(url, new Dictionary <string, string>());

            url = "http://api.yiboshi.com/api/study/public/getBeginExamUrl?userId=185313&examId=2949";
            string s4 = http.SendGet(url, new Dictionary <string, string>());

            url = "http://api.yiboshi.com/api/study/student/usercenter/exam?userId=185313&page=1&pageSize=10&examState=&bindType=2&trainingId=&examName=&psort=0";
            string s5 = http.SendGet(url, new Dictionary <string, string>());

            url = "http://online.yiboshi.com/online/api/user/login/oauth2?turl=http%3A%2F%2Fonline.yiboshi.com%2Fonline%2Fbyks%2FexamNotice.html&eurl=http%3A%2F%2Fwww.yiboshi.com%2FMyExam&ts=1507815738147&from=usercenter&fp=2C6981DCF3CDE429F87A3EF9D19DD055&userId=185313&examId=2949";
            string s6 = http.SendGet(url, new Dictionary <string, string>());

            url = "http://online.yiboshi.com/online/api/user/login/oauth2?turl=http%3A%2F%2Fonline.yiboshi.com%2Fonline%2Fbyks%2FexamNotice.html&eurl=http%3A%2F%2Fwww.yiboshi.com%2FMyExam&ts=1507815738147&from=usercenter&fp=2C6981DCF3CDE429F87A3EF9D19DD055&userId=185313&examId=2949";

            url = s4;
            string s8 = http.SendGet(url, new Dictionary <string, string>());

            url = "http://online.yiboshi.com/online/api/exam/getExamInfo";
            string result = http.SendPost(url, new Dictionary <string, string>());

            url = "http://online.yiboshi.com/online/api/exam/getPaper";//获取考试信息
            string s9 = http.SendPost(url, new Dictionary <string, string>());

            var           dic         = JSONHelper.JsonToDictionary(s9);
            var           examid      = dic["examId"].ToString();
            var           exampagerid = dic["examPaperId"].ToString();
            var           qlist       = dic["examQuestionVOList"] as ArrayList;
            StringBuilder asb         = new StringBuilder();

            asb.Append("{");
            bool isStart = true;
            int  index   = 1;

            foreach (var item in qlist)
            {
                asb.Append(isStart ? "" : ",");
                isStart = false;
                var       itemDic = item as Dictionary <string, object>;
                var       name    = itemDic["htmlContent"];
                DataTable dt      = database.QueryTable("select * from t_answer where name ='" + name + "'");
                var       answer  = dt.Rows[0]["ans"].ToString();
                asb.Append("\"" + index + "\":\"" + answer + "\"");
                index++;
            }


            asb.Append("}");



            url = "http://online.yiboshi.com/online/api/student/submitPaper";
            Dictionary <string, string> para = new Dictionary <string, string>();

            para.Add("mouseoutNumber", "2");
            para.Add("mouseoutTypes", "blur,resize");
            para.Add("examId", examid);
            para.Add("examPaperId", exampagerid);
            para.Add("studentId", uid);
            para.Add("userAnswers", asb.ToString());

            para.Add("notsureIds", "");

            return(Content(result));
        }
示例#8
0
        public ActionResult PassExamById()
        {
            string err = "{'result':'0'}";

            try
            {
                string      connString     = "Data Source=127.0.0.1;Initial Catalog=BlogSystem;Persist Security Info=True;User ID=sa;PWD=st";
                SqlliteHelp database       = /*new SqlDatabase(connString)*/ CommonController.database;;
                HttpHelper  http           = Session["http"] as HttpHelper;
                string      examId         = Request.Form["examid"];
                string      trainingStatus = Request.Form["trainingStatus"];
                string      userid         = Request.Form["userid"];
                string      trainId        = Request.Form["trainid"];


                string url = "http://api.yiboshi.com/api/study/student/usercenter/validateUserCreditBindingTerm"
                             + "?trainingIds=" + trainId + "&userId=" + userid + "";
                string s1 = http.SendGet(url, new Dictionary <string, string>());

                url = "http://api.yiboshi.com/api/study/student/getServerNowTime";
                string s2 = http.SendGet(url, new Dictionary <string, string>());

                url = "http://api.yiboshi.com/api/study/student/validateTrainingExam?trainingStatus="
                      + trainingStatus
                      + "&userId=" + userid + "";
                string s3 = http.SendGet(url, new Dictionary <string, string>());

                url = "http://api.yiboshi.com/api/study/public/getBeginExamUrl?userId=" + userid + "&examId=" + examId + "";
                string s4 = http.SendGet(url, new Dictionary <string, string>());

                url = "http://api.yiboshi.com/api/study/student/usercenter/exam"
                      + "?userId=" + userid + "&page=1&pageSize=10&examState=&bindType=2&trainingId=&examName=&psort=0";
                string s5 = http.SendGet(url, new Dictionary <string, string>());

                url = "http://online.yiboshi.com/online/api/user/login/oauth2?"
                      + "turl=http%3A%2F%2Fonline.yiboshi.com%2Fonline%2Fbyks%2FexamNotice.html"
                      + "&eurl=http%3A%2F%2Fwww.yiboshi.com%2FMyExam&ts=1507815738147"
                      + "&from=usercenter&fp=2C6981DCF3CDE429F87A3EF9D19DD055"
                      + "&userId=" + userid + "&examId=" + examId;
                //string s6 = http.SendGet(url, new Dictionary<string, string>());

                url = s4;
                string s8 = http.SendGet(url, new Dictionary <string, string>());

                url = "http://online.yiboshi.com/online/api/exam/getExamInfo";
                string result = http.SendPost(url, new Dictionary <string, string>());

                url = "http://online.yiboshi.com/online/api/student/startExam";
                string s10 = http.SendPost(url, new Dictionary <string, string>());

                url = "http://online.yiboshi.com/online/api/exam/getPaper";//获取考试信息
                string s9       = http.SendPost(url, new Dictionary <string, string>());
                var    dataInfo = JSONHelper.JsonToDictionary(s9);
                var    data     = dataInfo["data"] as Dictionary <string, object>;
                var    qlist    = data["examQuestionVOList"] as ArrayList;

                StringBuilder answerSb = new StringBuilder();
                answerSb.Append("{");
                bool   isStart = true;
                int    index   = 1;
                Random r       = new Random();
                var    ansList = "A,B,C,D,E".Split(',');
                foreach (var ques in qlist)
                {
                    answerSb.Append(isStart?"":",");
                    isStart = false;
                    var qDic = ques as Dictionary <string, object>;
                    var name = "默认题目";
                    int k    = r.Next(ansList.Length);
                    var ans  = ansList[k];
                    try
                    {
                        name = qDic["htmlContent"].ToString();
                        DataTable dt = database.QueryTable("select * from t_answer where name = '" + name + "'");
                        if (dt == null)
                        {
                            name = name.Substring(2, name.Length - 2);
                            dt   = database.QueryTable(
                                "select * from t_answer where name like '%" + name + "%'");
                        }
                        ans = dt.Rows[0]["ans"].ToString();
                    }
                    catch (Exception ex)
                    {
                    }
                    answerSb.Append("\"" + index + "\":\"" + ans + "\"");
                    index++;
                }
                answerSb.Append("}");
                string examPaperId = "";
                var    meta        = dataInfo["meta"] as Dictionary <string, object>;
                var    user        = meta["user"] as Dictionary <string, object>;
                examPaperId = user["currentExamPaperId"].ToString();

                url = "http://online.yiboshi.com/online/api/student/submitPaper";
                Dictionary <string, string> subDic = new Dictionary <string, string>()
                {
                    { "mouseoutNumber", "2" },
                    { "mouseoutTypes", "blur,resize" },
                    { "examId", examId },
                    { "examPaperId", examPaperId },
                    { "studentId", userid },
                    { "userAnswers", answerSb.ToString() },
                    { "notsureIds", "" }
                };
                string s11 = "";
                s11 = http.SendPost(url, subDic);
                return(Content(s11));
            }
            catch (Exception ex)
            {
                return(Content(err));
            }
        }