Exemplo n.º 1
0
        private void treeViewProperty_AfterSelect(object sender, TreeViewEventArgs e)
        {
            DocObject docObj = this.treeViewProperty.SelectedNode.Tag as DocObject;

            if (docObj != null)
            {
                if (docObj is DocPropertySet)
                {
                    this.textBoxType.Text = ((DocPropertySet)docObj).PropertySetType;
                }
                else if (docObj is DocProperty)
                {
                    DocProperty docProp = (DocProperty)docObj;
                    this.textBoxType.Text = docProp.PropertyType + ": " + docProp.PrimaryDataType + " / " + docProp.SecondaryDataType;
                }

                this.textBoxDescription.Text = docObj.Documentation;
            }
            else if (this.treeViewProperty.SelectedNode.Parent != null && this.treeViewProperty.SelectedNode.Parent.Tag is DocProperty)
            {
                DocProperty docProp = (DocProperty)this.treeViewProperty.SelectedNode.Parent.Tag;
                this.textBoxType.Text        = docProp.PropertyType + ": " + docProp.PrimaryDataType + " / " + docProp.SecondaryDataType;
                this.textBoxDescription.Text = docProp.Documentation;
            }

            this.buttonOK.Enabled = (this.treeViewProperty.CheckBoxes || this.SelectedProperty != null || (this.m_entity == null && this.SelectedPropertySet != null));
        }
Exemplo n.º 2
0
        public static string GetDocumentProperty(string filePath, DocProperty docProp)
        {
            string propertyValue = "";

            using (SpreadsheetDocument wkbk = SpreadsheetDocument.Open(filePath, true))
            {
                switch (docProp)
                {
                case DocProperty.Creator:
                    propertyValue = wkbk.PackageProperties.Creator;
                    break;

                case DocProperty.LastModifiedBy:
                    propertyValue = wkbk.PackageProperties.LastModifiedBy;
                    break;

                case DocProperty.Category:
                    propertyValue = wkbk.PackageProperties.Category;
                    break;

                case DocProperty.Description:
                    propertyValue = wkbk.PackageProperties.Description;
                    break;

                case DocProperty.Subject:
                    propertyValue = wkbk.PackageProperties.Subject;
                    break;

                case DocProperty.Title:
                    propertyValue = wkbk.PackageProperties.Title;
                    break;
                }
            }
            return(propertyValue);
        }
Exemplo n.º 3
0
        private async Task <bool> ExecuteAsync()
        {
            bool executedSuccessfully = true;

            try
            {
                if (GetConfigurationValues())
                {
                    _indexerApiUrl = "https://api.videoindexer.ai";
                    //Retrieve _indexerApiKey from secret store
                    _indexerApiKey = "";                     //Add your own credentials here

                    //Get job details
                    IndexJob indexJob = new IndexJob();
                    indexJob = GetSingleJob();


                    if (indexJob.Success)
                    {
                        await UpdateStatus(indexJob, "In Progress");

                        //Get job document details
                        DocProperty doc = new DocProperty();
                        doc = await GetDocProperty(indexJob.WorkspaceArtifactID, indexJob.DocumentArtifactID);

                        if (doc.Success)
                        {
                            //Launch video for indexing
                            VideoIndex       videoIndex       = new VideoIndex(doc.Path, doc.Filename, doc.Begdoc, _indexerApiUrl, _indexerApiKey, _logger, Helper);
                            VideoIndexResult videoIndexResult = await videoIndex.Sample();

                            //Update job with index details.  We will use these details later in the custom page.
                            await WriteValuesToIndexJob(indexJob, videoIndexResult);
                            await WriteValuesToDocumentObject(indexJob, videoIndexResult);

                            //Write transcript to document field
                        }
                        CleanupQueue(indexJob);
                        await UpdateStatus(indexJob, "Complete");
                    }
                }
                const int maxMessageLevel = 10;
                RaiseMessage("Completed.", maxMessageLevel);
            }
            catch (Exception ex)
            {
                LogError(ex);
                executedSuccessfully = false;
            }
            return(executedSuccessfully);
        }
            public PropertiesResponse(Project project)
            {
                BuiltIn = new List <DocProperty>();
                Custom  = new List <DocProperty>();

                foreach (var obj in project.BuiltInProps)
                {
                    DocProperty metadataObject = new DocProperty
                    {
                        Name  = obj.Name,
                        Value = obj.Value,
                        Type  = PropertyType.String
                    };
                    BuiltIn.Add(metadataObject);
                }


                foreach (var obj in project.CustomProps)
                {
                    string       value        = obj.Type.ToString();
                    PropertyType propertyType = PropertyType.None;

                    switch (value.ToLower())
                    {
                    case "string":
                        propertyType = PropertyType.String;
                        break;

                    case "datetime":
                        propertyType = PropertyType.DateTime;
                        break;

                    case "number":
                        propertyType = PropertyType.Number;
                        break;

                    case "boolean":
                        propertyType = PropertyType.Boolean;
                        break;
                    }

                    DocProperty metadataObject = new DocProperty
                    {
                        Name  = obj.Name,
                        Value = obj.Value,
                        Type  = propertyType
                    };
                    Custom.Add(metadataObject);
                }
            }
