using DevExpress.XtraEditors; using ExtensionsDev; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DW5S.Entity; using DW5S.Repostory; using Serilog; using DW5S.Service; using DW5S.ViewModel; namespace DW5S.App.PopupControl { public partial class ShowCgCtrl : DevExpress.XtraEditors.XtraUserControl { PosResViewModel posItem; List listCg = new List(); List listXgf = new List(); public ShowCgCtrl() { InitializeComponent(); this.layoutControl1.UseDefault(); gridShowCg.UseDefault(listCg); gridCgXgf.UseDefault(listXgf).UseRowNumber(); } public ShowCgCtrl(PosResViewModel posItem) : this() { this.posItem = posItem; } private async void ShowCgCtrl_Load(object sender, EventArgs e) { List sats = null; var unitOfWork = IocContainer.UnitOfWork; var repsSat = unitOfWork.Of(); sats = (await repsSat.GetAllAsync()).ToList(); List list = new List(); var repsCg = unitOfWork.OfLong(); var repsPos = IocContainer.UnitOfWork.OfLong(); var pos = await repsPos.GetByIdAsync(this.posItem.Id); var cgEntity = await repsCg.FirstOrDefaultAsync(p => p.Id == pos.CgResID); if (cgEntity == null) return; //主邻1 { list.Add(new CgResViewModel { Id = cgEntity.Id, CreateTime = cgEntity.CreateTime, UpdateTime = cgEntity.UpdateTime, SigTime = cgEntity.SigTime, AdjaCode = cgEntity.Adja1Code, AdjaXlTime = cgEntity.Adja1XlTime, Dto = cgEntity.Dto1, FreqdownMHz = Math.Round(cgEntity.FreqdownHz / 1e6, 3), FrequpMHz = Math.Round(cgEntity.FrequpHz / 1e6, 3), MainXlTime = cgEntity.MainXlTime, TaskID = cgEntity.TaskID, Dfo = cgEntity.Dfo1, Snr = cgEntity.Snr1, MainCode = cgEntity.MainCode, }); } if (cgEntity.Adja2Code != null) { //主邻2 list.Add(new CgResViewModel { Id = cgEntity.Id, CreateTime = cgEntity.CreateTime, UpdateTime = cgEntity.UpdateTime, SigTime = cgEntity.SigTime, AdjaCode = cgEntity.Adja2Code.Value, AdjaXlTime = null, Dto = cgEntity.Dto2.Value, FreqdownMHz = Math.Round(cgEntity.FreqdownHz / 1e6, 3), FrequpMHz = Math.Round(cgEntity.FrequpHz / 1e6, 3), MainXlTime = cgEntity.MainXlTime, TaskID = cgEntity.TaskID, Dfo = cgEntity.Dfo2.Value, Snr = cgEntity.Snr2.Value, MainCode = cgEntity.MainCode, }); } this.listCg.Clear(); this.listCg.AddRange(list); } private async void gridView1_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e) { listXgf.Clear(); var cgItem = e.Row as CgResViewModel; if (cgItem != null) { var unitOfWork = IocContainer.UnitOfWork; var repsCgXgf = unitOfWork.OfLong(); var data = await repsCgXgf.FindAsync(p => p.CgResID == cgItem.Id); listXgf.AddRange(data.Select(p => new CgXgfViewModel { Id = p.Id, Dto = p.Dto, Dfo = p.Dfo, Snr = p.Snr, CreateTime = p.CreateTime, UpdateTime = p.UpdateTime, })); //查询相关峰结果 } this.gridView2.RefreshData(); } } }