示例#1
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;
            }
        }
示例#2
0
        void denglu(tcpDataCommunication tcpComm, stringMsg msg)
        {
            string address = tcpComm.tcpClientId.Split('&')[2];
            string account = msg.value["account"];
            string pwd     = msg.value["pwd"];

            RetUser curr = user.Login(account, pwd);

            BLE.stringMsg m1 = new BLE.stringMsg();
            m1.name = BLE.msgEnum.dengru;
            m1.value.Add("return", curr.Success.ToString());


            if (curr.Success)
            {
                tcpComm.user = curr.User;
                if (Common.UserViewList == null)
                {
                    Common.UserViewList = new List <UserView>();
                }
                Common.UserViewList.Add(new UserView()
                {
                    ID = curr.User.ID, Name = curr.User.Account, Address = address
                });
                BindDataGridView(Common.UserViewList);
                m1.value.Add("ID", curr.User.ID.ToString());

                string jsonCurr = JsonConvert.SerializeObject(curr);
                m1.value.Add("jsonCurr", jsonCurr);

                ConfigInfo config     = user.GetSave();
                string     jsonConfig = JsonConvert.SerializeObject(config);
                m1.value.Add("ConfigInfo", jsonConfig);
            }



            tcpComm.sendData(m1);

            // UserService user = new UserService();
        }