ShowCgCtrl.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using DevExpress.XtraEditors;
  2. using ExtensionsDev;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using DW5S.App.Model;
  13. using DW5S.Entity;
  14. using DW5S.Repostory;
  15. namespace DW5S.App.PopupControl
  16. {
  17. public partial class ShowCgCtrl : DevExpress.XtraEditors.XtraUserControl
  18. {
  19. PosRes posItem;
  20. List<ModelCg> listCg = new List<ModelCg>();
  21. List<ModelCgXgf> listXgf = new List<ModelCgXgf>();
  22. public ShowCgCtrl()
  23. {
  24. InitializeComponent();
  25. this.layoutControl1.UseDefault();
  26. gridShowCg.UseDefault(listCg);
  27. gridCgXgf.UseDefault(listXgf).UseRowNumber();
  28. }
  29. public ShowCgCtrl(PosRes posItem)
  30. : this()
  31. {
  32. this.posItem = posItem;
  33. }
  34. private async void ShowCgCtrl_Load(object sender, EventArgs e)
  35. {
  36. List<SatInfo> sats = null;
  37. using (RHDWContext db = new RHDWContext())
  38. {
  39. sats = await db.SatInfos.ToListAsync();
  40. }
  41. List<ModelCg> list = new List<ModelCg>();
  42. using (RHDWPartContext db = RHDWPartContext.GetContext(posItem.SigTime))
  43. {
  44. if (db == null) return;
  45. var cgEntity = db.CgRes.Where(p => p.ID == posItem.CgResID).FirstOrDefault();
  46. if (cgEntity == null) return;
  47. //主邻1
  48. if (cgEntity.Adja1Code != null)
  49. {
  50. ModelCg item = new ModelCg()
  51. {
  52. ID = cgEntity.ID,
  53. CreateTime = cgEntity.CreateTime,
  54. UpdateTime = cgEntity.UpdateTime,
  55. SigTime = cgEntity.SigTime,
  56. Dto = cgEntity.Dto1,
  57. Dfo = cgEntity.Dfo1,
  58. Snr = cgEntity.Snr1,
  59. MainSat = cgEntity.MainCode?.ToString(),
  60. AdjaSat = cgEntity.Adja1Code.ToString(),
  61. CgType = 0,
  62. };
  63. var find = sats.Find(p => p.SatCode == cgEntity.MainCode.Value);
  64. if (find != null)
  65. item.MainSat = find.Sat;
  66. find = sats.Find(p => p.SatCode == cgEntity.Adja1Code.Value);
  67. if (find != null)
  68. item.AdjaSat = find.Sat;
  69. list.Add(item);
  70. }
  71. //主邻2
  72. if (cgEntity.Adja2Code != null)
  73. {
  74. ModelCg item = new ModelCg()
  75. {
  76. ID = cgEntity.ID,
  77. CreateTime = cgEntity.CreateTime,
  78. UpdateTime = cgEntity.UpdateTime,
  79. SigTime = cgEntity.SigTime,
  80. Dto = cgEntity.Dto2,
  81. Dfo = cgEntity.Dfo2,
  82. Snr = cgEntity.Snr2,
  83. MainSat = cgEntity.MainCode?.ToString(),
  84. AdjaSat = cgEntity.Adja2Code.ToString(),
  85. CgType = 1,
  86. };
  87. var find = sats.Find(p => p.SatCode == cgEntity.MainCode.Value);
  88. if (find != null)
  89. item.MainSat = find.Sat;
  90. find = sats.Find(p => p.SatCode == cgEntity.Adja2Code.Value);
  91. if (find != null)
  92. item.AdjaSat = find.Sat;
  93. list.Add(item);
  94. }
  95. //超短
  96. if (cgEntity.DtoCdb != null)
  97. {
  98. ModelCg item = new ModelCg()
  99. {
  100. ID = cgEntity.ID,
  101. CreateTime = cgEntity.CreateTime,
  102. UpdateTime = cgEntity.UpdateTime,
  103. SigTime = cgEntity.SigTime,
  104. Dto = cgEntity.DtoCdb,
  105. Dfo = cgEntity.DfoCdb,
  106. Snr = cgEntity.SnrCdb,
  107. MainSat = cgEntity.MainCode?.ToString(),
  108. AdjaSat = "超短站",
  109. CgType = 2,
  110. };
  111. var find = sats.Find(p => p.SatCode == cgEntity.MainCode.Value);
  112. if (find != null)
  113. item.MainSat = find.Sat;
  114. list.Add(item);
  115. }
  116. }
  117. this.listCg.Clear();
  118. this.listCg.AddRange(list);
  119. }
  120. private async void gridView1_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
  121. {
  122. listXgf.Clear();
  123. var cgItem = e.Row as ModelCg;
  124. if (cgItem != null)
  125. {
  126. using (RHDWPartContext db = RHDWPartContext.GetContext(cgItem.SigTime))
  127. {
  128. if (db != null)
  129. {
  130. var data = await db.CgXgfRes.Where(p => p.CgResID == cgItem.ID && p.CgType == cgItem.CgType).ToListAsync();
  131. listXgf.AddRange(data.Select(p => new ModelCgXgf
  132. {
  133. ID = p.ID,
  134. Dto = p.Dto,
  135. Dfo = p.Dfo,
  136. Snr = p.Snr,
  137. CreateTime = p.CreateTime,
  138. UpdateTime = p.UpdateTime,
  139. }));
  140. }
  141. }
  142. //查询相关峰结果
  143. }
  144. this.gridView2.RefreshData();
  145. }
  146. }
  147. }