/// <summary> /// This method will attempt to connect to the third-party. /// </summary> /// <param name="properties"> /// The collection of information required by this Connector to connect to the third-party. /// </param> public void Connect(IDictionary <string, string> properties) { // Use LogMethodExecution to add entry and exit tracing to a method. // When wrapped in a using statement, the exit point // is written during garbage collection. using (new LogMethodExecution(ConnectorTypeName, "Connect")) { try { //parse the incomming properties to ensure the proper parameters are set BuildConnectionString(properties); //attempt a connection to the selected datasource _dataAccess.OleDbConnect(_connectionString); //open the connection for the metadata access to the server _metaDataAccess = new OleDbMetadataAccess(_dataAccess); //open the connection to the metadata provider _metadataProvider = new MetadataProvider(_metaDataAccess); } catch (OleDbException oleDbException) { string msg = ExceptionFormatter.BuildActionableException( "Unable to Connect to datasource", string.Format("The following error occured in the {0}:", Globals.ConnectorName), oleDbException); //be sure to log any errors that occure while attempting to connect Logger.Write(Logger.Severity.Error, Globals.ConnectorName, msg); //throw the InvalidConnectionException found in the ConnectorApi throw new InvalidConnectionException(msg); } catch (InvalidOperationException invalidOperationException) { string msg = ExceptionFormatter.BuildActionableException( "Unable to connect to datasource the provider information is invalid.", string.Format("The following error occured in the {0}:", Globals.ConnectorName), invalidOperationException); //be sure to log an error that is due to an invalid provider Logger.Write(Logger.Severity.Error, Globals.ConnectorName, msg); //throw the InvalidConnectionException found in the ConnectorApi throw new InvalidConnectionException(msg); } } }
/// <summary> /// This method will attempt to connect to the third-party. /// </summary> /// <param name="properties"> /// The collection of information required by this Connector to connect to the third-party. /// </param> public void Connect(IDictionary<string, string> properties) { // Use LogMethodExecution to add entry and exit tracing to a method. // When wrapped in a using statement, the exit point // is written during garbage collection. using (new LogMethodExecution(ConnectorTypeName, "Connect")) { try { //parse the incomming properties to ensure the proper parameters are set BuildConnectionString(properties); //attempt a connection to the selected datasource _dataAccess.OleDbConnect(_connectionString); //open the connection for the metadata access to the server _metaDataAccess = new OleDbMetadataAccess(_dataAccess); //open the connection to the metadata provider _metadataProvider = new MetadataProvider(_metaDataAccess); } catch (OleDbException oleDbException) { string msg = ExceptionFormatter.BuildActionableException( "Unable to Connect to datasource", string.Format("The following error occured in the {0}:", Globals.ConnectorName), oleDbException); //be sure to log any errors that occure while attempting to connect Logger.Write(Logger.Severity.Error, Globals.ConnectorName, msg); //throw the InvalidConnectionException found in the ConnectorApi throw new InvalidConnectionException(msg); } catch (InvalidOperationException invalidOperationException) { string msg = ExceptionFormatter.BuildActionableException( "Unable to connect to datasource the provider information is invalid.", string.Format("The following error occured in the {0}:", Globals.ConnectorName), invalidOperationException); //be sure to log an error that is due to an invalid provider Logger.Write(Logger.Severity.Error, Globals.ConnectorName, msg); //throw the InvalidConnectionException found in the ConnectorApi throw new InvalidConnectionException(msg); } } }