Esempio n. 1
0
        /// <summary>
        /// Validates the specified connections.
        /// </summary>
        /// <param name="connections">The connections.</param>
        /// <param name="variableDispenser">The variable dispenser.</param>
        /// <param name="componentEvents">The component events.</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            try
            {
                string _sourceFile = Common.GetVariableValue<string>(this.sourceFile, variableDispenser);
                string _targetFile = Common.GetVariableValue<string>(this.targetFile, variableDispenser);

                string errorMsg = String.Empty;
                if (String.IsNullOrEmpty(_sourceFile))
                    errorMsg += " Source,";

                if (String.IsNullOrEmpty(_targetFile))
                    errorMsg += " Target,";

                if (errorMsg.Trim().Length > 0)
                {
                    componentEvents.FireError(0, "", "Missing:" + errorMsg.Remove(errorMsg.Length - 1) + ".", "", 0);
                    return DTSExecResult.Failure;
                }
                
                return base.Validate(connections, variableDispenser, componentEvents, log);
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Validate: ", ex.Message + Environment.NewLine + ex.StackTrace, "", 0);
                return DTSExecResult.Failure;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Validate local parameters
        /// </summary>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser,
                                               IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            bool isBaseValid = true;

            if (base.Validate(connections, variableDispenser, componentEvents, log) != DTSExecResult.Success)
            {
                componentEvents.FireError(0, "SSISDownloadFileTask", "Base validation failed", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(HttpConnector))
            {
                componentEvents.FireError(0, "SSISDownloadFileTask", "A connector is required.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(HttpSourceFile))
            {
                componentEvents.FireError(0, "SSISDownloadFileTask", "A source file (direct file URL) is required.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(LocalDestinationFile))
            {
                componentEvents.FireError(0, "SSISDownloadFileTask", "A destination file (local path) is required.", "", 0);
                isBaseValid = false;
            }

            return(isBaseValid ? DTSExecResult.Success : DTSExecResult.Failure);
        }
        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;
            }
        }
Esempio n. 4
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {

            System.Threading.Thread.Sleep(this._interval * 60000);

            return DTSExecResult.Success;
        }
Esempio n. 5
0
        /// <summary>
        /// Overrides Execute logic
        /// Core Logic: It Fires a Custom Event, with the given ComponentType and Message
        /// <see cref="Microsoft.SqlServer.Dts.Runtime.Task.Execute"/>
        /// </summary>
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            bool refFire = false;
            componentEvents.FireInformation(ComponentType, "", GetMessageText(variableDispenser, componentEvents, MessageText), "", 0, ref refFire);

            return base.Execute(connections, variableDispenser, componentEvents, log, transaction);
        }
 public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
 {
     return (
         connections.Contains(ConnectionName)
         && !string.IsNullOrWhiteSpace(TargetPath)
         ) ? DTSExecResult.Success : DTSExecResult.Failure;
 }
        /// <summary>
        /// Validate local parameters
        /// </summary>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser,
                                               IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            bool isBaseValid = true;


            if (base.Validate(connections, variableDispenser, componentEvents, log) != DTSExecResult.Success)
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask", "Base validation failed", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(ReportServer))
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask", "Please specify a Report Server URL.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(ReportPath))
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask", "Please specify a path to your report.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(ReportName))
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask", "Please specify the report name.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(OutPutType))
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask", "Please specify the output file type.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(FileSourceType))
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask", "You didn't specify the output type version : by File Connector or by Variable/Expression.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(DestinationFile))
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask", "Please specify a destination file path of the generated report.", "", 0);
                isBaseValid = false;
            }

            if (SendFileByEmail == Keys.TRUE && (string.IsNullOrEmpty(SmtpFrom) || string.IsNullOrEmpty(SmtpRecipients)))
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask", "Please specify the minimal elements to send the email: the Sender and the Recipient(s) addresses.", "", 0);
                isBaseValid = false;
            }

            //bool refire = false;
            //GenerateReport(connections, variableDispenser, componentEvents, refire);

            return(isBaseValid ? DTSExecResult.Success : DTSExecResult.Failure);
        }
        /// <summary>
        /// Validate properties
        /// </summary>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser,
                                               IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            bool isBaseValid = true;

            if (base.Validate(connections, variableDispenser, componentEvents, log) != DTSExecResult.Success)
            {
                componentEvents.FireError(0, "SSISEncodeFileTask", "Base validation failed", "", 0);
                isBaseValid = false;
            }

            if (EncodingType < 1)
            {
                componentEvents.FireError(0, "SSISEncodeFileTask", "An encode type is required.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(SourceType))
            {
                componentEvents.FireError(0, "SSISEncodeFileTask", "A source type is required.", "", 0);
                isBaseValid = false;
            }

            if (!AutodetectSourceEncodingType && SourceEncodingType < 1)
            {
                componentEvents.FireError(0, "SSISEncodeFileTask",
                                          "if AutodetectSourceEncodingType is true, please specify an initial encoding.",
                                          "", 0);
                isBaseValid = false;
            }

            if (SourceFileType.FromFileConnector.ToString() == SourceType)
            {
                if (string.IsNullOrEmpty(FileConnector))
                {
                    componentEvents.FireError(0, "SSISEncodeFileTask", "A FILE connector is required.", "", 0);
                    isBaseValid = false;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(FileSourcePathInVariable))
                {
                    componentEvents.FireError(0, "SSISEncodeFileTask", "A file path is required.", "", 0);
                    isBaseValid = false;
                }
            }

            if (ReadWriteBuffer < 1)
            {
                componentEvents.FireError(0, "SSISEncodeFileTask", "The ReadWriteBuffer property cannot be less than 1.", "", 0);
                isBaseValid = false;
            }

            //var trans = new object();
            //ProxyExecute(connections, variableDispenser, componentEvents, log, trans);

            return(isBaseValid ? DTSExecResult.Success : DTSExecResult.Failure);
        }
Esempio n. 9
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            DTSExecResult execResult = DTSExecResult.Success;

            System.Windows.Forms.MessageBox.Show(this.displayText);

            return execResult;
        }
Esempio n. 10
0
 public static void Write(this IDTSLogging log, string eventName, string message)
 {
     if (log == null)
     {
         return;
     }
     byte[] dataBytes = null;
     log.Log(eventName, null, null, null, null, null, message, DateTime.Now, DateTime.Now, 0, ref dataBytes);
 }
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            ConnectionManager cSSH = getConnectionManager(connections, _SSHconnMgrName);
            List<KeyValuePair<string, string>> connParams = (List<KeyValuePair<string, string>>)cSSH.AcquireConnection(transaction);

            string host = connParams.Find(t => t.Key == "Host").Value;
            string username = connParams.Find(t => t.Key == "Username").Value;
            string password = connParams.Find(t => t.Key == "Password").Value;
            int port = Convert.ToInt32(connParams.Find(t => t.Key == "Port").Value);

            if (_operation == SSHFTPOperation.SendFiles)
            {
                ConnectionManager cSend = getConnectionManager(connections, _sendFilesSourceConnectionManagerName);
                string sourceFile = cSend.AcquireConnection(transaction).ToString();
                SshTransferProtocolBase sshCp;
                sshCp = new Sftp(host, username);
                sshCp.Password = password;
                string localFile = sourceFile;
                string remoteFile = getRemotePathAndFile(_sendFilesDestinationDirectory, Path.GetFileName(sourceFile));
                try
                {
                    sshCp.Connect();
                    sshCp.Put(localFile, remoteFile);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    sshCp.Close();
                }
            }
            if (_operation == SSHFTPOperation.ReceiveFiles)
            {
                ConnectionManager cReceive = getConnectionManager(connections, _receiveFilesDestinationConnectionManagerName);
                string destinationDirectory = cReceive.AcquireConnection(transaction).ToString();
                SshTransferProtocolBase sshCp;
                sshCp = new Sftp(host, username);
                sshCp.Password = password;
                try
                {
                    sshCp.Connect();
                    sshCp.Get(_receiveFilesSourceFile, destinationDirectory);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    sshCp.Close();
                }
            }

            return DTSExecResult.Success;
        }
Esempio n. 12
0
 public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log) {
     return (
         !string.IsNullOrWhiteSpace(Host)
         && Port > 0
         && !string.IsNullOrWhiteSpace(Username)
         && !string.IsNullOrWhiteSpace(Password)
         && !string.IsNullOrWhiteSpace(SourcePath)
         && !string.IsNullOrWhiteSpace(TargetPath)
         ) ? DTSExecResult.Success : DTSExecResult.Failure;
 }
Esempio n. 13
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            if (this._interval <= 0)
            {
                componentEvents.FireError(0, "", "Pause length must be greater than 0.", "", 0);
                return DTSExecResult.Failure;
            }

            return DTSExecResult.Success;
        }
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser,
                                               IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            if (WebHookUrl == null)
            {
                componentEvents.FireError(0, "Slact Taks", "Error sending message to Slack. Webhook is not set.", "", 0);
                return(DTSExecResult.Failure);
            }

            return(DTSExecResult.Success);
        }
