public string Synchronize(string environmentName)
        {
            var syncConfiguration = _configurationReader.ReadConfiguration();

            if (syncConfiguration.SiteDefinitions == null || !syncConfiguration.SiteDefinitions.Any())
            {
                Logger.Information("No site definitions found to synchronize.");
                resultLog.AppendLine("No site definitions found to synchronize.<br />");
                return(resultLog.ToString());
            }

            var stopwatch = Stopwatch.StartNew();

            try
            {
                var updatedSites = MergeSiteDefinitions(syncConfiguration.SiteDefinitions);

                Logger.Information($"Updated total of {updatedSites} sites.");
                resultLog.AppendLine($"Updated total of {updatedSites} sites.<br />");
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occured when trying to synchronize site definitions", ex);
                resultLog.AppendLine($"An exception occured when trying to synchronize site definitions: {ex.Message}<br />");
            }

            stopwatch.Stop();
            Logger.Information($"Synchronize site definitions took {stopwatch.ElapsedMilliseconds}ms.");

            return(resultLog.ToString());
        }
Beispiel #2
0
        private SpecFlowGeneratorConfiguration GenSpecFlowGeneratorConfig()
        {
            try
            {
                var specflowGeneratorConfig = new SpecFlowGeneratorConfiguration();

                var configurationHolder = _configurationReader.ReadConfiguration();
                switch (configurationHolder.ConfigSource)
                {
                case ConfigSource.AppConfig:
                    var appConfigFormat    = configurationHolder.TransformConfigurationToOldHolder();
                    var oldGeneratorConfig = new GeneratorConfigurationProvider().LoadConfiguration(appConfigFormat).GeneratorConfiguration;

                    specflowGeneratorConfig.GeneratorPath = oldGeneratorConfig.GeneratorPath;
                    specflowGeneratorConfig.UsesPlugins   = oldGeneratorConfig.UsesPlugins;
                    break;

                case ConfigSource.Json:
                    var defaultSpecFlowConfiguration = ConfigurationLoader.GetDefault();
                    var specflowLoader = new ConfigurationLoader();
                    var jsonConfig     = specflowLoader.Load(defaultSpecFlowConfiguration, configurationHolder);

                    specflowGeneratorConfig.GeneratorPath = jsonConfig.GeneratorPath;
                    specflowGeneratorConfig.UsesPlugins   = jsonConfig.UsesPlugins;
                    break;
                }

                return(specflowGeneratorConfig);
            }
            catch (Exception exception)
            {
                _tracer.Trace("Config load error: " + exception, "VsGeneratorInfoProvider");
                return(new SpecFlowGeneratorConfiguration());
            }
        }
Beispiel #3
0
        public RuntimeAgentConfiguration PerformHandshake(IConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            var outputWriter = connection.OutputWriter;

            _messageProtocol.WriteHello(outputWriter);
            outputWriter.FlushAndLog("WriteHello");

            var inputReader = connection.InputReader;
            var reply       = inputReader.ReadByte();

            switch (reply)
            {
            case MessageTypes.Configuration:
                return(_configurationReader.ReadConfiguration(inputReader));

            case MessageTypes.Error:
                throw new HandshakeException(inputReader.ReadUtfBigEndian(), reply);

            default:
                throw new HandshakeException($"Handshake operation failed with unexpected reply: {reply}", reply);
            }
        }
        public void UpdateConfiguration()
        {
            var newConfiguration = configurationReader.ReadConfiguration()
                                   ?? configurationFactory.GetDefaultAppConfiguration();

            if (!newConfiguration.Equals(Configuration))
            {
                var oldConfiguration = Configuration;

                Configuration = newConfiguration;

                OnConfigurationChange?.Invoke(
                    this,
                    new ConfigurationChangeEventArgs(oldConfiguration, newConfiguration)
                    );

                var oldMachines = oldConfiguration?.Machines ??
                                  new ReadOnlyCollection <MachineConfiguration>(Array.Empty <MachineConfiguration>());

                if (!newConfiguration.Machines.OrderBy(c => c.Uuid).SequenceEqual(oldMachines.OrderBy(c => c.Uuid)))
                {
                    OnMachineConfigurationChange?.Invoke(
                        this,
                        new MachineConfigurationChangeEventArgs(oldMachines, newConfiguration.Machines)
                        );
                }
            }
        }
