本文整理匯總了C#中AdoDataConnection.ServiceConnectionString方法的典型用法代碼示例。如果您正苦於以下問題:C# AdoDataConnection.ServiceConnectionString方法的具體用法?C# AdoDataConnection.ServiceConnectionString怎麽用?C# AdoDataConnection.ServiceConnectionString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AdoDataConnection
的用法示例。
在下文中一共展示了AdoDataConnection.ServiceConnectionString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ConnectWindowsServiceClient
/// <summary>
/// Connects to backend windows service.
/// </summary>
public static void ConnectWindowsServiceClient(bool overwrite = false)
{
TlsClient remotingClient;
ISecurityProvider provider;
UserData userData;
if (overwrite)
{
DisconnectWindowsServiceClient();
ServiceConnectionRefreshed(null, EventArgs.Empty);
}
else if (s_windowsServiceClient == null || s_windowsServiceClient.Helper.RemotingClient.CurrentState != ClientState.Connected)
{
if (s_windowsServiceClient != null)
DisconnectWindowsServiceClient();
AdoDataConnection database = new AdoDataConnection(DefaultSettingsCategory);
try
{
string connectionString = database.ServiceConnectionString(true);
if (!string.IsNullOrWhiteSpace(connectionString))
{
s_windowsServiceClient = new WindowsServiceClient(connectionString);
if (SecurityProviderCache.TryGetCachedProvider(CurrentPrincipal.Identity.Name, out provider))
{
userData = provider.UserData;
if ((object)userData != null)
{
s_windowsServiceClient.Helper.Username = userData.LoginID;
s_windowsServiceClient.Helper.Password = SecurityProviderUtility.EncryptPassword(provider.Password);
remotingClient = s_windowsServiceClient.Helper.RemotingClient as TlsClient;
if ((object)remotingClient != null && (object)provider.SecurePassword != null && provider.SecurePassword.Length > 0)
remotingClient.NetworkCredential = new NetworkCredential(userData.LoginID, provider.SecurePassword);
}
}
s_windowsServiceClient.Helper.RemotingClient.MaxConnectionAttempts = -1;
s_windowsServiceClient.Helper.RemotingClient.ConnectionEstablished += RemotingClient_ConnectionEstablished;
s_windowsServiceClient.Helper.RemotingClient.ConnectionException += RemotingClient_ConnectionException;
ConnectAsync();
}
}
finally
{
database.Dispose();
}
}
}