コード例 #1
0
        public ConnectionManager GetFlatFileConnection <T>(string path, EntityTypeConfiguration <T> map, bool updateExisting = false) where T : class
        {
            if (string.IsNullOrWhiteSpace(path) ||
                !File.Exists(path))
            {
                throw new ArgumentException($"'{path}' is not a valid flat file path.");
            }

            FileInfo fileInfo = new FileInfo(path);

            string fileName = fileInfo.Name.Replace(fileInfo.Extension, "")
                              .Trim('.');

            string name        = $"SSIS Flat File Connection Manager for {fileName}";
            string description = $"Provides an SSIS connection to {path}";
            string streamName  = $"{fileInfo.Name}.{ConnectionManagerExtension}";

            ConnectionManager manager = CensusPackageConnections.Contains(name) ? CensusPackageConnections[name] : CensusPackageConnections.Add("FLATFILE");

            manager.ConnectionString = path;
            manager.Name             = name;
            manager.Description      = description;

            IDTSConnectionManagerFlatFile100 ffManager = manager.InnerObject as IDTSConnectionManagerFlatFile100;

            if (ffManager != null)
            {
                ffManager.AlwaysCheckForRowDelimiters = true;
                ffManager.ColumnNamesInFirstDataRow   = false;
                ffManager.Unicode      = false;
                ffManager.CodePage     = CodePage;
                ffManager.LocaleID     = LocaleID;
                ffManager.RowDelimiter = RowDelimiter;
                ffManager.Format       = "FixedWidth";
                GetColumns(ref ffManager, map);
            }

            return(manager);
        }
コード例 #2
0
        private ConnectionManager GetDefaultConnection()
        {
            ConnectionManager manager = CensusPackageConnections.Contains(DefaultConnectionName) ? CensusPackageConnections[DefaultConnectionName] : CensusPackageConnections.Add("ADO.NET:SQL");

            if (manager == null)
            {
                throw new ArgumentException("Unable to retrieve or create the default connection for the package!");
            }

            manager.Name             = DefaultConnectionName;
            manager.Description      = DefaultConnectionDescription;
            manager.ConnectionString = Program.DefaultConnectionString;

            return(manager);
        }