| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- /* ==============================================================================
- * 功能描述:楼层顺序号检查
- * 创 建 者:Garrett
- * 创建日期:2018/10/23 9:01:13
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using Autodesk.Revit.DB;
- using Microsoft.Win32;
- using NPOI.SS.UserModel;
- using NPOI.SS.Util;
- using NPOI.XSSF.UserModel;
- using SAGA.DotNetUtils.Extend;
- using SAGA.DotNetUtils.Others;
- using SAGA.MBI.Common;
- using SAGA.MBI.DataArrange;
- using SAGA.MBI.Model;
- using SAGA.MBI.ToolsData.CheckBase;
- using SAGA.RevitUtils.Extends;
- namespace SAGA.MBI.ToolsData.ModeCheck
- {
- /// <summary>
- /// DocumentSagaSignCheck
- /// </summary>
- class FloorSequenceCheck : ModeCheckBase
- {
- public FloorSequenceCheck()
- {
- Name = "楼层标高与楼层顺序号检查";
- RIsNeedTwoMoreFloors = true;
- }
- [DataCheckProcessAspect]
- public override bool Check()
- {
- if (!RBase.IsRight)
- {
- IsRight = RBase.IsRight;
- return IsRight;
- }
- //检查楼层顺序号
- IsRight = CheckFloorSequence();
- Results.ForEach(t => t.IsRight = IsRight);
- RMessage = IsRight ? "" : "楼层文件当前层标高排序与物理世界的楼层顺序号排序规则不一致,请检查";
- return IsRight;
- }
- public override void Correct()
- {
- throw new NotImplementedException();
- }
- /// <summary>
- /// 检查楼层顺序号
- /// </summary>
- /// <returns></returns>
- private bool CheckFloorSequence()
- {
- bool sequenceResult = true;
- if (RBase.Results.Count > 1)
- {
- int count = RBase.Results.Count;
- for (int i = 0; i < count - 1; i++)
- {
- var item0 = RBase.Results[i] as SagaSignCheckResult;
- var item1 = RBase.Results[i + 1] as SagaSignCheckResult;
- if (item1.HBase >= item0.HBase)
- {
- sequenceResult = false;
- break;
- }
- }
- }
- RBase.Results.ForEach(t => Results.Add(new FloorSequenceCheckResult() { RBase = t }));
- return sequenceResult;
- }
- //[DataCheckProcessAspect]
- public override void Export()
- {
- //Check();
- IWorkbook book = DCRExport.GetWorkbook();
- try
- {
- //ISheet sheet = book.CreateSheet(Name);
- ISheet sheet = book.GetSheet(Name);
- #region 添加数据
- int index = 3;
- //IRow row4 = sheet.CreateRow(index);
- //row4.HeightInPoints = 15;
- //row4.AddCell(0, "楼层本地名称", DataCheckNPOIStyle.Title);
- //row4.AddCell(1, "文件名", DataCheckNPOIStyle.Title);
- //row4.AddCell(2, "文件地址", DataCheckNPOIStyle.Title);
- //row4.AddCell(3, "楼层平面视图名称", DataCheckNPOIStyle.Title);
- //row4.AddCell(4, "标高高度(m)", DataCheckNPOIStyle.Title);
- //row4.AddCell(5, "楼层顺序号", DataCheckNPOIStyle.Title);
- //row4.AddCell(6, "通过", DataCheckNPOIStyle.Title);
- //row4.AddCell(7, "备注(失败原因)", DataCheckNPOIStyle.Title);
- IRow rowF = null;
- DataCheckNPOIStyle style = this.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
- foreach (var result in Results)
- {
- index++;
- IRow rowN = sheet.CreateRow(index);
- //保存第一行,用于赋值
- if (rowF == null) rowF = rowN;
- SagaSignCheckResult rbase = result.RBase as SagaSignCheckResult;
- if (rbase == null)
- continue;
- rowN.AddCell(0, rbase.RFloorName, style);
- rowN.AddCell(1, rbase.RFileName, style);
- rowN.AddCell(2, rbase.RPath, style);
- rowN.AddCell(3, rbase.RPlanName, style);
- rowN.AddCell(4, rbase.HBase.FromApi().MmToM().ToString("f2"), style);
- rowN.AddCell(5, rbase.RSequence.ToString(), style);
- }
- if (rowF != null)
- {
- int sindex = rowF.RowNum;
- //合并单元格
- sheet.MarginCellAndBorder(sindex, index, 6, 6);
- sheet.MarginCellAndBorder(sindex, index, 7, 7);
- string rowF6 = this.IsRight ? "通过" : "不通过";
- rowF.AddCell(6, rowF6, style, true);
- rowF.AddCell(7, this.RMessage, style, true);
- }
- #endregion
- }
- catch (Exception e)
- {
- MessageShowBase.Show(e);
- }
- }
- }
- }
|