Ejemplo n.º 1
0
        private static void WipeSqlServerCredentials(string webRootPath)
        {
            var pathToConnectionStringsConfig = webRootPath.PathCombine("App_Config").PathCombine("ConnectionStrings.config");

            var connectionStringsDocument = new XmlDocumentEx();

            connectionStringsDocument.Load(pathToConnectionStringsConfig);

            var connectionsStringsElement = new XmlElementEx(connectionStringsDocument.DocumentElement, connectionStringsDocument);

            var connectionStrings = new ConnectionStringCollection(connectionsStringsElement);

            connectionStrings.AddRange(connectionsStringsElement.Element.ChildNodes.OfType <XmlElement>().Select(element => new ConnectionString(element, connectionsStringsElement.Document)));

            foreach (var connectionString in connectionStrings)
            {
                if (!connectionString.IsSqlConnectionString)
                {
                    continue;
                }

                var builder = new SqlConnectionStringBuilder(connectionString.Value)
                {
                    DataSource = string.Empty,
                    UserID     = string.Empty,
                    Password   = string.Empty
                };
                connectionString.Value = builder.ToString();
            }

            connectionStrings.Save();
        }
Ejemplo n.º 2
0
        private void InitializeDatabase()
        {
            Task.Factory.StartNew(() =>
            {
                IEncryptionAgent encryption;
                string passwd;

                IDbManager dbManager       = new Krokot.Database.Petapoco.PetapocoDbManager(null, null);
                IFileLoader resourceloader = new ResourceSqlLoader("resource-loader", "SqlFiles", Assembly.GetAssembly(this.GetType()));
                dbManager.AddSqlLoader(resourceloader);

                ConnectionStringCollection connections = ApplicationSettings.Instance.Database.Items;
                foreach (ConnectionStringElement connection in connections)
                {
                    encryption = new RijndaelEncryption(connection.Key, connection.IV);
                    passwd     = encryption.Decrypt(connection.Password);

                    dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
                    {
                        ConnectionString = string.Format(connection.ConnectionString, connection.UserId, passwd),
                        IsDefault        = connection.IsDefault,
                        Name             = connection.Name,
                        ProviderName     = connection.ProviderName
                    });
                }

                ObjectPool.Instance.Register <IDbManager>().ImplementedBy(dbManager);
            });
        }
        /// <summary>
        /// Returns the desired command based on the provided <see cref="OptionObject2015"/> and parameter.
        /// </summary>
        /// <param name="optionObject"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static IRunScriptCommand GetCommand(IOptionObject2015 optionObject, IParameter parameter)
        {
            if (optionObject == null)
            {
                logger.Error("The provided OptionObject2015 is null");
            }

            IOptionObjectDecorator optionObjectDecorator = new OptionObjectDecorator(optionObject);

            logger.Debug("Script '" + parameter.ScriptName + "' requested.");

            // Get Dependencies
            ConnectionStringCollection odbcConnectionStrings = ConnectionStringSelector.GetConnectionStringCollection();
            var repository  = new GetOdbcDataRepository(odbcConnectionStrings);
            var smtpService = new SmtpService();

            switch (parameter.ScriptName.ToUpperInvariant().Trim())
            {
                #region General Purpose Commands

                #endregion

                #region PM/Cal-PM Commands

                #endregion

                #region CWS Commands

                #endregion

                #region MSO Commands

                #endregion

                #region Utility and Testing Commands

            case "GETODBCDATA":
                logger.Debug("{command} selected.", nameof(GetOdbcDataCommand));
                return(new GetOdbcDataCommand(optionObjectDecorator, repository));

            case "HELLOWORLD":
                logger.Debug(nameof(HelloWorldCommand) + " selected.");
                return(new HelloWorldCommand(optionObjectDecorator));

            case "SENDEMAIL":
                logger.Debug("{command} selected.", nameof(SendEmailCommand));
                return(new SendEmailCommand(optionObjectDecorator, smtpService));

            case "SETFIELDVALUE":
                logger.Debug("{command} selected.", nameof(SetFieldValueCommand));
                return(new SetFieldValueCommand(optionObjectDecorator, parameter));

                #endregion

            default:
                logger.Warn(nameof(DefaultCommand) + " selected because ScriptName '" + parameter.ScriptName + "' does not match an existing command option.");
                return(new DefaultCommand(optionObjectDecorator, parameter));
            }
        }
    private ConnectionStringCollection GetConnectionStringCollection(XmlElementEx connectionStringsNode)
    {
      var connectionStrings = new ConnectionStringCollection(connectionStringsNode);
      XmlNodeList addNodes = connectionStringsNode.Element.ChildNodes;
      connectionStrings.AddRange(addNodes.OfType<XmlElement>().Select(element => new ConnectionString(element, connectionStringsNode.Document)));

      return connectionStrings;
    }
        private ConnectionStringCollection GetConnectionStringCollection(XmlElementEx connectionStringsNode)
        {
            var         connectionStrings = new ConnectionStringCollection(connectionStringsNode);
            XmlNodeList addNodes          = connectionStringsNode.Element.ChildNodes;

            connectionStrings.AddRange(addNodes.OfType <XmlElement>().Select(element => new ConnectionString(element, connectionStringsNode.Document)));

            return(connectionStrings);
        }