Exemplo n.º 5
0
        private async Task <DocProperty> GetDocProperty(int workspaceArtifactID, int documentArtifactID)
        {
            DocProperty  doc = new DocProperty();
            const string fileNameFieldName = "File Name";

            try
            {
                using (IObjectManager manager = this.Helper.GetServicesManager().CreateProxy <IObjectManager>(Relativity.API.ExecutionIdentity.System))
                {
                    var fieldsToRead = new List <FieldRef>();
                    fieldsToRead.Add(new FieldRef()
                    {
                        Name = fileNameFieldName
                    });
                    var readRequest = new ReadRequest()
                    {
                        Object = new RelativityObjectRef {
                            ArtifactID = documentArtifactID
                        },
                        Fields = fieldsToRead
                    };
                    RelativityObject document = (await manager.ReadAsync(workspaceArtifactID, readRequest)).Object;
                    if (document != null)
                    {
                        doc.Begdoc   = document.Name;
                        doc.Filename = document.FieldValues.First(f => f.Field.Name == fileNameFieldName).Value.ToString();

                        string       sql = @"
															SELECT [Location] 
															FROM [EDDSDBO].[File]
															WHERE [Type] = 0
															AND [DocumentArtifactID] = @documentArtifactIDParam"                                                            ;
                        SqlParameter documentArtifactIDParam = new SqlParameter("@documentArtifactIDParam", SqlDbType.Int);
                        documentArtifactIDParam.Value = documentArtifactID;
                        doc.Path = Helper.GetDBContext(workspaceArtifactID).ExecuteSqlStatementAsScalar(sql, new SqlParameter[] { documentArtifactIDParam }).ToString() ?? string.Empty;
                    }
                    doc.Success = !string.IsNullOrEmpty(doc.Path) && !string.IsNullOrEmpty(doc.Filename);
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return(doc);
        }
Exemplo n.º 6
0
        public static void SetDocumentProperty(string filePath, DocProperty docProp, string strValue)
        {
            using (SpreadsheetDocument wkbk = SpreadsheetDocument.Open(filePath, true))
            {
                try
                {
                    switch (docProp)
                    {
                    case DocProperty.Creator:
                        wkbk.PackageProperties.Creator = strValue;
                        break;

                    case DocProperty.LastModifiedBy:
                        wkbk.PackageProperties.LastModifiedBy = strValue;
                        break;

                    case DocProperty.Category:
                        wkbk.PackageProperties.Category = strValue;
                        break;

                    case DocProperty.Description:
                        wkbk.PackageProperties.Description = strValue;
                        break;

                    case DocProperty.Subject:
                        wkbk.PackageProperties.Subject = strValue;
                        break;

                    case DocProperty.Title:
                        wkbk.PackageProperties.Title = strValue;
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// Process property information.
        /// </summary>
        /// <param name="exportedType">The <see cref="DocExportedType"/> to parse.</param>
        private void ProcessProperties(DocExportedType exportedType)
        {
            var defaultRules = typeof(DefaultComparisonRules);

            foreach (var prop in exportedType.Type.GetProperties(
                         BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static))
            {
                if (prop.DeclaringType != exportedType.Type)
                {
                    continue;
                }

                var property = new DocProperty(exportedType)
                {
                    Name           = $"{exportedType.Name}.{prop.Name}",
                    XPath          = MemberUtils.GetSelector(prop),
                    Type           = prop.PropertyType,
                    TypeParameters = ProcessTypeParameters(prop.PropertyType),
                    Code           = MemberUtils.GenerateCodeFor(prop),
                };

                if (exportedType.Type == defaultRules && prop.GetMethod.IsStatic)
                {
                    var expression = prop.GetMethod.Invoke(null, null);
                    property.CustomInfo = expression.ToString();
                }

                LinkCache.Register(property);

                if (prop.GetIndexParameters().Length > 0)
                {
                    property.IsIndexer   = true;
                    property.IndexerType = TypeCache.Cache[prop.GetIndexParameters().First().ParameterType];
                }

                property.TypeParameter = exportedType.TypeParameters.FirstOrDefault(
                    t => t.Name == property.Type.Name);

                exportedType.Properties.Add(property);
            }
        }
Exemplo n.º 8
0
        private void SaveNode(TreeNode tn)
        {
            ChangeInfo info = (ChangeInfo)tn.Tag;

            if (tn.Checked)
            {
                if (info.Original == null)
                {
                    // add new item
                    if (info.Change is DocLocalization)
                    {
                        DocLocalization localChange = (DocLocalization)info.Change;

                        ChangeInfo parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocObject  docObj     = (DocObject)parentinfo.Original;
                        docObj.RegisterLocalization(localChange.Locale, localChange.Name, localChange.Documentation);
                    }
                    else if (info.Change is DocAttribute)
                    {
                        DocAttribute localAttr = (DocAttribute)info.Change;

                        ChangeInfo parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocEntity  docEntity  = (DocEntity)parentinfo.Original;

                        DocAttribute docAttr = (DocAttribute)localAttr.Clone();
                        docEntity.Attributes.Add(docAttr);
                    }
                    else if (info.Change is DocWhereRule)
                    {
                        DocWhereRule localAttr = (DocWhereRule)info.Change;

                        ChangeInfo parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocEntity  docEntity  = (DocEntity)parentinfo.Original;

                        DocWhereRule docAttr = (DocWhereRule)localAttr.Clone();
                        docEntity.WhereRules.Add(docAttr);
                    }
                    else if (info.Change is DocFunction)
                    {
                        DocFunction localAttr = (DocFunction)info.Change;

                        ChangeInfo parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocSchema  docSchema  = (DocSchema)parentinfo.Original;

                        DocFunction docAttr = (DocFunction)localAttr.Clone();
                        docSchema.Functions.Add(docAttr);
                    }
                    else if (info.Change is DocConstant)
                    {
                        this.ToString();
                    }
                    else if (info.Change is DocProperty)
                    {
                        this.ToString();

                        DocProperty localProp = (DocProperty)info.Change;

                        ChangeInfo     parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocPropertySet docPset    = (DocPropertySet)parentinfo.Original;

                        DocProperty docProperty = (DocProperty)localProp.Clone();
                        docPset.Properties.Add(docProperty);
                    }
                    else if (info.Change is DocPropertyConstant)
                    {
                        this.ToString();

                        DocPropertyConstant localProp = (DocPropertyConstant)info.Change;

                        ChangeInfo             parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocPropertyEnumeration docPset    = (DocPropertyEnumeration)parentinfo.Original;

                        DocPropertyEnumeration docEnumChange = (DocPropertyEnumeration)parentinfo.Change;
                        int index = docEnumChange.Constants.IndexOf(localProp);

                        DocPropertyConstant docProperty = (DocPropertyConstant)localProp.Clone();
                        docPset.Constants.Insert(index, docProperty);
                    }
                    else
                    {
                        this.ToString();
                    }
                }
                else if (info.Change == null)
                {
                    // removal of definition
                    if (info.Original is DocAttribute)
                    {
                        DocAttribute docAttr    = (DocAttribute)info.Original;
                        ChangeInfo   parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocEntity    docEntity  = (DocEntity)parentinfo.Original;

                        docEntity.Attributes.Remove(docAttr);
                        docAttr.Delete();
                    }
                    else
                    {
                        this.ToString();
                    }
                }
                else
                {
                    // change of documentation
                    info.Original.Name          = info.Change.Name;
                    info.Original.Documentation = info.Change.Documentation;

                    if (info.Original is DocWhereRule)
                    {
                        DocWhereRule whereOriginal = (DocWhereRule)info.Original;
                        DocWhereRule whereChange   = (DocWhereRule)info.Change;
                        whereOriginal.Expression = whereChange.Expression;
                    }
                    else if (info.Original is DocFunction)
                    {
                        DocFunction whereOriginal = (DocFunction)info.Original;
                        DocFunction whereChange   = (DocFunction)info.Change;
                        whereOriginal.Expression = whereChange.Expression;
                    }
                }
            }

            foreach (TreeNode tnSub in tn.Nodes)
            {
                SaveNode(tnSub);
            }
        }
Exemplo n.º 9
0
        private static void extractListings(DocProject project, DocProperty property, Dictionary <string, DocPropertyEnumeration> encounteredPropertyEnumerations)
        {
            project.Properties.Add(property);

            if (string.IsNullOrEmpty(property.SecondaryDataType))
            {
                property.SecondaryDataType = null;
            }
            else if (property.PropertyType == DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE && property.Enumeration == null)
            {
                string[] fields = property.SecondaryDataType.Split(":".ToCharArray());
                if (fields.Length == 1)
                {
                    string name = fields[0];
                    foreach (DocPropertyEnumeration docEnumeration in project.PropertyEnumerations)
                    {
                        if (string.Compare(name, docEnumeration.Name) == 0)
                        {
                            property.Enumeration       = docEnumeration;
                            property.SecondaryDataType = null;
                            break;
                        }
                    }
                }
                else if (fields.Length == 2)
                {
                    string name = fields[0];
                    DocPropertyEnumeration propertyEnumeration = null;
                    if (encounteredPropertyEnumerations.TryGetValue(name, out propertyEnumeration))
                    {
                        property.SecondaryDataType = null;
                        property.Enumeration       = propertyEnumeration;
                    }
                    else
                    {
                        foreach (DocPropertyEnumeration docEnumeration in project.PropertyEnumerations)
                        {
                            if (string.Compare(name, docEnumeration.Name) == 0)
                            {
                                property.Enumeration       = docEnumeration;
                                property.SecondaryDataType = null;
                                break;
                            }
                        }
                        if (property.Enumeration == null)
                        {
                            property.Enumeration = new DocPropertyEnumeration()
                            {
                                Name = name
                            };
                            project.PropertyEnumerations.Add(property.Enumeration = property.Enumeration);
                            encounteredPropertyEnumerations[name] = property.Enumeration;
                            foreach (string str in fields[1].Split(",".ToCharArray()))
                            {
                                string constantName          = str.Trim();
                                DocPropertyConstant constant = null;
                                foreach (DocPropertyConstant docConstant in project.PropertyConstants)
                                {
                                    if (string.Compare(docConstant.Name, constantName) == 0)
                                    {
                                        constant = docConstant;
                                        break;
                                    }
                                }
                                if (constant == null)
                                {
                                    constant = new DocPropertyConstant()
                                    {
                                        Name = constantName
                                    };
                                    project.PropertyConstants.Add(constant);
                                }
                                property.Enumeration.Constants.Add(constant);
                            }
                            property.SecondaryDataType = null;
                        }
                    }
                }
            }

            foreach (DocProperty element in property.Elements)
            {
                extractListings(project, element, encounteredPropertyEnumerations);
            }
        }
Exemplo n.º 10
0
        private void WriteList(System.IO.StreamWriter writer, SortedList <string, DocObject> sortlist)
        {
            foreach (string key in sortlist.Keys)
            {
                DocObject docEntity = sortlist[key];

                WriteItem(writer, docEntity, 0, docEntity.Name);

                if (docEntity is DocEntity)
                {
                    if ((this.m_scope & DocDefinitionScopeEnum.EntityAttribute) != 0)
                    {
                        DocEntity docEnt = (DocEntity)docEntity;
                        foreach (DocAttribute docAttr in docEnt.Attributes)
                        {
                            WriteItem(writer, docAttr, 1, docEntity.Name);
                        }
                    }
                }
                else if (docEntity is DocEnumeration)
                {
                    if ((this.m_scope & DocDefinitionScopeEnum.TypeConstant) != 0)
                    {
                        DocEnumeration docEnum = (DocEnumeration)docEntity;
                        foreach (DocConstant docConst in docEnum.Constants)
                        {
                            WriteItem(writer, docConst, 1, docEntity.Name);
                        }
                    }
                }
                else if (docEntity is DocPropertySet)
                {
                    if ((this.m_scope & DocDefinitionScopeEnum.PsetProperty) != 0)
                    {
                        DocPropertySet docPset       = (DocPropertySet)docEntity;
                        DocEntity      docApp        = null;
                        DocEntity[]    docApplicable = docPset.GetApplicableTypeDefinitions(this.m_project);
                        if (docApplicable != null && docApplicable.Length > 0 && docApplicable[0] != null)
                        {
                            docApp = this.m_project.GetDefinition(docApplicable[0].BaseDefinition) as DocEntity;
                        }
                        foreach (DocProperty docProp in docPset.Properties)
                        {
                            // filter out leaf properties defined at common pset (e.g. Reference, Status)
                            DocProperty docSuper = this.m_project.FindProperty(docProp.Name, docApp);
                            if (docSuper == docProp || docSuper == null)
                            {
                                WriteItem(writer, docProp, 1, docEntity.Name);
                            }
                        }
                    }
                }
                else if (docEntity is DocPropertyEnumeration)
                {
                    if ((this.m_scope & DocDefinitionScopeEnum.PEnumConstant) != 0)
                    {
                        DocPropertyEnumeration docPE = (DocPropertyEnumeration)docEntity;
                        foreach (DocPropertyConstant docPC in docPE.Constants)
                        {
                            WriteItem(writer, docPC, 1, docEntity.Name);
                        }
                    }
                }
                else if (docEntity is DocQuantitySet)
                {
                    if ((this.m_scope & DocDefinitionScopeEnum.QsetQuantity) != 0)
                    {
                        DocQuantitySet docQset = (DocQuantitySet)docEntity;
                        foreach (DocQuantity docQuan in docQset.Quantities)
                        {
                            WriteItem(writer, docQuan, 1, docEntity.Name);
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        public static void ImportPsdPropertyTemplate(PropertyDef def, DocProperty docprop)
        {
            DocPropertyTemplateTypeEnum proptype = DocPropertyTemplateTypeEnum.P_SINGLEVALUE;
            string datatype = String.Empty;
            string elemtype = String.Empty;

            if (def.PropertyType.TypePropertyEnumeratedValue != null)
            {
                proptype = DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE;
                datatype = "IfcLabel";
                StringBuilder sbEnum = new StringBuilder();
                sbEnum.Append(def.PropertyType.TypePropertyEnumeratedValue.EnumList.name);
                sbEnum.Append(":");
                foreach (EnumItem item in def.PropertyType.TypePropertyEnumeratedValue.EnumList.Items)
                {
                    sbEnum.Append(item.Value);
                    sbEnum.Append(",");
                }
                sbEnum.Length--; // remove trailing ','
                elemtype = sbEnum.ToString();
            }
            else if (def.PropertyType.TypePropertyReferenceValue != null)
            {
                proptype = DocPropertyTemplateTypeEnum.P_REFERENCEVALUE;
                datatype = def.PropertyType.TypePropertyReferenceValue.reftype;
                if (def.PropertyType.TypePropertyReferenceValue.DataType != null)
                {
                    elemtype = def.PropertyType.TypePropertyReferenceValue.DataType.type; // e.g. IfcTimeSeries
                }
            }
            else if (def.PropertyType.TypePropertyBoundedValue != null)
            {
                proptype = DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE;
                datatype = def.PropertyType.TypePropertyBoundedValue.DataType.type;
            }
            else if (def.PropertyType.TypePropertyListValue != null)
            {
                proptype = DocPropertyTemplateTypeEnum.P_LISTVALUE;
                datatype = def.PropertyType.TypePropertyListValue.ListValue.DataType.type;
            }
            else if (def.PropertyType.TypePropertyTableValue != null)
            {
                proptype = DocPropertyTemplateTypeEnum.P_TABLEVALUE;
                datatype = def.PropertyType.TypePropertyTableValue.DefiningValue.DataType.type;
                elemtype = def.PropertyType.TypePropertyTableValue.DefinedValue.DataType.type;
            }
            else if (def.PropertyType.TypePropertySingleValue != null)
            {
                proptype = DocPropertyTemplateTypeEnum.P_SINGLEVALUE;
                datatype = def.PropertyType.TypePropertySingleValue.DataType.type;
            }
            else if (def.PropertyType.TypeComplexProperty != null)
            {
                proptype = DocPropertyTemplateTypeEnum.COMPLEX;
                datatype = def.PropertyType.TypeComplexProperty.name;
            }

            if (!String.IsNullOrEmpty(def.IfdGuid))
            {
                try
                {
                    docprop.Uuid = new Guid(def.IfdGuid);
                }
                catch
                {
                }
            }

            docprop.Name = def.Name;
            if (def.Definition != null)
            {
                docprop.Documentation = def.Definition.Trim();
            }
            docprop.PropertyType = proptype;
            docprop.PrimaryDataType = datatype;
            docprop.SecondaryDataType = elemtype.Trim();

            foreach (NameAlias namealias in def.NameAliases)
            {
                string localdesc = null;
                foreach (DefinitionAlias docalias in def.DefinitionAliases)
                {
                    if (docalias.lang.Equals(namealias.lang))
                    {
                        localdesc = docalias.Value;
                    }
                }

                docprop.RegisterLocalization(namealias.lang, namealias.Value, localdesc);
            }

            // recurse for complex properties
            if (def.PropertyType.TypeComplexProperty != null)
            {
                foreach (PropertyDef subdef in def.PropertyType.TypeComplexProperty.PropertyDefs)
                {
                    DocProperty subprop = docprop.RegisterProperty(subdef.Name);
                    ImportPsdPropertyTemplate(subdef, subprop);
                }
            }
        }
Exemplo n.º 12
0
        private static void ExportPsdProperty(DocProperty docProp, PropertyDef prop, Dictionary<string, DocPropertyEnumeration> mapPropEnum)
        {
            prop.IfdGuid = docProp.Uuid.ToString("N");
            prop.Name = docProp.Name;
            prop.Definition = docProp.Documentation;

            prop.NameAliases = new List<NameAlias>();
            prop.DefinitionAliases = new List<DefinitionAlias>();
            foreach (DocLocalization docLocal in docProp.Localization)
            {
                NameAlias na = new NameAlias();
                prop.NameAliases.Add(na);
                na.lang = docLocal.Locale;
                na.Value = docLocal.Name;

                DefinitionAlias da = new DefinitionAlias();
                prop.DefinitionAliases.Add(da);
                da.lang = docLocal.Locale;
                da.Value = docLocal.Documentation;
            }

            prop.PropertyType = new PropertyType();
            switch (docProp.PropertyType)
            {
                case DocPropertyTemplateTypeEnum.P_SINGLEVALUE:
                    prop.PropertyType.TypePropertySingleValue = new TypePropertySingleValue();
                    prop.PropertyType.TypePropertySingleValue.DataType = new DataType();
                    prop.PropertyType.TypePropertySingleValue.DataType.type = docProp.PrimaryDataType;
                    break;

                case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE:
                    prop.PropertyType.TypePropertyBoundedValue = new TypePropertyBoundedValue();
                    prop.PropertyType.TypePropertyBoundedValue.DataType = new DataType();
                    prop.PropertyType.TypePropertyBoundedValue.DataType.type = docProp.PrimaryDataType;
                    break;

                case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE:
                    prop.PropertyType.TypePropertyEnumeratedValue = new TypePropertyEnumeratedValue();
                    prop.PropertyType.TypePropertyEnumeratedValue.EnumList = new EnumList();
                    {
                        if (docProp.SecondaryDataType != null)
                        {
                            string[] parts = docProp.SecondaryDataType.Split(':');
                            if (parts.Length == 2)
                            {
                                string[] enums = parts[1].Split(',');
                                prop.PropertyType.TypePropertyEnumeratedValue.EnumList.name = parts[0];
                                prop.PropertyType.TypePropertyEnumeratedValue.EnumList.Items = new List<EnumItem>();
                                foreach (string eachenum in enums)
                                {
                                    EnumItem eni = new EnumItem();
                                    prop.PropertyType.TypePropertyEnumeratedValue.EnumList.Items.Add(eni);
                                    eni.Value = eachenum.Trim();
                                }
                            }

                            string propenum = docProp.SecondaryDataType;
                            if (propenum != null)
                            {
                                int colon = propenum.IndexOf(':');
                                if (colon > 0)
                                {
                                    propenum = propenum.Substring(0, colon);
                                }
                            }
                            DocPropertyEnumeration docPropEnum = null;
                            if (mapPropEnum.TryGetValue(propenum, out docPropEnum))
                            {
                                prop.PropertyType.TypePropertyEnumeratedValue.ConstantList = new ConstantList();
                                prop.PropertyType.TypePropertyEnumeratedValue.ConstantList.Items = new List<ConstantDef>();
                                foreach (DocPropertyConstant docPropConst in docPropEnum.Constants)
                                {
                                    ConstantDef con = new ConstantDef();
                                    prop.PropertyType.TypePropertyEnumeratedValue.ConstantList.Items.Add(con);

                                    con.Name = docPropConst.Name.Trim();
                                    con.Definition = docPropConst.Documentation;
                                    con.NameAliases = new List<NameAlias>();
                                    con.DefinitionAliases = new List<DefinitionAlias>();

                                    foreach (DocLocalization docLocal in docPropConst.Localization)
                                    {
                                        NameAlias na = new NameAlias();
                                        con.NameAliases.Add(na);
                                        na.lang = docLocal.Locale;
                                        na.Value = docLocal.Name.Trim();

                                        DefinitionAlias da = new DefinitionAlias();
                                        con.DefinitionAliases.Add(da);
                                        da.lang = docLocal.Locale;
                                        da.Value = docLocal.Documentation;
                                    }
                                }
                            }
                        }
                    }

                    break;

                case DocPropertyTemplateTypeEnum.P_LISTVALUE:
                    prop.PropertyType.TypePropertyListValue = new TypePropertyListValue();
                    prop.PropertyType.TypePropertyListValue.ListValue = new ListValue();
                    prop.PropertyType.TypePropertyListValue.ListValue.DataType = new DataType();
                    prop.PropertyType.TypePropertyListValue.ListValue.DataType.type = docProp.PrimaryDataType;
                    break;

                case DocPropertyTemplateTypeEnum.P_TABLEVALUE:
                    prop.PropertyType.TypePropertyTableValue = new TypePropertyTableValue();
                    prop.PropertyType.TypePropertyTableValue.Expression = String.Empty;
                    prop.PropertyType.TypePropertyTableValue.DefiningValue = new DefiningValue();
                    prop.PropertyType.TypePropertyTableValue.DefiningValue.DataType = new DataType();
                    prop.PropertyType.TypePropertyTableValue.DefiningValue.DataType.type = docProp.PrimaryDataType;
                    prop.PropertyType.TypePropertyTableValue.DefinedValue = new DefinedValue();
                    prop.PropertyType.TypePropertyTableValue.DefinedValue.DataType = new DataType();
                    prop.PropertyType.TypePropertyTableValue.DefinedValue.DataType.type = docProp.SecondaryDataType;
                    break;

                case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE:
                    prop.PropertyType.TypePropertyReferenceValue = new TypePropertyReferenceValue();
                    prop.PropertyType.TypePropertyReferenceValue.reftype = docProp.PrimaryDataType;
                    break;

                case DocPropertyTemplateTypeEnum.COMPLEX:
                    prop.PropertyType.TypeComplexProperty = new TypeComplexProperty();
                    prop.PropertyType.TypeComplexProperty.name = docProp.PrimaryDataType;
                    prop.PropertyType.TypeComplexProperty.PropertyDefs = new List<PropertyDef>();
                    foreach(DocProperty docSub in docProp.Elements)
                    {
                        PropertyDef sub = new PropertyDef();
                        prop.PropertyType.TypeComplexProperty.PropertyDefs.Add(sub);
                        ExportPsdProperty(docSub, sub, mapPropEnum);
                    }
                    break;
            }
        }
Exemplo n.º 13
0
 private void toolStripMenuItemInsertProperty_Click(object sender, EventArgs e)
 {
     DocPropertySet docPset = (DocPropertySet)this.treeView.SelectedNode.Tag;
     DocProperty docProp = new DocProperty();
     docPset.Properties.Add(docProp);
     docProp.PropertyType = DocPropertyTemplateTypeEnum.P_SINGLEVALUE;
     this.treeView.SelectedNode = this.LoadNode(this.treeView.SelectedNode, docProp, docProp.Name, false);
     this.toolStripMenuItemEditRename_Click(sender, e);
 }
Exemplo n.º 14
0
        private void toolStripMenuItemEditPaste_Click(object sender, EventArgs e)
        {
            if (this.treeView.Focused)
            {
                DocObject docSelect = this.treeView.SelectedNode.Tag as DocObject;
                if (docSelect is DocSection && this.m_clipboard is DocSchema && this.m_clipboardNode.Parent.Tag is DocSection)
                {
                    DocSchema docSchema = (DocSchema)this.m_clipboard;
                    DocSection docSectionNew = (DocSection)docSelect;
                    DocSection docSectionOld = (DocSection)this.m_clipboardNode.Parent.Tag;

                    docSectionOld.Schemas.Remove(docSchema);
                    docSectionNew.Schemas.Add(docSchema);

                    this.m_clipboardNode.Remove();
                    TreeNode tnSchema = this.LoadNode(this.treeView.SelectedNode, docSchema, docSchema.Name, true);
                    this.treeView.SelectedNode = tnSchema;
                    LoadNodeSchema(tnSchema, docSchema);
                }
                else if (docSelect is DocSchema && this.m_clipboard is DocPropertySet)
                {
                    DocSchema schemaNew = (DocSchema)docSelect;
                    DocPropertySet psetOld = (DocPropertySet)this.m_clipboard;
                    if (this.m_clipboardCut)
                    {
                        if (this.m_clipboardNode.Parent.Parent.Tag is DocSchema)
                        {
                            DocSchema schemaOld = (DocSchema)this.m_clipboardNode.Parent.Parent.Tag;
                            schemaOld.PropertySets.Remove(psetOld);
                            schemaNew.PropertySets.Add(psetOld);

                            this.m_clipboardNode.Remove();
                            this.m_clipboardNode = null;
                            this.m_clipboard = null;
                            this.m_clipboardCut = false;

                            this.treeView.SelectedNode = this.LoadNode(this.treeView.SelectedNode.Nodes[4], psetOld, psetOld.Name, false);
                        }
                    }
                    else
                    {
                        // TODO...
                    }
                }
                else if (docSelect is DocPropertySet && this.m_clipboard is DocProperty)
                {
                    DocPropertySet psetNew = (DocPropertySet)docSelect;
                    DocProperty propOld = (DocProperty)this.m_clipboard;
                    if (this.m_clipboardCut)
                    {
                        if (this.m_clipboardNode.Parent.Tag is DocPropertySet)
                        {
                            DocPropertySet psetOld = (DocPropertySet)this.m_clipboardNode.Parent.Tag;
                            psetOld.Properties.Remove(propOld);
                            psetNew.Properties.Add(propOld);

                            this.m_clipboardNode.Remove();
                            this.m_clipboardNode = null;
                            this.m_clipboard = null;
                            this.m_clipboardCut = false;

                            this.treeView.SelectedNode = this.LoadNode(this.treeView.SelectedNode, propOld, propOld.Name, false);
                        }
                    }
                    else
                    {
                        DocProperty propNew = new DocProperty();
                        propNew.Name = propOld.Name;
                        propNew.Documentation = propOld.Documentation;
                        propNew.PropertyType = propOld.PropertyType;
                        propNew.PrimaryDataType = propOld.PrimaryDataType;
                        propNew.SecondaryDataType = propOld.SecondaryDataType;
                        foreach(DocLocalization localOld in propOld.Localization)
                        {
                            DocLocalization localNew = new DocLocalization();
                            localNew.Name = localOld.Name;
                            localNew.Documentation = localOld.Documentation;
                            localNew.Category = localOld.Category;
                            localNew.Locale = localOld.Locale;
                            localNew.URL = localOld.URL;
                            propNew.Localization.Add(localNew);
                        }

                        this.treeView.SelectedNode = this.LoadNode(this.treeView.SelectedNode, propNew, propNew.Name, false);
                    }
                }
                else if (docSelect is DocConceptRoot && this.m_clipboard is DocTemplateUsage)
                {
                    DocConceptRoot docRoot = (DocConceptRoot)docSelect;

                    DocTemplateUsage docSource = (DocTemplateUsage)this.m_clipboard;
                    DocTemplateUsage docTarget = new DocTemplateUsage();
                    docRoot.Concepts.Add(docTarget);

                    CopyTemplateUsage(docSource, docTarget);

                    this.treeView.SelectedNode = LoadNode(this.treeView.SelectedNode, docTarget, docTarget.Name, false);
                }
                else if (docSelect is DocModelView && this.m_clipboard is DocExchangeDefinition)
                {
                    DocModelView docView = (DocModelView)docSelect;
                    DocExchangeDefinition docSource = (DocExchangeDefinition)this.m_clipboard;
                    DocExchangeDefinition docTarget = new DocExchangeDefinition();

                    docView.Exchanges.Add(docTarget);
                    docTarget.Name = docSource.Name;
                    docTarget.Documentation = docSource.Documentation;
                    docTarget.Author = docSource.Author;
                    docTarget.Copyright = docSource.Copyright;
                    docTarget.Owner = docSource.Owner;
                    docTarget.Icon = docSource.Icon;

                    // copy entity requirements if in same view
                    if (docView.Exchanges.Contains(docSource))
                    {
                        foreach (DocConceptRoot docRoot in docView.ConceptRoots)
                        {
                            foreach (DocTemplateUsage docConcept in docRoot.Concepts)
                            {
                                List<DocExchangeItem> listNew = new List<DocExchangeItem>();

                                foreach (DocExchangeItem docSourceER in docConcept.Exchanges)
                                {
                                    if (docSourceER.Exchange == docSource)
                                    {
                                        DocExchangeItem docTargetER = new DocExchangeItem();
                                        docTargetER.Exchange = docTarget;
                                        docTargetER.Applicability = docSourceER.Applicability;
                                        docTargetER.Requirement = docSourceER.Requirement;

                                        listNew.Add(docTargetER);
                                    }
                                }

                                foreach (DocExchangeItem docTargetER in listNew)
                                {
                                    docConcept.Exchanges.Add(docTargetER);
                                }
                            }
                        }
                    }

                    this.treeView.SelectedNode = LoadNode(this.treeView.SelectedNode, docTarget, docTarget.Name, false);
                }
            }
            else
            {
                this.textBoxHTML.Paste();
            }
        }
Exemplo n.º 15
0
        private void toolStripButtonTemplateInsert_Click(object sender, EventArgs e)
        {
            if (this.dataGridViewConceptRules.SelectedRows.Count == 0)
            {
                return;
            }

            this.m_editcon = true;

            DocPropertySet existingPropertySet = null;

            bool isPsetDefined     = false;
            bool isPropertyDefined = false;

            if (this.m_conceptleaf != null)
            {
                if (this.m_conceptleaf.Definition.Uuid == DocTemplateDefinition.guidTemplatePropertyList || this.m_conceptleaf.Definition.Uuid == DocTemplateDefinition.guidTemplatePropertyBounded ||
                    this.m_conceptleaf.Definition.Uuid == DocTemplateDefinition.guidTemplatePropertyEnumerated || this.m_conceptleaf.Definition.Uuid == DocTemplateDefinition.guidTemplatePropertyReference ||
                    this.m_conceptleaf.Definition.Uuid == DocTemplateDefinition.guidTemplatePropertySingle || this.m_conceptleaf.Definition.Uuid == DocTemplateDefinition.guidTemplatePropertyTable)
                {
                    foreach (DocSection docSection in this.Project.Sections)
                    {
                        foreach (DocSchema docSchema in docSection.Schemas)
                        {
                            foreach (DocPropertySet docPset in docSchema.PropertySets)
                            {
                                if (docPset.Name == this.ConceptItem.Name)
                                {
                                    isPsetDefined       = true;
                                    existingPropertySet = docPset;
                                }
                                // search properties
                                foreach (DocProperty docProp in docPset.Properties)
                                {
                                    for (int i = 0; i < this.dataGridViewConceptRules.SelectedRows.Count; i++)
                                    {
                                        if (dataGridViewConceptRules.SelectedRows[i].Tag is DocTemplateItem)
                                        {
                                            DocTemplateItem propertyItem = (DocTemplateItem)dataGridViewConceptRules.SelectedRows[i].Tag;
                                            if (docProp.Name == propertyItem.GetParameterValue("PropertyName"))
                                            {
                                                isPropertyDefined = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    //this.m_conceptroot.ApplicableItems.RemoveAt(index);
                }

                if (!isPsetDefined)
                {
                    FormSelectSchema schemaSelect = new FormSelectSchema(this.Project);
                    schemaSelect.ShowDialog();

                    DocPropertySet  pset     = new DocPropertySet();
                    DocTemplateItem psetItem = (DocTemplateItem)this.ConceptItem;
                    pset.Name = psetItem.GetParameterValue("PsetName");
                    if (!isPropertyDefined)
                    {
                        for (int i = 0; i < this.dataGridViewConceptRules.SelectedRows.Count; i++)
                        {
                            DocProperty property = new DocProperty();
                            if (dataGridViewConceptRules.SelectedRows[i].Tag is DocTemplateItem)
                            {
                                DocTemplateItem propertyItem = (DocTemplateItem)dataGridViewConceptRules.SelectedRows[i].Tag;
                                property.Name = propertyItem.GetParameterValue("PropertyName");
                                //if (propertyItem.GetParameterValue("Value") != null)
                                //{
                                property.PrimaryDataType = propertyItem.GetParameterValue("Value");
                                //}
                                pset.Properties.Add(property);
                            }
                        }
                    }
                    schemaSelect.Selection.PropertySets.Add(pset);
                }
                else
                {
                    if (!isPropertyDefined)
                    {
                        for (int i = 0; i < this.dataGridViewConceptRules.SelectedRows.Count; i++)
                        {
                            DocProperty property = new DocProperty();
                            if (dataGridViewConceptRules.SelectedRows[i].Tag is DocTemplateItem)
                            {
                                DocTemplateItem propertyItem = (DocTemplateItem)dataGridViewConceptRules.SelectedRows[i].Tag;
                                property.Name = propertyItem.GetParameterValue("PropertyName");
                                //if (propertyItem.GetParameterValue("Value") != null)
                                //{
                                property.PrimaryDataType = propertyItem.GetParameterValue("Value");
                                //}
                                existingPropertySet.Properties.Add(property);
                            }
                        }
                    }
                }

                if (this.ParentForm.Owner is FormEdit)
                {
                    FormEdit ownerForm = (FormEdit)this.ParentForm.Owner;
                    //ownerForm.i
                }
                this.m_editcon = false;
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Extracts description of referenced data, using properties, quantities, and attributes.
        /// </summary>
        /// <param name="mapEntity"></param>
        /// <param name="docView">Optional model view, for retrieving more specific descriptions such as for ports</param>
        /// <returns></returns>
        public string GetDescription(Dictionary<string, DocObject> mapEntity, DocModelView docView)
        {
            string desc = null;
            CvtValuePath valpath = this;

            if (valpath != null &&
                valpath.Property != null &&
                valpath.Property.Name.Equals("IsDefinedBy") &&
                valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcRelDefinesByProperties"))
            {
                DocObject docPset = null;
                mapEntity.TryGetValue(valpath.Identifier, out docPset);

                if (docPset is DocPropertySet)
                {
                    DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;// localize??
                    }
                }
                else if (docPset is DocQuantitySet)
                {
                    DocQuantity docProp = ((DocQuantitySet)docPset).GetQuantity(valpath.InnerPath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;// localize??
                    }
                }
            }
            else if (valpath != null &&
                valpath.Property != null &&
                valpath.Property.Name.Equals("HasPropertySets") &&
                valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcPropertySet"))
            {
                DocObject docPset = null;
                mapEntity.TryGetValue(valpath.Identifier, out docPset);

                if (docPset is DocPropertySet)
                {
                    DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;// localize??
                    }
                }
            }
            else if(valpath != null &&
                valpath.Property != null &&
                valpath.Property.Name.Equals("Material") &&
                valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcMaterial") &&
                valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath.Type.Name.Equals("IfcMaterialProperties"))
            {
                DocObject docPset = null;
                mapEntity.TryGetValue(valpath.InnerPath.Identifier, out docPset);

                if(docPset is DocPropertySet)
                {
                    DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.Identifier);
                    if(docProp != null)
                    {
                        desc = docProp.Documentation;
                    }
                }
            }
            else if (valpath != null && 
                valpath.Property != null &&
                valpath.Property.Name.Equals("IsNestedBy") &&
                valpath.InnerPath != null && valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath != null)
            {
                CvtValuePath pathInner = valpath.InnerPath.InnerPath;
                if (pathInner.Type != null && pathInner.Type.Name.Equals("IfcDistributionPort"))
                {
                    string portname = valpath.InnerPath.Identifier;
                    if (pathInner.Property != null && pathInner.Property.Name.Equals("IsDefinedBy"))
                    {
                        // lookup description of property at port
                        DocObject docPset = null;
                        mapEntity.TryGetValue(pathInner.Identifier, out docPset);

                        if (docPset is DocPropertySet)
                        {
                            DocProperty docProp = ((DocPropertySet)docPset).GetProperty(pathInner.InnerPath.InnerPath.Identifier);
                            if (docProp != null)
                            {
                                desc = portname + ": " + docProp.Documentation;
                            }
                        }

                    }
                    else
                    {
                        desc = portname;

                        // lookup description of port
                        Guid guidPortNesting = new Guid("bafc93b7-d0e2-42d8-84cf-5da20ee1480a");
                        foreach (DocConceptRoot docRoot in docView.ConceptRoots)
                        {
                            if (docRoot.ApplicableEntity == valpath.Type)
                            {
                                foreach(DocTemplateUsage docConcept in docRoot.Concepts)
                                {
                                    if(docConcept.Definition != null && docConcept.Definition.Uuid == guidPortNesting)
                                    {
                                        foreach (DocTemplateItem docItem in docConcept.Items)
                                        {
                                            if(docItem.Name.Equals(portname))
                                            {
                                                desc = docItem.Documentation;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (desc == null)
            {
                while (valpath != null && valpath.InnerPath != null && valpath.InnerPath.Property != null)
                {
                    valpath = valpath.InnerPath;
                }
                if (valpath != null && valpath.Property != null)
                {
                    desc = valpath.Property.Documentation;
                }
                else if (valpath != null)
                {
                    desc = "The IFC class identifier indicating the subtype of object.";
                }
            }

            return desc;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Extracts description of referenced data, using properties, quantities, and attributes.
        /// </summary>
        /// <param name="mapEntity"></param>
        /// <param name="docView">Optional model view, for retrieving more specific descriptions such as for ports</param>
        /// <returns></returns>
        public string GetDescription(Dictionary <string, DocObject> mapEntity, DocModelView docView)
        {
            string       desc    = null;
            CvtValuePath valpath = this;

            if (valpath != null &&
                valpath.Property != null &&
                valpath.Property.Name.Equals("IsDefinedBy") &&
                valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcRelDefinesByProperties") &&
                valpath.Identifier != null)
            {
                DocObject docPset = null;
                mapEntity.TryGetValue(valpath.Identifier, out docPset);

                if (docPset is DocPropertySet)
                {
                    DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;// localize??

                        if (String.IsNullOrEmpty(docProp.Documentation))
                        {
                            this.ToString();
                        }
                    }
                }
                else if (docPset is DocQuantitySet)
                {
                    DocQuantity docProp = ((DocQuantitySet)docPset).GetQuantity(valpath.InnerPath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;// localize??

                        if (String.IsNullOrEmpty(docProp.Documentation))
                        {
                            this.ToString();
                        }
                    }
                }
            }
            else if (valpath != null &&
                     valpath.Property != null &&
                     valpath.Property.Name.Equals("HasAssignments") &&
                     valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcRelAssignsToControl") &&
                     valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath.Type.Name.Equals("IfcPerformanceHistory"))
            {
                DocObject docPset = null;
                if (mapEntity.TryGetValue(valpath.InnerPath.InnerPath.Identifier, out docPset))
                {
                    DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.InnerPath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;// localize??

                        if (docProp.Documentation == null)
                        {
                            DocLocalization docLoc = docProp.GetLocalization(null);
                            if (docLoc != null)
                            {
                                desc = docLoc.Documentation;
                            }
                        }
                    }
                }

                this.ToString();
            }
            else if (valpath != null &&
                     valpath.Property != null &&
                     valpath.Property.Name.Equals("HasPropertySets") &&
                     valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcPropertySet"))
            {
                DocObject docPset = null;
                mapEntity.TryGetValue(valpath.Identifier, out docPset);

                if (docPset is DocPropertySet)
                {
                    DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;// localize??

                        if (String.IsNullOrEmpty(docProp.Documentation))
                        {
                            this.ToString();
                        }
                    }
                }
            }
            else if (valpath != null &&
                     valpath.Property != null &&
                     valpath.Property.Name.Equals("Material") &&
                     valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcMaterial") &&
                     valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath.Type.Name.Equals("IfcMaterialProperties"))
            {
                DocObject docPset = null;
                mapEntity.TryGetValue(valpath.InnerPath.Identifier, out docPset);

                if (docPset is DocPropertySet)
                {
                    DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;
                    }
                }
            }
            else if (valpath != null &&
                     valpath.Property != null &&
                     valpath.Property.Name.Equals("HasProperties") &&
                     valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcMaterialProperties"))
            {
                DocObject docPset = null;
                mapEntity.TryGetValue(valpath.Identifier, out docPset);

                if (docPset is DocPropertySet)
                {
                    DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.Identifier);
                    if (docProp != null)
                    {
                        desc = docProp.Documentation;
                    }
                }
            }
            else if (valpath != null &&
                     valpath.Property != null &&
                     valpath.Property.Name.Equals("IsNestedBy") &&
                     valpath.InnerPath != null && valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath != null)
            {
                CvtValuePath pathInner = valpath.InnerPath.InnerPath;
                if (pathInner.Type != null && pathInner.Type.Name.Equals("IfcDistributionPort"))
                {
                    string portname = valpath.InnerPath.Identifier;
                    if (pathInner.Property != null && pathInner.Property.Name.Equals("IsDefinedBy"))
                    {
                        // lookup description of property at port
                        DocObject docPset = null;
                        mapEntity.TryGetValue(pathInner.Identifier, out docPset);

                        if (docPset is DocPropertySet)
                        {
                            DocProperty docProp = ((DocPropertySet)docPset).GetProperty(pathInner.InnerPath.InnerPath.Identifier);
                            if (docProp != null)
                            {
                                desc = portname + ": " + docProp.Documentation;
                            }
                        }
                    }
                    else
                    {
                        desc = portname;

                        // lookup description of port
                        Guid guidPortNesting = new Guid("bafc93b7-d0e2-42d8-84cf-5da20ee1480a");
                        if (docView != null)
                        {
                            foreach (DocConceptRoot docRoot in docView.ConceptRoots)
                            {
                                if (docRoot.ApplicableEntity == valpath.Type)
                                {
                                    foreach (DocTemplateUsage docConcept in docRoot.Concepts)
                                    {
                                        if (docConcept.Definition != null && docConcept.Definition.Uuid == guidPortNesting)
                                        {
                                            foreach (DocTemplateItem docItem in docConcept.Items)
                                            {
                                                if (docItem.Name != null && docItem.Name.Equals(portname))
                                                {
                                                    desc = docItem.Documentation;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (desc == null)
            {
                while (valpath != null && valpath.InnerPath != null && valpath.InnerPath.Property != null)
                {
                    valpath = valpath.InnerPath;
                }
                if (valpath != null && valpath.Property != null)
                {
                    desc = valpath.Property.Documentation;
                }
                else if (valpath != null)
                {
                    desc = "The IFC class identifier indicating the subtype of object.";
                }
            }

            // clear out any notes
            int block = desc.IndexOf("<blockquote");

            if (block != -1)
            {
                desc = desc.Substring(0, block);
            }

            return(desc);
        }
Exemplo n.º 18
0
        private static IfcPropertyTemplate ExportIfcPropertyTemplate(DocProperty docProp, IfcLibraryInformation ifcLibInfo, Dictionary<string, DocPropertyEnumeration> mapEnums)
        {
            if (docProp.PropertyType == DocPropertyTemplateTypeEnum.COMPLEX)
            {
                IfcComplexPropertyTemplate ifcProp = new IfcComplexPropertyTemplate();
                ifcProp.GlobalId = SGuid.Format(docProp.Uuid);
                ifcProp.Name = docProp.Name;
                ifcProp.Description = docProp.Documentation;
                ifcProp.TemplateType = IfcComplexPropertyTemplateTypeEnum.P_COMPLEX;
                ifcProp.UsageName = docProp.PrimaryDataType;

                foreach (DocProperty docSubProp in docProp.Elements)
                {
                    IfcPropertyTemplate ifcSub = ExportIfcPropertyTemplate(docSubProp, ifcLibInfo, mapEnums);
                    ifcProp.HasPropertyTemplates.Add(ifcSub);
                }

                return ifcProp;
            }
            else
            {
                IfcSimplePropertyTemplate ifcProp = new IfcSimplePropertyTemplate();
                ifcProp.GlobalId = SGuid.Format(docProp.Uuid);
                ifcProp.Name = docProp.Name;
                ifcProp.Description = docProp.Documentation;
                ifcProp.TemplateType = (IfcSimplePropertyTemplateTypeEnum)Enum.Parse(typeof(IfcSimplePropertyTemplateTypeEnum), docProp.PropertyType.ToString());
                ifcProp.PrimaryMeasureType = docProp.PrimaryDataType;
                ifcProp.SecondaryMeasureType = docProp.SecondaryDataType;

                foreach (DocLocalization docLoc in docProp.Localization)
                {
                    IfcLibraryReference ifcLib = new IfcLibraryReference();
                    ifcLib.Language = docLoc.Locale;
                    ifcLib.Name = docLoc.Name;
                    ifcLib.Description = docLoc.Documentation;
                    ifcLib.ReferencedLibrary = ifcLibInfo;

                    IfcRelAssociatesLibrary ifcRal = new IfcRelAssociatesLibrary();
                    ifcRal.RelatingLibrary = ifcLib;
                    ifcRal.RelatedObjects.Add(ifcProp);

                    ifcProp.HasAssociations.Add(ifcRal);
                }

                // enumerations
                if (ifcProp.TemplateType == IfcSimplePropertyTemplateTypeEnum.P_ENUMERATEDVALUE && ifcProp.SecondaryMeasureType != null)
                {
                    // NEW: lookup formal enumeration
                    string propdatatype = ifcProp.SecondaryMeasureType;
                    int colon = propdatatype.IndexOf(':');
                    if(colon > 0)
                    {
                        propdatatype = propdatatype.Substring(0, colon);
                    }

                    DocPropertyEnumeration docEnumeration = null;
                    if(mapEnums.TryGetValue(propdatatype, out docEnumeration))
                    {
                        ifcProp.Enumerators = new IfcPropertyEnumeration();
                        ifcProp.GlobalId = SGuid.Format(docEnumeration.Uuid);
                        ifcProp.Enumerators.Name = docEnumeration.Name;
                        ifcProp.Enumerators.EnumerationValues = new List<IfcValue>();
                        ifcProp.SecondaryMeasureType = null;

                        foreach(DocPropertyConstant docConst in docEnumeration.Constants)
                        {
                            IfcLabel label = new IfcLabel();
                            label.Value = docConst.Name;
                            ifcProp.Enumerators.EnumerationValues.Add(label);

                            foreach (DocLocalization docLoc in docConst.Localization)
                            {
                                IfcLibraryReference ifcLib = new IfcLibraryReference();
                                ifcLib.Identification = docConst.Name; // distinguishes the constant value within the enumeration
                                ifcLib.Language = docLoc.Locale;
                                ifcLib.Name = docLoc.Name;
                                ifcLib.Description = docLoc.Documentation;
                                ifcLib.ReferencedLibrary = ifcLibInfo;

                                if(docLoc.Documentation == null && docLoc.Locale == "en")
                                {
                                    ifcLib.Description = docConst.Documentation;
                                }

                                IfcRelAssociatesLibrary ifcRal = new IfcRelAssociatesLibrary();
                                ifcRal.RelatingLibrary = ifcLib;
                                ifcRal.RelatedObjects.Add(ifcProp);

                                ifcProp.HasAssociations.Add(ifcRal);
                            }

                        }
                    }

                }

                return ifcProp;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="docEntity">If entity specified, shows property sets and properties applicable to entity; if null, shows all property sets.</param>
        /// <param name="docProject">Required project.</param>
        /// <param name="multiselect">True to select multiple properties; False to select single property; Null to show properties that can be merged.</param>
        public FormSelectProperty(DocEntity docEntity, DocProject docProject, bool?multiselect) : this()
        {
            this.m_entity  = docEntity;
            this.m_project = docProject;

            if (multiselect != null)
            {
                if (multiselect == true)
                {
                    this.treeViewProperty.CheckBoxes = true;
                    this.Text = "Include Property Sets";

                    this.comboBoxPort.Enabled = false;
                }
                else if (multiselect == false)
                {
                    // find applicable ports
                    this.comboBoxPort.Items.Add("(object)");
                    this.comboBoxPort.SelectedIndex = 0;

                    if (docEntity != null)
                    {
                        foreach (DocModelView docView in docProject.ModelViews)
                        {
                            foreach (DocConceptRoot docRoot in docView.ConceptRoots)
                            {
                                if (docRoot.ApplicableEntity == docEntity)
                                {
                                    foreach (DocTemplateUsage docConcept in docRoot.Concepts)
                                    {
                                        if (docConcept.Definition != null && docConcept.Definition.Uuid == DocTemplateDefinition.guidPortNesting)
                                        {
                                            foreach (DocTemplateItem docItem in docConcept.Items)
                                            {
                                                string name = docItem.GetParameterValue("Name");
                                                if (name != null && !this.comboBoxPort.Items.Contains(name))
                                                {
                                                    this.comboBoxPort.Items.Add(name);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }


                this.LoadPropertySets();
            }
            else if (multiselect == null)
            {
                this.Text = "Merge Duplicate Properties";
                this.treeViewProperty.CheckBoxes = true;
                this.comboBoxPort.Enabled        = false;

                // build list of shared properties

                //Dictionary<string, DocProperty> duplicateProperties = new Dictionary<string, DocProperty>();
                this.m_sharedproperties = new Dictionary <string, DocProperty>();

                foreach (DocSection docSection in this.m_project.Sections)
                {
                    foreach (DocSchema docSchema in docSection.Schemas)
                    {
                        foreach (DocPropertySet docPset in docSchema.PropertySets)
                        {
                            // first, capture all unique properties... THEN, only shared properties
                            if (!docPset.IsVisible())
                            {
                                foreach (DocProperty docProp in docPset.Properties)
                                {
                                    if (!this.m_sharedproperties.ContainsKey(docProp.Name))
                                    {
                                        this.m_sharedproperties.Add(docProp.Name, docProp);
                                    }

                                    /*
                                     * else if(!duplicateProperties.ContainsKey(docProp.Name))
                                     * {
                                     * duplicateProperties.Add(docProp.Name, docProp);
                                     * }*/
                                }
                            }
                        }
                    }
                }
                //this.m_sharedproperties = duplicateProperties;

                // find all duplicate properties
                foreach (DocSection docSection in this.m_project.Sections)
                {
                    foreach (DocSchema docSchema in docSection.Schemas)
                    {
                        foreach (DocPropertySet docPset in docSchema.PropertySets)
                        {
                            if (docPset.IsVisible())
                            {
                                TreeNode tnPset = null;

                                foreach (DocProperty docProp in docPset.Properties)
                                {
                                    DocProperty docExist = null;
                                    if (this.m_sharedproperties.TryGetValue(docProp.Name, out docExist) && docExist != docProp)
                                    {
                                        if (tnPset == null)
                                        {
                                            tnPset                    = new TreeNode();
                                            tnPset.Tag                = docPset;
                                            tnPset.Text               = docPset.Name;
                                            tnPset.ImageIndex         = 0;
                                            tnPset.SelectedImageIndex = 0;
                                            tnPset.Checked            = true;
                                            this.treeViewProperty.Nodes.Add(tnPset);
                                        }

                                        TreeNode tnProp = new TreeNode();
                                        tnProp.Tag                = docProp;
                                        tnProp.Text               = docProp.Name;
                                        tnProp.ImageIndex         = 1;
                                        tnProp.SelectedImageIndex = 1;
                                        tnProp.Checked            = true;
                                        tnPset.Nodes.Add(tnProp);
                                        tnPset.Expand();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
        public static void Download(DocProject project, System.ComponentModel.BackgroundWorker worker, string baseurl, string username, string password)
        {
            if (project.Sections[4].Schemas.Count == 0)
            {
                project.Sections[4].Schemas.Add(new DocSchema());
            }

            string url = baseurl + "api/4.0/session/login?email=" + HttpUtility.UrlEncode(username) + "&password="******"POST";
            request.ContentLength = 0;
            request.ContentType   = "application/x-www-form-urlencoded";
            request.Accept        = "application/json";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            System.IO.Stream       stream = response.GetResponseStream();
            System.IO.StreamReader reader = new System.IO.StreamReader(stream);
            string body = reader.ReadToEnd();

            string cookie = response.Headers.Get("Set-Cookie");

            string[] parts     = cookie.Split(new char[] { ';', ',' }); // bug? comma separates session ID
            string   match     = "peregrineapisessionid=";
            string   sessionid = null;

            foreach (string part in parts)
            {
                if (part.StartsWith(match))
                {
                    sessionid = part.Substring(match.Length);
                    break;
                }
            }

            /*-Get all users:
             * var client = new RestClient("http://test.bsdd.buildingsmart.org/api/4.0/IfdUser/");
             * var request = new RestRequest(Method.GET);
             * request.AddHeader("cookie", "peregrineapisessionid=thesessionid");
             * request.AddHeader("accept", "application/json");
             * request.AddHeader("content-type", "application/x-www-form-urlencoded; charset=UTF-8");
             * IRestResponse response = client.Execute(request);*/

            /*- Get all languages:
             * var client = new RestClient("http://test.bsdd.buildingsmart.org/api/4.0/IfdLanguage/");
             * var request = new RestRequest(Method.GET);
             * request.AddHeader("cookie", "peregrineapisessionid={{sessionId}}");
             * request.AddHeader("accept", "application/json");
             * request.AddHeader("content-type", "application/x-www-form-urlencoded; charset=UTF-8");
             * IRestResponse response = client.Execute(request);*/
            request               = (HttpWebRequest)HttpWebRequest.Create(baseurl + "api/4.0/IfdLanguage/");
            request.Method        = "GET";
            request.ContentLength = 0;
            request.ContentType   = "application/x-www-form-urlencoded; charset=UTF-8";
            request.Headers.Add("cookie", "peregrineapisessionid=" + sessionid);
            request.Accept = "application/json";
            response       = (HttpWebResponse)request.GetResponse();

            stream = response.GetResponseStream();
            reader = new System.IO.StreamReader(stream);
            body   = reader.ReadToEnd();

            body.ToString();

            request               = (HttpWebRequest)HttpWebRequest.Create(baseurl + "api/4.0/IfdConcept/search/filter/language/1ASQw0qJqHuO00025QrE$V/type/NEST/Pset_*");
            request.Method        = "GET";
            request.ContentLength = 0;
            request.ContentType   = "application/x-www-form-urlencoded; charset=UTF-8";
            request.Headers.Add("cookie", "peregrineapisessionid=" + sessionid);
            request.Accept = "application/json";
            response       = (HttpWebResponse)request.GetResponse();

            stream = response.GetResponseStream();
            reader = new System.IO.StreamReader(stream);
            body   = reader.ReadToEnd();

            System.IO.Stream       ms     = new System.IO.MemoryStream();
            System.IO.StreamWriter writer = new System.IO.StreamWriter(ms);
            writer.Write(body);
            writer.Flush();
            ms.Position = 0;
            //System.IO.MemoryStream mstream = new System.IO.MemoryStream()

            ResponseSearch ifdRoot;

            try
            {
                DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings();
                //settings.UseSimpleDictionaryFormat = true;
                System.Runtime.Serialization.Json.DataContractJsonSerializer ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(ResponseSearch));
                ifdRoot = (ResponseSearch)ser.ReadObject(ms);
            }
            catch
            {
                return;
            }

            // PERF: consider API on server that would return all information at once (currently 150+ round trips)
            for (int iConc = 0; iConc < ifdRoot.IfdConcept.Length; iConc++)
            {
                IfdConcept concept = ifdRoot.IfdConcept[iConc];
                worker.ReportProgress((int)(100.0 * (double)iConc / (double)ifdRoot.IfdConcept.Length));

                // api/4.0/IfdPSet/{guid}/ifcVersion/{ifcVersion}/XML

#if true                                   //figure out version info // language code starting at 5th character then lowercase -- e.g. "IFC-2X4" -> "2x4"
                string ifcversion = "2x4"; // "IFC4";// "ifc-2X4"; //???? what should this be ???? -- code "ifc-2X4" appears in headers; "IFC-2x4" appears in UI; "IFC4" is official schema name
                request               = (HttpWebRequest)HttpWebRequest.Create(baseurl + "api/4.0/IfdPSet/" + concept.guid + "/ifcVersion/" + ifcversion + "/XML");
                request.Method        = "GET";
                request.ContentLength = 0;
                request.ContentType   = "application/x-www-form-urlencoded; charset=UTF-8";
                request.Headers.Add("cookie", "peregrineapisessionid=" + sessionid);
                request.Accept = "application/xml";
#endif
#if false // worked April 1, but no longer works as of 2017-06-13 (http body returns "null" -- as in 4 character string) -- issue with test server -- CoBuilder merge wiped out content??
                request               = (HttpWebRequest)HttpWebRequest.Create(baseurl + "api/4.0/IfdConcept/" + concept.guid + "/children");
                request.Method        = "GET";
                request.ContentLength = 0;
                request.ContentType   = "application/x-www-form-urlencoded; charset=UTF-8";
                request.Headers.Add("cookie", "peregrineapisessionid=" + sessionid);
                request.Accept = "application/json";
                //request.Accept = "application/xml";
#endif
                try
                {
                    response = (HttpWebResponse)request.GetResponse();

                    stream = response.GetResponseStream();


                    reader = new System.IO.StreamReader(stream);
                    body   = reader.ReadToEnd();
                    if (body != null && body != "null") // !!!!
                    {
                        ms     = new MemoryStream();
                        writer = new StreamWriter(ms, Encoding.Unicode);
                        writer.Write(body);
                        writer.Flush();
                        ms.Position = 0;

                        try
                        {
                            using (FormatXML format = new FormatXML(ms, typeof(PropertySetDef), null, null))
                            {
                                format.Load();
                                PropertySetDef psd = (PropertySetDef)format.Instance;
                                Program.ImportPsd(psd, project);
                            }
                        }
                        catch
                        {
                            System.Diagnostics.Debug.WriteLine("Error downloading property set: " + concept.guid.ToString());
                        }


#if false
                        ResponsePset ifdResponse;
                        DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings();
                        //settings.UseSimpleDictionaryFormat = true;
                        System.Runtime.Serialization.Json.DataContractJsonSerializer ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(ResponsePset));

                        try
                        {
                            System.IO.Stream       xs      = new System.IO.MemoryStream();
                            System.IO.StreamWriter xwriter = new System.IO.StreamWriter(xs);
                            xwriter.Write(body);
                            xwriter.Flush();
                            xs.Position = 0;

                            ifdResponse = (ResponsePset)ser.ReadObject(xs);

                            ifdResponse.ToString();


                            DocPropertySet docPset = new DocPropertySet();
                            docPset.Uuid = new Guid();// concept.guid;
                            foreach (IfdName ifdName in concept.fullNames)
                            {
                                // if english
                                if (ifdName.languageFamily == "IFC")
                                {
                                    docPset.Name = ifdName.name;
                                }
                                else
                                {
                                    DocLocalization docLoc = new DocLocalization();
                                    docLoc.Locale = ifdName.language.languageCode;
                                    docLoc.Name   = ifdName.name;
                                    docPset.Localization.Add(docLoc);
                                }
                            }
                            docPset.Documentation = concept.definitions.description;
                            project.Sections[4].Schemas[0].PropertySets.Add(docPset);

                            foreach (IfdConceptInRelationship ifdProp in ifdResponse.IfdConceptInRelationship)
                            {
                                //ifdProp.fullNames[0].
                                DocProperty docProp = new DocProperty();
                                if (ifdProp.definitions != null)
                                {
                                    docProp.Documentation = ifdProp.definitions.description;
                                }
                                docPset.Properties.Add(docProp);

                                foreach (IfdName ifdName in ifdProp.fullNames)
                                {
                                    // if english
                                    if (ifdName.languageFamily == "IFC")
                                    {
                                        //docProp.Name = ifdName.name;
                                        string[] nameparts = ifdName.name.Split('.');
                                        if (nameparts.Length == 2)
                                        {
                                            docPset.Name = nameparts[0];
                                            docProp.Name = nameparts[1];
                                        }
                                    }
                                    else
                                    {
                                        DocLocalization docLoc = new DocLocalization();
                                        docLoc.Locale = ifdName.language.languageCode;
                                        docLoc.Name   = ifdName.name;
                                        docProp.Localization.Add(docLoc);
                                    }
                                }
                            }
                        }
#endif
                    }
                }
                catch
                {
                    //...
                    return;
                }
            }
        }