public void TestOutputColumn_Timecode_Missing()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 speechToText = dataFlowTask.ComponentMetaDataCollection.New();

            speechToText.ComponentClassID = typeof(Martin.SQLServer.Dts.SSISSpeechToText).AssemblyQualifiedName;
            CManagedComponentWrapper speechToTextInstance = speechToText.Instantiate();

            speechToTextInstance.ProvideComponentProperties();
            speechToText.CustomPropertyCollection[Utility.SubscriptionKeyPropName].Value = "NotTheDefault";
            // Before this is default setup for a clean component

            speechToText.OutputCollection[0].OutputColumnCollection.RemoveObjectByID(speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputTimecodeColumnName].ID);
            IDTSOutputColumn100 tempCol = speechToText.OutputCollection[0].OutputColumnCollection.New();

            tempCol.Name = "TempCol";
            tempCol.SetDataTypeProperties(DataType.DT_STR, 10, 0, 0, 1252);
            DTSValidationStatus actual   = speechToTextInstance.Validate();
            DTSValidationStatus expected = DTSValidationStatus.VS_ISCORRUPT;

            Assert.AreEqual(expected, actual);
            Assert.AreEqual("[Error] SSIS Speech To Text: Required Output Column Timecode is missing.", events.errorMessages[0]);
        }
        public void TestValidateOK()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 speechToText = dataFlowTask.ComponentMetaDataCollection.New();

            speechToText.ComponentClassID = typeof(Martin.SQLServer.Dts.SSISSpeechToText).AssemblyQualifiedName;
            CManagedComponentWrapper speechToTextInstance = speechToText.Instantiate();

            speechToTextInstance.ProvideComponentProperties();

            speechToText.CustomPropertyCollection[Utility.SubscriptionKeyPropName].Value = "NotTheDefault";

            DTSValidationStatus actual   = speechToTextInstance.Validate();
            DTSValidationStatus expected = DTSValidationStatus.VS_ISVALID;

            Assert.AreEqual(expected, actual);
            Assert.AreEqual(0, events.errorMessages.Count, "There are error messages");
        }
示例#3
0
        public void TestSetOutputColumnDefaults()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();
            ComponentEventHandler    events           = new ComponentEventHandler();

            dataFlowTask.Events               = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);
            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();
            IDTSOutput100       output = textFileSplitter.OutputCollection.New();
            IDTSOutputColumn100 actual = output.OutputColumnCollection.New();

            ManageColumns.SetOutputColumnDefaults(actual, 1252);

            Assert.AreEqual(DataType.DT_STR, actual.DataType, "DataType is wrong");
            Assert.AreEqual(255, actual.Length, "Length is wrong");
            Assert.AreEqual(DTSRowDisposition.RD_NotUsed, actual.ErrorRowDisposition, "Row Disposition is wrong");
            Assert.AreEqual(DTSRowDisposition.RD_NotUsed, actual.TruncationRowDisposition, "Truncate Disposition is wrong");
        }
示例#4
0
        public FileSystemTask(
            Packages.VulcanPackage vulcanPackage, 
            string name, 
            string taskDescription, 
            DTS.IDTSSequence parentContainer,
            string sourceConnection, 
            string destConnection,  
            Microsoft.SqlServer.Dts.Tasks.FileSystemTask.DTSFileSystemOperation operation
            )
            : base(vulcanPackage,
            name,
            taskDescription,
            parentContainer)
        {
            Connection source = new Connection(vulcanPackage, sourceConnection, sourceConnection, "FILE",String.Format("\"{0}\"",ExpressionPathBuilder.EscapeBackslashes(sourceConnection)));
            Connection dest = new Connection(vulcanPackage, destConnection, destConnection, "FILE",String.Format("\"{0}\"",ExpressionPathBuilder.EscapeBackslashes(destConnection)));

            source.SetProperty("FileUsageType", 2);
            dest.SetProperty("FileUsageType", 2);
            fileSystemTask = (DTS.TaskHost)parentContainer.Executables.Add("STOCK:FileSystemTask");
            fileSystemTask.Name = name;
            this.Task.Operation = operation;
            this.Task.Source = source.ConnectionManager.ID;
            this.Task.Destination = dest.ConnectionManager.ID;
        }
        public void TestOutputColumn_InvalidCustomProperty()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 speechToText = dataFlowTask.ComponentMetaDataCollection.New();

            speechToText.ComponentClassID = typeof(Martin.SQLServer.Dts.SSISSpeechToText).AssemblyQualifiedName;
            CManagedComponentWrapper speechToTextInstance = speechToText.Instantiate();

            speechToTextInstance.ProvideComponentProperties();
            speechToText.CustomPropertyCollection[Utility.SubscriptionKeyPropName].Value = "NotTheDefault";
            // Before this is default setup for a clean component

            IDTSCustomProperty100 cp = speechToText.OutputCollection[0].OutputColumnCollection[0].CustomPropertyCollection.New();

            cp.Name  = "IAmInvalid";
            cp.Value = "IAmInvalid";
            DTSValidationStatus actual   = speechToTextInstance.Validate();
            DTSValidationStatus expected = DTSValidationStatus.VS_ISCORRUPT;

            Assert.AreEqual(expected, actual);
            Assert.AreEqual("[Error] SSIS Speech To Text: Output Column InputChannel has invalid property IAmInvalid.", events.errorMessages[0]);
        }
示例#6
0
        public void TestAddNumberOfRowsOutputColumns()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();
            ComponentEventHandler    events           = new ComponentEventHandler();

            dataFlowTask.Events               = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);
            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();
            IDTSOutput100 actual = textFileSplitter.OutputCollection.New();

            ManageColumns.AddNumberOfRowsOutputColumns(actual);

            Assert.AreEqual(3, actual.OutputColumnCollection.Count, "Number of Columns is wrong");
            Assert.AreEqual(MessageStrings.KeyValueColumnName, actual.OutputColumnCollection[0].Name, "Column Name is wrong");
            Assert.AreEqual(DataType.DT_STR, actual.OutputColumnCollection[0].DataType, "DataType is wrong");
            Assert.AreEqual(255, actual.OutputColumnCollection[0].Length, "Length is wrong");
            Assert.AreEqual(MessageStrings.KeyValueColumnDescription, actual.OutputColumnCollection[0].Description, "Description is wrong");
            Assert.AreEqual(MessageStrings.NumberOfRowsColumnName, actual.OutputColumnCollection[1].Name, "Column Name is wrong");
            Assert.AreEqual(DataType.DT_I8, actual.OutputColumnCollection[1].DataType, "DataType is wrong");
            Assert.AreEqual(0, actual.OutputColumnCollection[1].Length, "Length is wrong");
            Assert.AreEqual(MessageStrings.NumberOfRowsColumnDescription, actual.OutputColumnCollection[1].Description, "Description is wrong");
            Assert.AreEqual(MessageStrings.KeyValueStatusColumnName, actual.OutputColumnCollection[2].Name, "Column Name is wrong");
            Assert.AreEqual(DataType.DT_STR, actual.OutputColumnCollection[2].DataType, "DataType is wrong");
            Assert.AreEqual(255, actual.OutputColumnCollection[2].Length, "Length is wrong");
            Assert.AreEqual(MessageStrings.KeyValueStatusColumnDescription, actual.OutputColumnCollection[2].Description, "Description is wrong");
        }
示例#7
0
 protected override void AddComponent(ISequence sequence, string executableID)
 {
     base.AddComponent(sequence, executableID);
     TaskHost             = Executable as SSIS.TaskHost; //alternativ: sequence.Executables[0] as SSIS.TaskHost;
     TaskHost.Name        = Name;
     TaskHost.Description = Description;
 }
        public void TestValidateExtraCustomProperty()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 speechToText = dataFlowTask.ComponentMetaDataCollection.New();

            speechToText.ComponentClassID = typeof(Martin.SQLServer.Dts.SSISSpeechToText).AssemblyQualifiedName;
            CManagedComponentWrapper speechToTextInstance = speechToText.Instantiate();

            speechToTextInstance.ProvideComponentProperties();

            speechToText.CustomPropertyCollection.New();

            DTSValidationStatus actual   = speechToTextInstance.Validate();
            DTSValidationStatus expected = DTSValidationStatus.VS_ISCORRUPT;

            Assert.AreEqual(expected, actual);
            Assert.AreEqual("[Error] SSIS Speech To Text: There is either to many or not enough custom properties.", events.errorMessages[0]);
        }
        public void TestChangeRowsProcessedOutputTypeToData()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();

            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();

            Boolean exceptionThrown = false;

            try
            {
                instance.SetOutputProperty(textFileSplitter.OutputCollection[3].ID, ManageProperties.typeOfOutput, Utilities.typeOfOutputEnum.DataRecords);
            }
            catch (COMException ex)
            {
                Assert.AreEqual(MessageStrings.CantChangeOutputProperties("RowsProcessed"), ex.Message, "Exception Message Wrong");
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown, "Exception Not Thrown");
        }
示例#10
0
        public FileSystemTask(
            Packages.VulcanPackage vulcanPackage,
            string name,
            string taskDescription,
            DTS.IDTSSequence parentContainer,
            string sourceConnection,
            string destConnection,
            Microsoft.SqlServer.Dts.Tasks.FileSystemTask.DTSFileSystemOperation operation
            )
            :
            base(
                vulcanPackage,
                name,
                taskDescription,
                parentContainer
                )
        {
            Connection source = new Connection(vulcanPackage, sourceConnection, sourceConnection, "FILE", String.Format("\"{0}\"", ExpressionPathBuilder.EscapeBackslashes(sourceConnection)));
            Connection dest   = new Connection(vulcanPackage, destConnection, destConnection, "FILE", String.Format("\"{0}\"", ExpressionPathBuilder.EscapeBackslashes(destConnection)));

            source.SetProperty("FileUsageType", 2);
            dest.SetProperty("FileUsageType", 2);
            fileSystemTask        = (DTS.TaskHost)parentContainer.Executables.Add("STOCK:FileSystemTask");
            fileSystemTask.Name   = name;
            this.Task.Operation   = operation;
            this.Task.Source      = source.ConnectionManager.ID;
            this.Task.Destination = dest.ConnectionManager.ID;
        }
