public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction) {
            try {
                var connectionManager = connections[ConnectionName];
                var connection = connectionManager.AcquireConnection(transaction) as SqlConnection;

                var dropKeysScript = Resources.DropCreateFKScriptCommon.Replace(SELECT_STATEMENT_PLACEHOLDER, Resources.CreateFKScript);

                var command = new SqlCommand(dropKeysScript, connection);

                var reader = command.ExecuteReader();

                var scriptBuilder = new StringBuilder();

                while (reader.Read())
                {
                    var dropScript = reader.GetString(reader.GetOrdinal("CreateScript"));
                    //var sourceTableName = reader.GetString(reader.GetOrdinal("SourceTableName"));
                    //var targetTableName = reader.GetString(reader.GetOrdinal("TargetTableName"));

                    scriptBuilder.AppendLine(dropScript);
                }

                if (File.Exists(TargetPath))
                {
                    File.Delete(TargetPath);
                }

                File.WriteAllText(TargetPath, scriptBuilder.ToString());

                return DTSExecResult.Success;
            } catch (Exception ex) {
                log.Write(string.Format("{0}.Execute", GetType().FullName), ex.ToString());
                return DTSExecResult.Failure;
            }
        }
Example #2
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            try {
                using (var sftp = new SftpClient(Host, Port, Username, Password))
                {
                    sftp.Connect();

                    using (var file = File.OpenWrite(TargetPath))
                    {
                        sftp.DownloadFile(SourcePath, file);
                    }

                    return(DTSExecResult.Success);
                }
            } catch (Exception ex) {
                log.Write(string.Format("{0}.Execute", GetType().FullName), ex.ToString());
                return(DTSExecResult.Failure);
            }
        }
Example #3
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            try {
                var connectionManager = connections[ConnectionName];
                var connection        = connectionManager.AcquireConnection(transaction) as SqlConnection;

                var dropKeysScript = Resources.DropCreateFKScriptCommon.Replace(SELECT_STATEMENT_PLACEHOLDER, Resources.CreateFKScript);

                var command = new SqlCommand(dropKeysScript, connection);

                var reader = command.ExecuteReader();

                var scriptBuilder = new StringBuilder();

                while (reader.Read())
                {
                    var dropScript = reader.GetString(reader.GetOrdinal("CreateScript"));
                    //var sourceTableName = reader.GetString(reader.GetOrdinal("SourceTableName"));
                    //var targetTableName = reader.GetString(reader.GetOrdinal("TargetTableName"));

                    scriptBuilder.AppendLine(dropScript);
                }

                if (File.Exists(TargetPath))
                {
                    File.Delete(TargetPath);
                }

                File.WriteAllText(TargetPath, scriptBuilder.ToString());

                return(DTSExecResult.Success);
            } catch (Exception ex) {
                log.Write(string.Format("{0}.Execute", GetType().FullName), ex.ToString());
                return(DTSExecResult.Failure);
            }
        }
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction) {

            try {
                using (var sftp = new SftpClient(Host, Port, Username, Password))
                {
                    sftp.Connect();

                    using (var file = File.OpenWrite(TargetPath))
                    {
                        sftp.DownloadFile(SourcePath, file);
                    }

                    return DTSExecResult.Success;
                }   
            } catch (Exception ex) {
                log.Write(string.Format("{0}.Execute", GetType().FullName), ex.ToString());
                return DTSExecResult.Failure;
            }
        }