12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using Autodesk.Revit.Attributes;
- using Autodesk.Revit.DB;
- using Autodesk.Revit.UI;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Converters;
- using SAGA.DotNetUtils.Data;
- using SAGA.DotNetUtils.Geometry;
- using SAGA.RevitUtils;
- using SAGA.RevitUtils.Extends;
- using ServiceRevitLib.Mode;
- namespace ServiceRevitLib
- {
- #region 测试命令
- public class ServiceDataCheckTest
- {
- public static string Check(Document doc)
- {
- string result = null;
- try
- {
- var factory = new CheckFactory();
- factory.SetCheckItems("SagaCheck,UnitCheck,FamilyNameCheck,EquipPartLocationCheck,ColumnCheck,ElementRangeCheck,ConnectorCheck,SystemNameCheck,EquipInSpaceCheck,SystemReferEquipCheck,ParameterIntegrityCheck,PipeCheck,XYZOverlapCheck");
- factory.Check(doc);
- result = Serialze(factory);
- string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
- string path = Path.Combine(@"D:\", $"DataCheck{fileName}.json");
- //File.WriteAllText(path, result);
- }
- catch (Exception e)
- {
- result = Serialze(ResultBase.Exception(e.Message));
- }
- return result;
- }
- public static string Serialze(object obj)
- {
- JsonSerializerSettings jsetting = CreateDefaultSettings();
- var result = JsonConvert.SerializeObject(obj, jsetting);
- return result;
- }
- private static JsonSerializerSettings CreateDefaultSettings()
- {
- JsonSerializerSettings jsetting = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
- jsetting.Converters.Add(new StringEnumConverter());
- return jsetting;
- }
- }
-
- #endregion
- }
|