示例#1
0
        public object PostAddQuestion([FromBody] Question_View questionInfo)
        {
            Question question = new Question();

            question.id       = questionInfo.id;
            question.question = questionInfo.question;
            question.a        = questionInfo.a;
            question.b        = questionInfo.b;
            question.c        = questionInfo.c;
            question.d        = questionInfo.d;
            question.a        = questionInfo.a;
            question.answer   = questionInfo.answer;
            question.analysis = questionInfo.analysis;
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     Id       = cookie1["CourseId"];
            int        courseId = int.Parse(Id);

            question.courseId    = courseId;
            question.unitId      = questionInfo.unitId;
            question.knowledgeId = questionInfo.knowledgeId;
            question.difficulty  = questionInfo.difficulty;
            question.rightNum    = questionInfo.rightNum;
            question.totalNum    = questionInfo.totalNum;
            var    future = Bmob.CreateTaskAsync(question);
            String id     = future.Result.objectId;

            return(id);
        }
示例#2
0
        public object PostFile([FromBody] Resource_View resourceView)
        {
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     id       = cookie1["CourseId"];
            int        courseId = int.Parse(id);
            String     a        = "";
            // String objectId = "";
            Resource resource = new Resource();

            resource.id          = BmobInput.Parse <BmobInt>(resourceView.id);
            resource.file        = resourceView.file;
            resource.type        = resourceView.type;
            resource.courseId    = BmobInput.Parse <BmobInt>(courseId);
            resource.unitId      = BmobInput.Parse <BmobInt>(resourceView.unitId);
            resource.knowledgeId = BmobInput.Parse <BmobInt>(resourceView.knowledgeId);
            //var query = new BmobQuery();
            //query.WhereEqualTo("id", course.id);
            var f = Bmob.CreateTaskAsync("Resource", resource);

            try
            {
                a = f.Result.objectId;
            }
            catch
            {
                a = "失败";
            }
            return(a);
        }
示例#3
0
        public void ACLAddTest()
        {
            var data = new GameObject(TABLENAME);

            data.arrint    = BmobArrays.wrap <int>(1, 2, 3);
            data.arrstring = BmobArrays.wrap <string>("1", "2", "3");

            data.jo2 = 123;

            // 用于下面的区间查询
            Random rnd = new Random();

            data.jo = rnd.Next(-50, 170);
            data.s  = "String";

            BmobACL acl = new BmobACL();

            acl.WriteAccess("b0eab87db3");
            acl.ReadAccess("b0eab87db3");
            data.ACL = acl;

            var future = Bmob.CreateTaskAsync(data);

            FinishedCallback(future.Result, null);
        }
示例#4
0
 public void CreateTest()
 {
     Create(
         data =>
     {
         var future = Bmob.CreateTaskAsync(data);
         FinishedCallback(future.Result, null);
     }
         );
 }
示例#5
0
        public void RoleTest()
        {
            //这里创建四个用户对象指针,分别为老板、人事小张、出纳小谢和自己
            // just for test
            BmobPointer <BmobUser> boss = new BmobUser()
            {
                objectId = "1"
            };
            BmobPointer <BmobUser> hr_zhang = new BmobUser()
            {
                objectId = "2"
            };
            BmobPointer <BmobUser> hr_luo = new BmobUser()
            {
                objectId = "3"
            };
            BmobPointer <BmobUser> cashier_xie = new BmobUser()
            {
                objectId = "4"
            };
            BmobPointer <BmobUser> me = new BmobUser()
            {
                objectId = "5"
            };

            {
                //创建HR和Cashier两个用户角色(这里为了举例BmobRole的使用,将这段代码写在这里,正常情况下放在员工管理界面会更合适)
                BmobRole hr = new BmobRole();
                hr.name = "HR";
                var users = new BmobRelation <BmobUser>();
                users.Add(hr_zhang);
                users.Add(hr_luo);

                //将hr_zhang和hr_luo归属到hr角色中
                hr.AddUsers(users);

                //保存到云端角色表中(web端可以查看Role表)
                var future = Bmob.CreateTaskAsync(hr);
                FinishedCallback(future.Result, null);
            }

            {
                BmobRole cashier = new BmobRole();
                cashier.name = "Cashier";
                var users = new BmobRelation <BmobUser>();
                users.Add(cashier_xie);

                //将cashier_xie归属到cashier角色中
                cashier.AddUsers(users);

                //保存到云端角色表中(web端可以查看Role表)
                var future = Bmob.CreateTaskAsync(cashier);
                FinishedCallback(future.Result, null);
            }
        }
