public static bool Authorize(bool syncAll, bool testSite) { bool result = false; try { AuthorizationWindow dlg = new AuthorizationWindow(testSite); if (dlg.ShowDialog() == true) { if (testSite) { Core.Settings.Default.LiveAPITokenStaging = dlg.Token; } else { Core.Settings.Default.LiveAPIToken = dlg.Token; } using (GeocachingLiveV6 client = new GeocachingLiveV6(testSite)) { var resp = client.Client.GetYourUserProfile(new LiveV6.GetYourUserProfileRequest() { AccessToken = client.Token, DeviceInfo = new LiveV6.DeviceData() { DeviceName = "GlobalcachingApplication", DeviceUniqueId = "internal", ApplicationSoftwareVersion = "V1.0.0.0" } }); if (resp.Status.StatusCode == 0) { result = true; Core.Data.AccountInfo ai = new Core.Data.AccountInfo("GC", resp.Profile.User.UserName); Core.ApplicationData.Instance.AccountInfos.Add(ai); Core.Settings.Default.LiveAPIMemberType = resp.Profile.User.MemberType.MemberTypeName; Core.Settings.Default.LiveAPIMemberTypeId = (int)resp.Profile.User.MemberType.MemberTypeId; if (syncAll) { if (resp.Profile.User.HomeCoordinates != null) { Core.Settings.Default.HomeLocationLat = resp.Profile.User.HomeCoordinates.Latitude; Core.Settings.Default.HomeLocationLon = resp.Profile.User.HomeCoordinates.Longitude; } } } else { } } } } catch (Exception e) { Core.ApplicationData.Instance.Logger.AddLog(null, e); } return(result); }
private void Button_Click_1(object sender, RoutedEventArgs e) { try { using (GeocachingLiveV6 client = new GeocachingLiveV6()) { var resp = client.Client.GetYourUserProfile(new LiveV6.GetYourUserProfileRequest() { AccessToken = Token, DeviceInfo = new LiveV6.DeviceData() { DeviceName = "GlobalcachingApplication", DeviceUniqueId = "internal", ApplicationSoftwareVersion = "V1.0.0.0" } }); if (resp.Status.StatusCode == 0) { Core.Settings.Default.LiveAPIToken = Token; Core.Data.AccountInfo ai = new Core.Data.AccountInfo("GC", resp.Profile.User.UserName); Core.ApplicationData.Instance.AccountInfos.Add(ai); Core.Settings.Default.LiveAPIMemberType = resp.Profile.User.MemberType.MemberTypeName; Core.Settings.Default.LiveAPIMemberTypeId = (int)resp.Profile.User.MemberType.MemberTypeId; if (resp.Profile.User.HomeCoordinates != null) { Core.Settings.Default.HomeLocationLat = resp.Profile.User.HomeCoordinates.Latitude; Core.Settings.Default.HomeLocationLon = resp.Profile.User.HomeCoordinates.Longitude; } Close(); } else { Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Error, resp.Status.StatusMessage); } } } catch (Exception ex) { Core.ApplicationData.Instance.Logger.AddLog(this, ex); } }
public static bool Authorize(bool syncAll, bool testSite) { bool result = false; try { AuthorizationWindow dlg = new AuthorizationWindow(testSite); if (dlg.ShowDialog()==true) { if (testSite) { Core.Settings.Default.LiveAPITokenStaging = dlg.Token; } else { Core.Settings.Default.LiveAPIToken = dlg.Token; } using (GeocachingLiveV6 client = new GeocachingLiveV6(testSite)) { LiveV6.GetUserProfileResponse resp = client.Client.GetYourUserProfile(new LiveV6.GetYourUserProfileRequest() { AccessToken = client.Token, DeviceInfo = new LiveV6.DeviceData() { DeviceName = "GlobalcachingApplication", DeviceUniqueId = "internal", ApplicationSoftwareVersion = "V1.0.0.0" } }); if (resp.Status.StatusCode == 0) { result = true; Core.Data.AccountInfo ai = new Core.Data.AccountInfo("GC", resp.Profile.User.UserName); Core.ApplicationData.Instance.AccountInfos.Add(ai); Core.Settings.Default.LiveAPIMemberType = resp.Profile.User.MemberType.MemberTypeName; Core.Settings.Default.LiveAPIMemberTypeId = (int)resp.Profile.User.MemberType.MemberTypeId; if (syncAll) { if (resp.Profile.User.HomeCoordinates != null) { Core.Settings.Default.HomeLocationLat = resp.Profile.User.HomeCoordinates.Latitude; Core.Settings.Default.HomeLocationLon = resp.Profile.User.HomeCoordinates.Longitude; } } } else { } } } } catch(Exception e) { Core.ApplicationData.Instance.Logger.AddLog(null, e); } return result; }