Esempio n. 15
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            DTSExecResult execResult = base.Validate(connections, variableDispenser, componentEvents, log);
            if (execResult == DTSExecResult.Success)
            {
                // Validate task properties
                if (string.IsNullOrEmpty(displayText))
                {
                    componentEvents.FireWarning(1, this.GetType().Name, "Value required for DisplayText", string.Empty, 0);
                }
            }

            return execResult;
        }
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            ConnectionManager conn = getCurrentConnectionManager(connections);
            List<KeyValuePair<string, string>> connParams = (List<KeyValuePair<string, string>>)conn.AcquireConnection(transaction);

            string host = connParams.Find(t => t.Key == "Host").Value;
            string username = connParams.Find(t => t.Key == "Username").Value;
            string password = connParams.Find(t => t.Key == "Password").Value;
            int port = Convert.ToInt32(connParams.Find(t => t.Key == "Port").Value);

            SshExec exec = new SshExec(host, username);
            exec.Password = password;

            try
            {
                string stdOut = string.Empty;
                string stdErr = string.Empty;
                exec.Connect();
                StringReader sr = new StringReader(_commandText);
                while (true)
                {
                    string s = sr.ReadLine();
                    if (s != null && stdErr.Trim().Length == 0)
                    {
                        int res = exec.RunCommand(s, ref stdOut, ref stdErr);
                    }
                    else
                    {
                        if (stdErr.Trim().Length > 0)
                        {
                            fireError(componentEvents, stdErr);
                            return DTSExecResult.Failure;
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                fireError(componentEvents, ex.Message);
                return DTSExecResult.Failure;
            }
            finally
            {
                exec.Close();
            }
            return DTSExecResult.Success;
        }
        public override DTSExecResult Execute(Connections connections,
                                              VariableDispenser variableDispenser,
                                              IDTSComponentEvents componentEvents,
                                              IDTSLogging log,
                                              object transaction)
        {
            //return base.Execute(connections, variableDispenser, componentEvents, log, transaction);
            Server catalogServer = new Server(ServerName);
            IntegrationServices integrationServices = new IntegrationServices(catalogServer);
            Catalog             catalog             = integrationServices.Catalogs[PackageCatalog];
            CatalogFolder       catalogFolder       = catalog.Folders[PackageFolder];
            ProjectInfo         catalogProject      = catalogFolder.Projects[PackageProject];

            Microsoft.SqlServer.Management.IntegrationServices.PackageInfo catalogPackage = catalogProject.Packages[PackageName + ".dtsx"];

            catalogPackage.Execute(false, null);

            return(DTSExecResult.Success);
        }
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser,
                                              IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            try
            {
                var client  = new SlackClient();
                var message = new SlackMessage();
                message.Text     = this.Text;
                message.Username = this.User;
                client.SendMessage(message, this.WebHookUrl);
            }
            catch (Exception e)
            {
                componentEvents.FireError(0, "Slact Taks", "Error sending message to Slack. Webhook = " + WebHookUrl, "", 0);
            }

            //Always retun sucess because we do not want to fail package if we cannot send message to Slack
            //TODO: Should this be a setting?
            return(DTSExecResult.Success);
        }
Esempio n. 19
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            Debugger.Launch();

              var filesToTransfer = Directory.GetFiles(SourceDirectory, FileTypeFilter);
              WebHDFSClient client;

              if (filesToTransfer.Length == 0)
              {
            return DTSExecResult.Success;
              }

              try
              {
            ConnectionManager cm = connections[this.ConnectionManagerName];
            client = cm.AcquireConnection(transaction) as WebHDFSClient;
              }
              catch (Exception)
              {
            componentEvents.FireError(0, "HDFSTask", "Unable to create HDFS Connection Manager", "", 0);
            return DTSExecResult.Failure;
              }

              foreach (var file in filesToTransfer)
              {
            string fileName = Path.GetFileName(file);

            string remoteFileName = RemoteDirectory + "/" + fileName;

            try
            {
              client.CreateFile(file, remoteFileName).Wait();
            }
            catch (Exception)
            {
              componentEvents.FireError(0, "HDFSTask", "Unable to transfer file...", "", 0);
              return DTSExecResult.Failure;
            }
              }
              return DTSExecResult.Success;
        }
Esempio n. 20
0
 /// <summary>
 /// Overrides default validate logic, method will be called each time ssis tries to validate the package
 /// <see cref="Microsoft.SqlServer.Dts.Runtime.Task.Validate"/>
 /// </summary>
 /// <param name="connections"></param>
 /// <param name="variableDispenser"></param>
 /// <param name="componentEvents"></param>
 /// <param name="log"></param>
 /// <returns></returns>
 public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
 {
     if (string.IsNullOrEmpty(MessageText))
     {
         componentEvents.FireWarning(0, "LOG", "The message is empty!", "", 0);
     }
     else
     {
         try
         {
             GetMessageText(variableDispenser, componentEvents, MessageText);
         }
         catch (Exception ex)
         {
             componentEvents.FireError(1, "LOG", "the chosen variable cannot be read: " + ex.Message, "", 0);
             return DTSExecResult.Failure;
         }
     }
    
     return base.Validate(connections, variableDispenser, componentEvents, log);
 }
Esempio n. 21
0
        /// <summary>
        /// Validates the specified connections.
        /// </summary>
        /// <param name="connections">The connections.</param>
        /// <param name="variableDispenser">The variable dispenser.</param>
        /// <param name="componentEvents">The component events.</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            try
            {
                string sourceFile = Common.GetVariableValue<string>(this.sourceFile, variableDispenser);
                string targetFile = Common.GetVariableValue<string>(this.targetFile, variableDispenser);
                string publicKey = Common.GetVariableValue<string>(this.publicKey, variableDispenser);
                string privateKey = Common.GetVariableValue<string>(this.privateKey, variableDispenser);
                string passPhrase = Common.GetVariableValue<string>(this.passPhrase, variableDispenser);

                string errorMsg = String.Empty;
                if (String.IsNullOrEmpty(sourceFile))
                    errorMsg += " Source File,";

                if (String.IsNullOrEmpty(targetFile) || targetFile.Trim().Length == 0)
                    errorMsg += " Target File,";

                if (String.IsNullOrEmpty(publicKey) && this.fileAction != PGPFileAction.Decrypt)
                    errorMsg += " Public Key,";

                if (String.IsNullOrEmpty(privateKey) && this.fileAction != PGPFileAction.Encrypt)
                    errorMsg += " Private Key for Decryption and Encryption with signature,";

                if (String.IsNullOrEmpty(passPhrase) && this.fileAction != PGPFileAction.Encrypt)
                    errorMsg += " Pass Phrase for Decryption and Encryption with signature,\n";

                if (errorMsg.Trim().Length > 0)
                {
                    componentEvents.FireError(0, "", "Missing:" + errorMsg.Remove(errorMsg.Length - 1) + ".", "", 0);
                    return DTSExecResult.Failure;
                }
                
                return base.Validate(connections, variableDispenser, componentEvents, log);
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Validate: ", ex.Message + Environment.NewLine + ex.StackTrace, "", 0);
                return DTSExecResult.Failure;
            }
        }
Esempio n. 22
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            WinSCPWrapper p;
            SQLServerWrapper s;
            IEnumerable<RemoteFileInfo> remoteFiles;

            // connect to servers
            try
            {
                p = new WinSCPWrapper(connections[this.WinSCPConnectionManagerName], transaction);
            }
            catch (System.Exception e)
            {
                componentEvents.FireError(0, "WinSCPTask.Execute - WinSCPConnection", e.Message, "", 0);
                return DTSExecResult.Failure;
            }

            // compare remote files with local metadata; if using OLEDB - it can be tricky
            try
            {
                s = new SQLServerWrapper(connections[this.SQLServerConnectionManagerName], transaction);
            }
            catch (System.Exception e)
            {
                componentEvents.FireError(0, "WinSCPTask.Execute - SqlServerConnection", e.Message, "", 0);
                return DTSExecResult.Failure;
            }

            // get remote files
            remoteFiles = p.SearchDirectory(DirectoryPath, null, 0);
            s.SaveFilesToDatabase(remoteFiles);

            // close connections
            p.CloseSession();

            return DTSExecResult.Success;
        }
