using Yw.Hydro; namespace Yw.WinFrmUI { public partial class SetHydroMonitorAnalyseListCtrl : DevExpress.XtraEditors.XtraUserControl { public SetHydroMonitorAnalyseListCtrl() { InitializeComponent(); this.gridView1.SetNormalEditView(30); this.colRelation.OptionsColumn.AllowEdit = false; this.colPropName.OptionsColumn.AllowEdit = false; this.colUnitName.OptionsColumn.AllowEdit = false; } private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息 private Yw.Model.HydroVisualInfo _visual = null;//构件 private List _allMonitorList = null;//所有监测列表 private BindingList _allBindingList = null;//所有绑定列表 /// /// 绑定数据 /// public void SetBindingData ( Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroVisualInfo visual, List allMonitorList ) { _hydroInfo = hydroInfo; _visual = visual; _allMonitorList = allMonitorList; _allBindingList = new BindingList(); if (hydroInfo != null) { if (visual != null) { var propList = HydroMonitorPropHelper.GetPropList(visual.Catalog); var sortCode = allMonitorList == null || allMonitorList.Count < 1 ? 0 : allMonitorList.Max(x => x.SortCode); foreach (var prop in propList) { var vmo = allMonitorList? .Find(x => x.ModelID == hydroInfo.ID && x.Parter == visual.Code && x.SourceType == Yw.Hydro.eSourceType.Analyse && x.PropName == prop); if (vmo == null) { sortCode++; vmo = new HydroMonitorVmo() { ID = 0, ModelID = hydroInfo.ID, Parter = visual.Code, SourceType = Yw.Hydro.eSourceType.Analyse, PropName = prop, Flags = new List(), SortCode = sortCode, Description = string.Empty }; } var vm = new HydroMonitorAnalyseViewModel(vmo, visual); _allBindingList.Add(vm); } } } InitialFlags(); this.hydroMonitorAnalyseViewModelBindingSource.DataSource = _allBindingList; this.hydroMonitorAnalyseViewModelBindingSource.ResetBindings(false); } //初始化标签 private async void InitialFlags() { var flags = await BLLFactory.Instance.GetBySysType(Yw.Hydro.DataType.HydroMonitor); this.repositoryItemCheckedComboBoxEdit1.Items.BeginUpdate(); this.repositoryItemCheckedComboBoxEdit1.Items.Clear(); if (flags != null && flags.Count > 0) { foreach (var flag in flags) { this.repositoryItemCheckedComboBoxEdit1.Items.Add(flag.Name); } } this.repositoryItemCheckedComboBoxEdit1.Items.EndUpdate(); } /// /// 获取监测列表 /// public async Task> GetMonitorList() { if (_hydroInfo == null) { return default; } if (_visual == null) { return default; } var checkedList = _allBindingList?.Where(x => x.Checked).ToList(); checkedList?.ForEach(x => { x.Vmo.Flags = HydroFlagsHelper.ToList(x.Flags); x.Vmo.Description = x.Description; }); var vmoList = checkedList?.Select(x => x.Vmo).ToList(); var bol = await BLLFactory.Instance.Save(_hydroInfo.ID, _visual.Code, eSourceType.Analyse, vmoList); if (!bol) { TipFormHelper.ShowError("设置失败!"); return default; } TipFormHelper.ShowSucceed("设置成功!"); var monitorList = await BLLFactory.Instance.GetBySourceType(_hydroInfo.ID, _visual.Code, eSourceType.Analyse); return monitorList; } } }