示例#11
0
        public void TestExecuteRecogniseAsyncBasic()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 speechToText = dataFlowTask.ComponentMetaDataCollection.New();

            speechToText.ComponentClassID = typeof(Martin.SQLServer.Dts.SSISSpeechToText).AssemblyQualifiedName;
            CManagedComponentWrapper speechToTextInstance = speechToText.Instantiate();

            speechToTextInstance.ProvideComponentProperties();
            speechToText.CustomPropertyCollection[Utility.SubscriptionKeyPropName].Value = config.AppSettings.Settings["subscriptionKey"].Value;

            Uri targetURI = new Uri(@"wss://speech.platform.bing.com/api/service/recognition/continuous");
            SpeechToTextImplement testMe = new SpeechToTextImplement(speechToText, "en-us", targetURI, config.AppSettings.Settings["subscriptionKey"].Value);
            string filename = "Ex_Pro_1.mp3";

            testMe.ExecuteRecogniseAsync(filename).Wait();
            Assert.IsTrue(testMe.Results.Count > 0);
        }
示例#12
0
 public HDFSTaskUIForm(Microsoft.SqlServer.Dts.Runtime.TaskHost taskHost, Microsoft.SqlServer.Dts.Runtime.Connections connections, IServiceProvider serviceProvider)
     : this()
 {
     this.taskHost          = taskHost;
     this.connections       = connections;
     this.serviceProvider   = serviceProvider;
     this.connectionService = serviceProvider.GetService(typeof(IDtsConnectionService)) as IDtsConnectionService;
 }
示例#13
0
 public HDFSTaskUIForm(Microsoft.SqlServer.Dts.Runtime.TaskHost taskHost, Microsoft.SqlServer.Dts.Runtime.Connections connections, IServiceProvider serviceProvider)
     : this()
 {
     this.taskHost = taskHost;
       this.connections = connections;
       this.serviceProvider = serviceProvider;
       this.connectionService = serviceProvider.GetService(typeof(IDtsConnectionService)) as IDtsConnectionService;
 }
示例#14
0
        public override void Initialize(Microsoft.SqlServer.Dts.Runtime.TaskHost taskHost, IServiceProvider serviceProvider)
        {
            base.Initialize(taskHost, serviceProvider);

            _signalVariables = new List <string>();

            foreach (Variable v in TaskHost.Variables)
            {
                if (v.DataType == TypeCode.Boolean && v.Namespace == "User")
                {
                    _signalVariables.Add(v.QualifiedName);
                }
            }
        }
示例#15
0
 public ExecutePackageTask(
     Packages.VulcanPackage vulcanPackage, 
     string name, 
     string taskDescription, 
     DTS.IDTSSequence parentContainer,
     Connection packageConnection
     )
     : base(vulcanPackage,
     name,
     taskDescription,
     parentContainer)
 {
     executePackageTaskHost = (DTS.TaskHost)parentContainer.Executables.Add("STOCK:ExecutePackageTask");
     executePackageTaskHost.Name = name;
     Task.Connection = packageConnection.ConnectionManager.ID;
 }
示例#16
0
        public void TestIDTSOutputCreator()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();
            ComponentEventHandler    events           = new ComponentEventHandler();

            dataFlowTask.Events               = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);
            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();

            IDTSOutput100 output = textFileSplitter.OutputCollection.New();

            output.Name = "New # Output";
            output.ErrorRowDisposition = DTSRowDisposition.RD_NotUsed;

            ManageProperties.AddOutputProperties(output.CustomPropertyCollection);

            ManageColumns.AddNumberOfRowsOutputColumns(output);

            ManageProperties propertyManager = new ManageProperties();

            propertyManager.PostErrorEvent += new PostErrorDelegate(this.PostError);
            errorMessages = new List <string>();

            SSISOutput actual = new SSISOutput(output, null);

            Assert.IsNotNull(actual, "SSISOutput is null");
            Assert.IsNotNull(actual.CustomPropertyCollection, "Custom Property Collection is null");
            Assert.IsNotNull(actual.OutputColumnCollection, "Column Collection is null");
            Assert.AreEqual(3, actual.CustomPropertyCollection.Count, "Custom Property Collection Count is Wrong");
            Assert.AreEqual(3, actual.OutputColumnCollection.Count, "Output Column Collection Count is Wrong");
            Assert.IsNotNull(ManageProperties.GetPropertyValue(actual.CustomPropertyCollection, ManageProperties.typeOfOutput));
            Assert.IsNotNull(ManageProperties.GetPropertyValue(actual.CustomPropertyCollection, ManageProperties.rowTypeValue));
            Assert.IsNotNull(ManageProperties.GetPropertyValue(actual.CustomPropertyCollection, ManageProperties.masterRecordID));
            Assert.AreEqual("_NewOutput", actual.Name, "Name is incorrect");
            Assert.AreEqual(DTSRowDisposition.RD_NotUsed, actual.ErrorRowDisposition, "Error Row Disposition is incorrect");
        }
示例#17
0
        public frmEditProperties(TaskHost taskHost, Connections connections)
        {
            InitializeComponent();

            _taskHost    = taskHost;
            _connections = connections;
            _variables   = taskHost.Variables;

            if (taskHost == null)
            {
                throw new ArgumentNullException("taskHost");
            }

            FillConnectionInfoPanel();
            FillDetailsPanel();
            FillRecordSetElements();
            GetAssemblyVersion();
        }
示例#18
0
文件: SQLTask.cs 项目: japj/vulcan
        public SQLTask(Packages.VulcanPackage package, string name, string description, DTS.IDTSSequence parentContainer, Connection destinationConnection, Dictionary<string,object> propertiesDictionary)
            : base(package,
            name,
            description,
            parentContainer)
        {
            this._expressionBuilder = new Vulcan.Common.Helpers.ExpressionPathBuilder(package);

            _sqlTask = (DTS.TaskHost)parentContainer.Executables.Add("STOCK:SQLTask");
            _sqlTask.Name = name;
            _sqlTask.Description = description;

            SetProperties(propertiesDictionary);
            if (destinationConnection != null)
            {
                SetProperty("Connection", destinationConnection.ConnectionManager.Name);
            }
        }
示例#19
0
 public ExecutePackageTask(
     Packages.VulcanPackage vulcanPackage,
     string name,
     string taskDescription,
     DTS.IDTSSequence parentContainer,
     Connection packageConnection
     )
     :
     base(
         vulcanPackage,
         name,
         taskDescription,
         parentContainer
         )
 {
     executePackageTaskHost      = (DTS.TaskHost)parentContainer.Executables.Add("STOCK:ExecutePackageTask");
     executePackageTaskHost.Name = name;
     Task.Connection             = packageConnection.ConnectionManager.ID;
 }
示例#20
0
        public SSISEmitterContext Emit()
        {
            MessageEngine.Global.Trace(Severity.Notification, Resources.EmittingETL, _logicalETL.Name);

            _dataFlowTask = (DTS.TaskHost)Context.SSISSequence.AppendExecutable("STOCK:PipelineTask");
            _dataFlowTask.Properties["DelayValidation"].SetValue(_dataFlowTask, _logicalETL.DelayValidation);
            _dataFlowTask.Properties["IsolationLevel"].SetValue(_dataFlowTask, _logicalETL.IsolationLevel);

            _dataFlowTask.Name = _logicalETL.Name;
            
            this.NewDataFlow();

            SSISEmitterContext dataFlowContext = _context.AddDataFlow(this);

            foreach (Transformation t in _logicalETL.Transformations)
            {
                dataFlowContext.InstantiateEmitter(t, dataFlowContext).Emit();
            }
            return _context;
        }
示例#21
0
        public SSISEmitterContext Emit()
        {
            MessageEngine.Global.Trace(Severity.Notification, Resources.EmittingETL, _logicalETL.Name);

            _dataFlowTask = (DTS.TaskHost)Context.SSISSequence.AppendExecutable("STOCK:PipelineTask");
            _dataFlowTask.Properties["DelayValidation"].SetValue(_dataFlowTask, _logicalETL.DelayValidation);
            _dataFlowTask.Properties["IsolationLevel"].SetValue(_dataFlowTask, _logicalETL.IsolationLevel);

            _dataFlowTask.Name = _logicalETL.Name;

            this.NewDataFlow();

            SSISEmitterContext dataFlowContext = _context.AddDataFlow(this);

            foreach (Transformation t in _logicalETL.Transformations)
            {
                dataFlowContext.InstantiateEmitter(t, dataFlowContext).Emit();
            }
            return(_context);
        }
示例#22
0
文件: SQLTask.cs 项目: mosamy/vulcan
        public SQLTask(Packages.VulcanPackage package, string name, string description, DTS.IDTSSequence parentContainer, Connection destinationConnection, Dictionary <string, object> propertiesDictionary)
            :
            base(
                package,
                name,
                description,
                parentContainer
                )
        {
            this._expressionBuilder = new Vulcan.Common.Helpers.ExpressionPathBuilder(package);

            _sqlTask             = (DTS.TaskHost)parentContainer.Executables.Add("STOCK:SQLTask");
            _sqlTask.Name        = name;
            _sqlTask.Description = description;

            SetProperties(propertiesDictionary);
            if (destinationConnection != null)
            {
                SetProperty("Connection", destinationConnection.ConnectionManager.Name);
            }
        }