示例#6
0
        public object PostAddClass([FromBody] Class classInfo)
        {
            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);

            classInfo.tId      = username;
            classInfo.courseId = courseId;
            var    future = Bmob.CreateTaskAsync("Class", classInfo);
            String id     = future.Result.objectId;

            return(id);
        }
示例#7
0
        public object PostUploadQuestion([FromBody] List <Question_View> question1)
        {
            String        a    = "";
            List <String> list = new List <String>();

            quesList.AddRange(question1);
            int length = quesList.Count;

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

                var future = Bmob.CreateTaskAsync(question);
                try
                {
                    String id = future.Result.objectId;
                    list.Add(id);
                }
                catch
                {
                    //没成功的会跳转到这里
                }
            }
            if (quesList.Count == list.Count)
            {
                a = "上传成功";
            }
            else
            {
                a = "上传失败";
            }
            return(a);
        }
示例#8
0
        public string AddExceptionLog(OperatorLog log)
        {
            var result = string.Empty;

            if (BmobUser.CurrentUser != null)
            {
                log.user = BmobUser.CurrentUser;
            }
            var createResult = Bmob.CreateTaskAsync(log);

            if (createResult.Result != null)
            {
                return(createResult.Result.objectId);
            }

            return(null);
        }
示例#9
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);
                }
            }
        }
示例#10
0
        private void regBtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtNickName.Text.Trim()))
            {
                MessageBox.Show("请填写昵称!");
                return;
            }

            if (string.IsNullOrWhiteSpace(username.Text.Trim()))
            {
                MessageBox.Show("请填写帐号!");
                return;
            }

            if (string.IsNullOrWhiteSpace(password.Text.Trim()))
            {
                MessageBox.Show("请填写密码!");
                return;
            }

            //注册用户
            var user = new UserEntity();

            user.username     = username.Text.Trim();
            user.password     = password.Text.Trim();
            user.NickName     = txtNickName.Text.Trim();
            user.WechatOpenId = string.Empty;
            user.avatar       = "https://pic.cnblogs.com/face/110188/20170406195314.png";

            user.Sex = new BmobBoolean(false);
            var future = Bmob.CreateTaskAsync <UserEntity>(user);

            try
            {
                FinishedCallback(future.Result, result);
                var form = new BmobUserForm();
                form.Show();
                this.Close();
            }
            catch
            {
                result.Text = "注册失败,原因:" + future.Exception.InnerException.ToString();
            }
        }
示例#11
0
        [HttpPost]                                                //定义访问方式(Post或Get方法)
        public object PostAddUnit([FromBody] Unit_View unit_view) //返回数据的函数,如果是Get方法则方法名为Get开头,若是Post则使用Post开头。
        {
            String result = "";
            Unit   unit   = new Unit();

            unit.id       = unit_view.id;
            unit.name     = unit_view.name;
            unit.courseId = unit_view.courseId;
            var future = Bmob.CreateTaskAsync("Unit", unit);

            try
            {
                result = future.Result.objectId;
            }catch
            {
                result = "失败";
            }
            return(result);
        }
        private void regBtn_Click(object sender, EventArgs e)
        {
            //注册用户
            MyUserObject user = new MyUserObject();

            user.username = username.Text;
            user.password = password.Text;
            user.sex      = new BmobBoolean(false);
            user.age      = 50;
            var future = Bmob.CreateTaskAsync <MyUserObject>(user);

            try
            {
                FinishedCallback(future.Result, result);
            }
            catch
            {
                MessageBox.Show("注册失败,原因:" + future.Exception.InnerException.ToString());
            }
        }
