当前位置: 首页>>代码示例>>C#>>正文


C# IServerConnection.SetCustomProperty方法代码示例

本文整理汇总了C#中IServerConnection.SetCustomProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IServerConnection.SetCustomProperty方法的具体用法?C# IServerConnection.SetCustomProperty怎么用?C# IServerConnection.SetCustomProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServerConnection的用法示例。


在下文中一共展示了IServerConnection.SetCustomProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnOK_Click

        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)
                {
//.........这里部分代码省略.........
开发者ID:kanbang,项目名称:Colt,代码行数:101,代码来源:LoginDialog.cs


注:本文中的IServerConnection.SetCustomProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。