private static async Task RunClientAsync(string[] args, CancellationToken token) { var config = new Config(); ParseArgs(args, config); ValidateQuery(config.Query); if (config.Debug) { Console.WriteLine("Config:"); Log(config); Console.WriteLine(); } using TProtocol protocol = MakeProtocol(config); Console.WriteLine("Logging in..."); var loginService = new LoginService(protocol); int key = await loginService.LogInAsync(config.Login, config.Key, token); if (config.Debug) { Console.WriteLine("Login credentials:"); Console.WriteLine($"Name={config.Login}"); Console.WriteLine($"Key={key}"); Console.WriteLine(); } Console.WriteLine("Sending query..."); var searchService = new SearchService(protocol, config); SearchState initial = await searchService.SearchAsync(config.Query, config.Limit, token); if (config.Debug) { Console.WriteLine($"Initial search state obtained. Estimated result count: {initial.CountEstimate}"); } Console.WriteLine("Fetching query results..."); List <Item> results = await searchService.FetchAllAsync(initial, token); if (config.Debug) { Console.WriteLine("Results:"); Log(results); Console.WriteLine(); } Console.WriteLine("Generating report..."); var reportService = new ReportService(protocol); var report = reportService.GenerateReport(results); if (config.Debug) { Console.WriteLine("Report:"); Log(report); Console.WriteLine(); } Console.WriteLine("Sending report..."); bool reportCorrect = await reportService.SaveReportAsync(report, token); Console.WriteLine($"Report correct? {reportCorrect}"); Console.WriteLine("Logging out..."); await loginService.LogOutAsync(token); Console.WriteLine("Finished."); }
public ClientService(ICommunication communication_) { this.communication = communication_; loginService = new LoginService(communication); }