예제 #1
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, "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);
        }
예제 #2
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;
            }
        }
예제 #3
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            bool failure = false;

            if (checkInterval <= 0)
            {
                componentEvents.FireError(0, Resources.WatForFileTaskName, Resources.ErrorCheckInterval, string.Empty, 0);
                failure = true;
            }

            if (files.Count == 0)
            {
                componentEvents.FireError(0, Resources.WaitForFileTaskName, Resources.ErrorMissingFileToCheck, string.Empty, 0);
                failure = true;
            }
            else
            {
                failure = !CheckFilesToCheck();
                if (failure)
                {
                    componentEvents.FireError(0, Resources.WaitForFileTaskName, Resources.ErrorNotValidFileToCheck, string.Empty, 0);
                }
            }


            if (failure)
            {
                return(DTSExecResult.Failure);
            }
            else
            {
                return(base.Validate(connections, variableDispenser, componentEvents, log));
            }
        }
예제 #4
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)
        {
            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);
        }
예제 #6
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);
        }
예제 #7
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);
            }
        }
예제 #8
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);
            }
        }
        /// <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);
        }
예제 #10
0
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            if (_typeCompression == Type_Compression.Please_Select)
            {
                componentEvents.FireError(1, "UnZip SSIS", "Please select type compression to use.", null, 0);
                return(DTSExecResult.Failure);
            }
            else
            {
                if (_typeCompression == Type_Compression.TAR || _typeCompression == Type_Compression.TAR_GZ)
                {
                    if (!string.IsNullOrWhiteSpace(_password) || !string.IsNullOrWhiteSpace(_comment))
                    {
                        componentEvents.FireWarning(1, "UnZip SSIS", "Archives TAR and TAR/GZ do not support option: 'Comment'.", null, 0);
                    }
                }

                if (_typeCompression == Type_Compression.TAR)
                {
                    if (_testarchive)
                    {
                        componentEvents.FireWarning(1, "UnZip SSIS", "Archives TAR do not support option: 'Verify Archive'.", null, 0);
                    }
                }
            }

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

            if (_storePaths == Store_Paths.Please_Select)
            {
                componentEvents.FireError(1, "UnZip SSIS", "Please select type Store Paths (No_Paths / Relative_Paths / Absolute_Paths).", null, 0);
                return(DTSExecResult.Failure);
            }

            if (_typeOperation == Type_Operation.Compress || _typeOperation == Type_Operation.Decompress)
            {
                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);
        }
예제 #11
0
        private void Executing(VariableDispenser variableDispenser, IDTSComponentEvents componentEvents)
        {
            bool refire = false;

            try
            {
                PowerShellCoreScripting.GetNeededVariables(variableDispenser, ref _vars, componentEvents, this);

                componentEvents.FireInformation(0, "SSISPowerShell", String.Format("Launching PowerShell Script: {0} ", EvaluateExpression(PowerShellScript, variableDispenser)), string.Empty, 0, ref refire);

                var futureDevis = System.Threading.Tasks.Task.Factory.StartNew(() => PowerShellCoreScripting.RunScript(PowerShellScript, variableDispenser));
                System.Threading.Tasks.Task.WaitAll(futureDevis);
                string retVal = futureDevis.Result.Trim();

                componentEvents.FireInformation(0, "SSISPowerShell", String.Format("Execution of PowerShell Script succeeded"), string.Empty, 0, ref refire);

                componentEvents.FireInformation(0, "SSISPowerShell", string.Format("The result: {0}", retVal), string.Empty, 0, ref refire);

                componentEvents.FireInformation(0, "SSISPowerShell", string.Format("Attach result to the output variable: {0}", OutputVariableName), string.Empty, 0, ref refire);
                string output = PowerShellCoreScripting.GetVariableFromNamespaceContext(OutputVariableName).Trim();

                try
                {
                    _vars[output].Value = retVal;
                }
                catch (Exception exception)
                {
                    componentEvents.FireError(0, "SSISPowerShell", string.Format("Error : {0}", exception.Message), "", 0);
                }
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "SSISPowerShell", string.Format("Error : {0}", ex.Message), "", 0);
            }
            finally
            {
                if (_vars != null)
                {
                    if (_vars.Locked != null)
                    {
                        if (_vars.Locked)
                        {
                            _vars.Unlock();
                        }
                    }
                }
            }
        }
        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);
            }
        }