Esempio n. 23
0
        /// <summary>
        /// Executes the action based on seleted options.
        /// </summary>
        /// <param name="connections">The connections.</param>
        /// <param name="variableDispenser">The variable dispenser.</param>
        /// <param name="componentEvents">The component events.</param>
        /// <param name="log">The log.</param>
        /// <param name="transaction">The transaction.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Data Set Variable Must Contain a Valid List<ISFTPFileInfo> Object.</exception>
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            try
            {
                bool fireAgain = true;
                string _localFile = Common.GetVariableValue<string>(this.localFile, variableDispenser);
                string _remoteFile = Common.GetVariableValue<string>(this.remoteFile, variableDispenser);
                string _hostName = Common.GetVariableValue<string>(this.hostName, variableDispenser);
                int _portNumber = Common.GetVariableValue<int>(this.portNumber, variableDispenser);
                string _userName = Common.GetVariableValue<string>(this.userName, variableDispenser);
                string _passWord = Common.GetVariableValue<string>(this.passWord, variableDispenser);
                string _fileFilter = Common.GetVariableValue<string>(this.fileFilter, variableDispenser);

                List<ISFTPFileInfo> sftpFileInfo = new List<ISFTPFileInfo>();
                SFTPConnection sftp = new SFTPConnection(_hostName, _userName, _passWord, _portNumber, this.stopOnFailure, componentEvents, this.logLevel);

                if (this.fileAction == SFTPFileAction.ReceiveMultiple || this.fileAction == SFTPFileAction.SendMultiple)
                {
                    if (Common.GetVariableValue<object>(fileInfo, variableDispenser).GetType() != typeof(List<ISFTPFileInfo>))
                        throw new Exception("Data Set Variable Must Contain a Valid List<ISFTPFileInfo> Object.");
                }

                if (this.fileAction == SFTPFileAction.Send)
                {
                    List<string> fileList = Common.GetFileList(_localFile, _fileFilter, this.isRecursive);
                    foreach (string fileName in fileList)
                        sftpFileInfo.Add(new SFTPFileInfo(fileName, _remoteFile, this.overwriteDest, this.removeSource));

                    if (sftpFileInfo.Count > 0)
                        sftp.UploadFiles(sftpFileInfo);
                    else
                        componentEvents.FireInformation(1, "", "No files selected for Upload.", "", 1, ref fireAgain);
                }
                else if (this.fileAction == SFTPFileAction.SendMultiple)
                {
                    sftpFileInfo = (List<ISFTPFileInfo>)Common.GetVariableValue<object>(fileInfo, variableDispenser);
                    if (sftpFileInfo.Count > 0)
                        sftp.UploadFiles(sftpFileInfo);
                    else
                        componentEvents.FireInformation(1, "", "No files selected for Upload.", "", 1, ref fireAgain);
                }
                else if (this.fileAction == SFTPFileAction.Receive)
                {
                    List<IRemoteFileInfo> remoteFileList = sftp.ListFiles(_remoteFile);
                    remoteFileList = Common.GetRemoteFileList(remoteFileList, _fileFilter);
                    foreach (IRemoteFileInfo remoteFile in remoteFileList)
                        sftpFileInfo.Add(new SFTPFileInfo(_localFile, remoteFile.FullName, this.overwriteDest, this.removeSource));

                    if (sftpFileInfo.Count > 0)
                        sftp.DownloadFiles(sftpFileInfo);
                    else
                        componentEvents.FireInformation(1, "", "No files selected for Download.", "", 1, ref fireAgain);
                }
                else if (this.fileAction == SFTPFileAction.ReceiveMultiple)
                {
                    sftpFileInfo = (List<ISFTPFileInfo>)Common.GetVariableValue<object>(fileInfo, variableDispenser);
                    if (sftpFileInfo.Count > 0)
                        sftp.DownloadFiles(sftpFileInfo);
                    else
                        componentEvents.FireInformation(1, "", "No files selected for Download.", "", 1, ref fireAgain);
                }
                else if (this.fileAction == SFTPFileAction.List)
                {
                    List<IRemoteFileInfo> remoteFileList = sftp.ListFiles(_remoteFile);
                    Common.SetVariableValue(this.remoteFileListVariable, remoteFileList, variableDispenser);
                }
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Execute: ", ex.Message +Environment.NewLine + ex.StackTrace, "", 0);
                return DTSExecResult.Failure;
            }
            return DTSExecResult.Success;
        }
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            //SSH Connection Manager
            if (StringUtil.NullOrEmpty(_SSHconnMgrName))
            {
                fireError(componentEvents, "No SSH Connection Manager selected.");
                return DTSExecResult.Failure;
            }
            ConnectionManager cSSH = getConnectionManager(connections, _SSHconnMgrName);
            if (cSSH == null)
            {
                fireError(componentEvents, "No SSH Connection Manager selected.");
                return DTSExecResult.Failure;
            }

            //Send Files
            if (_operation == SSHFTPOperation.SendFiles)
            {
                if (StringUtil.NullOrEmpty(_sendFilesSourceConnectionManagerName))
                {
                    fireError(componentEvents, "No Send Files Source Connection Manager selected.");
                    return DTSExecResult.Failure;
                }
                ConnectionManager cSend = getConnectionManager(connections, _sendFilesSourceConnectionManagerName);
                if (cSend == null)
                {
                    fireError(componentEvents, "No Send Files Source Connection Manager selected.");
                    return DTSExecResult.Failure;
                }
                if (StringUtil.NullOrEmpty(_sendFilesDestinationDirectory))
                {
                    fireError(componentEvents, "No Send Files Destination Directory Specified.");
                    return DTSExecResult.Failure;
                }
            }

            //Receive Files
            if (_operation == SSHFTPOperation.ReceiveFiles)
            {
                if (StringUtil.NullOrEmpty(_receiveFilesDestinationConnectionManagerName))
                {
                    fireError(componentEvents, "No Receive Files Destination Connection Manager selected.");
                    return DTSExecResult.Failure;
                }
                ConnectionManager cReceive = getConnectionManager(connections, _receiveFilesDestinationConnectionManagerName);
                if (cReceive == null)
                {
                    fireError(componentEvents, "No Receive Files Destination Connection Manager selected.");
                    return DTSExecResult.Failure;
                }
                if (StringUtil.NullOrEmpty(_receiveFilesSourceFile))
                {
                    fireError(componentEvents, "No Receive Files Source File specified.");
                    return DTSExecResult.Failure;
                }
            }
            return DTSExecResult.Success;
        }
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            //initialize report execution service
            string RSExecURL = @"http://" + Server + "/ReportServer/ReportExecution2005.asmx";
            ReportExecutionService RSExec2005 = new ReportExecutionService();

            RSExec2005.Credentials = System.Net.CredentialCache.DefaultCredentials;
            RSExec2005.Url         = RSExecURL;

            //prepare variables
            byte[]    Results  = null;
            Warning[] warnings = null;
            string    encoding;
            string    mimetype;

            string[] streamids = null;
            string   extension;

            try
            {
                ExecutionInfo Info = new ExecutionInfo();
                Info = RSExec2005.LoadReport(SelectedReport, null);


                if (DtParameters != null)
                {
                    if (DtParameters.Rows.Count > 0)
                    {
                        List <Tuple <string, string> > lstParameters = new List <Tuple <string, string> >();
                        foreach (DataRow row in DtParameters.Rows)
                        {
                            if (row["ParameterValue"] != null)
                            {
                                if (!string.IsNullOrEmpty(row["ParameterValue"].ToString()))
                                {
                                    //the parameter value has to be a variable
                                    string pName = row["ParameterName"].ToString();

                                    Variables varPValue = null;
                                    variableDispenser.LockOneForRead(row["ParameterValue"].ToString(), ref varPValue);
                                    string pValue = varPValue[0].Value.ToString();

                                    lstParameters.Add(Tuple.Create(pName, pValue));
                                }
                            }
                        }

                        ParameterValue[] Parameters;
                        if (lstParameters.Count > 0)
                        {
                            Parameters = new ParameterValue[lstParameters.Count];

                            for (int i = 0; i < lstParameters.Count; i++)
                            {
                                Parameters[i]       = new ParameterValue();
                                Parameters[i].Name  = lstParameters[i].Item1;
                                Parameters[i].Value = lstParameters[i].Item2;
                            }

                            RSExec2005.SetExecutionParameters(Parameters, "en-us");
                        }
                    }
                }

                //output format and name
                Variables varFileFormat = null;
                variableDispenser.LockOneForRead(FileFormat, ref varFileFormat);

                Variables varFileName = null;
                variableDispenser.LockOneForRead(FileName, ref varFileName);

                Results = RSExec2005.Render(varFileFormat[0].Value.ToString(), null, out extension, out mimetype, out encoding, out warnings, out streamids);
                Info    = RSExec2005.GetExecutionInfo();

                FileStream FS = File.Create(varFileName[0].Value.ToString(), Results.Length);
                FS.Write(Results, 0, Results.Length);
                FS.Close();

                return(DTSExecResult.Success);
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Reporting Service Task", "Task Error: " + ex.ToString(), "", -1);
                return(DTSExecResult.Failure);
            }
        }
Esempio n. 26
0
        /// <summary>
        /// This method is a run-time method executed dtsexec.exe
        /// </summary>
        /// <param name="connections"></param>
        /// <param name="variableDispenser"></param>
        /// <param name="componentEvents"></param>
        /// <param name="log"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            bool refire = false;

            GetNeededVariables(variableDispenser, HttpSourceFile);
            GetNeededVariables(variableDispenser, LocalDestinationFile);

            componentEvents.FireInformation(0,
                                            "SSISDownloadFileTask",
                                            string.Format("Source File: \"{0}\", Destination File \"{1}\"",
                                                          EvaluateExpression(HttpSourceFile, variableDispenser),
                                                          EvaluateExpression(LocalDestinationFile, variableDispenser)),
                                            string.Empty,
                                            0,
                                            ref refire);

            try
            {
                componentEvents.FireInformation(0,
                                                "SSISDownloadFileTask",
                                                "Prepare variables",
                                                string.Empty,
                                                0,
                                                ref refire);

                componentEvents.FireInformation(0,
                                                "SSISDownloadFileTask",
                                                DownloadFile(connections, variableDispenser, componentEvents)
                                                    ? "The file has been downloaded successfully."
                                                    : "The file has NOT been downloaded.",
                                                string.Empty,
                                                0,
                                                ref refire);
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0,
                                          "SSISDownloadFileTask",
                                          string.Format("Problem: {0}",
                                                        ex.Message),
                                          "",
                                          0);
            }
            finally
            {
                if (_vars.Locked)
                {
                    _vars.Unlock();
                }
            }

            return(base.Execute(connections, variableDispenser, componentEvents, log, transaction));
        }
