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(); }); } }); }
public void QueryOrder(int orderStatus) { var bmobQuery = new BmobQuery(); if (orderStatus != OrderStatus.NONE) { bmobQuery.WhereEqualTo("status", orderStatus); } _bmobWindows.Find <Order>("Order", bmobQuery, (resp, ex) => { if (ex != null) { Debug.WriteLine("查询出错:" + ex.Message); return; } var orders = resp.results; _view.orderShow(orders); //对比前后订单列表的不同 if (orderStatus == OrderStatus.已下单) { Debug.WriteLine("检索已下单"); orders.ForEach(order => { var objectId = order.objectId; var isNew = true; holdingOrders.ForEach(holdOrder => { if (objectId.Equals(holdOrder.objectId)) { isNew = false; } }); if (isNew) { Debug.WriteLine("有新订单来了,请注意查收"); var sndPlayer = new System.Media.SoundPlayer(@"./resource/kyOrderSound"); sndPlayer.Play(); } }); holdingOrders = orders; } }); }
/// <summary> /// 初始化事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnInit_Click(object sender, EventArgs e) { BmobWindows Bmob = new BmobWindows(); Bmob.initialize("38cd909fe640756176303b980453db55", "9e8a836ccfd013f87619b284a97de02c"); // 初始化Bmob客户端 BmobDebug.Register(msg => { Debug.WriteLine(msg); }); // 用于调试输出请求参数 BmobQuery query = new BmobQuery(); //新建查询 查询Activityrecord表中所有的数据 按时间正向排序 Bmob.Find <ReadFile>("Activityrecord", query, (resp, exception) => { // 处理查询网络异常 if (exception != null) { return; } //对返回结果进行处理 List <ReadFile> list = resp.results; foreach (var game in list) { BmobFile record = game.record; if (record != null) { if (File.Exists(record.filename)) { Console.WriteLine("跳过:" + record.filename); } else { Console.WriteLine("下载:" + record.filename); //调用HttpDownload进行非重复文件的下载,此处下载为同步下载 即一个下载完才会执行之后代码 HttpDownload(record.url, "./" + record.filename); } } } Console.WriteLine("开始写入"); String[] files = Directory.GetFiles("./", "*.txt", SearchOption.AllDirectories); foreach (string f in files) { if (File.Exists("db.txt")) { Console.WriteLine("it is existed"); } else { FileStream fs = new FileStream("db.txt", FileMode.CreateNew); fs.Close(); } Console.WriteLine("查看" + f); if (f.Contains("db.txt")) { continue; } string a = System.IO.File.ReadAllText(f); string b = System.IO.File.ReadAllText("db.txt"); System.IO.File.WriteAllText("db.txt", a + "\r\n" + b); File.Delete(f); } byte[] byData = new byte[100]; char[] charData = new char[1000]; // 这里是Bmob的回调函数 也就是查询完之后执行下载了所有文件再执行此处的合并和InitChart // 所以需要将这个设置为False 否则会提示操作跨线程错误 Control.CheckForIllegalCrossThreadCalls = false; InitChart(); Read("db.txt"); }); }