public void Execute(string[] args) { var url = AppSetting.Get <string>("ApiUrl"); var key = AppSetting.Get <string>("Key"); var siteServiceId = AppSetting.Get <Guid>("SiteServiceId"); int interval; try { interval = int.Parse(args[0]) * 1000; } catch (Exception) { Console.WriteLine("Invalid parameters"); return; } if (!apiService.AuthenSiteService(siteServiceId, key)) { Console.WriteLine("Authen Faild"); return; } connection = new HubConnectionBuilder() .WithUrl(url + "/ControlHub") .WithAutomaticReconnect() .Build(); InitialConnections().Wait(); connection.Reconnected += async(msg) => { await Register(apiService.GetToken()); }; connection.StartAsync().Wait(); Register(apiService.GetToken()).Wait(); timer.Interval = interval; loadPumpTimer.Interval = 180000; loadPumpTimer.Elapsed += LoadPumpTimer_Elapsed; timer.Elapsed += Timer_Elapsed; timer.Start(); loadPumpTimer.Start(); Console.Clear(); Console.WriteLine("Notify pump state to clients."); Console.WriteLine("Running..."); Console.WriteLine("Enter command \"exit\" for terminate jobs."); Console.Write("Command : "); var cmd = Console.ReadLine(); while (cmd.ToLower() != "exit") { Console.Clear(); Console.WriteLine("Notify pump state to clients."); Console.WriteLine("Running..."); Console.WriteLine("Enter command \"exit\" for terminate jobs."); Console.Write("Command : "); cmd = Console.ReadLine(); } this.Dispose(); }