Esempio n. 27
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            if (this._interval <= 0)
            {
                componentEvents.FireError(0, "", "Pause length must be greater than 0.", "", 0);
                return(DTSExecResult.Failure);
            }

            return(DTSExecResult.Success);
        }
        /// <summary>
        /// Validate local parameter
        /// </summary>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            var isBaseValid = true;

            if (base.Validate(connections, variableDispenser, componentEvents, log) != DTSExecResult.Success)
            {
                componentEvents.FireError(0, "ReportGeneratorTask", "Base validation failed", "", 0);
                isBaseValid = false;
            }
            if (string.IsNullOrEmpty(Filename))
            {
                componentEvents.FireError(0, "ReportGeneratorTask", "A file name is required.", "", 0);
                isBaseValid = false;
            }
            if (string.IsNullOrEmpty(Recordset) && ReportType == "Dataset Report")
            {
                componentEvents.FireError(0, "ReportGeneratorTask", "A recordset is required.", "", 0);
                isBaseValid = false;
            }
            if (string.IsNullOrEmpty(Reportname))
            {
                componentEvents.FireError(0, "ReportGeneratorTask", "A Reportname is required.", "", 0);
                isBaseValid = false;
            }
            if (string.IsNullOrEmpty(Datasetname) && ReportType == "Dataset Report")
            {
                componentEvents.FireError(0, "ReportGeneratorTask", "A Datasetname is required.", "", 0);
                isBaseValid = false;
            }
            if (ReportType != "Dataset Report")
            {
                if (!WindowsAuthorization)
                {
                    if (string.IsNullOrEmpty(Username))
                    {
                        componentEvents.FireError(0, "ReportGeneratorTask", "A Username is required.", "", 0);
                        isBaseValid = false;
                    }
                    if (string.IsNullOrEmpty(Password))
                    {
                        componentEvents.FireError(0, "ReportGeneratorTask", "A Password is required.", "", 0);
                        isBaseValid = false;
                    }
                }
            }

            return(isBaseValid ? DTSExecResult.Success : DTSExecResult.Failure);
        }
Esempio n. 29
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            bool pass = true;

              if (string.IsNullOrWhiteSpace(SourceDirectory))
              {
            componentEvents.FireError(0, "HDFSTask", "Source Directoy value not specfied", "", 0);
            pass = false;
              }
              if (string.IsNullOrWhiteSpace(RemoteDirectory))
              {
            componentEvents.FireError(0, "HDFSTask", "Remote Directoy value not specfied", "", 0);
            pass = false;
              }
              if (string.IsNullOrWhiteSpace(FileTypeFilter))
              {
            componentEvents.FireError(0, "HDFSTask", "No filetype filter specified.", "", 0);
            pass = false;
              }

              try
              {
            var cm = connections[ConnectionManagerName];
            if ((cm.InnerObject as SSISHDFS.HDFSConnectionManager.HDFSConnectionManager) == null)
            {
              componentEvents.FireError(0, "HDFSTask", "No HDFS Connection Manager specfied", "", 0);
              pass = false;
            }
              }
              catch (Exception)
              {
            componentEvents.FireError(0, "HDFSTask", "No HDFS Connection Manager specfied", "", 0);
            pass = false;
              }

              if (pass)
              {
            return DTSExecResult.Success;
              }
              else
              {
            return DTSExecResult.Failure;
              }
        }
Esempio n. 30
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            if (_typeOperation == Type_Operation.Please_Select)
            {
                componentEvents.FireError(1, "UnZip SSIS", "Please select type operation (De/Compress).", null, 0);
                return(DTSExecResult.Failure);
            }

            if (_typeOperation == Type_Operation.Compress)
            {
                if ((string.IsNullOrEmpty(_fileZip)) || (string.IsNullOrEmpty(_folderSource)))
                {
                    componentEvents.FireError(1, "UnZip SSIS", "Please select Source Folder and Zip File.", null, 0);
                    return(DTSExecResult.Failure);
                }
            }
            else
            {
                if ((string.IsNullOrEmpty(_fileZip)) || (string.IsNullOrEmpty(_folderSource)) || (string.IsNullOrEmpty(_folderDest)))
                {
                    componentEvents.FireError(1, "UnZip SSIS", "Please select Source Folder, Zip File and Destination Folder.", null, 0);
                    return(DTSExecResult.Failure);
                }
            }
            return(DTSExecResult.Success);
        }
 public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log) {
     return (
         connections.Contains(ConnectionName)
         ) ? DTSExecResult.Success : DTSExecResult.Failure;
 }
Esempio n. 32
0
 public DTSExecResult Validate(Connections connections, Variables variables, IDTSEvents events, IDTSLogging log)
 {
     return Package.Validate(connections, variables, events, log);
 }
        /// <summary>
        /// Validate local parameters
        /// </summary>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            bool isBaseValid = true;

            if (base.Validate(connections, variableDispenser, componentEvents, log) != DTSExecResult.Success)
            {
                componentEvents.FireError(0, "SSISWebServiceTask", "Base validation failed", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(ServiceUrl))
            {
                componentEvents.FireError(0, "SSISWebServiceTask", "An URL is required.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(Service))
            {
                componentEvents.FireError(0, "SSISWebServiceTask", "A service name is required.", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(WebMethod))
            {
                componentEvents.FireError(0, "SSISWebServiceTask", "A WebMethod name is required.", "", 0);
                isBaseValid = false;
            }

            return(isBaseValid ? DTSExecResult.Success : DTSExecResult.Failure);
        }
        /// <summary>
        /// This method is a run-time method executed dtsexec.exe
        /// </summary>
        /// <param name="connections"></param>
        /// <param name="variableDispenser"></param>
        /// <param name="componentEvents"></param>
        /// <param name="log"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            bool refire = false;

            componentEvents.FireInformation(0,
                                            "SSISWebServiceTask",
                                            "Prepare variables",
                                            string.Empty,
                                            0,
                                            ref refire);

            GetNeededVariables(variableDispenser, componentEvents);

            try
            {
                componentEvents.FireInformation(0,
                                                "SSISWebServiceTask",
                                                string.Format("Initialize WebService: {0}", EvaluateExpression(ServiceUrl, variableDispenser)),
                                                string.Empty,
                                                0,
                                                ref refire);
                object[] result;
                using (var wsdlHandler = new WSDLHandler(new Uri(EvaluateExpression(ServiceUrl, variableDispenser).ToString())))
                {
                    componentEvents.FireInformation(0,
                                                    "SSISWebServiceTask",
                                                    string.Format("InvokeRemoteMethod: {0}=>{1}",
                                                                  EvaluateExpression(Service, variableDispenser),
                                                                  EvaluateExpression(WebMethod, variableDispenser)),
                                                    string.Empty,
                                                    0,
                                                    ref refire);

                    result = wsdlHandler.InvokeRemoteMethod <object>(EvaluateExpression(Service, variableDispenser).ToString(),
                                                                     EvaluateExpression(WebMethod, variableDispenser).ToString(),
                                                                     (from parameters in ((MappingParams)MappingParams)
                                                                      select EvaluateExpression(parameters.Value, variableDispenser)).ToArray());
                }

                if (result != null)
                {
                    if (IsValueReturned == "1")
                    {
                        componentEvents.FireInformation(0,
                                                        "SSISWebServiceTask",
                                                        string.Format("Get the Returned Value to: {0}", ReturnedValue),
                                                        string.Empty,
                                                        0,
                                                        ref refire);

                        string val = ReturnedValue.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[1].Trim();

                        componentEvents.FireInformation(0,
                                                        "SSISWebServiceTask",
                                                        string.Format("Get the Returned Value to {0} and convert to {1}",
                                                                      val.Substring(0, val.Length - 1),
                                                                      _vars[val.Substring(0, val.Length - 1)].DataType),
                                                        string.Empty,
                                                        0,
                                                        ref refire);

                        _vars[val.Substring(0, val.Length - 1)].Value = Convert.ChangeType(result[0], _vars[val.Substring(0, val.Length - 1)].DataType);

                        componentEvents.FireInformation(0,
                                                        "SSISWebServiceTask",
                                                        string.Format("The String Result is {0} ",
                                                                      _vars[val.Substring(0, val.Length - 1)].Value),
                                                        string.Empty,
                                                        0,
                                                        ref refire);
                    }
                    else
                    {
                        componentEvents.FireInformation(0,
                                                        "SSISWebServiceTask",
                                                        "Execution without return or no associated return variable",
                                                        string.Empty,
                                                        0,
                                                        ref refire);
                    }
                }
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0,
                                          "SSISWebServiceTask",
                                          string.Format("Problem: {0}",
                                                        ex.Message + "\n" + ex.StackTrace),
                                          "",
                                          0);
            }
            finally
            {
                if (_vars.Locked)
                {
                    _vars.Unlock();
                }
            }

            return(base.Execute(connections, variableDispenser, componentEvents, log, transaction));
        }
Esempio n. 35
0
        /// <summary>
        /// Validates the specified connections.
        /// </summary>
        /// <param name="connections">The connections.</param>
        /// <param name="variableDispenser">The variable dispenser.</param>
        /// <param name="componentEvents">The component events.</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            try
            {
                string _localFile = Common.GetVariableValue<string>(this.localFile, variableDispenser);
                string _remoteFile = Common.GetVariableValue<string>(this.remoteFile, variableDispenser);
                string _hostName = Common.GetVariableValue<string>(this.hostName, variableDispenser);
                string _portNumber = Common.GetVariableValue<string>(this.portNumber, variableDispenser);
                string _userName = Common.GetVariableValue<string>(this.userName, variableDispenser);
                string _passWord = Common.GetVariableValue<string>(this.passWord, variableDispenser);
                string _fileListVar = Common.GetVariableValue<string>(this.remoteFileListVariable, variableDispenser);
                TypeCode _fileListVarType = Common.GetVariableType(this.remoteFileListVariable, variableDispenser);
                string _fileInfoVar = Common.GetVariableValue<string>(this.fileInfo, variableDispenser);
                TypeCode _fileInfoType = Common.GetVariableType(this.fileInfo, variableDispenser);

                string errorMsg = String.Empty;

                if (String.IsNullOrEmpty(_hostName))
                    errorMsg += " Host Name,";

                if (String.IsNullOrEmpty(_portNumber))
                    errorMsg += " Port Number,";
                else
                {
                    int p;
                    if (Int32.TryParse(_portNumber, out p) == false)
                        errorMsg += " Port Number(must be a valid integer),";
                }

                if (String.IsNullOrEmpty(_userName))
                    errorMsg += " User Name,";

                if (String.IsNullOrEmpty(_passWord))
                    errorMsg += " Password,";

                if (String.IsNullOrEmpty(_localFile) && (this.fileAction == SFTPFileAction.Send || this.fileAction == SFTPFileAction.Receive))
                    errorMsg += " Local File,";

                if (String.IsNullOrEmpty(_remoteFile) && (this.fileAction == SFTPFileAction.Send || this.fileAction == SFTPFileAction.Receive || this.fileAction == SFTPFileAction.List))
                    errorMsg += " Remote File,";
                
                if (this.fileAction == SFTPFileAction.List && String.IsNullOrEmpty(_fileListVar))
                    errorMsg += " Result Variable,";
                else if (this.fileAction == SFTPFileAction.List && _fileListVarType != TypeCode.Object)
                    errorMsg += " Result Variable(must be of type Object),";

                if (this.fileAction == SFTPFileAction.SendMultiple || this.fileAction == SFTPFileAction.ReceiveMultiple)
                {
                    if (String.IsNullOrEmpty(_fileInfoVar))
                        errorMsg += " Data Set Variable,";
                    else if (_fileInfoType != TypeCode.Object)
                        errorMsg += " Data Set Variable(must be of type Object),";
                }

                if (errorMsg.Trim().Length > 0)
                {
                    componentEvents.FireError(0, "", "Missing:" + errorMsg.Remove(errorMsg.Length - 1) + ".", "", 0);
                    return DTSExecResult.Failure;
                }
                
                return base.Validate(connections, variableDispenser, componentEvents, log);
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Validate: ", ex.Message + Environment.NewLine + ex.StackTrace, "", 0);
                return DTSExecResult.Failure;
            }
        }
