Exemplo n.º 1
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("获取失败");
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private void deleteData_Click(object sender, EventArgs e)
        {
            //删除一条记录
            var future = Bmob.DeleteTaskAsync(TABLE_NAME, gameObject.objectId);

            FinishedCallback(future.Result, resultText);

            //设置控件的可用性
            findAllData.Enabled = true;
            findOneData.Enabled = false;
            deleteData.Enabled  = false;
            updateData.Enabled  = false;

            FormStatusLabel.Text = "删除一条数据成功";
        }
Exemplo n.º 5
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);
                }
            }
        }
Exemplo n.º 6
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("获取失败");
            }
        }
Exemplo n.º 7
0
        public void DeleteTest()
        {
            var future = Bmob.DeleteTaskAsync(TABLENAME, LatestObjectId);

            FinishedCallback(future.Result, null);
        }