示例#23
0
        public SsisSqlTask(SqlTask obj, SSISEmitterContext context) : base(obj, context)
        {
            _logicalExecuteSQL = obj;
            _sqlTask = (DTS.TaskHost)Context.SSISSequence.AppendExecutable("STOCK:SQLTask");

            if (!string.IsNullOrEmpty(_logicalExecuteSQL.Name))
            {
                _name = _logicalExecuteSQL.Name;
            }

            _sqlTask.Name = Name + Guid.NewGuid().ToString();
            _sqlTask.Description = Description;

            SetProperty("Connection", _logicalExecuteSQL.Connection);
            SetProperty("IsolationLevel", _logicalExecuteSQL.IsolationLevel);

            switch (_logicalExecuteSQL.Type.ToUpper(System.Globalization.CultureInfo.InvariantCulture))
            {
                case "EXPRESSION": SSISTask.SqlStatementSourceType = DTSTasks.ExecuteSQLTask.SqlStatementSourceType.DirectInput; break;
                default: //case "FILE":
                    SSISTask.SqlStatementSourceType = DTSTasks.ExecuteSQLTask.SqlStatementSourceType.FileConnection; break;
            }
        }
示例#24
0
        public void TestChangeErrorOutputSetColumnProperty()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();

            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();

            IDTSOutput100 errorOutput = textFileSplitter.OutputCollection[1];

            ManageProperties.AddMissingOutputColumnProperties(errorOutput.OutputColumnCollection[0].CustomPropertyCollection);

            Boolean exceptionThrown = false;

            try
            {
                instance.SetOutputColumnProperty(errorOutput.ID, errorOutput.OutputColumnCollection[0].ID, ManageProperties.dotNetFormatString, String.Empty);
            }
            catch (COMException ex)
            {
                Assert.AreEqual(MessageStrings.CantChangeOutputProperties("Error"), ex.Message, "Exception Message Wrong");
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown, "Exception Not Thrown");
        }
示例#25
0
        public SsisSqlTask(SqlTask obj, SSISEmitterContext context) : base(obj, context)
        {
            _logicalExecuteSQL = obj;
            _sqlTask           = (DTS.TaskHost)Context.SSISSequence.AppendExecutable("STOCK:SQLTask");

            if (!string.IsNullOrEmpty(_logicalExecuteSQL.Name))
            {
                _name = _logicalExecuteSQL.Name;
            }

            _sqlTask.Name        = Name + Guid.NewGuid().ToString();
            _sqlTask.Description = Description;

            SetProperty("Connection", _logicalExecuteSQL.Connection);
            SetProperty("IsolationLevel", _logicalExecuteSQL.IsolationLevel);

            switch (_logicalExecuteSQL.Type.ToUpper(System.Globalization.CultureInfo.InvariantCulture))
            {
            case "EXPRESSION": SSISTask.SqlStatementSourceType = DTSTasks.ExecuteSQLTask.SqlStatementSourceType.DirectInput; break;

            default:     //case "FILE":
                SSISTask.SqlStatementSourceType = DTSTasks.ExecuteSQLTask.SqlStatementSourceType.FileConnection; break;
            }
        }
