예제 #1
0
        public static TCObjectPropertiesDefinition CreateIssuesProperties(String objectToCreateOn, String propertyName)
        {
            TCProject proj = TCAddOn.ActiveWorkspace.GetTCProject();
            TCObjectPropertiesDefinition issuesDef = proj.ObjectPropertiesDefinitions.FirstOrDefault(pd => pd.Name.ToLower() == objectToCreateOn.ToLower());

            if (issuesDef == null)
            {   // Create Issues property definition.
                TCComponentFolder tempFolder = (TCComponentFolder)proj.CreateComponentFolder();
                issuesDef = tempFolder.CreatePropertyDefinition("Issue");
                proj.Move(issuesDef);
                tempFolder.Delete(MsgBoxResult_OkCancel.Ok, MsgBoxResult_YesNo.Yes);
            }

            // Check if object exist
            if (issuesDef != null)
            {
                String[] props = issuesDef.GetPropertyNames();

                // Check if property already exists, create it otherwise
                if (!props.Contains(propertyName))
                {
                    TCObjectProperty newPrp = issuesDef.CreateProperty();
                    newPrp.Name = propertyName;
                }
            }

            return(issuesDef);
        }
예제 #2
0
        public static string[] GetPropertyNames(string type)
        {
            TCProject proj = TCAddOn.ActiveWorkspace.GetTCProject();
            TCObjectPropertiesDefinition propDef = proj.ObjectPropertiesDefinitions.FirstOrDefault(pd => pd.Name.ToLower() == type.ToLower());
            List <string> properties             = new List <string>();

            if (propDef is Tricentis.TCAPIObjects.Objects.RequirementTypeDefinition)
            {
                var reqType = typeof(Requirement);
                properties.AddRange(GetAvailablePropertiesForType(reqType));
            }
            else if (type == "Issue")
            {
                var issType = typeof(Issue);
                properties.AddRange(GetAvailablePropertiesForType(issType));
            }
            properties.AddRange(propDef.GetPropertyNames());
            return(properties.ToArray());
        }
예제 #3
0
        public static TCObjectPropertiesDefinition CreateCustomProperties(String objectToCreateOn, String propertyName)
        {
            TCProject proj = TCAddOn.ActiveWorkspace.GetTCProject();
            TCObjectPropertiesDefinition propDef = proj.ObjectPropertiesDefinitions.FirstOrDefault(pd => pd.Name.ToLower() == objectToCreateOn.ToLower());

            // Check if object exist
            if (propDef != null)
            {
                String[] props = propDef.GetPropertyNames();

                // Check if property already exists, create it otherwise
                if (!props.Contains(propertyName))
                {
                    TCObjectProperty newPrp = propDef.CreateProperty();
                    newPrp.Name = propertyName;
                }
            }
            else
            {
                throw new Exception("Invalid object to create property definition");
            }

            return(propDef);
        }