Ejemplo n.º 6
0
        void OnConfigChanged(object sender, EventArgs args)
        {
            ConnectionStringCollection collection = (ConnectionStringCollection)sender;

            foreach (string instanceName in collection)
            {
                string connString = collection[instanceName];
                if (databases.Contains(instanceName))
                {
                    Database db = databases[instanceName];
                    db.SetConnectionString(connString);
                }
            }
        }
        protected override void Process(ImportArgs args)
        {
            var pathToConnectionStringsConfig = args._RootPath.PathCombine("Website").PathCombine("App_Config").PathCombine("ConnectionStrings.config");
            var connectionStringsDocument     = new XmlDocumentEx();

            connectionStringsDocument.Load(pathToConnectionStringsConfig);
            var connectionsStringsElement = new XmlElementEx(connectionStringsDocument.DocumentElement, connectionStringsDocument);
            ConnectionStringCollection connStringCollection = GetConnectionStringCollection(connectionsStringsElement);

            foreach (var conn in connStringCollection)
            {
                if (conn.IsSqlConnectionString)
                {
                    var builder = new SqlConnectionStringBuilder(conn.Value)
                    {
                        IntegratedSecurity = false,
                        DataSource         = args._ConnectionString.DataSource,
                        UserID             = args._ConnectionString.UserID,
                        Password           = args._ConnectionString.Password
                    };

                    if (args._DatabaseNameAppend != -1)
                    {
                        builder.InitialCatalog = $"{builder.InitialCatalog}_{args._DatabaseNameAppend}";
                    }
                    else
                    {
                        builder.InitialCatalog = builder.InitialCatalog;
                    }

                    conn.Value = builder.ToString();
                }
                else if (conn.IsMongoConnectionString)
                {
                    var builder = new MongoUrlBuilder(conn.Value);

                    foreach (var database in args.ExtractedMongoDatabases)
                    {
                        if (database.OriginalName == builder.DatabaseName)
                        {
                            builder.DatabaseName = database.FinalName;
                            conn.Value           = builder.ToString();
                            break;
                        }
                    }
                }
            }

            connStringCollection.Save();
        }
        public void GetCommand_GetOdbcData_ReturnsGetOdbcDataCommand()
        {
            // Arrange
            OptionObject2015           optionObject2015           = new OptionObject2015();
            IOptionObjectDecorator     optionObjectDecorator      = new OptionObjectDecorator(optionObject2015);
            IParameter                 parameter                  = new Parameter("GetOdbcData");
            ConnectionStringCollection connectionStringCollection = new ConnectionStringCollection("", "", "");
            var repository = new GetOdbcDataRepository(connectionStringCollection);
            GetOdbcDataCommand expected = new GetOdbcDataCommand(optionObjectDecorator, repository);

            // Act
            IRunScriptCommand actual = CommandSelector.GetCommand(optionObject2015, parameter);

            // Assert
            Assert.AreEqual(expected.GetType(), actual.GetType());
        }
        public static IServiceCollection AddFluentCommander(this IServiceCollection services, IConfiguration config)
        {
            new CommanderBootstrapper().Bootstrap(services);

            services.AddScoped <IDatabaseCommanderFactory, OracleDatabaseCommanderFactory>();

            var connectionStringCollection = new ConnectionStringCollection(config);

            if (connectionStringCollection.ConnectionStringNames.Contains("DefaultConnection"))
            {
                services.AddSingleton(new OracleConnectionStringBuilder(connectionStringCollection.Get("DefaultConnection")));
                services.AddTransient <IDatabaseCommander, OracleDatabaseCommander>();
            }

            return(services);
        }
        public IServiceCollection Bootstrap(IServiceCollection services, IConfiguration configuration)
        {
            new CommanderBootstrapper().Bootstrap(services);

            services.AddTransient <SqlServerBulkCopyCommand>();
            services.AddTransient <SqlServerPaginationCommand>();
            services.AddTransient(typeof(SqlServerScalarCommand <>));
            services.AddTransient <SqlServerSqlNonQueryCommand>();
            services.AddTransient <SqlServerSqlQueryCommand>();
            services.AddTransient <SqlServerStoredProcedureCommand>();
            services.AddTransient <ISqlServerCommandExecutor, SqlServerCommandExecutor>();

            var connectionStringCollection = new ConnectionStringCollection(configuration);

            if (connectionStringCollection.ConnectionStringNames.Contains("DefaultConnection"))
            {
                services.AddSingleton(new SqlConnectionStringBuilder(connectionStringCollection.Get("DefaultConnection")));
                services.AddTransient <IDatabaseCommander, SqlServerDatabaseCommander>();
            }

            return(services);
        }
        protected override void Process(ImportArgs args)
        {
            var pathToConnectionStringsConfig = args.rootPath.PathCombine("Website").PathCombine("App_Config").PathCombine("ConnectionStrings.config");
            var connectionStringsDocument     = new XmlDocumentEx();

            connectionStringsDocument.Load(pathToConnectionStringsConfig);
            var connectionsStringsElement = new XmlElementEx(connectionStringsDocument.DocumentElement, connectionStringsDocument);
            ConnectionStringCollection connStringCollection = this.GetConnectionStringCollection(connectionsStringsElement);

            foreach (var conn in connStringCollection)
            {
                if (conn.IsSqlConnectionString)
                {
                    var builder = new SqlConnectionStringBuilder(conn.Value)
                    {
                        IntegratedSecurity = false,
                        DataSource         = args.connectionString.DataSource,
                        UserID             = args.connectionString.UserID,
                        Password           = args.connectionString.Password
                    };

                    if (args.databaseNameAppend != -1)
                    {
                        builder.InitialCatalog = builder.InitialCatalog + "_" + args.databaseNameAppend.ToString();
                    }
                    else
                    {
                        builder.InitialCatalog = builder.InitialCatalog;
                    }

                    conn.Value = builder.ToString();
                }
            }

            connStringCollection.Save();
        }
