Beispiel #1
0
        public void PorCuCalculation()
        {
            DepositDensityInputParams input = new DepositDensityInputParams
            {
                DepositTypeId                 = "xxx",
                MedianTonnage                 = "0.5",
                AreaOfTrack                   = "10000",
                NumbOfKnownDeposits           = "0",
                ExistingDepositDensityModelID = "PorCu",
                CSVPath = "c:\\temp\\mapWizard\\PorCuCSV_wHeaders.csv"
            };

            DepositDensityTool DepositDensityTool = new DepositDensityTool();
            var result = DepositDensityTool.Execute(input);

            Assert.IsNotNull(result);
        }
Beispiel #2
0
        public void ExecuteTest02()
        {
            DepositDensityInputParams input = new DepositDensityInputParams
            {
                DepositTypeId                 = "xxx",
                MedianTonnage                 = "0.5",
                AreaOfTrack                   = "3228",
                NumbOfKnownDeposits           = "2",
                ExistingDepositDensityModelID = "General",
                CSVPath = "c:\\temp\\mapWizard\\generalCSV_wHeaders.csv"
            };

            DepositDensityTool DepositDensityTool = new DepositDensityTool();
            var result = DepositDensityTool.Execute(input);

            Assert.IsNotNull(result);
        }
        /// <summary>
        /// Run tool with user input.
        /// </summary>
        private async void RunTool()
        {
            logger.Info("-->{0}", this.GetType().Name);
            // 1. Collect input parameters.
            DepositDensityInputParams input = new DepositDensityInputParams
            {
                DepositTypeId                 = "xxx",
                MedianTonnage                 = Model.MedianTonnage.ToString(),
                AreaOfTrack                   = Model.AreaOfPermissiveTract.ToString(),
                NumbOfKnownDeposits           = Model.NumbOfKnownDeposits.ToString(),
                ExistingDepositDensityModelID = Model.ExistingDepositDensityModelID,
                CSVPath = Model.CSVPath,
                TractId = Model.SelectedTract
            };
            // 2. Execute tool.
            DepositDensityResult ddResult = default(DepositDensityResult);

            Model.IsBusy = true;

            try
            {
                await Task.Run(() =>
                {
                    DepositDensityTool tool = new DepositDensityTool();
                    ddResult               = tool.Execute(input) as DepositDensityResult;
                    Result.N10             = ddResult.N10;
                    Result.N50             = ddResult.N50;
                    Result.N90             = ddResult.N90;
                    Result.PlotImagePath   = ddResult.PlotImagePath;
                    Result.PlotImageBitMap = BitmapFromUri(ddResult.PlotImagePath);
                    Result.Model           = Model.ExistingDepositDensityModelID;
                    if (Model.ExistingDepositDensityModelID == "General")
                    {
                        Result.MTonnage = Model.MedianTonnage.ToString();
                    }
                    else
                    {
                        Result.MTonnage = "-";
                    }
                    Result.TArea  = Model.AreaOfPermissiveTract.ToString();
                    Result.NKnown = Model.NumbOfKnownDeposits.ToString();
                    Result.Note   = ddResult.Note;
                });

                input.N10  = Result.N10;
                input.N50  = Result.N50;
                input.N90  = Result.N90;
                input.Note = Result.Note;
                string outputFolder = Path.Combine(settingsService.RootPath, "UndiscDep");
                input.Save(Path.Combine(outputFolder, "deposit_density_input_params.json"));
                dialogService.ShowNotification("DepositDensityTool completed successfully.", "Success");
                viewModelLocator.SettingsViewModel.WriteLogText("DepositDensityTool completed successfully.", "Success");
                Model.LastRunDate = "Last Run: " + DateTime.Now.ToString("g");
                Model.RunStatus   = 1;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Failed to execute REngine() script");
                dialogService.ShowNotification("Run failed. Check output for details.\r\n- Are all input parameters correct?\r\n- Are all input files valid? \r\n- Are all input and output files closed?", "Error");
                viewModelLocator.SettingsViewModel.WriteLogText("Run failed in Deposit Density Tool. Check output for details.\r\n- Are all input parameters correct?\r\n- Are all input files valid? \r\n- Are all input and output files closed?", "Error");
                Model.RunStatus = 0;
            }
            finally
            {
                Model.IsBusy = false;
            }
            logger.Info("<--{0} completed", this.GetType().Name);
        }