public override void AcquireConnections(object transaction) { DTSValidationStatus validationStatus = this.ValidateConnection(DTSValidationStatus.VS_ISVALID); if (validationStatus == DTSValidationStatus.VS_ISVALID) { IDTSConnectionManager100 connectionManager = this.ComponentMetaData.RuntimeConnectionCollection[0].ConnectionManager; try { this.fileName = (string)connectionManager.AcquireConnection(transaction); } catch (Exception) { this.PostErrorAndThrow(MessageStrings.CannotGetFileNameFromConnection); } if (!System.IO.File.Exists(this.fileName)) { this.PostErrorAndThrow(MessageStrings.FileDoesNotExist(this.fileName)); } } else { throw new COMException(string.Empty, E_FAIL); } }
public override void AcquireConnections(object transaction) { if (ComponentMetaData.RuntimeConnectionCollection.Count > 0) { IDTSRuntimeConnection100 conn = ComponentMetaData.RuntimeConnectionCollection[0]; m_ConnMgr = conn.ConnectionManager; database = (MongoDatabase)m_ConnMgr.AcquireConnection(null); } }
/// <summary> /// Establishes a connection to a connection manager. /// <param name="transaction">The transaction the connection is participating in. (optional)</param> public override void AcquireConnections(object transaction) { if (ComponentMetaData.RuntimeConnectionCollection.Count > 0) { IDTSRuntimeConnection100 conn = ComponentMetaData.RuntimeConnectionCollection[0]; m_ConnMgr = conn.ConnectionManager; if (m_ConnMgr != null) { database = (MongoDatabase)m_ConnMgr.AcquireConnection(null); } } }
public void TestReleaseConnectionsDelegatesToConnectionManager() { PrivateObject p = new PrivateObject(typeof(MongoDataSource.MongoDataSource)); IDTSConnectionManager100 connManager = Mock.Create <IDTSConnectionManager100>(Constructor.Mocked); p.SetField("m_ConnMgr", connManager); MongoDatabase mockedDb = Mock.Create <MongoDatabase>(Constructor.Mocked); p.SetField("database", mockedDb); p.Invoke("ReleaseConnections", null); Mock.Assert(() => connManager.ReleaseConnection(mockedDb)); }
//================================================================================================= public override void ReleaseConnections() { if (m_scope == null) { return; } // get the runtime connection IDTSRuntimeConnection100 conn = ComponentMetaData.RuntimeConnectionCollection[CONNECTION_NAME]; IDTSConnectionManager100 connMgr = conn.ConnectionManager; connMgr.ReleaseConnection(m_scope); m_scope = null; }
public override void AcquireConnections(object transaction) { if (m_scope != null && m_scope.IsConnected) { bool bCancel; ErrorSupport.FireError(HResults.DTS_E_ALREADYCONNECTED, out bCancel); throw new PipelineComponentHResultException(HResults.DTS_E_ALREADYCONNECTED); } IDTSRuntimeConnection100 conn; try { // get the runtime connection conn = ComponentMetaData.RuntimeConnectionCollection[CONNECTION_NAME]; } catch (Exception) { bool bCancel; ErrorSupport.FireErrorWithArgs(HResults.DTS_E_CANNOTTFINDRUNTIMECONNECTIONOBJECT, out bCancel, CONNECTION_NAME); throw new PipelineComponentHResultException(HResults.DTS_E_CANNOTTFINDRUNTIMECONNECTIONOBJECT); } // get the connection manager from the connection IDTSConnectionManager100 conn_mgr = conn.ConnectionManager; if (conn_mgr == null) { bool bCancel; ErrorSupport.FireErrorWithArgs(HResults.DTS_E_CONNECTIONMANANGERNOTASSIGNED, out bCancel, CONNECTION_NAME); throw new PipelineComponentHResultException(HResults.DTS_E_CONNECTIONMANANGERNOTASSIGNED); } m_scope = (conn_mgr.AcquireConnection(transaction)) as ManagementScope; if (m_scope == null) { bool bCancel; ErrorSupport.FireError(HResults.DTS_E_CANNOTACQUIREMANAGEDCONNECTIONFROMCONNECTIONMANAGER, out bCancel); throw new PipelineComponentHResultException(HResults.DTS_E_CANNOTACQUIREMANAGEDCONNECTIONFROMCONNECTIONMANAGER); } }
/// <summary> /// This method is called once, before rows begin to be processed in the data flow. /// /// You can remove this method if you don't need to do anything here. /// </summary> public override void AcquireConnections(object Transaction) { connMgr = this.Connections.Connection; sqlConn = (SqlConnection)connMgr.AcquireConnection(null); }
public override void ReleaseConnections() { m_ConnMgr = null; }
public override void AcquireConnections(object transaction) { IDTSRuntimeConnection100 conn = ComponentMetaData.RuntimeConnectionCollection[0]; m_ConnMgr = conn.ConnectionManager; }
/* To use a variable in this script, first ensure that the variable has been added to * either the list contained in the ReadOnlyVariables property or the list contained in * the ReadWriteVariables property of this script component, according to whether or not your * code needs to write into the variable. To do so, save this script, close this instance of * Visual Studio, and update the ReadOnlyVariables and ReadWriteVariables properties in the * Script Transformation Editor window. * To use a parameter in this script, follow the same steps. Parameters are always read-only. * * Example of reading from a variable or parameter: * DateTime startTime = Variables.MyStartTime; * * Example of writing to a variable: * Variables.myStringVariable = "new value"; */ #endregion #region Help: Using Integration Services Connnection Managers /* Some types of connection managers can be used in this script component. See the help topic * "Working with Connection Managers Programatically" for details. * * To use a connection manager in this script, first ensure that the connection manager has * been added to either the list of connection managers on the Connection Managers page of the * script component editor. To add the connection manager, save this script, close this instance of * Visual Studio, and add the Connection Manager to the list. * * If the component needs to hold a connection open while processing rows, override the * AcquireConnections and ReleaseConnections methods. * * Example of using an ADO.Net connection manager to acquire a SqlConnection: * object rawConnection = Connections.SalesDB.AcquireConnection(transaction); * SqlConnection salesDBConn = (SqlConnection)rawConnection; * * Example of using a File connection manager to acquire a file path: * object rawConnection = Connections.Prices_zip.AcquireConnection(transaction); * string filePath = (string)rawConnection; * * Example of releasing a connection manager: * Connections.SalesDB.ReleaseConnection(rawConnection); */ #endregion #region Help: Firing Integration Services Events /* This script component can fire events. * * Example of firing an error event: * ComponentMetaData.FireError(10, "Process Values", "Bad value", "", 0, out cancel); * * Example of firing an information event: * ComponentMetaData.FireInformation(10, "Process Values", "Processing has started", "", 0, fireAgain); * * Example of firing a warning event: * ComponentMetaData.FireWarning(10, "Process Values", "No rows were received", "", 0); */ #endregion public override void AcquireConnections(object Transaction) { IDTSConnectionManager100 connMgr = this.Connections.Connection; destination = (string)connMgr.AcquireConnection(null); }