/// <summary> /// 全部更新为最新数据 /// </summary> public void getdata() { //返回addressBook ObservableCollection <caddressBook> addressBook = newaddressBook(); string json = JsonConvert.SerializeObject(addressBook); ctransmitter transmitter = new ctransmitter(-1, ecommand.addressBook, json); _principal_computer.send(transmitter.ToString()); System.Threading.Thread.Sleep(1000); ObservableCollection <cdiary> diary = newdiary(); json = JsonConvert.SerializeObject(diary); transmitter = new ctransmitter(-1, ecommand.diary, json); _principal_computer.send(transmitter.ToString()); System.Threading.Thread.Sleep(1000); ObservableCollection <cmemorandum> memorandum = newmemorandum(); json = JsonConvert.SerializeObject(memorandum); transmitter = new ctransmitter(-1, ecommand.memorandum, json); _principal_computer.send(transmitter.ToString()); System.Threading.Thread.Sleep(1000); ObservableCollection <cproperty> property = newproperty(); json = JsonConvert.SerializeObject(property); transmitter = new ctransmitter(-1, ecommand.property, json); _principal_computer.send(transmitter.ToString()); }
private void implement(string str) { try { str = str.TrimEnd('\0'); if (switchimplement != null && !string.IsNullOrEmpty(str)) { ctransmitter transmitter = JsonConvert.DeserializeObject <ctransmitter>(str); ecommand command = (ecommand)Enum.Parse(typeof(ecommand), transmitter.command); int id = Convert.ToInt32(transmitter.id); switchimplement(id, command, transmitter.str); } //switch (command) //{ // case ecommand.ce: // reminder("收到" + transmitter.id); // break; //} } catch (Exception e) { reminder("str不是ctransmitter " + e.Message); } }