Beispiel #1
0
        private static void GetWorkItem(APIHelper aPIHelper, AzureServiceConfiguration azureServiceConfiguration)
        {
            Console.WriteLine($"Obtendo os dados do Work Item de ID {azureServiceConfiguration.LastWorkItemID}");
            WorkItemDTO workItemDTO = aPIHelper.Get <WorkItemDTO>($"{azureServiceConfiguration.Organization}/{azureServiceConfiguration.Project}/_apis/wit/workitems/{azureServiceConfiguration.LastWorkItemID}?fields=System.Id,System.Title,System.WorkItemType,System.CreatedDate&api-version=5.1").GetAwaiter().GetResult();

            if (workItemDTO != null)
            {
                Console.WriteLine($"Dados do Work Item de ID {azureServiceConfiguration.LastWorkItemID} foram encontrados e serão adicionados ao banco de dados");

                WorkItemRepository workItemRepository = new WorkItemRepository(new AzureDevOpsDbContextFactory().CreateDbContext());
                workItemRepository.Add(new WorkItem {
                    ID        = workItemDTO.fields.SystemId,
                    Title     = workItemDTO.fields.SystemTitle,
                    Type      = workItemDTO.fields.SystemWorkItemType,
                    CreatedOn = workItemDTO.fields.SystemCreatedDate
                });

                azureServiceConfiguration.LastWorkItemID++;
                GetWorkItem(aPIHelper, azureServiceConfiguration);
            }
            else
            {
                Console.WriteLine($"Dados do Work Item de ID {azureServiceConfiguration.LastWorkItemID} não foram encontrados a rotina será encerrada");
                azureServiceConfiguration.LastWorkItemID--;
                azureServiceConfigurationRepository.Update(azureServiceConfiguration);
            }
        }
Beispiel #2
0
 public WorkItem CreateWorkItem(WorkItem workItem)
 {
     try
     {
         if (workItem == null)
         {
             throw new NullReferenceException();
         }
         var newWorkItem = _workItemRepository.Add(workItem);
         return(newWorkItem);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }