public string RunJob(ref JobDataMap dataMap, string jobName, string id, string taskName) { //using (IWC_OfficalAccountsRepository m_Rep = new WC_OfficalAccountsRepository(new DBContainer())) //{ // IQueryable<WC_OfficalAccounts> queryable = m_Rep.GetList(); ValidationErrors validationErrors = new ValidationErrors(); // foreach (var entity in queryable) // { // if (!string.IsNullOrEmpty(entity.AppId) && !string.IsNullOrEmpty(entity.AppSecret)) // { // entity.AccessToken = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetToken(entity.AppId, entity.AppSecret).access_token; // entity.ModifyTime = ResultHelper.NowTime; // } // } // if (queryable.Count() > 0) // { TaskJob.UpdateState(ref validationErrors, jobName, 1, "成功"); // m_Rep.SaveChanges(); // } return("批量更新经销商!"); //} }
static void Main(string[] args) { Global.Startup(); TaskJob.Worker(); TaskJob.Subscribe(); Console.ReadLine(); }
private Task(EDataType dataType, TaskJob job) { Status = TaskStatus.InQueue; Info = new UploadInfo(); Info.Job = job; Info.DataType = dataType; Info.UploadDestination = dataType; }
public string CloseJob(JobModel jobModel) { ValidationErrors validationErrors = new ValidationErrors(); Log.Write("CloseJob", jobModel.taskName, "关闭"); TaskJob.UpdateState(ref validationErrors, jobModel.id, 3, "挂起"); return("关闭获取Access_Token任务"); }
static void Main(string[] args) { Global.Startup(); TaskJobBuss taskJobBuss = new TaskJobBuss(); taskJobBuss.doWork(""); TaskJob.Subscribe(); Console.ReadLine(); }
public void Dojob() { TaskJob newJob = new TaskJob("我的任务1" + DateTime.Now, DateTime.Now.AddSeconds(60)); lock (Global.jobs) { Global.jobs.Add(newJob); } }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new TaskJob() { aiUnits = aiUnits, commandBuffer = endFrameBarrier.CreateCommandBuffer() }; return(job.Schedule(aiUnits.Length, 1000, inputDeps));///TODO: fix inner loop batch count }
static void Main(string[] args) { if (DatabaseOperationWeb.TYPE == null) { DatabaseOperationWeb.TYPE = new DBManager(); } TaskJob.Worker(); TaskJob.Subscribe(); Console.ReadLine(); //TaskJobBuss taskJobBuss = new TaskJobBuss(); //taskJobBuss.HandleAccount(); }
public void SingleObjectQueueTest() { var t = new TaskJob(1, Priority.Normal); Assert.IsTrue(queue.IsEmpty()); queue.Enqueue(t, t.Priority); Assert.IsFalse(queue.IsEmpty()); Assert.IsTrue(queue.TryDequeue(out var res)); Assert.AreEqual(t, res); }
public async Task <HttpResponseMessage> updateTask(TaskJob task) { HttpResponseMessage res = new HttpResponseMessage(); try { _taskService.Update(task); res = Request.CreateResponse(HttpStatusCode.OK); } catch (Exception e) { res = Request.CreateResponse(e.Message); } return(await System.Threading.Tasks.Task.FromResult(res)); }
public async Task <bool> Handle(TaskCommand request, CancellationToken cancellationToken) { var task = await _taskJobRepository.GetAll(a => a.TaskName == request.TaskName).FirstOrDefaultAsync(); if (task == null) { var createTask = new TaskJob(Guid.NewGuid().ToString(), request.TaskGroup, request.TaskName, request.TaskCron, request.TaskDescp); await _taskJobRepository.AsyncAdd(createTask); } else { task.UpdateSchedule(request.TaskGroup, request.TaskName, request.TaskCron, request.TaskDescp); _taskJobRepository.Update(task); } return(await _taskJobRepository.UnitOfWork.SaveEntitiesAsync()); }
public async Task CantExecuteAfterPoolStop() { var list = new List <TaskJob>(100); foreach (var num in Enumerable.Range(1, 100)) { list.Add(new TaskJob(num, num > 10 ? num > 50 ? Priority.High : Priority.Normal : Priority.Low)); } foreach (var t in list) { Assert.IsTrue(await taskPool.Execute(t, t.Priority)); } taskPool.Stop(); var anotherTask = new TaskJob(777, Priority.High); Assert.IsFalse(await taskPool.Execute(anotherTask, anotherTask.Priority)); Assert.IsFalse(anotherTask.IsComplete); }
public async Task <TaskExecutionStatus> ExecuteTaskAsync(TCommand task, CancellationToken cancellationToken = default) { var taskMetadata = TaskMetadataManager.FindTaskMetadata <TCommand>(); await Executor.ConnectAsync(cancellationToken); var taskId = await Allocator.PushTaskAsync(task, cancellationToken); var tasks = await Allocator.WaitTasksAsync(Executor.ExecutorId, cancellationToken); var taskExecutionModel = tasks.Single(); var executorContext = new JobExecutorContextWrapper(Executor.ExecutorId, Executor); using (var job = new TaskJob(taskExecutionModel, new TaskHandlerMetadata(taskMetadata.TaskName, typeof(TaskHandler <TCommand>)), ServiceScope, executorContext)) { await job.Run(cancellationToken); } return(executorContext.Status); }
public string RunJob(ref JobDataMap dataMap, string jobName, string id, string taskName) { WC_OfficalAccountsRepository m_Rep = new WC_OfficalAccountsRepository(); IQueryable <WC_OfficalAccounts> queryable = m_Rep.FindList(); ValidationErrors validationErrors = new ValidationErrors(); foreach (var entity in queryable) { if (!string.IsNullOrEmpty(entity.AppId) && !string.IsNullOrEmpty(entity.AppSecret)) { entity.AccessToken = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetToken(entity.AppId, entity.AppSecret).access_token; entity.ModifyTime = ResultHelper.NowTime.ToString("yyyy-MM-dd HH:mm:ss"); } } if (queryable.Count() > 0) { TaskJob.UpdateState(ref validationErrors, jobName, 1, "成功"); m_Rep.SaveChanges(); } return("批量更新Access_Token!"); }
public Task OnStartedJob(TaskJob job) { Status = TaskExecutionStatus.Started; return(executorContext.OnStartedJob(job)); }
JobHandle ScheduleTaskJob() { TaskJob job = new TaskJob(); return(job.Schedule()); // This tells the job system to schedule this job to be completed by available thread when possible }
public Task OnDefferJob(TaskJob job) { Status = TaskExecutionStatus.Deffer; return(executorContext.OnDefferJob(job)); }
public Task OnTimeoutJob(TaskJob job) { Status = TaskExecutionStatus.Timeout; return(executorContext.OnTimeoutJob(job)); }
public Task OnErrorJob(TaskJob job, Exception exception) { Status = TaskExecutionStatus.Error; return(executorContext.OnErrorJob(job, exception)); }
public Task OnUnhandledError(TaskJob job, Exception exception) { Status = TaskExecutionStatus.UnhandledError; return(executorContext.OnUnhandledError(job, exception)); }
public ActionResult SendMail() { var task = new TaskJob(); return(Content(task.SendMail())); }
public Task OnSuccessJob(TaskJob job) { Status = TaskExecutionStatus.Success; return(executorContext.OnSuccessJob(job)); }