Exemplo n.º 1
0
        private void AddBpaHydsimClick(object sender, EventArgs e)
        {
            var dlg = new Reclamation.TimeSeries.ScenarioPicker.ScenarioPicker();

            dlg.Text = "Select Hydsim Output Files";
            dlg.Dialog.DefaultExt = ".mdb";
            dlg.Dialog.Filter     = "BPA Hydsim Access (*.mdb, *.accdb)|*.mdb;*.accdb|All Files|*.*";
            dlg.Dialog.Title      = "Open BPA Hydsim Access File";

            try
            {
                DB.SuspendTreeUpdates();
                var result = dlg.ShowDialog();

                if (result == DialogResult.OK)
                {
                    if (dlg.ScenariosChecked && dlg.ScenarioFiles.Count > 0)
                    {
                        //create scenarios
                        ShowAsBusy("Reading Hydsim data");
                        var tblScen = DB.GetScenarios();

                        foreach (var item in dlg.ScenarioFiles)
                        {
                            string scenarioPath = ConnectionStringUtility.MakeFileNameRelative("FileName=" + item, DB.DataSource);
                            tblScen.AddScenarioRow(Path.GetFileNameWithoutExtension(item), true, scenarioPath, 0);
                        }
                        //add first file in the list to the tree
                        if (dlg.AddToTreeChecked)
                        {
                            var bpa = new BpaHydsim.BpaHydsimTreeAccess(dlg.ScenarioFiles[0], DB.DataSource, DB.NextSDI(), this.CurrentFolder.ID);
                            var tbl = bpa.CreateTree();
                            DB.Server.SaveTable(tbl);
                        }

                        DB.Server.SaveTable(tblScen);
                        DatabaseChanged();
                    }
                    else
                    if (dlg.AddToTreeChecked)
                    {
                        //add to tree, but not to scenairo list
                        ShowAsBusy("Reading Hydsim data");
                        for (int i = 0; i < dlg.ScenarioFiles.Count; i++)
                        {
                            string fn  = dlg.ScenarioFiles[i].ToString();
                            var    bpa = new BpaHydsim.BpaHydsimTreeAccess(fn, DB.DataSource, DB.NextSDI(), this.CurrentFolder.ID);
                            var    tbl = bpa.CreateTree();
                            DB.Server.SaveTable(tbl);
                        }
                        DatabaseChanged();
                    }
                }
            }

            finally
            {
                ShowAsReady("Done with Hydsim import");
                DB.ResumeTreeUpdates();
            }
        }
Exemplo n.º 2
0
        private void AddBpaHydsimClick(object sender, EventArgs e)
        {
            var dlg = new Reclamation.TimeSeries.ScenarioPicker.ScenarioPicker();

            dlg.Text = "Select Hydsim Output Files";
            dlg.Dialog.DefaultExt = ".mdb";
            dlg.Dialog.Filter = "BPA Hydsim Access (*.mdb, *.accdb)|*.mdb;*.accdb|All Files|*.*";
            dlg.Dialog.Title = "Open BPA Hydsim Access File";

            try
            {
                DB.SuspendTreeUpdates();
                var result = dlg.ShowDialog();

                if (result == DialogResult.OK)
                {
                    if (dlg.ScenariosChecked && dlg.ScenarioFiles.Count > 0)
                    {
                        //create scenarios
                        ShowAsBusy("Reading Hydsim data");
                        var tblScen = DB.GetScenarios();

                        foreach (var item in dlg.ScenarioFiles)
                        {
                            string scenarioPath = ConnectionStringUtility.MakeFileNameRelative("FileName=" + item, DB.DataSource);
                            tblScen.AddScenarioRow(Path.GetFileNameWithoutExtension(item), true, scenarioPath,0);
                        }
                        //add first file in the list to the tree
                        if (dlg.AddToTreeChecked)
                        {
                            var bpa = new BpaHydsim.BpaHydsimTreeAccess(dlg.ScenarioFiles[0], DB.DataSource, DB.NextSDI(), this.CurrentFolder.ID);
                            var tbl = bpa.CreateTree();
                            DB.Server.SaveTable(tbl);
                        }

                        DB.Server.SaveTable(tblScen);
                        DatabaseChanged();
                    }
                    else
                        if (dlg.AddToTreeChecked)
                        {
                            //add to tree, but not to scenairo list
                            ShowAsBusy("Reading Hydsim data");
                            for (int i = 0; i < dlg.ScenarioFiles.Count; i++)
                            {
                                string fn = dlg.ScenarioFiles[i].ToString();
                                var bpa = new BpaHydsim.BpaHydsimTreeAccess(fn, DB.DataSource, DB.NextSDI(), this.CurrentFolder.ID);
                                var tbl = bpa.CreateTree();
                                DB.Server.SaveTable(tbl);
                            }
                            DatabaseChanged();
                        }
                }
            }

            finally
            {
                ShowAsReady("Done with Hydsim import");
                DB.ResumeTreeUpdates();
            }
        }