Ejemplo n.º 1
0
        public JsonResult NoTreatmentFacility()
        {
            var treatmentFacilityUrl = $"{NeptuneWebConfiguration.NereidUrl}/api/v1/treatment_facility/validate?state=ca&region=soc";

            var treatmentFacilities = HttpRequestStorage.DatabaseEntities.TreatmentBMPs
                                      .Where(x => x.TreatmentBMPID == 9974).ToList().Select(x => x.ToTreatmentFacility(true)).ToList();

            var treatmentFacilityTable = new TreatmentFacilityTable()
            {
                TreatmentFacilities = treatmentFacilities
            };
            bool   failed          = false;
            string responseContent = null;

            try
            {
                NereidUtilities.RunJobAtNereid <TreatmentFacilityTable, object>(treatmentFacilityTable,
                                                                                treatmentFacilityUrl,
                                                                                out responseContent, HttpClient);
            }
            catch (Exception)
            {
                failed = true;
            }

            return(Json(
                       new
            {
                firstCallFailed = failed,
                responseContent,
                requestContent = JsonConvert.SerializeObject(treatmentFacilityTable)
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult ValidateNetworkGraph()
        {
            var networkValidatorUrl = $"{NeptuneWebConfiguration.NereidUrl}/api/v1/network/validate";
            var stopwatch           = new Stopwatch();

            stopwatch.Start();
            var buildGraphStartTime = stopwatch.Elapsed;
            var graph             = NereidUtilities.BuildNetworkGraph(HttpRequestStorage.DatabaseEntities);
            var buildGraphEndTime = stopwatch.Elapsed;

            var validateCallStartTime  = stopwatch.Elapsed;
            var networkValidatorResult = NereidUtilities.RunJobAtNereid <Graph, NetworkValidatorResult>(graph, networkValidatorUrl, out _, HttpClient);

            var validateCallEndTime = stopwatch.Elapsed;

            stopwatch.Stop();

            var returnValue = new
            {
                NetworkValidatorResult   = networkValidatorResult,
                BuildGraphElapsedTime    = (buildGraphEndTime - buildGraphStartTime).Milliseconds,
                ValidateGraphElapsedTime = (validateCallEndTime - validateCallStartTime).Milliseconds,
                NodeCount = graph.Nodes.Count,
                EdgeCount = graph.Edges.Count,
            };

            return(Json(returnValue, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public JsonResult ValidateTreatmentFacility(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey)
        {
            var treatmentFacilityUrl = $"{NeptuneWebConfiguration.NereidUrl}/api/v1/treatment_facility/validate?state=ca&region=soc";

            var treatmentFacility = treatmentBMPPrimaryKey.EntityObject.ToTreatmentFacility(true);

            var treatmentFacilityTable = new TreatmentFacilityTable()
            {
                TreatmentFacilities = new List <TreatmentFacility> {
                    treatmentFacility
                }
            };

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            NereidUtilities.RunJobAtNereid <TreatmentFacilityTable, object>(treatmentFacilityTable, treatmentFacilityUrl,
                                                                            out var responseContent, HttpClient);
            var stopwatchElapsedMilliseconds = stopwatch.ElapsedMilliseconds;

            return(Json(
                       new
            {
                rpcTime = stopwatchElapsedMilliseconds,
                responseContent,
                requestContent = JsonConvert.SerializeObject(treatmentFacilityTable)
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public JsonResult TreatmentFacility()
        {
            var treatmentFacilityUrl = $"{NeptuneWebConfiguration.NereidUrl}/api/v1/treatment_facility/validate?state=ca&region=soc";

            var treatmentFacilities = NereidUtilities.ModelingTreatmentBMPs(HttpRequestStorage.DatabaseEntities)
                                      .ToList().Where(x => x.IsFullyParameterized())
                                      .Select(x => x.ToTreatmentFacility(false)).ToList();

            var treatmentFacilityTable = new TreatmentFacilityTable()
            {
                TreatmentFacilities = treatmentFacilities
            };

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            NereidUtilities.RunJobAtNereid <TreatmentFacilityTable, object>(treatmentFacilityTable, treatmentFacilityUrl,
                                                                            out var responseContent, HttpClient);
            var stopwatchElapsedMilliseconds = stopwatch.ElapsedMilliseconds;

            return(Json(
                       new
            {
                rpcTime = stopwatchElapsedMilliseconds,
                responseContent,
                requestContent = JsonConvert.SerializeObject(treatmentFacilityTable)
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public JsonResult BaselineLoading()
        {
            var landSurfaceLoadingUrl    = $"{NeptuneWebConfiguration.NereidUrl}/api/v1/land_surface/loading?details=true&state=ca&region=soc";
            var regionalSubbasinsForTest = new List <int> {
                2377, 12394
            };
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var buildLoadingInputStartTime = stopwatch.Elapsed;
            var vNereidLoadingInputs       = HttpRequestStorage.DatabaseEntities.vNereidLoadingInputs.Where(x => regionalSubbasinsForTest.Contains(x.RegionalSubbasinID)).ToList();
            var landSurfaceLoadingRequest  = new LandSurfaceLoadingRequest(vNereidLoadingInputs, true);
            var buildLoadingInputEndTime   = stopwatch.Elapsed;

            stopwatch.Stop();

            var unused = NereidUtilities.RunJobAtNereid <LandSurfaceLoadingRequest, object>(landSurfaceLoadingRequest, landSurfaceLoadingUrl, out var responseContent, HttpClient);

            var returnValue = new
            {
                LoadingRequest = landSurfaceLoadingRequest,

                LoadingResult = responseContent,

                SubgraphCallElapsedTime = (buildLoadingInputEndTime - buildLoadingInputStartTime).Milliseconds,
            };

            return(Json(returnValue, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        public JsonResult SolutionSequence()
        {
            var solutionSequenceUrl = $"{NeptuneWebConfiguration.NereidUrl}/api/v1/network/solution_sequence?min_branch_size=12";
            var stopwatch           = new Stopwatch();

            stopwatch.Start();

            var buildGraphStartTime = stopwatch.Elapsed;
            var graph             = NereidUtilities.BuildNetworkGraph(HttpRequestStorage.DatabaseEntities);
            var buildGraphEndTime = stopwatch.Elapsed;

            var solutionSequenceRequestObject = new SolutionSequenceRequest(graph);

            var subgraphCallStartTime  = stopwatch.Elapsed;
            var solutionSequenceResult = NereidUtilities.RunJobAtNereid <SolutionSequenceRequest, SolutionSequenceResult>(solutionSequenceRequestObject,
                                                                                                                          solutionSequenceUrl, out _, HttpClient);
            var subgraphCallEndTime = stopwatch.Elapsed;

            stopwatch.Stop();
            var returnValue = new
            {
                SubgraphResult          = solutionSequenceResult.Data,
                BuildGraphElapsedTime   = (buildGraphEndTime - buildGraphStartTime).Milliseconds,
                SubgraphCallElapsedTime = (subgraphCallEndTime - subgraphCallStartTime).Milliseconds,
                NodeCount = graph.Nodes.Count,
                EdgeCount = graph.Edges.Count,
            };

            return(Json(returnValue, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        public JsonResult Subgraph()
        {
            var subgraphUrl = $"{NeptuneWebConfiguration.NereidUrl}/api/v1/network/subgraph";
            var stopwatch   = new Stopwatch();

            stopwatch.Start();

            var buildGraphStartTime = stopwatch.Elapsed;
            var graph             = NereidUtilities.BuildNetworkGraph(HttpRequestStorage.DatabaseEntities);
            var buildGraphEndTime = stopwatch.Elapsed;

            var subgraphRequestObject = new NereidSubgraphRequestObject(graph, new List <Node> {
                new Node("BMP_39")
            });
            var subgraphCallStartTime = stopwatch.Elapsed;

            var subgraphResult = NereidUtilities.RunJobAtNereid <NereidSubgraphRequestObject, SubgraphResult>(subgraphRequestObject,
                                                                                                              subgraphUrl, out _, HttpClient);
            var subgraphCallEndTime = stopwatch.Elapsed;

            stopwatch.Stop();

            var returnValue = new
            {
                SubgraphResult          = subgraphResult,
                BuildGraphElapsedTime   = (buildGraphEndTime - buildGraphStartTime).Milliseconds,
                SubgraphCallElapsedTime = (subgraphCallEndTime - subgraphCallStartTime).Milliseconds,
                NodeCount = graph.Nodes.Count,
                EdgeCount = graph.Edges.Count,
            };

            return(Json(returnValue, JsonRequestBehavior.AllowGet));
        }