ExecuteDeferredRequests(int bulkSize = 1000) { ValidateDeferredQueueState(); IDictionary <OrganizationRequest, ExecuteBulkResponse> bulkResponse; using (var service = enhancedOrgServiceBase.GetService()) { bulkResponse = deferredRequests .Cast <OrganisationRequestToken <OrganizationResponse> >() .Select(e => e.Request) .ExecuteTransaction(service, true, bulkSize); } var responses = deferredRequests .Cast <OrganisationRequestToken <OrganizationResponse> >() .ToDictionary( e => e.Request, e => { e.Value = bulkResponse[e.Request].Response; return(e); }); // TODO set response token as ready for consumption, else error CancelDeferredRequests(); return(responses); }
public virtual IDictionary <Guid, OrganizationResponse> ExecutePlan() { ValidateExecutionPlanState(); var serialised = executionQueue.ToList().SerialiseContractJson(true, surrogate: new DateTimeCrmContractSurrogateCustom()); if (serialised.IsEmpty()) { throw new InvalidPluginExecutionException("Could not deserialise planned execution operations." + " Possibly because one of the serialised types could not be found through the sandbox plugin."); } var request = new OrganizationRequest("ys_LibrariesExecutePlannedOperations") { Parameters = new ParameterCollection { { "ExecutionPlan", serialised.Compress() } } }; using var service = enhancedOrgServiceBase.GetService(); var response = ((string)service.Execute(request)["SerialisedResult"]).Decompress(); var result = response.DeserialiseContractJson <MockDictionary>(true, surrogate: new DateTimeCrmContractSurrogateCustom()) .ToDictionary(e => Guid.Parse(e.Key), e => e.Value.Unmock <OrganizationResponse>()); CancelPlanning(); return(result); }