Exemple #1
0
 public Session(IConf conf, string user)
     : this(conf)
 {
     _user = user;
     _isCommited = false;
     Open();
 }
 public DeployExceptionHandler(IDeployEvents callback, IConf appSettings, IServiceLogger logger, ISession session)
 {
     _callback = callback;
     _session = session;
     _appSettings = appSettings;
     _logger = logger;
 }
        public void CreateTestEnvironment()
        {
            _surveyDir = "TestSurvey" + TestUtils.GetPostfix();
            _conf = CreateConfForPackage(_surveyDir);

            TestUtils.PreparePackageFor(DeployMode.Install, _conf.PackagePaths.Survey);
            Directory.CreateDirectory(_conf.CommonPaths.Surveys);
            Directory.CreateDirectory(_conf.CommonPaths.Backups);
        }
 public void PrepareDeploySettings()
 {
     var mockedConf = new Mock<IConf>();
     mockedConf.Setup(s => s.ConnectionStrings).Returns(new ConnectionStrings(null, ConfigurationManager.ConnectionStrings["deployer"].ConnectionString));
     mockedConf.Setup(s => s.Survey).Returns(new Survey("Test", null, DeployMode.Install));
     mockedConf.Setup(s => s.SessionKey).Returns(TestUtils.GetPostfix(50));
     _conf = mockedConf.Object;
     _user = GetTestUser("Test" + TestUtils.GetPostfix());
 }
Exemple #5
0
        public void SetUp()
        {
            _mockedIISManager = new Mock<IIISManager>();
            _mockedIISManager.Setup(m => m.CreateSurvey(It.IsAny<string>()));
            _mockedIISManager.Setup(m => m.DeleteSurvey());

            var mockedConf = new Mock<IConf>();
            mockedConf.Setup(c => c.IISManager).Returns(_mockedIISManager.Object);
            mockedConf.Setup(c => c.SurveyPath).Returns(new SurveyPaths(null, null));

            _conf = mockedConf.Object;
        }
Exemple #6
0
        public void SetUp()
        {
            _mockedIISManager = new Mock <IIISManager>();
            _mockedIISManager.Setup(m => m.CreateSurvey(It.IsAny <string>()));
            _mockedIISManager.Setup(m => m.DeleteSurvey());

            var mockedConf = new Mock <IConf>();

            mockedConf.Setup(c => c.IISManager).Returns(_mockedIISManager.Object);
            mockedConf.Setup(c => c.SurveyPath).Returns(new SurveyPaths(null, null));

            _conf = mockedConf.Object;
        }
Exemple #7
0
        public static T Configure <T>(this IConf conf, T obj, string key = null)
        {
            if (null == conf)
            {
                throw new ArgumentNullException(nameof(conf));
            }

            var container = conf.Container;

            if (container == null)
            {
                throw new ArgumentException(paramName: nameof(conf), message: $"{nameof(conf.Container)} is null.");
            }

            return(container.Configure(obj, key));
        }
        public void CreateTestEnvironment()
        {
            var confSection = DeployerConfigurationSection.Instance;
            var surveyName = "TestSurvey" + TestUtils.GetPostfix();
            var pathToSurvey = Path.Combine(confSection.Settings.Paths.Surveys, surveyName);
            var iisManager = new Mock<IIISManager>();
            iisManager.Setup(m => m.SurveyPath).Returns(pathToSurvey);

            var mockedConf = new Mock<IConf>();
            mockedConf.Setup(s => s.CommonPaths).Returns(new CommonPaths(confSection.Settings.Paths.Surveys, null, null));
            mockedConf.Setup(s => s.SurveyPath).Returns(new SurveyPaths(pathToSurvey, null));
            mockedConf.Setup(s => s.IISManager).Returns(iisManager.Object);
            _conf = mockedConf.Object;

            Directory.CreateDirectory(_conf.CommonPaths.Surveys);
        }
