Пример #1
0
 public Task <JobMetadataResult[]> Handle(JobSearchCriteria command)
 {
     return(_searchHandlerImpl.Handle(command));
 }
Пример #2
0
        public Task <JobMetadataResult[]> Handle(JobSearchCriteria criteria)
        {
            Expression <Func <SqlCommonDbOddJobMetaData, bool> > expr = null;

            if (!string.IsNullOrWhiteSpace(criteria.QueueName))
            {
                expr = ExpressionHelpers.CombineBinaryExpression(expr,
                                                                 (a) => a.QueueName.ToLower().Contains(criteria.QueueName.ToLower()), false);
            }

            if (!string.IsNullOrWhiteSpace(criteria.MethodName) && criteria.UseMethod)
            {
                expr = ExpressionHelpers.CombineBinaryExpression(expr,
                                                                 (a) => a.MethodName.ToLower().Contains(criteria.MethodName.ToLower()), false);
            }
            if (!string.IsNullOrWhiteSpace(criteria.Status) && criteria.UseStatus)
            {
                expr = ExpressionHelpers.CombineBinaryExpression(expr,
                                                                 (a) => a.Status.ToLower().Contains(criteria.Status.ToLower()), false);
            }

            /*       if (statusCriteria != null && statusCriteria.Any())
             *     {
             *         expr = ExpressionHelpers.CombineBinaryExpression(expr, (a) => a.Status.LikeAnyLower(statusCriteria),
             *             requireAll);
             *
             *     }
             *
             *     if (jobNameCriteria != null && jobNameCriteria.Any())
             *     {
             *         expr = ExpressionHelpers.CombineBinaryExpression(expr,
             *             (a) => a.MethodName.LikeAnyUpper(jobNameCriteria), requireAll);
             *     }
             *
             *     if (jobGuids != null && jobGuids.Any())
             *     {
             *         expr = ExpressionHelpers.CombineBinaryExpression(expr, (a) => a.JobGuid.In(jobGuids), requireAll);
             *     }
             *
             *     expr = ExpressionHelpers.CombineBinaryExpression(expr, (a) => (
             *         (createdNoLaterThan == null || a.CreatedDate <= createdNoLaterThan)
             *         &&
             *         (createdNoEarlierThan == null || a.CreatedDate >= createdNoEarlierThan)
             *     ), requireAll);
             *     expr = ExpressionHelpers.CombineBinaryExpression(expr, (a) => (
             *         (lastExecutedNoLaterThan == null || a.LastAttempt <= lastExecutedNoLaterThan)
             *         &&
             *         (lastExecutedNoEarlierThan == null || a.LastAttempt >= lastExecutedNoEarlierThan)
             *     ), requireAll);
             */
            var result = expr == null ? new JobMetadataResult[] { } : _provider.GetSerializableJobsByCriteria(expr).Select(q => new JobMetadataResult()
            {
                ExecutionTime = q.ExecutionTime.ToString(),
                JobArgs       = q.JobArgs.Select(r => new JobParameterDto()
                {
                    Ordinal = r.Ordinal, Name = r.Name, Type = r.TypeName, Value = r.Value
                }).ToArray(),
                JobId = q.JobId,
                MethodGenericTypes = q.MethodGenericTypes.ToArray(),
                MethodName         = q.MethodName,
                Queue           = q.QueueName,
                RetryParameters = new JobRetryParameters()
                {
                    LastAttempt  = q.RetryParameters.LastAttempt,
                    RetryCount   = q.RetryParameters.RetryCount,
                    MaxRetries   = q.RetryParameters.MaxRetries,
                    MinRetryWait = q.RetryParameters.MinRetryWait
                },

                Status         = q.Status,
                TypeExecutedOn = q.TypeExecutedOn
            });

            return(Task.FromResult(result.ToArray()));
        }