Beispiel #1
0
        private void cmdExport_Click(object sender, EventArgs e)
        {
            try
            {
                this.Enabled = false;

                var templateMdb = GetTemplateMdb();
                if (templateMdb == default(string))
                {
                    return;
                }

                var newMdb = GetNewMdbName(templateMdb);
                if (newMdb == default(string))
                {
                    return;
                }

                File.Copy(templateMdb, newMdb);

                var entries = GetJournalEntries();
                if (entries.Count == 0)
                {
                    return;
                }

                var mdbWriter = new MdbWriter()
                {
                    MdbName = newMdb
                };

                DeleteExistingJournal(mdbWriter);

                mdbWriter.CreateJournal();

                try
                {
                    mdbWriter.InsertRows(entries);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                // ...and start a viewer.
                Process.Start(newMdb);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.Enabled = true;
            }
        }
Beispiel #2
0
        private void DeleteExistingJournal(MdbWriter mdbWriter)
        {
            var journalTableName = mdbWriter.GetTableNames().FirstOrDefault(x => string.Compare(x, "Journal", StringComparison.OrdinalIgnoreCase) == 0);

            if (journalTableName != null)
            {
                mdbWriter.DeleteJournal();
            }
        }