本文整理汇总了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)
{
//.........这里部分代码省略.........