예제 #1
0
        private static void Main(string[] args)
        {
            var githubDownloader = new ReleaseDownloader(args[0], args[1]);

            var releases = githubDownloader.GetDataForAllReleases();

            foreach (var release in releases)
            {
                var releaseName = $"{release.tag_name}";

                var releasePath = $"releases\\{releaseName}";

                Console.WriteLine("Release: {0}", release.tag_name);

                CheckAndCreateFolder(releasePath);

                SaveReleaseComments(release.body, releasePath);

                foreach (var asset in release.assets)
                {
                    var assetPath = releasePath + "\\" + asset.name;

                    Console.WriteLine("\tAsset: {0} - {1}", asset.id, assetPath);
                    var assetDl = githubDownloader.DownloadAsset(asset.id, assetPath);
                }
            }
        }
예제 #2
0
 private PluginService(HttpClient httpClient, string version, string pluginPath, string lang)
 {
     _cultureInfo    = new CultureInfo(lang);
     Version         = version;
     _betaDownloader =
         new ReleaseDownloader(new ReleaseDownloaderSettings(httpClient, AuthorName, RepoName, true,
                                                             pluginPath));
     _downloader =
         new ReleaseDownloader(
             new ReleaseDownloaderSettings(httpClient, AuthorName, RepoName, false, pluginPath));
 }
예제 #3
0
        public ActionResult <InstanceDto> Upgrade([FromHeader(Name = "Authorization")] string token, [FromHeader(Name = "Source")]  string source, [FromHeader(Name = "AssetName")]  string assetname)
        {
            ActionResult <InstanceDto> actionResult = NoContent();

            try
            {
                var githubDownloader = new ReleaseDownloader(source, token);
                var releases         = githubDownloader.GetDataForAllReleases();
                var asset            = releases.FirstOrDefault()?.assets?.FirstOrDefault(at => at.name == assetname);
                if (asset != null)
                {
                    if (githubDownloader.DownloadAsset(asset.id, out byte[] assetbinary))
        private void CheckUpdatesAndContinues()
        {
            HttpClient httpClient               = new HttpClient();
            string     author                   = "ZombieRage";
            string     repo                     = "zRageMapDownloader";
            bool       includePreRelease        = false;
            IReleaseDownloaderSettings settings = new ReleaseDownloaderSettings(httpClient, author, repo, includePreRelease, Utils.APP_PATH);

            // create downloader
            IReleaseDownloader downloader = new ReleaseDownloader(settings);

            // check version
            DispatchIfNecessary(() =>
            {
                txtMessage.Text = "Checking for updates...";
            });

            string currentVersion    = GetVersionKeyInfo();
            bool   installNewVersion = !string.IsNullOrEmpty(currentVersion) ? !downloader.IsLatestRelease(currentVersion) : true;

            if (installNewVersion || !File.Exists(Utils.APP_FILE))
            {
                DispatchIfNecessary(() =>
                {
                    Visibility      = Visibility.Visible;
                    txtMessage.Text = "Downloading lastest version...";
                });

                downloader.DownloadLatestRelease();

                var downloadedVersion = downloader.GetLatestReleaseVersion();
                UpdateVersionKeyInfo(downloadedVersion);
                RegisterCustomUrlScheme();
            }

            if (File.Exists(Utils.APP_FILE))
            {
                DispatchIfNecessary(() =>
                {
                    txtMessage.Text            = "Starting application...";
                    pbProgress.IsIndeterminate = false;
                    pbProgress.Value           = 1;
                });

                ProcessStartInfo psi = new ProcessStartInfo(Utils.APP_FILE);
                Process.Start(psi);
            }
            else
            {
                DispatchIfNecessary(() =>
                {
                    MessageBox.Show("Application not found", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                });
            }

            // clean up
            downloader.DeInit();
            httpClient.Dispose();
            DispatchIfNecessary(() =>
            {
                Application.Current.Shutdown();
            });
        }