示例#13
0
        [HttpPost]                                                               //定义访问方式(Post或Get方法)
        public object PostAddKnowledge([FromBody] Knowledge_View knowledge_view) //返回数据的函数,如果是Get方法则方法名为Get开头,若是Post则使用Post开头。
        {
            String    result    = "";
            Knowledge knowledge = new Knowledge();

            knowledge.id       = knowledge_view.id;
            knowledge.name     = knowledge_view.name;
            knowledge.courseId = knowledge_view.courseId;
            knowledge.unitId   = knowledge_view.unitId;
            var future = Bmob.CreateTaskAsync("Knowledge", knowledge);

            try
            {
                result = future.Result.objectId;
            }
            catch
            {
                result = "失败";
            }
            return(result);
        }
示例#14
0
        public object PostSavePaper([FromBody] Examination_View examination_View)
        {
            HttpCookie  cookie1     = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String      id          = cookie1["CourseId"];
            int         courseId    = int.Parse(id);
            Examination examination = new Examination();

            examination.id           = BmobInput.Parse <BmobInt> (examination_View.id);
            examination.name         = examination_View.name;
            examination.questionList = examination_View.questionList;
            examination.difficulty   = BmobInput.Parse <BmobDouble>(examination_View.difficulty);
            examination.courseId     = BmobInput.Parse <BmobInt>(courseId);
            var future = Bmob.CreateTaskAsync("Examination", examination);

            try
            {
                String objectId = future.Result.objectId;
                return(objectId);
            }
            catch
            {
                return("获取失败");
            }
        }
示例#15
0
        public object PostAddCourse([FromBody] Course_View cl)
        {
            String     a        = "";
            HttpCookie cookie   = HttpContext.Current.Request.Cookies["UserInfoRemember"];
            String     username = cookie["username"].ToString();
            Course     course   = new Course();

            course.id   = BmobInput.Parse <BmobInt>(cl.id);
            course.name = cl.name;
            course.tId  = username;
            //course.program = cl.program;
            //course.experiment = cl.experiment;
            //course.time = cl.time;
            var future = Bmob.CreateTaskAsync("Course", course);

            try
            {
                a = "success";
            }catch
            {
                a = "fail";
            }
            return(a);
        }
        private void createData_Click(object sender, EventArgs e)
        {
            //设置值
            System.Random rnd = new System.Random();
            gameObject.score      = rnd.Next(-50, 170);
            gameObject.playerName = "123";
            gameObject.cheatMode  = false;

            //保存数据
            var future = Bmob.CreateTaskAsync(gameObject);

            // !!! 直接获取异步对象结果会阻塞主线程! 建议使用async + await/callback的形式, 可以参考文件上传功能的实现。
            //获取创建记录的objectId
            gameObject.objectId = future.Result.objectId;

            FinishedCallback(future.Result, resultText);

            //设置控件的可用性
            findAllData.Enabled  = true;
            findOneData.Enabled  = true;
            deleteData.Enabled   = true;
            updateData.Enabled   = true;
            FormStatusLabel.Text = "创建成功";
        }
