예제 #1
0
        //控制历史数据操作按钮事件
        private void buttonControlHisData_Click(object sender, EventArgs e)
        {
            try
            {
                var rowHandle = gridViewConHisTree.FocusedRowHandle;
                var fzh       = gridViewConHisTree.GetRowCellValue(rowHandle, "Fzh");
                SubstationBindDto sbd;
                lock (_locker2)
                {
                    sbd = _substationConHisDataBindDto.FirstOrDefault(a => a.Fzh == (string)fzh);
                }

                if (sbd == null)
                {
                    XtraMessageBox.Show("未能从列表数据中找到该分站。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //发送获取数据命令
                byte conType;
                if (sbd.DataState == "0" || sbd.DataState == "3")
                {
                    conType = 1;
                }
                else
                {
                    conType = 0;
                }

                var req = new List <StationControlItem>()
                {
                    new StationControlItem()
                    {
                        controlType = conType,
                        fzh         = Convert.ToUInt16(fzh)
                    }
                };
                ControlInterfaceFuction.SendQueryHistoryControlRequest(req);

                var allSubstation = ControlInterfaceFuction.GetAllSubstation(); //获取所有分站缓存数据
                RefSubstationConHisDataList(allSubstation);
            }
            catch (Exception exc)
            {
                XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #2
0
        //窗体关闭时
        private void Maintenance_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                //if (
                //    XtraMessageBox.Show("窗体关闭后将取消所有分站历史数据的获取,确认要执行该操作吗?", "提示", MessageBoxButtons.YesNo,
                //        MessageBoxIcon.Question) == DialogResult.Yes)
                //{
                //取消所有数据获取
                var lisSc = new List <StationControlItem>();     //5分钟历史数据和控制历史数据共用
                lock (_locker1)
                {
                    foreach (var item in _substationFiveHisDataBindDto)
                    {
                        lisSc.Add(new StationControlItem()
                        {
                            fzh         = Convert.ToUInt16(item.Fzh),
                            controlType = 2
                        });
                    }
                }
                ControlInterfaceFuction.SendQueryHistoryRealDataRequest(lisSc);
                ControlInterfaceFuction.SendQueryHistoryControlRequest(lisSc);

                //if (_refThr != null && _refThr.IsAlive == true)
                //{
                //    _refThr.Abort();
                //}
                _ifLoop = false;
                //注释,造成界面卡,就不用调用此段代码  20170811
                //if (_refThr != null && _refThr.IsAlive == true)
                //{
                //    _refThr.Join();
                //}
                //Dispose();
                //}
                //else
                //{
                //    e.Cancel = true;
                //}
            }
            catch (Exception exc)
            {
                XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }