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("获取失败"); } }
public void queryCommodity(string category, string subcategory) { var bmobQuery = new BmobQuery(); if (category.Equals("促销")) { bmobQuery.WhereEqualTo("Promotion", "true"); } else if (category.Equals("广告")) { bmobQuery.WhereEqualTo("AD", "true"); } else { bmobQuery.WhereEqualTo("Category", category); } if (subcategory != null) { bmobQuery.WhereEqualTo("CategorySub", subcategory); } bmobQuery.Limit(1000); _bmobWindows.Find <Commodity>("Commodity", bmobQuery, (resp, ex) => { if (ex != null) { Debug.WriteLine("查询出错:" + ex.Message); return; } var commodities = resp.results; _view.commodityShow(commodities); }); }
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("获取失败"); } }
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); }
[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); }
[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格式 }
[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); }
public bool ExsitLogID(string missionID) { BmobQuery query = new BmobQuery(); query.WhereEqualTo("MissionID", missionID); return(FindByQuery(query, 2).Count != 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("获取失败"); } }
public void LoadEntry() { try { if (string.IsNullOrEmpty(CurrentObjectID)) { Entry = new E(); } else { BmobQuery query = new BmobQuery(); query.WhereEqualTo("objectId", CurrentObjectID); var task = Bomb().FindTaskAsync <E>(GetTableName(), query); if (task.Result.results.Count == 1) { Entry = task.Result.results[0]; } else { Entry = new E(); } } } catch (AggregateException ex) { ErrorMessage = ex.InnerException.Message; } catch (Exception ex2) { ErrorMessage = ex2.Message; } }
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 { } }
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("获取失败"); } }
public void FindByID(Action <UserBmobDao> call_back, Action fail_call_back = null) { BmobQuery query = new BmobQuery(); BmobManager.Instance.Bmob.Find <UserBmobDao>(GameConstData.USER_TABLE_NAME, query.WhereEqualTo("id", id.ToString()), (resp, exce) => { UserBmobDao result = null; if (exce != null) { fail_call_back(); Debug.LogError(exce.Message); return; } if (resp.results.Count > 0) { result = resp.results[0]; } else { Debug.Log(" 没有这个ID"); } call_back(result); }); }
public static Task <List <Prop> > getPropsInMark(Mark mark) { return(Task.Run( async() => { BmobQuery query = new BmobQuery(); query.WhereEqualTo("mark", new BmobPointer <Mark>(mark)); QueryCallbackData <Prop> data = await Bmob.FindTaskAsync <Prop>(Prop.table_name, query); List <Prop> props = new List <Prop>(); foreach (Prop prop in data.results) { /*Vector3 pos = new Vector3((float)prop.pos_x.Get(), (float)prop.pos_y.Get(), (float)prop.pos_z.Get()); * Vector4 rot = new Vector4((float)prop.rot_x.Get(), (float)prop.rot_y.Get(), (float)prop.rot_z.Get(), (float)prop.rot_w.Get()); * Vector3 sca = new Vector3((float)prop.scale_x.Get(), (float)prop.scale_y.Get(), (float)prop.scale_z.Get()); * if (prop.type.Get() == 0) * props.Add(new TextProp { text = prop.text, type = 0, position = pos, rotation = rot, scale = sca, }); * if (prop.type.Get() == 1) * props.Add(new ImageProp { fileName = prop.texture.filename, url = prop.texture.url, type = 1, position = pos, rotation = rot, scale = sca, }); * if (prop.type.Get() == 2) * props.Add(new VideoProp { fileName = prop.video.filename, url = prop.video.url, type = 2 position = pos, rotation = rot, scale = sca, }); * if (prop.type.Get() == 3) * props.Add(new ModelProp { fileName = prop.model.reference.model.filename, url = prop.model.reference.model.url, type = 3, position = pos, rotation = rot, scale = sca, });*/ props.Add(prop); } return props; })); }
/// <summary> /// 读取金币记录 /// </summary> public void loadJinBI() { this.Items.Clear(); BmobQuery query = new BmobQuery(); query.WhereEqualTo("jieShouUserId", JYCaoZuo.getCaoZuo().user.userId); query.OrderByDescending("createdAt"); query.Limit(50); bmob.Find <message>("message", query, (resp, exception) => { if (exception != null) { JYCaoZuo.getCaoZuo().showMessagem("查询异常" + exception.Message); return; } JYCaoZuo.getCaoZuo().showMessagem("查 结果" + resp); this.page.Dispatcher.BeginInvoke(delegate { foreach (message li in resp.results) { JYJinBiJiLuMode mode = new JYJinBiJiLuMode(); mode.MessgeType = li.messgeType; mode.SendUserId = li.sendUserId; mode.JieShouUserId = li.jieShouUserId; mode.Title = li.title; mode.Content = li.content; mode.CreatTime = li.createdAt; mode.objiectId = li.objectId; // liShiJiLu li = resp.results[0]; this.Items.Add(mode); } }); }); }
public static void InitPushService(PushNotificationChannel channel, string tableName, Action action) { BmobQuery query = new BmobQuery(); query.WhereEqualTo("DeviceId", UUID); bmob.Find <Push>(tableName, query, (resp, ex) => { if (ex != null || resp.results.Count == 0) { Push push = new Push(); push.LeftTime = channel.ExpirationTime.UtcDateTime; push.CURL = channel.Uri; push.DeviceId = UUID; push.ProductId = CurrentApp.AppId.ToString("D"); bmob.Create(tableName, push, (s, e) => { action?.Invoke(); }); return; } if (resp.results.Count == 1) { var push = resp.results[0]; push.LeftTime = channel.ExpirationTime.UtcDateTime; push.CURL = channel.Uri; bmob.Update(tableName, push.objectId, push, (s, e) => { action?.Invoke(); }); } }); }
/// <summary> /// 增加或减少金币 /// </summary> /// <param name="nubber">增加或减少的金币数量</param> /// <param name="beiZhu">这次操作的备注</param> public void updataJinBi(double nubber, string beiZhu) { user.jinBi += nubber; addCaoZuo(nubber, beiZhu, user.jinBi); //增加 updataUser(); return; BmobQuery queryUser = new BmobQuery(); queryUser.WhereEqualTo("userId", user.userId); bmob.Find <myUser>(tableNameForUser, queryUser, (resp, exception) => { if (exception != null) { showMessagem("查询异常" + exception.Message); return; } if (resp.results.Count == 0) { showMessagem("没有改用户 创建"); creatUser(); } else { showMessagem("查找到该用户" + resp.results[0]); user = resp.results[0]; } }); }
public IList <TB_TechniqueMission> FindMissionByTechniqueID(string TechniqueID) { BmobQuery query = new BmobQuery(); query.WhereEqualTo("TechniqueID", TechniqueID); return(FindByQuery(query)); }
public bool ExistTechniqueID(string techniqueObjectID) { BmobQuery query = new BmobQuery(); query.WhereEqualTo("TechniqueID", techniqueObjectID); return(FindByQuery(query, 2).Count != 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("获取失败"); } }
/// <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); }
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格式 }
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); }
[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格式 }
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); }
/// <summary> /// 用户登录 /// </summary> /// <param name="LoginUser"></param> /// <param name="finished"></param> public void Login(BmobGameObject LoginUser, OnLoginFinish finished) { BmobQuery query = new BmobQuery(); query.WhereEqualTo("userid", LoginUser.userid).WhereEqualTo("password", LoginUser.password); bmobUnity.Find <BmobGameObject>(TABLE_NAME, query, (resp, exception) => { if (exception != null) { Debug.Log("查询失败, 失败原因为: " + exception.Message); return; } List <BmobGameObject> list = resp.results; if (list.Count != 0) { finished(true); } else { finished(false); } foreach (var user in list) { Debug.Log("ID:" + user.userid); } }); }
public void FindByMissionIDAsyn(string missionID, BmobCallback <cn.bmob.response.QueryCallbackData <TB_TechniqueLog> > callback) { //创建一个BmobQuery查询对象 BmobQuery query = new BmobQuery(); query.WhereEqualTo("MissionID", missionID); BmobIntance.Create().Bmob.Find <TB_TechniqueLog>("TB_TechniqueLog", query, callback); }
public IList <TB_TechniqueLog> FindByMissionID(string missionID, bool SortDatedesc = true) { BmobQuery query = new BmobQuery(); query.WhereEqualTo("MissionID", missionID); query.OrderByDescending("Date"); return(FindByQuery(query)); }
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("获取失败"); } }
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); }
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); }
void FindUser() { BmobQuery query = new BmobQuery (); query.WhereEqualTo ("username", "test"); Bmob.Find<MyBmobUser> (BmobUser.TABLE, query, (resp, exception) => { if (exception != null) { print ("查询失败, 失败原因为: " + exception.Message); return; } List<MyBmobUser> list = resp.results; foreach (var user in list) { print ("获取的对象为: " + toString (user)); } }); }
void FindQueryWithCount() { BmobQuery query = new BmobQuery (); query.WhereEqualTo ("playerName", "123"); query.Count (); Bmob.Find<BmobGameObject> (TABLENAME, query, (resp, exception) => { if (exception != null) { print ("查询失败, 失败原因为: " + exception.Message); return; } List<BmobGameObject> list = resp.results; BmobInt count = resp.count; print ("满足条件的对象个数为: " + count.Get ()); foreach (var game in list) { print ("获取的对象为: " + toString (game)); } }); }