private static async void StartAlarmClock() { var timeSpan = new TimeSpan(4, 30, 0); Action action = () => { using (var client = new HttpClient()) { client.GetAsync($"http://127.0.0.1:{Port}/api/SmartHouse/TurnOff").Wait(); } Logger.LogInfoMessage("Smart house turn off"); var smartHouse = new SmartHouseService(); var pandoraService = new PandoraService(); pandoraService.Stop(); using (var orvibioService = new OrviboService()) { var turnOffResult = orvibioService.TurnOff(); Logger.LogInfoMessage("orvibioService.TurnOff"); Logger.LogInfoMessage(turnOffResult.Message); Thread.Sleep(TimeSpan.FromMinutes(1)); var turnOnResult = orvibioService.TurnOn(); Logger.LogInfoMessage("orvibioService.TurnOn"); Logger.LogInfoMessage(turnOnResult.Message); } Thread.Sleep(TimeSpan.FromMinutes(3)); smartHouse.RestartOpenVPNService().Wait(); }; var alarmClock = new AlarmClock(DateTime.Today.AddDays(1).Date.AddTicks(timeSpan.Ticks), action); await alarmClock.Start(); }
private async Task ExecutePandoraCommands(string command) { var pandora = new PandoraService(); var smartHouse = new SmartHouseService(); await ShowProgressScreen($"Starting to {command} song"); switch (command) { case "Play": await smartHouse.Run(UWPLib.Model.SmartHouseCommands.Play); await CompleteMessage(""); break; case "Stop": await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.Play); await CompleteMessage(""); break; case "Next": await smartHouse.Run(UWPLib.Model.SmartHouseCommands.Next); await CompleteMessage(""); break; case "Love": await smartHouse.LoveSong(); await CompleteMessage(""); break; case "Hate": await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.ThumbDown); await CompleteMessage(""); break; case "Boring": await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.Tired); await CompleteMessage(""); break; case "Show": var info = await smartHouse.GetCurrentSong(); await CortanaResponseShowSong(info); break; case "NextStation": var nextInfo = await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.NextStation); await CompleteMessage(nextInfo?.Message); break; case "PrevStation": var prevInfo = await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.PrevStation); await CompleteMessage(prevInfo?.Message); break; default: LaunchAppInForeground(); break; } }
public MainWindow() { pandoraService = new PandoraService(); restfulService = new RESTfulService(); InitializeComponent(); }