示例#1
0
        private void buttonVDI3805Read_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Path.Combine(Application.StartupPath, "Samples");
            //openFileDialog.Filter = "VDI Files (*.zip)|*.txt|All files (*.*)|*.*";


            DialogResult result = openFileDialog.ShowDialog();

            if (result.ToString() == "OK")
            {
                string filename = openFileDialog.FileName;
                workingFolder = Path.GetDirectoryName(filename);
                //filename = @"samples\PART03_Broetje_GFX.zip";
                textBoxVdiFile.Text = "Reading and analyzing the VDI3805 file, this can take a while, please wait...";
                textBoxVdiFile.Refresh();

                vdi3805              = new VDI3805.VDI3805(filename);
                textBoxVdiFile.Text += Environment.NewLine + "Reading of file finished...";
                textBoxVdiFile.Refresh();

                string fileContentAsXml = vdi3805.ToXml();
                fileNameXml = filename.Replace("zip", "xml");
                File.WriteAllText(fileNameXml, fileContentAsXml);

                linkLabelVDI3085.Text = fileNameXml;
                linkLabelVDI3085.Links.Clear();
                linkLabelVDI3085.Links.Add(0, 1000, fileNameXml);
                linkLabelVDI3085.Enabled = true;
                linkLabelVDI3085.Refresh();
                var lineCount = File.ReadLines(fileNameXml).Count();
                textBoxVdiFile.Text += Environment.NewLine + "Intermediate XML file saved sucessufully on disk (" + lineCount.ToString() + " Lines)";
                textBoxVdiFile.Text += Environment.NewLine + "Loading the file...";
                textBoxVdiFile.Refresh();

                textBoxVdiFile.Text = fileContentAsXml;
                buttonCreateCcFileFromVDI.Visible = true;
                textBoxCafmConnectFile.Visible    = true;
            }
        }
示例#2
0
        public string CreateCcFileFromVDI3805(VDI3805.VDI3805 vdi3805)
        {
            EventHandler handler = eventHandler;

            string   tempModelFilename = InitializeCcFile("CAFM-ConnectFacilitiesViewTemplateVdi3805.ifcxml");
            Document doc = null;

            if (!Current.Documents.ContainsKey(tempModelFilename))
            {
                doc = Ifc4.Workspace.CurrentWorkspace.OpenDocument(tempModelFilename);
                doc.IfcXmlDocument.Header.Author            = vdi3805.ManufacturerName;
                doc.IfcXmlDocument.Header.Organization      = vdi3805.ManufacturerText;
                doc.IfcXmlDocument.Header.OriginatingSystem = vdi3805.Filename;
                doc.IfcXmlDocument.Header.Authorization     = vdi3805.ManufacturerUrl;
                Current.Documents.Add(tempModelFilename, doc);

                string catalogueName = "CAFMConnectCatalogueOfObjectTypes";
                if (m_TempAllIfcClassificationReferenceCollection == null)
                {
                    m_TempAllIfcClassificationReferenceCollection = GetIfcClassificationReferenceCollectionFromCatalogue(tempModelFilename, catalogueName);
                }

                m_filteredIfcClassificationReference = m_TempAllIfcClassificationReferenceCollection.FirstOrDefault(item => item.Identification == vdi3805.GetCclassification());
            }
            string siteGuid = AddNewSite(tempModelFilename, vdi3805.ManufacturerName, vdi3805.ManufacturerName, vdi3805.ManufacturerName2, vdi3805.ManufacturerText, vdi3805.LeadData_010.IssueMonth, vdi3805.CountryCode);
            string code     = vdi3805.GetCclassification();

            foreach (ProductMainGroup1_100 pmg100 in vdi3805.LeadData_010.ProductMainGroup1_100s)
            {
                LastAction = pmg100.ProductDesignation;
                handler?.Invoke(this, EventArgs.Empty);

                foreach (ProductMainGroup2_110 pmg110 in pmg100.ProductMainGroup2_110s)
                {
                    LastAction = pmg110.ProductDesignation;
                    handler?.Invoke(this, EventArgs.Empty);

                    foreach (ProductElementData_700 ped700 in pmg110.ProductElementData_700s)
                    {
                        CafmConnect.Manufacturer.CcManufacturerProduct product = new CcManufacturerProduct(code);

                        switch (vdi3805.VDI3805PartNumber)
                        {
                        case "PART02":
                            break;

                        case "PART03":
                            product.Description = ped700.HeatGenerator.ProductName;
                            product.Name        = ped700.HeatGenerator.ProductRange;
                            product.Attributes.Add(new CcManufacturerProductDetail("Beschreibung", "Beschreibung", pmg100.ProductDesignation));

                            FieldInfo[] fields = ped700.HeatGenerator.GetType().GetFields();
                            foreach (var field in fields)
                            {
                                string value;
                                if (field.GetValue(ped700.HeatGenerator) != null)
                                {
                                    value = field.GetValue(ped700.HeatGenerator).ToString();
                                }
                                else
                                {
                                    value = string.Empty;
                                }
                                product.Attributes.Add(new CcManufacturerProductDetail(field.Name, field.Name, value));
                            }

                            LastAction = ped700.HeatGenerator.ProductName;
                            handler?.Invoke(this, EventArgs.Empty);

                            break;

                        case "PART04":
                            break;

                        case "PART05":
                            break;

                        case "PART06":
                            break;

                        case "PART07":
                            break;

                        case "PART08":
                            break;

                        case "PART09":
                            break;
                        }


                        //product.Attributes.Add(new CcManufacturerProductDetail("Beschreibung", "Beschreibung", pmg.ProductMainGroup2_110s.FirstOrDefault().ProductElementData_700s.FirstOrDefault().HeatGenerators.FirstOrDefault().ProductName.ToString()));
                        //product.Attributes.Add(new CcManufacturerProductDetail("Anzahl Haltestellen", "Anzahl Haltestellen", "10"));
                        //product.Attributes.Add(new CcManufacturerProductDetail("Tragkraft in Personen", "Tragkraft in Personen", "5"));
                        //product.Attributes.Add(new CcManufacturerProductDetail("Tragkraft", "Tragkraft", (i * 2).ToString()));

                        if (siteGuid != null)
                        {
                            AddNewProduct(tempModelFilename, siteGuid, code, product, pmg100.ProductDesignation);
                        }
                    }
                }
            }

            return(tempModelFilename);
        }