Exemple #9
0
        public void CreateTestEnvironment()
        {
            var confSection  = DeployerConfigurationSection.Instance;
            var surveyName   = "TestSurvey" + TestUtils.GetPostfix();
            var pathToSurvey = Path.Combine(confSection.Settings.Paths.Surveys, surveyName);
            var iisManager   = new Mock <IIISManager>();

            iisManager.Setup(m => m.SurveyPath).Returns(pathToSurvey);

            var mockedConf = new Mock <IConf>();

            mockedConf.Setup(s => s.CommonPaths).Returns(new CommonPaths(confSection.Settings.Paths.Surveys, null, null));
            mockedConf.Setup(s => s.SurveyPath).Returns(new SurveyPaths(pathToSurvey, null));
            mockedConf.Setup(s => s.IISManager).Returns(iisManager.Object);
            _conf = mockedConf.Object;

            Directory.CreateDirectory(_conf.CommonPaths.Surveys);
        }
 public ISession CreateSessionObj(IConf settings, string user)
 {
     return _sessionFactory(settings, user);
 }
Exemple #11
0
 protected Validator(IConf conf)
 {
     _conf = conf;
 }
Exemple #12
0
 protected Deployer(IConf conf)
 {
     _conf = conf;
 }
Exemple #13
0
 public static DirectoryValidator Create(IConf appSettings)
 {
     return new DirectoryValidator(appSettings);
 }
Exemple #14
0
 public static IISDeployer Create(IConf appSettings)
 {
     return(new IISDeployer(appSettings));
 }
Exemple #15
0
 public IISValidator(IConf conf)
     : base(conf)
 {
     Name = "IIS validator";
 }
Exemple #16
0
 public DatabaseDeployer(IConf conf) : base(conf)
 {
     Name = "Database";
 }
Exemple #17
0
 public DirectoryDeployer(IConf conf)
     : base(conf)
 {
     Name = "Directory";
 }
Exemple #18
0
 public IDeployExceptionHandler CreateDeployExHandlerObj(IDeployEvents callback, IConf settings, IServiceLogger logger, ISession session)
 {
     return(_exHandlerFactory(callback, settings, logger, session));
 }
Exemple #19
0
 public Session(IConf conf, string user) : this(conf) {
     _user       = user;
     _isCommited = false;
     Open();
 }
Exemple #20
0
 public ISession CreateSessionObj(IConf settings, string user)
 {
     return(_sessionFactory(settings, user));
 }
Exemple #21
0
 public IEnumerable <IDeployer> CreateDeployersList(IConf settings)
 {
     return(_deployersFactory(settings));
 }
Exemple #22
0
 public IEnumerable <IValidator> CreateValidatorsList(IConf settings)
 {
     return(_validatorsFactory(settings));
 }
Exemple #23
0
 protected Validator(IConf conf)
 {
     _conf = conf;
 }
Exemple #24
0
 public DirectoryValidator(IConf conf)
     : base(conf)
 {
     Name = "Directory validator";
 }
Exemple #25
0
 public static IISValidator Create(IConf appSettings)
 {
     return new IISValidator(appSettings);
 }
Exemple #26
0
 public DatabaseDeployer(IConf conf)
     : base(conf)
 {
     Name = "Database";
 }
Exemple #27
0
 public static DatabaseDeployer Create(IConf appSettings)
 {
     return(new DatabaseDeployer(appSettings));
 }
Exemple #28
0
 public static DatabaseDeployer Create(IConf appSettings)
 {
     return new DatabaseDeployer(appSettings);
 }
Exemple #29
0
 public static DirectoryDeployer Create(IConf appSettings)
 {
     return new DirectoryDeployer(appSettings);
 }
 public static DeployExceptionHandler Create(IDeployEvents callback, IConf appSettings, IServiceLogger logger, ISession session)
 {
     return new DeployExceptionHandler(callback, appSettings, logger, session);
 }
Exemple #31
0
 public IISDeployer(IConf conf) : base(conf)
 {
     Name = "IIS";
 }
Exemple #32
0
 public static DirectoryDeployer Create(IConf appSettings)
 {
     return(new DirectoryDeployer(appSettings));
 }