Beispiel #5
0
        public string Synchronize(string environmentName)
        {
            Logger.Information("ScheduledJobSynchronizer starting synchronization.");
            var syncConfiguration = _configurationReader.ReadConfiguration();

            if (syncConfiguration.ScheduledJobs == null)
            {
                resultLog.AppendLine("No ScheduleJob config found.<br />");
                return(resultLog.ToString());
            }

            UpdateScheduledJobs(syncConfiguration.ScheduledJobs);

            return(resultLog.ToString());
        }
        protected override ProjectSettings LoadProjectSettings()
        {
            tracer.Trace("Discover project settings", "VsGeneratorServices");

            ProjectPlatformSettings projectPlatformSettings;
            var tergetLanguage = VsProjectScope.GetTargetLanguage(project);

            switch (tergetLanguage)
            {
            case ProgrammingLanguage.CSharp:
                projectPlatformSettings = new ProjectPlatformSettings
                {
                    Language        = GenerationTargetLanguage.CSharp,
                    LanguageVersion = new Version("3.0"),
                    Platform        = GenerationTargetPlatform.DotNet,
                    PlatformVersion = new Version("3.5"),
                };
                break;

            case ProgrammingLanguage.VB:
                projectPlatformSettings = new ProjectPlatformSettings
                {
                    Language        = GenerationTargetLanguage.VB,
                    LanguageVersion = new Version("9.0"),
                    Platform        = GenerationTargetPlatform.DotNet,
                    PlatformVersion = new Version("3.5"),
                };
                break;

            default:
                throw new NotSupportedException("target language not supported");
            }

            var configurationHolder = _configurationReader.ReadConfiguration();

            return(new ProjectSettings
            {
                ProjectName = Path.GetFileNameWithoutExtension(project.FullName),
                AssemblyName = VsxHelper.GetProjectAssemblyName(project),
                ProjectFolder = VsxHelper.GetProjectFolder(project),
                DefaultNamespace = VsxHelper.GetProjectDefaultNamespace(project),
                ProjectPlatformSettings = projectPlatformSettings,
                ConfigurationHolder = configurationHolder.TransformConfigurationToOldHolder()
            });
        }
Beispiel #7
0
        public void ProcessIncomingMessage(BinaryReader inputReader)
        {
            byte messageType = inputReader.ReadByte();

            switch (messageType)
            {
            case MessageTypes.Start:
                _messageHandler.OnStart();
                break;

            case MessageTypes.Stop:
                _messageHandler.OnStop();
                break;

            case MessageTypes.Pause:
                _messageHandler.OnPause();
                break;

            case MessageTypes.Unpause:
                _messageHandler.OnUnpause();
                break;

            case MessageTypes.Suspend:
                _messageHandler.OnSuspend();
                break;

            case MessageTypes.Unsuspend:
                _messageHandler.OnUnsuspend();
                break;

            case MessageTypes.Configuration:
                _configurationHandler.OnConfig(_configurationReader.ReadConfiguration(inputReader));
                break;

            case MessageTypes.Error:
                _messageHandler.OnError(inputReader.ReadUtfBigEndian());
                break;

            default:
                _errorHandler.HandleError("Unrecognized control message in ProcessIncomingMessage.", null);
                break;
            }
        }
Beispiel #8
0
        public void ReadChanges(IConfigurationReader configurationReader,
                                List <IQueueProcessor> processors,
                                IQueueClientFactory queueClientFactory,
                                IMessageProcessorFactory messageProcessorFactory,
                                IQueueProcessorFactory queueProcessorFactory)
        {
            var configurations = configurationReader.ReadConfiguration();

            /*
             * First, create processors to add.
             */
            var toAdd = FindConfigsToAdd(configurations,
                                         processors,
                                         queueClientFactory,
                                         messageProcessorFactory,
                                         queueProcessorFactory);

            /*
             * Second, find processors to remove.
             */
            var toRemove = FindEntriesToRemove(configurations, processors);

            /*
             * Now remove those for removal and add the new ones.
             */

            foreach (var processor in toRemove)
            {
                Logger.Info($"Stopping queueprocessor for queue [{processor.Configuration.QueueUrl}], url [{processor.Configuration.RedriveUrl}], alias [{processor.Configuration.Alias}]");
                processor.Stop();
                processors.Remove(processor);
            }

            foreach (var processor in toAdd)
            {
                Logger.Info($"Starting new queueprocessor for queue [{processor.Configuration.QueueUrl}], url [{processor.Configuration.RedriveUrl}], alias [{processor.Configuration.Alias}]");
                processor.Start();
                processors.Add(processor);
            }
        }
Beispiel #9
0
        private void Validate(string name,
                              string parameters,
                              string values,
                              out List <string> requestedParams,
                              out List <string> passedParams,
                              out List <string> passedValues,
                              out ConfigurationEntry config)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new BadRequestException("No config requested");
            }

            var configs = _configurationReader.ReadConfiguration();

            config = configs.FirstOrDefault(x => string.Equals(x.Name.ToLower(), name.ToLower(), StringComparison.InvariantCulture));

            if (config == null)
            {
                throw new ConfigurationNotFoundException("Configuration not found");
            }

            requestedParams = Parse(config.Parameters);
            passedParams    = Parse(parameters);
            passedValues    = Parse(values);

            if (requestedParams.Count != passedParams.Count)
            {
                throw new BadRequestException("Parameters passed are incorrect");
            }

            if (passedParams.Count != passedValues.Count)
            {
                throw new BadRequestException("Passed values are incorrect");
            }
        }