| | |
| | | { |
| | | public partial class IBoxFormEnergyAnalysis : DocumentPage |
| | | { |
| | | private string startCode = "[&start&]"; |
| | | private string endCode = "[&end&]"; |
| | | private string paramCode = "[¶m&]"; |
| | | private string getenergyanalyCode = "getenergyanaly";//获取能耗分析数据 |
| | | private string analydayCode = "analyday";//校验能耗分析 |
| | | |
| | | |
| | | public IBoxFormEnergyAnalysis() |
| | | { |
| | |
| | | _series_qds.CrosshairLabelPattern = "千吨水能耗:{V:N2} kW·h/km³"; |
| | | } |
| | | |
| | | private void InitDate() |
| | | public void InitDate() |
| | | { |
| | | this.dateEditStartDate.Text = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"); |
| | | this.dateEditEndDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | } |
| | | |
| | | public void HideButton() |
| | | { |
| | | //simpleButton1.Visible = simpleButton2.Visible = simpleButton5.Visible = false; |
| | | layoutControlItem3.Visibility = layoutControlItem4.Visibility = layoutControlItem10.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | } |
| | | |
| | | List<PumpEnergyViewModel> _models; |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | /// <param name="models"></param> |
| | | public void BindData(List<PumpEnergyViewModel> models) |
| | | { |
| | | _models = models; |
| | |
| | | private Series _series_ydl { get { return this.chartControl1.Series[0]; } } |
| | | private Series _series_qds { get { return this.chartControl1.Series[2]; } } |
| | | |
| | | private void SetChart(List<PumpEnergyViewModel> models) |
| | | public void SetChart(List<PumpEnergyViewModel> models) |
| | | { |
| | | this.chartControl1.BeginInit(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | this.chartControl1.EndInit(); |
| | | this.chartControl1.EndInit(); |
| | | } |
| | | |
| | | private void EboxFormEnergyAnalysis_Load(object sender, EventArgs e) |
| | |
| | | Search(); |
| | | } |
| | | |
| | | private void Search() |
| | | public void Search() |
| | | { |
| | | var m = new GetCalcValueModel() |
| | | { |
| | |
| | | EndDate = DateTime.Parse(this.dateEditEndDate.EditValue.ToString()), |
| | | }; |
| | | |
| | | SendText(startCode + getenergyanalyCode + paramCode + JsonHelper.Object2Json(m) + endCode); |
| | | SendText(IBoxHelper.startCode + IBoxHelper.getenergyanalyCode + IBoxHelper.paramCode + JsonHelper.Object2Json(m) + IBoxHelper.endCode); |
| | | } |
| | | |
| | | public event EventHandler<string> SendData; |
| | | private void SendText(string content) |
| | | { |
| | | //BluetoothHelper.GetInstance().SendData(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.getenergyanalyCode: |
| | | { |
| | | var order = IBoxHelper.HttpGet(content); |
| | | var result = IBoxHelper.GetContent(order); |
| | | if (!string.IsNullOrEmpty(result)) |
| | | { |
| | | var model = JsonHelper.Json2Object<List<PumpEnergyViewModel>>(result); |
| | | BindData(model); |
| | | } |
| | | break; |
| | | } |
| | | default: |
| | | IBoxHelper.HttpGet(content); |
| | | break; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | MessageBoxHelper.ShowWarning("网络连接失败,请检查网络"); |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 查询 |
| | |
| | | |
| | | private void simpleButton5_Click(object sender, EventArgs e) |
| | | { |
| | | Check(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 校验 |
| | | /// </summary> |
| | | public void Check() |
| | | { |
| | | var dlg = new AnalyDayForm(); |
| | | if (dlg.ShowDialog() == DialogResult.OK) |
| | | { |
| | | var dt = dlg.CurrDateTime; |
| | | SendText(startCode + analydayCode + paramCode + dt + endCode); |
| | | SendText(IBoxHelper.startCode + IBoxHelper.analydayCode + IBoxHelper.paramCode + dt + IBoxHelper.endCode); |
| | | MessageBoxHelper.ShowInfo("操作成功"); |
| | | } |
| | | } |