Exemplo n.º 1
0
        public Program(ApplicationInformation applicationInformation, IUserInterface userInterface, IActionLogger logger, ICommandLineArgumentInterpreter commandLineArgumentInterpreter, IHelpCommand helpCommand)
        {
            if (applicationInformation == null)
            {
                throw new ArgumentNullException("applicationInformation");
            }

            if (userInterface == null)
            {
                throw new ArgumentNullException("userInterface");
            }

            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            if (commandLineArgumentInterpreter == null)
            {
                throw new ArgumentNullException("commandLineArgumentInterpreter");
            }

            if (helpCommand == null)
            {
                throw new ArgumentNullException("helpCommand");
            }

            this.applicationInformation = applicationInformation;
            this.userInterface = userInterface;
            this.logger = logger;
            this.commandLineArgumentInterpreter = commandLineArgumentInterpreter;
            this.helpCommand = helpCommand;
        }
Exemplo n.º 2
0
 public AuditController(IActionLogger actionLogger, IMapper mapper,
                        IRemoteLockRepository lockRepository, IUnitOfWork uow)
 {
     this.actionLogger   = actionLogger;
     this.mapper         = mapper;
     this.lockRepository = lockRepository;
     this.uow            = uow;
 }
Exemplo n.º 3
0
 public LocksController(ILockHttpService lockHttpService, IRemoteLockRepository lockRepository,
                        IMapper mapper, IUnitOfWork uow, IActionLogger actionLogger)
 {
     this.lockHttpService = lockHttpService;
     this.lockRepository  = lockRepository;
     this.mapper          = mapper;
     this.uow             = uow;
     this.actionLogger    = actionLogger;
 }
Exemplo n.º 4
0
        public void BeforeEachTest()
        {
            this.sequentialTestExecutionMonitor.WaitOne();

            CommandLineIntegrationTestUtilities.RemoveAllFilesAndFoldersWhichAreCreatedOnStartup();

            StructureMapSetup.Setup();
            this.encodingProvider = ObjectFactory.GetInstance<IEncodingProvider>();
            this.applicationInformation = ObjectFactory.GetInstance<ApplicationInformation>();
            this.commandProvider = ObjectFactory.GetInstance<ICommandProvider>();
            this.userInterface = ObjectFactory.GetInstance<IUserInterface>();
            this.logger = ObjectFactory.GetInstance<IActionLogger>();
            this.commandLineArgumentInterpreter = ObjectFactory.GetInstance<ICommandLineArgumentInterpreter>();
            this.helpCommand = ObjectFactory.GetInstance<IHelpCommand>();

            this.program = new Program(this.applicationInformation, this.userInterface, this.logger, this.commandLineArgumentInterpreter, this.helpCommand);
        }
Exemplo n.º 5
0
        public ConsoleUserInterface(IConsoleTextManipulation textManipulation, IActionLogger logger, IServiceResultVisualizer serviceResultVisualizer)
        {
            if (textManipulation == null)
            {
                throw new ArgumentNullException("textManipulation");
            }

            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            if (serviceResultVisualizer == null)
            {
                throw new ArgumentNullException("serviceResultVisualizer");
            }

            this.textManipulation = textManipulation;
            this.logger = logger;
            this.serviceResultVisualizer = serviceResultVisualizer;
        }
Exemplo n.º 6
0
        public bool Execute(ISessionContext context)
        {
            _logger = context.GetLogger();
            var _options = context.Options;

            try
            {
                var processFilename = _options.Get("processFilename", "");
                if (String.IsNullOrWhiteSpace(processFilename))
                {
                    throw new ArgumentNullException("processFilename");
                }

                var taskWorkDir = _options.Get("processWorkingDirectory", "");
                if (String.IsNullOrWhiteSpace(taskWorkDir))
                {
                    taskWorkDir = System.IO.Path.GetDirectoryName(processFilename);
                }

                fireAndForget = _options.Get("fireAndForget", false);
                // save ammount of log to produce
                _maxLogLines = 10 - (int)_logger.GetLogLevel();


                return(ExecuteProcess(processFilename,
                                      _options.Get("parameters", ""),
                                      TimeSpan.FromSeconds(_options.Get("waitInSeconds", 0)),
                                      !fireAndForget,
                                      !fireAndForget,
                                      taskWorkDir));
            }
            catch (Exception ex)
            {
                context.Error = ex.Message;
                _logger.Error(ex);
                return(false);
            }
        }
        private void ExecuteRedshiftLoad(string connectionString, IActionLogger logger, string script, List <string> files, FileTransferDetails filesDetails)
        {
            var dtStart = DateTime.UtcNow;

            // prepare files full name
            HashSet <string> fileMap = new HashSet <string> (files
                                                             .Select(f => System.IO.Path.Combine("s3://", filesDetails.BucketName, f.Trim()).Replace('\\', '/')),
                                                             StringComparer.OrdinalIgnoreCase);

            // execute redshift load.
            logger.Debug("SQL Script start");

            RedshiftHelper.RunLoad(connectionString, script);

            logger.Debug("SQL Script end");

            int num_files = files.Count;

            do
            {
                num_files = 0;
                foreach (var i in stv_load_state.Read(connectionString))
                {
                    if (fileMap.Contains(i.current_file))
                    {
                        num_files++;
                    }
                }
                // wait a while
                if (num_files > 0)
                {
                    // sanity check... 2 hours to run a load operation is too long...
                    if ((DateTime.UtcNow - dtStart) > TimeSpan.FromHours(3))
                    {
                        break;
                    }
                    // wait a while
                    System.Threading.Thread.Sleep(10000);
                }
            }while (num_files > 0);

            // check load errors table
            foreach (var i in stl_load_errors.Read(connectionString, dtStart))
            {
                if (fileMap.Contains(i.filename.Trim()))
                {
                    throw new Exception("Load error detected <stl_load_errors>: " + Newtonsoft.Json.JsonConvert.SerializeObject(i));
                }
            }

            // check commited files table
            var filesLoaded = new HashSet <string> (stl_load_commits.ReadCommitedFiles(connectionString, dtStart).Select(f => f.Trim()), StringComparer.OrdinalIgnoreCase);

            foreach (var f in fileMap)
            {
                if (!filesLoaded.Contains(f))
                {
                    throw new Exception("Load error; file not commited <stl_load_commits>: " + f);
                }
            }

            logger.Debug("Files loaded");
        }
