/// <summary> /// Initialize new instance of UndiscoveredDepositsViewModel /// </summary> /// <param name="logger">Logging for the MapWizard.</param> /// <param name="dialogService">Service for using dialogs and notifications.</param> /// <param name="settingsService">Service for using and editing settings.</param> public UndiscoveredDepositsViewModel(ILogger logger, IDialogService dialogService, ISettingsService settingsService) { this.logger = logger; this.dialogService = dialogService; this.settingsService = settingsService; result = new UndiscoveredDepositsResultModel(); TractChangedCommand = new RelayCommand(TractChanged, CanRunTool); FindTractsCommand = new RelayCommand(FindTractIDs, CanRunTool); RunToolCommand = new RelayCommand(RunTool, CanRunTool); AddEstimationCommand = new RelayCommand(AddEstimation, CanRunTool); AddCustomEstimationCommand = new RelayCommand(AddCustomEstimation, CanRunTool); SelectModelCommand = new RelayCommand(SelectResult, CanRunTool); ShowModelDialog = new RelayCommand(OpenModelDialog, CanRunTool); OpenUndiscDepPlotCommand = new RelayCommand(OpenUndiscDepPlot, CanRunTool); viewModelLocator = new ViewModelLocator(); UndiscoveredDepositsInputParams inputParams = new UndiscoveredDepositsInputParams(); string projectFolder = Path.Combine(settingsService.RootPath, "UndiscDep"); if (!Directory.Exists(projectFolder)) { Directory.CreateDirectory(projectFolder); } string param_json = Path.Combine(projectFolder, "undiscovered_deposits_input_params.json"); if (File.Exists(param_json)) { try { inputParams.Load(param_json); Model = new UndiscoveredDepositsModel { DepositsCsvString = inputParams.DepositsNegativeCSV, CustomFunctionCsvString = inputParams.DepositsCustomCSV, EstN90 = inputParams.N90, EstN50 = inputParams.N50, EstN10 = inputParams.N10, EstN5 = inputParams.N5, EstN1 = inputParams.N1, SelectedTract = inputParams.TractID, NegBinomialExtensionFolder = "", Mark3ExtensionFolder = "", CustomExtensionFolder = "", EstimateRationale = inputParams.EstRationaleTXT, MARK3EstimateRationale = inputParams.Mark3EstRationaleTXT, CustomEstimateRationale = inputParams.CustomEstRationaleTXT, LastRunTract = inputParams.LastRunTract }; } catch (Exception ex) { Model = new UndiscoveredDepositsModel(); logger.Error(ex, "Failed to read json file"); dialogService.ShowNotification("Couldn't load Undiscovered Deposits tool's inputs correctly. Inputs were initialized to default values.", "Error"); viewModelLocator.SettingsViewModel.WriteLogText("Couldn't load Undiscovered Deposits tool's inputs correctly. Inputs were initialized to default values.", "Error"); } } else { Model = new UndiscoveredDepositsModel(); } FindTractIDs(); LoadResults(); try { if (Model.SelectedTract != null) { projectFolder = Path.Combine(projectFolder, Model.SelectedTract); if (Directory.Exists(projectFolder)) { // Find saved results from all the methods. DirectoryInfo projectFolderInfo = null; Model.ModelNames.Clear(); if (Directory.Exists(Path.Combine(projectFolder, "NegativeBinomial"))) { projectFolderInfo = new DirectoryInfo(Path.Combine(projectFolder, "NegativeBinomial")); //NegativeBinomial results FindModelnames(projectFolderInfo); } if (Directory.Exists(Path.Combine(projectFolder, "MARK3"))) { projectFolderInfo = new DirectoryInfo(Path.Combine(projectFolder, "MARK3")); //MARK3 results FindModelnames(projectFolderInfo); } if (Directory.Exists(Path.Combine(projectFolder, "Custom"))) { projectFolderInfo = new DirectoryInfo(Path.Combine(projectFolder, "Custom")); //Custom results FindModelnames(projectFolderInfo); } } } } catch (Exception ex) { logger.Error(ex, "Failed to load model names"); dialogService.ShowNotification("Failed to load model names.", "Error"); viewModelLocator.SettingsViewModel.WriteLogText("Failed to load model names correctly in Undiscovered Deposits tool.", "Error"); } var lastRunFile = Path.Combine(settingsService.RootPath, "UndiscDep", "undiscovered_deposits_last_run.lastrun"); if (File.Exists(lastRunFile)) { Model.LastRunDate = "Last Run: " + (new FileInfo(lastRunFile)).LastWriteTime.ToString(); } }
/// <summary> /// Initialize new instance of ReportingViewModel class. /// </summary> /// <param name="logger">Logging for the MapWizard</param> /// <param name="dialogService">Service for using project's dialogs and notifications</param> /// <param name="settingsService">Service for using and editing project's settings</param> public ReportingViewModel(ILogger logger, IDialogService dialogService, ISettingsService settingsService) { this.logger = logger; this.dialogService = dialogService; this.settingsService = settingsService; viewModelLocator = new ViewModelLocator(); RunToolCommand = new RelayCommand(RunTool, CanRunTool); GoToTractReportCommand = new RelayCommand(GoToTractReport, CanChangeView); GoToReportSelectionCommand = new RelayCommand(GoToReportSelection, CanChangeView); CheckTractFilesCommand = new RelayCommand(CheckFiles, CanRunTool); FindTractsCommand = new RelayCommand(FindTractIDs, CanRunTool); SelectTractImageFileCommand = new RelayCommand(SelectTractImageFile, CanRunTool); SelectKnownDepositsFileCommand = new RelayCommand(SelectKnownDepositsFile, CanRunTool); SelectProspectsOccurencesFileCommand = new RelayCommand(SelectProspectsOccurencesFile, CanRunTool); SelectExplorationFileCommand = new RelayCommand(SelectExplorationFile, CanRunTool); SelectSourcesFileCommand = new RelayCommand(SelectSourcesFile, CanRunTool); SelectReferencesFileCommand = new RelayCommand(SelectReferencesFile, CanRunTool); ReportingInputParams inputParams = new ReportingInputParams(); string outputFolder = Path.Combine(settingsService.RootPath, "Reporting"); if (!Directory.Exists(outputFolder)) { Directory.CreateDirectory(outputFolder); } string param_json = Path.Combine(outputFolder, "tract_report_input_params.json"); if (File.Exists(param_json)) { try { inputParams.Load(param_json); Model = new ReportingModel { TractImageFile = inputParams.TractImageFile, KnownDepositsFile = inputParams.KnownDepositsFile, ProspectsOccurencesFile = inputParams.ProspectsOccurencesFile, ExplorationFile = inputParams.ExplorationFile, SourcesFile = inputParams.SourcesFile, ReferencesFile = inputParams.ReferencesFile, SelectedTract = inputParams.SelectedTract, Authors = inputParams.Authors, Country = inputParams.Country, DescModelPath = inputParams.DescModel, DescModelName = inputParams.DescModelName, GTModelPath = inputParams.GTModel, GTModelName = inputParams.GTModelName, AddDescriptive = Convert.ToBoolean(inputParams.AddDescriptive), AddGradeTon = Convert.ToBoolean(inputParams.AddGradeTon), EnableDescCheck = Convert.ToBoolean(inputParams.EnableDescCheck), EnableGTCheck = Convert.ToBoolean(inputParams.EnableGTCheck), AsDate = inputParams.AsDate, AsDepth = inputParams.AsDepth, AsLeader = inputParams.AsLeader, AsTeamMembers = inputParams.AsTeamMembers, IsRaefDone = inputParams.IsRaefDone, IsScreenerDone = inputParams.IsScreenerDone, IsUndiscDepDone = inputParams.IsUndiscDepDone }; FindTractIDs(); // Gets the tractID names from PermissiveTractTool's Tracts folder. CheckFiles(); // Check which of the needed files for creating a report exist. if (Model.SelectedTract != null) // Check if the tool have ever been correctly ran before. { //Model.RunStatus = 0; Remove this? string docOutputFile = Path.Combine(outputFolder, Model.SelectedTract, "TractReport" + Model.SelectedTract + ".docx"); if (File.Exists(docOutputFile))// If reporting file exist then the tool have been ran. { Model.RunStatus = 1; } } SaveInputs(); // Save inputs to tract_report_input_params.json file. This might be not needed(?). } catch (Exception ex) { // If something goes wrong then the tool will be initialized to have default parameters. Model = new ReportingModel(); logger.Error(ex, "Failed to read json file"); dialogService.ShowNotification("Couldn't load Reporting tool's inputs correctly. Inputs were initialized to default values.", "Error"); viewModelLocator.SettingsViewModel.WriteLogText("Couldn't load Reporting tool's inputs correctly. Inputs were initialized to default values.", "Error"); } } else { Model = new ReportingModel(); FindTractIDs(); // Gets the tractID names from PermissiveTractTool's Trats folder. } // Check if the DepositType have been given correctly for the project. if (settingsService.Data.DepositType != null) { Model.DepositType = settingsService.Data.DepositType; } var lastRunFile = Path.Combine(settingsService.RootPath, "Reporting", "tract_report_last_run.lastrun"); if (File.Exists(lastRunFile)) { Model.LastRunDate = "Last Run: " + (new FileInfo(lastRunFile)).LastWriteTime.ToString(); } }
/// <summary> /// Initializes an instance of MonteCarloSimulationViewModel Class. /// </summary> /// <param name="logger">Logging for the MapWizard.</param> /// <param name="dialogService">Service for using dialogs and notifications.</param> /// <param name="settingsService">Service for using and editing settings.</param> public MonteCarloSimulationViewModel(ILogger logger, IDialogService dialogService, ISettingsService settingsService) { this.logger = logger; this.dialogService = dialogService; this.settingsService = settingsService; viewModelLocator = new ViewModelLocator(); result = new MonteCarloSimulationResultModel(); RunToolCommand = new RelayCommand(RunTool, CanRunTool); FindTractsCmd = new RelayCommand(FindTracts, CanRunTool); TractChangedCommand = new RelayCommand(TractChanged, CanRunTool); ShowModelDialog = new RelayCommand(OpenModelDialog, CanRunTool); SelectModelCommand = new RelayCommand(SelectResult, CanRunTool); SelectGradeObjectCommand = new RelayCommand(SelectGradeObject, CanRunTool); SelectTonnageObjectCommand = new RelayCommand(SelectTonnageObject, CanRunTool); SelectGradeTonnageObjectCommand = new RelayCommand(SelectGradeTonnageObject, CanRunTool); SelectNDepositsPmfObjectCommand = new RelayCommand(SelectNDepositsPmfObject, CanRunTool); OpenResultExcelObjectCommand = new RelayCommand(OpenResultExcelObject, CanRunTool); OpenTotalTonnagePlotCommand = new RelayCommand(OpenTotalTonnagePlot, CanRunTool); OpenMarginalPlotCommand = new RelayCommand(OpenMarginalPlot, CanRunTool); MonteCarloSimulationInputParams inputParams = new MonteCarloSimulationInputParams(); string projectFolder = Path.Combine(settingsService.RootPath, "MCSim"); if (!Directory.Exists(projectFolder)) { Directory.CreateDirectory(projectFolder); } string param_json = Path.Combine(projectFolder, "monte_carlo_simulation_input_params.json"); if (File.Exists(param_json)) { try { inputParams.Load(param_json); Model = new MonteCarloSimulationModel { GradePlot = inputParams.GradePlot, TonnagePlot = inputParams.TonnagePlot, NDepositsPmf = inputParams.NDepositsPmf, SelectedTract = inputParams.TractID, LastRunTract = "Tract: " + inputParams.LastRunTract }; FindTractIDs(); // Gets the tractID names from PermissiveTractTool's Delineation folder. //FindMCSimTractIDs(); // Gets the tractID names from MCSim folder } catch (Exception ex) { Model = new MonteCarloSimulationModel(); logger.Error(ex, "Failed to read json file"); dialogService.ShowNotification("Couldn't load Monte Carlo Simulation tool's inputs correctly. Inputs were initialized to default values.", "Error"); viewModelLocator.SettingsViewModel.WriteLogText("Couldn't load Monte Carlo Simulation tool's inputs correctly. Inputs were initialized to default values.", "Error"); } } else { Model = new MonteCarloSimulationModel(); FindTractIDs(); // Gets the tractID names from PermissiveTractTool's Delineation folder. //FindMCSimTractIDs(); // Gets the tractID names from MCSim folder } if (Model.SelectedTract != null) { LoadResults(); } if (Model.SelectedTract != null) { projectFolder = Path.Combine(projectFolder, Model.SelectedTract); if (Directory.Exists(projectFolder)) { Model.ModelNames.Clear(); FindModelnames(projectFolder); // Find saved results. } } var lastRunFile = Path.Combine(settingsService.RootPath, "MCSim", "monte_carlo_simulation_last_run.lastrun"); if (File.Exists(lastRunFile)) { Model.LastRunDate = "Last Run: " + (new FileInfo(lastRunFile)).LastWriteTime.ToString(); } }
/// <summary> /// Initializes a new instance of the GradeTonnageViewModel class. /// </summary> /// <param name="logger">Logging for the MapWizard.</param> /// <param name="dialogService">Service for using dialogs and notifications.</param> /// <param name="settingsService">Service for using and editing settings.</param> public GradeTonnageViewModel(ILogger logger, IDialogService dialogService, ISettingsService settingsService) { this.logger = logger; this.dialogService = dialogService; this.settingsService = settingsService; var GTFolder = Path.Combine(settingsService.RootPath, "GTModel"); var GTDirInfo = new DirectoryInfo(GTFolder); if (!Directory.Exists(GTFolder)) { Directory.CreateDirectory(GTFolder); } RunToolCommand = new RelayCommand(RunTool, CanRunTool); SelectFileCommand = new RelayCommand(SelectFile, CanRunTool); SelectMetalFileCommand = new RelayCommand(SelectMetalFile, CanRunTool); SelectFolderCommand = new RelayCommand(SelectFolder, CanRunTool); SelectModelCommand = new RelayCommand(SelectResult, CanRunTool); ShowModelDialog = new RelayCommand(OpenModelDialog, CanRunTool); OpenGradePlotCommand = new RelayCommand(OpenGradePlot, CanRunTool); OpenTonnagePlotCommand = new RelayCommand(OpenTonnagePlot, CanRunTool); viewModelLocator = new ViewModelLocator(); result = new GradeTonnageResultModel(); GradeTonnageInputParams inputParams = new GradeTonnageInputParams(); string projectFolder = Path.Combine(settingsService.RootPath, "GTModel"); string selectedProjectFolder = Path.Combine(settingsService.RootPath, "GTModel", "SelectedResult"); if (!Directory.Exists(selectedProjectFolder)) { Directory.CreateDirectory(selectedProjectFolder); } string param_json = Path.Combine(selectedProjectFolder, "GradeTonnage_input_params.json"); if (File.Exists(param_json)) { try { inputParams.Load(param_json); Model = new GradeTonnageModel { CSVPath = inputParams.CSVPath, IsTruncated = inputParams.IsTruncated, PdfType = inputParams.PDFType, MinDepositCount = Convert.ToInt32(inputParams.MinDepositCount), RandomSampleCount = Convert.ToInt32(inputParams.RandomSampleCount), Seed = Convert.ToInt32(inputParams.Seed), Folder = inputParams.Folder, ExtensionFolder = inputParams.ExtensionFolder, RunGrade = inputParams.RunGrade, RunTonnage = inputParams.RunTonnage, ModelType = inputParams.ModelType }; } catch (Exception ex) { Model = new GradeTonnageModel(); logger.Error(ex, "Failed to read json file"); dialogService.ShowNotification("Couldn't load Grade Tonnage tool's inputs correctly.", "Error"); viewModelLocator.SettingsViewModel.WriteLogText("Couldn't load Grade Tonnage tool's inputs correctly.", "Error"); } } else { Model = new GradeTonnageModel(); } if (Directory.GetFiles(selectedProjectFolder).Length != 0) { LoadResults(); } FindModelnames(projectFolder); var lastRunFile = Path.Combine(projectFolder, "GradeTonnage_last_run.lastrun"); if (File.Exists(lastRunFile)) { Model.LastRunDate = "Last Run: " + (new FileInfo(lastRunFile)).LastWriteTime.ToString(); } }
/// <summary> /// Initializes a new instance of the TractAggregationViewModel class. /// </summary> /// <param name="logger">Logging for the MapWizard.</param> /// <param name="dialogService">Service for using dialogs and notifications.</param> /// <param name="settingsService">Service for using and editing settings.</param> public TractAggregationViewModel(ILogger logger, IDialogService dialogService, ISettingsService settingsService) { this.logger = logger; this.dialogService = dialogService; this.settingsService = settingsService; viewModelLocator = new ViewModelLocator(); model = new TractAggregationModel(); result = new TractAggregationResultModel(); SelectCorrelationMatrixCommand = new RelayCommand(SelectCorrelationMatrix, CanRunTool); SelectProbDistFileCommand = new RelayCommand(SelectProbDistFile, CanRunTool); FindTractsCommand = new RelayCommand(FindTractIDs, CanRunTool); RunToolCommand = new RelayCommand(RunTool, CanRunTool); CombineDistFilesCommand = new RelayCommand(CombineDistFiles, CanRunTool); AddFilesToCombineListCommand = new RelayCommand(AddFilesToCombineList, CanRunTool); CombineTractsCommand = new RelayCommand(CombineTracts, CanRunTool); TractAggregationInputParams inputParams = new TractAggregationInputParams(); string projectFolder = Path.Combine(settingsService.RootPath, "TractAggregation"); if (!Directory.Exists(projectFolder)) { Directory.CreateDirectory(projectFolder); } string param_json = Path.Combine(projectFolder, "tract_aggregation_input_params.json"); if (File.Exists(param_json)) { try { inputParams.Load(param_json); Model = new TractAggregationModel { CorrelationMatrix = inputParams.CorrelationMatrix, ProbDistFile = inputParams.ProbDistFile, WorkingDir = inputParams.WorkingDir, TestName = inputParams.TestName, CreateInputFile = bool.Parse(inputParams.CreateInputFile), TractCombinationName = inputParams.TractCombinationName }; } catch (Exception ex) { Model = new TractAggregationModel(); logger.Error(ex, "Failed to read json file"); dialogService.ShowNotification("Couldn't load Tract Aggregation tool's inputs correctly. Inputs were initialized to default values.", "Error"); viewModelLocator.SettingsViewModel.WriteLogText("Couldn't load Tract Aggregation tool's inputs correctly. Inputs were initialized to default values.", "Error"); } } else { Model = new TractAggregationModel(); } FindTractIDs(); if (Directory.Exists(Path.Combine(settingsService.RootPath, "TractAggregation", "AggResults"))) { LoadResults(); } var lastRunFile = Path.Combine(settingsService.RootPath, "TractAggregation", "tract_aggregation_last_run.lastrun"); if (File.Exists(lastRunFile)) { Model.LastRunDate = "Last Run: " + (new FileInfo(lastRunFile)).LastWriteTime.ToString(); } }