//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()); } }
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); }
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; }
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(); }
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(); }
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; }
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; } } } }
protected void InitializeView(WindowPresenter windowPresenter) { this.WindowPresenter = windowPresenter; }
public ImportFromCruiseView(string fileName, WindowPresenter windowPresenter, TemplateEditViewPresenter viewPresenter) : this(windowPresenter, viewPresenter) { this._copyFromDB = new DAL(fileName); }