Esempio n. 1
0
 public void SaveConfig(string path, CheckConfiguration config)
 {
     var writer = new DataContractSerializer(typeof(CheckConfiguration));
     var file = File.Open(path, FileMode.Create);
     writer.WriteObject(file, config);
     file.Close();
 }
Esempio n. 2
0
        public CheckViewModel(CheckConfiguration config)
        {
            Groups = new ObservableCollection<CheckGroupViewModel>();

            foreach (var group in config.CheckGroups)
            {
                Groups.Add(new CheckGroupViewModel(group));
            }
        }
Esempio n. 3
0
        public void GenerateConfig()
        {
            var repo = new ConfigurationRepository();

            var config = new CheckConfiguration
            {
                Name = "Config",
                CheckGroups = new List<CheckGroup>
                {
                    new CheckGroup
                    {
                        Name = "Local Azure Storage",
                        Checks = new List<IEnvironmentCheck>
                        {
                            new ProcessCheck
                            {
                                Name = "Windows Azure Storage Emulator Check",
                                Description = "Checks that the Azure storage emulator process is running",
                                ProcessName = "AzureStorageEmulator.exe",
                                FailsGroup = true
                            },
                            new AzureStorageCheck
                            {
                                Name = "Azure storage JWT key check",
                                Description = "Checks for the existence of the JWT key in local Azure storage",
                                ConnectionString = "UseDevelopmentStorage=true;",
                                ContainerName = "sonovate",
                                BlobKey = "keys/jwt.key"
                            },
                            new AzureStorageCheck
                            {
                                Name = "Azure storage LinkedIn key check",
                                Description = "Checks for the existence of the LinkedIn key in local Azure storage",
                                ConnectionString = "UseDevelopmentStorage=true;",
                                ContainerName = "sonovate",
                                BlobKey = "oauth/LinkedIn.oauth"
                            },
                            new AzureStorageCheck
                            {
                                Name = "Azure storage GooglePlus key check",
                                Description = "Checks for the existence of the GooglePlus key in local Azure storage",
                                ConnectionString = "UseDevelopmentStorage=true;",
                                ContainerName = "sonovate",
                                BlobKey = "oauth/GooglePlus.oauth"
                            }
                        }

                    },
                    new CheckGroup
                    {
                        Name = "Redis",
                        Checks = new List<IEnvironmentCheck>
                        {
                            new ProcessCheck
                            {
                                Name = "Redis Process Check",
                                Description = "Checks the Redis server process is running",
                                ProcessName = "redis-server.exe"
                            },
                            new ServiceCheck
                            {
                                Name = "Redis Service Check",
                                Description = "Checks the Redis service is running",
                                ServiceDisplayName = "Redis",
                                State = "Running",
                                FailureLevel = FailureLevel.Warning
                            }
                        }
                    },
                    new CheckGroup {
                        Name = "PostgreSQL",

                        Checks = new List<IEnvironmentCheck>
                        {
                            new ServiceCheck
                            {
                                Name = "Postgresql Service Check",
                                Description = "Checks the PostgreSql service is running",
                                ServiceDisplayName = "PostgreSQL Server",
                                State = "Running",
                                FuzzyMatch = true
                            },
                            new ProcessCheck
                            {
                                Name = "Postgresql Process Check",
                                Description = "Checks the PostgreSql process is running",
                                ProcessName = "postgres.exe",
                                FailsGroup = true
                            },
                            new PostgresqlCheck
                            {
                                Name = "PostgreSql Core Check",
                                Description = "Checks for the existence of the Core database in PostgreSql",
                                ConnectionString = @"Server=127.0.0.1;Port=5432;User Id=dev_user;Password=Development1;Database=sv_core;",
                                SqlQuery = "SELECT datname FROM pg_catalog.pg_database WHERE lower(datname) = lower('sv_core');",
                                ExpectedRecordCount = 1
                            },
                            new PostgresqlCheck
                            {
                                Name = "PostgreSql Directory Check",
                                Description = "Checks for the existence of the Directory database in PostgreSql",
                                ConnectionString = @"Server=127.0.0.1;Port=5432;User Id=dev_user;Password=Development1;Database=sv_directory;",
                                SqlQuery = "SELECT datname FROM pg_catalog.pg_database WHERE lower(datname) = lower('sv_directory');",
                                ExpectedRecordCount = 1
                            },
                            new PostgresqlCheck
                            {
                                Name = "Api Key Check",
                                Description = "Checks for the existence of an API key in the Core database",
                                ConnectionString = @"Server=127.0.0.1;Port=5432;User Id=dev_user;Password=Development1;Database=sv_core;",
                                SqlQuery = "SELECT *FROM cor_api_key;",
                                ExpectedRecordCount = -1,
                                FailureLevel = FailureLevel.Warning
                            }
                        }
                    },
                    new CheckGroup
                    {
                        Name = "Utility",
                        Checks = new List<IEnvironmentCheck>
                        {
                            new RegistryCheck
                            {
                                Name = "Url Rewriter Check",
                                Description = "Checks the Url rewriter is installed",
                                KeyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\URL Rewrite",
                                KeyName = "Version"
                            },
                            new OptionalFeatureCheck
                            {
                                Name = "IIS feature check",
                                Description = "Checks whether IIS has been activated as an optional feature",
                                FeatureCaption = "Internet Information Services"
                            }
                        }
                    }
                }
            };

            repo.SaveConfig("D:/config.xml", config);
        }