Ejemplo n.º 1
0
        private void ListComponentFiles(ComboBox Input, ComboBox Output, ComponentDownloader.ComponentType ServerType)
        {
            ComponentDownloader Comp = new ComponentDownloader();

            // Selected Server/Module files.
            if (ServerType == ComponentDownloader.ComponentType.WebServer)
            {
                Comp = CompWS;
            }
            if (ServerType == ComponentDownloader.ComponentType.PHP)
            {
                Comp = CompPHP;
            }
            if (ServerType == ComponentDownloader.ComponentType.DataBase)
            {
                Comp = CompDB;
            }

            Comp.SelTypes = ServerType;
            int ServerId = 0;

            if (Comp.LoadServerList())
            {
                foreach (DataRow Row in Comp.SvrList.Rows)
                {
                    if (Row["FullName"].ToString().CompareTo(Input.SelectedItem.ToString()) == 0)
                    {
                        ServerId = Convert.ToInt32(Row["Id"]);
                        break;
                    }
                }
            }
            else
            {
                return;
            }

            if (Comp.LoadServerFileList(ServerId))
            {
                Output.Items.Clear();

                if (Comp.SvrURLs.Rows.Count > 0)
                {
                    foreach (DataRow row in Comp.SvrURLs.Rows)
                    {
                        try
                        {
                            Output.Items.Add(Comp.CleanURL(row["URL"].ToString()));
                        }
                        catch (Exception ex)
                        {
                            Globals.Error.Show(ex.Message);
                        }
                    }

                    Output.SelectedIndex = 0;
                }
            }
        }
        private void DownloadAllComponents()
        {
            if (!Directory.Exists(InstallerSettings.DownloadDirectory))
            {
                Directory.CreateDirectory(InstallerSettings.DownloadDirectory);
            }

            Downloader = new ComponentDownloader();
            Downloader.OnDownloadProgressChanged += OnDownloadProgressChanged;

            List <InstallerComponent> components = InstallerComponents.Components;

            for (int i = 0; i < components.Count; i++)
            {
                InstallerComponent component = components[i];

                // if it's disabled,
                // skip it
                if (!component.Enabled)
                {
                    continue;
                }
retry:
                ChangeProgressBarValue(0);
                Log($"Downloading {component.Name}...");

                Downloader.DownloadComponent(ref component, InstallerSettings.DownloadDirectory);

                InstallerComponents.Components[i] = component;

                if (Downloader.Failed)
                {
                    Log($"Downloading {component.Name} Failed");

                    // log Exception aswell, if it exists
                    if (Downloader.Exception != null)
                    {
                        Log(Downloader.Exception.Message);
                        Log(Downloader.Exception.StackTrace);
                    }

                    // ask the user if they want to retry
                    DialogResult ret = MessageBox.Show("Download Failed, Try Again?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (ret == DialogResult.Yes)
                    {
                        // I know, I know, 'goto bad', but if you really hate this,
                        // PR me a rework of this mess which doesn't use goto
                        goto retry;
                    }

                    return;
                }
            }

            Log("Downloading completed");

            LaunchInstallComponents();
        }
        private async Task DownloadAllComponents()
        {
            var downloader = new ComponentDownloader();

            downloader.OnDownloadProgressChanged += OnDownloadProgressChanged;

            var components = InstallerSettings.InstallerComponents.Components;

            for (int i = 0; i < components.Count; i++)
            {
                InstallerComponent component = components[i];

                // make sure component is enabled
                if (!component.Enabled)
                {
                    continue;
                }

                bool useFallback = false;
retry:
                try
                {
                    ChangeProgressBarValue(0);
                    Log($"Downloading {component.Name}...");

                    await downloader.DownloadComponent(i, InstallerSettings.DownloadDirectory, useFallback);
                }
                catch (Exception e)
                {
                    Log($"Downloading {component.Name} Failed");
                    Log(e.Message);
                    Log(e.StackTrace);

                    if (component.FallbackUrls != null &&
                        !useFallback)
                    {
                        Log("Retrying With Fallback...");
                        useFallback = true;
                        goto retry;
                    }

                    // ask the user if they want to retry
                    DialogResult ret = MessageBox.Show("Download Failed, Try Again?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (ret == DialogResult.Yes)
                    {
                        useFallback = false;
                        goto retry;
                    }

                    // early exit
                    return;
                }
            }

            Log("Downloading completed");
            LaunchInstallComponents();
        }
        private void DownloadAllComponents()
        {
            if (!Directory.Exists(InstallerSettings.DownloadDirectory))
            {
                Directory.CreateDirectory(InstallerSettings.DownloadDirectory);
            }

            Downloader = new ComponentDownloader();
            Downloader.OnDownloadProgressChanged += OnDownloadProgressChanged;

            string project64FileName = Path.Combine(InstallerSettings.DownloadDirectory, "Project64.zip");

            // we *sadly* need to do something special for Project64
            Log("Downloading Project64...");
            Downloader.Project64(project64FileName);

            if (Downloader.Failed)
            {
                Log("Downloading Project64 Failed");
                Log(Downloader.Exception.Message);
                Log(Downloader.Exception.StackTrace);
                return;
            }

            foreach (InstallerComponent component in InstallerComponents.Components)
            {
                // if it's disabled,
                // skip it
                if (!component.Enabled)
                {
                    continue;
                }

                ChangeProgressBarValue(0);
                Log($"Downloading {component.Name}...");
                Downloader.DownloadComponent(component, InstallerSettings.DownloadDirectory);

                if (Downloader.Failed)
                {
                    Log($"Downloading {component.Name} Failed");

                    // log Exception aswell, if it exists
                    if (Downloader.Exception != null)
                    {
                        Log(Downloader.Exception.Message);
                        Log(Downloader.Exception.StackTrace);
                    }
                    return;
                }
            }

            Log("Downloading completed");

            LaunchInstallComponents();
        }
Ejemplo n.º 5
0
        private void InstallComponentsWindow(ComponentDownloader.ComponentType type)
        {
            ComponentDownloader ComponentDialog = new ComponentDownloader();

            ComponentDialog.SelTypes = type;

            ComponentDialog.ShowDialog();
            ComponentDialog.Dispose();

            LoadCombos();
        }
Ejemplo n.º 6
0
        private Boolean ServerInstalled(String Target, String Folder)
        {
            ComponentDownloader CD       = new ComponentDownloader();
            List <string>       possible = CD.GetPossibleServers(Folder);

            foreach (string srvr in possible)
            {
                if (Target.CompareTo(srvr) == 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var downloader = new ComponentDownloader("https://github.com/Milkitic/Osu-Player/releases/download/2.0.6994.3181/Osu-Player.zip", "E:\\");

            downloader.RequestCreated   += Downloader_RequestCreated;
            downloader.ResponseReceived += Downloader_ResponseReceived;
            downloader.DownloadStarted  += Downloader_DownloadStarted;
            downloader.ProgressChanged  += Downloader_ProgressChanged;
            downloader.DownloadFinished += Downloader_DownloadFinished;
            downloader.ErrorOccured     += Downloader_ErrorOccured;
            downloader.NamingConflict   += Downloader_NamingConflict;
            downloader.StartAsync().Wait();
            Console.WriteLine("press any key to continue...");
            Console.ReadKey(true);
        }
Ejemplo n.º 8
0
        private void DownloadAllComponents()
        {
            if (!Directory.Exists(InstallerSettings.DownloadDirectory))
            {
                Directory.CreateDirectory(InstallerSettings.DownloadDirectory);
            }

            Downloader = new ComponentDownloader();
            Downloader.OnDownloadProgressChanged += OnDownloadProgressChanged;

            List <InstallerComponent> components = InstallerComponents.Components;

            for (int i = 0; i < components.Count; i++)
            {
                InstallerComponent component = components[i];

                // if it's disabled,
                // skip it
                if (!component.Enabled)
                {
                    continue;
                }

                ChangeProgressBarValue(0);
                Log($"Downloading {component.Name}...");

                Downloader.DownloadComponent(ref component, InstallerSettings.DownloadDirectory);

                InstallerComponents.Components[i] = component;

                if (Downloader.Failed)
                {
                    Log($"Downloading {component.Name} Failed");

                    // log Exception aswell, if it exists
                    if (Downloader.Exception != null)
                    {
                        Log(Downloader.Exception.Message);
                        Log(Downloader.Exception.StackTrace);
                    }
                    return;
                }
            }

            Log("Downloading completed");

            LaunchInstallComponents();
        }