예제 #13
0
        /// <summary>
        /// Resolves the variable placeholders in message text and returnes the resolved message
        /// Variable placeholders will be lookedup and the value will be inserted in the placeholder
        /// </summary>
        /// <param name="variableDispenser">the ssis variable dispenser to access runtime variables</param>
        /// <param name="componentEvents"></param>
        /// <param name="messageText">the message text possibly containing variable placeholder</param>
        /// <returns>returns the resolved message where all variable placeholders are replaced by their correspoding values</returns>
        public string GetMessageText(VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, string messageText)
        {
            try
            {
                if (messageText != "")
                {
                    while (messageText.Contains("@("))
                    {
                        int start = messageText.IndexOf("@(", 0);
                        int end   = messageText.IndexOf(")", start);

                        string varName = messageText.Substring(start + 2, end - start - 2);

                        messageText = messageText.Replace("@(" + varName + ")", GetValueFromVariable(variableDispenser, varName));
                    }
                }
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "", "Fehler beim Anfordern eines Variablen-Wertes: " + ex.Message, "", 0);
                throw ex;
            }

            return(messageText);
        }
예제 #14
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            if (sleepInterval > 0)
            {
                bool failure;
                while (!GetSignalledState(variableDispenser, componentEvents, log, out failure) && !failure)
                {
                    System.Threading.Thread.Sleep(sleepInterval);
                }
                if (failure)
                {
                    return(DTSExecResult.Failure);
                }
                else
                {
                    return(DTSExecResult.Success);
                }
            }
            else if (sleepInterval <= 0)
            {
                componentEvents.FireError(0, Resources.SleepTaskName, Resources.ErrorSleepInterval, string.Empty, 0);
                return(DTSExecResult.Failure);
            }

            return(base.Execute(connections, variableDispenser, componentEvents, log, transaction));
        }
        /// <summary>
        /// Method use to encode the flat file
        /// </summary>
        /// <param name="connections"></param>
        /// <param name="variableDispenser"></param>
        /// <param name="componentEvents"></param>
        /// <returns></returns>
        private bool EncodeFile(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents)
        {
            bool retval = false;
            bool refire = false;

            try
            {
                string filePath = SourceType == SourceFileType.FromFileConnector.ToString()
                                        ? connections[FileConnector].ConnectionString
                                        : EvaluateExpression(FileSourcePathInVariable, variableDispenser).ToString();

                retval = new FileEncodingTools(filePath,
                                               EncodingType,
                                               AutodetectSourceEncodingType,
                                               SourceEncodingType,
                                               ReadWriteBuffer).Encode(componentEvents);
            }
            catch (Exception exception)
            {
                componentEvents.FireError(0,
                                          "SSISEncodeFileTask",
                                          string.Format("EncodeFile Error :{0} {1} {2}", exception.Message, exception.Source, exception.StackTrace),
                                          string.Empty,
                                          0);
            }

            return(retval);
        }
        /// <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));
        }
