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); }
static void Main(string[] args) { using (TCAPI tcapi = TCAPI.CreateInstance()) { TCWorkspace workspace = tcapi.OpenWorkspace( twsPath: @"C:\Users\estan\Desktop\trainings\TOSCA Customizations\Tosca Workspace\Training Customizations\Training Customizations.tws", loginName: "Admin", loginPassword: ""); TCProject project = workspace.GetProject(); TCFolder folder = project.CreateComponentFolder(); folder.Name = "Created folder With Script"; folder.EnsureUniqueName(); // workspace.Save(); List <TCObject> search_result = project.Search(tqlString: "=>SUBPARTS:TestCase[Name==\"Test\"]"); TestCase copyTestCase = (TestCase)search_result.First(); OwnedItem parentFolder = copyTestCase.ParentFolder; // parentFolder.CheckoutTree(); for (int i = 0; i < 10; i++) { parentFolder.Copy(copyTestCase); } //workspace.CheckInAll(""); workspace.Save(); Console.WriteLine(value: "Created folder and Test Cases Copied"); } }