示例#1
0
        public async Task <JsonResult> GetCMVSummary([FromRoute] string siteModelID, [FromBody] OverrideParameters overrides)
        {
            string resultToReturn;

            if (!Guid.TryParse(siteModelID, out var UID))
            {
                resultToReturn = $"<b>Invalid Site Model UID: {siteModelID}</b>";
            }
            else
            {
                var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(UID, false);

                if (siteModel == null)
                {
                    resultToReturn = $"<b>Site model {UID} is unavailable</b>";
                }
                else
                {
                    var sw = new Stopwatch();
                    sw.Start();

                    var operation = new CMVStatisticsOperation();

                    var result = await operation.ExecuteAsync(
                        new CMVStatisticsArgument()
                    {
                        ProjectID = siteModel.ID,
                        Filters   = new FilterSet(new CombinedFilter()),
                        Overrides = overrides
                    }
                        );

                    if (result != null)
                    {
                        string resultString = $"<b>CMV Summary Results (in {sw.Elapsed}) :</b><br/>";
                        resultString += "<b>================================================</b><br/>";
                        resultString += $"<b>Above CMV Percentage:</b> {result.AboveTargetPercent}<br/>";
                        resultString += $"<b>Within CMV Percentage Range:</b> {result.WithinTargetPercent}<br/>";
                        resultString += $"<b>Below CMV Percentage:</b> {result.BelowTargetPercent}<br/>";
                        resultString += $"<b>Total Area Covered in Sq Meters:</b> {result.TotalAreaCoveredSqMeters}<br/>";

                        resultToReturn = resultString;
                    }
                    else
                    {
                        resultToReturn = "<b>No result</b>";
                    }
                }
            }

            return(new JsonResult(resultToReturn));
        }
示例#2
0
        public async Task <JsonResult> GetCMVDetails([FromRoute] string siteModelID, [FromBody] OverrideParameters overrides)
        {
            const int CMV_DENOMINATOR = 10;
            string    resultToReturn;

            if (!Guid.TryParse(siteModelID, out var UID))
            {
                resultToReturn = $"<b>Invalid Site Model UID: {siteModelID}</b>";
            }
            else
            {
                var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(UID, false);
                var cmvBands  = new[] { 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 1000, 1200 };

                if (siteModel == null)
                {
                    resultToReturn = $"<b>Site model {UID} is unavailable</b>";
                }
                else
                {
                    var sw = new Stopwatch();
                    sw.Start();

                    var operation = new CMVStatisticsOperation();
                    var result    = await operation.ExecuteAsync(
                        new CMVStatisticsArgument()
                    {
                        ProjectID = siteModel.ID,
                        Filters   = new FilterSet()
                        {
                            Filters = new[] { new CombinedFilter() }
                        },
                        CMVDetailValues = cmvBands,
                        Overrides       = overrides
                    }
                        );

                    if (result != null)
                    {
                        string resultString = $"<b>CMV Details Results (in {sw.Elapsed}) :</b><br/>";
                        resultString += "<b>================================================</b><br/>";

                        var anyTwoDigitsNumber   = cmvBands.ToList().Find(s => (s / CMV_DENOMINATOR) >= TWO_DIGITS_NUMBER);
                        var anyThreeDigitsNumber = cmvBands.ToList().Find(s => (s / CMV_DENOMINATOR) >= THREE_DIGITS_NUMBER);

                        for (int i = 0; i < cmvBands.Length; i++)
                        {
                            string space = anyThreeDigitsNumber > 0 && cmvBands[i] / CMV_DENOMINATOR < THREE_DIGITS_NUMBER ? "&nbsp;&nbsp;" : string.Empty;

                            if (anyTwoDigitsNumber > 0 && cmvBands[i] / CMV_DENOMINATOR < TWO_DIGITS_NUMBER)
                            {
                                space += "&nbsp;&nbsp;";
                            }

                            resultString += $"<b>{space}{cmvBands[i] / CMV_DENOMINATOR}</b> - {result.Percents[i]:##0.#0}%<br/>";
                        }

                        resultToReturn = resultString;
                    }
                    else
                    {
                        resultToReturn = "<b>No result</b>";
                    }
                }
            }

            return(new JsonResult(resultToReturn));
        }