Beispiel #1
0
        private static int _GetSolveHR(VrpResultsResponse resp)
        {
            Debug.Assert(resp != null);

            // check "succeeded" flag
            int hr = HResult.E_FAIL;

            if (!resp.SolveSucceeded)
            {
                // solve is not succeeded, try to determine exact HRESULT code
                // by response messages
                JobMessage[] messages = resp.Messages;
                if (messages != null)
                {
                    // process messages
                    if (!SolveErrorParser.ParseErrorCode(messages, out hr))
                    {
                        // cannot determine HRESULT
                        hr = HResult.E_FAIL;
                        Logger.Warning(LOG_UNDETERMINED_SOLVE_HR);
                    }
                }
            }
            else
            {
                // solve is succeeded, HRESULT = SO_OK
                hr = HResult.S_OK;
            }

            return(hr);
        }
Beispiel #2
0
        private static VrpResultsResponse _GetVrpResults(
            SyncVrpResponse response)
        {
            Debug.Assert(response != null);

            var vrpResponse = new VrpResultsResponse()
            {
                RouteResult = new GPRouteResult(),
                JobID       = SYNC_JOB_ID,
            };

            var results = vrpResponse.RouteResult;

            var layer = default(GPFeatureRecordSetLayer);

            _GetVrpObject <GPFeatureRecordSetLayer>(
                response,
                SyncVrpResponse.ParamRoutes,
                out layer);
            results.Routes = layer;

            var recordSet = default(GPRecordSet);

            _GetVrpObject <GPRecordSet>(response, SyncVrpResponse.ParamStops, out recordSet);
            results.Stops = recordSet;

            _GetVrpObject <GPRecordSet>(
                response,
                SyncVrpResponse.ParamUnassignedOrders,
                out recordSet);
            results.ViolatedStops = recordSet;

            _GetVrpObject <GPFeatureRecordSetLayer>(
                response,
                SyncVrpResponse.ParamDirections,
                out layer);
            results.Directions = layer;

            // solve result flag
            bool solveRes = false;

            if (_GetVrpObject <bool>(response, SyncVrpResponse.ParamSucceeded, out solveRes))
            {
                vrpResponse.SolveSucceeded = solveRes;
            }
            else
            {
                vrpResponse.SolveSucceeded = false;
            }

            // messages
            vrpResponse.Messages = response.Messages;

            vrpResponse.SolveHR = _GetSolveHR(vrpResponse);

            return(vrpResponse);
        }
Beispiel #3
0
        private static void _ValidateVrpResults(VrpResultsResponse resp)
        {
            Debug.Assert(resp != null);

            var results        = resp.RouteResult;
            var invalidResults =
                results == null ||
                results.Routes == null ||
                results.Stops == null;

            if (invalidResults)
            {
                throw new RouteException(Properties.Messages.Error_InvalidResultJobResponse);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Converts job submitting response into the result of synchronous
        /// job execution.
        /// </summary>
        /// <param name="response">The reference to the response object to
        /// be converted.</param>
        /// <param name="client">The reference to the REST service client object
        /// to retrieve job results with.</param>
        /// <param name="cancelTracker">The reference to the cancellation tracker
        /// object.</param>
        /// <returns><see cref="T:ESRI.ArcLogistics.Routing.Json.VrpResultsResponse"/>
        /// object corresponding to the specified job submitting response.</returns>
        private VrpResultsResponse _ConvertToSyncReponse(
            GetVrpJobResultResponse response,
            IVrpRestService client,
            ICancelTracker cancelTracker)
        {
            var syncResponse = new VrpResultsResponse()
            {
                SolveSucceeded = false,
                JobID          = response.JobId,
            };

            syncResponse.SolveSucceeded = false;
            syncResponse.Messages       = response.Messages;
            syncResponse.SolveHR        = HResult.E_FAIL;

            if (response.JobStatus != NAJobStatus.esriJobSucceeded)
            {
                return(syncResponse);
            }

            var solveSucceeded = _GetGPObject <GPBoolParam>(
                client,
                response.JobId,
                response.Outputs.SolveSucceeded.ParamUrl);

            syncResponse.SolveSucceeded = solveSucceeded.Value;
            syncResponse.SolveHR        = _GetSolveHR(syncResponse);

            if (CanProcessResult(syncResponse.SolveHR))
            {
                _ValidateResponse(response);

                // get route results
                syncResponse.RouteResult = _LoadResultData(
                    client,
                    response,
                    cancelTracker);
            }

            return(syncResponse);
        }