// ReSharper restore All #pragma warning restore 0649 public Tuple <Version, DateTime, string> GetLatestRelease(bool includeBeta) { if (includeBeta) { var rest = new SimpleJsonRest(null, @"https://api.github.com"); var response = rest.Get <List <JsonResponse> >("repos/Mikescher/AlephNote/releases").First(); var url = response.assets.First(a => a.browser_download_url.EndsWith(".zip")).browser_download_url; var date = response.published_at; var version = ParseVersion(response.tag_name); return(Tuple.Create(version, date, url)); } else { var rest = new SimpleJsonRest(null, @"https://api.github.com"); var response = rest.Get <JsonResponse>("repos/Mikescher/AlephNote/releases/latest"); var url = response.assets.First(a => a.browser_download_url.EndsWith(".zip")).browser_download_url; var date = response.published_at; var version = ParseVersion(response.tag_name); return(Tuple.Create(version, date, url)); } }
public bool UploadStatistics(Version version) { #if DEBUG return(true); #endif try { var rest = new SimpleJsonRest(_settings.CreateProxy(), @"https://mikescher.com"); var response = rest.Get <JsonResponse>( "api/statsping", $"Name={"AlephNote"}", $"Version={version}", $"ClientID={_settings.ClientID:D}", $"ProviderStr={_settings.ActiveAccount.Plugin.DisplayTitleShort.Replace(' ', '_')}", $"ProviderID={_settings.ActiveAccount.Plugin.GetUniqueID()}", $"NoteCount={_repository.Notes.Count}"); return(response.success); } catch (Exception e) { LoggerSingleton.Inst.Warn("StatsConnection", "Could not send anonymous usage statistics to server", e.ToString()); return(false); } }
public Tuple <Version, DateTime, string> GetLatestRelease(bool includeBeta) { var rest = new SimpleJsonRest(_settings?.CreateProxy(), @"https://api.github.com"); var responses = rest .Get <List <JsonResponse> >("repos/Mikescher/AlephNote/releases") .OrderByDescending(p => Version.TryParse(p.tag_name.Trim('V', 'v', ' '), out var v) ? v : new Version(0, 0, 0)) .ToList(); var response = includeBeta ? responses.First() : responses.First(p => !p.prerelease); var url = response.assets.First(a => a.browser_download_url.EndsWith(".zip")).browser_download_url; var date = response.published_at; var version = ParseVersion(response.tag_name); return(Tuple.Create(version, date, url)); }
public bool UploadStatistics(Version version) { #if DEBUG return(true); #endif try { var rest = new SimpleJsonRest(_settings.CreateProxy(), @"https://mikescher.com"); var rfmode = (_settings.RawFolderRepoAllowCreation ? "C":"") + (_settings.RawFolderRepoAllowDeletion ? "D" : "") + (_settings.RawFolderRepoAllowModification ? "M" : ""); var asmod = _settings.GetAnyAdvancedSettingsChanged(out var asdiff); var response = rest.Get <JsonResponse>( "api/statsping", $"Name={"AlephNote"}", $"Version={version}", $"ClientID={_settings.ClientID:D}", $"ProviderStr={_settings.ActiveAccount.Plugin.DisplayTitleShort.Replace(' ', '_')}", $"ProviderID={_settings.ActiveAccount.Plugin.GetUniqueID()}", $"NoteCount={_repository.Notes.Count}", $"RawFolderRepo={_settings.UseRawFolderRepo}", $"RawFolderRepoMode={rfmode}", $"GitMirror={_settings.DoGitMirror}", $"GitMirrorPush={_settings.GitMirrorDoPush}", $"Theme={_settings.Theme}", $"LaunchOnBoot={_settings.LaunchOnBoot}", $"EmulateHierarchicalStructure={_settings.EmulateHierarchicalStructure}", $"HasEditedAdvancedSettings={asmod}", $"AdvancedSettingsDiff={asdiff}"); return(response.success); } catch (Exception e) { LoggerSingleton.Inst.Warn("StatsConnection", "Could not send anonymous usage statistics to server", e.ToString()); return(false); } }