Exemplo n.º 1
0
        private void _buttonCreateManufacturerData_Click(object sender, EventArgs e)
        {
            string key = Workspace.Current.CreateCcFile("MyName", "MyCompany", "MySoftware", "MyAuthorization");

            Manufacturer.ManufacturerCreatorUtils.InitializeManufacturerFile(key, "SampleManufacturer", "SampleManufacturer description");

            // We want to add a rediator product definition to our new file
            // At first we have to get the CcManufaturerProduct, which is automatically filled with the required attibutes
            CcManufacturerProduct product = Manufacturer.ManufacturerCreatorUtils.LoadProductDataTemplate(key, "423.17");

            product.Name = "Name of my product";
            // Set the description for this product
            product.Description = "Description of the radiator";

            foreach (CcManufacturerProductDetail detail in product.Attributes)
            {
                // Get here the manufacturer data from the own product catalogue
                detail.AttributeValue = "My Value";
            }

            Manufacturer.ManufacturerCreatorUtils.AddManufacturerProductToFile(key, product);

            string filename = @"c:\\tmp\\MyFirstEmptyCafmConnectManufacturerFile.ifcxml";

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            Workspace.Current.SaveCcFileAs(key, filename);
        }
Exemplo n.º 2
0
 private void _dataGridViewManufacturers_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         if (_dataGridViewManufacturers.SelectedRows != null)
         {
             m_selprd = _dataGridViewManufacturers.SelectedRows[0].DataBoundItem as CcManufacturerProduct;
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 3
0
        public void StartSelection(string code)
        {
            m_view.SetCode(code);
            m_view.SetData(m_model.GetProductSelectionForCode(code));

            if (m_view.ShowSelectionDLG() == System.Windows.Forms.DialogResult.OK)
            {
                m_prd = m_view.GetSelectedProduct();
            }
            else
            {
                m_prd = null;
            }
        }
Exemplo n.º 4
0
        private void buttonCafmConnectCreate_Click(object sender, EventArgs e)
        {
            linkLabel1.Text              = string.Empty;
            textBoxCafmConnectFile.Text  = "Please wait, this takes a while, sometimes several minutes.";
            textBoxCafmConnectFile.Text += Environment.NewLine + "We work hard to optimize the code, to make this happen faster...";
            textBoxCafmConnectFile.Text += Environment.NewLine + "When the file is created, please open it with the CAFM-Conenct Editor.";
            textBoxCafmConnectFile.Refresh();
            int maxVariants = Convert.ToInt16(textBox2.Text);

            string fileName = Path.GetTempPath() + maxVariants.ToString() + ".ifczip";

            CafmConnect.Workspace ws = new Workspace();
            string key = ws.CreateCcFile("Author", "Organization", "System", "Authorization");

            string    siteGuid = ws.AddNewSite(key, "CGN", "SiteDescription", "SiteStreet", "50667", "Cologne", "DE");
            Stopwatch sw       = new Stopwatch();

            sw.Start();

            for (int i = 1; i <= maxVariants; i++)
            {
                CafmConnect.Manufacturer.CcManufacturerProduct product = new CcManufacturerProduct("461");
                product.Description = "Aufzug " + i.ToString();
                product.Name        = "Variante " + i.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)
                {
                    ws.AddNewProduct(key, siteGuid, "461", product, product.Description);
                }

                labelCounter.Text = i.ToString();
                labelCounter.Refresh();

                labelStopwatch.Text = (sw.ElapsedMilliseconds / i).ToString();
                labelStopwatch.Refresh();
            }

            ws.SaveCcFileAs(key, fileName, true, true);
            sw.Stop();

            linkLabel1.Text             = fileName;
            textBoxCafmConnectFile.Text = ws.GetModelOfCcFile(fileName);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void AddNewProduct(string currentFilename, string siteGuid, string classificationCode, CcManufacturerProduct product, string system)
        {
            if (Current.Documents.ContainsKey(currentFilename))
            {
                Ifc4.CcFacility newSystem = Current.Documents[currentFilename].Project.Facilities.Where(x => x.IfcSystem.Name == product.Code &&
                                                                                                        x.IfcSystem.Description == system)
                                            .FirstOrDefault();
                if (newSystem == null)
                {
                    newSystem = Current.Documents[currentFilename].Project.Facilities.AddNewSystem(Current.Documents[currentFilename].Project);
                    newSystem.IfcSystem.GlobalId    = Ifc4.GlobalId.ConvertToIfcGuid(Guid.NewGuid());
                    newSystem.IfcSystem.Name        = product.Code;
                    newSystem.IfcSystem.Description = system;
                }
                CcFacility newFacility = newSystem.Facilities.AddNewFacility();
                newFacility.ObjectTypeId             = m_filteredIfcClassificationReference.Id; // z.B "i2139"
                newFacility.Number                   = product.Name;
                newFacility.IfcObjectDefinition.Name = product.Code;
                newFacility.Description              = product.Description;

                var propertyDescriptors = from propertyDescriptor in System.ComponentModel.TypeDescriptor.GetProperties(newFacility).Cast <System.ComponentModel.PropertyDescriptor>().OfType <Ifc4.CustomModel.CustomPropertyDescriptor>()
                                          select propertyDescriptor;

                foreach (CcManufacturerProductDetail attribute in product.Attributes)
                {
                    foreach (var propertyDescriptor in propertyDescriptors)
                    {
                        if (propertyDescriptor.IsReadOnly)
                        {
                            continue;
                        }

                        if (propertyDescriptor.Converter == null)
                        {
                            continue;
                        }

                        if (propertyDescriptor.IfcPropertyName == attribute.AttributeCcName)
                        {
                            newFacility.SetValue(propertyDescriptor, attribute.AttributeValue);
                            continue;
                        }
                    }
                }
            }
        }