Exemplo n.º 8
0
 public EmailController(IWebsiteRepository repository, IEmailService emailService, IActionLogger actionLogger)
 {
     m_repository = repository;
     m_emailService = emailService;
     m_actionLogger = actionLogger;
 }
Exemplo n.º 9
0
 public GenerateController(IImageToPointService imageConverter, IActionLogger logger)
 {
     _imageConverter = imageConverter;
     _logger         = logger;
 }
Exemplo n.º 10
0
 public ImagesController(IGetImagesService imagesService, IActionLogger logger)
 {
     _imagesService = imagesService;
     _logger        = logger;
 }
 public ActionAttribute(IActionLogger logger)
 {
     this._logger = logger;
 }
 public DisposableServiceProvider(IActionLogger actionLogger)
 {
     this.actionLogger = actionLogger;
 }
Exemplo n.º 13
0
 public ActionLoggerAttribute(IActionLogger logger)
 {
     _logger = logger;
 }
Exemplo n.º 14
0
        public bool Execute(ISessionContext context)
        {
            _context = context;
            _logger  = context.GetLogger();
            _options = context.Options;

            IFileTransfer input = null;

            _fileTransferService = context.GetContainer().GetInstanceOf <IFileService> ();
            _deleteSourceFile    = _options.Get <bool> ("deleteSourceFile", false);
            _retryCount          = _options.Get <int> ("retryCount", 2);
            _retryWait           = TimeSpan.FromMilliseconds(_options.Get <int> ("retryWaitMs", 250));

            try
            {
                var searchPath = _options.Get("inputPath", _options.Get("searchPath", ""));
                if (String.IsNullOrEmpty(searchPath))
                {
                    throw new ArgumentNullException("inputPath");
                }

                if (String.IsNullOrEmpty(_options.Get("outputPath", "")))
                {
                    throw new ArgumentNullException("outputPath");
                }

                _maxFilesCount = _options.Get("maxFileCount", _maxFilesCount);
                if (_maxFilesCount <= 0)
                {
                    _maxFilesCount = Int32.MaxValue;
                }

                // prepare paths
                input = _fileTransferService.Open(searchPath, _options);
                if (!input.IsOpened())
                {
                    throw new Exception(String.Format("Invalid inputPath, {0}: {1}", input.LastError ?? "", searchPath));
                }

                // try move files
                ParallelTasks <FileTransferInfo> .Process(input.ListFiles().Take(_maxFilesCount), 0, _options.Get("maxConcurrency", 2), f => MoveFileInternal(f, searchPath));

                if (!String.IsNullOrEmpty(input.LastError))
                {
                    _logger.Warn(input.LastError);
                }

                if (_filesCount > 0)
                {
                    _logger.Success("Done");
                    return(true);
                }
                else
                {
                    _logger.Debug("No Files Found on: " + searchPath);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                context.Error = ex.Message;
                _logger.Error(ex);
                return(false);
            }
            finally
            {
                if (input != null)
                {
                    input.Dispose();
                }
            }
        }
Exemplo n.º 15
0
 public HomeController(IWebsiteRepository repository, ILogRepository logRepository, IActionLogger actionLogger)
 {
     m_repository = repository;
     m_actionLogger = actionLogger;
     m_logRepository = logRepository;
 }
Exemplo n.º 16
0
 public ContactController(IActionLogger logger)
 {
     _logger = logger;
 }