Ejemplo n.º 1
0
        /// <summary>
        /// 根据Class名称通过反射的方式创建IJobDetial
        /// 注意需要向J_JobInfo中拓展的UID赋值
        /// 修改传入的对象为IJ_JobInfo的实现类
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static IJobDetail CreateJobInstance(IJ_JobInfo jobInfo,IJobData jobdatamap)
        {
            //1 通过反射的方式创建Job实例
            IJob job_temp= JobAbstractFactory.CreateJob(jobInfo.JobClassName);
            //2 获取创建的Job实例的Type
            Type type = job_temp.GetType();
            IJobDetail job = null;
            #region 注释掉用以下方式替代
            //var obj= Activator.CreateInstance(type);

            //正常创建:
            //IJobDetail job=JobBuilder.Create<Job_Test>()
            //                        .WithIdentity("myJob", "group1")
            //                        .Build();
            #endregion
            //3 创建Job
            //获取传递过来的UID
            try
            {
                job = JobBuilder.Create(type)
                                    .WithIdentity(jobInfo.JID.ToString(), jobInfo.JobGroup)
                                    .UsingJobData("UID", jobInfo.UID)
                                    .UsingJobData(jobdatamap.JobDataKey,SerializerHelper.SerializerToString(jobdatamap))        //添加一个需要传向作业调度中的对象(发送对象——含一些必要的信息)
                                    .Build();
            }
            catch (Exception)
            {

            }

            return job;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 创建作业实例
 /// (写入数据库及添加至作业调度池中)
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public PMS.Model.Message.IBaseResponse AddJobInfo(J_JobInfo model, IJobData jobData=null)
 {
     //1 创建与UserInfo的关系
        var user= this.CurrentDBSession.UserInfoDAL.GetListBy(u => u.ID == model.UID).FirstOrDefault();
     //12月9日
     //注意此处不要将user转成中间变量,否则会创建一个新的user对象该userInfo表中
     //model.UserInfoes.Add(user.ToMiddleModel());
     model.UserInfoes.Add(user);
     //2 创建J_JobInfo对象
     // 1 添加作业至调度池中
     if(jobData==null) jobData = new PMS.Model.JobDataModel.SendJobDataModel();
     model.JobState = (int)(PMS.Model.Enum.JobState_Enum.WAITING);
     base.Create(model);
     //var response = ijobService.AddScheduleJob(model, jobData);
     var response = client_quartzProxy.AddScheduleJob(model, jobData as PMS.Model.JobDataModel.SendJobDataModel);
     //object response_wcf= jobServiceClient.AddScheduleJob(model.ToMiddleModel(), jobData);
     //var response= response_wcf as Model.Message.IBaseResponse;
     //client.AddScheduleJob(model.ToMiddleModel(), jobData);
     //2 写入jobInfo表作业的状态
     if (response.Success)
     {
         model.JobState = (int)(PMS.Model.Enum.JobState_Enum.WAITING);
         base.Update(model);
     }
     //2 根据传入的JobInfo创建指定的作业
     //if (response.Success == true)
     //{
     //    base.Create(model);
     //}
     //if (base.Create(model))
     //{
     //    return true;
     //}
     return response;
 }
Ejemplo n.º 3
0
    	public Job( IJobData job ) : this()
        {
    	    ID          = job.ID;
    	    StatusID    = job.StatusID;
    	    CreatedDate = job.CreatedDate;
    	    LastUpdated = job.LastUpdated;

			var xDoc = new XmlDocument();
			xDoc.LoadXml( job.JobXML.ToString());

    		AddPluginTrackables(xDoc.DocumentElement);
        }
Ejemplo n.º 4
0
 public JobCountViewComponent(IJobData jobData)
 {
     this.jobData = jobData;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据工作对象 添加任务计划
        /// 作业需要含UID
        /// </summary>
        /// <param name="jobInfo">作业(含UID)</param>
        /// <param name="data_temp">向作业调度中传的临时数据</param>
        /// <returns></returns>
        public IBaseResponse AddScheduleJob(J_JobInfo jobInfo,IJobData data_temp)
        {
            //1 根据Job的类名通过反射的方式创建IJobDetial
            var job = JobFactory.CreateJobInstance(jobInfo, data_temp);
            IBaseResponse response = new BaseResponse() { Success = false };
            if (job == null)
            {
                response.Message = string.Format("创建作业实例时出错");
            }
            //2 创建定时器
            var trigger = JobFactory.CreateTrigger(jobInfo);

            //3 将定时器加入job中
            //var sche = new SchedulerFactory().GetScheduler();
            sche.ScheduleJob(job, trigger);
            try
            {
                //4 启动工作
                sche.Start();
                LogHelper.WriteLog(string.Format("{0}创建的作业{1}-{2}(所属{3})已添加至调度池中", jobInfo.CreateUser, jobInfo.JID, jobInfo.JobName, jobInfo.JobGroup));
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("作业添加错误",ex);
                throw;
            }

            response.Success = true;
            response.Message = string.Format("作业已添加至调度池中");
            return response;
        }
Ejemplo n.º 6
0
 public DetailModel(IJobData jobData)
 {
     this.jobData = jobData;
 }
Ejemplo n.º 7
0
 public EditModel(IJobData jobData, IHtmlHelper htmlHelper)
 {
     this.jobData    = jobData;
     this.htmlHelper = htmlHelper;
 }
Ejemplo n.º 8
0
 public ISingleResult<Job> Job_Update(IJobData jobData)
 {
     return Job_Update(jobData.ID,  jobData.StatusID, jobData.JobXML, jobData.CreatedDate);
 }
Ejemplo n.º 9
0
 public JobController(IJobData repostroryJob)
 {
     _repostroryJob = repostroryJob;
 }
Ejemplo n.º 10
0
 public DeleteModel(IJobData jobData)
 {
     this.jobData = jobData;
 }
Ejemplo n.º 11
0
 public IBaseResponse AddScheduleJob(J_JobInfo jobInfo, IJobData data_temp)
 {
     IBaseResponse response = new BaseResponse() { Success = false };
     return response;
 }
Ejemplo n.º 12
0
 public int Job_Update(IJobData jobData)
 {
     return Job_Update(jobData.ID, jobData.ClientID, jobData.StatusID, jobData.JobXML, jobData.CreatedDate);
 }
Ejemplo n.º 13
0
 public ListModel(IConfiguration config, Data.IJobData jobData)
 {
     this.config  = config;
     this.jobData = jobData;
 }