protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item) { try { var request = CastRequestObjectTo <GetEditDataRequest>(item); #if RAPTOR if (UseTRexGateway("ENABLE_TREX_GATEWAY_EDIT_DATA")) { #endif var projectIds = new ProjectIDs(request.ProjectId.Value, request.ProjectUid.Value); projectIds.Validate(); var assetUid = await GetAssetUid(projectIds, request.assetId); var parameters = new Dictionary <string, string> { { "projectUid", request.ProjectUid.Value.ToString() } } ; if (assetUid.HasValue) { parameters.Add("assetUid", assetUid.ToString()); } var queryParams = $"?{new System.Net.Http.FormUrlEncodedContent(parameters).ReadAsStringAsync().Result}"; var results = await trexCompactionDataProxy.SendDataGetRequest <TRexEditDataResult>(request.ProjectUid.Value.ToString(), $"/productiondataedit{queryParams}", customHeaders); var assetMatches = await GetAssetIds(projectIds, results.DataEdits.Select(d => d.AssetUid).ToList()); var convertedResults = from d in results.DataEdits select ProductionDataEdit.CreateProductionDataEdit(assetMatches[d.AssetUid], d.StartUtc, d.EndUtc, d.MachineDesignName, d.LiftNumber); return(EditDataResult.CreateEditDataResult(convertedResults.ToList())); #if RAPTOR } return(ProcessWithRaptor(request)); #endif } finally { ContractExecutionStates.ClearDynamic(); } }
private ContractExecutionResult ProcessWithRaptor(GetEditDataRequest request) { TDesignName[] designNames; TDesignLayer[] layers; if (request.assetId == null) { designNames = raptorClient.GetOverriddenDesigns(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID, -1); layers = raptorClient.GetOverriddenLayers(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID, -1); } else { designNames = raptorClient.GetOverriddenDesigns(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID, request.assetId <= 0 ? -1 : (long)request.assetId); layers = raptorClient.GetOverriddenLayers(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID, request.assetId <= 0 ? -1 : (long)request.assetId); } return(EditDataResult.CreateEditDataResult(ConvertDataEdits(designNames, layers))); }