Esempio n. 36
0
        /// <summary>
        /// Validate local parameters
        /// </summary>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            bool isBaseValid = true;

            if (base.Validate(connections, variableDispenser, componentEvents, log) != DTSExecResult.Success)
            {
                componentEvents.FireError(0, "SSISPowerShellTask", "Base validation failed", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(PowerShellScript))
            {
                componentEvents.FireError(0, "SSISPowerShellTask", "Input PowerShell script is missing.", "", 0);
                isBaseValid = false;
            }

            /*else if (string.IsNullOrEmpty(OutputVariableName))
             * {
             *  componentEvents.FireError(0, "SSISPowerShellTask", "Output variable specified.", "", 0);
             *  isBaseValid = false;
             * }*/

            return(isBaseValid ? DTSExecResult.Success : DTSExecResult.Failure);
        }
Esempio n. 37
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            try
            {
                ConnectionManager cmW = connections[this.WinSCPConnectionManagerName];
                //return DTSExecResult.Success;
            }
            catch (System.Exception e)
            {
                componentEvents.FireError(0, "WinSCPTask", "Invalid WinSCP connection manager. " + e.Message, "", 0);
                return DTSExecResult.Failure;
            }

            try
            {
                ConnectionManager cmS = connections[this.SQLServerConnectionManagerName];
            }
            catch (System.Exception e)
            {
                componentEvents.FireError(0, "WinSCPTask", "Invalid SQL Server connection manager. " + e.Message, "", 0);
                return DTSExecResult.Failure;
            }

            return DTSExecResult.Success;
        }
Esempio n. 38
0
 /// <summary>
 /// Executes the specified action based on settings.
 /// </summary>
 /// <param name="connections">The connections.</param>
 /// <param name="variableDispenser">The variable dispenser.</param>
 /// <param name="componentEvents">The component events.</param>
 /// <param name="log">The log.</param>
 /// <param name="transaction">The transaction.</param>
 /// <returns></returns>
 public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
 {
     try
     {
         string _sourceFile = Common.GetVariableValue<string>(this.sourceFile, variableDispenser);
         string _targetFile = Common.GetVariableValue<string>(this.targetFile, variableDispenser);
         string _password = Common.GetVariableValue<string>(this.zipPassword, variableDispenser);
         string _fileFilter = Common.GetVariableValue<string>(this.fileFilter, variableDispenser);
 
         if (this.compressionType == CompressionType.Zip)
         {
             ZipManager zipManager = new ZipManager(_sourceFile, _targetFile,this.zipCompressionLevel, _password, this.recursive, _fileFilter, this.removeSource, this.overwriteTarget, this.logLevel, componentEvents);
             if (this.fileAction == ZipFileAction.Compress)
                 zipManager.Zip();
             else if (this.fileAction == ZipFileAction.Decompress)
                 zipManager.UnZip();
         }
         else if (this.compressionType == CompressionType.Tar)
         {
             TarManager tarManager = new TarManager(_sourceFile, _targetFile, this.tarCompressionLevel, _password, this.recursive, this.removeSource, this.overwriteTarget, this.logLevel, componentEvents);
             if (this.fileAction == ZipFileAction.Compress)
                 tarManager.Compress();
             else if (this.fileAction == ZipFileAction.Decompress)
                 tarManager.Decompress();
         }
     }
     catch (Exception ex)
     {
         componentEvents.FireError(0, "Execute: ", ex.Message + Environment.NewLine + ex.StackTrace, "", 0);
         return DTSExecResult.Failure;
     }
     return DTSExecResult.Success;
 }
Esempio n. 39
0
        /// <summary>
        /// Executes the action based on seleted options.
        /// </summary>
        /// <param name="connections">The connections.</param>
        /// <param name="variableDispenser">The variable dispenser.</param>
        /// <param name="componentEvents">The component events.</param>
        /// <param name="log">The log.</param>
        /// <param name="transaction">The transaction.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Data Set Variable Must Contain a Valid List<ISFTPFileInfo> Object.</exception>
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            try
            {
                bool   fireAgain   = true;
                string _localFile  = Common.GetVariableValue <string>(this.localFile, variableDispenser);
                string _remoteFile = Common.GetVariableValue <string>(this.remoteFile, variableDispenser);
                string _hostName   = Common.GetVariableValue <string>(this.hostName, variableDispenser);
                int    _portNumber = Common.GetVariableValue <int>(this.portNumber, variableDispenser);
                string _userName   = Common.GetVariableValue <string>(this.userName, variableDispenser);
                string _passWord   = Common.GetVariableValue <string>(this.passWord, variableDispenser);
                string _fileFilter = Common.GetVariableValue <string>(this.fileFilter, variableDispenser);

                List <ISFTPFileInfo> sftpFileInfo = new List <ISFTPFileInfo>();
                SFTPConnection       sftp         = new SFTPConnection(_hostName, _userName, _passWord, _portNumber, this.stopOnFailure, componentEvents, this.logLevel);

                if (this.fileAction == SFTPFileAction.ReceiveMultiple || this.fileAction == SFTPFileAction.SendMultiple)
                {
                    if (Common.GetVariableValue <object>(fileInfo, variableDispenser).GetType() != typeof(List <ISFTPFileInfo>))
                    {
                        throw new Exception("Data Set Variable Must Contain a Valid List<ISFTPFileInfo> Object.");
                    }
                }

                if (this.fileAction == SFTPFileAction.Send)
                {
                    List <string> fileList = Common.GetFileList(_localFile, _fileFilter, this.isRecursive);
                    foreach (string fileName in fileList)
                    {
                        sftpFileInfo.Add(new SFTPFileInfo(fileName, _remoteFile, this.overwriteDest, this.removeSource));
                    }

                    if (sftpFileInfo.Count > 0)
                    {
                        sftp.UploadFiles(sftpFileInfo);
                    }
                    else
                    {
                        componentEvents.FireInformation(1, "", "No files selected for Upload.", "", 1, ref fireAgain);
                    }
                }
                else if (this.fileAction == SFTPFileAction.SendMultiple)
                {
                    sftpFileInfo = (List <ISFTPFileInfo>)Common.GetVariableValue <object>(fileInfo, variableDispenser);
                    if (sftpFileInfo.Count > 0)
                    {
                        sftp.UploadFiles(sftpFileInfo);
                    }
                    else
                    {
                        componentEvents.FireInformation(1, "", "No files selected for Upload.", "", 1, ref fireAgain);
                    }
                }
                else if (this.fileAction == SFTPFileAction.Receive)
                {
                    List <IRemoteFileInfo> remoteFileList = sftp.ListFiles(_remoteFile);
                    remoteFileList = Common.GetRemoteFileList(remoteFileList, _fileFilter);
                    foreach (IRemoteFileInfo remoteFile in remoteFileList)
                    {
                        sftpFileInfo.Add(new SFTPFileInfo(_localFile, remoteFile.FullName, this.overwriteDest, this.removeSource));
                    }

                    if (sftpFileInfo.Count > 0)
                    {
                        sftp.DownloadFiles(sftpFileInfo);
                    }
                    else
                    {
                        componentEvents.FireInformation(1, "", "No files selected for Download.", "", 1, ref fireAgain);
                    }
                }
                else if (this.fileAction == SFTPFileAction.ReceiveMultiple)
                {
                    sftpFileInfo = (List <ISFTPFileInfo>)Common.GetVariableValue <object>(fileInfo, variableDispenser);
                    if (sftpFileInfo.Count > 0)
                    {
                        sftp.DownloadFiles(sftpFileInfo);
                    }
                    else
                    {
                        componentEvents.FireInformation(1, "", "No files selected for Download.", "", 1, ref fireAgain);
                    }
                }
                else if (this.fileAction == SFTPFileAction.List)
                {
                    List <IRemoteFileInfo> remoteFileList = sftp.ListFiles(_remoteFile);
                    Common.SetVariableValue(this.remoteFileListVariable, remoteFileList, variableDispenser);
                }
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Execute: ", ex.Message + Environment.NewLine + ex.StackTrace, "", 0);
                return(DTSExecResult.Failure);
            }
            return(DTSExecResult.Success);
        }
