コード例 #1
0
        public Connection GetConnection(TransformSettings transformSettings)
        {
            try
            {
                var connectionReference = Connections.GetConnection(ConnectionClassName, ConnectionAssemblyName);

                if (!transformSettings.RemoteSettings.Permissions.AllowLocalFiles && connectionReference.RequiresLocalStorage)
                {
                    throw new RepositoryException($"The connection {connectionReference.Name} can not be used on this remote agent as local file access is forbidden.");
                }

                var connection = connectionReference.GetConnection();
                connection.ClientFactory = transformSettings.ClientFactory;

                this.CopyProperties(connection, true);

                if (!UsePasswordVariable)
                {
                    connection.Password = GetPassword(transformSettings.RemoteSettings.AppSettings.EncryptionKey,
                                                      transformSettings.RemoteSettings.SystemSettings.EncryptionIterations);
                }

                if (!UseConnectionStringVariable)
                {
                    connection.ConnectionString = GetConnectionString(
                        transformSettings.RemoteSettings.AppSettings.EncryptionKey,
                        transformSettings.RemoteSettings.SystemSettings.EncryptionIterations);
                }

                if (transformSettings.HasVariables())
                {
                    connection.ConnectionString = transformSettings.InsertHubVariables(connection.ConnectionString);
                    connection.Server           = transformSettings.InsertHubVariables(connection.Server);
                    connection.Password         = transformSettings.InsertHubVariables(connection.Password);
                    connection.Username         = transformSettings.InsertHubVariables(connection.Username);
                    connection.DefaultDatabase  = transformSettings.InsertHubVariables(connection.DefaultDatabase);
                    connection.Filename         = transformSettings.InsertHubVariables(connection.Filename);
                }

                connection.FilePermissions = transformSettings.RemoteSettings.Permissions.GetFilePermissions();

                return(connection);
            }
            catch (Exception ex)
            {
                throw new RepositoryException($"Get connection failed.  {ex.Message}", ex);
            }
        }
コード例 #2
0
        public Table GetRejectedTable(DexihHub hub, Connection connection, TransformSettings transformSettings)
        {
            var table = GetTable(hub, connection, transformSettings);

            return(table.GetRejectedTable(RejectedTableName));
        }
コード例 #3
0
        public Table GetTable(DexihHub hub, Connection connection, InputColumn[] inputColumns, TransformSettings transformSettings, string referenceTableAlias = null)
        {
            Table table;

            if (connection == null)
            {
                table = new Table();
            }
            else
            {
                EConnectionCategory category;
                if (connection is ConnectionFlatFile)
                {
                    category = EConnectionCategory.File;
                }
                else
                {
                    var connectionReference = Connections.GetConnection(connection.GetType());
                    category = connectionReference.ConnectionCategory;
                }

                switch (category)
                {
                case EConnectionCategory.File:
                    table = new FlatFile();
                    if (FileFormatKey == null)
                    {
                        ((FlatFile)table).FileConfiguration = new FileConfiguration();
                    }
                    else
                    {
                        var fileFormat =
                            hub.DexihFileFormats.SingleOrDefault(f => f.IsValid && f.Key == FileFormatKey);

                        if (fileFormat == null)
                        {
                            throw new RepositoryException(
                                      $"The file format for the table {Name} with key {FileFormatKey} could not be found.");
                        }

                        ((FlatFile)table).FileConfiguration = fileFormat?.GetFileFormat();
                    }

                    break;

                case EConnectionCategory.WebService:
                    table = new WebService();
                    break;

                default:
                    table = new Table();
                    break;
                }
            }

            // create a temporary copy and exclude the fileFormat (which is different between DexihTable & Table)
            this.CopyProperties(table, false);

            switch (table)
            {
            case FlatFile flatFile:

                if (transformSettings.HasVariables())
                {
                    flatFile.FileIncomingPath  = transformSettings.InsertHubVariables(flatFile.FileIncomingPath);
                    flatFile.FileMatchPattern  = transformSettings.InsertHubVariables(flatFile.FileMatchPattern);
                    flatFile.FileOutgoingPath  = transformSettings.InsertHubVariables(flatFile.FileOutgoingPath);
                    flatFile.FileProcessedPath = transformSettings.InsertHubVariables(flatFile.FileProcessedPath);
                    flatFile.FileRejectedPath  = transformSettings.InsertHubVariables(flatFile.FileRejectedPath);
                    flatFile.FileRootPath      = transformSettings.InsertHubVariables(flatFile.FileRootPath);
                }

                break;

            case WebService restFunction:

                if (transformSettings.HasVariables())
                {
                    restFunction.RestfulUri = transformSettings.InsertHubVariables(restFunction.RestfulUri);
                    restFunction.RowPath    = transformSettings.InsertHubVariables(restFunction.RowPath);
                }

                break;
            }

            foreach (var dbColumn in DexihTableColumns.Where(c => c.IsValid && c.DeltaType != EDeltaType.IgnoreField).OrderBy(c => c.Position))
            {
                table.Columns.Add(dbColumn.GetTableColumn(inputColumns, referenceTableAlias));
            }

            foreach (var dbIndex in DexihTableIndexes.Where(c => c.IsValid))
            {
                table.Indexes.Add(new TableIndex()
                {
                    Name    = dbIndex.Name,
                    Columns = dbIndex.Columns.Select(ti =>
                    {
                        var column = DexihTableColumns.SingleOrDefault(c => c.Key == ti.ColumnKey);
                        if (column != null)
                        {
                            return(new TableIndexColumn(column.Name, ti.Direction));
                        }

                        return(null);
                    }).Where(c => c != null).ToList()
                });
            }

            return(table);
        }
コード例 #4
0
        public Table GetTable(DexihHub hub, Connection connection, IEnumerable <DexihColumnBase> inputColumns, TransformSettings transformSettings, string referenceTableAlias = null)
        {
            var inputs = inputColumns.Select(c => c.ToInputColumn()).ToArray();

            return(GetTable(hub, connection, inputs, transformSettings, referenceTableAlias));
        }
コード例 #5
0
 public Table GetTable(DexihHub hub, Connection connection, TransformSettings transformSettings, string referenceTableAlias = null)
 {
     return(GetTable(hub, connection, (InputColumn[])null, transformSettings, referenceTableAlias));
 }