private PeriodicServiceEntity UpdateService(string key, PeriodicServiceEntity e, PeriodicServiceOptions options, long iteration)
 {
     e.Enabled            = options.Enabled;
     e.Updated            = DateTime.UtcNow;
     e.Iteration          = iteration;
     e.PeriodMilliseconds = options.PeriodMilliseconds;
     e.Options            = Serialize(options);
     return(e);
 }
        private PeriodicServiceEntity UpdateRunService(string key, PeriodicServiceEntity e, PeriodicServiceOptions options, long iteration, long runDuration, string error)
        {
            var result = UpdateService(key, e, options, iteration);

            result.LastRun = DateTime.UtcNow;
            result.LastRunDurationMilliseconds = runDuration;
            result.LastRunError = error;
            return(result);
        }
        private PeriodicServiceEntity AddService(string key, PeriodicServiceOptions options, long iteration)
        {
            var result = new PeriodicServiceEntity
            {
                Name        = key,
                Added       = DateTime.UtcNow,
                ServiceType = options.ServiceType
            };

            result = UpdateService(key, result, options, iteration);
            return(result);
        }