Esempio n. 40
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            bool b = false;

            componentEvents.FireInformation(1, "UnZip SSIS", "Start 1", null, 0, ref b);

            componentEvents.FireInformation(1, "UnZip SSIS", "Start process file: '" + _folderDest + _fileZip + "'.", null, 0, ref b);

            if (_typeOperation == Type_Operation.Please_Select)
            {
                componentEvents.FireError(1, "UnZip SSIS", "Please select type operation (De/Compress).", null, 0);
                throw new Exception("Please select type operation (De/Compress).");
            }

            ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();

            if (!_folderSource.EndsWith("\\"))
            {
                _folderSource = _folderSource + "\\";
            }
            if (!_folderDest.EndsWith("\\"))
            {
                _folderDest = _folderDest + "\\";
            }

            if (!string.IsNullOrEmpty(_password))
            {
                fz.Password = _password;
            }

            try
            {
                if (!System.IO.Directory.Exists(_folderDest))
                {
                    componentEvents.FireInformation(1, "UnZip SSIS", "Create Folder: '" + _folderDest + "'.", null, 0, ref b);
                    System.IO.Directory.CreateDirectory(_folderDest);
                }

                if (_typeOperation == Type_Operation.Compress)
                {
                    fz.CreateZip(_folderDest + _fileZip, _folderSource, _Recurse, _FileFilter);

                    if ((_testarchive) || (!string.IsNullOrEmpty(_comment)))
                    {
                        ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile(_folderDest + _fileZip);

                        if (_testarchive)
                        {
                            componentEvents.FireInformation(1, "UnZip SSIS", "Start verify file ZIP (" + _fileZip + ")", null, 0, ref b);
                            if (!zipFile.TestArchive(true))
                            {
                                throw new Exception("Verify file zip: " + _fileZip + " failed.");
                            }
                        }

                        if (!string.IsNullOrEmpty(_comment))
                        {
                            componentEvents.FireInformation(1, "UnZip SSIS", "Set Comment.", null, 0, ref b);
                            zipFile.BeginUpdate();
                            zipFile.SetComment(_comment);
                            zipFile.CommitUpdate();
                        }
                    }
                }
                else
                {
                    if (_testarchive)
                    {
                        ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile(_folderSource + _fileZip);

                        componentEvents.FireInformation(1, "UnZip SSIS", "Start verify file ZIP (" + _fileZip + ")", null, 0, ref b);

                        if (!zipFile.TestArchive(true))
                        {
                            throw new Exception("Verify file zip: " + _fileZip + " failed.");
                        }
                    }

                    fz.ExtractZip(_folderSource + _fileZip, _folderDest, _FileFilter);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            componentEvents.FireInformation(1, "UnZip SSIS", "End process file: '" + _folderDest + _fileZip + "'.", null, 0, ref b);

            return(DTSExecResult.Success);
        }
Esempio n. 41
0
        /// <summary>
        /// Validates the specified connections.
        /// </summary>
        /// <param name="connections">The connections.</param>
        /// <param name="variableDispenser">The variable dispenser.</param>
        /// <param name="componentEvents">The component events.</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            try
            {
                string   _localFile       = Common.GetVariableValue <string>(this.localFile, variableDispenser);
                string   _remoteFile      = Common.GetVariableValue <string>(this.remoteFile, variableDispenser);
                string   _hostName        = Common.GetVariableValue <string>(this.hostName, variableDispenser);
                string   _portNumber      = Common.GetVariableValue <string>(this.portNumber, variableDispenser);
                string   _userName        = Common.GetVariableValue <string>(this.userName, variableDispenser);
                string   _passWord        = Common.GetVariableValue <string>(this.passWord, variableDispenser);
                string   _fileListVar     = Common.GetVariableValue <string>(this.remoteFileListVariable, variableDispenser);
                TypeCode _fileListVarType = Common.GetVariableType(this.remoteFileListVariable, variableDispenser);
                string   _fileInfoVar     = Common.GetVariableValue <string>(this.fileInfo, variableDispenser);
                TypeCode _fileInfoType    = Common.GetVariableType(this.fileInfo, variableDispenser);

                string errorMsg = String.Empty;

                if (String.IsNullOrEmpty(_hostName))
                {
                    errorMsg += " Host Name,";
                }

                if (String.IsNullOrEmpty(_portNumber))
                {
                    errorMsg += " Port Number,";
                }
                else
                {
                    int p;
                    if (Int32.TryParse(_portNumber, out p) == false)
                    {
                        errorMsg += " Port Number(must be a valid integer),";
                    }
                }

                if (String.IsNullOrEmpty(_userName))
                {
                    errorMsg += " User Name,";
                }

                if (String.IsNullOrEmpty(_passWord))
                {
                    errorMsg += " Password,";
                }

                if (String.IsNullOrEmpty(_localFile) && (this.fileAction == SFTPFileAction.Send || this.fileAction == SFTPFileAction.Receive))
                {
                    errorMsg += " Local File,";
                }

                if (String.IsNullOrEmpty(_remoteFile) && (this.fileAction == SFTPFileAction.Send || this.fileAction == SFTPFileAction.Receive || this.fileAction == SFTPFileAction.List))
                {
                    errorMsg += " Remote File,";
                }

                if (this.fileAction == SFTPFileAction.List && String.IsNullOrEmpty(_fileListVar))
                {
                    errorMsg += " Result Variable,";
                }
                else if (this.fileAction == SFTPFileAction.List && _fileListVarType != TypeCode.Object)
                {
                    errorMsg += " Result Variable(must be of type Object),";
                }

                if (this.fileAction == SFTPFileAction.SendMultiple || this.fileAction == SFTPFileAction.ReceiveMultiple)
                {
                    if (String.IsNullOrEmpty(_fileInfoVar))
                    {
                        errorMsg += " Data Set Variable,";
                    }
                    else if (_fileInfoType != TypeCode.Object)
                    {
                        errorMsg += " Data Set Variable(must be of type Object),";
                    }
                }

                if (errorMsg.Trim().Length > 0)
                {
                    componentEvents.FireError(0, "", "Missing:" + errorMsg.Remove(errorMsg.Length - 1) + ".", "", 0);
                    return(DTSExecResult.Failure);
                }

                return(base.Validate(connections, variableDispenser, componentEvents, log));
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Validate: ", ex.Message + Environment.NewLine + ex.StackTrace, "", 0);
                return(DTSExecResult.Failure);
            }
        }
Esempio n. 42
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            System.Threading.Thread.Sleep(this._interval * 60000);

            return(DTSExecResult.Success);
        }
Esempio n. 43
0
 public override void InitializeTask(Connections connections, VariableDispenser variableDispenser, IDTSInfoEvents events, IDTSLogging log, EventInfos eventInfos, LogEntryInfos logEntryInfos, ObjectReferenceTracker refTracker)
 {
     base.InitializeTask(connections, variableDispenser, events, log, eventInfos, logEntryInfos, refTracker);
 }
        /// <summary>
        /// This method is called at runtime, and does all the "work".
        /// </summary>
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            _localname = Localname();

            if (ReportType == "Dataset Report")
            {
                Variables vars  = null;
                var       oleda = new System.Data.OleDb.OleDbDataAdapter();
                var       dt    = new DataTable(Datasetname);
                variableDispenser.LockForRead(Recordset);
                variableDispenser.GetVariables(ref vars);
                componentEvents.FireInformation(0, "ReportGenerator", "Filename: " + _localname, string.Empty, 0, ref _refire);
                try
                {
                    //var rv = new ReportViewer {ProcessingMode = ProcessingMode.Local};
                    var val = vars[Recordset].Value;
                    oleda.Fill(dt, val);
                    componentEvents.FireInformation(0, "ReportGenerator", "Starts report generation with " + dt.Rows.Count + " rows", string.Empty, 0, ref _refire);
                    Run(Reportname, Datasetname, dt, _localname);
                    componentEvents.FireInformation(0, "ReportGenerator", "The report was created.", string.Empty, 0, ref _refire);

                    //Warning: debugmode is a user defined option.
                    if (DebugMode)
                    {
                        componentEvents.FireInformation(0, "ReportGenerator", "Satrts local report generation", string.Empty, 0, ref _refire);
                        var localReport = new ReportViewerUi
                        {
                            Datasetname = Datasetname,
                            Data        = dt,
                            Reportname  = Reportname
                        };
                        localReport.ShowDialog();
                    }
                }
                catch (Exception ex)
                {
                    componentEvents.FireError(0, "ReportGeneratorTask", ex.ToString(), "", 0);
                }
                finally
                {
                    if (vars.Locked)
                    {
                        vars.Unlock();
                    }
                }
            }
            else
            {
                GenerateServerReport(variableDispenser, componentEvents);
            }


            // set prefixfilename to variable
            if (!string.IsNullOrEmpty(PrefixFilename) && PrefixFilename != "Choose a Variable")
            {
                SetPrefixFilename(variableDispenser, componentEvents);
            }

            return(base.Execute(connections, variableDispenser, componentEvents, log, transaction));
        }