示例#26
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            // Reloads invalidate the ParentContainer, so we should do it much later.
            string etlName =
                patternNavigator.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;

            Message.Trace(Severity.Notification, "{0}", etlName);
            bool delayValidation = patternNavigator.SelectSingleNode("@DelayValidation").ValueAsBoolean;

            string sourceName = patternNavigator.SelectSingleNode("rc:SourceConnection/@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;

            Connection sourceConnection =
                Connection.GetExistingConnection(
                    VulcanPackage,
                    patternNavigator.SelectSingleNode("rc:SourceConnection/@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value
                    );

            if (sourceConnection != null)
            {
                string query = patternNavigator.SelectSingleNode("rc:Query", VulcanPackage.VulcanConfig.NamespaceManager).Value.Trim();

                // Add the Data Flow Task to the Package.
                DTS.TaskHost pipeHost = (DTS.TaskHost)ParentContainer.Executables.Add("STOCK:PipelineTask");
                pipeHost.Properties["DelayValidation"].SetValue(pipeHost, delayValidation);
                MainPipe dataFlowTask = (MainPipe)pipeHost.InnerObject;
                pipeHost.Name = etlName;

                // Add the Source (this is temporary and will be replaced with a new style of Source element)
                IDTSComponentMetaData90 sourceDataComponent = dataFlowTask.ComponentMetaDataCollection.New();
                sourceDataComponent.ComponentClassID = "DTSAdapter.OleDbSource.1";

                // IMPORTANT! If you do not Instantiate() and ProvideComponentProperties first,
                // the component names do not get set... this is bad.
                CManagedComponentWrapper oleInstance = sourceDataComponent.Instantiate();
                oleInstance.ProvideComponentProperties();

                sourceDataComponent.Name = etlName + " Source";

                if (sourceDataComponent.RuntimeConnectionCollection.Count > 0)
                {
                    sourceDataComponent.RuntimeConnectionCollection[0].ConnectionManager =
                        DTS.DtsConvert.ToConnectionManager90(
                            sourceConnection.ConnectionManager
                            );
                    sourceDataComponent.RuntimeConnectionCollection[0].ConnectionManagerID =
                        sourceConnection.ConnectionManager.ID;
                }

                oleInstance.SetComponentProperty("AccessMode", 2);
                oleInstance.SetComponentProperty("SqlCommand", query);

                try
                {
                    oleInstance.AcquireConnections(null);
                    oleInstance.ReinitializeMetaData();
                    oleInstance.ReleaseConnections();
                }
                catch (System.Runtime.InteropServices.COMException ce)
                {
                    Message.Trace(Severity.Error, ce, "OLEDBSource:{0}: {1}: Source {2}: Query {3}", sourceDataComponent.GetErrorDescription(ce.ErrorCode), ce.Message, sourceConnection.ConnectionManager.Name, query);
                }
                catch (Exception e)
                {
                    Message.Trace(Severity.Error, e, "OLEDBSource:{0}: Source {1}: Query {2}", e.Message, sourceConnection.ConnectionManager.Name, query);
                }

                //Map parameter variables:

                StringBuilder parameterBuilder = new StringBuilder();
                foreach (XPathNavigator paramNav in patternNavigator.Select("rc:Parameter", VulcanPackage.VulcanConfig.NamespaceManager))
                {
                    string name    = paramNav.SelectSingleNode("@Name").Value;
                    string varName = paramNav.SelectSingleNode("@VariableName").Value;

                    if (VulcanPackage.DTSPackage.Variables.Contains(varName))
                    {
                        DTS.Variable variable = VulcanPackage.DTSPackage.Variables[varName];
                        parameterBuilder.AppendFormat("\"{0}\",{1};", name, variable.ID);
                    }
                    else
                    {
                        Message.Trace(Severity.Error, "DTS Variable {0} does not exist", varName);
                    }
                }

                oleInstance.SetComponentProperty("ParameterMapping", parameterBuilder.ToString());

                ///Transformation Factory
                IDTSComponentMetaData90 parentComponent = sourceDataComponent;
                XPathNavigator          transNav        = patternNavigator.SelectSingleNode("rc:Transformations", VulcanPackage.VulcanConfig.NamespaceManager);
                if (transNav != null)
                {
                    foreach (XPathNavigator nav in transNav.SelectChildren(XPathNodeType.Element))
                    {
                        // this is naughty but can be fixed later :)
                        Transformation t = TransformationFactory.ProcessTransformation(VulcanPackage, parentComponent, dataFlowTask, nav);
                        if (t != null)
                        {
                            parentComponent = t.Component;
                        }
                    }
                }

                XPathNavigator destNav = patternNavigator.SelectSingleNode("rc:Destination", VulcanPackage.VulcanConfig.NamespaceManager);
                if (destNav != null)
                {
                    string           name             = destNav.SelectSingleNode("@Name").Value;
                    Connection       destConnection   = Connection.GetExistingConnection(VulcanPackage, destNav.SelectSingleNode("@ConnectionName").Value);
                    string           tableName        = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", destNav.SelectSingleNode("@Table").Value.Trim());
                    OLEDBDestination oledbDestination = new OLEDBDestination(VulcanPackage, dataFlowTask, parentComponent, name, name, destConnection, tableName);

                    string accessMode       = destNav.SelectSingleNode("@AccessMode").Value;
                    bool   tableLock        = destNav.SelectSingleNode("@TableLock").ValueAsBoolean;
                    bool   checkConstraints = destNav.SelectSingleNode("@CheckConstraints").ValueAsBoolean;
                    bool   keepIdentity     = destNav.SelectSingleNode("@KeepIdentity").ValueAsBoolean;
                    bool   keepNulls        = destNav.SelectSingleNode("@KeepNulls").ValueAsBoolean;

                    int rowsPerBatch        = destNav.SelectSingleNode("@RowsPerBatch").ValueAsInt;
                    int maxInsertCommitSize = destNav.SelectSingleNode("@MaximumInsertCommitSize").ValueAsInt;

                    switch (accessMode.ToUpperInvariant())
                    {
                    case "TABLE":
                        oledbDestination.ComponentInstance.SetComponentProperty("AccessMode", 0);
                        oledbDestination.ComponentInstance.SetComponentProperty("OpenRowset", tableName);
                        break;

                    case "TABLEFASTLOAD":
                        oledbDestination.ComponentInstance.SetComponentProperty("AccessMode", 3);
                        oledbDestination.ComponentInstance.SetComponentProperty("OpenRowset", tableName);

                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadKeepIdentity", keepIdentity);
                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadKeepNulls", keepNulls);
                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadMaxInsertCommitSize", maxInsertCommitSize);

                        StringBuilder fastLoadOptions = new StringBuilder();
                        if (tableLock)
                        {
                            fastLoadOptions.AppendFormat("TABLOCK,");
                        }
                        if (checkConstraints)
                        {
                            fastLoadOptions.AppendFormat("CHECK_CONSTRAINTS,");
                        }
                        if (rowsPerBatch > 0)
                        {
                            fastLoadOptions.AppendFormat("ROWS_PER_BATCH = {0}", rowsPerBatch);
                        }
                        fastLoadOptions = fastLoadOptions.Replace(",", "", fastLoadOptions.Length - 5, 5);

                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadOptions", fastLoadOptions.ToString());
                        break;

                    default:
                        Message.Trace(Severity.Error, "Unknown Destination Load Type of {0}", accessMode);
                        break;
                    }

                    try
                    {
                        oledbDestination.InitializeAndMapDestination();
                    }
                    catch (Exception)
                    {
                    }

                    // Map any overrides
                    foreach (XPathNavigator nav in destNav.Select("rc:Map", VulcanPackage.VulcanConfig.NamespaceManager))
                    {
                        string source = nav.SelectSingleNode("@Source").Value;
                        string destination;
                        bool   unMap = false;

                        if (nav.SelectSingleNode("@Destination") == null)
                        {
                            unMap       = true;
                            destination = source;
                        }
                        else
                        {
                            destination = nav.SelectSingleNode("@Destination").Value;
                        }

                        oledbDestination.Map(source, destination, unMap);
                    }
                } // end DestNav != null
                this.FirstExecutableGeneratedByPattern = pipeHost;
                this.LastExecutableGeneratedByPattern  = pipeHost;
            } //END sourceConnection != null
            else
            {
                Message.Trace(Severity.Error, "Source Connection {0} does not exist in {1}", sourceName, etlName);
            }
        } //END function Emit
示例#27
0
 public SsisExecutePackage(ExecutePackageTask execPackage, SSISEmitterContext context)
     : base(execPackage, context)
 {
     _execPackageTaskHost = (DTS.TaskHost)Context.SSISSequence.AppendExecutable("STOCK:ExecutePackageTask");
     Initialize(execPackage);
 }
示例#28
0
文件: FTPTask.cs 项目: mosamy/vulcan
        public FTPTask(
            Packages.VulcanPackage vulcanPackage,
            string name,
            string taskDescription,
            DTS.IDTSSequence parentContainer,
            string serverName,
            string port,
            string userName,
            string password,
            string remotePath,
            bool isRemotePathVariable,
            string localPath,
            bool isLocalPathVariable,
            Microsoft.SqlServer.Dts.Tasks.FtpTask.DTSFTPOp operation
            )
            :
            base(
                vulcanPackage,
                name,
                taskDescription,
                parentContainer
                )
        {
            fTPTask             = (DTS.TaskHost)parentContainer.Executables.Add("STOCK:FTPTask");
            fTPTask.Name        = name;
            fTPTask.Description = taskDescription;
            this.Task.Operation = operation;

            this.Task.IsRemotePathVariable = isRemotePathVariable;
            this.Task.IsLocalPathVariable  = isLocalPathVariable;

            Connection fTPServerConnection = new Connection(vulcanPackage, serverName, serverName, "FTP", String.Format("\"{0}:{1}\"", serverName, port));

            fTPServerConnection.SetProperty("ServerUserName", userName);
            fTPServerConnection.SetProperty("ServerPassword", password);
            this.Task.Connection = fTPServerConnection.ConnectionManager.ID;

            if (this.Task.IsRemotePathVariable == true)
            {
                this.Task.RemotePath = remotePath;
            }
            else
            {
                this.Task.RemotePath = remotePath;
            }

            if (this.Task.IsLocalPathVariable == true)
            {
                this.Task.LocalPath = localPath;
            }
            else
            {
                Connection localConnection  = new Connection(vulcanPackage, localPath, localPath, "File", String.Format("\"{0}\"", ExpressionPathBuilder.EscapeBackslashes(localPath)));
                int        intFileUsageType = 2;
                switch (operation)
                {
                case Microsoft.SqlServer.Dts.Tasks.FtpTask.DTSFTPOp.Send:
                    intFileUsageType = 0;
                    break;

                case Microsoft.SqlServer.Dts.Tasks.FtpTask.DTSFTPOp.Receive:
                    intFileUsageType = 2;
                    break;

                default:
                    intFileUsageType = 2;
                    break;
                }
                localConnection.SetProperty("FileUsageType", intFileUsageType);

                this.Task.LocalPath = localPath;
            }
        }
示例#29
0
 public SsisExecutePackage(ExecutePackageTask execPackage, SSISEmitterContext context)
     : base(execPackage, context)
 {
     _execPackageTaskHost = (DTS.TaskHost)Context.SSISSequence.AppendExecutable("STOCK:ExecutePackageTask");
     Initialize(execPackage);
 }
示例#30
0
 public void Initialize(Microsoft.SqlServer.Dts.Runtime.TaskHost taskHost, IServiceProvider serviceProvider)
 {
     this.TaskHost        = taskHost;
     this.ServiceProvider = serviceProvider;
 }
        public frmEditProperties(TaskHost taskHost, Connections connections)
        {
            InitializeComponent();

            grdParameters.DataError += grdParameters_DataError;

            _taskHost = taskHost;

            try
            {
                Cursor = Cursors.WaitCursor;

                cmbServices.Items.Clear();
                cmbMethods.Items.Clear();
                grdParameters.Rows.Clear();

                //Get URL's Service
                cmbURL.Items.AddRange(LoadVariables("System.String").ToArray());
                if (_taskHost.Properties[Keys.SERVICE_URL].GetValue(_taskHost) != null)
                {
                    if (!string.IsNullOrEmpty(_taskHost.Properties[Keys.SERVICE_URL].GetValue(_taskHost).ToString()))
                    {
                        cmbURL.SelectedIndexChanged      -= cmbURL_SelectedIndexChanged;
                        cmbServices.SelectedIndexChanged -= cmbServices_SelectedIndexChanged;
                        cmbMethods.SelectedIndexChanged  -= cmbMethods_SelectedIndexChanged;

                        cmbURL.Text = _taskHost.Properties[Keys.SERVICE_URL].GetValue(_taskHost).ToString();

                        ReloadFromService();

                        if (_taskHost.Properties[Keys.SERVICE_CONTRACT].GetValue(_taskHost) != null)
                        {
                            if (!string.IsNullOrEmpty(_taskHost.Properties[Keys.SERVICE_CONTRACT].GetValue(_taskHost).ToString()))
                            {
                                cmbServices.SelectedIndex = FindStringInComboBox(cmbServices, _taskHost.Properties[Keys.SERVICE_CONTRACT].GetValue(_taskHost).ToString(), -1);

                                //Get Operation Contracts by Service Contract
                                foreach (var method in ((WebServiceMethods)(((ComboBoxObjectComboItem)(cmbServices.SelectedItem)).ValueMemeber)))
                                {
                                    cmbMethods.Items.Add(new ComboBoxObjectComboItem(method.WebServiceMethodParameters, method.Name));
                                }

                                cmbMethods.SelectedIndex = FindStringInComboBox(cmbMethods, _taskHost.Properties[Keys.OPERATION_CONTRACT].GetValue(_taskHost).ToString(), -1);

                                if (_taskHost.Properties[Keys.RETURNED_VALUE].GetValue(_taskHost) != null)
                                {
                                    if (!string.IsNullOrEmpty(_taskHost.Properties[Keys.RETURNED_VALUE].GetValue(_taskHost).ToString()))
                                    {
                                        foreach (var service in _dynamicProxyFactory.AvailableServices.Where(service => service.Key == cmbServices.Text))
                                        {
                                            foreach (var webServiceMethods in service.Value)
                                            {
                                                if (webServiceMethods.Name != cmbMethods.Text)
                                                {
                                                    continue;
                                                }

                                                string selectedText = string.Empty;

                                                cmbReturnVariable.Items.Clear();

                                                cmbReturnVariable.Items.AddRange(LoadVariables(webServiceMethods.ResultType, ref selectedText).Items.Cast <string>().ToList().Where(s => s.StartsWith("@[User")).ToArray());
                                                cmbReturnVariable.SelectedIndex = FindStringInComboBox(cmbReturnVariable, _taskHost.Properties[Keys.RETURNED_VALUE].GetValue(_taskHost).ToString(), -1);

                                                switch (webServiceMethods.ResultType)
                                                {
                                                case "System.Void":
                                                    lbOutputValue.Visible = cmbReturnVariable.Visible = false;
                                                    _withReturnValue      = Keys.FALSE;
                                                    break;

                                                default:
                                                    lbOutputValue.Visible = cmbReturnVariable.Visible = true;
                                                    _withReturnValue      = Keys.TRUE;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    cmbReturnVariable.Items.AddRange(LoadAllUserVariables().ToArray());
                                }

                                FillGridWithParams(_taskHost.Properties[Keys.MAPPING_PARAMS].GetValue(_taskHost) as MappingParams);
                                FillGridWithHeaders(_taskHost.Properties[Keys.MAPPING_HEADERS].GetValue(_taskHost) as MappingHeaders);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            finally
            {
                cmbURL.SelectedIndexChanged      += cmbURL_SelectedIndexChanged;
                cmbServices.SelectedIndexChanged += cmbServices_SelectedIndexChanged;
                cmbMethods.SelectedIndexChanged  += cmbMethods_SelectedIndexChanged;
                Cursor = Cursors.Arrow;
            }
        }
示例#32
0
        public frmEditProperties(TaskHost taskHost, Connections connections)
        {
            InitializeComponent();

            _connections = connections;

            //grdParameters.DataError += grdParameters_DataError(object sender, );

            _taskHost    = taskHost;
            _isFirstLoad = true;

            try
            {
                Cursor = Cursors.WaitCursor;

                optFileVariable.CheckedChanged         -= (optFileVariable_CheckedChanged_1);
                optFileVariable.Click                  -= (optFileVariable_Click);
                optFileConnection.CheckedChanged       -= (optFileConnection_CheckedChanged_1);
                cmdFileVariable.Click                  -= (cmdFileVariable_Click);
                optFileFormatVariable.CheckedChanged   -= (optFileFormatVariable_CheckedChanged_1);
                optFileFormatVariable.Click            -= (optFileFormatVariable_CheckedChanged);
                optFileFormatConnection.CheckedChanged -= (optFileFormatConnection_CheckedChanged_1);
                optFileFormatConnection.ChangeUICues   -= (optFileFormatConnection_CheckedChanged);

                LoadDbConnections();

                if (_taskHost.Properties[Keys.SQL_SERVER].GetValue(_taskHost) != null)
                {
                    cmbSQLServer.SelectedIndex = FindStringInComboBox(cmbSQLServer, _taskHost.Properties[Keys.SQL_SERVER].GetValue(_taskHost).ToString(), -1);

                    if (!string.IsNullOrEmpty(cmbSQLServer.Text))
                    {
                        LoadDataBaseObjects();
                    }
                }

                if (_taskHost.Properties[Keys.NETWORK_PACKET_SIZE].GetValue(_taskHost) != null)
                {
                    txPacketSize.Text = _taskHost.Properties[Keys.NETWORK_PACKET_SIZE].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.USE_REGIONAL_SETTINGS].GetValue(_taskHost) != null)
                {
                    bool isCheckedRegionalSettings;
                    Boolean.TryParse(_taskHost.Properties[Keys.USE_REGIONAL_SETTINGS].GetValue(_taskHost).ToString(),
                                     out isCheckedRegionalSettings);
                    chkRegionalSettings.Checked = isCheckedRegionalSettings;
                }

                if (_taskHost.Properties[Keys.NATIVE_DB_DATATYPE].GetValue(_taskHost) != null)
                {
                    bool isNativeDBType;
                    Boolean.TryParse(_taskHost.Properties[Keys.NATIVE_DB_DATATYPE].GetValue(_taskHost).ToString(),
                                     out isNativeDBType);
                    chkNativeDatabase.Checked = isNativeDBType;
                }

                if (_taskHost.Properties[Keys.FIRSTROW].GetValue(_taskHost) != null)
                {
                    txFirstRow.Text = _taskHost.Properties[Keys.FIRSTROW].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.LASTROW].GetValue(_taskHost) != null)
                {
                    txLastRow.Text = _taskHost.Properties[Keys.LASTROW].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.FIELD_TERMINATOR].GetValue(_taskHost) != null)
                {
                    txFieldTerminator.Text = _taskHost.Properties[Keys.FIELD_TERMINATOR].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.ROW_TERMINATOR].GetValue(_taskHost) != null)
                {
                    txRowTerminator.Text = _taskHost.Properties[Keys.ROW_TERMINATOR].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.SQL_STATEMENT].GetValue(_taskHost) != null)
                {
                    txSQL.Text = _taskHost.Properties[Keys.SQL_STATEMENT].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.DESTINATION_FILE_CONNECTION].GetValue(_taskHost) != null)
                {
                    if (_taskHost.Properties[Keys.DESTINATION_FILE_CONNECTION].GetValue(_taskHost).ToString() == Keys.TRUE)
                    {
                        optFileConnection.Checked = true;
                        cmdFileVariable.Enabled   = false;
                        LoadFileConnectionsDestination();
                    }
                    else
                    {
                        cmdFileVariable.Enabled = true;
                        optFileVariable.Checked = true;
                        LoadFileVariablesDestination();
                    }
                }
                else
                {
                    optFileConnection.Checked = true;
                    cmdFileVariable.Enabled   = false;
                    LoadFileConnectionsDestination();
                }

                if (_taskHost.Properties[Keys.FORMAT_FILE_CONNECTION].GetValue(_taskHost) != null)
                {
                    if (_taskHost.Properties[Keys.FORMAT_FILE_CONNECTION].GetValue(_taskHost).ToString() == Keys.TRUE)
                    {
                        optFileFormatConnection.Checked = true;
                        cmdFileFormatVariable.Enabled   = false;
                        LoadFileConnectionsFileFormat();
                    }
                    else
                    {
                        optFileFormatVariable.Checked = true;
                        cmdFileFormatVariable.Enabled = true;
                        LoadFileVariablesFileFormat();
                    }
                }
                else
                {
                    optFileFormatConnection.Checked = true;
                    cmdFileFormatVariable.Enabled   = false;
                    LoadFileConnectionsFileFormat();
                }

                cmbLogin.Items.Clear();
                cmbPassword.Items.Clear();
                cmbLogin.Items.AddRange(LoadVariables("System.String").ToArray());
                cmbPassword.Items.AddRange(LoadVariables("System.String").ToArray());

                if (_taskHost.Properties[Keys.TRUSTED_CONNECTION].GetValue(_taskHost) != null)
                {
                    bool isCheckedTrustedConnection;
                    Boolean.TryParse(_taskHost.Properties[Keys.TRUSTED_CONNECTION].GetValue(_taskHost).ToString(), out isCheckedTrustedConnection);
                    chkTrustedConnection.Checked = isCheckedTrustedConnection;
                    label10.Enabled = label11.Enabled = cmbPassword.Enabled = cmbLogin.Enabled = !chkTrustedConnection.Checked;
                }
                else
                {
                    chkTrustedConnection.Checked = true;
                }

                label10.Enabled = label11.Enabled = cmbLogin.Enabled = cmbPassword.Enabled = !chkTrustedConnection.Checked;

                if (_taskHost.Properties[Keys.SET_QUOTED_IDENTIFIERS_ON].GetValue(_taskHost) != null)
                {
                    bool isSET_QUOTED_IDENTIFIERS_ON;
                    Boolean.TryParse(_taskHost.Properties[Keys.SET_QUOTED_IDENTIFIERS_ON].GetValue(_taskHost).ToString(), out isSET_QUOTED_IDENTIFIERS_ON);
                    chkQuotes.Checked = isSET_QUOTED_IDENTIFIERS_ON;
                }

                if (_taskHost.Properties[Keys.UNICODE_CHR].GetValue(_taskHost) != null)
                {
                    bool isUnicode;
                    Boolean.TryParse(_taskHost.Properties[Keys.UNICODE_CHR].GetValue(_taskHost).ToString(), out isUnicode);
                    chkUnicode.Checked = isUnicode;
                }

                if (_taskHost.Properties[Keys.CHARACTER_DATA_TYPE].GetValue(_taskHost) != null)
                {
                    bool isChrDataType;
                    Boolean.TryParse(_taskHost.Properties[Keys.CHARACTER_DATA_TYPE].GetValue(_taskHost).ToString(), out isChrDataType);
                    chkChDataType.Checked = isChrDataType;
                }

                if (_taskHost.Properties[Keys.SQL_STATEMENT].GetValue(_taskHost) != null)
                {
                    txSQL.Text = _taskHost.Properties[Keys.SQL_STATEMENT].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.MAX_ERRORS].GetValue(_taskHost) != null)
                {
                    txMaxErrors.Text = _taskHost.Properties[Keys.MAX_ERRORS].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.SQL_VIEW].GetValue(_taskHost) != null)
                {
                    cmbViews.SelectedIndex = FindStringInComboBox(cmbViews, _taskHost.Properties[Keys.SQL_VIEW].GetValue(_taskHost).ToString(), -1);
                }

                if (_taskHost.Properties[Keys.SQL_StoredProcedure].GetValue(_taskHost) != null)
                {
                    cmbStoredProcedures.SelectedIndex = FindStringInComboBox(cmbStoredProcedures, _taskHost.Properties[Keys.SQL_StoredProcedure].GetValue(_taskHost).ToString(), -1);
                }

                if (_taskHost.Properties[Keys.SQL_TABLE].GetValue(_taskHost) != null)
                {
                    cmbTables.SelectedIndex = FindStringInComboBox(cmbTables, _taskHost.Properties[Keys.SQL_TABLE].GetValue(_taskHost).ToString(), -1);
                }

                if (_taskHost.Properties[Keys.DESTINATION].GetValue(_taskHost) != null)
                {
                    cmbDestination.SelectedIndex = FindStringInComboBox(cmbDestination, _taskHost.Properties[Keys.DESTINATION].GetValue(_taskHost).ToString(), -1);
                }

                if (_taskHost.Properties[Keys.FORMAT_FILE].GetValue(_taskHost) != null)
                {
                    cmbFormatFile.SelectedIndex = FindStringInComboBox(cmbFormatFile, _taskHost.Properties[Keys.FORMAT_FILE].GetValue(_taskHost).ToString(), -1);
                }

                if (_taskHost.Properties[Keys.SRV_LOGIN].GetValue(_taskHost) != null)
                {
                    cmbLogin.SelectedIndex = FindStringInComboBox(cmbLogin, _taskHost.Properties[Keys.SRV_LOGIN].GetValue(_taskHost).ToString(), -1);
                }

                if (_taskHost.Properties[Keys.SRV_PASSWORD].GetValue(_taskHost) != null)
                {
                    cmbPassword.SelectedIndex = FindStringInComboBox(cmbPassword, _taskHost.Properties[Keys.SRV_PASSWORD].GetValue(_taskHost).ToString(), -1);
                }

                if (_taskHost.Properties[Keys.CODE_PAGE].GetValue(_taskHost) != null)
                {
                    cmbCodePage.Text = _taskHost.Properties[Keys.CODE_PAGE].GetValue(_taskHost).ToString();
                }

                if (_taskHost.Properties[Keys.ACTIVATE_CMDSHELL].GetValue(_taskHost) != null)
                {
                    chkRightsCMDSHELL.Checked = (_taskHost.Properties[Keys.ACTIVATE_CMDSHELL].GetValue(_taskHost).ToString() == Keys.TRUE) ? true : false;
                }

                if (_taskHost.Properties[Keys.DATA_SOURCE].GetValue(_taskHost) != null)
                {
                    tabControl.SelectedTab = tabControl.TabPages.Cast <TabPage>().Where(tab => tab.Text == _taskHost.Properties[Keys.DATA_SOURCE].GetValue(_taskHost).ToString()).FirstOrDefault();
                }

                if (_taskHost.Properties[Keys.SEND_FILE_BY_EMAIL].GetValue(_taskHost) != null)
                {
                    chkEmail.Checked = _taskHost.Properties[Keys.SEND_FILE_BY_EMAIL].GetValue(_taskHost).ToString() == Keys.TRUE;
                    EnableSmtp(chkEmail.Checked);
                }
                else
                {
                    EnableSmtp(false);
                }

                optFileVariable.CheckedChanged         += (optFileVariable_CheckedChanged_1);
                optFileVariable.Click                  += (optFileVariable_Click);
                optFileConnection.CheckedChanged       += (optFileConnection_CheckedChanged_1);
                cmdFileVariable.Click                  += (cmdFileVariable_Click);
                optFileFormatVariable.CheckedChanged   += (optFileFormatVariable_CheckedChanged_1);
                optFileFormatVariable.Click            += (optFileFormatVariable_CheckedChanged);
                optFileFormatConnection.CheckedChanged += (optFileFormatConnection_CheckedChanged_1);
                optFileFormatConnection.ChangeUICues   += (optFileFormatConnection_CheckedChanged);

                _isFirstLoad = false;
            }
            catch (Exception exception)
            {
                Cursor = Cursors.Arrow;
                MessageBox.Show(exception.Message);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
示例#33
0
        public frmEditProperties(TaskHost taskHost, Connections connections)
        {
            InitializeComponent();

            grdParameters.DataError += grdParameters_DataError;

            _taskHost = taskHost;

            try
            {
                Cursor = Cursors.WaitCursor;

                cmbServices.Items.Clear();
                cmbMethods.Items.Clear();
                grdParameters.Rows.Clear();

                //Get URL's Service
                cmbURL.Items.AddRange(LoadVariables("System.String").ToArray());
                if (_taskHost.Properties[NamedStringMembers.SERVICE_URL].GetValue(_taskHost) != null)
                {
                    if (!string.IsNullOrEmpty(_taskHost.Properties[NamedStringMembers.SERVICE_URL].GetValue(_taskHost).ToString()))
                    {
                        cmbURL.SelectedIndexChanged      -= cmbURL_SelectedIndexChanged;
                        cmbServices.SelectedIndexChanged -= cmbServices_SelectedIndexChanged;
                        cmbMethods.SelectedIndexChanged  -= cmbMethods_SelectedIndexChanged;


                        _wsdlHandler = new WSDLHandler(new Uri(EvaluateExpression(_taskHost.Properties[NamedStringMembers.SERVICE_URL].GetValue(_taskHost).ToString(),
                                                                                  _taskHost.VariableDispenser).ToString()));

                        cmbURL.Text = _taskHost.Properties[NamedStringMembers.SERVICE_URL].GetValue(_taskHost).ToString();

                        //Get Services
                        cmbServices.Items.AddRange(_wsdlHandler.AvailableServices.ToArray());
                        cmbServices.SelectedIndex = FindStringInComboBox(cmbServices, _taskHost.Properties[NamedStringMembers.SERVICE].GetValue(_taskHost).ToString(), -1);

                        //Get Methods by service
                        cmbMethods.Items.AddRange(_wsdlHandler.GetServiceMethods(_taskHost.Properties[NamedStringMembers.SERVICE].GetValue(_taskHost).ToString()).ToArray());
                        cmbMethods.SelectedIndex = FindStringInComboBox(cmbMethods, _taskHost.Properties[NamedStringMembers.WEBMETHOD].GetValue(_taskHost).ToString(), -1);

                        var webServiceMethod = from m in _wsdlHandler.WebServiceMethods
                                               where m.Name == _taskHost.Properties[NamedStringMembers.WEBMETHOD].GetValue(_taskHost).ToString()
                                               select new WebServiceMethod
                        {
                            Name       = m.Name,
                            ResultType = m.ResultType
                        };

                        //Get returned variables
                        if (_taskHost.Properties[NamedStringMembers.RETURNED_VALUE] != null)
                        {
                            if (!string.IsNullOrEmpty(_taskHost.Properties[NamedStringMembers.RETURNED_VALUE].GetValue(_taskHost).ToString()))
                            {
                                cmbReturnVariable.Items.AddRange(LoadVariables((webServiceMethod.FirstOrDefault()).ResultType).ToArray());
                                cmbReturnVariable.SelectedIndex = FindStringInComboBox(cmbReturnVariable, _taskHost.Properties[NamedStringMembers.RETURNED_VALUE].GetValue(_taskHost).ToString(), -1);
                            }
                        }

                        FillGridWithParams(_taskHost.Properties[NamedStringMembers.MAPPING_PARAMS].GetValue(_taskHost) as MappingParams);

                        cmbURL.SelectedIndexChanged      += cmbURL_SelectedIndexChanged;
                        cmbServices.SelectedIndexChanged += cmbServices_SelectedIndexChanged;
                        cmbMethods.SelectedIndexChanged  += cmbMethods_SelectedIndexChanged;
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
示例#34
0
        public static void BuildSSISPackage(out Microsoft.SqlServer.Dts.Runtime.Package package, out IDTSComponentMetaData100 multipleHash, out CManagedComponentWrapper multipleHashInstance, out String lineageString, out MainPipe dataFlowTask, out Microsoft.SqlServer.Dts.Runtime.Application app)
        {
            package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            dataFlowTask = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            // Create a flat file source
            ConnectionManager flatFileConnectionManager = package.Connections.Add("FLATFILE");

            flatFileConnectionManager.Properties["Format"].SetValue(flatFileConnectionManager, "Delimited");
            flatFileConnectionManager.Properties["Name"].SetValue(flatFileConnectionManager, "Flat File Connection");
            flatFileConnectionManager.Properties["ConnectionString"].SetValue(flatFileConnectionManager, @".\TextDataToBeHashed.txt");
            flatFileConnectionManager.Properties["ColumnNamesInFirstDataRow"].SetValue(flatFileConnectionManager, false);
            flatFileConnectionManager.Properties["HeaderRowDelimiter"].SetValue(flatFileConnectionManager, "\r\n");
            flatFileConnectionManager.Properties["TextQualifier"].SetValue(flatFileConnectionManager, "\"");
            flatFileConnectionManager.Properties["DataRowsToSkip"].SetValue(flatFileConnectionManager, 0);
            flatFileConnectionManager.Properties["Unicode"].SetValue(flatFileConnectionManager, false);
            flatFileConnectionManager.Properties["CodePage"].SetValue(flatFileConnectionManager, 1252);

            // Create the columns in the flat file
            IDTSConnectionManagerFlatFile100       flatFileConnection = flatFileConnectionManager.InnerObject as IDTSConnectionManagerFlatFile100;
            IDTSConnectionManagerFlatFileColumn100 StringDataColumn   = flatFileConnection.Columns.Add();

            StringDataColumn.ColumnDelimiter     = ",";
            StringDataColumn.ColumnType          = "Delimited";
            StringDataColumn.DataType            = DataType.DT_STR;
            StringDataColumn.DataPrecision       = 0;
            StringDataColumn.DataScale           = 0;
            StringDataColumn.MaximumWidth        = 255;
            ((IDTSName100)StringDataColumn).Name = "StringData";
            IDTSConnectionManagerFlatFileColumn100 MoreStringColumn = flatFileConnection.Columns.Add();

            MoreStringColumn.ColumnDelimiter     = ",";
            MoreStringColumn.ColumnType          = "Delimited";
            MoreStringColumn.DataType            = DataType.DT_STR;
            MoreStringColumn.DataPrecision       = 0;
            MoreStringColumn.DataScale           = 0;
            MoreStringColumn.MaximumWidth        = 255;
            ((IDTSName100)MoreStringColumn).Name = "MoreString";
            IDTSConnectionManagerFlatFileColumn100 DateColumn = flatFileConnection.Columns.Add();

            DateColumn.ColumnDelimiter     = ",";
            DateColumn.ColumnType          = "Delimited";
            DateColumn.DataType            = DataType.DT_DATE;
            DateColumn.DataPrecision       = 0;
            DateColumn.DataScale           = 0;
            DateColumn.MaximumWidth        = 0;
            ((IDTSName100)DateColumn).Name = "DateColumn";
            IDTSConnectionManagerFlatFileColumn100 IntegerColumn = flatFileConnection.Columns.Add();

            IntegerColumn.ColumnDelimiter     = ",";
            IntegerColumn.ColumnType          = "Delimited";
            IntegerColumn.DataType            = DataType.DT_I4;
            IntegerColumn.DataPrecision       = 0;
            IntegerColumn.DataScale           = 0;
            IntegerColumn.MaximumWidth        = 0;
            ((IDTSName100)IntegerColumn).Name = "IntegerColumn";
            IDTSConnectionManagerFlatFileColumn100 NumericColumn = flatFileConnection.Columns.Add();

            NumericColumn.ColumnDelimiter     = "\r\n";
            NumericColumn.ColumnType          = "Delimited";
            NumericColumn.DataType            = DataType.DT_NUMERIC;
            NumericColumn.DataPrecision       = 15;
            NumericColumn.DataScale           = 2;
            NumericColumn.MaximumWidth        = 0;
            ((IDTSName100)NumericColumn).Name = "NumericColumn";

            app = new Microsoft.SqlServer.Dts.Runtime.Application();

            IDTSComponentMetaData100 flatFileSource = dataFlowTask.ComponentMetaDataCollection.New();

            flatFileSource.ComponentClassID = app.PipelineComponentInfos["Flat File Source"].CreationName;
            // Get the design time instance of the Flat File Source Component
            var flatFileSourceInstance = flatFileSource.Instantiate();

            flatFileSourceInstance.ProvideComponentProperties();

            flatFileSource.RuntimeConnectionCollection[0].ConnectionManager   = DtsConvert.GetExtendedInterface(flatFileConnectionManager);
            flatFileSource.RuntimeConnectionCollection[0].ConnectionManagerID = flatFileConnectionManager.ID;

            // Reinitialize the metadata.
            flatFileSourceInstance.AcquireConnections(null);
            flatFileSourceInstance.ReinitializeMetaData();
            flatFileSourceInstance.ReleaseConnections();
            flatFileSource.CustomPropertyCollection["RetainNulls"].Value = true;



            //[MD5BinaryOutput] varbinary(16), [MD5HexOutput] varchar(34), [MD5BaseOutput] varchar(24))";
            multipleHash = dataFlowTask.ComponentMetaDataCollection.New();
            multipleHash.ComponentClassID = typeof(Martin.SQLServer.Dts.MultipleHash).AssemblyQualifiedName;
            multipleHashInstance          = multipleHash.Instantiate();

            multipleHashInstance.ProvideComponentProperties();
            multipleHash.Name = "Multiple Hash Test";
            multipleHashInstance.ReinitializeMetaData();

            // Create the path from source to destination.
            StaticTestUtilities.CreatePath(dataFlowTask, flatFileSource.OutputCollection[0], multipleHash, multipleHashInstance);

            // Select the input columns.
            IDTSInput100        multipleHashInput  = multipleHash.InputCollection[0];
            IDTSVirtualInput100 multipleHashvInput = multipleHashInput.GetVirtualInput();

            foreach (IDTSVirtualInputColumn100 vColumn in multipleHashvInput.VirtualInputColumnCollection)
            {
                multipleHashInstance.SetUsageType(multipleHashInput.ID, multipleHashvInput, vColumn.LineageID, DTSUsageType.UT_READONLY);
            }

            // Add the output columns
            // Generate the Lineage String
            lineageString = String.Empty;
            foreach (IDTSInputColumn100 inputColumn in multipleHashInput.InputColumnCollection)
            {
                if (lineageString == String.Empty)
                {
                    lineageString = String.Format("#{0}", inputColumn.LineageID);
                }
                else
                {
                    lineageString = String.Format("{0},#{1}", lineageString, inputColumn.LineageID);
                }
            }
        }
        public void TestProvideComponentProperties()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 speechToText = dataFlowTask.ComponentMetaDataCollection.New();

            speechToText.ComponentClassID = typeof(Martin.SQLServer.Dts.SSISSpeechToText).AssemblyQualifiedName;
            CManagedComponentWrapper speechToTextInstance = speechToText.Instantiate();

            speechToTextInstance.ProvideComponentProperties();

            int intExpected = 7;  // Add 1 to the number that the component added, as there is a custom MS one as well.
            int intActual   = speechToText.CustomPropertyCollection.Count;

            Assert.AreEqual(intExpected, intActual, "Custom Property Collection Count is wrong");

            IDTSCustomProperty100 cpActual = speechToText.CustomPropertyCollection[Utility.SubscriptionKeyPropName];

            Assert.AreEqual(Utility.SubscriptionKeyPropName, cpActual.Name, "Property name is wrong");
            Assert.AreEqual(DTSCustomPropertyExpressionType.CPET_NOTIFY, cpActual.ExpressionType, "Expression type on SubscriptionKeyPropName is wrong");

            cpActual = speechToText.CustomPropertyCollection[Utility.OperationModePropName];
            Assert.AreEqual(Utility.OperationModePropName, cpActual.Name, "Property name is wrong");
            Assert.AreEqual(DTSCustomPropertyExpressionType.CPET_NONE, cpActual.ExpressionType, "Expression type on OperationModePropName is wrong");
            Assert.AreEqual(typeof(SSISSpeechToText.OperationModeEnum).AssemblyQualifiedName, cpActual.TypeConverter, "Type Converter on OperationModePropName is wrong");

            cpActual = speechToText.CustomPropertyCollection[Utility.LanguagePropName];
            Assert.AreEqual(cpActual.Name, Utility.LanguagePropName, "Property name is wrong");
            Assert.AreEqual(cpActual.ExpressionType, DTSCustomPropertyExpressionType.CPET_NONE, "Expression type on LanguagePropName is wrong");
            Assert.AreEqual(cpActual.TypeConverter, typeof(SSISSpeechToText.SpeechLanguageEnum).AssemblyQualifiedName, "Type Converter on LanguagePropName is wrong");

            cpActual = speechToText.CustomPropertyCollection[Utility.ChannelSeparationPropName];
            Assert.AreEqual(cpActual.Name, Utility.ChannelSeparationPropName, "Property name is wrong");
            Assert.AreEqual(cpActual.ExpressionType, DTSCustomPropertyExpressionType.CPET_NONE, "Expression type on ChannelSeparationPropName is wrong");
            Assert.AreEqual(cpActual.TypeConverter, typeof(SSISSpeechToText.ChannelSeparationEnum).AssemblyQualifiedName, "Type Converter on ChannelSeparationPropName is wrong");

            cpActual = speechToText.CustomPropertyCollection[Utility.ShortPhraseUrlPropName];
            Assert.AreEqual(Utility.ShortPhraseUrlPropName, cpActual.Name, "Property name is wrong");
            Assert.AreEqual(DTSCustomPropertyExpressionType.CPET_NOTIFY, cpActual.ExpressionType, "Expression type on ShortPhraseUrlPropName is wrong");
            Assert.AreEqual(string.Empty, cpActual.TypeConverter, "Type Converter on AuthenticationUriPropName is wrong");

            cpActual = speechToText.CustomPropertyCollection[Utility.LongPhraseUrlPropName];
            Assert.AreEqual(Utility.LongPhraseUrlPropName, cpActual.Name, "Property name is wrong");
            Assert.AreEqual(DTSCustomPropertyExpressionType.CPET_NOTIFY, cpActual.ExpressionType, "Expression type on LongPhraseUrlPropName is wrong");
            Assert.AreEqual(string.Empty, cpActual.TypeConverter, "Type Converter on AuthenticationUriPropName is wrong");

            intExpected = 1;
            intActual   = speechToText.InputCollection.Count;
            Assert.AreEqual(intExpected, intActual, "Input Collection Count is wrong");
            Assert.AreEqual(speechToText.InputCollection[0].Name, "Input", "Input Name is Wrong");
            Assert.AreEqual(speechToText.InputCollection[0].InputColumnCollection.Count, 0, "There are input columns");

            intExpected = 1;
            intActual   = speechToText.OutputCollection.Count;
            Assert.AreEqual(intExpected, intActual, "Output Collection Count is wrong");
            Assert.AreEqual(speechToText.OutputCollection[0].Name, "SpeechOutput", "Output Name is Wrong");
            Assert.AreEqual(speechToText.OutputCollection[0].OutputColumnCollection.Count, 3, "The number of output columns is wrong");

            Assert.AreEqual(speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputChannelColumnName].Name, Utility.OutputChannelColumnName, "Output column name is wrong");
            Assert.AreEqual(speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputChannelColumnName].DataType, DataType.DT_STR, "Output column OutputSpeechColumnName datatype is wrong");
            Assert.AreEqual((SSISSpeechToText.OutputTypeEnum)speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputChannelColumnName].CustomPropertyCollection[Utility.OutputColumnOutputTypePropName].Value, SSISSpeechToText.OutputTypeEnum.Channel, "Output column OutputChannelColumnName purpose is wrong");

            Assert.AreEqual(speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputSpeechColumnName].Name, Utility.OutputSpeechColumnName, "Output column name is wrong");
            Assert.AreEqual(speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputSpeechColumnName].DataType, DataType.DT_TEXT, "Output column OutputSpeechColumnName datatype is wrong");
            Assert.AreEqual((SSISSpeechToText.OutputTypeEnum)speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputSpeechColumnName].CustomPropertyCollection[Utility.OutputColumnOutputTypePropName].Value, SSISSpeechToText.OutputTypeEnum.Speech, "Output column OutputSpeechColumnName purpose is wrong");

            Assert.AreEqual(speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputTimecodeColumnName].Name, Utility.OutputTimecodeColumnName, "Output column name is wrong");
            Assert.AreEqual(speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputTimecodeColumnName].DataType, DataType.DT_DBTIME2, "Output column OutputTimecodeColumnName datatype is wrong");
            Assert.AreEqual((SSISSpeechToText.OutputTypeEnum)speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputTimecodeColumnName].CustomPropertyCollection[Utility.OutputColumnOutputTypePropName].Value, SSISSpeechToText.OutputTypeEnum.Timecode, "Output column OutputTimecodeColumnName purpose is wrong");
        }