Ejemplo n.º 12
0
        public void ValidateConnectionStrings(
            [Operand(Name = "names", Description = "The space-separated list of module names.")] List <string> moduleNames,
            [Option(LongName = "all", ShortName = "a")] bool all)
        {
            if (moduleNames == null || moduleNames.Count == 0)
            {
                if (!all)
                {
                    CommandLineHandler.DisplayHelp("test connection-strings");
                    return;
                }
            }
            else if (all)
            {
                CommandLineHandler.DisplayHelp("test connection-strings");
                return;
            }

            var commandContext = CommandLineHandler.Context;

            if (all)
            {
                moduleNames = ModuleLister.GetAllModules(commandContext);
            }

            var allConnectionStrings = new List <NamedConnectionString>();
            var index = 0;

            foreach (var moduleName in moduleNames)
            {
                var moduleConfiguration = ModuleConfigurationLoader.LoadModuleConfiguration(commandContext, moduleName, null, null);
                if (moduleConfiguration == null)
                {
                    continue;
                }

                if (index == 0)
                {
                    var sharedCs = new ConnectionStringCollection();
                    sharedCs.LoadFromConfiguration(moduleConfiguration.Configuration, "ConnectionStrings:Shared", commandContext.HostConfiguration.SecretProtector);
                    if (sharedCs.All.Any())
                    {
                        commandContext.Logger.Information("connection strings for: {Module}", "Shared");
                        foreach (var cs in sharedCs.All)
                        {
                            commandContext.Logger.Information("\t{ConnectionStringName} ({Provider})", cs.Name, cs.GetFriendlyProviderName());
                            allConnectionStrings.Add(cs);
                        }
                    }
                }

                commandContext.Logger.Information("connection strings for: {Module}", moduleName);

                var connectionStrings = new ConnectionStringCollection();
                connectionStrings.LoadFromConfiguration(moduleConfiguration.Configuration, "ConnectionStrings:Module", commandContext.HostConfiguration.SecretProtector);
                foreach (var cs in connectionStrings.All)
                {
                    commandContext.Logger.Information("\t{ConnectionStringName} ({Provider})", cs.Name, cs.GetFriendlyProviderName());
                    allConnectionStrings.RemoveAll(x => x.Name == cs.Name);
                    allConnectionStrings.Add(cs);
                }

                index++;
            }

            commandContext.Logger.Information("relevant connection strings");
            var originalNames = allConnectionStrings
                                .Select(x => x.Name.Split('-')[0])
                                .Distinct()
                                .ToList();

            foreach (var originalName in originalNames)
            {
                var connectionString = allConnectionStrings.Find(x => string.Equals(x.Name, originalName + "-" + Environment.MachineName, StringComparison.InvariantCultureIgnoreCase))
                                       ?? allConnectionStrings.Find(x => string.Equals(x.Name, originalName, StringComparison.InvariantCultureIgnoreCase));

                var knownFields = connectionString.GetKnownConnectionStringFields();
                if (knownFields == null)
                {
                    commandContext.Logger.Information("\ttesting: {ConnectionStringName} ({Provider})",
                                                      connectionString.Name, connectionString.GetFriendlyProviderName());
                }
                else
                {
                    var message = "\ttesting: {ConnectionStringName} ({Provider})";
                    var args    = new List <object>()
                    {
                        connectionString.Name,
                        connectionString.GetFriendlyProviderName(),
                    };

                    if (knownFields.Server != null)
                    {
                        message += ", server: {Server}";
                        args.Add(knownFields.Server);
                    }

                    if (knownFields.Port != null)
                    {
                        message += ", port: {Port}";
                        args.Add(knownFields.Port);
                    }

                    if (knownFields.Database != null)
                    {
                        message += ", database: {Database}";
                        args.Add(knownFields.Database);
                    }

                    if (knownFields.IntegratedSecurity != null)
                    {
                        message += ", integrated security: {IntegratedSecurity}";
                        args.Add(knownFields.IntegratedSecurity);
                    }

                    if (knownFields.UserId != null)
                    {
                        message += ", user: {UserId}";
                        args.Add(knownFields.UserId);
                    }

                    commandContext.Logger.Information(message, args.ToArray());
                }

                try
                {
                    EtlConnectionManager.TestConnection(connectionString);
                    commandContext.Logger.Information("\t\tPASSED");
                }
                catch (Exception ex)
                {
                    commandContext.Logger.Write(LogEventLevel.Fatal, "\t\t{ErrorMessage}", ex.FormatExceptionWithDetails(false));
                }
            }

            commandContext.Logger.Information("connection string test(s) finished");
        }