Esempio n. 45
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            DTSExecResult execResult = DTSExecResult.Success;

            System.Windows.Forms.MessageBox.Show(this.displayText);

            return(execResult);
        }
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            DTSExecResult Result = base.Validate(connections, variableDispenser, componentEvents, log);

            if (Result == DTSExecResult.Success)
            {
                if (string.IsNullOrEmpty(Server))
                {
                    componentEvents.FireError(0, "Reporting Service Execution Task", "Missing configuration value - Report Server", "", 0);
                    return(DTSExecResult.Failure);
                }

                if (string.IsNullOrEmpty(SelectedReport))
                {
                    componentEvents.FireError(0, "Reporting Service Execution Task", "Missing configuration value - Selected Report", "", 0);
                    return(DTSExecResult.Failure);
                }

                if (string.IsNullOrEmpty(FileFormat))
                {
                    componentEvents.FireError(0, "Reporting Service Execution Task", "Missing configuration value - Output File Format", "", 0);
                    return(DTSExecResult.Failure);
                }

                if (string.IsNullOrEmpty(FileName))
                {
                    componentEvents.FireError(0, "Reporting Service Execution Task", "Missing configuration value - Output File Name", "", 0);
                    return(DTSExecResult.Failure);
                }
            }

            return(DTSExecResult.Success);
        }
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            try
            {
                string commandText = null;

                ReadVariables(variableDispenser);
                //DbConnection connection = connections[_connectionName].AcquireConnection(transaction) as DbConnection;
                //SqlConnection connection = (SqlConnection)connections[_connectionName].AcquireConnection(transaction);
                DbCommand command = null;

                //using (SqlCommand command = new SqlCommand())
                if (_connection is SqlConnection)
                {
                    commandText = @"INSERT INTO SSISLog (EventType, PackageName, TaskName, EventCode, EventDescription, PackageDuration, Host, ExecutionID, EventHandlerDateTime,UID)
                                        VALUES (@EventType, @PackageName, @TaskName, @EventCode, @EventDescription, @PackageDuration, @Host, @Executionid, @handlerdatetime,@uid)";

                    command = new SqlCommand();

                    command.Parameters.Add(new SqlParameter("@EventType", _eventType));
                    command.Parameters.Add(new SqlParameter("@PackageName", _packageName));
                    command.Parameters.Add(new SqlParameter("@TaskName", _taskName));
                    command.Parameters.Add(new SqlParameter("@EventCode", _errorCode ?? string.Empty));
                    command.Parameters.Add(new SqlParameter("@EventDescription", _errorDescription ?? string.Empty));
                    command.Parameters.Add(new SqlParameter("@PackageDuration", _packageDuration));
                    command.Parameters.Add(new SqlParameter("@Host", _machineName));
                    command.Parameters.Add(new SqlParameter("@ExecutionID", _executionid));
                    command.Parameters.Add(new SqlParameter("@handlerdatetime", _handlerdatetime));
                    command.Parameters.Add(new SqlParameter("@uid", _uid));
                }
                else if (_connection is OleDbConnection)
                {
                    commandText = @"INSERT INTO SSISLog (EventType,PackageName,TaskName,EventCode,EventDescription,PackageDuration,Host,ExecutionID,EventHandlerDateTime,UID)
                                        VALUES (?,?,?,?,?,?,?,?,?,?)";

                    command = new OleDbCommand();

                    command.Parameters.Add(new OleDbParameter("@EventType", _eventType));
                    command.Parameters.Add(new OleDbParameter("@PackageName", _packageName));
                    command.Parameters.Add(new OleDbParameter("@TaskName", _taskName));
                    command.Parameters.Add(new OleDbParameter("@EventCode", _errorCode ?? string.Empty));
                    command.Parameters.Add(new OleDbParameter("@EventDescription", _errorDescription ?? string.Empty));
                    command.Parameters.Add(new OleDbParameter("@PackageDuration", _packageDuration));
                    command.Parameters.Add(new OleDbParameter("@Host", _machineName));
                    command.Parameters.Add(new OleDbParameter("@ExecutionID", _executionid));
                    command.Parameters.Add(new OleDbParameter("@handlerdatetime", _handlerdatetime));
                    command.Parameters.Add(new OleDbParameter("@uid", _uid));
                }

                command.CommandText = commandText;
                command.CommandType = CommandType.Text;
                command.Connection  = _connection;

                command.ExecuteNonQuery();
                _connection.Close();
                return(DTSExecResult.Success);
            }
            catch (Exception exc)
            {
                componentEvents.FireError(0, "CustomLoggingTask-Execute", "Task Errored: " + exc.ToString(), "", -1);
                return(DTSExecResult.Failure);
            }
        }
Esempio n. 48
0
        /// <summary>
        /// Executes the specified actions based on settings.
        /// </summary>
        /// <param name="connections">The connections.</param>
        /// <param name="variableDispenser">The variable dispenser.</param>
        /// <param name="componentEvents">The component events.</param>
        /// <param name="log">The log.</param>
        /// <param name="transaction">The transaction.</param>
        /// <returns></returns>
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            bool fireAgain = true;
            try
            {
                string sourceFile = Common.GetVariableValue<string>(this.sourceFile, variableDispenser);
                string targetFile = Common.GetVariableValue<string>(this.targetFile, variableDispenser);
                string publicKey = Common.GetVariableValue<string>(this.publicKey, variableDispenser);
                string privateKey = Common.GetVariableValue<string>(this.privateKey, variableDispenser);
                string passPhrase = Common.GetVariableValue<string>(this.passPhrase, variableDispenser);

                if (this.fileAction == PGPFileAction.Decrypt)
                {
                    componentEvents.FireInformation(1, "", String.Format("Decrypting file [{0}] -> [{1}]", sourceFile, targetFile), "", 0, ref fireAgain);
                    PGPManager.Decrypt(sourceFile, privateKey, passPhrase, targetFile, this.overwriteTarget,this.removeSource);
                    componentEvents.FireInformation(1, "", String.Format("Successfully Decrypted file [{0}] -> [{1}]. ", sourceFile, targetFile), "", 0, ref fireAgain);
                }
                else if (this.fileAction == PGPFileAction.Encrypt)
                {
                    componentEvents.FireInformation(1, "", String.Format("Encrypting file [{0}] -> [{1}]", sourceFile, targetFile), "", 0, ref fireAgain);
                    PGPManager.Encrypt(sourceFile, publicKey, targetFile, this.overwriteTarget, this.removeSource, this.isArmored);
                    componentEvents.FireInformation(1, "", String.Format("Sucessfully Encrypted file [{0}] -> [{1}]", sourceFile, targetFile), "", 0, ref fireAgain);
                }
                else if (this.fileAction == PGPFileAction.EncryptAndSign)
                {
                    componentEvents.FireInformation(1, "", String.Format("Encrypting and Signing file [{0}] -> [{1}]", sourceFile, targetFile), "", 0, ref fireAgain);
                    PGPManager.EncryptAndSign(sourceFile, publicKey, privateKey, passPhrase, targetFile, this.overwriteTarget, this.removeSource, this.isArmored);
                    componentEvents.FireInformation(1, "", String.Format("Sucessfully Encrypted and Signed file [{0}] -> [{1}]", sourceFile, targetFile), "", 0, ref fireAgain);
                }
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Execute: ", ex.Message + Environment.NewLine + ex.StackTrace, "", 0);
                return DTSExecResult.Failure;
            }
            return DTSExecResult.Success;
        }
 public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
 {
     if (StringUtil.NullOrEmpty(_connMgrName))
     {
         fireError(componentEvents, "No Connection Manager selected.");
         return DTSExecResult.Failure;
     }
     ConnectionManager c = getCurrentConnectionManager(connections);
     if (c == null)
     {
         fireError(componentEvents, "No Connection Manager selected.");
         return DTSExecResult.Failure;
     }
     if (c.Properties["Host"].GetValue(c) == null)
     {
         fireError(componentEvents, "Host not configured.");
         return DTSExecResult.Failure;
     }
     if (StringUtil.NullOrEmpty(c.Properties["Host"].GetValue(c).ToString()))
     {
         fireError(componentEvents, "Host not configured.");
         return DTSExecResult.Failure;
     }
     if (c.Properties["Username"].GetValue(c) == null)
     {
         fireError(componentEvents, "Username not configured.");
         return DTSExecResult.Failure;
     }
     if (StringUtil.NullOrEmpty(c.Properties["Username"].GetValue(c).ToString()))
     {
         fireError(componentEvents, "Username not configured.");
         return DTSExecResult.Failure;
     }
     if (c.Properties["Password"].GetValue(c) == null)
     {
         fireError(componentEvents, "Password not configured.");
         return DTSExecResult.Failure;
     }
     if (StringUtil.NullOrEmpty(c.Properties["Password"].GetValue(c).ToString()))
     {
         fireError(componentEvents, "Password not configured.");
         return DTSExecResult.Failure;
     }
     return DTSExecResult.Success;
 }
Esempio n. 50
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            DTSExecResult execResult = base.Validate(connections, variableDispenser, componentEvents, log);

            if (execResult == DTSExecResult.Success)
            {
                // Validate task properties
                if (string.IsNullOrEmpty(displayText))
                {
                    componentEvents.FireWarning(1, this.GetType().Name, "Value required for DisplayText", string.Empty, 0);
                }
            }

            return(execResult);
        }
