internal static SerializedJob Serialize(BackgroundJobDetail job)
 {
     return new SerializedJob(job.Type.AssemblyQualifiedName, job.Method.Name,
         JobHelper.ToJson(
             job.Method.GetParameters().Select(x => x.ParameterType)),
         JobHelper.ToJson(job.Arguments));
 }
 internal static SerializedJob Serialize(BackgroundJobDetail job)
 {
     return(new SerializedJob(job.Type.AssemblyQualifiedName, job.Method.Name,
                              JobHelper.ToJson(
                                  job.Method.GetParameters().Select(x => x.ParameterType)),
                              JobHelper.ToJson(job.Arguments)));
 }
        public static void Enqueue(string queueName, Expression <Action> methodCall, string jobLabel, int?maxRetryCount)
        {
            if (!MessageQueue.Exists(queueName))
            {
                throw new InvalidOperationException(string.Format("ќчередь {0} отсутствует.", queueName));
            }
            var mq = new MessageQueue(queueName);

            using (var messageQueueTransaction = new MessageQueueTransaction())
            {
                messageQueueTransaction.Begin();
                var message = new Message(new MessageWrapper(maxRetryCount)
                {
                    SerializedJob =
                        JobHelper.ToJson(SerializedJob.Serialize(BackgroundJobDetail.FromExpression(methodCall)))
                })
                {
                    Label = jobLabel,
                };
                mq.Send(message, messageQueueTransaction);
                messageQueueTransaction.Commit();
            }
        }