Exemplo n.º 1
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);
        }
Exemplo n.º 2
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;
 }