예제 #1
0
        public static void TimerElapsed(object state)
        {
            WorkItemService service = new WorkItemService(_configurations);

            var itens = new ApiAzureDevopsCloud(_configurations.Url
                                                , _configurations.BasicToken, _configurations.Project).getWorkItens();

            while (!itens.IsCompleted)
            {
                ;
            }

            foreach (var item in itens.Result.ToList())
            {
                var workItem = new WorkItemResult
                {
                    IdWorkItem = item.Id.Value
                };

                foreach (var valor in item.Fields)
                {
                    if (valor.Key == "System.Title")
                    {
                        workItem.Titulo = valor.Value.ToString();
                    }

                    if (valor.Key == "System.WorkItemType")
                    {
                        workItem.Tipo = valor.Value.ToString();
                    }

                    if (valor.Key == "System.ChangedDate")
                    {
                        workItem.DataCriacaoWorkItem = DateTime.Parse(valor.Value.ToString());
                    }
                }
                if (!service.GetByWorkId(item.Id.Value))
                {
                    service.Create(workItem);
                }

                Console.WriteLine(JsonConvert.SerializeObject(workItem));
            }
        }