static void Main(string[] args) { Console.WriteLine("Welcome to Bake Pizza"); var pizza = new CheezFactory(); pizza.Order("Cheese"); Console.WriteLine(); var pizza2 = new CornFactory(); pizza.Order("Corn"); Console.WriteLine(); Console.Read(); }
/// <summary> /// 将任务移入任务池 /// </summary> /// <param name="taskid"></param> /// <param name="taskruntimeinfo"></param> /// <returns></returns> public bool Add(string taskid, NodeTaskRuntimeInfo taskruntimeinfo) { lock (_locktag) { if (!TaskRuntimePool.ContainsKey(taskid)) { JobDetail jobDetail = new JobDetail(taskruntimeinfo.TaskModel.id.ToString(), taskruntimeinfo.TaskModel.categoryid.ToString(), typeof(TaskJob));// 任务名,任务组,任务执行类 var trigger = CornFactory.CreateTigger(taskruntimeinfo); _sched.ScheduleJob(jobDetail, trigger); TaskRuntimePool.Add(taskid, taskruntimeinfo); return(true); } return(false); } }
/// <summary> /// 将任务移入任务池 /// </summary> /// <param name="taskid"></param> /// <param name="taskruntimeinfo"></param> /// <returns></returns> public bool Add(string taskid, NodeTaskRunTimeInfo taskruntimeinfo, ref string nextrunTime) { lock (_locktag) { if (!TaskRuntimePool.ContainsKey(taskid)) { JobDetail jobDetail = new JobDetail(taskruntimeinfo.TaskModel.id.ToString(), taskruntimeinfo.TaskModel.groupid.ToString(), typeof(TaskJob));// 任务名,任务组,任务执行类 var trigger = CornFactory.CreateTigger(taskruntimeinfo); _sched.ScheduleJob(jobDetail, trigger); nextrunTime = Convert.ToDateTime(trigger.GetNextFireTimeUtc()).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); nextrunTime = nextrunTime.IndexOf("0001-01") > -1 ? "2099-12-30" : nextrunTime; TaskRuntimePool.Add(taskid, taskruntimeinfo); return(true); } return(false); } }