Пример #1
0
        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("批量更新经销商!");
            //}
        }
Пример #2
0
 static void Main(string[] args)
 {
     Global.Startup();
     TaskJob.Worker();
     TaskJob.Subscribe();
     Console.ReadLine();
 }
Пример #3
0
 private Task(EDataType dataType, TaskJob job)
 {
     Status = TaskStatus.InQueue;
     Info = new UploadInfo();
     Info.Job = job;
     Info.DataType = dataType;
     Info.UploadDestination = dataType;
 }
 private Task(EDataType dataType, TaskJob job)
 {
     Status                 = TaskStatus.InQueue;
     Info                   = new UploadInfo();
     Info.Job               = job;
     Info.DataType          = dataType;
     Info.UploadDestination = dataType;
 }
Пример #5
0
        public string CloseJob(JobModel jobModel)
        {
            ValidationErrors validationErrors = new ValidationErrors();

            Log.Write("CloseJob", jobModel.taskName, "关闭");
            TaskJob.UpdateState(ref validationErrors, jobModel.id, 3, "挂起");
            return("关闭获取Access_Token任务");
        }
Пример #6
0
        static void Main(string[] args)
        {
            Global.Startup();
            TaskJobBuss taskJobBuss = new TaskJobBuss();

            taskJobBuss.doWork("");
            TaskJob.Subscribe();
            Console.ReadLine();
        }
Пример #7
0
        public void Dojob()
        {
            TaskJob newJob = new TaskJob("我的任务1" + DateTime.Now,
                                         DateTime.Now.AddSeconds(60));

            lock (Global.jobs)
            {
                Global.jobs.Add(newJob);
            }
        }
Пример #8
0
        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
        }
Пример #9
0
 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));
        }
Пример #12
0
        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());
        }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }
Пример #15
0
        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!");
        }
Пример #16
0
        public Task OnStartedJob(TaskJob job)
        {
            Status = TaskExecutionStatus.Started;

            return(executorContext.OnStartedJob(job));
        }
Пример #17
0
    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
    }
Пример #18
0
        public Task OnDefferJob(TaskJob job)
        {
            Status = TaskExecutionStatus.Deffer;

            return(executorContext.OnDefferJob(job));
        }
Пример #19
0
        public Task OnTimeoutJob(TaskJob job)
        {
            Status = TaskExecutionStatus.Timeout;

            return(executorContext.OnTimeoutJob(job));
        }
Пример #20
0
        public Task OnErrorJob(TaskJob job, Exception exception)
        {
            Status = TaskExecutionStatus.Error;

            return(executorContext.OnErrorJob(job, exception));
        }
Пример #21
0
        public Task OnUnhandledError(TaskJob job, Exception exception)
        {
            Status = TaskExecutionStatus.UnhandledError;

            return(executorContext.OnUnhandledError(job, exception));
        }
Пример #22
0
        public ActionResult SendMail()
        {
            var task = new TaskJob();

            return(Content(task.SendMail()));
        }
Пример #23
0
        public Task OnSuccessJob(TaskJob job)
        {
            Status = TaskExecutionStatus.Success;

            return(executorContext.OnSuccessJob(job));
        }