Exemple #1
0
        private void btnTestProxy_Click(object sender, EventArgs e)
        {
            using (new AutoCursor(this)) {
                frmUpdater  fu  = (frmUpdater)this.Owner;
                GuiExtended gui = null;
                var         url = string.Empty;
                try {
                    gui = fu.GetGui();
                    if (gui == null)
                    {
                        MessageBox.Show(this,
                                        getDisplayMember("TestProxy{invalidurl_body}", "A valid URL could not be determined, or Updater is configured to use a local file resource.  Please check the value specified in \"Download from Server:\" on the main form."),
                                        getDisplayMember("TestProxy{invalidurl_title}", "Invalid URL"));
                        return;
                    }
                    gui.WebRequestCreatedCallback = delegate(HttpWebRequest req) {
                        Utility.InitProxySettings(req, chkHttpProxy.Checked, chkUseDefaultProxy.Checked, txtProxyServerName.Text, Utility.ToInt32(txtProxyPort.Text, 0), chkProxyBypassOnLocal.Checked, chkUseDefaultProxyCredentials.Checked, txtProxyUsername.Text, txtProxyPassword.Text, txtProxyDomain.Text, !chkProxySuppress417Errors.Checked);
                    };

                    url = gui.Url;
                    var version = gui.GetVersion();
                    MessageBox.Show(this,
                                    getDisplayMember("TestProxy{success_body}", "Successfully connected to {0} at \n {1}", version, gui.Url),
                                    getDisplayMember("TestProxy{success_title}", "Success - HTTP Proxy Configuration"));
                } catch (Exception ex) {
                    MessageBox.Show(this,
                                    getDisplayMember("TestProxy{failed_body}", "Failed to reach the GRIN-Global web service at \n{0}\n\nError: {1}", url, ex.Message),
                                    getDisplayMember("TestProxy{failed_title}", "Failed - HTTP Proxy Configuration"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #2
0
        private void btnDownloadInstallerCD_Click(object sender, EventArgs e)
        {
            frmUpdater fu = (frmUpdater)this.Owner;


            var groupName     = "GRIN-Global Full CD";
            var componentType = "Full CD";
            var description   = "Looking for GRIN-Global Full CD...";

            if (rdoGGOnly.Checked)
            {
                groupName     = "GRIN-Global CD";
                componentType = "CD";
                description   = "Looking for GRIN-Global CD...";
            }
            else if (rdoPrerequisites.Checked)
            {
                groupName     = "GRIN-Global Prerequisites";
                componentType = "Prerequisites";
                description   = "Looking for GRIN-Global Prerequisites CD...";
            }

            List <FileDownloadInfo> files = null;
            var sd = new SortedDictionary <string, List <FileDownloadInfo> >();

            using (new AutoCursor(this)) {
                files = fu.GetLatestFileInfo(groupName, componentType, description, true, null);
                sd.Add("CD", files);
            }

            if (files.Count > 0)
            {
                new frmProgress().ShowDialog(this, componentType, sd, false, chkIsMirrorServer.Checked, true, null, false, false, false);
            }
            else
            {
                var url = Utility.GetRegSetting("LastURL", "");
                if (Utility.IsWindowsFilePath(url))
                {
                    MessageBox.Show(getDisplayMember("DownloadCD{local}",
                                                     "You are currently pointing at a local file path.\nNavigate to the following folder in Windows Explorer to see the contents of the GRIN-Global CD:\n\n{0}", Path.GetDirectoryName(url)));
                }
                else
                {
                    var uri = new Uri(url);
                    MessageBox.Show(getDisplayMember("DownloadCD{filenotfound}", "The {0} cab file could not be found on the server.\nPlease inform the administrator of {1}.", groupName, uri.Host));
                }
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // valid command line:
            // [/conn [last|url_to_connect_to]] [/download group file [file] [file] [file]] [/refresh]


            string connectToUrl = null;
            string group        = null;
            bool   refresh      = false;
            var    files        = new List <string>();
            int    i            = 0;

            while (i < args.Length)
            {
                switch (args[i].ToLower())
                {
                case "rem":
                case "#":
                case ";":
                    // skip all the rest
                    i = args.Length;
                    break;

                case "/conn":
                case "-conn":
                case "--conn":
                case "/connection":
                case "-connection":
                case "--connection":
                case "/c":
                case "-c":
                case "--c":
                    if (i < args.Length - 1)
                    {
                        connectToUrl = args[i + 1];
                        i++;
                    }
                    break;

                case "/download":
                case "-download":
                case "--download":
                case "/d":
                case "-d":
                case "--d":
                    if (i < args.Length - 1)
                    {
                        i++;
                        group = args[i];

                        while (i < args.Length - 1)
                        {
                            i++;
                            files.Add(args[i]);
                        }
                    }
                    break;

                case "/refresh":
                case "-refresh":
                case "--refresh":
                case "/r":
                case "-r":
                case "--r":
                    refresh = true;
                    break;
                }
                i++;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var f = new frmUpdater();

            if (!String.IsNullOrEmpty(connectToUrl))
            {
                f.AutoDownloadUrl = Utility.IsWindowsFilePath(connectToUrl) ? Utility.ResolveFilePath(connectToUrl, false) : connectToUrl;
            }
            f.AutoDownloadGroup = group;
            f.AutoDownloadFiles = files;
            f.RefreshGroups     = refresh;

            if (f.IsAutoDownloading())
            {
                // allow multiple instance of updater to run if it is just auto-downloading...
                //MessageBox.Show("Attempting to download following files in Group='" + f.AutoDownloadGroup + "' from URL='" + f.AutoDownloadUrl + "': " + String.Join(", ", f.AutoDownloadFiles.ToArray()));
                f.StartPosition = FormStartPosition.CenterScreen;
                f.ShowInTaskbar = true;
                Application.Run(f);
            }
            else
            {
                // only allow a single instance of updater to run if it is not auto-downloading...
                if (__mutex.WaitOne(TimeSpan.Zero, true))
                {
                    try {
                        Application.Run(f);
                    } finally {
                        if (__mutex != null)
                        {
                            __mutex.ReleaseMutex();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(getDisplayMember("Main", "Only one instance of GRIN-Global Updater can be run at a time."));
                }
            }
        }