示例#36
0
        /// <summary>
        /// Initializes a new instance of the <see cref="frmAssembly"/> class.
        /// </summary>
        /// <param name="taskHost">The task host.</param>
        /// <param name="connections">The connections.</param>
        public frmAssembly(TaskHost taskHost, Connections connections)
        {
            InitializeComponent();
            _isFirstLoad = true;

            _taskHost    = taskHost;
            _connections = connections;

            if (taskHost == null)
            {
                throw new ArgumentNullException("taskHost");
            }

            LoadFileConnections();

            try
            {
                if (_taskHost.Properties[NamedStringMembers.CONFIGURATION_TYPE].GetValue(_taskHost).ToString() != ConfigurationType.NO_CONFIGURATION)
                {
                    if (_taskHost.Properties[NamedStringMembers.CONFIGURATION_TYPE].GetValue(_taskHost).ToString() == ConfigurationType.FILE_CONNECTOR)
                    {
                        LoadConfigFileConnections();
                        optChooseConfigFileConnector.Checked = true;
                    }
                    else
                    {
                        cmbConfigurationFile.Items.AddRange(LoadVariables("System.String").ToArray());
                        optChooseVariable.Checked = true;
                    }

                    cmbConfigurationFile.Text = _taskHost.Properties[NamedStringMembers.CONFIGURATION_FILE].GetValue(_taskHost).ToString();

                    chkConfigFile.Checked = true;
                }
                else
                {
                    chkConfigFile.Checked = false;
                }
            }
            catch
            {
                chkConfigFile.Checked = false;
            }
            finally
            {
                EnableConfigurationControlFile();
            }

            if (_taskHost.Properties[NamedStringMembers.ASSEMBLY_CONNECTOR].GetValue(_taskHost) == null)
            {
                return;
            }

            cmbConnection.SelectedIndexChanged -= cmbConnection_SelectedIndexChanged;
            cmbNamespace.SelectedIndexChanged  -= cmbNamespace_SelectedIndexChanged;
            cmbClasses.SelectedIndexChanged    -= cmbClasses_SelectedIndexChanged;

            try
            {
                try
                {
                    var mappingParams = _taskHost.Properties[NamedStringMembers.MAPPING_PARAMS].GetValue(_taskHost).ToString().Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string mappingParam in mappingParams)
                    {
                        _paramsManager.Add(mappingParam.Split('|')[0], mappingParam.Split('|')[1]);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }

                cmbConnection.SelectedIndex = cmbConnection.FindString(_taskHost.Properties[NamedStringMembers.ASSEMBLY_CONNECTOR].GetValue(_taskHost).ToString());

                GetAssemblyInfo(_taskHost.Properties[NamedStringMembers.ASSEMBLY_PATH].GetValue(_taskHost).ToString());

                cmbNamespace.SelectedIndex = FindStringInComboBox(cmbNamespace,
                                                                  _taskHost.Properties[NamedStringMembers.ASSEMBLY_NAMESPACE].GetValue(_taskHost).ToString(),
                                                                  -1);
                GetAssemblyClasses(cmbNamespace.Text);

                cmbClasses.SelectedIndex = FindStringInComboBox(cmbClasses,
                                                                _taskHost.Properties[NamedStringMembers.ASSEMBLY_CLASS].GetValue(_taskHost).ToString(),
                                                                -1);

                GetAssemblyMethods(cmbNamespace.Text, cmbClasses.Text);

                SelectTheRightMethod();

                //cmbConfigurationFile.Text = _taskHost.Properties[NamedStringMembers.CONFIGURATION_FILE].GetValue(_taskHost).ToString();
            }
            catch (Exception exception)
            {
                Cursor = Cursors.Arrow;
                MessageBox.Show(exception.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            cmbConnection.SelectedIndexChanged += cmbConnection_SelectedIndexChanged;
            cmbNamespace.SelectedIndexChanged  += cmbNamespace_SelectedIndexChanged;
            cmbClasses.SelectedIndexChanged    += cmbClasses_SelectedIndexChanged;
        }
示例#37
0
文件: FTPTask.cs 项目: japj/vulcan
        public FTPTask(
            Packages.VulcanPackage vulcanPackage,
            string name,
            string taskDescription,
            DTS.IDTSSequence parentContainer,
            string serverName,
            string port,
            string userName,
            string password,
            string remotePath,
            bool isRemotePathVariable,
            string localPath,
            bool isLocalPathVariable,
            Microsoft.SqlServer.Dts.Tasks.FtpTask.DTSFTPOp operation
            )
            : base(vulcanPackage,
            name,
            taskDescription,
            parentContainer)
        {
            fTPTask = (DTS.TaskHost)parentContainer.Executables.Add("STOCK:FTPTask");
            fTPTask.Name = name;
            fTPTask.Description = taskDescription;
            this.Task.Operation = operation;

            this.Task.IsRemotePathVariable = isRemotePathVariable;
            this.Task.IsLocalPathVariable = isLocalPathVariable;

            Connection fTPServerConnection = new Connection(vulcanPackage, serverName, serverName, "FTP", String.Format("\"{0}:{1}\"", serverName, port));
            fTPServerConnection.SetProperty("ServerUserName", userName);
            fTPServerConnection.SetProperty("ServerPassword", password);
            this.Task.Connection = fTPServerConnection.ConnectionManager.ID;

            if (this.Task.IsRemotePathVariable == true)
            {
                this.Task.RemotePath = remotePath;
            }
            else
            {
                this.Task.RemotePath = remotePath;
            }

            if (this.Task.IsLocalPathVariable == true)
            {
                this.Task.LocalPath = localPath;
            }
            else
            {
                Connection localConnection = new Connection(vulcanPackage, localPath, localPath, "File", String.Format("\"{0}\"", ExpressionPathBuilder.EscapeBackslashes(localPath)));
                int intFileUsageType = 2;
                switch (operation)
                {
                    case Microsoft.SqlServer.Dts.Tasks.FtpTask.DTSFTPOp.Send:
                        intFileUsageType = 0;
                        break;
                    case Microsoft.SqlServer.Dts.Tasks.FtpTask.DTSFTPOp.Receive:
                        intFileUsageType = 2;
                        break;
                    default:
                        intFileUsageType = 2;
                        break;
                }
                localConnection.SetProperty("FileUsageType", intFileUsageType);

                this.Task.LocalPath = localPath;
            }
        }
示例#38
0
        public Executable AddTask <T>(EntityTypeConfiguration <T> map, ConnectionManager manager) where T : class
        {
            FileInfo fileInfo            = new FileInfo(manager.ConnectionString);
            string   fileName            = fileInfo.Name.Substring(0, fileInfo.Name.Length - 4);
            string   dataFlowName        = $"Data Flow from {fileName} to {map.GetTableName()} in the {map.GetSchemaName()} Schema";
            string   dataFlowDescription = $"This data flow task will transfer the records from {manager.ConnectionString} to the {map.GetFullTableName()}";

            Executable executable = CensusPackageExecutables.Contains(dataFlowName)
                                        ? CensusPackageExecutables[dataFlowName]
                                        : CensusPackageExecutables.Add("STOCK:PipelineTask");
            TaskHost task = executable as TaskHost;

            if (task == null)
            {
                throw new ArgumentException("Failed to retrieve executable as TaskHost!");
            }

            task.Name        = dataFlowName;
            task.Description = dataFlowDescription;

            MainPipe dataFlow = task.InnerObject as MainPipe;

            if (dataFlow == null)
            {
                throw new ArgumentException("Unable to retrieve task as a MainPipe!");
            }

            dataFlow.ComponentMetaDataCollection.RemoveAll();
            dataFlow.Events = DtsConvert.GetExtendedInterface(new SSISComponentEventHandler());

            #region Source
            IDTSComponentMetaData100 source = dataFlow.ComponentMetaDataCollection.New();
            source.Name             = $"{FlatFileSourceComponentInfo.Name} reference to {fileName}";
            source.Description      = $"This component will read all of the records located in {fileInfo.FullName}";
            source.ContactInfo      = "Anthony Hart | [email protected]";
            source.ComponentClassID = FlatFileSourceComponentInfo.CreationName;

            CManagedComponentWrapper sourceWrapper = source.Instantiate();
            sourceWrapper.ProvideComponentProperties();

            source.RuntimeConnectionCollection[0].ConnectionManager   = DtsConvert.GetExtendedInterface(manager);
            source.RuntimeConnectionCollection[0].ConnectionManagerID = manager.ID;

            source.RuntimeConnectionCollection[0].Name        = "FlatFileConnection";
            source.RuntimeConnectionCollection[0].Description = manager.Description;

            sourceWrapper.SetComponentProperty("RetainNulls", true);

            sourceWrapper.AcquireConnections(null);
            sourceWrapper.ReinitializeMetaData();
            sourceWrapper.ReleaseConnections();
            #endregion Source

            #region Destination
            IDTSComponentMetaData100 destination = dataFlow.ComponentMetaDataCollection.New();
            destination.Name             = $"{ADONETDestinationComponentInfo.Name} reference to {map.GetTableName()} in the {map.GetSchemaName()} Schema";
            destination.Description      = $"This component will import all of the records that were read from the {FlatFileSourceComponentInfo.Name} component into the {map.GetFullTableName()} table";
            destination.ContactInfo      = "Anthony Hart | [email protected]";
            destination.ComponentClassID = ADONETDestinationComponentInfo.CreationName;

            CManagedComponentWrapper destinationWrapper = destination.Instantiate();
            destinationWrapper.ProvideComponentProperties();

            destination.RuntimeConnectionCollection[0].ConnectionManager   = DtsConvert.GetExtendedInterface(DefaultConnection);
            destination.RuntimeConnectionCollection[0].ConnectionManagerID = DefaultConnection.ID;
            destination.RuntimeConnectionCollection[0].Name        = "IDbConnection";
            destination.RuntimeConnectionCollection[0].Description = DefaultConnection.Description;

            destinationWrapper.SetComponentProperty("CommandTimeout", 600);
            destinationWrapper.SetComponentProperty("TableOrViewName", map.GetFullTableName());

            destinationWrapper.AcquireConnections(null);
            destinationWrapper.ReinitializeMetaData();
            destinationWrapper.ReleaseConnections();
            #endregion Destination

            #region Pathing
            IDTSPath100 path = dataFlow.PathCollection.New();
            path.AttachPathAndPropagateNotifications(source.OutputCollection[0], destination.InputCollection[0]);
            #endregion

            #region Column Mapping
            IDTSInput100        input        = destination.InputCollection[0];
            IDTSVirtualInput100 virtualInput = input.GetVirtualInput();

            foreach (IDTSVirtualInputColumn100 vColumn in virtualInput.VirtualInputColumnCollection)
            {
                IDTSInputColumn100 vCol = destinationWrapper.SetUsageType(input.ID, virtualInput, vColumn.LineageID, vColumn.Name == "TERMINATOR" ? DTSUsageType.UT_IGNORED : DTSUsageType.UT_READWRITE);
                if (vCol != null)
                {
                    destinationWrapper.MapInputColumn(input.ID, vCol.ID, input.ExternalMetadataColumnCollection[vCol.Name].ID);
                }
            }
            #endregion Column Mapping

            return(executable);
        }