Пример #1
0
 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 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");
 }
Пример #5
0
        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();
            }
        }
Пример #6
0
        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();
        }
 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");
 }