Esempio n. 51
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            try
            {
                //Azure Storage Connection
                if (_connection == null || string.IsNullOrEmpty(_connection.Trim()))
                {
                    componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Connection manager required.", null, 0);
                    return DTSExecResult.Failure;
                }

                if (validateConnection(connections, _connection) == (DtsObject)null)
                {
                    componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Invalid connection manager name.", null, 0);
                    return DTSExecResult.Failure;
                }

                //Source
                if (_source == null || string.IsNullOrEmpty(_source.Trim()))
                {
                    componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Source required", null, 0);
                    return DTSExecResult.Failure;
                }

                if (_sourceType == SourceType.FileConnection)
                {
                    var sourceConn = validateConnection(connections, _source);

                    if (sourceConn == null)
                    {
                        componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Invalid source connection manager name.", null, 0);
                        return DTSExecResult.Failure;
                    }
                }
                else if (_sourceType == SourceType.Variable)
                {
                    if (!isValidVariable(variableDispenser, _source, TypeCode.String))
                    {
                        componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Source variable must be of string data type", null, 0);
                        return DTSExecResult.Failure;
                    }
                }

                //Destination
                if (_outputDestination != DestinationType.None)
                {
                    if (_destination == null || string.IsNullOrEmpty(_destination.Trim()))
                    {
                        componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Destination required", null, 0);
                        return DTSExecResult.Failure;
                    }

                    if (_outputDestination == DestinationType.FileConnection)
                    {
                        var destConn = validateConnection(connections, _destination);

                        if (destConn == null)
                        {
                            componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Invalid destination connection manager name.", null, 0);
                            return DTSExecResult.Failure;
                        }
                    }
                    else if (_outputDestination == DestinationType.Variable)
                    {
                        if (!isValidVariable(variableDispenser, _destination, TypeCode.String))
                        {
                            componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Destination variable must be of string data type", null, 0);
                            return DTSExecResult.Failure;
                        }
                    }
                }

                //Azure ML Config
                if (_azureMLBaseURL == null || string.IsNullOrEmpty(_azureMLBaseURL.Trim()))
                {
                    componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Azure ML base url required.", null, 0);
                    return DTSExecResult.Failure;
                }

                if (_azureMLAPIKey == null || string.IsNullOrEmpty(_azureMLAPIKey.Trim()))
                {
                    componentEvents.FireError(-1, "ExecuteAzureMLBatch", "Azure ML api key required.", null, 0);
                    return DTSExecResult.Failure;
                }

                if (_mlBatchTimeout == 0)
                {
                    _mlBatchTimeout = 300;
                }

                return DTSExecResult.Success;
            }
            catch (Exception)
            {
                return DTSExecResult.Failure;
            }
        }
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            const string METHOD_NAME = "CustomLoggingTask-Validate";

            try
            {
                if (string.IsNullOrEmpty(_eventType))
                {
                    componentEvents.FireError(0, METHOD_NAME, "The event property must be specified", "", -1);
                    return(DTSExecResult.Failure);
                }

                if (string.IsNullOrEmpty(_connectionName))
                {
                    componentEvents.FireError(0, METHOD_NAME, "No connection has been specified", "", -1);
                    return(DTSExecResult.Failure);
                }

                //SqlConnection connection = connections[_connectionName].AcquireConnection(null) as SqlConnection;
                _connection = connections[_connectionName].AcquireConnection(null) as DbConnection;

                if (_connection == null)
                {
                    ConnectionManager cm = connections[_connectionName];
                    Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManagerDatabaseParameters100 cmParams = cm.InnerObject as Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManagerDatabaseParameters100;
                    _connection = cmParams.GetConnectionForSchema() as OleDbConnection;

                    if (_connection == null)
                    {
                        componentEvents.FireError(0, METHOD_NAME, "The connection is not a valid ADO.NET or OLEDB connection", "", -1);
                        return(DTSExecResult.Failure);
                    }
                }

                if (!variableDispenser.Contains("System::SourceID"))
                {
                    componentEvents.FireError(0, METHOD_NAME, "No System::SourceID variable available. This task can only be used in an Event Handler", "", -1);
                    return(DTSExecResult.Failure);
                }

                return(DTSExecResult.Success);
            }
            catch (Exception exc)
            {
                componentEvents.FireError(0, METHOD_NAME, "Validation Failed: " + exc.ToString(), "", -1);
                return(DTSExecResult.Failure);
            }
        }
Esempio n. 53
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            _componentEvents = componentEvents;
            _variableDispenser = variableDispenser;
            _connections = connections;

            _azureBlobConnectionInfo = (AzureBlobConnectionInfo)_connections[_connection].AcquireConnection(null);

            Uri uri = (Uri)null;

            if (this.InputSource != SourceType.BlobPath)
            {
                //If a blob name is specified we create one
                if (string.IsNullOrEmpty(_blobName))
                {
                    _blobName = string.Format(AZURE_ML_BLOB_NAME_FORMAT,
                        DateTime.Now.ToString("yyyyMMdd"),
                        Guid.NewGuid());
                }

                uri = UploadFile();

                if (uri == null)
                    return DTSExecResult.Failure;
            }
            else
            {
                uri = new Uri(_source);
            }

            var task = ProcessBatch(uri);
            task.Wait();

            if (task.Result != BatchScoreStatusCode.Finished)
            {
                return DTSExecResult.Failure;
            }

            return DTSExecResult.Success;
        }
Esempio n. 54
0
 public override void InitializeTask(Connections connections, VariableDispenser variableDispenser, IDTSInfoEvents events, IDTSLogging log, EventInfos eventInfos, LogEntryInfos logEntryInfos, ObjectReferenceTracker refTracker)
 {
     base.InitializeTask(connections, variableDispenser, events, log, eventInfos, logEntryInfos, refTracker);
 }
Esempio n. 55
0
        /// <summary>
        /// This method is a run-time method executed dtsexec.exe
        /// </summary>
        /// <param name="connections"></param>
        /// <param name="variableDispenser"></param>
        /// <param name="componentEvents"></param>
        /// <param name="log"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            Executing(variableDispenser, componentEvents);

            return(base.Execute(connections, variableDispenser, componentEvents, log, transaction));
        }
Esempio n. 56
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents,
                                              IDTSLogging log, object transaction)
        {
            try
            {
                using (var sftp = new Rebex.Net.Sftp())
                {
                    // connect to a server
                    sftp.Connect(HostName, ServerPort);
                    // authenticate
                    sftp.Login(LoginId, Password);

                    //sftp.Encoding = Encoding.ASCII;//.BigEndianUnicode;//.ASCII;//.Unicode;
                    sftp.TransferType = TransferType;

                    if (FtpType == FtpType.Download) //read from MFT
                    {
                        var filesToRead = sftp.GetList(InBoundFolderPath)
                                          .Where(fl => fl.Name.StartsWith(SourceFileNamePattern, StringComparison.OrdinalIgnoreCase))
                                          .Select(s => new
                        {
                            FileName     = s.Name,
                            FullFilePath = InBoundFolderPath + "/" + s.Name
                        }).ToArray();

                        if (filesToRead.Any())
                        {
                            var _downloadedFileNames = new List <string>();

                            //download the file into local folder
                            foreach (var file in filesToRead)
                            {
                                sftp.GetFiles(file.FullFilePath, LocalPath,
                                              SftpBatchTransferOptions.Default, SftpActionOnExistingFiles.OverwriteAll);
                                _downloadedFileNames.Add(file.FileName);

                                if (ReWriteFileToASCII)
                                {
                                    string from = Path.Combine(LocalPath, file.FileName);
                                    string to   = Path.Combine(LocalPath, file.FileName + "_temp");
                                    using (StreamReader reader = new StreamReader(from, System.Text.Encoding.UTF8, true, 10))
                                        using (StreamWriter writer = new StreamWriter(to, false, System.Text.Encoding.ASCII, 10))
                                        {
                                            while (reader.Peek() >= 0)
                                            {
                                                writer.WriteLine(reader.ReadLine());
                                            }
                                        }
                                    //delete old file and rename *_temp file to old file
                                    File.Delete(from);
                                    File.Move(Path.Combine(LocalPath, file.FileName + "_temp"), Path.Combine(LocalPath, file.FileName));
                                }

                                //delete the file, after download
                                if (DeleteSourceFileOnSuccess)
                                {
                                    sftp.DeleteFile(file.FullFilePath);
                                }
                            }
                            DownloadedFileNames = string.Join(",", _downloadedFileNames);
                        }
                        else
                        {
                            throw new Exception(string.Format("No file with name pattern:'{0}' found inside folder :'{1}' to download.", SourceFileNamePattern, InBoundFolderPath));
                        }
                    }
                    else //outbound -> write to MFT
                    {
                        //get file from application path
                        var filesToWrite = Directory.GetFiles(LocalPath, SourceFileNamePattern + "*");

                        if (filesToWrite.Any())
                        {
                            //upload file
                            foreach (var file in filesToWrite)
                            {
                                sftp.PutFiles(file, OutBoundFolderPath, SftpBatchTransferOptions.Default);

                                //delete the file, after upload
                                if (DeleteSourceFileOnSuccess)
                                {
                                    File.Delete(file);
                                }
                            }
                        }
                        else
                        {
                            throw new Exception(string.Format("No file with name pattern:'{0}' found inside folder :'{1}' to upload.", SourceFileNamePattern, LocalPath));
                        }
                    }
                    sftp.Disconnect();
                }
                return(DTSExecResult.Success);
            }
            catch (System.Exception e)
            {
                componentEvents.FireError(0, null, string.Format("Error using Rebex Sftp: {0}", e), null, 0);

                return(DTSExecResult.Failure);
            }
        }
Esempio n. 57
0
 public DTSExecResult Execute(Connections connections, Variables variables, IDTSEvents events, IDTSLogging log,
                              object transaction)
 {
     return Package.Execute(connections, variables, events, log, transaction);
 }
Esempio n. 58
0
 public override void InitializeTask(Connections connections, VariableDispenser variableDispenser, IDTSInfoEvents events, IDTSLogging log,
                                     EventInfos eventInfos, LogEntryInfos logEntryInfos, ObjectReferenceTracker refTracker)
 {
     //DownloadedFileNames=new List<string>();
     base.InitializeTask(connections, variableDispenser, events, log, eventInfos, logEntryInfos, refTracker);
 }
Esempio n. 59
0
 public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents,
                                        IDTSLogging log)
 {
     //return base.Validate(connections, variableDispenser, componentEvents, log);
     return(DTSExecResult.Success);
 }
Esempio n. 60
-2
        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;
            }
        }