static void Main(string[] args) { Console.Write("Do you have an existing source account? (Y/n) "); ConsoleKeyInfo existingAccount = Console.ReadKey(); Console.WriteLine(); string src_user = ""; string src_pass; if (existingAccount.Key == ConsoleKey.Y || existingAccount.Key == ConsoleKey.Enter) { Console.Write("Username: "******"Password (not hidden): "); src_pass = Console.ReadLine(); } else { Console.Write("Desired username: "******":") + 2); } Console.Write("Enter your eCourt URL (e.g. https://server.domain/ecourtpath/): "); string eC_URL = Console.ReadLine(); Console.Write("Enter your eCourt username: "******"Enter your eCourt password (not hidden): "); string eC_pass = Console.ReadLine(); string authToken = TicketImport.GetEcourtUserAuthToken(eC_user, eC_pass); TicketImport _ticketImport = new TicketImport( "https://customdev.journaltech.com/api/soap/TicketAPI.svc?wsdl", src_user, src_pass, eC_URL, authToken ); Console.WriteLine(); Console.Write("Ready to roll! Press any key to import all new tickets... "); Console.ReadKey(); Console.WriteLine(); _ticketImport.ImportNewTickets(); Console.Write("Complete! Press any key to exit... "); Console.ReadKey(); }
public void CanImportTicket() { var ticket = new TicketImport() { Subject = "my printer is on fire", Comments = new List <TicketImportComment> { new TicketImportComment { AuthorId = Settings.UserId, Value = "HELP comment created in Import 1", Public = false, CreatedAt = DateTime.UtcNow.AddDays(-2) }, new TicketImportComment { AuthorId = Settings.UserId, Value = "HELP comment created in Import 2", Public = false, CreatedAt = DateTime.UtcNow.AddDays(-3) } }, Priority = TicketPriorities.Urgent, CreatedAt = DateTime.Now.AddDays(-5), UpdatedAt = DateTime.Now.AddDays(-4), SolvedAt = DateTime.Now.AddDays(-3), Status = TicketStatus.Solved, AssigneeId = Settings.UserId, Description = "test description" }; var res = api.Tickets.ImportTicket(ticket).Ticket; Assert.NotNull(res); Assert.True(res.Id.HasValue); Assert.Greater(res.Id.Value, 0); Assert.Less(res.CreatedAt.Value.LocalDateTime, DateTime.Now.AddDays(-4)); Assert.Greater(res.UpdatedAt.Value.LocalDateTime, res.CreatedAt.Value.LocalDateTime); Assert.AreEqual(res.Status, TicketStatus.Solved); Assert.AreEqual(res.Description, "test description"); var resComments = api.Tickets.GetTicketComments(res.Id.Value); Assert.NotNull(resComments); Assert.AreEqual(resComments.Count, 3); api.Tickets.DeleteAsync(res.Id.Value); //Assert.Greater(res.SolvedAt.Value.LocalDateTime, res.UpdatedAt.Value.LocalDateTime); }
public void CanBulkImportTicket() { List <TicketImport> test = new List <TicketImport>(); for (int x = 0; x < 2; x++) { var ticket = new TicketImport() { Subject = "my printer is on fire", Comments = new List <TicketImportComment> { new TicketImportComment { AuthorId = Settings.UserId, Value = "HELP comment created in Import 1", CreatedAt = DateTime.UtcNow.AddDays(-2), Public = false }, new TicketImportComment { AuthorId = Settings.UserId, Value = "HELP comment created in Import 2", CreatedAt = DateTime.UtcNow.AddDays(-3), Public = false } }, Priority = TicketPriorities.Urgent, CreatedAt = DateTime.Now.AddDays(-5), UpdatedAt = DateTime.Now.AddDays(-4), SolvedAt = DateTime.Now.AddDays(-3), Status = TicketStatus.Solved, AssigneeId = Settings.UserId, Description = "test description" }; test.Add(ticket); } var res = api.Tickets.BulkImportTickets(test); Assert.AreEqual(res.JobStatus.Status, "queued"); var job = api.JobStatuses.GetJobStatus(res.JobStatus.Id); Assert.AreEqual(job.JobStatus.Id, res.JobStatus.Id); int count = 0; while (job.JobStatus.Status.ToLower() != "completed" && count < 10) { Thread.Sleep(1000); job = api.JobStatuses.GetJobStatus(res.JobStatus.Id); count++; } Assert.AreEqual(job.JobStatus.Status.ToLower(), "completed"); foreach (var r in job.JobStatus.Results) { var ticket = api.Tickets.GetTicket(r.Id).Ticket; Assert.AreEqual(ticket.Description, "test description"); var resComments = api.Tickets.GetTicketComments(r.Id); Assert.NotNull(resComments); Assert.AreEqual(resComments.Count, 3); foreach (var c in resComments.Comments) { Assert.True(c.CreatedAt.HasValue); Assert.Less(c.CreatedAt.Value.LocalDateTime, DateTime.Now.AddDays(-1)); } api.Tickets.DeleteAsync(r.Id); } }
/// <summary> /// In addition to setting normal ticket properties, you can set the following time stamps on the tickets: solved_at, updated_at, and created_at. /// </summary> /// <param name="ticket"></param> /// <returns></returns> public async Task <IndividualTicketResponse> ImportTicketAsync(TicketImport ticket) { return(await GenericPostAsync <IndividualTicketResponse>($"{_imports}/{_tickets}.json", new { ticket })); }
/// <summary> /// In addition to setting normal ticket properties, you can set the following time stamps on the tickets: solved_at, updated_at, and created_at. /// </summary> /// <param name="ticket"></param> /// <returns></returns> public IndividualTicketResponse ImportTicket(TicketImport ticket) { return(GenericPost <IndividualTicketResponse>($"{_imports}/{_tickets}.json", new { ticket })); }
/// <summary> /// In addition to setting normal ticket properties, you can set the following time stamps on the tickets: solved_at, updated_at, and created_at. /// </summary> /// <param name="ticket"></param> /// <returns></returns> public async Task <IndividualTicketResponse> ImportTicketAsync(TicketImport ticket) { var body = new { ticket }; return(await GenericPostAsync <IndividualTicketResponse>(_imports + "/" + _tickets + ".json", body)); }
/// <summary> /// In addition to setting normal ticket properties, you can set the following time stamps on the tickets: solved_at, updated_at, and created_at. /// </summary> /// <param name="ticket"></param> /// <returns></returns> public IndividualTicketResponse ImportTicket(TicketImport ticket) { var body = new { ticket }; return(GenericPost <IndividualTicketResponse>(_imports + "/" + _tickets + ".json", body)); }