Exemple #33
0
 protected Session(IConf conf)
 {
     _conf = conf;
 }
Exemple #34
0
 public static IISValidator Create(IConf appSettings)
 {
     return(new IISValidator(appSettings));
 }
Exemple #35
0
 public IISDeployer(IConf conf)
     : base(conf)
 {
     Name = "IIS";
 }
 public IEnumerable<IDeployer> CreateDeployersList(IConf settings)
 {
     return _deployersFactory(settings);
 }
Exemple #37
0
 public static IISDeployer Create(IConf appSettings)
 {
     return new IISDeployer(appSettings);
 }
Exemple #38
0
 public DatabaseValidator(IConf conf)
     : base(conf)
 {
     Name = "Database validator";
 }
Exemple #39
0
 public DirectoryDeployer(IConf conf) : base(conf)
 {
     Name = "Directory";
 }
Exemple #40
0
 public static DatabaseValidator Create(IConf appSettings)
 {
     return new DatabaseValidator(appSettings);
 }
Exemple #41
0
 public IISValidator(IConf conf) : base(conf)
 {
     Name = "IIS validator";
 }
Exemple #42
0
 public DatabaseValidator(IConf conf) : base(conf)
 {
     Name = "Database validator";
 }
 public IDeployExceptionHandler CreateDeployExHandlerObj(IDeployEvents callback, IConf settings, IServiceLogger logger, ISession session)
 {
     return _exHandlerFactory(callback, settings, logger, session);
 }
Exemple #44
0
 public static DatabaseValidator Create(IConf appSettings)
 {
     return(new DatabaseValidator(appSettings));
 }
 public IEnumerable<IValidator> CreateValidatorsList(IConf settings)
 {
     return _validatorsFactory(settings);
 }
Exemple #46
0
 public DirectoryValidator(IConf conf) : base(conf)
 {
     Name = "Directory validator";
 }
Exemple #47
0
 protected Session(IConf conf)
 {
     _conf = conf;
 }
Exemple #48
0
 public static DirectoryValidator Create(IConf appSettings)
 {
     return(new DirectoryValidator(appSettings));
 }
Exemple #49
0
 protected Deployer(IConf conf)
 {
     _conf = conf;
 }
Exemple #50
0
        private void RunDeployment(IConf conf, IDeployEvents callback, DeployContext context, byte[] files)
        {
            using (var session = _dsFactory.CreateSessionObj(conf, _user)) {
                _logger.Info(string.Format("Session for '{0}' is opened", _sessionKey));

                var deploySteps = new List<IDeployer>();
                var failedValidators = new List<IValidator>();
                var exceptionHandler = _dsFactory.CreateDeployExHandlerObj(callback, conf, _logger, session);
                try {
                    conf.PackageManager.BytesToZip(files, conf.PackagePaths.Survey);
                    _logger.Info(string.Format("Zip files was unpacked to '{0}'", conf.PackagePaths.Survey));

                    DeployExecutor.Validate(_dsFactory.CreateValidatorsList(conf), failedValidators, callback, conf.Survey.DeployMode);
                    _logger.Info(string.Format("Validation process is complete. Found '{0}' error(s)", failedValidators.Count));
                    if (failedValidators.Any())
                        throw new ValidationException("Validation at " + String.Join(", ", failedValidators.Select(v => v.Name).ToArray()) + " failed.");

                    DeployExecutor.Deploy(_dsFactory.CreateDeployersList(conf), deploySteps, callback, conf.Survey.DeployMode);
                    _logger.Info(string.Format("Deploy is finished for '{0}'", _sessionKey));

                    session.Commit();
                    _logger.Info(string.Format("Session for '{0}' is commited successfully", _sessionKey));
                } catch (ValidationException exception) {
                    exceptionHandler.HandleValidation(exception, callback);
                } catch (DeployException exception) {
                    exceptionHandler.HandleDeploy(exception, callback, deploySteps, GetRollbackAction(context));
                } catch (Exception exception) {
                    exceptionHandler.HandleUnknown(exception, callback);
                }
            }
        }