示例#1
0
        public static FlatFileSourceComponentWrapper CreateComponent(FlatFileSource flatFileSource, DataFlowTaskWrapper dataFlowTaskWrapper, PackageWrapper packageWrapper, ProjectWrapper projectWrapper)
        {
            FlatFileSourceComponentWrapper flatFileSourceComponentWrapper = new FlatFileSourceComponentWrapper(dataFlowTaskWrapper)
            {
                Name        = flatFileSource.Name,
                RetainNulls = flatFileSource.RetainNulls
            };

            if (flatFileSource.FlatFileSourceColumns != null)
            {
                foreach (DataFlowColumnMapping dataFlowColumnMapping in flatFileSource.FlatFileSourceColumns)
                {
                    flatFileSourceComponentWrapper.CustomMappingColumns.Add((dataFlowColumnMapping.SourceColumn, dataFlowColumnMapping.TargetColumn));
                }
            }

            SetConnectionManager(projectWrapper, packageWrapper, flatFileSourceComponentWrapper, flatFileSource.ConnectionName);

            try
            {
                flatFileSourceComponentWrapper.GetMetadata();
            }
            catch (Exception e)
            {
                throw new Exception($"Failed to get metadata for data flow component {flatFileSourceComponentWrapper.Name}!", e);
            }

            return(flatFileSourceComponentWrapper);
        }
示例#2
0
        public void FlatFileSource_FullLoadTest()
        {
            var schema = new FlatFileSource("./TestMultilineFile.txt", RuntimeContext.Empty);

            int fires = 0;

            foreach (var item in schema.Rows)
            {
                fires += 1;
            }

            Assert.AreEqual(6, fires);
        }
示例#3
0
        public void FlatFileSource_CancelledLoadTest()
        {
            var endWorkTokenSource = new CancellationTokenSource();

            endWorkTokenSource.Cancel();
            var schema = new FlatFileSource("./TestMultilineFile.txt", new RuntimeContext(endWorkTokenSource.Token, new ISchemaColumn[0]));

            int fires = 0;

            foreach (var item in schema.Rows)
            {
                fires += 1;
            }

            Assert.AreEqual(0, fires);
        }
示例#4
0
        public void FlatFileSource_CancelledLoadTest()
        {
            var endWorkTokenSource = new CancellationTokenSource();

            endWorkTokenSource.Cancel();
            var schema = new FlatFileSource("./TestMultilineFile.txt", new InterCommunicator(endWorkTokenSource.Token));

            int fires = 0;

            foreach (var item in schema.Rows)
            {
                fires += 1;
            }

            Assert.AreEqual(0, fires);
        }