public void VerifyElement(string filePath, VerifiableLog log) { using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, false)) { ConnectionsPart connectionsPart = package.WorkbookPart.ConnectionsPart; X15.Connection connection = connectionsPart.Connections.Descendants <X15.Connection>().First(); X15.OleDbPrpoperties oleDbPrpoperties = connection.OleDbPrpoperties; log.Verify(oleDbPrpoperties.Connection == ConnectionString, "OleDbPrpoperties Connection value is not change."); X15.DbCommand dbCommand = oleDbPrpoperties.DbCommand; log.Verify(DBCommandText == dbCommand.Text, "DBCommandText value is not change."); } }
public void EditElement(string filePath, VerifiableLog log) { using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, true)) { ConnectionsPart connectionsPart = package.WorkbookPart.ConnectionsPart; X15.Connection connection = connectionsPart.Connections.Descendants <X15.Connection>().First(); X15.OleDbPrpoperties oleDbPrpoperties = connection.OleDbPrpoperties; oleDbPrpoperties.Connection = ConnectionString; log.Pass("Edited the OleDbPrpoperties connection"); X15.DbCommand dbCommand = oleDbPrpoperties.DbCommand; dbCommand.Text = DBCommandText; log.Pass("Edited the DbCommand."); } }
public void DeleteElement(string filePath, VerifiableLog log) { using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, true)) { ConnectionsPart connectionsPart = package.WorkbookPart.ConnectionsPart; X15.Connection connection = connectionsPart.Connections.Descendants <X15.Connection>().First(); X15.OleDbPrpoperties oleDbPrpoperties = connection.OleDbPrpoperties; oleDbPrpoperties.DbCommand.Remove(); log.Pass("Deleted The DbCommand."); oleDbPrpoperties.Remove(); log.Pass("Deleted The OleDbPrpoperties."); connection.Parent.Parent.Parent.Remove(); log.Pass("Deleted The Connection."); } }
public void VerifyConnection(string filePath, VerifiableLog log) { using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, false)) { ConnectionsPart connectionsPart = package.WorkbookPart.ConnectionsPart; X15.Connection connection = connectionsPart.Connections.Descendants <X15.Connection>().Where(e => e.Descendants <X15.OleDbPrpoperties>().Count() > 0).First(); log.Verify(connection != null, "Unable to obtain the X15.Connection"); X15.OleDbPrpoperties oleDbPrpoperties = connection.OleDbPrpoperties; log.Verify(oleDbPrpoperties != null, "Unable to obtain the X15.OleDbPrpoperties"); X15.DbTables dbTables = oleDbPrpoperties.DbTables; string connectionString = oleDbPrpoperties.Connection; log.Verify(connectionString != null, "Unable to obtain the X15.OleDbPrpoperties on Connection"); X15.DbCommand dbCommand = oleDbPrpoperties.DbCommand; log.Verify(dbCommand != null, "Unable to obtain the X15.DbCommand"); } }
public ConnectionTestEntities(string filePath) { using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, false)) { ConnectionsPart connectionsPart = package.WorkbookPart.ConnectionsPart; foreach (Connection connection in connectionsPart.Connections) { if (connection.Id == 1) { ConnectionId = connection.Id; ConnectionOdcFile = connection.ConnectionFile; ConnectionName = connection.Name; ConnectionType = connection.Type; ConnectionRefreshedVersion = connection.RefreshedVersion; ConnectionMinRefreshedVersion = connection.MinRefreshableVersion; ConnectionBackground = connection.Background; } } X15.Connection x15connection = connectionsPart.Connections.Descendants <X15.Connection>().FirstOrDefault(); if (x15connection == null) { throw new Exception("Unable to obtain the X15.Connection."); } X15ConnectionId = x15connection.Id; X15ConnectionAutoDelete = x15connection.AutoDelete; ConnectionExtension connectionExtension = new ConnectionExtension(x15connection.Parent.OuterXml); ConnectionExtUri = connectionExtension.Uri; X15.OleDbPrpoperties oleDbPrpoperties = x15connection.OleDbPrpoperties; ConnectionString = oleDbPrpoperties.Connection; X15.DbCommand dbCommand = oleDbPrpoperties.DbCommand; DBCommandText = dbCommand.Text; } }
// Generates content of connectionsPart1. private void GenerateConnectionsPart1Content(ConnectionsPart connectionsPart1) { Connections connections1 = new Connections(); Connection connection1 = new Connection(){ Id = (UInt32Value)1U, ConnectionFile = "C:\\Users\\pberruti\\Documents\\My Data Sources\\xlextdat105 Timestamps\\DAT105 Timestamp - Foodmart 2000 account.odc", Name = "DAT105 Timestamp - Foodmart 2000 account", Type = (UInt32Value)100U, RefreshedVersion = 5, MinRefreshableVersion = 5, Background = true }; ConnectionExtensionList connectionExtensionList1 = new ConnectionExtensionList(); ConnectionExtension connectionExtension1 = new ConnectionExtension(){ Uri = "{DE250136-89BD-433C-8126-D09CA5730AF9}" }; connectionExtension1.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); X15.Connection connection2 = new X15.Connection(){ Id = "d500245d-c151-4de3-9436-83c6e82b7f22", AutoDelete = true }; X15.OleDbPrpoperties oleDbPrpoperties1 = new X15.OleDbPrpoperties(){ Connection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=xlextdat105;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=PB07641564SHIP;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=Foodmart 2000" }; X15.DbCommand dbCommand1 = new X15.DbCommand(){ Text = "SELECT *, suser_name() CurrentUser, current_timestamp RefreshTime FROM \"Foodmart 2000\".\"dbo\".\"account\"" }; oleDbPrpoperties1.Append(dbCommand1); connection2.Append(oleDbPrpoperties1); connectionExtension1.Append(connection2); connectionExtensionList1.Append(connectionExtension1); connection1.Append(connectionExtensionList1); Connection connection3 = new Connection(){ Id = (UInt32Value)2U, KeepAlive = true, Name = "ModelConnection_Query", Description = "Model", Type = (UInt32Value)5U, RefreshedVersion = 5, MinRefreshableVersion = 3, SaveData = true }; DatabaseProperties databaseProperties1 = new DatabaseProperties(){ Connection = "Data Model Connection", Command = "Query", CommandType = (UInt32Value)3U }; ConnectionExtensionList connectionExtensionList2 = new ConnectionExtensionList(); ConnectionExtension connectionExtension2 = new ConnectionExtension(){ Uri = "{DE250136-89BD-433C-8126-D09CA5730AF9}" }; connectionExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); X15.Connection connection4 = new X15.Connection(){ Id = "", Model = true }; connectionExtension2.Append(connection4); connectionExtensionList2.Append(connectionExtension2); connection3.Append(databaseProperties1); connection3.Append(connectionExtensionList2); Connection connection5 = new Connection(){ Id = (UInt32Value)3U, KeepAlive = true, Name = "ThisWorkbookDataModel", Description = "Model", Type = (UInt32Value)5U, RefreshedVersion = 5, MinRefreshableVersion = 5, Background = true }; DatabaseProperties databaseProperties2 = new DatabaseProperties(){ Connection = "Data Model Connection", Command = "Model", CommandType = (UInt32Value)1U }; OlapProperties olapProperties1 = new OlapProperties(){ SendLocale = true, RowDrillCount = (UInt32Value)1000U }; ConnectionExtensionList connectionExtensionList3 = new ConnectionExtensionList(); ConnectionExtension connectionExtension3 = new ConnectionExtension(){ Uri = "{DE250136-89BD-433C-8126-D09CA5730AF9}" }; connectionExtension3.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); X15.Connection connection6 = new X15.Connection(){ Id = "", Model = true }; connectionExtension3.Append(connection6); connectionExtensionList3.Append(connectionExtension3); connection5.Append(databaseProperties2); connection5.Append(olapProperties1); connection5.Append(connectionExtensionList3); connections1.Append(connection1); connections1.Append(connection3); connections1.Append(connection5); connectionsPart1.Connections = connections1; }