예제 #17
0
        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);
            }

            if (Text == null)
            {
                componentEvents.FireError(0, "Slact Taks", "Error sending message to Slack. Text is not set.", "", 0);
                return(DTSExecResult.Failure);
            }

            return(DTSExecResult.Success);
        }
        /// <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);
        }
        private DTSExecResult ValidateProperties(ref IDTSComponentEvents componentEvents)
        {
            DTSExecResult result = DTSExecResult.Success;

            if (String.IsNullOrEmpty(this.FtpProtocolName))
            {
                componentEvents.FireError(0, TASK_NAME, FtpProtocolName_MISSING_MESAGE, String.Empty, 0);
                result = DTSExecResult.Failure;
            }

            if (String.IsNullOrEmpty(this.FtpHostName))
            {
                componentEvents.FireError(0, TASK_NAME, FtpHostName_MISSING_MESAGE, String.Empty, 0);
                result = DTSExecResult.Failure;
            }

            if (String.IsNullOrEmpty(this.FtpUserName))
            {
                componentEvents.FireError(0, TASK_NAME, FtpUserName_MISSING_MESAGE, String.Empty, 0);
                result = DTSExecResult.Failure;
            }

            if (String.IsNullOrEmpty(this.FtpPassword))
            {
                componentEvents.FireError(0, TASK_NAME, FtpPassword_MISSING_MESAGE, String.Empty, 0);
                result = DTSExecResult.Failure;
            }

            if (String.IsNullOrEmpty(this.FtpSshHostKeyFingerprint))
            {
                componentEvents.FireError(0, TASK_NAME, FtpSshHostKeyFingerprint_MISSING_MESAGE, String.Empty, 0);
                result = DTSExecResult.Failure;
            }

            if (String.IsNullOrEmpty(this.FtpOperationName))
            {
                componentEvents.FireError(0, TASK_NAME, FtpOperationName_MISSING_MESAGE, String.Empty, 0);
                result = DTSExecResult.Failure;
            }

            if (String.IsNullOrEmpty(this.FtpLocalPath))
            {
                componentEvents.FireError(0, TASK_NAME, FtpLocalPath_MISSING_MESAGE, String.Empty, 0);
                result = DTSExecResult.Failure;
            }

            if (String.IsNullOrEmpty(this.FtpRemotePath))
            {
                componentEvents.FireError(0, TASK_NAME, FtpRemotePath_MISSING_MESAGE, String.Empty, 0);
                result = DTSExecResult.Failure;
            }

            return(result);
        }
예제 #20
0
파일: HDFSTask.cs 프로젝트: kzhen/SSISHDFS
        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);
            }
        }
        public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
        {
            Boolean fireAgain = false;

            try
            {
                // Validate mandatory String properties.
                DTSExecResult propertyValidationResult = this.ValidateProperties(ref componentEvents);
                if (propertyValidationResult != DTSExecResult.Success)
                {
                    return(propertyValidationResult);
                }

                // The package developer should know that files will be removed from the source.
                if (this.FtpRemove)
                {
                    componentEvents.FireInformation(0, TASK_NAME, REMOVE_ENABLED_MESSAGE, String.Empty, 0, ref fireAgain);
                }

                // Verify the connection.
                using (Session winScpSession = this.EstablishSession())
                {
                    componentEvents.FireInformation(0, TASK_NAME, SESSION_OPEN_MESSAGE, String.Empty, 0, ref fireAgain);

                    // Verify the remote resources.
                    OperationMode operation = (OperationMode)Enum.Parse(typeof(OperationMode), this.FtpOperationName);
                    switch (operation)
                    {
                    case OperationMode.PutFiles:
                        Boolean remoteDirectoryExists = winScpSession.FileExists(this.FtpRemotePath);
                        if (!remoteDirectoryExists)
                        {
                            componentEvents.FireInformation(0, TASK_NAME, String.Format(REMOTE_DIRECTORY_MISSING_MESSAGE_PATTERN, this.FtpRemotePath), String.Empty, 0, ref fireAgain);
                        }
                        break;

                    case OperationMode.GetFiles:
                    default:
                        Boolean remoteFileExists = winScpSession.FileExists(this.FtpRemotePath);
                        if (!remoteFileExists)
                        {
                            componentEvents.FireInformation(0, TASK_NAME, String.Format(REMOTE_FILES_MISSING_MESSAGE_PATTERN, this.FtpRemotePath), String.Empty, 0, ref fireAgain);
                        }
                        break;
                    }
                }

                return(DTSExecResult.Success);
            }
            catch (Exception exc)
            {
                String exceptionMessage = exc != null ? exc.Message : UNKNOWN_EXCEPTION_MESSAGE;
                componentEvents.FireError(0, TASK_NAME, String.Format(EXCEPTION_MESSAGE_PATTERN, exceptionMessage), String.Empty, 0);
                return(DTSExecResult.Failure);
            }
        }
