Example #1
0
        public void processReceivedData(byte[] replyData)
        {
            string msg = Encoding.ASCII.GetString(replyData);

            if (msg.Length == 7 && msg.Substring(0, 1).Equals("t"))
            {
                BmobWindows bmobWindows = CloudServiceHelper.BmobBuilder();
                int         lowValue    = int.Parse(msg.Substring(1, 2));
                int         highValue   = int.Parse(msg.Substring(4, 2));
                int         value       = (lowValue + highValue) / 2;
                bool        humid       = msg.Substring(6, 1).Equals("s") ? true : false;


                KyOperation kyOperation = new KyOperation(value, humid);
                kyOperation.objectId = "429af4fea3";
                bmobWindows.UpdateTaskAsync(kyOperation);
                KyCommand command = new KyCommand();
                bmobWindows.Get <KyCommand>("KyCommand", "6402c5a401", (result, ex) =>
                {
                    if (ex == null)
                    {
                        if (result.isOpenedLed.Get())
                        {
                            _tcpClient.Send("opled");
                            result.isOpenedLed = false;
                            bmobWindows.UpdateTaskAsync(result);
                        }
                    }
                });
            }
        }
Example #2
0
        public void stopCloudData()
        {
            KyOperation kyOperation = new KyOperation();

            kyOperation.isOpened = false;
            kyOperation.objectId = "429af4fea3";
            BmobWindows bmobWindows = CloudServiceHelper.BmobBuilder();

            bmobWindows.UpdateTaskAsync(kyOperation);
        }
Example #3
0
 //修改字段
 public bool ModifyData(TModel model)
 {
     try
     {
         TBmobModel Bmodel = DataMapperHelper.Map <TBmobModel>(model);
         var        future = Bmob.UpdateTaskAsync <TBmobModel>(Bmodel);
         return(true);
     }
     catch (Exception e)
     {
         string message = e.Message;
         return(false);
     }
 }
Example #4
0
        /// <summary>
        /// 修改分类
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public bool ModifyKind(string Name, string Id)
        {
            var    future1  = Bmob.GetTaskAsync <KindModel>("Kind_tb", Id);
            string ParentId = "";

            if (future1.Result is IBmobWritable)
            {
                ParentId = future1.Result.ParentId;
            }
            var linq = from r in Operation.Kind_Data.AsEnumerable() where r.Field <string>("ParentId") == ParentId && r.Field <string>("Name") == Name select r;

            if (linq.Count <DataRow>() > 0)
            {
                return(false);
            }
            KindModel kindModel = new KindModel("Kind_tb");

            kindModel.objectId = Id;
            kindModel.Name     = Name;
            var future = Bmob.UpdateTaskAsync <KindModel>(kindModel);

            if (future.Result is IBmobWritable)
            {
                linq = from r in Operation.Kind_Data.AsEnumerable() where r.Field <string>("Id") == Id select r;
                foreach (var data in Operation.Kind_Data.AsEnumerable())
                {
                    data.SetField <string>("Name", Name);
                }
                DataSynchronous("Kind_tb");
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void DataTimer_Tick(object sender, EventArgs e)
        {
            Console.WriteLine("定时器");
            BmobWindows bmobWindows = CloudServiceHelper.BmobBuilder();

            bmobWindows.Get <CloudControl>("CloudControl", "W2obDDDL", (result, ex) =>
            {
                if (ex == null)
                {
                    if (result.deployCollectOpened.Get())
                    {
                        PresetInfo.StartAutoCollect = true;
                        if (!isWorking)
                        {
                            isWorking = true;
                            _commPresenter.DeviceGatherStart(OperateType.Gather);
                        }
                        CloudControl cloudControl       = new CloudControl();
                        cloudControl.objectId           = "W2obDDDL";
                        cloudControl.cloudCollectOpened = true;

                        if (currentCollectNum == 0)
                        {
                            cloudControl.cloudCollectProgress = 0;
                        }
                        else
                        {
                            int value = currentCollectNum * 100 / currentCollectSumNum;
                            cloudControl.cloudCollectProgress = value;
                            Console.WriteLine("当前进度:" + value);
                        }
                        bmobWindows.UpdateTaskAsync(cloudControl);
                        Console.WriteLine("数据发送完毕");
                    }
                    else
                    {
                        PresetInfo.StartAutoCollect = false;
                        isWorking = false;
                    }
                }
            });
        }