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(); }
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(); }
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 connectionStringBuilder = new SqlConnectionStringBuilder(conn.Value) { IntegratedSecurity = false, DataSource = args.connectionString.DataSource, UserID = args.connectionString.UserID, Password = args.connectionString.Password }; connectionStringBuilder.InitialCatalog = DatabaseNameHelper.GetDatabaseNameFromSiteAndName( args.siteName, DatabaseNameHelper.GetDatabaseNameFromFiles(connectionStringBuilder.InitialCatalog), false); conn.Value = connectionStringBuilder.ToString(); } else if (conn.IsMongoConnectionString) { conn.Value = DatabaseNameHelper.ProcessMongoConnectionString(args.siteName, conn.Value); } } connStringCollection.Save(); }
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); }
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 async Task NodeWriteStaticScalarXmlElementValueVariableTest() { var browser = _services(); var node = "http://test.org/UA/Data/#i=10231"; var expected = JToken.FromObject(XmlElementEx.SerializeObject( new MemoryBufferInstance { Name = "test", TagCount = 333, DataType = "Byte" })); // Act var result = await browser.NodeValueWriteAsync(_endpoint, new ValueWriteRequestModel { NodeId = node, Value = expected, DataType = "XmlElement" }); // Assert await AssertResult(node, expected, result); }
public static ConnectionStringCollection GetConnectionStrings(string webRootPath) { XmlElementEx connectionStringsNode = GetConnectionStringsElement(XmlDocumentEx.LoadFile(Path.Combine(webRootPath, "web.config"))); return(GetConnectionStringCollection(connectionStringsNode)); }
public ConnectionStringCollection([NotNull] XmlElementEx connectionStringsElement) { Assert.ArgumentNotNull(connectionStringsElement, nameof(connectionStringsElement)); ConnectionStringsElement = connectionStringsElement; }
private ConnectionString([NotNull] XmlElementEx xmlElement) { Assert.ArgumentNotNull(xmlElement, "xmlElement"); this.element = xmlElement; }
public ConnectionStringCollection([NotNull] XmlElementEx connectionStringsElement) { Assert.ArgumentNotNull(connectionStringsElement, "connectionStringsElement"); this.connectionStringsElement = connectionStringsElement; }
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(); }
private ConnectionString([NotNull] XmlElementEx xmlElement) { Assert.ArgumentNotNull(xmlElement, nameof(xmlElement)); this.Element = xmlElement; }