本文整理汇总了C#中AdoDataConnection.DataPublisherConnectionString方法的典型用法代码示例。如果您正苦于以下问题:C# AdoDataConnection.DataPublisherConnectionString方法的具体用法?C# AdoDataConnection.DataPublisherConnectionString怎么用?C# AdoDataConnection.DataPublisherConnectionString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdoDataConnection
的用法示例。
在下文中一共展示了AdoDataConnection.DataPublisherConnectionString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubscriberUserControl_Loaded
/// <summary>
/// Handles loaded event for <see cref="SubscriberUserControl"/>.
/// </summary>
/// <param name="sender">Source of the event.</param>
/// <param name="e">Event arguments.</param>
private void SubscriberUserControl_Loaded(object sender, RoutedEventArgs e)
{
// Attach to load/before save event so class can load/add crypto keys from/to local keyIV cache
m_dataContext.PropertyChanged += SubscriberUserControl_PropertyChanged;
m_dataContext.BeforeSave += SubscriberUserControl_BeforeSave;
LoadCurrentKeyIV();
try
{
using (AdoDataConnection database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory))
{
Dictionary<string, string> settings;
string server;
IPAddress[] hostIPs = null;
IEnumerable<IPAddress> localIPs;
settings = database.DataPublisherConnectionString().ToNonNullString().ParseKeyValuePairs();
if (settings.TryGetValue("server", out server))
hostIPs = Dns.GetHostAddresses(server.Split(':')[0]);
localIPs = Dns.GetHostAddresses("localhost").Concat(Dns.GetHostAddresses(Dns.GetHostName()));
// Check to see if entered host name corresponds to a local IP address
if ((object)hostIPs == null)
MessageBox.Show("Failed to find service host address. If using Gateway security, secure key exchange may not succeed." + Environment.NewLine + "Please make sure to run manager application with administrative privileges on the server where service is hosted.", "Authorize Subcriber", MessageBoxButton.OK, MessageBoxImage.Warning);
else if (!hostIPs.Any(ip => localIPs.Contains(ip)))
MessageBox.Show("If using Gateway security, secure key exchange may not succeed." + Environment.NewLine + "Please make sure to run manager application with administrative privileges on the server where service is hosted.", "Authorize Subscriber", MessageBoxButton.OK, MessageBoxImage.Warning);
}
// If the user is not an Administrator, then the following properties for these controls are readonly and not enable
bool isAdmin = CommonFunctions.CurrentPrincipal.IsInRole("Administrator,Editor");
AcronymField.IsReadOnly = !isAdmin;
NameField.IsReadOnly = !isAdmin;
ValidIpAddressesField.IsReadOnly = !isAdmin;
EnablePGConnectionCheckBox.IsEnabled = isAdmin;
ImportSRQButton.IsEnabled = isAdmin;
ImportCERButton.IsEnabled = isAdmin;
FooterControl.IsEnabled = isAdmin;
}
catch
{
MessageBox.Show("Please make sure to run manager application with administrative privileges on the server where service is hosted.", "Authorize Subscriber", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
示例2: InitializeUnsynchronizedSubscription
private void InitializeUnsynchronizedSubscription()
{
try
{
using (AdoDataConnection database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory))
{
m_unsynchronizedSubscriber = new DataSubscriber();
m_unsynchronizedSubscriber.StatusMessage += m_unsynchronizedSubscriber_StatusMessage;
m_unsynchronizedSubscriber.ProcessException += m_unsynchronizedSubscriber_ProcessException;
m_unsynchronizedSubscriber.ConnectionEstablished += m_unsynchronizedSubscriber_ConnectionEstablished;
m_unsynchronizedSubscriber.NewMeasurements += m_unsynchronizedSubscriber_NewMeasurements;
m_unsynchronizedSubscriber.ConnectionTerminated += m_unsynchronizedSubscriber_ConnectionTerminated;
m_unsynchronizedSubscriber.ConnectionString = database.DataPublisherConnectionString();
m_unsynchronizedSubscriber.Initialize();
m_unsynchronizedSubscriber.Start();
}
}
catch (Exception ex)
{
MessageBox.Show("Failed to initialize subscription." + Environment.NewLine + ex.Message, "Failed to Subscribe", MessageBoxButton.OK);
}
}
示例3: GetDataPublisherConnectionString
// Gets the current data publisher connection string
private string GetDataPublisherConnectionString()
{
AdoDataConnection database = null;
try
{
// Create database connection to get the current data publisher connection string
database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory);
return database.DataPublisherConnectionString();
}
finally
{
if ((object)database != null)
database.Dispose();
}
}
示例4: InitializeSubscription
private void InitializeSubscription()
{
try
{
using (AdoDataConnection database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory))
{
m_subscriber = new DataSubscriber();
m_subscriber.StatusMessage += m_subscriber_StatusMessage;
m_subscriber.ProcessException += m_subscriber_ProcessException;
m_subscriber.ConnectionEstablished += m_subscriber_ConnectionEstablished;
m_subscriber.NewMeasurements += m_subscriber_NewMeasurements;
m_subscriber.ConnectionTerminated += m_subscriber_ConnectionTerminated;
m_subscriber.ProcessingComplete += m_subscriber_ProcessingComplete;
m_subscriber.ConnectionString = database.DataPublisherConnectionString();
m_subscriber.Initialize();
m_subscriber.Start();
}
}
catch
{
// TODO: show error in popup window
//Popup("Failed to initialize subscription." + Environment.NewLine + ex.Message, "Failed to Subscribe", MessageBoxImage.Error);
}
}
示例5: Load
private void Load()
{
string companyAcronym;
// Try to populate defaults for subscriber acronym and name using company information from the host application configuration file
if (TryGetCompanyAcronym(out companyAcronym))
{
SubscriberAcronym = companyAcronym;
SubscriberName = string.Format("{0} Subscription Authorization", companyAcronym);
}
// Connect to database to retrieve company information for current node
using (AdoDataConnection database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory))
{
try
{
string query = database.ParameterizedQueryString("SELECT Company.Acronym, Company.Name FROM Company, Node WHERE Company.ID = Node.CompanyID AND Node.ID = {0}", "id");
DataRow row = database.Connection.RetrieveRow(database.AdapterType, query, database.CurrentNodeID());
PublisherAcronym = row.Field<string>("Acronym");
PublisherName = row.Field<string>("Name");
// Generate a default shared secret password for subscriber key and initialization vector
byte[] buffer = new byte[4];
Random.GetBytes(buffer);
string generatedSecret = Convert.ToBase64String(buffer).RemoveCrLfs();
if (generatedSecret.Contains("="))
generatedSecret = generatedSecret.Split('=')[0];
SharedKey = generatedSecret;
// Generate an identity for this subscriber
AesManaged sa = new AesManaged();
sa.GenerateKey();
IdentityCertificate = Convert.ToBase64String(sa.Key);
// Generate valid local IP addresses for this connection
IEnumerable<IPAddress> addresses = Dns.GetHostAddresses(Dns.GetHostName()).OrderBy(key => key.AddressFamily);
ValidIPAddresses = addresses.ToDelimitedString("; ");
}
catch (Exception ex)
{
MessageBox.Show("ERROR: " + ex.Message, "Subscriber Request", MessageBoxButton.OK);
}
try
{
Dictionary<string, string> settings;
string server;
string[] splitServer;
int dataPublisherPort;
//IPAddress[] hostIPs = null;
//IEnumerable<IPAddress> localIPs;
settings = database.DataPublisherConnectionString().ToNonNullString().ParseKeyValuePairs();
//localIPs = Dns.GetHostAddresses("localhost").Concat(Dns.GetHostAddresses(Dns.GetHostName()));
if (settings.TryGetValue("server", out server))
{
splitServer = server.Split(':');
//hostIPs = Dns.GetHostAddresses(splitServer[0]);
if (splitServer.Length > 1 && int.TryParse(splitServer[1], out dataPublisherPort))
InternalDataPublisherPort = dataPublisherPort;
}
// These messages show up when not desired and are not very useful anymore...
//// Check to see if entered host name corresponds to a local IP address
//if (hostIPs == null)
// MessageBox.Show("Failed to find service host address. If using Gateway security, secure key exchange may not succeed." + Environment.NewLine + "Please make sure to run manager application with administrative privileges on the server where service is hosted.", "Subscription Request", MessageBoxButton.OK, MessageBoxImage.Warning);
//else if (!hostIPs.Any(ip => localIPs.Contains(ip)))
// MessageBox.Show("If using Gateway security, secure key exchange may not succeed." + Environment.NewLine + "Please make sure to run manager application with administrative privileges on the server where service is hosted.", "Subscription Request", MessageBoxButton.OK, MessageBoxImage.Warning);
}
catch
{
MessageBox.Show("Please make sure to run manager application with administrative privileges on the server where service is hosted.", "Subscription Request", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
}