lixiaojun
2024-11-25 839d9f96be96108dc9ca9359b3db32596e7e2454
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
@@ -1,5 +1,6 @@
using DevExpress.XtraBars.Docking;
using DevExpress.XtraBars.Docking2010.Views;
using Yw.Vmo;
using Yw.WinFrmUI.Page;
namespace HStation.WinFrmUI
@@ -13,24 +14,67 @@
            this.PageTitle.HeaderSvgImage = this.svgImg32[0];
            this.PageTitle.SvgImageSize = new Size(24, 24);
            //this.xhsProjectSimulationFunctionMgrCtrl1.ProjectSiteSelectedChangedEvent += xhsProjectSimulationFunctionMgrCtrl1_ProjectSiteSelectedChangedEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectInfoEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectInfoEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectSimulationEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSimulationEvent;
            // this.xhsProjectSimulationFunctionMgrCtrl1.CreateXhsProjectSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CreateXhsProjectSchemeEvent;
            //this.xhsProjectSimulationFunctionMgrCtrl1.CompareXhsProjectSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CompareXhsProjectSchemeEvent;
            PumpFullInfoViewDlg.JumpPumpFullInfoCtrl += ShowPumpInfo;
            this.xhsProjectSimulationFunctionMgrCtrl1.CreateProjectSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CreateProjectSchemeEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSchemeEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.CompareProjectWorkingEvent += XhsProjectSimulationFunctionMgrCtrl1_CompareProjectWorkingEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectWorkingEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectWorkingEvent;
        }
        private XhsProjectVmo _project = null;//项目
        private XhsProjectSiteVmo _projectSite = null;//项目站
        private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
        private List<HydroWorkingVmo> _allWorkingList = null;//所有工况列表
        private Dictionary<XhsSchemeVmo, List<HydroWorkingVmo>> _allSchemeWorkingDict = null;//所有方案工况字典
        private object _locker = new object();//锁定对象
        /// <summary>
        /// 初始化数据源
        /// </summary>
        public override void InitialDataSource()
        public override async void InitialDataSource()
        {
            base.InitialDataSource();
            if (_project == null)
            {
                return;
            }
            var overlay = this.ShowOverlay();
            _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
            var relation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                  .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
            if (relation == null)
            {
                return;
            }
            _allWorkingList = await BLLFactory<Yw.BLL.HydroWorking>.Instance.GetByModelID(relation.ModelID);
            if (_allWorkingList == null)
            {
                _allWorkingList = new List<HydroWorkingVmo>();
            }
            _allSchemeWorkingDict = new Dictionary<XhsSchemeVmo, List<HydroWorkingVmo>>();
            var allSchemeList = await BLLFactory<HStation.BLL.XhsScheme>.Instance.GetBySiteID(_projectSite.ID);
            if (allSchemeList != null && allSchemeList.Count > 0)
            {
                foreach (var scheme in allSchemeList)
                {
                    var schemeRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                    .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsScheme, scheme.ID, HStation.Xhs.Purpose.Simulation);
                    if (schemeRelation != null)
                    {
                        var allSchemeWorkingList = await BLLFactory<Yw.BLL.HydroWorking>.Instance.GetByModelID(schemeRelation.ModelID);
                        if (allSchemeWorkingList == null)
                        {
                            allSchemeWorkingList = new List<HydroWorkingVmo>();
                        }
                        _allSchemeWorkingDict.Add(scheme, allSchemeWorkingList);
                    }
                }
            }
            this.xhsProjectSimulationFunctionMgrCtrl1.SetBindingData(_project, _projectSite, _allWorkingList, _allSchemeWorkingDict);
            overlay.Close();
        }
        /// <summary>