示例#17
0
        private void duWord2()
        {
            try
            {
                Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
                Microsoft.Office.Interop.Word.Document    doc = null;
                object unknow = Type.Missing;
                app.Visible = true;
                string str  = @"E:\1200题.doc";
                object file = str;
                doc = app.Documents.Open(ref file,
                                         ref unknow, ref unknow, ref unknow, ref unknow,
                                         ref unknow, ref unknow, ref unknow, ref unknow,
                                         ref unknow, ref unknow, ref unknow, ref unknow,
                                         ref unknow, ref unknow, ref unknow);
                //得到标题
                int size1 = 100000;
                for (int i = 1; i < size1; i++)
                {
                    string temp    = doc.Paragraphs[i].Range.Text.Trim();
                    string title11 = temp;
                    Console.Write(title11);
                    if (!temp.Equals(""))
                    {
                        string tem1p3 = temp.Substring(0, 1);
                        if (StrIsInt(temp.Substring(0, 1)))
                        {
                            String title      = temp.Substring(2, temp.Length - 2); ///去掉两个字符串
                            String A          = String.Empty;
                            String B          = String.Empty;
                            String C          = String.Empty;
                            String D          = String.Empty;
                            String Answer     = String.Empty;
                            String Answercode = String.Empty;//答案编码
                            //String core = String.Empty;//相关词汇
                            // String codeyi = String.Empty;//参考译文
                            // String coreanasyl = String.Empty;//题目分析
                            //String explain = String.Empty;//考点解析

                            i++;
                            temp = doc.Paragraphs[i].Range.Text.Trim();

                            if (temp.Substring(0, 2).Equals("A)"))
                            {
                                string[] sArray1 = temp.Split(new string[] { "A)", "B)", "C)", "D)" }, StringSplitOptions.RemoveEmptyEntries);
                                A = sArray1[0];
                                B = sArray1[1];
                                C = sArray1[2];
                                D = sArray1[3];
                                i++;
                                temp = doc.Paragraphs[i].Range.Text.Trim();
                                //string tempcore1 = doc.Paragraphs[i++].Range.Text.Trim();
                                //string tempcore2 = doc.Paragraphs[i++].Range.Text.Trim();
                                //string tempcore3 = doc.Paragraphs[i++].Range.Text.Trim();
                                //string tempcore4 = doc.Paragraphs[i++].Range.Text.Trim();
                                //string tempcore8 = doc.Paragraphs[i++].Range.Text.Trim();
                                //string tempcore5 = doc.Paragraphs[i++].Range.Text.Trim();//参考译文
                                //string tempcore6 = doc.Paragraphs[i++].Range.Text.Trim();//题目分析
                                //string tempcore7 = doc.Paragraphs[i].Range.Text.Trim();//考点解析
                                //if (!StrIsInt(tempcore1.Trim().Substring(0, 1)) && !StrIsInt(tempcore2.Trim().Substring(0, 1)) && !StrIsInt(tempcore3.Trim().Substring(0, 1)) && !StrIsInt(tempcore4.Trim().Substring(0, 1)))
                                if (!StrIsInt(temp.Trim().Substring(0, 1)))
                                {
                                    //如果不等于数字则将数据付给core
                                    //core = tempcore1 + tempcore2 + tempcore3 + tempcore4;
                                    //if (!tempcore5.Substring(0, 3).Equals("【参考"))
                                    //{
                                    //    MessageBox.Show("【参考" + tempcore5);
                                    //}
                                    //if (!tempcore6.Substring(0, 3).Equals("【题目"))
                                    //{
                                    //    MessageBox.Show("【题目" + tempcore6);
                                    //}
                                    //if (!tempcore7.Substring(0, 3).Equals("【考点"))
                                    //{
                                    //    MessageBox.Show("【考点" + tempcore7);
                                    //}
                                    EnglishWordTiKu gameObject = new EnglishWordTiKu("EnglishWordTiKu");

                                    gameObject.titleSubject = title;

                                    gameObject.answer = "【答案】" + temp;
                                    if (temp.Equals("A"))
                                    {
                                        Answercode = "1";
                                    }
                                    else if (temp.Equals("B"))
                                    {
                                        Answercode = "2";
                                    }
                                    else if (temp.Equals("C"))
                                    {
                                        Answercode = "3";
                                    }
                                    else if (temp.Equals("D"))
                                    {
                                        Answercode = "4";
                                    }

                                    // gameObject.core = core;//相关词汇
                                    gameObject.answerCode = Answercode;//答案编码
                                    // gameObject.codeyi = tempcore5;//参考译文
                                    // gameObject.coreanasyl = tempcore6;//题目分析
                                    //gameObject.explain = tempcore7;//考点解析
                                    //   gameObject.chapterflag = int.Parse(dt.Rows[i][3].ToString());
                                    gameObject.optionA = A;
                                    gameObject.optionB = B;
                                    gameObject.optionC = C;
                                    gameObject.optionD = D;
                                    //gameObject.explain = dt.Rows[i][2].ToString();
                                    gameObject.chapterflag  = 2;
                                    gameObject.questiontype = 1;
                                    gameObject.subjectType  = "0";

                                    var future2 = Bmob.CreateTaskAsync(gameObject);
                                }
                                else
                                {
                                    MessageBox.Show("选项中有整数" + i + "///" + temp);
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("选项中有空" + i + "///" + doc.Paragraphs[i - 1].Range.Text.Trim());
                        }
                    }
                    else
                    {
                        MessageBox.Show("数据上传结束" + i + "//" + doc.Paragraphs[i - 2].Range.Text.Trim());
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }