Exemplo n.º 1
0
        public void Save(Configuration item)
        {
            try
            {
                using (var db = new FocaContextDb())
                {
                    var Config = db.Configurations.FirstOrDefault() ?? new Configuration();

                    Config.AvaliableTechExtensions = item.AvaliableTechExtensions;
                    Config.BingApiKey = item.BingApiKey;
                    Config.DefaultDnsCacheSnooping = item.DefaultDnsCacheSnooping;
                    Config.FingerPrintingAllFtp    = item.FingerPrintingAllFtp;
                    Config.FingerPrintingAllHttp   = item.FingerPrintingAllHttp;
                    Config.FingerPrintingAllSmtp   = item.FingerPrintingAllSmtp;
                    Config.FingerPrintingDns       = item.FingerPrintingDns;
                    Config.GoogleApiCx             = item.GoogleApiCx;
                    Config.GoogleApiKey            = item.GoogleApiKey;
                    Config.MaxRecursion            = item.MaxRecursion;
                    Config.SimultaneousDownloads   = item.SimultaneousDownloads;
                    Config.ProjectConfigFile       = item.ProjectConfigFile;
                    Config.ParallelDnsQueries      = item.ParallelDnsQueries;
                    Config.UseAllDns = item.UseAllDns;
                    Config.UseHead   = item.UseHead;
                    Config.SelectedTechExtensions = item.SelectedTechExtensions;
                    Config.SPathsPlugins          = item.SPathsPlugins;
                    Config.ShodanApiKey           = item.ShodanApiKey;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
        public static bool IsDatabaseAvailable(string connectionString)
        {
            if (String.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            try
            {
                using (FocaContextDb context = new FocaContextDb(connectionString))
                {
                    context.Database.CreateIfNotExists();
                    context.Database.Connection.Open();
                    context.Database.Connection.Close();
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }