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)); } }
static void Main(string[] args) { var workItemService = new WorkItemService(); while (true) { Console.WriteLine("--------------------------"); PrintUsage(); string command = Console.ReadLine(); if (command.ToLower().Trim() == "quit") { return; } // Parse the arguments string cmd, title = null, desc = null; int id; try { var arguments = command.Split(" ").Where(x => x != "").ToArray(); cmd = arguments[0].ToLower(); id = int.Parse(arguments[1]); if (arguments.Count() > 2) { title = arguments[2]; desc = arguments[3]; } } catch (Exception) { Console.WriteLine("Error"); continue; } var wi = workItemService.GetById(id); // Execute Command try { switch (cmd.ToLower()) { case "create": wi = new WorkItem(); workItemService.Create(wi); wi.Edit(title, desc); wi.Print(); break; case "delete": if (wi.CanDelete()) { workItemService.Delete(wi); } break; case "edit": wi.Edit(title, desc); workItemService.Edit(wi); break; case "open": wi.Open(); workItemService.Edit(wi); break; case "resolve": wi.Resolve(); workItemService.Edit(wi); break; case "verify": wi.Verify(); workItemService.Edit(wi); break; case "print": wi.Print(); break; default: PrintUsage(); continue; } } catch (Exception ex) { Console.WriteLine("Unable to perform operation. " + ex.Message); PrintUsage(); } } }
public ActionResult <WorkItem> Create(WorkItem book) { _workItemService.Create(book); return(CreatedAtRoute("GetWorkItem", new { id = book.Id.ToString() }, book)); }