예제 #1
0
 public static void LaunchJob(JobItem item)
 {
     if (_instance != null)
     {
         _instance.doJob(item, false);
     }
 }
예제 #2
0
 public static void RemoveJob(JobItem item)
 {
     if (_instance != null && _instance._jobItems.Remove(item))
     {
         _instance.saveJob();
     }
 }
예제 #3
0
        public static bool AddJob(JobItem item)
        {
            if (_instance == null)
            {
                StartUp();
            }
            var type = Type.GetType(item.AssemblyQualifiedName);

            if (type.GetInterface("CommonLib.Helper.IJob") != null)
            {
                _instance._jobItems.Add(item);
                _instance.saveJob();
                return(true);
            }
            return(false);
        }
예제 #4
0
        public static JobItem LaunchJob(int?jobID)
        {
            JobItem item = _instance?._jobItems?.Where(j => j.JobID == jobID).FirstOrDefault();

            if (item != null)
            {
                try
                {
                    _instance.doJob(item);
                    item.LastError = null;
                }
                catch (Exception ex)
                {
                    global::Utility.Logger.Error(ex);
                    item.LastError = ex.ToString();
                }
                _instance.saveJob();
            }

            return(item);
        }
예제 #5
0
        private void doJob(JobItem item, bool nextSchedule = true)
        {
            if (item.Pending == true)
            {
                return;
            }

            var type = Type.GetType(item.AssemblyQualifiedName);

            if (type == null)
            {
                _jobItems.Remove(item);
            }
            else
            {
                IJob job = (IJob)type.Assembly.CreateInstance(type.FullName);
                job.DoJob();
                if (nextSchedule)
                {
                    item.Schedule = job.GetScheduleToNextTurn(item.Schedule);
                }
                job.Dispose();
            }
        }