Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static SystemLogModel Create(SystemLogModel model)
        {
            // init entity
            var entity = new SystemLog();

            // set properties from model
            model.FillEntity(ref entity);
            // insert entity
            return(new SystemLogModel(SystemLogServices.Create(entity)));
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>

        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                // init time
                var time = DateTime.Now.AddMinutes(1);

                // init to time
                var toTime = new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, 0);

                // get ready scheduler
                var scheduler = SchedulerServices.GetAll(null, null, null, SchedulerStatus.Ready, true, SchedulerScope.Internal, null, toTime, null, 1).FirstOrDefault();
                if (scheduler != null)
                {
                    // run scheduler
                    await RunScheduler(scheduler);
                }
            }
            catch (Exception ex)
            {
                // create log
                var systemLog = new SystemLogModel
                {
                    Username         = "******",
                    Thread           = "JobScheduler",
                    Action           = SystemAction.TrackError,
                    ShortDescription = ex.Message,
                    LongDescription  = ex.ToString(),
                    IsException      = true,
                    CreatedDate      = DateTime.Now
                };

                // log exception
                SystemLogController.Create(systemLog);
            }
        }