public async Task <object> RetryParticipationSyncImmediately( CrmData data, Configurations requestWideSettings, bool requestConsumerId = false) { var jobId = await Task.Run(() => BackgroundJob.Enqueue <ICrmConsumerProvider>( iCrmProvider => iCrmProvider.CreateParticipationAsync( data, requestWideSettings, requestConsumerId))); var result = new object(); IMonitoringApi monitoringApi = JobStorage.Current.GetMonitoringApi(); JobDetailsDto jobDetails = monitoringApi.JobDetails(jobId); SucceededJobDto jobDto = monitoringApi.SucceededJobs(0, int.MaxValue) .First() //.FirstOrDefault(job => job.Key == "Key") .Value; if (jobDto != null) { result = jobDto.Result; return(JsonConvert.DeserializeObject <CrmResponse>(result.ToString())); } return(null); }
private string GetSucceededJobResult(string jobId) { var api = JobStorage.Current.GetMonitoringApi(); SucceededJobDto jobDto = api.SucceededJobs(0, int.MaxValue).FirstOrDefault(job => job.Key == jobId).Value; return(jobDto.Result as string); }
public JobList <SucceededJobDto> SucceededJobs(int @from, int count) { return(UsingDatabase(db => { var jobs = db.GetTable <Entities.Job>() .Where(j => j.StateName == "Succeeded") .OrderByDescending(j => j.Id) .Skip(from) .Take(count); var list = new List <KeyValuePair <string, SucceededJobDto> >(); foreach (var sqlJob in jobs) { var stateData = sqlJob.ToStateData().Data; var s = new SucceededJobDto() { Job = sqlJob.ToCommonJob(), InSucceededState = true, Result = stateData.ContainsKey("Result") ? stateData["Result"] : null, TotalDuration = stateData.ContainsKey("PerformanceDuration") && stateData.ContainsKey("Latency") ? (long?)long.Parse(stateData["PerformanceDuration"]) + (long?)long.Parse(stateData["Latency"]) : null, SucceededAt = sqlJob.GetNullableDateTimeStateDataValue("SucceededAt") }; list.Add(new KeyValuePair <string, SucceededJobDto>( sqlJob.Id.ToString(CultureInfo.InvariantCulture), s)); } return new JobList <SucceededJobDto>(list); })); }