private async Task <CrpSession> CreateOrUpdateCrpSession(CrpSession crpSession) { CreateCrpSession createCrpSession = new CreateCrpSession(_props); CrpSession res = new CrpSession(); if (!_dictionary.ContainsKey(crpSession.CrpSessionName)) { res = await createCrpSession.CreateCrpSessionInTfs(crpSession); } else { res.CrpSessionName = crpSession.CrpSessionName; res.CrpSessionId = _dictionary[crpSession.CrpSessionName]; } return(res); }
public async Task <CrpSession> CreateCrpSessionInTfs(CrpSession crpSession) { CrpSession res = new CrpSession(); List <Object> patchDocument = new List <object>(); patchDocument.Add(new { op = "add", path = "/fields/System.Title", value = crpSession.CrpSessionName }); //serialize the fields array into a json string var patchValue = new StringContent(JsonConvert.SerializeObject(patchDocument), Encoding.UTF8, "application/json-patch+json"); var requestUri = "APHP/" + _project + "/_apis/wit/workitems/$CRP Session?api-version=3.0"; var method = new HttpMethod("PATCH"); var request = new HttpRequestMessage(method, requestUri) { Content = patchValue }; string requestTxt = await request.Content.ReadAsStringAsync(); var response = await _client.SendAsync(request); _logger.LogUriAndPackage(requestUri, requestTxt); string responseTxt = await response.Content.ReadAsStringAsync(); _logger.Log(responseTxt); if (response.IsSuccessStatusCode) { string workItem = await response.Content.ReadAsStringAsync(); JObject jo = JObject.Parse(workItem); res.CrpSessionId = Convert.ToInt32(jo["id"]); res.CrpSessionName = crpSession.CrpSessionName; return(res); } else { return(null); } }
private List <ContractRequirement> GatherRequirements(Excel.Worksheet worksheet) { List <ContractRequirement> res = new List <ContractRequirement>(); int usedRows = GetUsedRows(worksheet); List <int> existingRequirements = new List <int>(); using (var progress = new ProgressBar()) { Console.Write("Gathering Requirements... "); for (int i = 3; i <= usedRows; i++) { progress.Report((double)i / (double)usedRows); if (!existingRequirements.Contains(Convert.ToInt32(worksheet.Cells[i, 5].Value2.ToString()))) { ContractRequirement currContractRequirement = new ContractRequirement(); currContractRequirement.RequirementID = Convert.ToInt32(worksheet.Cells[i, 5].Value2.ToString()); currContractRequirement.RequirementTitle = worksheet.Cells[i, 6].Value2.ToString(); currContractRequirement.Description = worksheet.Cells[i, 7].Value2.ToString(); currContractRequirement.ProposedLanguage = worksheet.Cells[i, 8].Value2.ToString(); currContractRequirement.PrimaryArea = worksheet.Cells[i, 9].Value2.ToString(); currContractRequirement.State = worksheet.Cells[i, 10].Value2.ToString(); currContractRequirement.Validated = worksheet.Cells[i, 11].Value2.ToString(); if (worksheet.Cells[i, 12].Value2 != null) { currContractRequirement.DeScopeDetails = worksheet.Cells[i, 12].Value2.ToString(); } if (worksheet.Cells[i, 13].Value2 != null) { currContractRequirement.ValidationActionItem = worksheet.Cells[i, 13].Value2.ToString(); } if (worksheet.Cells[i, 14].Value2 != null) { currContractRequirement.ValidationActionItemStatus = worksheet.Cells[i, 14].Value2.ToString(); } if (worksheet.Cells[i, 15].Value2 != null) { currContractRequirement.ValidationAssumptions = worksheet.Cells[i, 15].Value2.ToString(); } if (worksheet.Cells[i, 16].Value2 != null) { currContractRequirement.Deliverable = worksheet.Cells[i, 16].Value2.ToString(); } if (worksheet.Cells[i, 17].Value2 != null) { currContractRequirement.CoveredInCrp = worksheet.Cells[i, 17].Value2.ToString(); } if (worksheet.Cells[i, 18].Value2 != null) { List <string> allCrpSession = ExtractNewLineValues(worksheet.Cells[i, 18].Value2.ToString()); currContractRequirement.CrpSession = new List <CrpSession>(); foreach (string crpSession in allCrpSession) { if (_crpSessionMapping.ContainsKey(crpSession)) { CrpSession currCrpSession = new CrpSession { CrpSessionId = _crpSessionMapping[crpSession], CrpSessionName = crpSession }; currContractRequirement.CrpSession.Add(currCrpSession); } } } if (worksheet.Cells[i, 19].Value2 != null) { currContractRequirement.SolutionUnderstanding = worksheet.Cells[i, 19].Value2.ToString(); } if (worksheet.Cells[i, 20].Value2 != null) { //Console.WriteLine(_opssWorksheet.Cells[i, 20].Value2); List <string> allPlaybooks = ExtractNewLineValues(worksheet.Cells[i, 20].Value2.ToString()); currContractRequirement.Playbooks = new List <Playbook>(); foreach (string playbook in allPlaybooks) { if (_playbookMapping.ContainsKey(playbook)) { Playbook currPlaybook = new Playbook { PlaybookId = _playbookMapping[playbook], PlaybookName = playbook }; currContractRequirement.Playbooks.Add(currPlaybook); } } } if (worksheet.Cells[i, 21].Value2 != null) { List <string> allWorkPackages = ExtractNewLineValues(worksheet.Cells[i, 21].Value2.ToString()); currContractRequirement.WorkPackages = new List <WorkPackage>(); foreach (string workPackage in allWorkPackages) { WorkPackage currWorkPackage = new WorkPackage { WorkPackageName = workPackage }; currContractRequirement.WorkPackages.Add(currWorkPackage); } } if (worksheet.Cells[i, 22].Value2 != null) { List <string> allProductDsd = ExtractNewLineValues(worksheet.Cells[i, 22].Value2.ToString()); currContractRequirement.ProductDSD = new List <ProductDsd>(); foreach (string productDsd in allProductDsd) { if (_productDsdMapping.ContainsKey(productDsd)) { ProductDsd currProductDsd = new ProductDsd { ProductDsdId = _productDsdMapping[productDsd], ProductDsdName = productDsd }; currContractRequirement.ProductDSD.Add(currProductDsd); } } } if (worksheet.Cells[i, 24].Value2 != null) { currContractRequirement.VendorIntegration = worksheet.Cells[i, 24].Value2.ToString(); } if (worksheet.Cells[i, 25].Value2 != null) { currContractRequirement.Coverage = worksheet.Cells[i, 25].Value2.ToString(); } existingRequirements.Add(currContractRequirement.RequirementID); res.Add(currContractRequirement); } } Console.WriteLine(); } return(res); }