예제 #22
0
        /// <summary>
        /// Validates the task and its settings at desing time, and at run time.
        /// </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(_defaultApplicationName))
            {
                componentEvents.FireError(0, _taskName, UNRESOLVED_APPLICATION_NAME_MESSAGE, String.Empty, 0);
                return(DTSExecResult.Failure);
            }

            return(DTSExecResult.Success);
        }
예제 #23
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;
        }
예제 #24
0
        /// <summary>
        /// Validates the Task
        /// </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 (sleepInterval <= 0)
            {
                componentEvents.FireError(0, Resources.SleepTaskName, Resources.ErrorSleepInterval, string.Empty, 0);
                return(DTSExecResult.Failure);
            }

            return(base.Validate(connections, variableDispenser, componentEvents, log));
        }
예제 #25
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);
        }
예제 #26
0
        private bool GetSignalledState(VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, out bool failure)
        {
            bool isSignalled = false;

            failure = false;

            if (string.IsNullOrEmpty(SignalVariable))
            {
                componentEvents.FireError(0, Resources.WaitForSignalTaskName, Resources.ErrorSignalVariableHasToBeSpecified, string.Empty, 0);
                failure = true;
            }

            if (!variableDispenser.Contains(SignalVariable))
            {
                componentEvents.FireError(0, Resources.WaitForSignalTaskName, string.Format(Resources.ErrorSignalVariableDoesNotExists, SignalVariable), string.Empty, 0);
                failure = true;
            }
            else
            {
                Variables vars = null;
                variableDispenser.LockOneForRead(SignalVariable, ref vars);
                if (vars != null && vars.Contains(SignalVariable))
                {
                    Variable v = vars[SignalVariable];
                    if (v.DataType != TypeCode.Boolean)
                    {
                        componentEvents.FireError(0, Resources.WaitForSignalTaskName, string.Format(Resources.ErrorSignalVariableNotBoolean, SignalVariable), string.Empty, 0);
                        failure = true;
                    }

                    isSignalled = (bool)v.Value;
                    vars.Unlock();
                }
                else
                {
                    componentEvents.FireError(0, Resources.WaitForSignalTaskName, string.Format(Resources.ErrorLockSignalVariable, SignalVariable), string.Empty, 0);
                    failure = true;
                }
            }

            return(isSignalled);
        }
예제 #27
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;
        }
예제 #28
0
파일: HDFSTask.cs 프로젝트: kzhen/SSISHDFS
        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);
        }
예제 #29
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));
        }
예제 #30
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, "SSISBulkExportTask", "Base validation failed", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(SQLServerInstance))
            {
                componentEvents.FireError(0, "SSISBulkExportTask", "A SQL Server Connection is mandatory", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(DestinationPath))
            {
                componentEvents.FireError(0, "SSISBulkExportTask", "Destination Path is mandatory ", "", 0);
                isBaseValid = false;
            }

            if (string.IsNullOrEmpty(SQLStatment) &&
                string.IsNullOrEmpty(View) &&
                string.IsNullOrEmpty(Tables) &&
                string.IsNullOrEmpty(StoredProcedure))
            {
                componentEvents.FireError(0, "SSISBulkExportTask", "You must specify an SQL Select Statelment / a View name / a Stored Procedure name / a Table Name", "", 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;
            }

            return(isBaseValid ? DTSExecResult.Success : DTSExecResult.Failure);
        }
        private DTSExecResult ProxyExecute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            bool refire = false;

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


            if (!string.IsNullOrEmpty(FileSourcePathInVariable))
            {
                GetNeededVariables(variableDispenser, FileSourcePathInVariable);
            }

            try
            {
                componentEvents.FireInformation(0,
                                                "SSISEncodeFileTask",
                                                EncodeFile(connections, variableDispenser, componentEvents)
                                                    ? "The file has been encoded successfully."
                                                    : "The file has NOT been encoded.",
                                                string.Empty,
                                                0,
                                                ref refire);
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0,
                                          "SSISEncodeFileTask",
                                          string.Format("Problem: {0}", ex.Message),
                                          string.Empty,
                                          0);

                return(DTSExecResult.Failure);
            }
            finally
            {
                if (_vars != null)
                {
                    if (_vars.Locked)
                    {
                        _vars.Unlock();
                    }
                }
            }

            return(base.Execute(connections, variableDispenser, componentEvents, log, transaction));
        }
