async void GetSchedule() { try { // Get the schedule asychronously osVodigiWS.osVodigiServiceSoapClient ws = new osVodigiWS.osVodigiServiceSoapClient(); ws.Endpoint.Address = new System.ServiceModel.EndpointAddress(new Uri(PlayerConfiguration.configVodigiWebserviceURL)); osVodigiWS.Player_GetCurrentScheduleResponse scheduleResponse = await ws.Player_GetCurrentScheduleAsync(PlayerConfiguration.configPlayerID); string xml = scheduleResponse.Body.Player_GetCurrentScheduleResult; if (xml.StartsWith("<xml><Error>")) { throw new Exception("Error"); } ScheduleFile.SaveScheduleFile(xml); CurrentSchedule.ClearSchedule(); CurrentSchedule.LastScheduleXML = xml; CurrentSchedule.ParseScheduleXml(xml); // Also copies the PlayerSettings to Helpers.PlayerSettings // At this point, the schedule has been retrieved, so go to the Download control FadeOut(); } catch { DisplayErrorCondition(); } }
private void RegisterClicked() { try { lblError.Text = String.Empty; if (String.IsNullOrEmpty(txtAccountName.Text.Trim()) || String.IsNullOrEmpty(txtPlayerName.Text.Trim())) { lblError.Text = "Please enter Account and Player Names."; return; } osVodigiWS.osVodigiServiceSoapClient ws = new osVodigiWS.osVodigiServiceSoapClient(); ws.Endpoint.Address = new System.ServiceModel.EndpointAddress(new Uri(PlayerConfiguration.configVodigiWebserviceURL)); // Validate the account osVodigiWS.Account account = ws.Account_GetByName(txtAccountName.Text.Trim()); if (account == null) { lblError.Text = "Invalid Account Name. Please retry."; return; } PlayerConfiguration.configAccountID = account.AccountID; PlayerConfiguration.configAccountName = account.AccountName; // Validate the player osVodigiWS.Player player = ws.Player_GetByName(account.AccountID, txtPlayerName.Text.Trim()); if (player == null) { lblError.Text = "Invalid Player Name. Please retry."; return; } PlayerConfiguration.configPlayerID = player.PlayerID; PlayerConfiguration.configPlayerName = player.PlayerName; // Set the remaining properties on PlayerConfiguration and save the configuration PlayerConfiguration.configIsPlayerInitialized = true; PlayerConfiguration.SavePlayerConfiguration(); // Since registration can cause accountid/playerid changes, delete the local schedule file ScheduleFile.DeleteScheduleFile(); // Register the player at vodigi.com try { VodigiWS.VodigiWSSoapClient vws = new VodigiWS.VodigiWSSoapClient(); vws.PlayerRegistered("PlayerRegistration"); } catch { } FadeOut(); } catch { lblError.Text = "Cannot connect to Vodigi Server. Please retry."; } }
private Station __GetStation(XmlNode node, ESTW estw) { if (node == null) { return(null); } var StationName = node.Attributes["name"]; var StationShort = node.Attributes["short"]; var StationNumber = node.Attributes["refNr"]; var ScheduleFile = node.Attributes["scheduleFile"]; var LocalOrderFile = node.Attributes["localOrderFile"]; var DisplayName = node.Attributes["displayName"]; if (StationName == null || StationShort == null || StationNumber == null) { return(null); } short number; if (!Int16.TryParse(StationNumber.InnerText, out number)) { return(null); } string Schedule = ScheduleFile == null ? null : ScheduleFile.InnerText; string LocalOrders = LocalOrderFile == null ? null : LocalOrderFile.InnerText; var station = new Station(StationName.InnerText, StationShort.InnerText, number, Schedule, LocalOrders, estw); if (DisplayName != null) { station.DisplayName = DisplayName.InnerText; } foreach (XmlNode scheduleFileNode in node.SelectNodes("scheduleFile")) { var fileName = scheduleFileNode.Attributes["fileName"]; if (fileName == null || fileName.InnerText.IsNullOrWhiteSpace()) { continue; } var scheduleFile = new ScheduleFile(fileName.InnerText); scheduleFile.Tracks = scheduleFileNode.SelectNodes("track").Cast <XmlNode>().Select(x => x.InnerText).ToList(); station.ScheduleFiles.Add(scheduleFile); } return(station); }
private void UseLastClicked() { try { string xml = ScheduleFile.ReadScheduleFile(); if (String.IsNullOrEmpty(xml)) { MessageBox.Show("Unable to load previous schedule. Please use the 'Retry' button.", "No Previous Schedule", MessageBoxButton.OK, MessageBoxImage.Error); return; } CurrentSchedule.ParseScheduleXml(xml); FadeOut(); } catch { } }