Ejemplo n.º 1
0
        public void TestCreateBinCentricTables2()
        {
            DataReaderTests.DataReaderTests.PrintMethodName(System.Reflection.MethodBase.GetCurrentMethod());

            var fiSource = new FileInfo(FileRefs.BinCentricTest1);

            if (!fiSource.Exists)
            {
                return;
            }

            var fiTarget = DuplicateUIMF(fiSource, "_BinCentric2");

            if (fiTarget == null)
            {
                return;
            }

            using (var uimfReader = new DataReader(fiTarget.FullName))
            {
                // Note: providing true for parseViaFramework as a workaround for reading SqLite files located on a remote UNC share or in readonly folders
                var connectionString = "Data Source = " + fiTarget.FullName;
                using (var dbConnection = new System.Data.SQLite.SQLiteConnection(connectionString, true))
                {
                    dbConnection.Open();

                    using (var dbCommand = dbConnection.CreateCommand())
                    {
                        dbCommand.CommandText = "PRAGMA synchronous=0;BEGIN TRANSACTION;";
                        dbCommand.ExecuteNonQuery();
                    }

                    var binCentricTableCreator = new BinCentricTableCreation();

                    // Attach the events
                    binCentricTableCreator.OnProgress += BinCentricTableCreator_ProgressEvent;
                    binCentricTableCreator.Message    += BinCentricTableCreator_MessageEvent;

                    mLastProgressUpdateTime  = DateTime.UtcNow;
                    mLastProgressMessageTime = DateTime.UtcNow;

                    binCentricTableCreator.CreateBinCentricTable(dbConnection, uimfReader, ".");

                    using (var dbCommand = dbConnection.CreateCommand())
                    {
                        dbCommand.CommandText = "END TRANSACTION;PRAGMA synchronous=1;";
                        dbCommand.ExecuteNonQuery();
                    }

                    dbConnection.Close();
                }
            }

            Console.WriteLine("Added bin centric tables to " + fiTarget.FullName);
        }
Ejemplo n.º 2
0
        private void AddBinCentricTables(string filePath)
        {
            using (var uimfWriter = new DataReader(filePath))
            {
                var sourceFile       = new FileInfo(filePath);
                var workingDirectory = sourceFile.DirectoryName;

                var binCentricTableCreator = new BinCentricTableCreation();
                binCentricTableCreator.OnProgress += binCentricTableCreator_OnProgress;

                binCentricTableCreator.CreateBinCentricTable(uimfWriter.DBConnection, this.UimfUtil.UimfReader, workingDirectory);
            }

            UpdateBinCentricTableProgress(100);
        }
        private void AddBinCentricTables(string filePath)
        {
            var sourceFile = new FileInfo(filePath);

            using (var uimfReader = new DataReader(sourceFile.FullName))
            {
                // Note: providing true for parseViaFramework as a workaround for reading SqLite files located on a remote UNC share or in readonly folders
                var connectionString = "Data Source = " + sourceFile.FullName;
                using (var dbConnection = new System.Data.SQLite.SQLiteConnection(connectionString, true))
                {
                    dbConnection.Open();

                    /*
                     * // Start a transaction
                     * using (var dbCommand = dbConnection.CreateCommand())
                     * {
                     *  dbCommand.CommandText = "PRAGMA synchronous=0;BEGIN TRANSACTION;";
                     *  dbCommand.ExecuteNonQuery();
                     * }
                     */

                    var binCentricTableCreator = new BinCentricTableCreation();

                    var workingDirectory = sourceFile.DirectoryName;

                    // Attach the events
                    binCentricTableCreator.Message    += binCentricTableCreator_OnMessage;
                    binCentricTableCreator.OnProgress += binCentricTableCreator_OnProgress;

                    binCentricTableCreator.CreateBinCentricTable(dbConnection, uimfReader, workingDirectory);

                    /*
                     * // Finalize the transaction
                     * using (var dbCommand = dbConnection.CreateCommand())
                     * {
                     *  dbCommand.CommandText = "END TRANSACTION;PRAGMA synchronous=1;";
                     *  dbCommand.ExecuteNonQuery();
                     * }
                     */

                    dbConnection.Close();
                }
            }

            UpdateBinCentricTableProgress(100);
        }