예제 #32
0
        /// <summary>
        /// Executes the WaitForTimeTask - invokes the actual waiting for specified time
        /// </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)
        {
            //Actual time at the time of execution
            DateTime now = DateTime.Now;

            result = WaitForTimeResult.None;

            //Check the WaitTime for correct value
            if (waitTime < TimeSpan.Zero || waitTime >= day)
            {
                componentEvents.FireError(0, Resources.WaitForTimeTaskName, Resources.ErrorWaitForTime, string.Empty, 0);
                result = WaitForTimeResult.Error;
                return(DTSExecResult.Failure);
            }

            DateTime finalWaitTime = DateTime.Today.Add(waitTime);


            if (finalWaitTime < now)
            {
                if (!WaitNextDayIfTimePassed)
                {
                    result = WaitForTimeResult.PassedInPast;
                }
                else
                {
                    finalWaitTime = finalWaitTime.AddDays(1);
                }
            }

            while (result == WaitForTimeResult.None)
            {
                if (finalWaitTime <= DateTime.Now)
                {
                    result = WaitForTimeResult.Passed;
                }

                if (result == WaitForTimeResult.None)
                {
                    int sleepTime = (finalWaitTime - DateTime.Now).Milliseconds;
                    if (sleepTime <= 0)
                    {
                        sleepTime = 50;
                    }
                    System.Threading.Thread.Sleep(sleepTime);
                }
            }

            return(base.Execute(connections, variableDispenser, componentEvents, log, transaction));
        }
예제 #33
0
        /// <summary>
        /// Executes tasks. Does the actual sleep
        /// </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)
        {
            if (sleepInterval > 0)
            {
                System.Threading.Thread.Sleep(sleepInterval);
            }
            else
            {
                componentEvents.FireError(0, Resources.SleepTaskName, Resources.ErrorSleepInterval, string.Empty, 0);
                return(DTSExecResult.Failure);
            }

            return(base.Execute(connections, variableDispenser, componentEvents, log, transaction));
        }
예제 #34
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;
        }
예제 #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 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;
            }
        }
예제 #36
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);
 }
예제 #37
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;
        }
예제 #38
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;
            }
        }
예제 #39
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;
            }
        }
예제 #40
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;
        }
예제 #41
0
        /// <summary>
        /// Resolves the variable placeholders in message text and returnes the resolved message
        /// Variable placeholders will be lookedup and the value will be inserted in the placeholder
        /// </summary>
        /// <param name="variableDispenser">the ssis variable dispenser to access runtime variables</param>
        /// <param name="componentEvents"></param>
        /// <param name="messageText">the message text possibly containing variable placeholder</param>
        /// <returns>returns the resolved message where all variable placeholders are replaced by their correspoding values</returns>
        public string GetMessageText(VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, string messageText)
        {
            try
            {
                if (messageText != "")
                {
                    while (messageText.Contains("@("))
                    {

                        int start = messageText.IndexOf("@(", 0);
                        int end = messageText.IndexOf(")", start);

                        string varName = messageText.Substring(start + 2, end - start - 2);

                        messageText = messageText.Replace("@(" + varName + ")", GetValueFromVariable(variableDispenser, varName));
                    }
                }
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "", "Fehler beim Anfordern eines Variablen-Wertes: " + ex.Message, "", 0);
                throw ex;
            }

            return messageText;
        }
예제 #42
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;
 }
 private void fireError(IDTSComponentEvents componentEvents, string description)
 {
     componentEvents.FireError(0, "SSHExecuteCommandTask", description, "", 0);
 }
예제 #44
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;
        }
예제 #45
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;
              }
        }