public IEnumerable <ICancelingTemplateModel> GetAllByTaskType(JobTypeEnum taskType, bool isCoordinatorReason) { var result = repository.Find(t => !t.IsDeleted && t.IsCoordinatorReason == isCoordinatorReason && t.JobTypeList.Contains(taskType)); var mappedResult = result.Map <IEnumerable <ICancelingTemplateModel> >(); return(mappedResult); }
public AvailabilityFactory(CleanerMatchResultVM cleaner, Int32 serviceGapMins, JobTypeEnum serviceType, IList <String> serviceZone) { Cleaner = cleaner ?? throw new ArgumentException("No cleaner specified.", nameof(Cleaner)); if (serviceGapMins <= 0) { throw new ArgumentException("Invalid service gap requested.", nameof(ServiceGapMinutes)); } if (serviceZone == null || serviceZone.Count == 0) { throw new ArgumentException("Invalid service suburb/zone requested.", nameof(ServiceZone)); } ServiceDay = cleaner.SelectedRosterDay; if (cleaner.SelectedServiceDate.HasValue && cleaner.SelectedServiceDate != default(DateTime)) { ServiceDateUTC = cleaner.SelectedServiceDate.Value.ToUTC(); } else if (JobType == JobTypeEnum.Fortnighly || JobType == JobTypeEnum.Weekly) { // calculate next date ServiceDateUTC = DateTimeWrapper.FindNextDateForDay((DayOfWeek)ServiceDay); } JobType = serviceType; ServiceGapMinutes = serviceGapMins; ServiceZone = serviceZone; }
/// <summary> /// 作业日志记录 /// </summary> /// <param name="jobType">作业类型</param> /// <param name="jobName">作业名称</param> /// <param name="jobKey">作业主键</param> /// <param name="refClass">应用类别</param> /// <param name="refIDs">关键ID列表</param> /// <param name="status">状态</param> /// <param name="message">消息</param> public static void RecordLog(JobTypeEnum jobType, string jobName, string jobKey, string refClass, string refIDs, short status, string message, string stackTrace = null) { var entity = new JobLogEntity { JobType = jobType.ToString(), JobName = jobName, JobKey = jobKey, RefClass = refClass, RefIDs = refIDs, Status = status, Message = message, StackTrace = stackTrace, CreatedDateTime = System.DateTime.Now, CreatedByUserID = LogAdminDefine.ADMIN_USER_ID, CreatedByUserName = LogAdminDefine.ADMIN_USER_NAME }; LogService ls = new LogService(); ThreadPool.QueueUserWorkItem(new WaitCallback(ls.Record), entity); }
internal static bool ResumeTrigger(JobTypeEnum jobType, bool withRegularScheduling = true) { var trigger = jobType.GetTrigger(); if (trigger == null) { return(false); } if (withRegularScheduling) { var job = _scheduler.GetJobDetail(trigger.JobKey).Result; if (job == null) { return(false); } var jobSchedulingConfiguration = GetJobSchedulingConfiguration(job); var regularScheduling = jobSchedulingConfiguration.Scheduler; _scheduler.RescheduleJob(trigger.Key, regularScheduling); } _scheduler.ResumeTrigger(trigger.Key).Wait(); return(true); }
public static string GetTaskTypeLabel(this JobTypeEnum jobType, ITranslationService translationService) { var taskKeys = new[] { Constants.TaskTypeKey.FacilityTaskTypeKey, Constants.TaskTypeKey.AdHocTaskTypeKey, Constants.TaskTypeKey.TenantTaskType, Constants.TaskTypeKey.OtherTaskType }; IDictionary <string, string> translationList = translationService.Get(taskKeys, LanguageKey.Default); switch (jobType) { case JobTypeEnum.Facility: return(translationList[Constants.TaskTypeKey.FacilityTaskTypeKey]); case JobTypeEnum.AdHock: return(translationList[Constants.TaskTypeKey.AdHocTaskTypeKey]); case JobTypeEnum.Tenant: return(translationList[Constants.TaskTypeKey.TenantTaskType]); case JobTypeEnum.Other: return(translationList[Constants.TaskTypeKey.OtherTaskType]); default: throw new NotImplementedException($"No such task type {jobType}"); } }
public JobTypeEntry( JobTypeEnum jobTypeId, string jobTypeName ) { JobTypeId = jobTypeId; JobTypeName = jobTypeName; }
/// <summary> /// Log job error /// </summary> /// <param name="jobType"></param> /// <param name="executionType"></param> /// <param name="resultStatus"></param> /// <param name="message"></param> /// <param name="exception"></param> public static void LogJobError(JobTypeEnum jobType, JobExecutionTypeEnum executionType, JobResultStatusEnum resultStatus, string message, Exception exception) { // var theEvent = new LogEventInfo(LogLevel.Error, JOB_LOGGER_NAME, message); // theEvent.Properties["Status"] = JobResultStatusEnum.Success.ToString(); // theEvent.Properties["JobType"] = jobType.ToString(); // theEvent.Properties["IsForced"] = isForced.ToString(); // JobLogger.Log(theEvent); LogJobEvent(LogLevel.Error, jobType, executionType, resultStatus, message, exception); }
public List <Job> GetJobsByJobType(JobTypeEnum jobTypeId) { using (var cursor = collection.FindSync(f => f.JobTypeId == jobTypeId)) { List <Job> taskList = cursor.ToList(); return(FillDayAssigns(taskList)); } }
public CreateJobCommand(string id, Guid categoryId, string title, JobTypeEnum jobTypeId, Guid creatorId, RoleType createdByRole, List <JobAddress> addressList, List <RelationGroupModel> relationGroupList, string parentId) : base(id) { ParentId = parentId; CategoryId = categoryId; Title = title; JobTypeId = jobTypeId; CreatorId = creatorId; AddressList = addressList; RelationGroupList = relationGroupList; CreatedByRole = createdByRole; }
/// <summary> /// /// </summary> /// <param name="jobType"></param> /// <returns></returns> public static async Task ForceJobExecutionAsync(JobTypeEnum jobType) { if (_scheduler == null) { return; } var jobKey = jobType.GetJobKey(); var jobDataMap = new JobDataMap { { IS_FORCED, true } }; await _scheduler.TriggerJob(jobKey, jobDataMap).ConfigureAwait(false); }
private static ICronTrigger GetTrigger(this JobTypeEnum jobType) { if (_scheduler == null) { return(null); } if (!_scheduledTriggers.ContainsKey(jobType)) { throw new Exception($"Job '{jobType}' is not scheduled."); } return(_scheduledTriggers[jobType]); }
/// <summary> /// Log job event /// </summary> /// <param name="logLevel"></param> /// <param name="jobType"></param> /// <param name="executionType"></param> /// <param name="resultStatus"></param> /// <param name="message"></param> /// <param name="exception"></param> private static void LogJobEvent(LogLevel logLevel, JobTypeEnum jobType, JobExecutionTypeEnum executionType, JobResultStatusEnum resultStatus, string message, Exception exception = null) { var theEvent = new LogEventInfo(logLevel, JOB_LOGGER_NAME, message); theEvent.Properties["JobStatus"] = resultStatus.ToString(); theEvent.Properties["JobType"] = jobType.ToString(); theEvent.Properties["ExecutionType"] = executionType.ToString(); if (exception != null) { theEvent.Exception = exception; } JobLogger.Log(theEvent); }
public Task <IOperationalTaskModel> GetTask(Guid dayAssignId, JobTypeEnum type) { switch (type) { case JobTypeEnum.AdHock: return(GetAdHocTask(dayAssignId)); case JobTypeEnum.Tenant: return(GetTenantTask(dayAssignId)); case JobTypeEnum.Other: return(GetOtherTask(dayAssignId)); default: throw new Exception("GetTask method doesn't have implementation for type: " + type); } }
public JobDomain( string id, Guid categoryId, string title, JobTypeEnum jobTypeId, Guid creatorId, RoleType createdByRole, List <JobAddress> addressList, List <RelationGroupModel> relationGroupList, string parentId) : this() { Id = id; RaiseEvent(new JobCreated { ParentId = parentId, CategoryId = categoryId, Title = title, JobTypeId = jobTypeId, CreatorId = creatorId, AddressList = addressList, RelationGroupList = relationGroupList, CreatedByRole = createdByRole }); }
/// <summary> /// Convert the String (which should be string val of the enum) to the display string value /// </summary> /// <param name="val"></param> /// <returns></returns> public static string ToJobType(this string val) { if (string.IsNullOrEmpty(val)) { return(""); } string str = val; try { JobTypeEnum je = JobTypeEnum.NULL; str = je.FromString(val).TranslateVal(); } catch { str = val; } return(str); }
private static JobKey GetJobKey(this JobTypeEnum jobType) { if (_scheduler == null) { return(null); } if (!_scheduledTriggers.ContainsKey(jobType)) { throw new Exception($"Job '{jobType}' is not scheduled."); } var trigger = _scheduledTriggers[jobType]; var jobKey = trigger.JobKey; if (jobKey == null) { throw new Exception($"No job is defined for trigger '{trigger.Key}'."); } return(jobKey); }
/// <summary> /// Force job /// </summary> /// <param name="jobType"></param> public static void ForceJobExecution(JobTypeEnum jobType) { if (_scheduler == null) { return; } // var trigger = jobType.GetTrigger(); // if (_scheduler.GetTriggerState(trigger.Key).Result == TriggerState.Paused) // { // throw new Exception($"Trigger of '{jobType}' is paused."); // } var jobKey = jobType.GetJobKey(); var jobDataMap = new JobDataMap { { IS_FORCED, true } }; _scheduler.TriggerJob(jobKey, jobDataMap).Wait(); }
public static JobTypeEnum FromString(this JobTypeEnum jt, string val) { jt = (JobTypeEnum)Enum.Parse(typeof(JobTypeEnum), val); return(jt); }
public static string TranslateDesc(this JobTypeEnum jt) { return(TranslateExtension.GetString($"{jt.TranslateKey()}_DESC")); }
private static JobConfiguration <TJobData> LoadConfigurationForJob <TJobData>(JobTypeEnum jobType) where TJobData : IJobDataConfiguration <TJobData> { var jobConfiguration = new JobConfiguration <TJobData>(); var configuration = _configuration.GetSection($"{jobType}"); configuration.Bind(jobConfiguration); if (jobConfiguration.JobInfo == null) { throw new Exception($"JobInfo binding failed for type '{jobType}'."); } if (jobConfiguration.Scheduling == null) { throw new Exception($"Scheduling binding failed for type '{jobType}'."); } if (jobConfiguration.JobData == null) { throw new Exception($"JobData binding failed for type '{jobType}'."); } return(jobConfiguration); }
public static string TranslateKey(this JobTypeEnum jt) { return(string.Format("JOBTYPE_{0}", Enum.GetName(typeof(JobTypeEnum), jt))); }
public static JobDomain Create( string id, Guid categoryId, string title, JobTypeEnum jobTypeId, Guid creatorId, RoleType createdByRole, List <JobAddress> addressList, List <RelationGroupModel> relationGroupList, string parentId) { return(new JobDomain(id, categoryId, title, jobTypeId, creatorId, createdByRole, addressList, relationGroupList, parentId)); }
public static string TranslateVal(this JobTypeEnum jt) { return(TranslateExtension.GetString(jt.TranslateKey())); }
private void FillDayAssignData(IOperationalTaskModel viewModel, IDayAssign dayAssign, JobTypeEnum jobType) { viewModel.StatusId = dayAssign.StatusId; switch (jobType) { case JobTypeEnum.AdHock: FillAdHocDayAssignData(viewModel, dayAssign); break; case JobTypeEnum.Tenant: FillTenantDayAssignData(viewModel, dayAssign); break; case JobTypeEnum.Other: FillOtherTaskDayAssignData(viewModel, dayAssign); break; default: throw new NotImplementedException($"No such task type {jobType}"); } }
internal static void RestartJob(JobTypeEnum jobType) { if (_scheduler == null) { return; } // get job if (!_scheduledTriggers.ContainsKey(jobType)) { throw new Exception($"Job '{jobType}' is not scheduled."); } var trigger = _scheduledTriggers[jobType]; if (trigger == null) { throw new Exception($"Trigger for job '{jobType}' was not found."); } var jobKey = trigger.JobKey; if (jobKey == null) { throw new Exception($"Job key for job '{jobType}' was not found."); } var job = _scheduler.GetJobDetail(jobKey).Result; if (job == null) { throw new Exception($"JobDetail for job '{jobType}' was not found."); } var jt = job.JobType; // get job data type var jobData = job.JobDataMap[JOB_DATA_CONFIGURATION]; var jobDataType = jobData.GetType(); // load job configuration var loadConfigurationMethod = typeof(QuartzScheduler).GetMethod("LoadConfigurationForJob", BindingFlags.NonPublic | BindingFlags.Static); var genericMethod = loadConfigurationMethod.MakeGenericMethod(jobDataType); var jobConfiguration = genericMethod.Invoke(null, new object[] { jobType }); if (jobConfiguration == null) { throw new Exception($"Job configuration loading failed for job '{job.Key}'."); } // unschedule trigger and delete job _scheduler.UnscheduleJob(trigger.Key).Wait(); _scheduler.DeleteJob(jobKey).Wait(); if (_scheduledTriggers.Values.Contains(trigger)) { var scheduledTrigger = _scheduledTriggers.Single(i => i.Value.Key.Equals(trigger.Key)); _scheduledTriggers.Remove(scheduledTrigger.Key); } // register job var registerJobMethod = typeof(QuartzScheduler).GetMethod("RegisterJob", BindingFlags.NonPublic | BindingFlags.Static); genericMethod = registerJobMethod.MakeGenericMethod(jobDataType, jt); genericMethod.Invoke(null, null); // resume _scheduler.ResumeTrigger(trigger.Key).Wait(); _scheduler.ResumeJob(jobKey).Wait(); }
private JobType(JobTypeEnum jobTypeEnum) { Id = (int)jobTypeEnum; Name = jobTypeEnum.ToString(); }
private void FillJobData(IOperationalTaskModel viewModel, Job job, Guid departmentId, JobTypeEnum jobType) { switch (jobType) { case JobTypeEnum.AdHock: FillAdHocJobData(viewModel, job, departmentId); break; case JobTypeEnum.Tenant: FillTenantJobData(viewModel, job, departmentId); break; case JobTypeEnum.Other: FillOtherTaskJobData(viewModel, job, departmentId); break; default: throw new NotImplementedException($"No such task type {jobType}"); } }
public static string GetJobIdPrefix(this JobTypeEnum enumValue) { var attributevalue = enumValue.GetEnumAttribute <JobIdPrefixAttribute>(); return(attributevalue == null ? string.Empty : attributevalue.Value); }
public IEnumerable <ICancelingTemplateModel> GetCoordinatorByTaskType(JobTypeEnum taskType) { var result = cancelingTemplatesService.GetAllByTaskType(taskType, isCoordinatorReason: true); return(result); }