Exemple #1
0
        private void PopulateDatabase(string databasePath)
        {
            string location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name;

            _logger.OpenSection(location);

            _logger.Info("Opening database connection...");

            using (var connection = new SQLiteConnection("Data Source=" + databasePath + ";Version=3;"))
            {
                connection.Open();

                string[] createTableStatements =
                {
                    CREATE_TABLE_QUOTES,
                    CREATE_TABLE_WORDS,
                    CREATE_TABLE_SOURCES
                };

                foreach (var createOneTable in createTableStatements)
                {
                    CreateTable(createOneTable, connection);
                }

                CreateTable(ALL_DATA_VIEW, connection, "view");

                connection.Close();
            }

            _logger.CloseSection(location);
        }
Exemple #2
0
        private void btnCreateDictionary_Click(object sender, EventArgs e)
        {
            string location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name;

            _logger.OpenSection(location);

            var message    = _logger.Info("Enter a path in which the dictionary will be created.");
            var folderPath = Microsoft.VisualBasic.Interaction.InputBox(
                message, "Dictionary path",
                Path.GetDirectoryName(Application.ExecutablePath),
                this.Location.X + ((this.Size.Width - 370) / 2), this.Location.Y + ((this.Size.Height - 160) / 2));

            if (String.IsNullOrEmpty(folderPath))
            {
                MessageBox.Show(_logger.Info("Cancelled by user."));
                _logger.CloseSection(location);
                return;
            }

            _logger.Info("User chose folder '" + folderPath + "'.");
            if (!Directory.Exists(folderPath))
            {
                message = _logger.Info("Please enter the path of an existing folder.");
                MessageBox.Show(message, "Folder does not exist",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                _logger.CloseSection(location);
                return;
            }

            message = _logger.Info("Enter a filename for the dictionary.");
            var filename = Microsoft.VisualBasic.Interaction.InputBox(
                message, "Dictionary filename",
                "Dictionary" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".sqlite",
                this.Location.X + ((this.Size.Width - 370) / 2), this.Location.Y + ((this.Size.Height - 160) / 2));

            if (String.IsNullOrEmpty(filename))
            {
                MessageBox.Show(_logger.Info("Cancelled by user."));
                _logger.CloseSection(location);
                return;
            }

            var databaseCreator = GlobalObjects.DatabaseCreator.CreateDatabase(folderPath, filename);

            message = "Database created.";
            MessageBox.Show(_logger.Info(message));
            _logger.CloseSection(location);
        }