using DevExpress.Utils; using DevExpress.XtraTreeList; using HStation.WinFrmUI.Xhs; using Timer = System.Threading.Timer; namespace HStation.WinFrmUI { public partial class XhsProjectMgrPage : DocumentPage { public XhsProjectMgrPage() { InitializeComponent(); this.treeList1.InitialMultiColSettings(); this.treeList1.Appearance.Row.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Default; this.PageTitle.Caption = "项目管理"; this.PageTitle.HeaderSvgImage = this.svgImg32[0]; this.PageTitle.SvgImageSize = new Size(24, 24); this.Load += XhsProjectMgrPage_Load; } private void XhsProjectMgrPage_Load(object sender, EventArgs e) { repositoryItemImageComboBox1.Items.AddEnum(typeof(eXhsProjectStatus)); repositoryItemImageComboBox1.Items[0].ImageIndex = 0; repositoryItemImageComboBox1.Items[1].ImageIndex = 1; repositoryItemImageComboBox1.Items[2].ImageIndex = 2; repositoryItemImageComboBox1.Items[3].ImageIndex = 3; repositoryItemImageComboBox1.Items[4].ImageIndex = 4; repositoryItemImageComboBox1.Items[5].ImageIndex = 5; repositoryItemImageComboBox1.Items[6].ImageIndex = 6; repositoryItemImageComboBox1.Items[7].ImageIndex = 7; repositoryItemImageComboBox1.Items[8].ImageIndex = 8; } private List _allBindingList = null; private BLL.XhsProjectExtensions _bll = null; private event Action ImportProjectCompletedEvent = null; /// /// 初始化数据源 /// public override void InitialDataSource() { base.InitialDataSource(); InitialData(); } //初始化数据 private async void InitialData() { var overlay = this.ShowOverlay(); _allBindingList = new List(); var allProjectList = await BLLFactory.Instance.GetAll(); if (allProjectList != null && allProjectList.Count > 0) { foreach (var project in allProjectList) { var mapInfo = await BLLFactory.Instance .Get(HStation.Xhs.DataType.XhsProject, project.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location); Yw.Vmo.BimfaceFileVmo bimfaceFile = null; var projectSite = project.SiteList?.FirstOrDefault(); if (projectSite != null) { var bimfaceFileRelation = await BLLFactory.Instance .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, projectSite.ID, HStation.Xhs.Purpose.Simulation); ; if (bimfaceFileRelation != null) { bimfaceFile = await BLLFactory.Instance .GetByID(bimfaceFileRelation.BimfaceFileID); } } var vm = new XhsProjectMgrViewModel(project, mapInfo, bimfaceFile); _allBindingList.Add(vm); } } this.xhsProjectMgrViewModelBindingSource.DataSource = _allBindingList; this.xhsProjectMgrViewModelBindingSource.ResetBindings(false); overlay.Close(); } #region 当前 //获取当前 private XhsProjectMgrViewModel GetCurrentViewModel() { //if (_allProjectList == null) //{ // Yw.WinFrmUI.MessageBoxHelper.ShowError("数据初始化错误!"); // return null; //} //if (_allProjectList == null) //{ // Yw.WinFrmUI.MessageBoxHelper.ShowInfo("无数据"); // return null; //} //var vm = this.treeList1.GetCurrentViewModel(_allProjectList); //if (vm == null) //{ // Yw.WinFrmUI.MessageBoxHelper.ShowInfo("请选择数据行!"); // return null; //} //return vm; return default; } #endregion 当前 #region 基础操作 //添加 private void barBtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //var dlg = new ImportXhsProjectDlg(); //dlg.SetBindingData(); //if (dlg.ShowDialog() == DialogResult.OK) //{ // var prj = dlg.ViewModel; // if (prj.ProjectID == null) // return; // var vmo = await _bll.GetByID((long)prj.ProjectID); // if (vmo == null) // { // TipFormHelper.ShowError("导入失败!"); // return; // } // else // { // TipFormHelper.ShowSucceed("导入成功!"); // var mapinfo = await new Yw.BLL.MapInfo().Get(HStation.Xhs.DataType.XhsProject, (long)prj.ProjectID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location); // var bimFile = await BimfaceFileStateHelper.IsHaveBimFace((long)prj.ProjectID); // if (bimFile != null) // { // _allProjectList.Add(new XhsProjectMgrViewModel(vmo, true, bimFile.FileStatus, mapinfo)); // } // else // { // _allProjectList.Add(new XhsProjectMgrViewModel(vmo, false, 8, mapinfo)); // } // this.xhsProjectMgrViewModelBindingSource.ResetBindings(false); // } //} } //编辑 private void barBtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //var currentVm = this.GetCurrentViewModel(); //if (currentVm == null) //{ // MessageBoxHelper.ShowWarning("请选择数据行!"); // return; //} //var dlg = new EditProjectDlg(); //dlg.SetBindingData(currentVm.ID); //dlg.ReloadDataEvent += async (rhs, mapinfo) => //{ // if (await _bll.Update(rhs)) // { // currentVm.Reset(rhs); // this.xhsProjectMgrViewModelBindingSource.ResetBindings(false); // if (mapinfo != null) // { // // mapinfo.ObjectID = id; // mapinfo.ObjectName = rhs.Name; // var bol = await new Yw.BLL.MapInfo().Update(mapinfo); // if (!bol) // { // TipFormHelper.ShowError("地图信息编辑错误"); // } // } // return true; // } // return false; //}; //dlg.ShowDialog(); } //删除 private async void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var vm = this.treeList1.GetCurrentViewModel(_allBindingList); if (vm == null) { TipFormHelper.ShowWarn("请选择项目!"); return; } var result = XtraMessageBox.Show("是否确认删除此项目?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes; if (!result) { return; } if (vm.Project.SiteList != null && vm.Project.SiteList.Count > 0) { foreach (var projectSite in vm.Project.SiteList) { var allSchemeList = await BLLFactory.Instance.GetBySiteID(projectSite.ID); if (allSchemeList != null && allSchemeList.Count > 0) { foreach (var scheme in allSchemeList) { var schemeRelation = await BLLFactory.Instance .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsScheme, scheme.ID, HStation.Xhs.Purpose.Simulation); if (schemeRelation != null) { if (!await BLLFactory.Instance.DeleteAllByID(schemeRelation.ID)) { TipFormHelper.ShowError("项目方案模型删除失败,请重试!"); return; } } if (!await BLLFactory.Instance.DeleteByID(scheme.ID)) { TipFormHelper.ShowError("项目方案删除失败,请重试!"); return; } } } var bimfaceFileRelation = await BLLFactory.Instance .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, projectSite.ID, HStation.Xhs.Purpose.Simulation); if (bimfaceFileRelation != null) { if (!await BLLFactory.Instance.DeleteAllByID(bimfaceFileRelation.ID)) { TipFormHelper.ShowError("项目三维模型删除失败,请重试!"); return; } } var hydroRelation = await BLLFactory.Instance .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, projectSite.ID, HStation.Xhs.Purpose.Simulation); if (hydroRelation != null) { if (!await BLLFactory.Instance.DeleteAllByID(hydroRelation.ID)) { TipFormHelper.ShowError("项目模型删除失败,请重试!"); return; } } if (!await BLLFactory.Instance.DeleteByID(projectSite.ID)) { TipFormHelper.ShowError("项目站删除失败,请重试!"); return; } } } if (vm.MapInfo != null) { if (!await BLLFactory.Instance.DeleteByObjectTypeAndObjectID(HStation.Xhs.DataType.XhsProject, vm.Project.ID)) { TipFormHelper.ShowError("项目地图位置删除失败,请重试!"); return; } } var bol = await BLLFactory.Instance.DeleteByID(vm.Project.ID); if (!bol) { TipFormHelper.ShowError("项目删除失败,请重试!"); return; } _allBindingList.Remove(vm); this.xhsProjectMgrViewModelBindingSource.ResetBindings(false); TipFormHelper.ShowSucceed("项目删除成功!"); } //详细信息 private void barBtnInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { } #endregion 基础操作 private void treeList1_CustomDrawRow(object sender, DevExpress.XtraTreeList.CustomDrawRowEventArgs e) { var a = repositoryItemButtonEdit1.ReadOnly = true; } private async void treeList1_RowCellClick(object sender, RowCellClickEventArgs e) { //if (_allProjectList == null || _allProjectList.Count < 1) // return; //var vm = GetCurrentViewModel(); //if (vm == null) //{ // return; //} //if (e.Column != this.ColViewBimface) // return; //if (!vm.IsHaveBimface) //{ // TipFormHelper.ShowWarn("请先上传文件再进行操作!"); // return; //} //var guid = new PageGuid() //{ // Modular = Yw.WinFrmUI.PageModular.Bimface, // MoudingType = Yw.WinFrmUI.Page.eMoudingType.Tab, // Function = Yw.WinFrmUI.PageFunction.ViewSchemeMgr, // TagName = $"{vm.ID}" //}; //if (!IsExistPage(guid, true)) //{ // var page = new XhsProjectSimulationMgrPage(); // await page.SetBindingData(vm.ID); // CreatePage(page, guid); //} } #region 更多操作 //全部展开 private void barBtnExpandAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.treeList1.ExpandAll(); } //全部折叠 private void barBtnCollpseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.treeList1.CollapseAll(); } /// /// 树线 /// private void barCkTreeLine_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.treeList1.OptionsView.ShowTreeLines = this.barCkTreeLine.Checked ? DefaultBoolean.True : DefaultBoolean.False; } //查询 private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.treeList1.OptionsFind.AlwaysVisible = !this.treeList1.OptionsFind.AlwaysVisible; } //刷新 private void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // this.SetBindingData(); } #endregion 更多操作 //查看bimface模型 private async void barBtnViewBimface_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //var vm = GetCurrentViewModel(); //if (vm == null) //{ // return; //} //if (!vm.IsHaveBimface) //{ // TipFormHelper.ShowWarn("请先上传文件再进行操作!"); // return; //} //var guid = new PageGuid() //{ // Modular = Yw.WinFrmUI.PageModular.Bimface, // MoudingType = Yw.WinFrmUI.Page.eMoudingType.Tab, // Function = Yw.WinFrmUI.PageFunction.ViewBimface3d, // TagName = $"{vm.ID}" //}; //if (!IsExistPage(guid, true)) //{ // var page = new ViewXhsProjectBimfacePage(); // await page.SetBindingData(vm.ID); // CreatePage(page, guid); //} } //查看水力模型 private void barBtnViewHydro_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //if (_allProjectList == null || _allProjectList.Count < 1) // return; //var vm = GetCurrentViewModel(); //if (vm == null) //{ // return; //} //if (!vm.IsHaveBimface) //{ // TipFormHelper.ShowWarn("请先上传文件再进行操作!"); // return; //} //var guid = new PageGuid() //{ // Modular = "Hydro", // MoudingType = Yw.WinFrmUI.Page.eMoudingType.Tab, // Function = "ViewModel", //}; //if (!IsExistPage(guid, true)) //{ // var page = new HydroQ3dViewPage(); // page.SetBindingData(vm.ID); // CreatePage(page, guid); // } } //导入文件 private void BtnAddBimfaceFile_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //var currentVm = this.GetCurrentViewModel(); //if (currentVm == null) //{ // MessageBoxHelper.ShowWarning("请选择数据行!"); // return; //} //if (currentVm.ModelState != XhsProjectMgrViewModel.eFileStatus.Noupload) //{ // MessageBoxHelper.ShowWarning("已经存在模型文件!"); // return; //} //var dlg = new ImportXhsProjectFileDlg(); //dlg.SetBindingData(currentVm.ID); //if (dlg.ShowDialog() == DialogResult.OK) //{ // var prj = dlg.ViewModel; // if (prj.ProjectID == null) // return; // var mapinfo = await new Yw.BLL.MapInfo().Get(HStation.Xhs.DataType.XhsProject, (long)prj.ProjectID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location); // var bimFile = await BimfaceFileStateHelper.IsHaveBimFace((long)prj.ProjectID); // if (bimFile != null) // { // currentVm.Reset(currentVm, bimFile.FileStatus); // this.xhsProjectMgrViewModelBindingSource.ResetBindings(false); // } //} } } }