Exemplo n.º 1
0
        /// <summary>
        /// 成功收到格式正确的消息
        /// </summary>
        void successData()
        {
#if DEBUG
            Console.WriteLine(ble.ToString());
#endif
            initReaddata();

            newBleMessageEvent?.Invoke(this, ble);
        }
Exemplo n.º 2
0
        //新消息事件
        void newBlemessageEventFun(tcpDataCommunication tcpComm, BLEData ble)
        {
            //string jsonText = ((BLE.bleClass.t11)ble).msg;
            //JObject jo = (JObject)JsonConvert.DeserializeObject(jsonText);

            stringMsg msg = stringMsg.jsonToModel(ble.ToString());

            switch (msg.name)
            {
            case msgEnum.dengru:
                //bool bl = Convert.ToBoolean(jo["value"]["return"]);
                bool bl = Convert.ToBoolean(msg.value["return"]);
                if (bl)
                {
                    RetUser    curr        = JsonConvert.DeserializeObject <RetUser>(msg.value["jsonCurr"]);
                    ConfigInfo ConfigInfo1 = JsonConvert.DeserializeObject <ConfigInfo>(msg.value["ConfigInfo"]);
                    //RetUser curr = user.Login(login.textBox1.Text, login.textBox2.Text);
                    CurrUser.currUser = curr.User;
                    CurrUser.config   = ConfigInfo1;
                    CloseFrom2();
                    ShowFile(curr.User.ID);
                }
                else
                {
                    //   zTcpClient1.tcpComm.stop();
                    MessageBox.Show("账号或密码错误!");
                }
                break;

            case msgEnum.liaotian:
                //string groupSendingMsg = jo["value"]["groupSending"].ToString();
                string reciveMsg = "";
                if (msg.value.Keys.Contains("groupSending"))
                {
                    reciveMsg = msg.value["groupSending"];
                }
                else if (msg.value.Keys.Contains("singleSending"))
                {
                    reciveMsg = msg.value["singleSending"];
                }
                showMsg(reciveMsg);
                break;

            case msgEnum.returnUserFileList:
                ResetList(msg);
                break;

            case msgEnum.fileUpload:
                fileUpload(tcpComm, ble);
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        void fileUpload(tcpDataCommunication tcpComm, BLEData msg)
        {
            stringMsg m1 = stringMsg.jsonToModel(msg.ToString());

            if (m1.value["saveFileFullPath"].Trim() == "")
            {
                showMsg("<下载失败,服务端文件不存在>");
                // MessageBox.Show("下载失败,服务端文件不存在", "提示");
                return;
            }

            string fileName = System.IO.Path.GetFileName(m1.value["saveFileFullPath"]);


            showMsg(string.Format("<{0} 下载完成>", fileName));
            //MessageBox.Show("下载完成", "提示");
        }