@@ -39,13 +83,13 @@
        public async Task SetBindingData(long projectId)
        {
            _project = await BLLFactory<HStation.BLL.XhsProject>.Instance.GetByID(projectId);
            await SetBindingData(_project);
            SetBindingData(_project);
        }
        /// <summary>
        /// 设置数据
        /// </summary>
        public async Task SetBindingData(XhsProjectVmo project)
        public void SetBindingData(XhsProjectVmo project)
        {
            if (project == null)
            {
@@ -53,70 +97,59 @@
            }
            _project = project;
            this.PageTitle.Caption = $"{_project.Name}\r\n项目模拟";
            _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
            var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                  .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
            _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
            this.xhsProjectSimulationFunctionMgrCtrl1.SetBindingData(_project, _projectSite);
            //this.xhsProjectSimulationFunctionTreeCtrl1.SetBindingData(list);
            // await this.xhsProjectSimulationFunctionMgrCtrl1.SetBindingData(_project);
        }
        #region 功能面板
        //项目站选择改变事件
        private async void xhsProjectSimulationFunctionMgrCtrl1_ProjectSiteSelectedChangedEvent(XhsProjectSiteVmo obj)
        {
            _projectSite = obj;
            if (_projectSite != null)
            {
                var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                   .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
                _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
                //this.xhsProjectSimulationFunctionMgrCtrl1.ResetBindingData();
            }
        }
        //显示项目信息事件
        private async void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectInfoEvent(DevExpress.Utils.Svg.SvgImage obj)
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectInfoEvent(DevExpress.Utils.Svg.SvgImage svgImage)
        {
            var guid = new PageGuid()
            lock (_locker)
            {
                Modular = this.PageGuid.Modular,
                MoudingType = eMoudingType.Tab,
                Function = "xhs-project-simulation-info",
            };
            if (!IsExistPage(guid, true))
            {
                var page = new XhsProjectSimulationInfoPage();
                await page.SetBindingData(_project, _projectSite, _hydroInfo);
                CreatePage(page, guid);
                var guid = new PageGuid()
                {
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Info,
                };
                if (!IsExistPage(guid, true))
                {
                    var page = new XhsProjectSimulationInfoPage();
                    page.PageTitle.HeaderSvgImage = svgImage;
                    page.SetBindingData(_project, _projectSite);
                    CreatePage(page, guid);
                }
            }
        }
        //显示水力模拟事件
        private async void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSimulationEvent(DevExpress.Utils.Svg.SvgImage obj)
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSimulationEvent(DevExpress.Utils.Svg.SvgImage svgImage)
        {
            var guid = new PageGuid()
            lock (_locker)
            {
                Modular = this.PageGuid.Modular,
                MoudingType = eMoudingType.Tab,
                Function = "xhs-project-simulation-core",
            };
            if (!IsExistPage(guid, true))
            {
                var page = new XhsProjectSimulationCorePage();
                await page.SetBindingData(_project, _projectSite, _hydroInfo);
                CreatePage(page, guid);
                var guid = new PageGuid()
                {
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Simulation,
                };
                if (!IsExistPage(guid, true))
                {
                    var page = new XhsProjectSimulationCorePage();
                    page.PageTitle.HeaderSvgImage = svgImage;
                    page.AppendWorkingEvent += (working) =>
                    {
                        _allWorkingList.Add(working);
                        this.xhsProjectSimulationFunctionMgrCtrl1.AppendWorking(working);
                    };
                    page.SetBindingData(_project, _projectSite, _allWorkingList);
                    CreatePage(page, guid);
                }
            }
        }
        //创建项目方案事件
        private async void XhsProjectSimulationFunctionMgrCtrl1_CreateXhsProjectSchemeEvent(DevExpress.Utils.Svg.SvgImage obj)
        private async void XhsProjectSimulationFunctionMgrCtrl1_CreateProjectSchemeEvent(DevExpress.Utils.Svg.SvgImage svgImage)
        {
            if (_projectSite == null)
            {
@@ -131,14 +164,23 @@
            //dlg.ShowDialog();
            var dlg = new AddXhsSchemeDlg();
            await dlg.SetBindingData(_project, _projectSite, _hydroInfo);
            // await dlg.SetBindingData(_project, _projectSite, _hydroInfo);
            dlg.ShowDialog();
        }
        //比较项目方案事件
        private void XhsProjectSimulationFunctionMgrCtrl1_CompareXhsProjectSchemeEvent(DevExpress.Utils.Svg.SvgImage obj)
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSchemeEvent(XhsSchemeVmo arg1, DevExpress.Utils.Svg.SvgImage arg2)
        {
            TipFormHelper.ShowWarn("正在开发中,敬请期待...");
            throw new NotImplementedException();
        }
        private void XhsProjectSimulationFunctionMgrCtrl1_CompareProjectWorkingEvent(DevExpress.Utils.Svg.SvgImage obj)
        {
            throw new NotImplementedException();
        }
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectWorkingEvent(HydroWorkingVmo arg1, DevExpress.Utils.Svg.SvgImage arg2)
        {
            throw new NotImplementedException();
        }
        #endregion 功能面板
@@ -424,18 +466,5 @@
        #endregion Page
        private void ShowPumpInfo(PumpFullInfoCtrl pumpFullInfoCtrl)
        {
            var guid = new PageGuid()
            {
                Modular = this.PageGuid.Modular,
                MoudingType = eMoudingType.Tab,
                Function = "xhs-project-pump-info",
            };
            if (!IsExistPage(guid, true))
            {
                CreatePage(pumpFullInfoCtrl, guid);
            }
        }
    }
}