private void _LogJobStatistics(string jobId, SolveStatistics statistics) { Logger.Info(String.Format(LOG_JOB_STATISTICS, this.OperationType, jobId, statistics.RequestTime.TotalSeconds)); }
/// <summary> /// Does solve. /// </summary> /// <param name="jobRequest">VRP request.</param> /// <param name="cancelTracker">Cancel tracker (Can be NULL).</param> /// <returns>Function returning VRP solve operation result.</returns> public Func <SolveOperationResult <SubmitVrpJobRequest> > Solve( SubmitVrpJobRequest jobRequest, ICancelTracker cancelTracker) { Debug.Assert(null != jobRequest); var result = default(VrpResult); var resultProvider = Functional.MakeLambda(() => { var operationResult = new SolveOperationResult <SubmitVrpJobRequest>(); operationResult.SolveResult = _ProcessSolveResult(result, jobRequest); operationResult.NextStepOperation = _nextStep; return(operationResult); }); if (jobRequest.Orders.Features.Length == 0) { result = new VrpResult() { SolveHR = 0, }; return(resultProvider); } var factory = _context.VrpServiceFactory; using (var client = factory.CreateService(VrpRequestBuilder.JsonTypes)) { var requestTime = new Stopwatch(); requestTime.Start(); // send request var response = _SendRequest( client, jobRequest, cancelTracker); // create VRP result result = new VrpResult() { Messages = response.Messages, SolveHR = response.SolveHR, ResultObjects = response.RouteResult, }; if (CanProcessResult(result.SolveHR)) { _ValidateVrpResults(response); // calc. statistics requestTime.Stop(); var stat = new SolveStatistics() { RequestTime = requestTime.Elapsed }; _LogJobStatistics(response.JobID, stat); } if (!_options.GenerateDirections && result.ResultObjects != null) { result.ResultObjects.Directions = null; } return(resultProvider); } }