Ejemplo n.º 1
0
        public override void AcquireConnections(object transaction)
        {
            bool pbCancel = false;

            if (ComponentMetaData.RuntimeConnectionCollection["File To Write"].ConnectionManager != null)
            {
                ConnectionManager cm = Microsoft.SqlServer.Dts.Runtime.DtsConvert.GetWrapper(ComponentMetaData.RuntimeConnectionCollection["File To Write"].ConnectionManager);
                if (cm.CreationName != "FILE")
                {
                    ComponentMetaData.FireError(0, "Acquire Connections", "The Connection Manager is not a FILE Connection Manager", "", 0, out pbCancel);
                    throw new Exception("The Connection Manager is not a FILE Connection Manager");
                }
                else
                {
                    _fil = (Microsoft.SqlServer.Dts.Runtime.DTSFileConnectionUsageType)cm.Properties["FileUsageType"].GetValue(cm);
                    if (_fil != Microsoft.SqlServer.Dts.Runtime.DTSFileConnectionUsageType.CreateFile)
                    {
                        ComponentMetaData.FireError(0, "Acquire Connections", "The type of FILE connection manager must be an Existing File", "", 0, out pbCancel);
                        throw new Exception("The type of FILE connection manager must be Create File");
                    }
                    else
                    {
                        _filename = ReturnConnectionObject(ComponentMetaData.RuntimeConnectionCollection, "File To Write", transaction);
                        if (_filename == null || _filename.Length == 0)
                        {
                            ComponentMetaData.FireError(0, "Acquire Connections", "Nothing returned when grabbing the filename", "", 0, out pbCancel);
                            throw new Exception("Nothing returned when grabbing the filename");
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void AcquireConnections(object transaction)
        {
            if (ComponentMetaData.RuntimeConnectionCollection["File To Read"].ConnectionManager != null)
            {
                ConnectionManager cm = Microsoft.SqlServer.Dts.Runtime.DtsConvert.GetWrapper(ComponentMetaData.RuntimeConnectionCollection["File To Read"].ConnectionManager);
                if (cm.CreationName != "FILE")
                {
                    throw new Exception("The Connection Manager is not a FILE Connection Manager");
                }
                else
                {

                    _fil = (Microsoft.SqlServer.Dts.Runtime.DTSFileConnectionUsageType)cm.Properties["FileUsageType"].GetValue(cm);
                    if (_fil != Microsoft.SqlServer.Dts.Runtime.DTSFileConnectionUsageType.FileExists)
                    {
                        throw new Exception("The type of FILE connection manager must be an Existing File");
                    }
                    else
                    {
                        _filename = ComponentMetaData.RuntimeConnectionCollection["File To Read"].ConnectionManager.AcquireConnection(transaction).ToString();
                        if (_filename == null || _filename.Length == 0)
                        {
                            throw new Exception("Nothing returned when grabbing the filename");
                        }
                    }
                }
            }
        }