private static bool _GetVrpObject <T>(SyncVrpResponse response, string paramName, out T obj) { Debug.Assert(response != null); Debug.Assert(paramName != null); obj = default(T); bool res = false; if (response.Objects != null) { foreach (GPParamObject gpParam in response.Objects) { if (!String.IsNullOrEmpty(gpParam.paramName) && gpParam.paramName.Equals(paramName, StringComparison.OrdinalIgnoreCase)) { obj = (T)gpParam.value; res = true; break; } } } return(res); }
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); }