lixiaojun
2024-09-26 9c8743941f556a486ba2cc5bcb8a7a6ec1079d0a
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-AutoMatching/AssetsMainChoicePage.cs
@@ -5,7 +5,22 @@
        public AssetsMainChoicePage()
        {
            InitializeComponent();
            this.elbowsMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.fourLinkMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.pipeLineMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.pumpMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.threeLinkMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.valveMatchingCtrl1.RowClickEvent += RowClickEvent;
        }
        private void RowClickEvent(string code)
        {
            FormRowClickEvent.Invoke(code);
        }
        public event Action<string> FormRowClickEvent = null;
        public event Func<AssetsAutoMatchingViewModel, bool> RelaodEvent = null;
        private BLL.PumpMain _pumpMain = null;
@@ -15,21 +30,27 @@
        private BLL.ValveMain _valveMain = null;
        public void SetBindingData(AssetsAutoMatchingInputViewModel inputViewModel)
        private AssetsAutoMatchingViewModel _assetsAutoMatching = null;
        public async void SetBindingData(AssetsAutoMatchingViewModel inputViewModel)
        {
            _assetsAutoMatching = inputViewModel;
            this.elbowsMatchingCtrl1.SetBindingData(inputViewModel.ElbowsMatchingModels);
            this.pipeLineMatchingCtrl1.SetBindingData(inputViewModel.PipeLineMatchingModels);
            this.pumpMatchingCtrl1.SetBindingData(inputViewModel.PumpMatchingModels);
            this.threeLinkMatchingCtrl1.SetBindingData(inputViewModel.ThreeLinkMatchingModels);
            this.fourLinkMatchingCtrl1.SetBindingData(inputViewModel.FourLinkMatchingModels);
            this.valveMatchingCtrl1.SetBindingData(inputViewModel.ValveMatchingModels);
            await SetMatching(inputViewModel);
        }
        /// <summary>
        /// 初始化
        /// 自动匹配
        /// </summary>
        public async Task<AssetsAutoMatchingInputViewModel> SetMatching(AssetsAutoMatchingInputViewModel input)
        public async Task<AssetsAutoMatchingViewModel> SetMatching(AssetsAutoMatchingViewModel input)
        {
            if (input == null)
                return null;
            _pumpMain = new BLL.PumpMain();
            _adaptingManage = new BLL.AdaptingManage();
            _pipeLineManage = new BLL.PipeLineManage();
@@ -38,7 +59,7 @@
            var allAdapting = await _adaptingManage.GetAll();
            var allPipeLine = await _pipeLineManage.GetAll();
            var allValve = await _valveMain.GetAll();
            var assetsAutoMatching = new AssetsAutoMatchingInputViewModel();
            var assetsAutoMatching = new AssetsAutoMatchingViewModel();
            //泵匹配
            var pumpMatching = await this.pumpMatchingCtrl1.SetMatching(input.PumpMatchingModels, allPump);
            //三通匹配
@@ -46,12 +67,32 @@
            //四通匹配
            var fourLinkMatching = this.fourLinkMatchingCtrl1.SetMatching(input.FourLinkMatchingModels, allAdapting);
            //管道匹配
            var PipeLineMatching = this.pipeLineMatchingCtrl1.SetMatching(input.PipeLineMatchingModels, allPipeLine);
            var pipeLineMatching = this.pipeLineMatchingCtrl1.SetMatching(input.PipeLineMatchingModels, allPipeLine);
            //阀门匹配
            var ValveMatching = this.valveMatchingCtrl1.SetMatching(input.ValveMatchingModels, allValve);
            var valveMatching = this.valveMatchingCtrl1.SetMatching(input.ValveMatchingModels, allValve);
            //弯头匹配
            var elbowsMatching = this.elbowsMatchingCtrl1.SetMatching(input.ElbowsMatchingModels, allAdapting);
            assetsAutoMatching.PumpMatchingModels = pumpMatching;
            assetsAutoMatching.ThreeLinkMatchingModels = threeLinkMatching;
            assetsAutoMatching.FourLinkMatchingModels = fourLinkMatching;
            assetsAutoMatching.ElbowsMatchingModels = elbowsMatching;
            assetsAutoMatching.PipeLineMatchingModels = pipeLineMatching;
            assetsAutoMatching.ValveMatchingModels = valveMatching;
            return assetsAutoMatching;
        }
        //确定
        private void btnComplete_Click(object sender, EventArgs e)
        {
            if (RelaodEvent.Invoke(_assetsAutoMatching))
            {
                TipFormHelper.ShowSucceed("修改成功!");
            }
            else
            {
                TipFormHelper.ShowError("修改失败!");
            }
        }
    }
}