示例#1
0
        public JsonResult SolutionTestCase()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var graph = NereidUtilities.BuildNetworkGraph(HttpRequestStorage.DatabaseEntities);

            // this subgraph is 23 nodes deep
            var single   = graph.Nodes.Single(x => x.ID == "RSB_42");
            var subgraph = graph.GetUpstreamSubgraph(single);

            var allLoadingInputs = HttpRequestStorage.DatabaseEntities.vNereidLoadingInputs.ToList();
            var allModelingBMPs  = NereidUtilities.ModelingTreatmentBMPs(HttpRequestStorage.DatabaseEntities).ToList();
            var allWaterqualityManagementPlanNodes = NereidUtilities.GetWaterQualityManagementPlanNodes(HttpRequestStorage.DatabaseEntities).ToList();
            var allModelingQuickBMPs = HttpRequestStorage.DatabaseEntities.QuickBMPs.Include(x => x.TreatmentBMPType)
                                       .Where(x => x.PercentOfSiteTreated != null && x.TreatmentBMPType.IsAnalyzedInModelingModule).ToList();

            var responseContent = NereidUtilities.SolveSubgraph(subgraph, allLoadingInputs, allModelingBMPs, allWaterqualityManagementPlanNodes, allModelingQuickBMPs, out _, NereidController.HttpClient, true);

            var stopwatchElapsedMilliseconds = stopwatch.ElapsedMilliseconds;

            stopwatch.Stop();

            return(Json(new { elapsed = stopwatchElapsedMilliseconds, responseContent }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ContentResult TreatmentSiteTable()
        {
            var waterQualityManagementPlanNodes = NereidUtilities.GetWaterQualityManagementPlanNodes(HttpRequestStorage.DatabaseEntities);

            var list = HttpRequestStorage.DatabaseEntities.WaterQualityManagementPlans
                       .SelectMany(x => x.QuickBMPs.Where(y => y.TreatmentBMPType.IsAnalyzedInModelingModule)).Join(
                waterQualityManagementPlanNodes, x => x.WaterQualityManagementPlanID,
                x => x.WaterQualityManagementPlanID, (bmp, node) => new { bmp, node }).ToList();

            var treatmentSites = list.Select(x =>
                                             new TreatmentSite
            {
                NodeID = NereidUtilities.WaterQualityManagementPlanTreatmentNodeID(x.node.WaterQualityManagementPlanID,
                                                                                   x.node.RegionalSubbasinID),
                AreaPercentage     = x.bmp.PercentOfSiteTreated,
                CapturedPercentage = x.bmp.PercentCaptured,
                RetainedPercentage = x.bmp.PercentRetained,
                FacilityType       = x.bmp.TreatmentBMPType.TreatmentBMPModelingType.TreatmentBMPModelingTypeName
            }).ToList();

            var treatmentSiteTable = new TreatmentSiteTable()
            {
                TreatmentSites = treatmentSites
            };

            return(Content(JsonConvert.SerializeObject(treatmentSiteTable), "application/json"));
        }