UnitCheck.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* ==============================================================================
  2. * 功能描述:单位检查
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/10/23 15:08:55
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using NPOI.SS.UserModel;
  12. using SAGA.DotNetUtils.Others;
  13. using SAGA.MBI.ToolsData.CheckBase;
  14. namespace SAGA.MBI.ToolsData.ModeCheck
  15. {
  16. /// <summary>
  17. /// UnitCheck
  18. /// </summary>
  19. class UnitCheck : ModeCheckBase
  20. {
  21. public UnitCheck()
  22. {
  23. Name = "项目长度单位检查";
  24. }
  25. [DataCheckProcessAspect]
  26. public override bool Check()
  27. {
  28. if (!RBase.IsRight)
  29. {
  30. IsRight = RBase.IsRight;
  31. return IsRight;
  32. }
  33. bool unitResult = true;
  34. foreach (SagaSignCheckResult signResult in RBase.Results)
  35. {
  36. var ismmUnit = CheckDocumentData.IsLengthMMUnit(signResult.RDocument);
  37. var unitItem = new UnitCheckResult() { RBase = signResult };
  38. Results.Add(unitItem);
  39. unitItem.IsRight = ismmUnit;
  40. if (!ismmUnit)
  41. {
  42. unitItem.RMessage = "单位异常,请修改长度单位为毫米(mm)";
  43. unitResult = ismmUnit;
  44. }
  45. }
  46. IsRight = Results.All(t => t.IsRight); ;
  47. return IsRight;
  48. }
  49. public void Correct()
  50. {
  51. throw new NotImplementedException();
  52. }
  53. //[DataCheckProcessAspect]
  54. public override void Export()
  55. {
  56. //Check();
  57. IWorkbook book = DCRExport.GetWorkbook();
  58. try
  59. {
  60. //ISheet sheet = book.CreateSheet(Name);
  61. ISheet sheet = book.GetSheet(Name);
  62. #region 添加数据
  63. int index = 3;
  64. //IRow row4 = sheet.CreateRow(index);
  65. //row4.HeightInPoints = 15;
  66. //row4.AddCell(0, "楼层本地名称", DataCheckNPOIStyle.Title);
  67. //row4.AddCell(1, "文件名", DataCheckNPOIStyle.Title);
  68. //row4.AddCell(2, "文件地址", DataCheckNPOIStyle.Title);
  69. //row4.AddCell(3, "通过", DataCheckNPOIStyle.Title);
  70. //row4.AddCell(4, "备注(失败原因)", DataCheckNPOIStyle.Title);
  71. IRow rowF = null;
  72. foreach (var result in Results)
  73. {
  74. index++;
  75. DataCheckNPOIStyle style = result.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
  76. IRow rowN = sheet.CreateRow(index);
  77. SagaSignCheckResult rbase = result.RBase as SagaSignCheckResult;
  78. if (rbase == null)
  79. continue;
  80. rowN.AddCell(0, rbase.RFloorName, style);
  81. rowN.AddCell(1, rbase.RFileName, style);
  82. rowN.AddCell(2, rbase.RPath, style);
  83. string rowN4 = result.IsRight ? "通过" : "不通过";
  84. rowN.AddCell(3, rowN4, style);
  85. rowN.AddCell(4, result.RMessage, style);
  86. }
  87. #endregion
  88. }
  89. catch (Exception e)
  90. {
  91. MessageShowBase.Show(e);
  92. }
  93. }
  94. }
  95. }