private void ConnectWithTheCloud(Uri pushUri) { if (_info == null) { throw new InvalidOperationException("_info cloud data was empty."); } if (_pushSettings != null && pushUri != null) { // Store our updated URI first. _pushSettings.PushChannelUri = pushUri; _pushSettings.Save(); } System.Diagnostics.Debug.WriteLine("Push Notification Channel is now open: {0}", pushUri); string version = string.Empty; /*string deviceId; * string liveId; * GetDeviceInformation(out deviceId, out liveId);*/ /*string accent = string.Empty; * try * { * var accentColor = (Color)Application.Current.Resources["PhoneAccentColor"]; * if (accentColor != null) * { * accent = accentColor.ToString(CultureInfo.InvariantCulture); * } * } * catch * { * // timing issue? * }*/ IAppInfo iai = Application.Current as IAppInfo; if (iai != null) { version = iai.Version; } string av = version; string oat = _info.Token; string apv = string.Empty; IAppPlatformVersion iapv = Application.Current as IAppPlatformVersion; if (iapv != null) { apv = iapv.AppPlatformVersion; } string cc = _info.CheckinCount; string uc = _info.UseCount; string mfg = DeviceStatus.DeviceManufacturer + " " + DeviceStatus.DeviceName; string osv = Environment.OSVersion.Version.ToString(); IWebRequestFactory iwrf = Application.Current as IWebRequestFactory; if (iwrf != null) { var client = (iwrf.CreateWebRequestClient()).GetWrappedClientTemporary(); var uri = ((IGenerate4thAndMayorUri)(Application.Current)) .Get4thAndMayorUri(string.Format( CultureInfo.InvariantCulture, //"https://www.4thandmayor.com/v1/connect/?uri={0}&d={1}&lid={2}&oat={3}&u={4}&apv={5}&av={6}&cc={7}&uc={8}&mfg={9}&osv={10}&toast={11}&tile={12}&accent={13}", "/v1/connect/?uri={0}&oat={1}&u={2}&apv={3}&av={4}&cc={5}&uc={6}&mfg={7}&osv={8}", HttpUtility.UrlEncode(pushUri.ToString()), //deviceId, //liveId, oat, _info.UserId, apv, av, cc, uc, HttpUtility.UrlEncode(mfg), osv //_info.Toast, //_info.Tile, //HttpUtility.UrlEncode(accent) ), true); //var req = client.CreateSimpleWebRequest(uri); //client.DownloadStringCompleted += OnServiceConnectCompleted; // Try getting all active tiles. StringBuilder sb = new StringBuilder(); try { foreach (var t in ShellTile.ActiveTiles) { sb.AppendLine(t.NavigationUri.ToString()); } } catch (Exception) { } client.UploadStringAsync(uri, sb.ToString()); //client.DownloadStringAsyncWithPost(req, sb.ToString()); } }
public static List <Diag> GetDiagnostics() { var list = new List <Diag>(); // Better design: diagnostics can retrieve a value safely. Never // had this fail though. try { string os = Environment.OSVersion.ToString(); os = os.Replace("Windows CE", "Windows Phone"); list.Add(new Diag { Title = "operating system", Value = os }); IAppPlatformVersion iapv = Application.Current as IAppPlatformVersion; if (iapv != null) { string a = "unknown"; if (iapv.AppPlatformVersion == "7.0") { a = "Windows Phone 7"; } else if (iapv.AppPlatformVersion == "7.1") { a = "Windows Phone 7.5"; } list.Add(new Diag("designed for app platform", a)); } IAppInfo iai = Application.Current as IAppInfo; if (iai != null) { list.Add(new Diag("app version", iai.Version)); } list.Add(new Diag("current culture", CultureInfo.CurrentCulture.ToString())); list.Add(new Diag("user interface culture", CultureInfo.CurrentUICulture.ToString())); // DEVICE EXTENDED PROPERTIES! object o; if (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out o)) { string s = o as string; if (s != null) { list.Add( new Diag( "phone manufacturer", string.Format(CultureInfo.InvariantCulture, "{0}", s) )); } } if (DeviceExtendedProperties.TryGetValue("DeviceName", out o)) { string s = o as string; if (s != null) { // device friendly names =) // and super inefficient code. sweet. var upper = s.ToUpperInvariant(); if (upper == "SGH-I937") { s = "Focus S"; } if (upper == "SGH-I917") { s = "Focus"; } if (upper == "SGH-I917R") { s = "Focus*"; } if (upper.StartsWith("SGH-I1677")) { s = "Focus Flash"; // need to validate. } if (upper == "XDEVICEEMULATOR") { s = "Windows Phone Emulator"; } list.Add( new Diag( "phone model", string.Format(CultureInfo.InvariantCulture, "{0}", s) )); } } list.Add( new Diag( "peak memory use", string.Format(CultureInfo.CurrentCulture, "{0:N} MB", DeviceStatus.ApplicationPeakMemoryUsage / (1024 * 1024)) )); list.Add( new Diag( "available app memory", string.Format(CultureInfo.CurrentCulture, "{0:N} MB", DeviceStatus.ApplicationMemoryUsageLimit / (1024 * 1024)) )); list.Add( new Diag( "reported memory", string.Format(CultureInfo.CurrentCulture, "{0:N} MB", DeviceStatus.DeviceTotalMemory / (1024 * 1024)) )); list.Add(new Diag("web services agent", FourSquareWebClient.ClientInformation)); } catch { } return(list); }