Ejemplo n.º 13
0
        internal static ModuleConfiguration LoadModuleConfiguration(CommandContext commandContext, string moduleName, string[] moduleSettingOverrides, string[] pluginListOverride)
        {
            var sharedFolder         = Path.Combine(commandContext.HostConfiguration.ModulesFolder, "Shared");
            var sharedConfigFileName = Path.Combine(sharedFolder, "shared-configuration.json");

            var moduleFolder = Path.Combine(commandContext.HostConfiguration.ModulesFolder, moduleName);

            if (!Directory.Exists(moduleFolder))
            {
                commandContext.Logger.Write(LogEventLevel.Fatal, "can't find the module folder: {Folder}", moduleFolder);
                commandContext.OpsLogger.Write(LogEventLevel.Fatal, "can't find the module folder: {Folder}", moduleFolder);
                return(null);
            }

            moduleFolder = Directory.GetDirectories(commandContext.HostConfiguration.ModulesFolder, moduleName, SearchOption.TopDirectoryOnly).FirstOrDefault();
            moduleName   = Path.GetFileName(moduleFolder);

            var configurationBuilder = new ConfigurationBuilder();

            if (File.Exists(sharedConfigFileName))
            {
                configurationBuilder.AddJsonFile(sharedConfigFileName);
                commandContext.Logger.Debug("using shared configuration file from {FileName}", PathHelpers.GetFriendlyPathName(sharedConfigFileName));

                try
                {
                    configurationBuilder.Build();
                }
                catch (Exception ex)
                {
                    throw new ConfigurationFileException(PathHelpers.GetFriendlyPathName(sharedConfigFileName), "can't read the configuration file", ex);
                }
            }

            var moduleConfigFileName = Path.Combine(moduleFolder, "module-configuration.json");

            if (!File.Exists(moduleConfigFileName))
            {
                commandContext.Logger.Write(LogEventLevel.Fatal, "can't find the module configuration file: {FileName}", moduleConfigFileName);
                commandContext.OpsLogger.Write(LogEventLevel.Fatal, "can't find the module configuration file: {FileName}", moduleConfigFileName);
                return(null);
            }

            configurationBuilder.AddJsonFile(moduleConfigFileName);
            commandContext.Logger.Debug("using module configuration file from {FileName}", PathHelpers.GetFriendlyPathName(moduleConfigFileName));

            IConfigurationRoot configuration;

            try
            {
                configuration = configurationBuilder.Build();
                AddCommandLineArgumentsToModuleConfiguration(configuration, moduleSettingOverrides);
            }
            catch (Exception ex)
            {
                throw new ConfigurationFileException(PathHelpers.GetFriendlyPathName(moduleConfigFileName), "can't read the configuration file", ex);
            }

            var pluginNamesToExecute = pluginListOverride;

            if (pluginNamesToExecute == null || pluginNamesToExecute.Length == 0)
            {
                pluginNamesToExecute = configuration.GetSection("Module:PluginsToExecute-" + Environment.MachineName).Get <string[]>();
            }

            if (pluginNamesToExecute == null || pluginNamesToExecute.Length == 0)
            {
                pluginNamesToExecute = configuration.GetSection("Module:PluginsToExecute").Get <string[]>();
            }

            var broken = false;

            foreach (var pluginName in pluginNamesToExecute.Where(x => x.Contains(',', StringComparison.InvariantCultureIgnoreCase) || x.Contains(' ', StringComparison.InvariantCultureIgnoreCase)))
            {
                commandContext.Logger.Write(LogEventLevel.Fatal, "plugin name can't contain comma or space character: [{Plugin}]", pluginName);
                broken = true;
            }

            if (broken)
            {
                return(null);
            }

            var allConnectionStrings = new List <NamedConnectionString>();
            var sharedCs             = new ConnectionStringCollection();

            sharedCs.LoadFromConfiguration(configuration, "ConnectionStrings:Shared", commandContext.HostConfiguration.SecretProtector);
            foreach (var cs in sharedCs.All)
            {
                allConnectionStrings.Add(cs);
            }

            var moduleCs = new ConnectionStringCollection();

            moduleCs.LoadFromConfiguration(configuration, "ConnectionStrings:Module", commandContext.HostConfiguration.SecretProtector);
            foreach (var cs in moduleCs.All)
            {
                allConnectionStrings.RemoveAll(x => x.Name == cs.Name);
                allConnectionStrings.Add(cs);
            }

            var relevantConnectionStrings = new ConnectionStringCollection();

            if (allConnectionStrings?.Count > 0)
            {
                var originalNames = allConnectionStrings
                                    .Select(x => x.Name.Split('-')[0])
                                    .Distinct()
                                    .ToList();

                foreach (var originalName in originalNames)
                {
                    var connectionString = allConnectionStrings.Find(x => string.Equals(x.Name, originalName + "-" + Environment.MachineName, StringComparison.InvariantCultureIgnoreCase))
                                           ?? allConnectionStrings.Find(x => string.Equals(x.Name, originalName, StringComparison.InvariantCultureIgnoreCase));

                    relevantConnectionStrings.Add(connectionString);
                }
            }

            return(new ModuleConfiguration()
            {
                ModuleName = moduleName,
                ConfigurationFileName = moduleConfigFileName,
                ModuleFolder = moduleFolder,
                Configuration = configuration,
                ConnectionStrings = relevantConnectionStrings,
                EnabledPluginList = pluginNamesToExecute
                                    .Select(name => name.Trim())
                                    .Where(name => !name.StartsWith("!", StringComparison.InvariantCultureIgnoreCase))
                                    .Where(plugin => plugin != null)
                                    .ToList(),
                SecretProtector = commandContext.HostConfiguration.SecretProtector,
            });
        }
