コード例 #1
0
        //TODO make testable constructor
        public CruiseWizardPresenter(CruiseWizardView View, WindowPresenter windowPresenter, ApplicationControllerBase applicationController, DAL database)
        {
            this.View = View;
            this.WindowPresenter = windowPresenter;
            this.ApplicationController = applicationController;
            View.Presenter = this;
            _database = database;

            LoadSetupData();//load tree defaults, product codes, etc.

            LoadCruiseData();//read data from existing file

            //See if the file contains a template file record
            string templatePath = _database.ReadGlobalValue("CSM", "TemplatePath");

            if (!String.IsNullOrEmpty(templatePath))
            {
                this._fileHasTemplate = true;
                this._templateFile = new FileInfo(templatePath);
                View.SetTemplatePathTextBox(templatePath, false);
            }

            if (this.CuttingUnits.Count == 0)
            {
                this.CuttingUnits.Add(GetNewCuttingUnit());
            }
        }
コード例 #2
0
        protected void OnDatabaseChanged()
        {
            Analytics.TrackEvent(nameof(OnDatabaseChanged));

            var database = Database;
            var filePath = database.Path;

            if (database.CruiseFileType.HasFlag(CruiseFileType.Cruise))
            {
                String directroy = System.IO.Path.GetDirectoryName(filePath);
                UserSettings.CruiseSaveLocation = directroy;

                var fixMismatchSp = new FixMismatchSpeciesScript();
                if (fixMismatchSp.CheckCanExecute(database))
                {
                    fixMismatchSp.Execute(database);
                }

                if (DatabaseValidator.HasCruiseErrors(database, out var errors))
                {
                    var errorMessage = String.Join("\r\n", errors);
                    var errorData    = new Dictionary <string, string>()
                    {
                        { "errorMessage", errorMessage }
                    };

                    try
                    {
                        if (database.HasForeignKeyErrors())
                        {
                            var fkc = String.Join(",", database.QueryGeneric("PRAGMA foreign_key_check")
                                                  .Select(x => "{\r\n" + x.ToString() + "}")
                                                  .ToArray());
                            errorData.Add("foreign_key_check", fkc);
                        }
                    }
                    catch { }

                    Crashes.TrackError(new Exception("Cruise_Errors"), errorData);
                    //Analytics.TrackEvent("Cruise_Errors", errorData);

                    this.ActiveView.ShowMessage(errorMessage, null);
                }

                WindowPresenter.ShowCruiseLandingLayout();
            }
            else if (database.CruiseFileType.HasFlag(CruiseFileType.Template))
            {
                String directroy = System.IO.Path.GetDirectoryName(filePath);
                UserSettings.TemplateSaveLocation = directroy;
                WindowPresenter.ShowTemplateLandingLayout();
            }

            AppState.AddRecentFile(filePath);
            SaveCommand.Enabled = this.SaveAsCommand.Enabled = (database != null);
        }
コード例 #3
0
        public EditDesignView(WindowPresenter windowPresenter, DesignEditorPresentor viewPresenter)
        {
            this.ViewPresenter = viewPresenter;
            this.ViewPresenter.View = this;

            this.ExceptionHandler = viewPresenter.ApplicationController.ExceptionHandler;
            this.WindowPresenter = windowPresenter;
            InitializeComponent();
            this.SalePurposeComboBox.DataSource = Strings.SALE_PURPOSE;
        }
コード例 #4
0
        public EditTemplateView(WindowPresenter windowPresenter, TemplateEditViewPresenter viewPresenter)
        {
            this.WindowPresenter = windowPresenter;
            this.ViewPresenter = viewPresenter;
            ViewPresenter.View = this;

            //this.UserCommands = new ViewCommand[]{
            //    this.ViewPresenter.ApplicationController.MakeViewCommand("Close File", this.ViewPresenter.WindowPresenter.ShowCruiseLandingLayout),
            //    this.ViewPresenter.ApplicationController.MakeViewCommand("Import From File", this.ViewPresenter.WindowPresenter.ShowImportTemplate)
            //};

            InitializeComponent();
        }
コード例 #5
0
        public DataEditorView(WindowPresenter windowPresenter, ApplicationControllerBase applicationController)
            : this()
        {
            this.WindowPresenter = windowPresenter;
            this.ApplicationController = applicationController;

            this.Text = "Field Data - " + System.IO.Path.GetFileName(applicationController.Database.Path);

            this._BS_TreeSpecies.DataSource = applicationController.Database.Read<TreeDefaultValueDO>("TreeDefaultValue", null);

            this._BS_TreeSampleGroups.DataSource = applicationController.Database.Read<SampleGroupDO>("SampleGroup", null);
            //ResetViewFilters();
        }
コード例 #6
0
        public ImportFromCruiseView(WindowPresenter windowPresenter, TemplateEditViewPresenter viewPresenter)
        {
            InitializeComponent();
            this.WindowPresenter = windowPresenter;
            this.ApplicationController = viewPresenter.ApplicationController;

            //this.UserCommands = new ViewCommand[]{
            //    ApplicationController.MakeViewCommand("Import", this.Finish ),
            //    ApplicationController.MakeViewCommand("Cancel", this.WindowPresenter.ShowTemplateLandingLayout)
            //};

            this.TreeDefaultsToCopy = new List<TreeDefaultValueDO>();
            this.selectedItemsGridView1.SelectedItems = this.TreeDefaultsToCopy;
        }
コード例 #7
0
        public void SaveAs()
        {
            var path = WindowPresenter.AskSaveAsLocation(this.Database.Path);

            if (path != null)
            {
                try
                {
                    this.SaveAs(path);
                }
                catch (Exception ex)
                {
                    if (!ExceptionHandler.Handel(ex))
                    {
                        throw;
                    }
                }
            }
        }
コード例 #8
0
 protected void InitializeView(WindowPresenter windowPresenter)
 {
     this.WindowPresenter = windowPresenter;
 }
コード例 #9
0
 public ImportFromCruiseView(string fileName, WindowPresenter windowPresenter, TemplateEditViewPresenter viewPresenter)
     : this(windowPresenter, viewPresenter)
 {
     this._copyFromDB = new DAL(fileName);
 }