| | |
| | | public event EventHandler<string> SendData; |
| | | private void SendText(string content) |
| | | { |
| | | SendData?.Invoke(null, content); |
| | | if (SendData != null) |
| | | { |
| | | SendData?.Invoke(null, content); |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (IBoxHelper.Ping()) |
| | | { |
| | | var smsg = content.Split(new string[] { IBoxHelper.paramCode, IBoxHelper.startCode }, StringSplitOptions.RemoveEmptyEntries); |
| | | if (smsg.Length < 2) |
| | | { |
| | | return; |
| | | } |
| | | switch (smsg[0].Trim()) |
| | | { |
| | | case IBoxHelper.getprotocolCode: |
| | | { |
| | | var order = IBoxHelper.HttpGet(content); |
| | | var result = IBoxHelper.GetContent(order); |
| | | if (!string.IsNullOrEmpty(result)) |
| | | { |
| | | var model = JsonHelper.Json2Object<IBoxProtocolViewModel>(result); |
| | | BindData(model, false); |
| | | } |
| | | break; |
| | | } |
| | | case IBoxHelper.saveprotocolCode: |
| | | { |
| | | IBoxHelper.HttpPost(content); |
| | | break; |
| | | |
| | | } |
| | | default: |
| | | IBoxHelper.HttpGet(content); |
| | | break; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | MessageBoxHelper.ShowWarning("网络连接失败,请检查网络"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void HideButton() |
| | |
| | | private void simpleButton1_Click(object sender, EventArgs e) |
| | | { |
| | | Save(); |
| | | MessageBoxHelper.ShowInfo("数据保存成功!"); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public void Save() |
| | | { |
| | | SendText(IBoxHelper.startCode + IBoxHelper.saveprotocolCode + IBoxHelper.paramCode + JsonHelper.Object2Json(GetData()) + IBoxHelper.endCode); |
| | | MessageBoxHelper.ShowInfo("数据保存成功!"); |
| | | |
| | | } |
| | | public void SetData() |
| | | { |