Beispiel #1
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            var fileName = (string)e.Argument;

            try {
                var dataImporter = new DatabaseImporter();
                dataImporter.ImportFromSpreadsheet(fileName);
            }
            catch (ImportException exception) {
                e.Result = exception;
            }
        }
Beispiel #2
0
        //Lets the user choose a folder to export to.
        private void btn_export_browse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog browser = new FolderBrowserDialog();

            if (browser.ShowDialog() == DialogResult.OK)
            {
                txtbx_export_output_folder.Text = browser.SelectedPath;
                txtbx_import_source_folder.Text = browser.SelectedPath;
                Config.AddUpdateSetting("Export_OutputFolder", browser.SelectedPath);
                _backupFolderPath = $"{browser.SelectedPath}\\";
                _dbExporter       = new DatabaseExporter(_backupFolderPath);
                _dbImporter       = new DatabaseImporter(_backupFolderPath);
            }
        }
Beispiel #3
0
        public MainForm()
        {
            InitializeComponent();
            FormControls _controls = new FormControls(this);

            picBx_loadingicon.Visible = false;
            btn_cancel.Visible        = false;
            btn_start.Enabled         = false;

            FormControls.GetExportSettings();
            FormControls.GetImportSettings();

            _backupFolderPath = $"{txtbx_export_output_folder.Text}\\";

            if (!string.IsNullOrEmpty(_backupFolderPath))
            {
                _dbExporter = new DatabaseExporter(_backupFolderPath);
                _dbImporter = new DatabaseImporter(_backupFolderPath);
            }
        }
Beispiel #4
0
        public void Import(IProvisionSource source)
        {
            KPCContext.Log.DebugFormat("Importing data from {0} into DBContext.", source.GetType().Name);

            var store = source.Export();

            if (store == null)
            {
                throw new DataStoreException("Given data source contains no data to import.");
            }

            if (sessionFactory == null)
            {
                InitializeSessionFactory();
            }

            using (var importer = new DatabaseImporter(GetSession()))
            {
                // Note: Import order is important to maintain referential integrity of database
                importer.Import(store.Ingredients);
                importer.Import(store.IngredientForms);
                importer.Import(store.IngredientMetadata);
                importer.Import(store.NlpAnomalousIngredients);
                importer.Import(store.NlpDefaultPairings);
                importer.Import(store.NlpFormSynonyms);
                importer.Import(store.NlpIngredientSynonyms);
                importer.Import(store.NlpPrepNotes);
                importer.Import(store.NlpUnitSynonyms);
                importer.Import(store.Recipes);
                importer.Import(store.RecipeIngredients);
                importer.Import(store.RecipeMetadata);
                importer.Import(store.Menus);
                importer.Import(store.Favorites);
                importer.Import(store.QueuedRecipes);
                importer.Import(store.RecipeRatings);
                importer.Import(store.ShoppingLists);
                importer.Import(store.ShoppingListItems);
            }

            KPCContext.Log.DebugFormat("Done importing data from into DBContext.");
        }
        public void Import(IProvisionSource source)
        {
            KPCContext.Log.DebugFormat("Importing data from {0} into DBContext.", source.GetType().Name);

            var store = source.ExportStore();
            if (store == null)
            {
                throw new DataStoreException("Given data source contains no data to import.");
            }

            if (this.sessionFactory == null)
            {
                this.InitializeSessionFactory();
            }

            using (var importer = new DatabaseImporter(this.GetSession()))
            {
                // Note: Import order is important to maintain referential integrity of database
                importer.Import(store.Ingredients);
                importer.Import(store.IngredientForms);
                importer.Import(store.IngredientMetadata);
                importer.Import(store.NlpAnomalousIngredients);
                importer.Import(store.NlpDefaultPairings);
                importer.Import(store.NlpFormSynonyms);
                importer.Import(store.NlpIngredientSynonyms);
                importer.Import(store.NlpPrepNotes);
                importer.Import(store.NlpUnitSynonyms);
                importer.Import(store.Recipes);
                importer.Import(store.RecipeIngredients);
                importer.Import(store.RecipeMetadata);
                importer.Import(store.Menus);
                importer.Import(store.Favorites);
                importer.Import(store.QueuedRecipes);
                importer.Import(store.RecipeRatings);
                importer.Import(store.ShoppingLists);
                importer.Import(store.ShoppingListItems);
            }

            KPCContext.Log.DebugFormat("Done importing data from into DBContext.");
        }