public ObservableList <RQMExecutionRecord> GetExecutionRecordsByTestPlan(LoginDTO loginData, XmlReader reader, RQMProject currentRQMProjectMapping, string currentProjPrefix, string currentProjGuid, string testPlanURLPathVersioned) { ObservableList <RQMExecutionRecord> RQMExecutionRecords = new ObservableList <RQMExecutionRecord>(); RqmResponseData responseDataExecutionRecords = RQMRep.GetExecutionByTestPlan(loginData, currentProjPrefix, currentProjGuid, testPlanURLPathVersioned); XmlDocument docExecutionRecords = new XmlDocument(); docExecutionRecords.LoadXml(responseDataExecutionRecords.responseText.ToString()); XmlNamespaceManager nsmgrExecutionRecords = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrExecutionRecords.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeExecutionRecords = docExecutionRecords.DocumentElement; XmlNodeList executionRecords = responseDataNodeExecutionRecords.SelectNodes(currentRQMProjectMapping.RQMExecutionRecordsMapping.PathXML, nsmgrExecutionRecords); foreach (XmlNode executionRecord in executionRecords) { try { string curentExecutionRecordUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RelatedTestCaseUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); RqmResponseData responseDataVersionedTC = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordUri)); XmlDocument docVersionedTC = new XmlDocument(); docVersionedTC.LoadXml(responseDataVersionedTC.responseText.ToString()); XmlNode responseDataNodeVersionedTC = docVersionedTC.DocumentElement; RqmResponseData responseDataVersionedTS; try { string curentExecutionRecordScriptUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.ExecutesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri)); } catch { string curentExecutionRecordScriptUri = responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.UsesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri)); } XmlDocument docVersionedTS = new XmlDocument(); docVersionedTS.LoadXml(responseDataVersionedTS.responseText.ToString()); XmlNode responseDataNodeVersionedTS = docVersionedTS.DocumentElement; if (RQMExecutionRecords.Where(x => x.RQMID == executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString()).ToList().Count == 0) { RQMExecutionRecord rQMExecutionRecord = new RQMExecutionRecord(executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString(), responseDataNodeVersionedTS.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestScriptXmlPathToID, nsmgrExecutionRecords).InnerText.ToString(), responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestCaseXmlPathToID, nsmgrExecutionRecords).InnerText.ToString()); RQMExecutionRecords.Add(rQMExecutionRecord); } } catch { } } return(RQMExecutionRecords); }
public ObservableList <RQMExecutionRecord> GetTestSuiteCurrentResult(LoginDTO loginData, XmlReader reader, RQMProject currentRQMProjectMapping, string currentProjPrefix, string currentProjGuid, string currentTestSuiteResultUri) { if ((currentTestSuiteResultUri == null) || (currentTestSuiteResultUri == string.Empty)) { return(null); } ObservableList <RQMExecutionRecord> RQMExecutionRecords = new ObservableList <RQMExecutionRecord>(); RqmResponseData responseDataCurrentTestSuiteResult = RQMRep.GetRqmResponse(loginData, new Uri(currentTestSuiteResultUri)); XmlDocument docTestSuiteResult = new XmlDocument(); docTestSuiteResult.LoadXml(responseDataCurrentTestSuiteResult.responseText.ToString()); XmlNamespaceManager nsmgrTestSuiteResult = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestSuiteResultsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTestSuiteResult.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseTestSuiteResult = docTestSuiteResult.DocumentElement; XmlNodeList executionRecordsURIs = responseTestSuiteResult.SelectNodes(currentRQMProjectMapping.RQMTestSuiteResultsMapping.XMLPathToResultsExecutionRecordsList, nsmgrTestSuiteResult); XmlNamespaceManager nsmgrExecutionRecords = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrExecutionRecords.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); foreach (XmlNode executionRecordURI in executionRecordsURIs) { try { RqmResponseData responseDataExecutionRecord = RQMRep.GetRqmResponse(loginData, new Uri(executionRecordURI.Attributes[0].InnerText.ToString())); XmlDocument docExecutionRecords = new XmlDocument(); docExecutionRecords.LoadXml(responseDataExecutionRecord.responseText.ToString()); XmlNode responseDataNodeExecutionRecord = docExecutionRecords.DocumentElement; XmlNode executionRecord = responseDataNodeExecutionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.XMLPathOfSingleSelectionCase, nsmgrExecutionRecords); string curentExecutionRecordVersionedTCUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RelatedTestCaseUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); RqmResponseData responseDataVersionedTC = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordVersionedTCUri)); XmlDocument docVersionedTC = new XmlDocument(); docVersionedTC.LoadXml(responseDataVersionedTC.responseText.ToString()); XmlNode responseDataNodeVersionedTC = docVersionedTC.DocumentElement; RqmResponseData responseDataVersionedTS; try { string curentExecutionRecordScriptUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.ExecutesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri)); } catch { string curentExecutionRecordScriptUri = responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.UsesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri)); } XmlDocument docVersionedTS = new XmlDocument(); docVersionedTS.LoadXml(responseDataVersionedTS.responseText.ToString()); XmlNode responseDataNodeVersionedTS = docVersionedTS.DocumentElement; if (RQMExecutionRecords.Where(x => x.RQMID == executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString()).ToList().Count == 0) { RQMExecutionRecord rQMExecutionRecord = new RQMExecutionRecord(executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString(), responseDataNodeVersionedTS.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestScriptXmlPathToID, nsmgrExecutionRecords).InnerText.ToString(), responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestCaseXmlPathToID, nsmgrExecutionRecords).InnerText.ToString()); RQMExecutionRecords.Add(rQMExecutionRecord); } } catch { } } return(RQMExecutionRecords); }
public ObservableList <RQMTestCase> BuildRQMTestCaseList(XmlNodeList testCases, XmlNamespaceManager nsmgr, LoginDTO loginData, RQMProject currentRQMProjectMapping, XmlReader reader, string TestSuiteTitle, string TestSuiteId) { ObservableList <RQMTestCase> RQMTestCaseList = new ObservableList <RQMTestCase>(); foreach (XmlNode testCase in testCases) { RqmResponseData responseDataTC = RQMRep.GetRqmResponse(loginData, new Uri(testCase.Attributes[0].InnerText.ToString())); XmlDocument doc = new XmlDocument(); XmlDocument docTC = new XmlDocument(); doc.LoadXml(responseDataTC.responseText.ToString()); nsmgr = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestCaseMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgr.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeTC = doc.DocumentElement; RQMTestCase rQMTestCase = new RQMTestCase(responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.Name, nsmgr).InnerText.ToString(), responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.RQMID, nsmgr).InnerText.ToString(), responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.Description, nsmgr).InnerText.ToString(), responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.CreatedBy, nsmgr).Attributes[0].InnerText.Split('/').Last().ToString(), DateTime.Parse(responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.CreationDate, nsmgr).InnerText.ToString()).ToLocalTime(), TestSuiteTitle, TestSuiteId); try { XmlNodeList variables = responseDataNodeTC.SelectNodes(currentRQMProjectMapping.RQMTestCaseMapping.XMLPathToVariablesList, nsmgr); foreach (XmlNode variable in variables) { // looking for specific Variable from BTS if (variable.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.VariableName, nsmgr).InnerText.ToString() == BTS_ACTIVITY_ID) { rQMTestCase.BTSID = variable.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.VariableValue, nsmgr).InnerText.ToString(); continue; } RQMTestParameter rQMTestParameter; rQMTestParameter = new RQMTestParameter(variable.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.VariableName, nsmgr).InnerText.ToString(), variable.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.VariableValue, nsmgr).InnerText.ToString()); rQMTestCase.Parameters.Add(rQMTestParameter); } } catch { } XmlNodeList testScripts = responseDataNodeTC.SelectNodes(currentRQMProjectMapping.RQMTestCaseMapping.PathXML, nsmgr); foreach (XmlNode testScript in testScripts) { RqmResponseData responseDataTestScript = RQMRep.GetRqmResponse(loginData, new Uri(testScript.Attributes[0].InnerText.ToString())); doc.LoadXml(responseDataTestScript.responseText.ToString()); nsmgr = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestScriptMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgr.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeTestScript = doc.DocumentElement; RQMTestScript newRQMTestScript = new RQMTestScript(responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.Name, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.RQMID, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.Description, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.CreatedBy, nsmgr).Attributes[0].InnerText.Split('/').Last().ToString(), DateTime.Parse(responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.CreationDate, nsmgr).InnerText.ToString()).ToLocalTime()); try { XmlNodeList variables = responseDataNodeTestScript.SelectNodes(currentRQMProjectMapping.RQMTestScriptMapping.XMLPathToVariablesList, nsmgr); foreach (XmlNode variable in variables) { // looking for specific Variable from BTS if (variable.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.VariableName, nsmgr).InnerText.ToString() == BTS_ACTIVITY_STEPS_ID) { newRQMTestScript.BTSStepsIDs = variable.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.VariableValue, nsmgr).InnerText.ToString(); continue; } RQMTestParameter rQMTestParameter; rQMTestParameter = new RQMTestParameter(variable.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.VariableName, nsmgr).InnerText.ToString(), variable.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.VariableValue, nsmgr).InnerText.ToString()); newRQMTestScript.Parameters.Add(rQMTestParameter); } } catch { } XmlNodeList steps = responseDataNodeTestScript.SelectNodes(currentRQMProjectMapping.RQMTestScriptMapping.PathXML, nsmgr); foreach (XmlNode step in steps) { RQMStep newStep; try { newStep = new RQMStep(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.Name, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.RQMID, nsmgr).InnerText.ToString() + "_" + step.Attributes[0].InnerText.ToString(), ImportFromRQM.StripHTML(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.Description, nsmgr).InnerText.ToString()), ImportFromRQM.StripHTML(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.ExpectedResult, nsmgr).InnerText.ToString())); newRQMTestScript.Steps.Add(newStep); } catch { try { newStep = new RQMStep(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.Name, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.RQMID, nsmgr).InnerText.ToString() + "_" + step.Attributes[0].InnerText.ToString(), ImportFromRQM.StripHTML(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.Description, nsmgr).InnerText.ToString()), string.Empty); newRQMTestScript.Steps.Add(newStep); } catch { } } } rQMTestCase.TestScripts.Add(newRQMTestScript); if (rQMTestCase.TestScripts.Count > 0) { rQMTestCase.SelectedTestScriptName = rQMTestCase.TestScripts[0].Name.ToString(); } } RQMTestCaseList.Add(rQMTestCase); } return(RQMTestCaseList); }
public RQMTestPlan GetRQMTestPlanFullData(string RQMServerUrl, string RQMUserName, string RQMPassword, string RQMProject, RQMTestPlan testPlan) { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; string importConfigTemplate = System.IO.Path.Combine(RQMCore.ConfigPackageFolderPath, "RQM_Import", "RQM_ImportConfigs_Template.xml"); if (File.Exists(importConfigTemplate)) { XmlSerializer serializer = new XmlSerializer(typeof(RQMProjectListConfiguration)); FileStream fs = new FileStream(importConfigTemplate, FileMode.Open); XmlReader reader = XmlReader.Create(fs); RQMProjectListConfiguration RQMProjectList; RQMProjectList = (RQMProjectListConfiguration)serializer.Deserialize(reader); fs.Close(); RQMProject currentRQMProjectMapping; if (RQMProjectList.RQMProjects.Count > 0) { currentRQMProjectMapping = RQMProjectList.RQMProjects.Where(x => x.Name == RQMProject || x.Name == "DefaultProjectName").FirstOrDefault(); if (currentRQMProjectMapping != null) { // // building a list of TestCases LoginDTO loginData = new LoginDTO() { User = RQMUserName, Password = RQMPassword, Server = RQMServerUrl }; IProjectData rqmProjectsData = RQMRep.GetVisibleProjects(loginData); rqmProjectsDataList = rqmProjectsData.IProjectDefinitions; IProjectDefinitions currentProj = rqmProjectsDataList.Where(x => x.ProjectName == RQMProject).FirstOrDefault(); RqmResponseData responseData = RQMRep.GetRqmResponse(loginData, new Uri(testPlan.URLPath)); XmlDocument docTP = new XmlDocument(); docTP.LoadXml(responseData.responseText.ToString()); XmlNamespaceManager nsmgrTP = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestPlanMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTP.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNode = docTP.DocumentElement; testPlan.Description = responseDataNode.SelectSingleNode(currentRQMProjectMapping.RQMTestPlanMapping.Description, nsmgrTP).InnerText.ToString(); // Building execution Results Dictionary - start // - execution records that are seating on Test Plan testPlan.RQMExecutionRecords = GetExecutionRecordsByTestPlan(loginData, reader, currentRQMProjectMapping, currentProj.Prefix, currentProj.Guid, testPlan.URLPathVersioned); // building test cases lists of TestSuits (not on TestPlan) // test suites should be created already by function GetRQMTestPlanByIdByProject() // this is only enhancement that will add to them test cases and some values like description and so on XmlNodeList testSuites = responseDataNode.SelectNodes(currentRQMProjectMapping.RQMTestPlanMapping.PathXMLToTestSuitesLists, nsmgrTP); foreach (XmlNode testSuite in testSuites) { RqmResponseData responseDataTestSuite = RQMRep.GetRqmResponse(loginData, new Uri(testSuite.Attributes[0].InnerText.ToString())); XmlDocument docTestSuite = new XmlDocument(); docTestSuite.LoadXml(responseDataTestSuite.responseText.ToString()); XmlNamespaceManager nsmgrTS = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestSuiteMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTS.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeTestSuite = docTestSuite.DocumentElement; ObservableList <RQMTestCase> currentSuiteTestCases = BuildRQMTestCaseList(responseDataNodeTestSuite.SelectNodes(currentRQMProjectMapping.RQMTestSuiteMapping.PathXML, nsmgrTS), nsmgrTS, loginData, currentRQMProjectMapping, reader, responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.Name, nsmgrTS).InnerText.ToString(), responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.RQMID, nsmgrTS).InnerText.ToString()); RQMTestSuite currentTestSuite = testPlan.TestSuites.Where(z => z.RQMID == responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.RQMID, nsmgrTS).InnerText.ToString()).FirstOrDefault(); currentTestSuite.Name = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.Name, nsmgrTS).InnerText.ToString(); currentTestSuite.CreatedBy = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.RQMID, nsmgrTS).InnerText.ToString(); currentTestSuite.Description = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.Description, nsmgrTS).InnerText.ToString(); currentTestSuite.CreationDate = DateTime.Parse(responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.CreationDate, nsmgrTS).InnerText.ToString()).ToLocalTime(); currentTestSuite.TestCases = currentSuiteTestCases; // adding current's test suite list of tests cases to overall (test plan's) list of test cases - to be presented at ginger together currentSuiteTestCases.Where(y => !testPlan.TestCases.Select(x => x.RQMID).ToList().Contains(y.RQMID)).ToList().ForEach(z => testPlan.TestCases.Add(z)); } // // building test cases list directly on the TestPlan ObservableList <RQMTestCase> testPlansTestCases = BuildRQMTestCaseList(responseDataNode.SelectNodes(currentRQMProjectMapping.RQMTestPlanMapping.PathXML, nsmgrTP), nsmgrTP, loginData, currentRQMProjectMapping, reader, string.Empty, string.Empty); // testPlan.TestCases = testPlansTestCases; // temp? to review! testPlansTestCases.Where(y => !testPlan.TestCases.Select(x => x.RQMID).ToList().Contains(y.RQMID)).ToList().ForEach(z => testPlan.TestCases.Add(z)); } } } else { Reporter.ToLog(eLogLevel.ERROR, "Error while trying to import selected RQM test plan, RQM_ImportConfigs_Template.xml wasn't found at: " + importConfigTemplate); } Mouse.OverrideCursor = null; return(testPlan); }
public RQMTestPlan GetRQMTestPlanByIdByProject(string RQMServerUrl, string RQMUserName, string RQMPassword, string RQMProject, string RQMTestPlanId) { RQMTestPlan testPlanRes = null; string importConfigTemplate = System.IO.Path.Combine(RQMCore.ConfigPackageFolderPath, "RQM_Import", "RQM_ImportConfigs_Template.xml"); if (File.Exists(importConfigTemplate)) { XmlSerializer serializer = new XmlSerializer(typeof(RQMProjectListConfiguration)); FileStream fs = new FileStream(importConfigTemplate, FileMode.Open); XmlReader reader = XmlReader.Create(fs); RQMProjectListConfiguration RQMProjectList; RQMProjectList = (RQMProjectListConfiguration)serializer.Deserialize(reader); fs.Close(); RQMProject currentRQMProjectMapping; if (RQMProjectList.RQMProjects.Count > 0) { currentRQMProjectMapping = RQMProjectList.RQMProjects.Where(x => x.Name == RQMProject || x.Name == "DefaultProjectName").FirstOrDefault(); if (currentRQMProjectMapping != null) { // // LoginDTO loginData = new LoginDTO() { User = RQMUserName, Password = RQMPassword, Server = RQMServerUrl }; IProjectData rqmProjectsData = RQMRep.GetVisibleProjects(loginData); rqmProjectsDataList = rqmProjectsData.IProjectDefinitions; IProjectDefinitions currentProj = rqmProjectsDataList.Where(x => x.ProjectName == RQMProject).FirstOrDefault(); RqmResponseData responseData = RQMRep.GetTestPlanByIdByProject(loginData, currentProj.Prefix, currentProj.Guid, RQMTestPlanId); try //skip result incase of error, defect #5164 { XmlDocument doc = new XmlDocument(); doc.LoadXml(responseData.responseText.ToString()); XmlNamespaceManager nsmgr = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestPlansListMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgr.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNode = doc.DocumentElement; XmlNodeList testPlans = responseDataNode.SelectNodes(currentRQMProjectMapping.RQMTestPlansListMapping.XMLPathToTestPlansList, nsmgr); foreach (XmlNode testPlan in testPlans) { testPlanRes = new RQMTestPlan(testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.Name, nsmgr).InnerText.ToString(), testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.URLPath, nsmgr).Attributes[0].InnerText.ToString(), testPlan.Attributes[0].InnerText.ToString(), testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.RQMID, nsmgr).InnerText.ToString(), testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.CreatedBy, nsmgr).Attributes[0].InnerText.Split('/').Last().ToString(), DateTime.Parse(testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.CreationDate, nsmgr).InnerText.ToString()).ToLocalTime()); XmlNodeList testSuitesURInodes = testPlan.SelectNodes(currentRQMProjectMapping.RQMTestPlansListMapping.ContainedTestSuitesList, nsmgr); foreach (XmlNode testSuitesURInode in testSuitesURInodes) { RQMTestSuite rQMTestSuite = new RQMTestSuite(testSuitesURInode.Attributes[0].InnerText.ToString()); try { // TestSuite data from RQM RqmResponseData responseDataTestSuite = RQMRep.GetRqmResponse(loginData, new Uri(testSuitesURInode.Attributes[0].InnerText.ToString())); XmlDocument docTestSuite = new XmlDocument(); docTestSuite.LoadXml(responseDataTestSuite.responseText.ToString()); XmlNamespaceManager nsmgrTestSuite = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestSuiteAsItemMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTestSuite.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeTestSuite = docTestSuite.DocumentElement; rQMTestSuite.RQMID = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteAsItemMapping.RQMID, nsmgrTestSuite).InnerText.ToString(); rQMTestSuite.Name = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteAsItemMapping.Name, nsmgrTestSuite).InnerText.ToString(); // TestSuite data from RQM RqmResponseData responseDataTestSuiteExecutionRecords = RQMRep.GetTestSuiteExecutionRecordsByTestSuite(loginData, currentProj.Prefix, currentProj.Guid, testSuitesURInode.Attributes[0].InnerText.ToString()); XmlDocument docTestSuiteExecutionRecords = new XmlDocument(); docTestSuiteExecutionRecords.LoadXml(responseDataTestSuiteExecutionRecords.responseText.ToString()); XmlNamespaceManager nsmgrTestSuiteExecutionRecords = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestSuiteExecutionRecordMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTestSuiteExecutionRecords.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeExecutionRecords = docTestSuiteExecutionRecords.DocumentElement; try { rQMTestSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.URLPathVersioned = responseDataNodeExecutionRecords.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteExecutionRecordMapping.CurrentTestSuiteResult, nsmgrTestSuiteExecutionRecords).Attributes[0].InnerText.ToString(); } catch { } try { rQMTestSuite.TestSuiteExecutionRecord.URLPathVersioned = responseDataNodeExecutionRecords.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteExecutionRecordMapping.XMLTestSuiteExecutionRecord, nsmgrTestSuiteExecutionRecords).Attributes[0].InnerText.ToString(); rQMTestSuite.TestSuiteExecutionRecord.RQMID = responseDataNodeExecutionRecords.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteExecutionRecordMapping.RQMID, nsmgrTestSuiteExecutionRecords).InnerText.ToString(); } catch { } } catch { } testPlanRes.TestSuites.Add(rQMTestSuite); } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error while trying to retrieve TestPlan id:" + RQMTestPlanId); Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex); } } } } return(testPlanRes); }
public static ObservableList <ExternalItemFieldBase> GetItemFields(eRQMItemType itemType, BackgroundWorker bw) { ObservableList <ExternalItemFieldBase> fields = new ObservableList <ExternalItemFieldBase>(); //TODO : receive as parameters: RqmRepository rqmRep = new RqmRepository(); List <IProjectDefinitions> rqmProjectsDataList; //string rqmSserverUrl = loginData.Server.ToString() + "/"; string rqmSserverUrl = ALMCore.AlmConfig.ALMServerURL + "/"; LoginDTO loginData = new LoginDTO() { User = ALMCore.AlmConfig.ALMUserName, Password = ALMCore.AlmConfig.ALMPassword, Server = ALMCore.AlmConfig.ALMServerURL }; IProjectData rqmProjectsData = rqmRep.GetVisibleProjects(loginData); rqmProjectsDataList = rqmProjectsData.IProjectDefinitions; IProjectDefinitions currentProj = rqmProjectsDataList.FirstOrDefault(); string rqmDomain = currentProj.Prefix; string rqmProject = currentProj.ProjectName; //------------------------------- Improved solution string baseUri_ = string.Empty; string selfLink_ = string.Empty; int maxPageNumber_ = 0; int totalCategoryTypeCount = 0; string categoryValue = string.Empty; // --> itemfield.PossibleValues.Add(ccNode.Name); string categoryTypeID = string.Empty; //--> itemfield.ID //TODO: Populate list fields with CategoryTypes populatedValue = "Starting fields retrieve process... "; bw.ReportProgress(totalValues, populatedValue); RqmResponseData categoryType = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(rqmSserverUrl + rqmDomain + "/service/com.ibm.rqm.integration.service.IIntegrationService/resources/" + rqmProject + "/categoryType")); XmlDocument categoryTypeList = new XmlDocument(); if (!string.IsNullOrEmpty(categoryType.responseText)) { categoryTypeList.LoadXml(categoryType.responseText); } //TODO: Get 'next' and 'last links XmlNodeList linkList_ = categoryTypeList.GetElementsByTagName("link"); if (linkList_.Count > 0) { XmlNode selfPage = linkList_.Item(1); XmlNode lastPage_ = linkList_.Item(3); if (selfPage.Attributes["rel"].Value.ToString() == "self") //verify self link is present { selfLink_ = selfPage.Attributes["href"].Value.ToString(); //baseUri_ = selfLink_.Substring(0, selfLink_.Length - 1); baseUri_ = selfLink_; } if (lastPage_.Attributes["rel"].Value.ToString() == "last") //verify there is more than one page { if (selfPage.Attributes["rel"].Value.ToString() == "self") //verify self link is present { selfLink_ = selfPage.Attributes["href"].Value.ToString(); baseUri_ = selfLink_.Substring(0, selfLink_.Length - 1); } string tempString_ = lastPage_.Attributes["href"].Value.ToString(); maxPageNumber_ = System.Convert.ToInt32(tempString_.Substring(tempString_.LastIndexOf('=') + 1)); } string newUri_ = string.Empty; List <string> categoryTypeUriPages = new List <string>(); //List<ExternalItemFieldBase> tempFieldList = new List<ExternalItemFieldBase>(); ConcurrentBag <ExternalItemFieldBase> catTypeRsult = new ConcurrentBag <ExternalItemFieldBase>(); for (int k = 0; k <= maxPageNumber_; k++) { if (maxPageNumber_ > 0) { newUri_ = baseUri_ + k.ToString(); categoryTypeUriPages.Add(newUri_); } else { newUri_ = baseUri_; categoryTypeUriPages.Add(newUri_); } } //Parallel computing solution List <XmlNode> entryList = new List <XmlNode>(); if (categoryTypeUriPages.Count > 1) { Parallel.ForEach(categoryTypeUriPages.AsParallel(), categoryTypeUri => { newUri_ = categoryTypeUri; categoryType = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(newUri_)); if (!string.IsNullOrEmpty(categoryType.responseText)) { categoryTypeList.LoadXml(categoryType.responseText); } //TODO: Get all ID links under entry: XmlNodeList categoryTypeEntry_ = categoryTypeList.GetElementsByTagName("entry"); foreach (XmlNode entryNode in categoryTypeEntry_) { entryList.Add(entryNode); } ParallelLoopResult innerResult = Parallel.ForEach(entryList.AsParallel(), singleEntry => { XmlNodeList innerNodes = singleEntry.ChildNodes; XmlNode linkNode = innerNodes.Item(4); ExternalItemFieldBase itemfield = new ExternalItemFieldBase(); string getIDlink = string.Empty; getIDlink = linkNode.Attributes["href"].Value.ToString(); // retrived CategoryType link RqmResponseData categoryTypeDetail = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(getIDlink)); //System.Diagnostics.Debug.WriteLine("entered loop 2"); XmlDocument categoryTypeListing = new XmlDocument(); if (!string.IsNullOrEmpty(categoryTypeDetail.responseText)) { categoryTypeListing.LoadXml(categoryTypeDetail.responseText); } string categoryTypeName = string.Empty; // -->itemfield.Name string categoryTypeItemType = string.Empty; //-->itemfield.ItemType string categoryTypeMandatory = string.Empty; // --> itemfield.Mandatory & initial value for : --> itemfield.ToUpdate string typeIdentifier = categoryTypeListing.GetElementsByTagName("ns3:identifier").Item(0).InnerText; categoryTypeID = typeIdentifier.Substring(typeIdentifier.LastIndexOf(':') + 1); categoryTypeName = categoryTypeListing.GetElementsByTagName("ns3:title").Item(0).InnerText; categoryTypeItemType = categoryTypeListing.GetElementsByTagName("ns2:scope").Item(0).InnerText; categoryTypeMandatory = categoryTypeListing.GetElementsByTagName("ns2:required").Item(0).InnerText; itemfield.ItemType = categoryTypeItemType; itemfield.ID = categoryTypeID; itemfield.Name = categoryTypeName; if (itemfield.SelectedValue == null) { itemfield.SelectedValue = "NA"; } if (categoryTypeMandatory == "true") { itemfield.ToUpdate = true; itemfield.Mandatory = true; } else { itemfield.ToUpdate = false; itemfield.Mandatory = false; } catTypeRsult.Add(itemfield); populatedValue = "Populating field :" + categoryTypeName + " \r\nNumber of fields populated :" + catTypeRsult.Count; bw.ReportProgress(catTypeRsult.Count, populatedValue); }); }); } else { populatedValue = string.Empty; newUri_ = baseUri_; categoryType = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(newUri_)); if (!string.IsNullOrEmpty(categoryType.responseText)) { categoryTypeList.LoadXml(categoryType.responseText); } //TODO: Get all ID links under entry: XmlNodeList categoryTypeEntry_ = categoryTypeList.GetElementsByTagName("entry"); foreach (XmlNode entryNode in categoryTypeEntry_) { entryList.Add(entryNode); } ParallelLoopResult innerResult = Parallel.ForEach(entryList.AsParallel(), singleEntry => { XmlNodeList innerNodes = singleEntry.ChildNodes; XmlNode linkNode = innerNodes.Item(4); ExternalItemFieldBase itemfield = new ExternalItemFieldBase(); string getIDlink = string.Empty; getIDlink = linkNode.Attributes["href"].Value.ToString(); // retrived CategoryType link RqmResponseData categoryTypeDetail = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(getIDlink)); XmlDocument categoryTypeListing = new XmlDocument(); if (!string.IsNullOrEmpty(categoryTypeDetail.responseText)) { categoryTypeListing.LoadXml(categoryTypeDetail.responseText); } string categoryTypeName = string.Empty; // -->itemfield.Name string categoryTypeItemType = string.Empty; //-->itemfield.ItemType string categoryTypeMandatory = string.Empty; // --> itemfield.Mandatory & initial value for : --> itemfield.ToUpdate string typeIdentifier = categoryTypeListing.GetElementsByTagName("ns3:identifier").Item(0).InnerText; categoryTypeID = typeIdentifier.Substring(typeIdentifier.LastIndexOf(':') + 1); categoryTypeName = categoryTypeListing.GetElementsByTagName("ns3:title").Item(0).InnerText; categoryTypeItemType = categoryTypeListing.GetElementsByTagName("ns2:scope").Item(0).InnerText; categoryTypeMandatory = categoryTypeListing.GetElementsByTagName("ns2:required").Item(0).InnerText; itemfield.ItemType = categoryTypeItemType; itemfield.ID = categoryTypeID; itemfield.Name = categoryTypeName; if (itemfield.SelectedValue == null) { itemfield.SelectedValue = "NA"; } if (categoryTypeMandatory == "true") { itemfield.ToUpdate = true; itemfield.Mandatory = true; } else { itemfield.ToUpdate = false; itemfield.Mandatory = false; } catTypeRsult.Add(itemfield); populatedValue = "Populating field :" + categoryTypeName + " \r\n Number of fields populated :" + catTypeRsult.Count; bw.ReportProgress(catTypeRsult.Count, populatedValue); }); } foreach (ExternalItemFieldBase field in catTypeRsult) { fields.Add(field); totalCategoryTypeCount++; System.Diagnostics.Debug.WriteLine("Number of retrieved fields:" + totalCategoryTypeCount); } //TODO: Add Values to CategoryTypes Parallel populatedValue = "Starting values retrieve process... "; bw.ReportProgress(totalValues, populatedValue); RqmResponseData category = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(rqmSserverUrl + rqmDomain + "/service/com.ibm.rqm.integration.service.IIntegrationService/resources/" + rqmProject + "/category")); XmlDocument CategoryList = new XmlDocument(); CategoryList.LoadXml(category.responseText); totalValues = 0; populatedValue = string.Empty; //TODO: Get 'next' and 'last links XmlNodeList linkList = CategoryList.GetElementsByTagName("link"); XmlNode selfPageNode = linkList.Item(1); XmlNode lastPageNode = linkList.Item(3); string selfLink = selfPageNode.Attributes["href"].Value.ToString(); string baseUri = selfLink.Substring(0, selfLink.Length - 1); string tempString = lastPageNode.Attributes["href"].Value.ToString(); int maxPageNumber = System.Convert.ToInt32(tempString.Substring(tempString.LastIndexOf('=') + 1)); string newUri = string.Empty; List <string> categoryUriPages = new List <string>(); for (int i = 0; i <= maxPageNumber; i++) //for (int i = 0; i <= 25; i++) //scale testing { if (maxPageNumber > 0) { newUri = baseUri + i.ToString(); categoryUriPages.Add(newUri); } else { newUri = baseUri; categoryUriPages.Add(newUri); } } List <ExternalItemFieldBase> valueFields = new List <ExternalItemFieldBase>(); if (categoryUriPages.Count > 0) { int iDCount = 0; Parallel.ForEach(categoryUriPages.AsParallel(), singleUri => { newUri = singleUri; RqmResponseData category_ = new RqmResponseData(); category_ = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(newUri)); if (category_.ErrorCode == 401) { RQM.RQMConnect.Instance.RQMRep.ConnectToServer(loginData.Server.ToString(), loginData.User.ToString(), loginData.Password.ToString()); RQM.RQMConnect.Instance.RQMRep.ConnetProject(rqmDomain, rqmProject, loginData.User.ToString(), loginData.Password.ToString()); category_ = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(newUri)); } XmlDocument CategoryList_ = new XmlDocument(); if (!string.IsNullOrEmpty(category_.responseText)) { CategoryList_.LoadXml(category_.responseText); } XmlNodeList categoryIDs = CategoryList_.GetElementsByTagName("id"); iDCount += categoryIDs.Count; if (categoryIDs.Count > 0) { List <string> idLinkList = new List <string>(); for (int n = 1; n < categoryIDs.Count; n++) { idLinkList.Add(categoryIDs.Item(n).InnerText); } Parallel.ForEach(idLinkList.AsParallel(), getIDlink => { ExternalItemFieldBase valuesItemfield = new ExternalItemFieldBase(); if (!string.IsNullOrEmpty(getIDlink)) { RqmResponseData categoryValueDetails = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(getIDlink)); // retrieve category page XmlDocument categoryValueXML = new XmlDocument(); if (categoryValueDetails.ErrorCode == 401) { RQM.RQMConnect.Instance.RQMRep.ConnectToServer(loginData.Server.ToString(), loginData.User.ToString(), loginData.Password.ToString()); RQM.RQMConnect.Instance.RQMRep.ConnetProject(rqmDomain, rqmProject, loginData.User.ToString(), loginData.Password.ToString()); categoryValueDetails = RQM.RQMConnect.Instance.RQMRep.GetRqmResponse(loginData, new Uri(getIDlink)); } if (!string.IsNullOrEmpty(categoryValueDetails.responseText)) { categoryValueXML.LoadXml(categoryValueDetails.responseText); } //categoryValueXML.LoadXml(categoryValueDetails.responseText.ToString()); XmlNode categoryTypeNode; string catTypeLink = string.Empty; if (!string.IsNullOrEmpty(categoryValueXML.InnerText.ToString())) { categoryTypeNode = categoryValueXML.GetElementsByTagName("ns2:categoryType").Item(0); //need to consider changes in tag i.e. ns3/ns4... catTypeLink = categoryTypeNode.Attributes["href"].Value.ToString(); categoryTypeID = catTypeLink.Substring(catTypeLink.LastIndexOf(':') + 1); categoryValue = categoryValueXML.GetElementsByTagName("ns3:title").Item(0).InnerText; valuesItemfield.ID = categoryTypeID; valuesItemfield.PossibleValues.Add(categoryValue); totalValues++; valueFields.Add(valuesItemfield); System.Diagnostics.Debug.WriteLine("Total number of populated values is :" + totalValues + "/" + iDCount * (categoryUriPages.Count + 1)); //TODO pass this to a string to print in the UI populatedValue = "Populating value:" + categoryValue + " \r\n Total Values:" + totalValues; bw.ReportProgress(totalValues, populatedValue); } } }); System.Diagnostics.Debug.WriteLine("inner parallel -->finished"); } }); System.Diagnostics.Debug.WriteLine("outer parallel -->finished"); } //TODO: insert loop to add value to field if (fields.Count > 0) //category list has at least 1 entry { for (int j = 0; j < fields.Count; j++) //run through list { foreach (ExternalItemFieldBase values in valueFields) { if ((fields[j].ID.ToString() == values.ID.ToString())) { ExternalItemFieldBase addValueField = fields[j]; foreach (string possibleValue in values.PossibleValues) { addValueField.PossibleValues.Add(possibleValue); } fields[j] = addValueField; fields[j].SelectedValue = fields[j].PossibleValues[0]; } } } } } return(fields); }