FloorSequenceCheck.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* ==============================================================================
  2. * 功能描述:楼层顺序号检查
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/10/23 9:01:13
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Text.RegularExpressions;
  12. using System.Threading.Tasks;
  13. using Autodesk.Revit.DB;
  14. using Microsoft.Win32;
  15. using NPOI.SS.UserModel;
  16. using NPOI.SS.Util;
  17. using NPOI.XSSF.UserModel;
  18. using SAGA.DotNetUtils.Extend;
  19. using SAGA.DotNetUtils.Others;
  20. using SAGA.MBI.Common;
  21. using SAGA.MBI.DataArrange;
  22. using SAGA.MBI.Model;
  23. using SAGA.MBI.ToolsData.CheckBase;
  24. using SAGA.RevitUtils.Extends;
  25. namespace SAGA.MBI.ToolsData.ModeCheck
  26. {
  27. /// <summary>
  28. /// DocumentSagaSignCheck
  29. /// </summary>
  30. class FloorSequenceCheck : ModeCheckBase
  31. {
  32. public FloorSequenceCheck()
  33. {
  34. Name = "楼层标高与楼层顺序号检查";
  35. RIsNeedTwoMoreFloors = true;
  36. }
  37. [DataCheckProcessAspect]
  38. public override bool Check()
  39. {
  40. if (!RBase.IsRight)
  41. {
  42. IsRight = RBase.IsRight;
  43. return IsRight;
  44. }
  45. //检查楼层顺序号
  46. IsRight = CheckFloorSequence();
  47. Results.ForEach(t => t.IsRight = IsRight);
  48. RMessage = IsRight ? "" : "楼层文件当前层标高排序与物理世界的楼层顺序号排序规则不一致,请检查";
  49. return IsRight;
  50. }
  51. public override void Correct()
  52. {
  53. throw new NotImplementedException();
  54. }
  55. /// <summary>
  56. /// 检查楼层顺序号
  57. /// </summary>
  58. /// <returns></returns>
  59. private bool CheckFloorSequence()
  60. {
  61. bool sequenceResult = true;
  62. if (RBase.Results.Count > 1)
  63. {
  64. int count = RBase.Results.Count;
  65. for (int i = 0; i < count - 1; i++)
  66. {
  67. var item0 = RBase.Results[i] as SagaSignCheckResult;
  68. var item1 = RBase.Results[i + 1] as SagaSignCheckResult;
  69. if (item1.HBase >= item0.HBase)
  70. {
  71. sequenceResult = false;
  72. break;
  73. }
  74. }
  75. }
  76. RBase.Results.ForEach(t => Results.Add(new FloorSequenceCheckResult() { RBase = t }));
  77. return sequenceResult;
  78. }
  79. //[DataCheckProcessAspect]
  80. public override void Export()
  81. {
  82. //Check();
  83. IWorkbook book = DCRExport.GetWorkbook();
  84. try
  85. {
  86. //ISheet sheet = book.CreateSheet(Name);
  87. ISheet sheet = book.GetSheet(Name);
  88. #region 添加数据
  89. int index = 3;
  90. //IRow row4 = sheet.CreateRow(index);
  91. //row4.HeightInPoints = 15;
  92. //row4.AddCell(0, "楼层本地名称", DataCheckNPOIStyle.Title);
  93. //row4.AddCell(1, "文件名", DataCheckNPOIStyle.Title);
  94. //row4.AddCell(2, "文件地址", DataCheckNPOIStyle.Title);
  95. //row4.AddCell(3, "楼层平面视图名称", DataCheckNPOIStyle.Title);
  96. //row4.AddCell(4, "标高高度(m)", DataCheckNPOIStyle.Title);
  97. //row4.AddCell(5, "楼层顺序号", DataCheckNPOIStyle.Title);
  98. //row4.AddCell(6, "通过", DataCheckNPOIStyle.Title);
  99. //row4.AddCell(7, "备注(失败原因)", DataCheckNPOIStyle.Title);
  100. IRow rowF = null;
  101. DataCheckNPOIStyle style = this.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
  102. foreach (var result in Results)
  103. {
  104. index++;
  105. IRow rowN = sheet.CreateRow(index);
  106. //保存第一行,用于赋值
  107. if (rowF == null) rowF = rowN;
  108. SagaSignCheckResult rbase = result.RBase as SagaSignCheckResult;
  109. if (rbase == null)
  110. continue;
  111. rowN.AddCell(0, rbase.RFloorName, style);
  112. rowN.AddCell(1, rbase.RFileName, style);
  113. rowN.AddCell(2, rbase.RPath, style);
  114. rowN.AddCell(3, rbase.RPlanName, style);
  115. rowN.AddCell(4, rbase.HBase.FromApi().MmToM().ToString("f2"), style);
  116. rowN.AddCell(5, rbase.RSequence.ToString(), style);
  117. }
  118. if (rowF != null)
  119. {
  120. int sindex = rowF.RowNum;
  121. //合并单元格
  122. sheet.MarginCellAndBorder(sindex, index, 6, 6);
  123. sheet.MarginCellAndBorder(sindex, index, 7, 7);
  124. string rowF6 = this.IsRight ? "通过" : "不通过";
  125. rowF.AddCell(6, rowF6, style, true);
  126. rowF.AddCell(7, this.RMessage, style, true);
  127. }
  128. #endregion
  129. }
  130. catch (Exception e)
  131. {
  132. MessageShowBase.Show(e);
  133. }
  134. }
  135. }
  136. }