using System; using System.Collections.Generic; using System.Configuration; 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(ConfigurationManager.AppSettings["CheckItems"]); factory.Check(doc); result = Serialze(factory); #if DEBUG string fileName = DateTime.Now.ToString("yyyyMMddHHmmss"); string path = Path.Combine(@"E:\", $"DataCheck{fileName}.json"); File.WriteAllText(path, result); #endif } 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 }