public override string CreateExpiredJob(Common.Job job, IDictionary <string, string> parameters, DateTime createdAt, TimeSpan expireIn)
        {
            if (job == null)
            {
                throw new ArgumentNullException(nameof(job));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            InvocationData invocationData = InvocationData.Serialize(job);

            Documents.Job entityJob = new Documents.Job
            {
                InvocationData = invocationData,
                Arguments      = invocationData.Arguments,
                CreatedOn      = createdAt,
                ExpireOn       = createdAt.Add(expireIn).ToEpoch(),
                Parameters     = parameters
            };

            IOperationResult <Documents.Job> response = bucket.Insert(entityJob.Id, entityJob);

            if (response.Success)
            {
                return(entityJob.Id);
            }

            return(string.Empty);
        }
        public override JobData GetJobData(string jobId)
        {
            if (jobId == null)
            {
                throw new ArgumentNullException(nameof(jobId));
            }

            IDocumentResult <Documents.Job> result = bucket.GetDocument <Documents.Job>(jobId);

            if (result.Success && result.Content != null)
            {
                Documents.Job  data           = result.Content;
                InvocationData invocationData = data.InvocationData;
                invocationData.Arguments = data.Arguments;

                Common.Job       job           = null;
                JobLoadException loadException = null;

                try
                {
                    job = invocationData.Deserialize();
                }
                catch (JobLoadException ex)
                {
                    loadException = ex;
                }

                return(new JobData
                {
                    Job = job,
                    State = data.StateName,
                    CreatedAt = data.CreatedOn,
                    LoadException = loadException
                });
            }

            return(null);
        }