Esempio n. 1
0
        public async Task <bool> AlgorithmIsRunning()
        {
            // checks for a rating job in the processing state
            var job = await _ratingJobRepository.GetActive();

            if (job == null)
            {
                return(false);
            }
            using (var connection = JobStorage.Current.GetConnection())
            {
                try
                {
                    var jobState = connection.GetStateData(job.JobId.ToString());
                    if (jobState.Name.Equals(Hangfire.States.ProcessingState.StateName))
                    {
                        return(true);
                    }
                }
                catch (Exception)
                {
                    //job has not been run by the scheduler yet, swallow error
                    return(false);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public async Task <string> GetProgress(string type)
        {
            string jobType;

            switch (type)
            {
            case "singles":
                jobType = "Algorithm.Singles";
                break;

            case "doubles":
                jobType = "Algorithm.Doubles";
                break;

            default:
                return("Type must be singles or doubles");
            }
            var job = await _ratingJobRepository.GetActive(jobType);

            return(job == null ? "Not running" : job.Status);
        }