/// <summary> /// Creates a new Microsoft SQL Server ADO Store Manager /// </summary> /// <param name="server">Server</param> /// <param name="db">Database</param> /// <param name="user">Username</param> /// <param name="password">Password</param> /// <param name="encrypt">Whether to encrypt the connection</param> /// <param name="mode">Access Mode</param> public MicrosoftAdoManager(String server, String db, String user, String password, bool encrypt, AdoAccessMode mode) : base(CreateConnectionParameters(server, db, user, password, encrypt), mode) { this._connString = CreateConnectionString(server, db, user, password, encrypt); this._server = server; this._db = db; this._user = user; this._password = password; this._encrypt = encrypt; }
/// <summary> /// Creates a new Azure ADO Manager instance /// </summary> /// <param name="server">Server Name (this is the alphanumeric server name issues by the Azure platform which precedes <em>.database.windows.net</em> in the Server hostname)</param> /// <param name="db">Database</param> /// <param name="username">Username (will automatically have the @server appended to it)</param> /// <param name="password">Password</param> /// <param name="mode">Access Mode</param> /// <remarks> /// SQL Azure connections are always encrypted /// </remarks> public AzureAdoManager(String server, String db, String username, String password, AdoAccessMode mode) : base(server + AzureServerSuffix, db, username + "@" + server, password, true, mode) { this._azureServer = server; this._azureUser = username; }
/// <summary> /// Creates a new Microsoft SQL Server ADO Store Manager /// </summary> /// <param name="db">Database</param> /// <param name="encrypt">Whether to encrypt the connection</param> /// <param name="mode">Access Mode</param> /// <remarks> /// Will use <strong>localhost</strong> as the server and will assume a Trusted Connection (i.e. Windows authentication) since no username and password are specified /// </remarks> public MicrosoftAdoManager(String db, bool encrypt, AdoAccessMode mode) : this(DefaultServer, db, encrypt, mode) { }
/// <summary> /// Creates a new Microsoft SQL Server ADO Store Manager /// </summary> /// <param name="db">Database</param> /// <param name="mode">Access Mode</param> /// <remarks> /// Will use <strong>localhost</strong> as the server and will assume a Trusted Connection (i.e. Windows authentication) since no username and password are specified /// </remarks> public MicrosoftAdoManager(String db, AdoAccessMode mode) : this(db, false, mode) { }
/// <summary> /// Creates a new Microsoft SQL Server ADO Store Manager /// </summary> /// <param name="db">Database</param> /// <param name="user">Username</param> /// <param name="password">Password</param> /// <param name="mode">Access Mode</param> /// <remarks> /// Will use <strong>localhost</strong> as the server /// </remarks> public MicrosoftAdoManager(String db, String user, String password, AdoAccessMode mode) : this(db, user, password, false, mode) { }
/// <summary> /// Creates a new Microsoft SQL Server ADO Store Manager /// </summary> /// <param name="server">Server</param> /// <param name="db">Database</param> /// <param name="encrypt">Whether to encrypt the connection</param> /// <param name="mode">Access Mode</param> /// <remarks> /// Will assume a Trusted Connection (i.e. Windows authentication) since no username and password are specified /// </remarks> public MicrosoftAdoManager(String server, String db, bool encrypt, AdoAccessMode mode) : this(server, db, null, null, encrypt, mode) { }
/// <summary> /// Creates a new Microsoft SQL Server ADO Store Manager /// </summary> /// <param name="db">Database</param> /// <param name="user">Username</param> /// <param name="password">Password</param> /// <param name="encrypt">Whether to encrypt the connection</param> /// <param name="mode">Access Mode</param> /// <remarks> /// Will use <strong>localhost</strong> as the server /// </remarks> public MicrosoftAdoManager(String db, String user, String password, bool encrypt, AdoAccessMode mode) : this(DefaultServer, db, user, password, encrypt, mode) { }
/// <summary> /// Attempts to load an Object of the given type identified by the given Node and returned as the Type that this loader generates /// </summary> /// <param name="g">Configuration Graph</param> /// <param name="objNode">Object Node</param> /// <param name="targetType">Target Type</param> /// <param name="obj">Created Object</param> /// <returns>True if the loader succeeded in creating an Object</returns> public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj) { obj = null; INode managerNode; Object temp; //Create the URI Nodes we're going to use to search for things INode propServer = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServer), propDb = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDatabase); switch (targetType.FullName) { case MicrosoftAdoDataset: managerNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyGenericManager)); if (managerNode != null) { temp = ConfigurationLoader.LoadObject(g, managerNode); if (temp is MicrosoftAdoManager) { obj = new MicrosoftAdoDataset((MicrosoftAdoManager)temp); } else { throw new DotNetRdfConfigurationException("Unable to load the object identified by the Node '" + objNode.ToString() + "' since the object pointed to by the dnr:genericManager property could not be loaded as an instance of the required MicrosoftAdoManager class"); } } else { throw new DotNetRdfConfigurationException("Unable to load the object identified by the Node '" + objNode.ToString() + "' as it specified a dnr:type of MicrosoftAdoDataset but failed to specify a dnr:genericManager property to point to a MicrosoftAdoManager"); } break; case AzureAdoManager: case MicrosoftAdoManager: //Get Server and Database details String server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { server = "localhost"; } String db = ConfigurationLoader.GetConfigurationString(g, objNode, propDb); if (db == null) { return(false); } //Get user credentials String user, pwd; ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd); bool encrypt = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyEncryptConnection), false); String mode = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyLoadMode)); AdoAccessMode accessMode = (mode != null ? (AdoAccessMode)Enum.Parse(typeof(AdoAccessMode), mode) : AdoAccessMode.Streaming); //Create the Manager if (user != null && pwd != null) { if (targetType.FullName.Equals(MicrosoftAdoManager)) { obj = new MicrosoftAdoManager(server, db, user, pwd, encrypt, accessMode); } else { obj = new AzureAdoManager(server, db, user, pwd, accessMode); } } else { if (targetType.FullName.Equals(AzureAdoManager)) { throw new DotNetRdfConfigurationException("Unable to load the object identified by the Node '" + objNode.ToString() + "' as an AzureAdoManager as the required dnr:user and dnr:password properties were missing"); } obj = new MicrosoftAdoManager(server, db, encrypt, accessMode); } break; case MicrosoftAdoOptimiser: managerNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyGenericManager)); if (managerNode != null) { temp = ConfigurationLoader.LoadObject(g, managerNode); if (temp is MicrosoftAdoManager) { obj = new MicrosoftAdoOptimiser((MicrosoftAdoManager)temp); } else { throw new DotNetRdfConfigurationException("Unable to load the object identified by the Node '" + objNode.ToString() + "' since the object pointed to by the dnr:genericManager property could not be loaded as a MicrosoftAdoManager instance"); } } else { throw new DotNetRdfConfigurationException("Unable to load the object identified by the Node '" + objNode.ToString() + "' as it specified a dnr:type of AdoOptimiser but failed to specify a dnr:genericManager property to point to a MicrosoftAdoManager instance"); } break; } return(obj != null); }