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 == this.ConnectionString, "OleDbPrpoperties Connection value is not change.");

                X15.DbCommand dbCommand = oleDbPrpoperties.DbCommand;
                log.Verify(this.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 = this.ConnectionString;
                log.Pass("Edited the OleDbPrpoperties connection");

                X15.DbCommand dbCommand = oleDbPrpoperties.DbCommand;
                dbCommand.Text = this.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)
                    {
                        this.ConnectionId                  = connection.Id;
                        this.ConnectionOdcFile             = connection.ConnectionFile;
                        this.ConnectionName                = connection.Name;
                        this.ConnectionType                = connection.Type;
                        this.ConnectionRefreshedVersion    = connection.RefreshedVersion;
                        this.ConnectionMinRefreshedVersion = connection.MinRefreshableVersion;
                        this.ConnectionBackground          = connection.Background;
                    }
                }

                X15.Connection x15connection = connectionsPart.Connections.Descendants <X15.Connection>().FirstOrDefault();
                if (x15connection == null)
                {
                    throw new Exception("Unable to obtain the X15.Connection.");
                }

                this.X15ConnectionId         = x15connection.Id;
                this.X15ConnectionAutoDelete = x15connection.AutoDelete;

                ConnectionExtension connectionExtension = new ConnectionExtension(x15connection.Parent.OuterXml);
                this.ConnectionExtUri = connectionExtension.Uri;

                X15.OleDbPrpoperties oleDbPrpoperties = x15connection.OleDbPrpoperties;
                this.ConnectionString = oleDbPrpoperties.Connection;
                X15.DbCommand dbCommand = oleDbPrpoperties.DbCommand;
                this.DBCommandText = dbCommand.Text;
            }
        }