Esempio n. 1
0
 private async Task GetPowerCommsAsync()
 {
     CommsEnabled = false;
     if (PowerComms == null || PowerComms.ShortName != PowerStanding.ShortName)
     {
         try
         {
             PowerDetailsService powerService = PowerDetailsService.Instance();
             PowerComms = await powerService.GetPowerCommsAsync(PowerStanding.ShortName, 3).ConfigureAwait(false);
         }
         catch (HttpRequestException ex)
         {
             string errorMessage = ex.Message;
             int    start        = errorMessage.IndexOf("OPENSSL_internal:", StringComparison.OrdinalIgnoreCase);
             if (start > 0)
             {
                 start += 17;
                 int end = errorMessage.IndexOf(" ", start, StringComparison.OrdinalIgnoreCase);
                 errorMessage = $"SSL Error ({errorMessage.Substring(start, end - start).Trim()})";
             }
             else if (errorMessage.IndexOf("Error:", StringComparison.OrdinalIgnoreCase) > 0)
             {
                 errorMessage = errorMessage.Substring(errorMessage.IndexOf("Error:", StringComparison.OrdinalIgnoreCase) + 6).Trim();
             }
             ToastHelper.Toast("Network Error: Unable to download Power comms links");
         }
         catch (Exception)
         {
             ToastHelper.Toast("Error: Unable to download Power comms links");
         }
     }
     CommsEnabled = PowerComms != null;
 }
        private async Task GetPowerDetailsAsync()
        {
            try
            {
                PowerDetailsService pdService = PowerDetailsService.Instance();
                StandingsService    gsService = StandingsService.Instance();
                if (pdService.SelectedPower != null)
                {
                    PowerDetails = pdService.SelectedPower;
                    CancellationTokenSource cancelToken = new CancellationTokenSource();
                    PowerStanding = await gsService.GetPowerAsync(PowerDetails.ShortName, cancelToken).ConfigureAwait(false);

                    Cycle       = PowerStanding.Cycle;
                    LastUpdated = PowerStanding.LastUpdated;
                    ExpandText  = String.Format("<p>{0}</p>&nbsp;<ul><li>Strong Against: {1}</li><li>Weak Against: {2}</li></ul>",
                                                PowerDetails.ExpansionText,
                                                PowerDetails.ExpansionStrongGovernment,
                                                PowerDetails.ExpansionWeakGovernment);
                    ControlText = String.Format("<p>{0}</p>&nbsp;<ul><li>Strong Against: {1}</li><li>Weak Against: {2}</li></ul>",
                                                PowerDetails.ControlText,
                                                PowerDetails.ControlStrongGovernment,
                                                PowerDetails.ControlWeakGovernment);
                }
            }
            catch (Exception ex)
            {
                ToastHelper.Toast(String.Format("Error getting Power details: {0}", ex.Message));
            }
        }
Esempio n. 3
0
        private async Task OpenPowerDetailsAsync(PowerStanding power)
        {
            PowerDetailsService pdService = PowerDetailsService.Instance();

            pdService.SetSelectedPower(power.ShortName);
            await Xamarin.Forms.Shell.Current.GoToAsync("//powerDetails/overview").ConfigureAwait(false);
        }