コード例 #1
0
        public void FeedbackInfo()              //查询全部题目的函数
        {
            HttpCookie cookie   = HttpContext.Current.Request.Cookies["UserInfoRemember"];
            String     username = cookie["username"].ToString();
            var        query    = new BmobQuery();

            query.WhereEqualTo("tId", username);
            var future = Bmob.FindTaskAsync <Feedback>("Feedback", query);

            try
            {
                feedbackList = future.Result.results;
                foreach (var f in feedbackList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Feedback_View feedback_view = new Feedback_View();
                    feedback_view.objectId = f.objectId;
                    feedback_view.username = f.username;
                    feedback_view.nickname = f.nickname;
                    feedback_view.totalNum = f.totalNum.Get();
                    feedback_view.rightNum = f.rightNum.Get();
                    feedback_view.unitId   = f.unitId.Get();
                    feedback_view.classId  = f.classId;
                    fList.Add(feedback_view);
                }
            }
            catch
            {
            }
        }
コード例 #2
0
        public object GetQueryNumOfCourse(String classId)
        {
            var query = new BmobQuery();

            query.Limit(300);
            query.WhereEqualTo("classId", classId);
            var        query1   = new BmobQuery();
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     Id       = cookie1["CourseId"];
            int        courseId = int.Parse(Id);

            query1.WhereEqualTo("courseId", courseId);
            query = query.And(query1);
            query.OrderByDescending("totalNum");
            var future = Bmob.FindTaskAsync <Feedback>("Feedback", query);

            try
            {
                feedbackList = future.Result.results;
                foreach (var f in feedbackList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Feedback_View feedback_view = new Feedback_View();
                    feedback_view.objectId = f.objectId;
                    feedback_view.username = f.username;
                    feedback_view.nickname = f.nickname;
                    feedback_view.totalNum = f.totalNum.Get();
                    fList.Add(feedback_view);
                }
                return(ResultToJson.toJson(fList));
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #3
0
        [HttpGet]                       //定义访问方式(Post或Get方法)
        public object GetKnowledge()    //返回数据的函数,如果是Get方法则方法名为Get开头,若是Post则使用Post开头。
        {
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     id       = cookie1["CourseId"];
            int        courseId = int.Parse(id);
            var        query    = new BmobQuery();

            query.WhereEqualTo("courseId", courseId);
            query.OrderBy("id");
            var future = Bmob.FindTaskAsync <Knowledge>("Knowledge", query);

            try
            {
                knowledgeList = future.Result.results;
                foreach (var k in knowledgeList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Knowledge_View knowledge_view = new Knowledge_View();
                    knowledge_view.id       = k.id.Get();
                    knowledge_view.name     = k.name;
                    knowledge_view.courseId = k.courseId.Get();
                    knowledge_view.unitId   = k.unitId.Get();

                    kList.Add(knowledge_view);
                }
            }catch
            {
            }
            return(ResultToJson.toJson(kList));      //返回数据需要json格式
        }
コード例 #4
0
        /// <summary>
        ///     下载代理数据
        /// </summary>
        /// <returns></returns>
        private ProxyItems DownloadProxyList(int sinceId, int count)
        {
            //创建一个BmobQuery查询对象
            BmobQuery query = new BmobQuery();

            //查询playerName的值为bmob的记录
            query.WhereEqualTo("isvip", false);
            query.Limit(count);
            query.Skip(sinceId);

            ProxyItems items = new ProxyItems();

            var future = Bmob.FindTaskAsync <ProxyServers>(ProxyServers.TABLE_NAME, query);

            //对返回结果进行处理
            var list = future.Result.results;

            if (list != null && list.Count > 0)
            {
                items.items = new List <ProxyServer>();
                foreach (var model in list)
                {
                    var proxy = model.Get();
                    items.items.Add(proxy);
                }
            }
            else
            {
                items = null;
            }


            return(items);
        }
コード例 #5
0
        public object GetUpdateExam(int id, int questionId, int currentQuestionId)
        {
            String result             = "";
            String questionIds        = questionId.ToString();
            String currentQuestionIds = currentQuestionId.ToString();
            var    query = new BmobQuery();

            query.WhereEqualTo("id", id);
            var future = Bmob.FindTaskAsync <Examination>("Examination", query);

            try
            {
                String objectId     = future.Result.results[0].objectId;
                String questionList = future.Result.results[0].questionList;
                examination.questionList = questionList.Replace(currentQuestionIds, questionIds);
                var future1 = Bmob.UpdateTaskAsync("Examination", objectId, examination);
                try
                {
                    String a = future1.Result.updatedAt;
                    result = examination.questionList;
                }
                catch
                {
                    result = "fail";
                }
            }
            catch
            {
            }
            return(result);
        }
コード例 #6
0
        public object GetDeleteQuestion(int id, int courseId)
        {
            //两个条件的查询
            var query1 = new BmobQuery();

            query1.WhereEqualTo("id", id);
            var query2 = new BmobQuery();

            query1.WhereEqualTo("courseId", courseId);
            //And操作
            query1 = query1.And(query2);
            var future = Bmob.FindTaskAsync <Question>("Question", query1);

            try
            {
                var    a        = future.Result;
                String objectId = future.Result.results[0].objectId;
                var    future1  = Bmob.DeleteTaskAsync("Question", objectId);
                return(future1.Result.msg);
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #7
0
        [HttpGet]                       //定义访问方式(Post或Get方法)
        public object Get()             //返回数据的函数,如果是Get方法则方法名为Get开头,若是Post则使用Post开头。
        {
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     id       = cookie1["CourseId"];
            int        courseId = int.Parse(id);
            var        query    = new BmobQuery();

            query.Limit(300);
            query.WhereEqualTo("courseId", courseId);
            query.OrderBy("id");
            var future = Bmob.FindTaskAsync <Examination>("Examination", query);

            try
            {
                examinationList = future.Result.results;
                foreach (var e in examinationList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Examination_View examination_View = new Examination_View();
                    examination_View.objectId     = e.objectId;
                    examination_View.name         = e.name;
                    examination_View.questionList = e.questionList;
                    examination_View.id           = e.id.Get();
                    examination_View.difficulty   = e.difficulty.Get();
                    examination_View.courseId     = e.courseId.Get();
                    eList.Add(examination_View);
                }
            }
            catch
            {
            }
            return(ResultToJson.toJson(eList));      //返回数据需要json格式
        }
コード例 #8
0
        [HttpGet]                                                      //定义访问方式(Post或Get方法)
        public object GetUpdateUnit(int id, int courseId, String name) //返回数据的函数,如果是Get方法则方法名为Get开头,若是Post则使用Post开头。
        {
            String result = "";
            var    query  = new BmobQuery();

            query.WhereEqualTo("courseId", courseId);
            var query1 = new BmobQuery();

            query1.WhereEqualTo("id", id);
            query.And(query1);
            var future = Bmob.FindTaskAsync <Unit>("Unit", query);

            try
            {
                String objectId = future.Result.results[0].objectId;
                Unit   k        = new BmobModel.Unit();
                k      = future.Result.results[0];
                k.name = name;
                var future1 = Bmob.UpdateTaskAsync("Unit", objectId, k);
                try
                {
                    result = future1.Result.updatedAt;
                }
                catch
                {
                    result = "修改失败";
                }
            }
            catch
            {
                result = "修改失败";
            }
            return(result);
        }
コード例 #9
0
        public object GetSelectedUnit()
        {
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     id       = cookie1["CourseId"];
            int        courseId = int.Parse(id);
            var        query    = new BmobQuery();

            query.WhereEqualTo("courseId", courseId);
            var future = Bmob.FindTaskAsync <Unit>("Unit", query);

            try
            {
                unitList = future.Result.results;
                foreach (var u in unitList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Unit_View unit_view = new Unit_View();
                    unit_view.id       = u.id.Get();
                    unit_view.name     = u.name;
                    unit_view.courseId = u.courseId.Get();
                    uList.Add(unit_view);
                }
                return(ResultToJson.toJson(uList));
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #10
0
        public object PostFile([FromBody] Course_View cl)
        {
            String a        = "";
            String objectId = "";
            Course course   = new Course();

            course.id         = BmobInput.Parse <BmobInt>(cl.id);
            course.name       = cl.name;
            course.program    = cl.program;
            course.experiment = cl.experiment;
            course.time       = cl.time;
            var query = new BmobQuery();

            query.WhereEqualTo("id", course.id);
            var f = Bmob.FindTaskAsync <Course>("Course", query);

            try
            {
                objectId = f.Result.results[0].objectId;
                var future = Bmob.UpdateTaskAsync("Course", objectId, course);
                a = future.Result.updatedAt;
            }
            catch
            {
                a = "失败";
            }
            return(a);
        }
コード例 #11
0
        public object GetExaminationDetails(int id)
        {
            var query = new BmobQuery();

            query.WhereEqualTo("id", id);
            var future = Bmob.FindTaskAsync <Examination>("Examination", query);

            examinationList = future.Result.results;
            try
            {
                examinationList = future.Result.results;
                foreach (var e in examinationList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Examination_View examination_View = new Examination_View();
                    examination_View.objectId     = e.objectId;
                    examination_View.name         = e.name;
                    examination_View.questionList = e.questionList;
                    examination_View.id           = e.id.Get();
                    examination_View.difficulty   = e.difficulty.Get();
                    examination_View.courseId     = e.courseId.Get();
                    //if(examination_View.questionList != "")
                    //{
                    //    string[] results = examination_View.questionList.Split(new[] { ';' });
                    //    examination_View.examQuestion = Array.ConvertAll<string, int>(results, s => int.Parse(s));
                    //}
                    eList.Add(examination_View);
                }
            }
            catch
            {
            }
            return(ResultToJson.toJson(eList));      //返回数据需要json格式
        }
コード例 #12
0
        public object GetSelectedKnowledge(int unitId)
        {
            String     objectId = "";
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     id       = cookie1["CourseId"];
            int        courseId = int.Parse(id);
            var        query    = new BmobQuery();

            query.WhereEqualTo("courseId", courseId);
            var f = Bmob.FindTaskAsync <Knowledge>("Knowledge", query);

            try
            {
                query.WhereEqualTo("unitId", unitId);
                var future = Bmob.FindTaskAsync <Knowledge>("Knowledge", query);
                knowledgeList = future.Result.results;
                foreach (var k in knowledgeList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    objectId = f.Result.results[0].objectId;
                    Knowledge_View knowledge_view = new Knowledge_View();
                    knowledge_view.id       = k.id.Get();
                    knowledge_view.name     = k.name;
                    knowledge_view.courseId = k.courseId.Get();
                    knowledge_view.unitId   = k.unitId.Get();
                    kList.Add(knowledge_view);
                }
                return(ResultToJson.toJson(kList));
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #13
0
        [HttpGet]                                              //定义访问方式(Post或Get方法)
        public object GetDeleteKnowledge(int id, int courseId) //返回数据的函数,如果是Get方法则方法名为Get开头,若是Post则使用Post开头。
        {
            String result = "";
            var    query  = new BmobQuery();

            query.WhereEqualTo("courseId", courseId);
            var query1 = new BmobQuery();

            query1.WhereEqualTo("id", id);
            query.And(query1);
            var future = Bmob.FindTaskAsync <Knowledge>("Knowledge", query);

            try
            {
                String objectId = future.Result.results[0].objectId;
                var    future1  = Bmob.DeleteTaskAsync("Knowledge", objectId);
                try
                {
                    result = future1.Result.msg;
                }catch
                {
                    result = "删除失败";
                }
            }
            catch
            {
                result = "删除失败";
            }
            return(result);
        }
コード例 #14
0
        public object GetClassInfo()
        {
            HttpCookie cookie   = HttpContext.Current.Request.Cookies["UserInfoRemember"];
            String     username = cookie["username"].ToString();
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     id       = cookie1["CourseId"];
            int        courseId = int.Parse(id);
            var        query    = new BmobQuery();

            query.WhereEqualTo("tId", username);
            var q1 = new BmobQuery();

            q1.WhereEqualTo("courseId", courseId);
            query.And(q1);
            var future = Bmob.FindTaskAsync <Class>("Class", query);

            try
            {
                classList = future.Result.results;
                return(ResultToJson.toJson(classList));
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #15
0
        private void findAllData_Click(object sender, EventArgs e)
        {
            //查找表中的全部数据(默认最多返回10条数据)
            var future = Bmob.FindTaskAsync <GameObject>(TABLE_NAME, new BmobQuery());

            FinishedCallback(future.Result);

            FormStatusLabel.Text = "查找全部数据成功";
        }
コード例 #16
0
        public object Getselect()
        {
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     id       = cookie1["CourseId"];
            int        courseId = int.Parse(id);
            var        query    = new BmobQuery();

            query.WhereEqualTo("id", courseId);
            var future = Bmob.FindTaskAsync <Course>("Course", query);

            try
            {
                courseList = future.Result.results;
                foreach (var c in courseList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Course_View course_view = new Course_View();
                    course_view.id   = c.id.Get();
                    course_view.name = c.name;
                    if (c.time != null)
                    {
                        course_view.times = "查看教学日历";
                        course_view.timeu = c.time.url;
                    }
                    else
                    {
                        course_view.times = "暂无教学日历";
                        course_view.timeu = "";
                    }
                    if (c.program != null)
                    {
                        course_view.programs = "查看课程大纲";
                        course_view.programu = c.program.url;
                    }
                    else
                    {
                        course_view.programs = "暂无课程大纲";
                        course_view.programu = "";
                    }
                    if (c.experiment != null)
                    {
                        course_view.experiments = "查看实验大纲";
                        course_view.experimentu = c.experiment.url;
                    }
                    else
                    {
                        course_view.experiments = "暂无实验大纲";
                        course_view.experimentu = "";
                    }
                    cList.Add(course_view);
                }
                return(ResultToJson.toJson(cList));
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #17
0
        public void FindTest()
        {
            var query = new BmobQuery();

            query.Limit(1);
            var future = Bmob.FindTaskAsync <GameObject>(TABLENAME, query);

            FinishedCallback(future.Result, null);
        }
コード例 #18
0
        public void FindByWhereContainedInTest()
        {
            var query = new BmobQuery();

            query.WhereContainedIn("jo", 10, 30);
            var future = Bmob.FindTaskAsync <GameObject>(TABLENAME, query);

            FinishedCallback(future.Result, null);
        }
コード例 #19
0
        public void FindWithPointerInTest()
        {
            var query = new BmobQuery();

            query.WhereEqualTo("objectId", "33f58cdcc6");
            query.Include("user");
            var future = Bmob.FindTaskAsync <GameObject>(TABLENAME, query);

            FinishedCallback(future.Result, null);
        }
コード例 #20
0
        public object PostUpdateQuestion([FromBody] List <Question_View> questionsInfo)
        {
            String result = "";
            int    count  = 0;
            int    length = questionsInfo.Count;

            for (int i = 0; i < questionsInfo.Count; i++)
            {
                Question question = new Question();
                question.objectId    = questionsInfo[i].objectId;
                question.id          = questionsInfo[i].id;
                question.question    = questionsInfo[i].question;
                question.a           = questionsInfo[i].a;
                question.b           = questionsInfo[i].b;
                question.c           = questionsInfo[i].c;
                question.d           = questionsInfo[i].d;
                question.a           = questionsInfo[i].a;
                question.answer      = questionsInfo[i].answer;
                question.analysis    = questionsInfo[i].analysis;
                question.courseId    = questionsInfo[i].courseId;
                question.unitId      = questionsInfo[i].unitId;
                question.knowledgeId = questionsInfo[i].knowledgeId;
                question.difficulty  = questionsInfo[i].difficulty;
                question.totalNum    = questionsInfo[i].totalNum;
                question.rightNum    = questionsInfo[i].rightNum;
                questionList.Add(question);
            }

            for (int i = 0; i < length; i++)
            {
                var query1 = new BmobQuery();
                query1.WhereEqualTo("id", questionList[i].id);
                var query2 = new BmobQuery();
                query1.WhereEqualTo("courseId", questionList[i].courseId);
                //And操作
                query1 = query1.And(query2);
                var    future   = Bmob.FindTaskAsync <Question>("Question", query1);
                String objectId = future.Result.results[0].objectId;
                var    future1  = Bmob.UpdateTaskAsync("Question", objectId, questionList[i]);
                try
                {
                    String a = future1.Result.updatedAt;
                    count++;
                    if (count == length)
                    {
                        result = "success";
                    }
                }
                catch
                {
                    result = "fail";
                }
            }
            return(result);
        }
コード例 #21
0
        public void ACLQueryTest()
        {
            Object result = Bmob.LoginTaskAsync("winse", "winse").Result;

            Console.WriteLine(BmobUser.CurrentUser);

            var query  = new BmobQuery();
            var future = Bmob.FindTaskAsync <GameObject>(TABLENAME, query);

            FinishedCallback(future.Result, null);
        }
コード例 #22
0
        public object GetDeleteUnit(int courseId, int id)
        {
            String result = "";
            var    query  = new BmobQuery();

            query.WhereEqualTo("courseId", courseId);
            var query1 = new BmobQuery();

            query1.WhereEqualTo("id", id);
            query1.And(query);
            var future = Bmob.FindTaskAsync <Unit>("Unit", query1);

            try
            {
                String objectId = future.Result.results[0].objectId;
                var    future1  = Bmob.DeleteTaskAsync("Unit", objectId);
                try
                {
                    var query2 = new BmobQuery();
                    query2.WhereEqualTo("unitId", id);
                    query2.And(query);
                    var future2 = Bmob.FindTaskAsync <Knowledge>("Knowledge", query2);
                    try
                    {
                        int length = future2.Result.results.Count;
                        for (int i = 0; i < length; i++)
                        {
                            String objectid = future2.Result.results[i].objectId;
                            var    future3  = Bmob.DeleteTaskAsync("Knowledge", objectid);
                            try
                            {
                                result = future1.Result.msg;
                            }
                            catch
                            {
                                result = "删除失败";
                            }
                        }
                    }catch
                    {
                        result = "删除失败";
                    }
                }catch
                {
                    result = "删除失败";
                }
            }
            catch
            {
                result = "删除失败";
            }
            return(result);
        }
コード例 #23
0
        public object GetSelectedQuestion(int unitId, String knowledgeId, int difficulty)
        {
            var query = new BmobQuery();

            query.Limit(300);
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     Id       = cookie1["CourseId"];
            int        courseId = int.Parse(Id);

            query.WhereEqualTo("courseId", courseId);
            var query1 = new BmobQuery();

            query1.WhereEqualTo("unitId", unitId);
            var query2 = new BmobQuery();

            query2.WhereEqualTo("knowledgeId", knowledgeId);
            var query3 = new BmobQuery();

            query3.WhereEqualTo("difficulty", difficulty);
            query2 = query2.And(query3);
            query1 = query1.And(query2);
            query  = query.And(query1);
            var future = Bmob.FindTaskAsync <Question>("Question", query);

            try
            {
                questionList = future.Result.results;
                foreach (var q in questionList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Question_View question_view = new Question_View();
                    question_view.id          = q.id.Get();
                    question_view.difficulty  = q.difficulty.Get();
                    question_view.totalNum    = q.totalNum.Get();
                    question_view.rightNum    = q.rightNum.Get();
                    question_view.question    = q.question;
                    question_view.a           = q.a;
                    question_view.b           = q.b;
                    question_view.c           = q.c;
                    question_view.d           = q.d;
                    question_view.answer      = q.answer;
                    question_view.analysis    = q.analysis;
                    question_view.courseId    = q.courseId.Get();
                    question_view.unitId      = q.unitId.Get();
                    question_view.knowledgeId = q.knowledgeId;
                    qList.Add(question_view);
                }
                return(ResultToJson.toJson(qList));
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #24
0
        private void findAllData_Click(object sender, EventArgs e)
        {
            //查找表中的全部数据(默认最多返回10条数据)
            var query = new BmobQuery();

            query.WhereContainedIn <string>("playerName", "123");
            var future = Bmob.FindTaskAsync <GameObject>(TABLE_NAME, query);

            FinishedCallback(future.Result, resultText);

            FormStatusLabel.Text = "查找全部数据成功";
        }
コード例 #25
0
        [HttpGet]                      //定义访问方式(Post或Get方法)
        public object Get()            //返回数据的函数,如果是Get方法则方法名为Get开头,若是Post则使用Post开头。
        {
            var        query    = new BmobQuery();
            HttpCookie cookie   = HttpContext.Current.Request.Cookies["UserInfoRemember"];
            String     username = cookie["username"].ToString();

            query.WhereEqualTo("tId", username);
            query.Limit(300);
            var future = Bmob.FindTaskAsync <Course>("Course", query);

            courseList = future.Result.results;
            foreach (var c in courseList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
            {
                Course_View course_view = new Course_View();
                course_view.id   = c.id.Get();
                course_view.name = c.name;
                if (c.time != null)
                {
                    course_view.times = "查看教学日历";
                    course_view.timeu = c.time.url;
                }
                else
                {
                    course_view.times = "暂无教学日历";
                    course_view.timeu = "";
                }
                if (c.program != null)
                {
                    course_view.programs = "查看课程大纲";
                    course_view.programu = c.program.url;
                }
                else
                {
                    course_view.programs = "暂无课程大纲";
                    course_view.programu = "";
                }
                if (c.experiment != null)
                {
                    course_view.experiments = "查看实验大纲";
                    course_view.experimentu = c.experiment.url;
                }
                else
                {
                    course_view.experiments = "暂无实验大纲";
                    course_view.experimentu = "";
                }
                cList.Add(course_view);
            }
            return(ResultToJson.toJson(cList));    //返回数据需要json格式
        }
コード例 #26
0
        /// <summary>
        ///     新增或插入数据
        /// </summary>
        /// <param name="proxy"></param>
        /// <returns></returns>
        public void AddOrUpdateProxy(ProxyServer proxy)
        {
            var result = string.Empty;

            //创建一个BmobQuery查询对象
            BmobQuery query = new BmobQuery();

            //查询playerName的值为bmob的记录
            query.WhereEqualTo("proxy", proxy.proxy).And().WhereEqualTo("port", proxy.port);

            var          futrue = Bmob.FindTaskAsync <ProxyServers>(ProxyServers.TABLE_NAME, query);
            ProxyServers proxyServer;

            if (futrue.Result == null || futrue.Result.results == null || futrue.Result.results.Count == 0)
            {
                proxyServer = new ProxyServers();
                proxyServer.Set(proxy);
                if (BmobUser.CurrentUser != null)
                {
                    proxyServer.user = BmobUser.CurrentUser;
                }
                var createResult = Bmob.CreateTaskAsync(proxyServer);
            }
            else
            {
                proxyServer = futrue.Result.results.FirstOrDefault();
                proxyServer.Set(proxy);
                if (proxyServer.status.Get() == 0)
                {
                    proxyServer.failedcount = proxyServer.failedcount.Get() + 1;
                }
                if (BmobUser.CurrentUser != null)
                {
                    proxyServer.user = BmobUser.CurrentUser;
                }

                if (proxy.failedcount > 5) //失败次数大于5次删除云端
                {
                    Bmob.DeleteTaskAsync(ProxyServers.TABLE_NAME, proxyServer.objectId);
                }
                else
                {
                    var updateResult = Bmob.UpdateTaskAsync(ProxyServers.TABLE_NAME, proxyServer.objectId, proxyServer);
                }
            }
        }
コード例 #27
0
        public object GetQueryFeedback(String classId, int unitId)
        {
            var query = new BmobQuery();

            query.Limit(300);
            query.WhereEqualTo("classId", classId);
            var        query1   = new BmobQuery();
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     Id       = cookie1["CourseId"];
            int        courseId = int.Parse(Id);

            query1.WhereEqualTo("courseId", courseId);
            var query2 = new BmobQuery();

            query2.WhereEqualTo("unitId", unitId);
            query1 = query1.And(query2);
            query  = query.And(query1);
            //query.OrderByDescending("rightNum");
            var future = Bmob.FindTaskAsync <Feedback>("Feedback", query);

            try
            {
                feedbackList = future.Result.results;
                foreach (var f in feedbackList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Feedback_View feedback_view = new Feedback_View();
                    feedback_view.objectId = f.objectId;
                    feedback_view.username = f.username;
                    feedback_view.nickname = f.nickname;
                    feedback_view.totalNum = f.totalNum.Get();
                    feedback_view.rightNum = f.rightNum.Get();
                    if (feedback_view.totalNum != 0)
                    {
                        feedback_view.accuracy = 100 * feedback_view.rightNum / feedback_view.totalNum;
                    }
                    fList.Add(feedback_view);
                }
                List <Feedback_View> feedbackSortList = new List <Feedback_View>();
                feedbackSortList = fList.OrderByDescending(s => s.accuracy).ToList();
                return(ResultToJson.toJson(feedbackSortList));
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #28
0
        public object GetStudentById(String classId)
        {
            var query = new BmobQuery();

            query.WhereEqualTo("classId", classId);
            var future = Bmob.FindTaskAsync <User>("_User", query);

            try
            {
                userList = future.Result.results;
                return(ResultToJson.toJson(userList));
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #29
0
        public object GetDeleteExamination(int id)
        {
            var query = new BmobQuery();

            query.WhereEqualTo("id", id);
            var future = Bmob.FindTaskAsync <Examination>("Examination", query);

            try
            {
                String objectId = future.Result.results[0].objectId;
                var    future1  = Bmob.DeleteTaskAsync("Examination", objectId);
                return(future1.Result.msg);
            }
            catch
            {
                return("获取失败");
            }
        }
コード例 #30
0
        public object GetQuestionStatistic(int unitId)
        {
            var query = new BmobQuery();

            query.Limit(300);
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     id       = cookie1["CourseId"];
            int        courseId = int.Parse(id);

            query.WhereEqualTo("courseId", courseId);
            var query1 = new BmobQuery();

            query1.WhereEqualTo("unitId", unitId);
            query = query.And(query1);
            //query.OrderByDescending("rightNum");
            var future = Bmob.FindTaskAsync <Question>("Question", query);

            try
            {
                questionList = future.Result.results;
                foreach (var q in questionList)     //由于BmobModel中有BmobInt类型不能直接显示到页面中,所以需要对字段的类型进行处理,变为相对应的ViewModel格式。
                {
                    Question_View question_view = new Question_View();
                    question_view.id       = q.id.Get();
                    question_view.question = q.question;
                    question_view.totalNum = q.totalNum.Get();
                    question_view.rightNum = q.rightNum.Get();

                    if (question_view.totalNum != 0)
                    {
                        question_view.accuracy = 100 * question_view.rightNum / question_view.totalNum;
                    }
                    qList.Add(question_view);
                }

                questionSortList = qList.OrderByDescending(s => s.accuracy).ToList();

                return(ResultToJson.toJson(questionSortList));
            }
            catch
            {
                return("获取失败");
            }
        }