Ejemplo n.º 14
0
 public GetOdbcDataRepository(ConnectionStringCollection connectionStringCollection)
 {
     _connectionStringCollection = connectionStringCollection;
 }
Ejemplo n.º 15
0
 internal DatabaseManager()
 {
     databases = new DatabaseCollection();
     ConnectionStringCollection.RegisterConfigChangedNotification(OnConfigChanged);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Returns the desired command based on the provided <see cref="OptionObject2015"/> and parameter.
        /// </summary>
        /// <param name="optionObject"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static IRunScriptCommand GetCommand(OptionObject2015 optionObject, string parameter)
        {
            if (optionObject == null)
            {
                logger.Error("The provided {object} is null", nameof(OptionObject2015));
                return(new DefaultCommand(optionObject, parameter));
            }

            // Determine ScriptName
            logger.Debug("Parameter for scriptName is:  " + parameter);
            string scriptName = parameter != null?parameter.Split(',')[0] : "";

            logger.Debug("Script '" + scriptName + "' requested.");

            // Get Dependencies
            // Replace with this line when ready to do ODBC from SBOX and BLD
            //ConnectionStringCollection odbcConnectionStrings = ConnectionStringSelector.GetConnectionStringCollection(optionObject.Facility, optionObject.NamespaceName);
            ConnectionStringCollection odbcConnectionStrings = ConnectionStringSelector.GetConnectionStringCollection(optionObject.Facility);

            logger.Debug("Facility is: " + optionObject.Facility);
            var repository = new GetOdbcDataRepository(odbcConnectionStrings);

            logger.Debug("Repository is: " + repository.ToString());
            var smtpService = new SmtpService();

            logger.Debug("SMTP is: " + smtpService.ToString());

            // Select Command, Not Case Sensitive
            switch (scriptName.ToUpperInvariant().Trim())
            {
            // General Commands
            case "ADDDURATIONANDTIME":
                logger.Debug(nameof(AddDurationAndTimeCommand) + " selected.");
                return(new AddDurationAndTimeCommand(optionObject, parameter));

            case "CHKCHRS":
                logger.Debug(nameof(ChkChrsCommand) + " selected.");
                return(new ChkChrsCommand(optionObject, parameter));

            // PM Commands
            case "DIAGNOSISFORMLOAD":
                logger.Debug(nameof(DiagnosisFormLoadCommand) + " selected.");
                return(new DiagnosisFormLoadCommand(optionObject, repository));

            // CWS Commands

            // Testing and Sample ("Utility") Commands
            case "GETODBCDATA":
                logger.Debug(nameof(GetOdbcDataCommand) + " selected.");
                return(new GetOdbcDataCommand(optionObject, repository));

            case "HELLOWORLD":
                logger.Debug(nameof(HelloWorldCommand) + " selected.");
                return(new HelloWorldCommand(optionObject));

            case "SENDTESTEMAIL":
                logger.Debug(nameof(SendTestEmailCommand) + " selected.");
                return(new SendTestEmailCommand(optionObject, parameter, smtpService));

            // If nothing matches
            default:
                logger.Warn(nameof(DefaultCommand) + " selected because ScriptName '" + scriptName + "' does not match an existing command.");
                return(new DefaultCommand(optionObject, parameter));
            }
        }
        private static void WipeSqlServerCredentials(string webRootPath)
        {
            var pathToConnectionStringsConfig = webRootPath.PathCombine("App_Config").PathCombine("ConnectionStrings.config");

              var connectionStringsDocument = new XmlDocumentEx();
              connectionStringsDocument.Load(pathToConnectionStringsConfig);

              var connectionsStringsElement = new XmlElementEx(connectionStringsDocument.DocumentElement, connectionStringsDocument);

              var connectionStrings = new ConnectionStringCollection(connectionsStringsElement);
              connectionStrings.AddRange(connectionsStringsElement.Element.ChildNodes.OfType<XmlElement>().Select(element => new ConnectionString(element, connectionsStringsElement.Document)));

              foreach (var connectionString in connectionStrings)
              {
            if (!connectionString.IsSqlConnectionString)
            {
              continue;
            }

            var builder = new SqlConnectionStringBuilder(connectionString.Value)
            {
              DataSource = string.Empty,
              UserID = string.Empty,
              Password = string.Empty
            };
            connectionString.Value = builder.ToString();
              }

              connectionStrings.Save();
        }
Ejemplo n.º 18
0
 private OrmLiteConnectionManager()
 {
     ConnectionStringCollection.RegisterConfigChangedNotification(OnConfigChanged);
 }