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");
        }
예제 #2
0
        public IDTSOutput100 ModifyComp_CondSplit_AddOut(IDTSComponentMetaData100 Comp,
                                                         string OutName,
                                                         int OutEvalOrder,
                                                         string OutExpression,
                                                         string OutDesc = "SampleDescription"
                                                         )
        {
            CManagedComponentWrapper Inst = Comp.Instantiate();

            // We need to set a column's usage type before we can use it in an expression.
            // The code here will make all of the input columns available, but we could also
            // restrict it to just the columns that we need in the conditional split expression(s).

            IDTSInput100        splitInput  = Comp.InputCollection[0];
            IDTSVirtualInput100 splitVInput = splitInput.GetVirtualInput();

            IDTSInputColumnCollection100        splitInputCols  = splitInput.InputColumnCollection;
            IDTSVirtualInputColumnCollection100 splitVInputCols = splitVInput.VirtualInputColumnCollection;

            foreach (IDTSVirtualInputColumn100 vCol in splitVInputCols)
            {
                Inst.SetUsageType(splitInput.ID, splitVInput, vCol.LineageID, DTSUsageType.UT_READONLY);
            }

            //  Parametrize

            IDTSOutput100 splitOutput = Inst.InsertOutput(DTSInsertPlacement.IP_BEFORE, Comp.OutputCollection[0].ID);

            splitOutput.Name        = OutName;
            splitOutput.Description = OutDesc;
            splitOutput.IsErrorOut  = false;

            // Note: You will get an exception if you try to set these properties on the Default Output.
            Inst.SetOutputProperty(splitOutput.ID, "EvaluationOrder", OutEvalOrder);
            Inst.SetOutputProperty(splitOutput.ID, "FriendlyExpression", OutExpression);

            Inst.AcquireConnections(null);
            Inst.ReinitializeMetaData();
            Inst.ReleaseConnections();

            return(splitOutput);
        }
예제 #3
0
        private IDTSOutput100 ConfigureOutput(IDTSComponentMetaData100 src, IDeDestination dst, CManagedComponentWrapper dcomp)
        {
            if (dcomp == null)
            {
                dcomp = src.Instantiate();
            }

            IDTSOutput100 output = null;

            if (_movedata.Partition == null || String.IsNullOrEmpty(_movedata.Partition.Function) || _movedata.Partition.Function == "NONE")
            {
                output      = src.OutputCollection.New();
                output.Name = String.Format(CultureInfo.InvariantCulture, "Full Output to {0}", output.ID);
                output.SynchronousInputID = src.InputCollection[0].ID;
            }
            else
            {
                //connect to splitter, make sure the default output is the last
                output                    = dcomp.InsertOutput(DTSInsertPlacement.IP_BEFORE, src.OutputCollection[0].ID);
                output.Name               = String.Format(CultureInfo.InvariantCulture, "Partitioned Output to {0}", output.ID);
                output.Description        = String.Format(CultureInfo.InvariantCulture, "Partitions {0}-{1} ", dst.PartitionRange.Min, dst.PartitionRange.Max);
                output.SynchronousInputID = src.InputCollection[0].ID;
                output.IsErrorOut         = false;

                // Note: You will get an exception if you try to set these properties on the Default Output.
                dcomp.SetOutputProperty(output.ID, "EvaluationOrder", 0);
                if (dst.PartitionRange.Min == dst.PartitionRange.Max)
                {
                    dcomp.SetOutputProperty(output.ID, "FriendlyExpression", String.Format(CultureInfo.InvariantCulture, "[{0}] == {1}", _movedata.Partition.Output, dst.PartitionRange.Min));
                }
                else
                {
                    dcomp.SetOutputProperty(output.ID, "FriendlyExpression", String.Format(CultureInfo.InvariantCulture, "[{0}] >= {1} && [{0}] <= {2}", _movedata.Partition.Output, dst.PartitionRange.Min, dst.PartitionRange.Max));
                }
            }

            return(output);
        }