/// <summary>
 /// Adds the site.
 /// </summary>
 /// <param name="site">The site.</param>
 public void AddSite(PreferedSite site)
 {
     //A generic collection would be nice :/
     PreferedSite[] n = new PreferedSite[m_sites.Length + 1];
     Array.Copy(m_sites, 0, n, 0, m_sites.Length);
     n[n.Length - 1] = site;
     m_sites         = n;
 }
        private void cmbServerUrl_SelectedIndexChanged(object sender, EventArgs e)
        {
            PreferedSite site = cmbServerUrl.SelectedItem as PreferedSite;

            if (site == null)
            {
                return;
            }

            txtStartingpoint.Text = site.StartingPoint;
            txtUsername.Text      = site.Username;
            if (site.SavePassword)
            {
                txtPassword.Text = site.UnscrambledPassword;
            }
            else
            {
                txtPassword.Text = string.Empty;
            }

            CheckSavedPassword(this, EventArgs.Empty);
        }
Beispiel #3
0
 public void AddSites(PreferedSite[] sites)
 {
     cmbServerUrl.Items.AddRange(sites);
 }
Beispiel #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            using (new WaitCursor(this))
            {
                try
                {
                    PreferedSite ps = null;

                    if (_selectedIndex == 0) //HTTP
                    {
                        var builder = new System.Data.Common.DbConnectionStringBuilder();
                        builder["Url"]                  = _http.Server;                                                                       //NOXLATE
                        builder["Username"]             = _http.Username;                                                                     //NOXLATE
                        builder["Password"]             = _http.Password;                                                                     //NOXLATE
                        builder["Locale"]               = _http.Language;                                                                     //NOXLATE
                        builder["AllowUntestedVersion"] = true;                                                                               //NOXLATE

                        string agent = "MapGuide Maestro v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); //NOXLATE

                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.Http", builder.ToString());                              //NOXLATE
                        _conn.SetCustomProperty("UserAgent", agent);                                                                          //NOXLATE

                        //Update preferred site entry if it exists
                        int index = 0;
                        foreach (PreferedSite s in _http.GetSites())
                        {
                            if (s.SiteURL == _http.Server)
                            {
                                ps = s;
                                break;
                            }
                            else
                            {
                                index++;
                            }
                        }

                        if (ps == null)
                        {
                            ps = new PreferedSite();
                        }

                        if (ps.ApprovedVersion == null)
                        {
                            ps.ApprovedVersion = new Version(0, 0, 0, 0);
                        }

                        if (_conn.SiteVersion > _conn.MaxTestedVersion && _conn.SiteVersion > ps.ApprovedVersion)
                        {
                            if (MessageBox.Show(this, Strings.UntestedServerVersion, Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) != DialogResult.Yes)
                            {
                                return;
                            }
                        }

                        try
                        {
                            ps.SiteURL         = _http.Server;
                            ps.StartingPoint   = _http.StartingPoint;
                            ps.Username        = _http.Username;
                            ps.SavePassword    = chkSavePassword.Checked;
                            ps.ApprovedVersion = ps.ApprovedVersion > _conn.SiteVersion ? ps.ApprovedVersion : _conn.SiteVersion;
                            if (ps.SavePassword)
                            {
                                ps.UnscrambledPassword = _http.Password;
                            }
                            else
                            {
                                ps.ScrambledPassword = string.Empty;
                            }

                            if (index >= _siteList.Sites.Length)
                            {
                                _siteList.AddSite(ps);
                            }

                            //_siteList.AutoConnect = chkAutoConnect.Checked;
                            _siteList.PreferedSite = index;
                            var ci = _http.SelectedCulture;
                            if (ci != null)
                            {
                                _siteList.GUILanguage = ci.Name;
                            }
                            _siteList.Save();
                        }
                        catch (Exception)
                        {
                        }
                    }
                    else if (_selectedIndex == 1) //Native
                    {
                        System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();
                        builder["ConfigFile"] = LocalNativeLoginCtrl.LastIniPath;                                         //NOXLATE
                        builder["Username"]   = _localNative.Username;                                                    //NOXLATE
                        builder["Password"]   = _localNative.Password;                                                    //NOXLATE
                        builder["Locale"]     = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName; //NOXLATE
                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative", builder.ToString());   //NOXLATE
                    }
                    else //Local
                    {
                        NameValueCollection param = new NameValueCollection();
                        param["ConfigFile"] = LocalLoginCtrl.LastIniPath;                            //NOXLATE
                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.Local", param); //NOXLATE
                    }

                    _conn.AutoRestartSession = true;

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (TargetInvocationException ex)
                {
                    //We don't care about the outer exception
                    string msg = ex.InnerException.Message;
                    if (msg.IndexOf("MgConnectionFailedException") >= 0)
                    {
                        new ConnectionErrorDialog().ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(this, string.Format(Strings.ConnectionFailedError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                    if (msg.IndexOf("MgConnectionFailedException") >= 0)
                    {
                        new ConnectionErrorDialog().ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(this, string.Format(Strings.ConnectionFailedError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// Adds the site.
 /// </summary>
 /// <param name="site">The site.</param>
 public void AddSite(PreferedSite site)
 {
     //A generic collection would be nice :/
     PreferedSite[] n = new PreferedSite[m_sites.Length + 1];
     Array.Copy(m_sites, 0, n, 0, m_sites.Length);
     n[n.Length-1] = site;
     m_sites = n;
 }
Beispiel #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            using (new WaitCursor(this))
            {
                try
                {
                    PreferedSite ps = null;

                    if (_selectedIndex == 0) //HTTP
                    {
                        var builder = new System.Data.Common.DbConnectionStringBuilder();
                        builder["Url"] = _http.Server; //NOXLATE
                        builder["Username"] = _http.Username; //NOXLATE
                        builder["Password"] = _http.Password; //NOXLATE
                        builder["Locale"] = _http.Language; //NOXLATE
                        builder["AllowUntestedVersion"] = true; //NOXLATE

                        string agent = "MapGuide Maestro v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); //NOXLATE

                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.Http", builder.ToString()); //NOXLATE
                        _conn.SetCustomProperty("UserAgent", agent); //NOXLATE

                        //Update preferred site entry if it exists
                        int index = 0;
                        foreach (PreferedSite s in _http.GetSites())
                        {
                            if (s.SiteURL == _http.Server)
                            {
                                ps = s;
                                break;
                            }
                            else
                                index++;
                        }

                        if (ps == null)
                            ps = new PreferedSite();

                        if (ps.ApprovedVersion == null)
                            ps.ApprovedVersion = new Version(0, 0, 0, 0);

                        if (_conn.SiteVersion > _conn.MaxTestedVersion && _conn.SiteVersion > ps.ApprovedVersion)
                        {
                            if (MessageBox.Show(this, Strings.UntestedServerVersion, Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) != DialogResult.Yes)
                                return;
                        }

                        try
                        {
                            ps.SiteURL = _http.Server;
                            ps.StartingPoint = _http.StartingPoint;
                            ps.Username = _http.Username;
                            ps.SavePassword = chkSavePassword.Checked;
                            ps.ApprovedVersion = ps.ApprovedVersion > _conn.SiteVersion ? ps.ApprovedVersion : _conn.SiteVersion;
                            if (ps.SavePassword)
                                ps.UnscrambledPassword = _http.Password;
                            else
                                ps.ScrambledPassword = string.Empty;

                            if (index >= _siteList.Sites.Length)
                                _siteList.AddSite(ps);

                            //_siteList.AutoConnect = chkAutoConnect.Checked;
                            _siteList.PreferedSite = index;
                            var ci = _http.SelectedCulture;
                            if (ci != null)
                            {
                                _siteList.GUILanguage = ci.Name;
                            }
                            _siteList.Save();
                        }
                        catch (Exception)
                        {

                        }
                    }
                    else if (_selectedIndex == 1) //Native
                    {
                        System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();
                        builder["ConfigFile"] = LocalNativeLoginCtrl.LastIniPath; //NOXLATE
                        builder["Username"] = _localNative.Username; //NOXLATE
                        builder["Password"] = _localNative.Password; //NOXLATE
                        builder["Locale"] = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName; //NOXLATE
                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative", builder.ToString()); //NOXLATE
                    }
                    else //Local
                    {
                        NameValueCollection param = new NameValueCollection();
                        param["ConfigFile"] = LocalLoginCtrl.LastIniPath; //NOXLATE
                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.Local", param); //NOXLATE
                    }

                    _conn.AutoRestartSession = true;

                    this.DialogResult = DialogResult.OK;
                    this.Close();

                }
                catch (TargetInvocationException ex)
                {
                    //We don't care about the outer exception
                    string msg = ex.InnerException.Message;
                    MessageBox.Show(this, string.Format(Strings.ConnectionFailedError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                    MessageBox.Show(this, string.Format(Strings.ConnectionFailedError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }