internal static string ExportFacility(this Facility fac, FileInfo fInfo) { var fExt = fInfo.Extension.ToLowerInvariant(); switch (fExt) { case @".json": fac.WriteJson(fInfo.FullName); return("Report exported."); case @".xml": fac.WriteXml(fInfo.FullName); return("Report exported."); case @".xlsx": case @".xls": if (fac.IsValidationResult()) { // write xls validation report var xRep = new ExcelValidationReport(); var ret = xRep.Create(fac, fInfo.FullName); return(ret ? "Export successful." : "Export failed."); } // write cobie file string msg; fac.WriteCobie(fInfo.FullName, out msg); return(msg); } return("Warning: nothing done, check report extension."); }
public void ConvertCobieLiteUkToValidationReportTest() { var facility = Facility.ReadJson("ValidationReport.json"); var rep = new ExcelValidationReport(); Assert.IsTrue(rep.Create(facility, "ValidationReport", ExcelValidationReport.SpreadSheetFormat.Xlsx)); }
public void LakeSideXls0ValidationReport() { var validated = LakeSide0(); const string repName = @"..\..\LakeSideXls0ValidationReport.xlsx"; var xRep = new ExcelValidationReport(); var ret = xRep.Create(validated, repName); Assert.IsTrue(ret, "File not created"); }
public void CanSaveValidationReport() { // stage 0 is for documents // stage 1 is for zones // stage 6 is for assettypes var validated = GetValidated(@"Lakeside_Restaurant-stage6-COBie.json"); const string repName = @"..\..\ValidationReport.xlsx"; var xRep = new ExcelValidationReport(); var ret = xRep.Create(validated, repName); Assert.IsTrue(ret, "File not created"); }
public void HandlesIncompleteRequirmentFile() { // stage 0 is for documents // stage 1 is for zones // stage 6 is for assettypes var validated = GetValidated(@"Lakeside_Restaurant-FacilityNotRequired.json"); const string repName = @"..\..\ValidationReport.xlsx"; var xRep = new ExcelValidationReport(); var ret = xRep.Create(validated, repName); Assert.IsTrue(ret, "File not created"); }
public void TestXlsxValidation() { string msg; var subFl = Facility.ReadCobie(@"XLSX\LakesideWithDocuments.xlsx", out msg); var reqFl = Facility.ReadCobie(@"XLSX\Requirements6.xlsx", out msg); var validator = new FacilityValidator(); var result = validator.Validate(reqFl, subFl); var xRep = new ExcelValidationReport(); var ret = xRep.Create(result, @"C:\Data\dev\XbimTeam\XbimExchange\Tests\ValidationFiles\XLSX\Report.xlsx"); }
public void TestViewpointValidation() { string msg; var subFl = Facility.ReadCobie(@"VP\Submitted.xlsx", out msg); var reqFl = Facility.ReadCobie(@"VP\Required.xlsx", out msg); var validator = new FacilityValidator(); var result = validator.Validate(reqFl, subFl); const string repName = @"..\..\VPValidationReport.xlsx"; var xRep = new ExcelValidationReport(); var ret = xRep.Create(result, repName); result.WriteCobie(@"..\..\VPValidationResult.xlsx", out msg); }
static void Main(string[] args) { string msg; var subFl = Facility.ReadCobie(@"..\..\Tests\ValidationFiles\VP\Submitted.xlsx", out msg); var reqFl = Facility.ReadCobie(@"..\..\Tests\ValidationFiles\VP\Required.xlsx", out msg); var validator = new FacilityValidator(); var result = validator.Validate(reqFl, subFl); var tOut = Path.ChangeExtension(Path.GetTempFileName(), "xlsx"); result.WriteCobie(tOut, out msg); const string repName = @"ValidationReport.xlsx"; var xRep = new ExcelValidationReport(); var ret = xRep.Create(result, repName); }
static void Main(string[] args) { const string xlsx = @"Lakeside_Restaurant_fabric_only.xlsx"; string msg; var cobie = Facility.ReadCobie(xlsx, out msg); var req = Facility.ReadJson(@"003-Lakeside_Restaurant-stage6-COBie.json"); var validator = new FacilityValidator(); var result = validator.Validate(req, cobie); //create report using (var stream = File.Create(@"Lakeside_Restaurant_fabric_only.report.xlsx")) { var report = new ExcelValidationReport(); report.Create(result, stream, ExcelValidationReport.SpreadSheetFormat.Xlsx); stream.Close(); } }
public void VerifyCobie() { string reportBlobName = string.Format("{0}{1}", "output", ".json"); string ext = ".ifc"; string ext2 = ".json"; Stream input = File.OpenRead("NBS_LakesideRestaurant_small_optimized.ifc"); Stream inputRequirements = File.OpenRead("003-Lakeside_Restaurant-stage6-COBie.json"); Facility facility = null; string msg; switch (ext) { case ".ifc": case ".ifczip": case ".ifcxml": facility = GetFacilityFromIfc(input, ".ifc"); break; case ".json": facility = Facility.ReadJson(input); break; case ".xml": facility = Facility.ReadXml(input); break; case ".xls": facility = Facility.ReadCobie(input, ExcelTypeEnum.XLS, out msg); break; case ".xlsx": facility = Facility.ReadCobie(input, ExcelTypeEnum.XLSX, out msg); break; } Facility requirements = null; switch (ext2) { case ".xml": requirements = Facility.ReadXml(inputRequirements); break; case ".json": requirements = Facility.ReadJson(inputRequirements); break; case ".xls": requirements = Facility.ReadCobie(inputRequirements, ExcelTypeEnum.XLS, out msg); break; case ".xlsx": requirements = Facility.ReadCobie(inputRequirements, ExcelTypeEnum.XLSX, out msg); break; } if (facility == null || requirements == null) { return; } var vd = new FacilityValidator(); var validated = vd.Validate(requirements, facility); using (var repStream = File.OpenWrite(reportBlobName)) { validated.WriteJson(repStream); repStream.Close(); } var rep = new ExcelValidationReport(); var temp = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetTempFileName(), ".xlsx")); try { rep.Create(facility, temp, ExcelValidationReport.SpreadSheetFormat.Xlsx); } finally { if (File.Exists(temp)) { File.Delete(temp); } } }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("No Ifc or xBim file specified"); return; } var fileName = args[0]; Console.WriteLine("Reading " + fileName); using (var model = GetModel(fileName)) { if (model != null) { var context = new Xbim3DModelContext(model); context.CreateContext(geomStorageType: XbimGeometryType.PolyhedronBinary); var wexBimFilename = Path.ChangeExtension(fileName, "wexBIM"); using (var wexBiMfile = new FileStream(wexBimFilename, FileMode.Create, FileAccess.Write)) { using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile)) { Console.WriteLine("Creating " + wexBimFilename); context.Write(wexBimBinaryWriter); wexBimBinaryWriter.Close(); } wexBiMfile.Close(); } //now do the DPoW files var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); var fileDirectoryName = Path.GetDirectoryName(fileName); var facilities = new List <Facility>(); var ifcToCoBieLiteUkExchanger = new IfcToCOBieLiteUkExchanger(model, facilities); facilities = ifcToCoBieLiteUkExchanger.Convert(); var facilityNumber = 0; foreach (var facility in facilities) { var dpow = "DPoW"; if (facilities.Count > 1) { dpow += ++facilityNumber; } // ReSharper disable AssignNullToNotNullAttribute var dPoWFile = Path.Combine(fileDirectoryName, fileNameWithoutExtension + "_" + dpow); // ReSharper restore AssignNullToNotNullAttribute dPoWFile = Path.ChangeExtension(dPoWFile, "json"); Console.WriteLine("Creating " + dPoWFile); facility.WriteJson(dPoWFile); string cobieFile = Path.ChangeExtension(dPoWFile, "Xlsx"); Console.WriteLine("Creating " + cobieFile); string error; facility.WriteCobie(cobieFile, out error); if (!string.IsNullOrWhiteSpace(error)) { Console.WriteLine("COBie Errors: " + error); } dPoWFile = Path.ChangeExtension(dPoWFile, "xml"); Console.WriteLine("Creating " + dPoWFile); // facility.WriteXml(dPoWFile); var req = Facility.ReadJson(@"..\..\Tests\ValidationFiles\Lakeside_Restaurant-stage6-COBie.json"); var validator = new FacilityValidator(); var result = validator.Validate(req, facility); var verificationResults = Path.ChangeExtension(dPoWFile, "verified.xlsx"); Console.WriteLine("Creating " + verificationResults); //create report using (var stream = File.Create(verificationResults)) { var report = new ExcelValidationReport(); report.Create(result, stream, ExcelValidationReport.SpreadSheetFormat.Xlsx); stream.Close(); } facility.ValidateUK2012(Console.Out, true); string cobieValidatedFile = Path.ChangeExtension(dPoWFile, "Validated.Xlsx"); facility.WriteCobie(cobieValidatedFile, out error); dPoWFile = Path.ChangeExtension(dPoWFile, "xbim"); Console.WriteLine("Creating " + dPoWFile); using (var ifcModel = XbimModel.CreateModel(dPoWFile)) { ifcModel.Initialise("Xbim Tester", "XbimTeam", "Xbim.Exchanger", "Xbim Development Team", "3.0"); ifcModel.ReloadModelFactors(); using (var txn = ifcModel.BeginTransaction("Convert from COBieLiteUK")) { var coBieLiteUkToIfcExchanger = new CoBieLiteUkToIfcExchanger(facility, ifcModel); coBieLiteUkToIfcExchanger.Convert(); txn.Commit(); //var err = model.Validate(model.Instances, Console.Out); } dPoWFile = Path.ChangeExtension(dPoWFile, "ifc"); Console.WriteLine("Creating " + dPoWFile); ifcModel.SaveAs(dPoWFile, XbimStorageType.IFC); ifcModel.Close(); } } model.Close(); } } Console.WriteLine("Press any key to exit"); Console.Read(); }
private static void ProcessFile(string fileName, ExchangeSettings settings) { var outDirectoryName = Path.GetDirectoryName(fileName); if (settings.OutputdDirectory != null) { outDirectoryName = settings.OutputdDirectory.FullName; } if (outDirectoryName == null) { return; } var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); var w = new Stopwatch(); w.Start(); Console.WriteLine("Reading " + fileName); using (var model = GetModel(fileName)) { if (model == null) { Console.WriteLine("No model to process. Press any key to exit"); Console.Read(); return; } Console.WriteLine("Model open in {0}ms", w.ElapsedMilliseconds); // wexbim w.Restart(); var wexBimFilename = GetSaveName(outDirectoryName, fileNameWithoutExtension, ".wexBIM"); Console.WriteLine("Creating " + wexBimFilename); var context = new Xbim3DModelContext(model); context.CreateContext(); using (var wexBiMfile = new FileStream(wexBimFilename, FileMode.Create, FileAccess.Write)) { using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile)) { model.SaveAsWexBim(wexBimBinaryWriter); wexBimBinaryWriter.Close(); } wexBiMfile.Close(); } Console.WriteLine("wexBIM model created in {0}ms", w.ElapsedMilliseconds); //now do COBieExpress // w.Restart(); Console.WriteLine("Creating CobieExpress memoryModel..."); var cobie = new MemoryModel(new EntityFactoryCobieExpress()); var cobieExpressFile = GetSaveName(outDirectoryName, fileNameWithoutExtension, ".cobie"); var cobieExpressXmlFile = GetSaveName(outDirectoryName, fileNameWithoutExtension, ".cobieXml"); var cobieExpressZipFile = GetSaveName(outDirectoryName, fileNameWithoutExtension, ".cobieZip"); using (var txn = cobie.BeginTransaction("IFC data in")) { var exchanger = new IfcToCoBieExpressExchanger(model, cobie); exchanger.Convert(); txn.Commit(); } Console.WriteLine("COBieExpress memoryModel created and commited in {0}ms...", w.ElapsedMilliseconds); w.Restart(); cobie.SaveAsStep21(File.Create(cobieExpressFile)); cobie.SaveAsStep21Zip(File.Create(cobieExpressZipFile)); cobie.SaveAsXml(File.Create(cobieExpressXmlFile), new XmlWriterSettings { Indent = true, IndentChars = "\t" }, XbimXmlSettings.IFC4Add2); Console.WriteLine("3 COBieExpress files (.cobie., cobieXml and .cobieZip) saved in {0}ms", w.ElapsedMilliseconds); //now do the DPoW files // w.Restart(); Console.WriteLine("Creating CobieLiteUK Model..."); var facilities = new List <Facility>(); var ifcToCoBieLiteUkExchanger = new IfcToCOBieLiteUkExchanger(model, facilities); facilities = ifcToCoBieLiteUkExchanger.Convert(); Console.WriteLine("{1} facilities converted in in {0}ms", w.ElapsedMilliseconds, facilities.Count ); var multipleFacilities = facilities.Count > 1; for (var index = 0; index < facilities.Count; index++) { w.Restart(); var facility = facilities[index]; var dpowNameExtension = "DPoW"; if (multipleFacilities) { dpowNameExtension += index + 1; } // write json var dPoWFile = GetSaveName(outDirectoryName, fileNameWithoutExtension + "_" + dpowNameExtension, ".json"); Console.Write("Creating " + dPoWFile + "..."); facility.WriteJson(dPoWFile); Console.WriteLine(" completed in {0}ms", w.ElapsedMilliseconds); // xlsx var cobieFile = Path.ChangeExtension(dPoWFile, "xlsx"); Console.WriteLine("Creating " + cobieFile + "..."); string error; facility.WriteCobie(cobieFile, out error); Console.WriteLine(" completed in {0}ms", w.ElapsedMilliseconds); if (!string.IsNullOrWhiteSpace(error)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("COBie Errors: " + error); Console.ResetColor(); } // dpow validation // if (!string.IsNullOrEmpty(settings.DpowRequirementFile)) { w.Restart(); Console.Write("Reading DPoW requirement file: " + settings.DpowRequirementFile + "..."); var req = Facility.ReadJson(settings.DpowRequirementFile); Console.WriteLine(" completed in {0}ms", w.ElapsedMilliseconds); w.Restart(); Console.Write("Validating DPOW..."); var validator = new FacilityValidator(); var result = validator.Validate(req, facility); Console.WriteLine(" completed in {0}ms", w.ElapsedMilliseconds); w.Restart(); var validationResults = Path.ChangeExtension(dPoWFile, "validationReport.xlsx"); Console.Write("writing validation report: " + validationResults); //create report using (var stream = File.Create(validationResults)) { var report = new ExcelValidationReport(); report.Create(result, stream, ExcelValidationReport.SpreadSheetFormat.Xlsx); stream.Close(); } Console.WriteLine(" completed in {0}ms", w.ElapsedMilliseconds); } // now attempt basic content validation and recovery // w.Restart(); Console.WriteLine("Validating and recovering..."); facility.ValidateUK2012(Console.Out, true); var cobieValidatedFile = Path.ChangeExtension(dPoWFile, "ValidationWithAttemptedRecovery.xlsx"); Console.ForegroundColor = ConsoleColor.DarkYellow; facility.WriteCobie(cobieValidatedFile, out error); Console.ResetColor(); Console.WriteLine("Completed in {0}ms", w.ElapsedMilliseconds); // now ifc // w.Restart(); dPoWFile = Path.ChangeExtension(dPoWFile, "ifc"); Console.Write("Creating " + dPoWFile + "..."); var credentials = new XbimEditorCredentials() { ApplicationDevelopersName = "XbimTeam", ApplicationFullName = "Xbim.Exchanger", EditorsOrganisationName = "Xbim Development Team", EditorsFamilyName = "Xbim Tester", ApplicationVersion = global::System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString() }; using (var ifcModel = IfcStore.Create(credentials, XbimSchemaVersion.Ifc2X3, XbimStoreType.EsentDatabase)) { using (var txn = ifcModel.BeginTransaction("Convert from COBieLiteUK")) { var coBieLiteUkToIIfcExchanger = new CoBieLiteUkToIfcExchanger(facility, ifcModel); coBieLiteUkToIIfcExchanger.Convert(); txn.Commit(); //var err = model.Validate(model.Instances, Console.Out); } ifcModel.SaveAs(dPoWFile, StorageType.Ifc); ifcModel.Close(); } Console.WriteLine(" completed in {0}ms", w.ElapsedMilliseconds); } model.Close(); } }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("No IIfc or xBim file specified"); return; } var fileName = args[0]; Console.WriteLine("Reading " + fileName); using (var model = GetModel(fileName)) { if (model == null) { Console.WriteLine("No model to process. Press any key to exit"); Console.Read(); return; } var context = new Xbim3DModelContext(model); context.CreateContext(); var wexBimFilename = Path.ChangeExtension(fileName, "wexBIM"); using (var wexBiMfile = new FileStream(wexBimFilename, FileMode.Create, FileAccess.Write)) { using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile)) { Console.WriteLine("Creating " + wexBimFilename); model.SaveAsWexBim(wexBimBinaryWriter); wexBimBinaryWriter.Close(); } wexBiMfile.Close(); } //now do COBieExpress var cobie = new MemoryModel(new EntityFactory()); var cobieExpressFile = Path.ChangeExtension(fileName, ".cobie"); var cobieExpressXmlFile = Path.ChangeExtension(fileName, ".cobieXml"); var cobieExpressZipFile = Path.ChangeExtension(fileName, ".cobieZip"); var w = new Stopwatch(); using (var txn = cobie.BeginTransaction("IFC data in")) { var exchanger = new IfcToCoBieExpressExchanger(model, cobie); w.Start(); exchanger.Convert(); w.Stop(); txn.Commit(); } Console.WriteLine("COBieExpress model created in {0}ms", w.ElapsedMilliseconds); cobie.SaveAsStep21(File.Create(cobieExpressFile)); cobie.SaveAsStep21Zip(File.Create(cobieExpressZipFile)); cobie.SaveAsXml(File.Create(cobieExpressXmlFile), new XmlWriterSettings { Indent = true, IndentChars = "\t" }); //now do the DPoW files var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); var fileDirectoryName = Path.GetDirectoryName(fileName); var facilities = new List <Facility>(); var ifcToCoBieLiteUkExchanger = new IfcToCOBieLiteUkExchanger(model, facilities); facilities = ifcToCoBieLiteUkExchanger.Convert(); var facilityNumber = 0; foreach (var facility in facilities) { var dpow = "DPoW"; if (facilities.Count > 1) { dpow += ++facilityNumber; } // ReSharper disable AssignNullToNotNullAttribute var dPoWFile = Path.Combine(fileDirectoryName, fileNameWithoutExtension + "_" + dpow); // ReSharper restore AssignNullToNotNullAttribute dPoWFile = Path.ChangeExtension(dPoWFile, "json"); Console.WriteLine("Creating " + dPoWFile); facility.WriteJson(dPoWFile); string cobieFile = Path.ChangeExtension(dPoWFile, "Xlsx"); Console.WriteLine("Creating " + cobieFile); string error; facility.WriteCobie(cobieFile, out error); if (!string.IsNullOrWhiteSpace(error)) { Console.WriteLine("COBie Errors: " + error); } dPoWFile = Path.ChangeExtension(dPoWFile, "xml"); Console.WriteLine("Creating " + dPoWFile); // facility.WriteXml(dPoWFile); var req = Facility.ReadJson(@"..\..\Tests\ValidationFiles\Lakeside_Restaurant-stage6-COBie.json"); var validator = new FacilityValidator(); var result = validator.Validate(req, facility); var verificationResults = Path.ChangeExtension(dPoWFile, "verified.xlsx"); Console.WriteLine("Creating " + verificationResults); //create report using (var stream = File.Create(verificationResults)) { var report = new ExcelValidationReport(); report.Create(result, stream, ExcelValidationReport.SpreadSheetFormat.Xlsx); stream.Close(); } facility.ValidateUK2012(Console.Out, true); string cobieValidatedFile = Path.ChangeExtension(dPoWFile, "Validated.Xlsx"); facility.WriteCobie(cobieValidatedFile, out error); dPoWFile = Path.ChangeExtension(dPoWFile, "xbim"); var credentials = new XbimEditorCredentials() { ApplicationDevelopersName = "XbimTeam", ApplicationFullName = "Xbim.Exchanger", EditorsOrganisationName = "Xbim Development Team", EditorsFamilyName = "Xbim Tester", ApplicationVersion = "3.0" }; Console.WriteLine("Creating " + dPoWFile); using ( var ifcModel = IfcStore.Create(credentials, IfcSchemaVersion.Ifc2X3, XbimStoreType.EsentDatabase)) { using (var txn = ifcModel.BeginTransaction("Convert from COBieLiteUK")) { var coBieLiteUkToIIfcExchanger = new CoBieLiteUkToIfcExchanger(facility, ifcModel); coBieLiteUkToIIfcExchanger.Convert(); txn.Commit(); //var err = model.Validate(model.Instances, Console.Out); } dPoWFile = Path.ChangeExtension(dPoWFile, "ifc"); Console.WriteLine("Creating " + dPoWFile); ifcModel.SaveAs(dPoWFile, IfcStorageType.Ifc); ifcModel.Close(); } } model.Close(); } Console.WriteLine("Press any key to exit"); Console.Read(); }