public override void SetPredecessor(JobTask task, bool validateDependency = true) { base.SetPredecessor(task, validateDependency); if (validateDependency) { var type = task.Result.ResultType; //FIXME: All of these has to be cached and refactored try { var fromData = type.GetProperty("From"); if (fromData.PropertyType != typeof(DefaultAddress)) throw new InvalidCastException("Type Verification From Field Failed"); var toData = type.GetProperty("To"); if (toData.PropertyType != typeof(DefaultAddress)) throw new InvalidCastException("Type Verification To Field Failed"); var ride = type.GetProperty("Asset"); if (ride.PropertyType != typeof(AssetModel)) throw new InvalidCastException("Type Verification Asset field failed"); IsDependencySatisfied = true; } catch (Exception ex) { throw new JobTaskDependencyException("Error occured on dependency assignment", this, ex); } } Predecessor.JobTaskCompleted += Predecessor_JobTaskCompleted; }
public void Can_insert_update_and_delete_when_table_splitting() { ExtendedSqlAzureExecutionStrategy.ExecuteNew( () => { using (new TransactionScope()) { using (var context = CreateContext()) { var jobTaskState = new JobTaskState { State = "Foo" }; var jobTask = new JobTask { Description = "Foo", State = jobTaskState }; Assert.Equal(0, context.Set<JobTask>().Count()); Assert.Equal(0, context.Set<JobTaskState>().Count()); context.Set<JobTask>().Add(jobTask); context.SaveChanges(); Assert.Equal(1, context.Set<JobTask>().Count()); Assert.Equal(1, context.Set<JobTaskState>().Count()); jobTask.Description = "Bar"; context.SaveChanges(); context.Set<JobTaskState>().Remove(jobTaskState); context.SaveChanges(); Assert.Equal(0, context.Set<JobTask>().Count()); Assert.Equal(0, context.Set<JobTaskState>().Count()); } } }); }
public override void SetPredecessor(JobTask task, bool validateDependency = true) { base.SetPredecessor(task, validateDependency); if (validateDependency) { var type = task.Result.ResultType; //FIXME: All of these has to be cached and refactored try { VerifyPropertyTypesFromResult(type); IsDependencySatisfied = true; } catch (Exception ex) { throw new JobTaskDependencyException("Error occured on dependency assignment", this, ex); } } Predecessor.JobTaskCompleted += Predecessor_JobTaskCompleted; }
private void Predecessor_JobTaskCompleted(JobTask sender, JobTaskResult jobTaskResult) { if (this.State == JobTaskState.PENDING) { this.State = JobTaskState.IN_PROGRESS; UpdateTask(); } try { var type = jobTaskResult.ResultType; VerifyPropertyTypesFromResult(type); var asset = type.GetProperty("Asset"); Asset = asset.GetValue(jobTaskResult, null) as AssetModel; } catch (Exception) { throw; } }
private void Predecessor_JobTaskCompleted(JobTask sender, JobTaskResult jobTaskResult) { if (this.State == JobTaskState.PENDING) { this.State = JobTaskState.IN_PROGRESS; UpdateTask(); } try { var type = jobTaskResult.ResultType; var ride = type.GetProperty("Asset"); if (ride.PropertyType != typeof(AssetModel)) throw new InvalidCastException("Type Verification Asset field failed"); Asset = ride.GetValue(jobTaskResult, null) as AssetModel; } catch (Exception) { throw; } }
public async Task <bool> ResolveAssetRef(JsonPatchDocument <JobTask> taskPatch, JobTask jobTask) { var assetRefReplaceOp = taskPatch.Operations.FirstOrDefault(x => x.op == "replace" && x.path == "/AssetRef"); if (!(assetRefReplaceOp?.value is string)) { return(false); } // INFO: Now we need to actually fetch the asset and get shit done if (jobTask.State == JobTaskState.COMPLETED) { throw new InvalidOperationException($"Updating AssetRef of JobTask {jobTask.id} is not suppported as the task is in {jobTask.State} state"); } var asset = await accountManager.FindAsByIdAsync <Asset>(assetRefReplaceOp.value.ToString()); if (asset == null) { return(false); } var assetModel = new AssetModel(asset); assetRefReplaceOp.path = "/Asset"; assetRefReplaceOp.value = assetModel; return(true); }
public Task <int> SaveJobTaskAsync(JobTask task) { return(database.InsertAsync(task)); }
public static void AdjustStep(IJob job, JobTask ji, IExtend ext) { // 不许动态调节步进 if (job.StepRate == 0 || job.MinStep == job.MaxStep) { return; } //// 向前调节步进,避免多线程时间错乱 //var dt = ext["Step_Last"].ToDateTime(); //if (dt.Year > 2000 && ji.Start <= dt) return; //ext["Step_Last"] = ji.Start; // 新步进 var st = 0L; var near = false; var adjust = false; // 计算停止线,需要注意偏移量 var end = job.End; if (end.Year <= 2000 || end > DateTime.Now) { end = DateTime.Now.AddSeconds(-job.Offset); } // 距离目标较近时步进减半 if (ji.End.AddSeconds(ji.Step) > end) { st = ji.Step; while (st > 0 && ji.End.AddSeconds(st) > end) { st /= 2; } near = true; } else { if (ji.Total > 0) { // 逼近批大小 st = (Int64)ji.BatchSize * ji.Step / ji.Total; adjust = true; } // 踩空逻辑 else { // 距离目标较远时加大步进 //st = job.MaxStep; st = (Int32)(ji.Step * (1 + job.StepRate / 100.0)); } // 步进率 var jstep = ji.Step; var rate = jstep == 0 ? 0 : (st - jstep) * 100.0 / jstep; // 变化不能超过比率 if (Math.Abs(rate) > job.StepRate) { rate = job.StepRate; if (st < jstep) { rate = -rate; } st = (Int32)(jstep + rate * jstep / 100); } } // 限制最大最小步进 if (st < job.MinStep) { st = job.MinStep; } else if (st > job.MaxStep) { st = job.MaxStep; } if (st == job.Step) { return; } // 踩空时要求步进没有改变过 if (near || adjust || job.Step == ji.Step) { job.Step = (Int32)st; } }
public async Task<bool> ResolveAssetRef(JsonPatchDocument<JobTask> taskPatch, JobTask jobTask) { var assetRefReplaceOp = taskPatch.Operations.FirstOrDefault(x => x.op == "replace" && x.path == "/AssetRef"); if (!(assetRefReplaceOp?.value is string)) return false; // INFO: Now we need to actually fetch the asset and get shit done if (jobTask.State == JobTaskState.COMPLETED) throw new InvalidOperationException($"Updating AssetRef of JobTask {jobTask.id} is not suppported as the task is in {jobTask.State} state"); var asset = await _accountManager.FindAsByIdAsync<Data.Entity.Identity.Asset>(assetRefReplaceOp.value.ToString()); if (asset == null) return false; var assetModel = new AssetModel(asset); assetRefReplaceOp.path = "/Asset"; assetRefReplaceOp.value = assetModel; return true; }
private void SetProperJobState(JobTask jobTask) { if (jobTask.State >= JobTaskState.IN_PROGRESS && jobTask.State < JobTaskState.COMPLETED && state != JobState.IN_PROGRESS) { state = JobState.IN_PROGRESS; this.InitiationTime = this.InitiationTime ?? DateTime.UtcNow; } else if (jobTask.State == JobTaskState.CANCELLED) state = JobState.CANCELLED; if (this.tasks.All(x => x.State == JobTaskState.COMPLETED)) { this.CompletionTime = DateTime.UtcNow; this.state = JobState.COMPLETED; } }
internal async Task<UpdateResult> UpdateJobTask(string jobId, int taskIndex, JobTask task) { task.ModifiedTime = DateTime.Now; var Filter = Builders<Job>.Filter.Where(x => x.Id == jobId); var UpdateDefinition = Builders<Job>.Update.Set(x => x.Tasks[taskIndex], task); var result = await _context.Jobs.UpdateOneAsync(Filter, UpdateDefinition); return result; }
public void TaskProgress(Job job, JobTask task, Exception exception, string message, params object[] args) { var rowKey = String.Format("{0}-{1}", DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks, Guid.NewGuid()); // Write event. _jobInstanceEventsWriter.Write(job.RunId.ToString(), rowKey, new Dictionary<string, EntityProperty>() { { "Task", new EntityProperty(task.GetType().Name) }, { "Message", new EntityProperty(String.Format(message, args)) }, { "ErrorMessage", new EntityProperty(exception != null ? exception.Message : null) }, { "ErrorType", new EntityProperty(exception != null ? exception.GetType().ToString() : null) }, { "ErrorStackTrace", new EntityProperty(exception != null ? exception.StackTrace : null) }, { "ErrorObject", new EntityProperty(exception != null ? JsonConvert.SerializeObject(exception) : String.Empty) } }); }
public void TaskComplete(Job job, JobTask task, DateTime startTime, TimeSpan duration) { TaskProgress(job, task, null, "Completed task '{0}' in {1}.", task.GetType().Name, duration); }
public void TaskRunning(Job job, JobTask task, DateTime startTime) { TaskProgress(job, task, null, "Started task '{0}' at {1}.", task.GetType().Name, startTime); }
public void TaskProgress(Job job, JobTask task, string message, params object[] args) { TaskProgress(job, task, null, message, args); }
private void RunSingleTask(JobTask task) { _logger.Trace(() => $"Starting task '{task.Id}', dependencies: {task.DependenciesInfo()}."); task.Action(); }
public void Footlocker() // will make a other cs file for each site { string path = Utils.GetPath("proxy.txt"); if (new FileInfo(path).Length == 0) { Console.WriteLine("running localhost"); } else { Console.WriteLine("running proxy"); } Console.WriteLine("my proxy" + proxylist.Count); int quantity = 0; if (SizeruncheckBox.IsChecked == false) // easy case { /// <summary> /// normal case no use all profile and use range box /// </summary> /// bool t = false; if (Localhost.IsChecked == true || (new FileInfo(path).Length == 0)) { t = true; } Random rand = new Random(); if (int.TryParse(Quantity.Text, out quantity) && quantity > 0 && UseallcheckBox.IsChecked == false) // easy case { for (var x = 1; x <= quantity; x++) { int nextVal = rand.Next(proxylist.Count); JobTask playerList = new JobTask(); playerList.ID = MyList.Count.ToString(); playerList.Product = url.Text; playerList.Site = Sitelist.Text; playerList.Status = ""; if (t) { playerList.Proxy = "Localhost"; } else { playerList.Proxy = proxylist[nextVal]; } playerList.Billing = Profile.Text; playerList.Size = size.Text; MyList.Add(playerList); savelist.Add(MyList.Count); } dataGridProxies.ItemsSource = MyList; } /// <summary> /// case with use all profile not use range box /// </summary> else if (quantity > 0 && UseallcheckBox.IsChecked == true) { int Profilesize = Profile.Items.Count; for (var y = 0; y <= Profilesize - 1; y++) { for (var x = 1; x <= quantity; x++) { int nextVal = rand.Next(proxylist.Count); JobTask playerList = new JobTask(); playerList.ID = MyList.Count.ToString(); playerList.Product = url.Text; playerList.Site = Sitelist.Text; playerList.Status = ""; if (t) { playerList.Proxy = "Localhost"; } else { playerList.Proxy = proxylist[nextVal]; } playerList.Billing = Profile.Items[y].ToString(); playerList.Size = size.Text; MyList.Add(playerList); savelist.Add(MyList.Count); } } } } else if (SizeruncheckBox.IsChecked == true) { /// <summary> /// case not use all profile use range box /// </summary> /// bool t = false; if (Localhost.IsChecked == true || (new FileInfo(path).Length == 0)) { t = true; } Random rand = new Random(); if (quantity > 0 && UseallcheckBox.IsChecked == false) // hard case 1 { // int count = 1; Double currentsize = Double.Parse(startsize.Text); while (currentsize - 0.5 != Double.Parse(endsize.Text)) { for (var x = 1; x <= quantity; x++) { int nextVal = rand.Next(proxylist.Count); JobTask playerList = new JobTask(); playerList.ID = MyList.Count.ToString(); playerList.Product = url.Text; playerList.Site = Sitelist.Text; playerList.Status = ""; if (t) { playerList.Proxy = "Localhost"; } else { playerList.Proxy = proxylist[nextVal]; } playerList.Billing = Profile.Text; playerList.Size = currentsize.ToString(); MyList.Add(playerList); savelist.Add(MyList.Count); } currentsize = currentsize + 0.5; } //Debug.Info(count.ToString()); dataGridProxies.ItemsSource = MyList; } /// <summary> /// case use all profile use range box /// </summary> /// else if (quantity > 0 && UseallcheckBox.IsChecked == true) { int Profilesize = Profile.Items.Count; for (var y = 0; y <= Profilesize - 1; y++) { Double currentsize = Double.Parse(startsize.Text); while (currentsize - 0.5 != Double.Parse(endsize.Text)) { for (var x = 1; x <= quantity; x++) { int nextVal = rand.Next(proxylist.Count); JobTask playerList = new JobTask(); playerList.ID = MyList.Count.ToString(); playerList.Product = url.Text; playerList.Site = Sitelist.Text; playerList.Status = ""; if (t) { playerList.Proxy = "Localhost"; } else { playerList.Proxy = proxylist[nextVal]; } playerList.Billing = Profile.Items[y].ToString(); playerList.Size = currentsize.ToString(); MyList.Add(playerList); savelist.Add(MyList.Count); } currentsize = currentsize + 0.5; } } } } // Only run this code if Quantity.Text is a valid parse. //https://stackoverflow.com/questions/7198005/c-sharp-httpwebrequest-website-sign-in set up CookieContainer }
public WebTask(Product product, ref ObservableCollection <JobTask> myList, int index, int current, ref DataGrid dataGridProxies, ref JobTask item) { TheProduct = product; MyList = myList; this.index = index; this.current = current; this.dataGridProxies = dataGridProxies; this.item = item; }
public JobSucceededEvent(JobTask job) { Job = job; }
public void TaskFailed(Job job, JobTask task, DateTime startTime, Exception exception) { TaskProgress(job, task, exception, "Task '{0}' failed: {1}.", task.GetType().Name, exception.Message); }
// GET: ContractorController/Edit/5 public async Task <ActionResult> EditJobTask(int jobTaskId) { JobTask taskToEdit = await _repo.JobTask.GetJobTaskAsync(jobTaskId); return(View(taskToEdit)); }
public JobTaskDependencyException(string message, JobTask jobTask, Exception innerException) : base(message, innerException) { JobTask = jobTask; }
// GET: ContractorController/Delete/5 public async Task <ActionResult> Delete(int taskId) { JobTask jobToDelete = await _repo.JobTask.GetJobTaskAsync(taskId); return(View(jobToDelete)); }
public void SetTaskDetails(JobTask task) { _backup = task.CreateBackup(); _task = task; DataContext = _task; }
public Task <int> DeleteJobTaskAsync(JobTask task) { return(database.DeleteAsync(task)); }
public override void SetPredecessor(JobTask task, bool validateDependency = true) { base.SetPredecessor(task, validateDependency); }
public JobEnqueuedEvent(JobTask job) { Job = job; }
public void initFromTask(JobTask task) { }
JobTaskResult IJobTaskWorker.WorkOn(JobTask task) { return(this.WorkOn(( TTask )task)); }
public Task <int> UpdateJobTaskAsync(JobTask task) { return(database.UpdateAsync(task)); }
public static JobTask CreateJobTask(string jobTaskId) { JobTask jobTask = new JobTask(); jobTask.JobTaskId = jobTaskId; return jobTask; }
private void _terminalTask_JobTaskCompleted(JobTask sender, JobTaskResult result) { CompleteJob(); }
public ApiStatus(JobTask jobTask) { Status = jobTask.Status.ToString(); Timestamp = jobTask.UpdatedAt?.ToString("O") ?? jobTask.CreatedAt?.ToString("O"); }
public virtual void Run(JobTask task) { this.Run(( TTask )task); }
public static JobTaskContract Map(JobTask source) { return(Mapper.Map <JobTaskContract>(source)); }
public void initFromTask(JobTask task) { // Timeout TextBox_timeout.Text = task.timeout.ToString(); }
public Boolean Report(TaskResult task) { if (task == null || task.ID == 0) { throw new InvalidOperationException("无效操作 TaskID=" + task?.ID); } // 判断是否有权 var app = _App; var jt = JobTask.FindByID(task.ID); if (jt == null) { throw new InvalidOperationException($"找不到任务[{task.ID}]"); } var job = Job.FindByID(jt.JobID); if (job == null || job.AppID != app.ID) { XTrace.WriteLine(task.ToJson()); throw new InvalidOperationException($"应用[{app}]无权操作作业[{job}#{jt}]"); } // 只有部分字段允许客户端修改 if (task.Status > 0) { jt.Status = task.Status; } jt.Speed = task.Speed; jt.Total = task.Total; jt.Success = task.Success; jt.Cost = task.Cost; jt.Key = task.Key; jt.Message = task.Message; // 已终结的作业,汇总统计 if (task.Status == JobStatus.完成 || task.Status == JobStatus.错误) { jt.Times++; SetJobFinish(job, jt); // 记录状态 UpdateOnline(app, jt, _Net); } if (task.Status == JobStatus.错误) { SetJobError(job, jt); jt.Error++; //ji.Message = err.Message; // 出错时判断如果超过最大错误数,则停止作业 CheckMaxError(app, job); } // 从创建到完成的全部耗时 var ts = DateTime.Now - jt.CreateTime; jt.FullCost = (Int32)ts.TotalSeconds; jt.SaveAsync(); //ji.Save(); return(true); }
private void buttonCreateJob_Click(object sender, RoutedEventArgs e) { // If a trigger is defined if (trigger == null && !jobNowCheckbox.IsChecked.Value) { MessageBox.Show("Error : An execution trigger must be provided to the job", "Job creation error"); return; } // Get the selected computers if (selectedComputersGrid.SelectedItems.Count <= 0) { MessageBox.Show("Error : No computer selected. At least one computer should be selected", "Job creation error"); return; } var selectedComputers = new List <ComputerInfo>(); foreach (Computer c in selectedComputersGrid.SelectedItems) { selectedComputers.Add(App.computerInfoStore.getComputerInfoByName(c.nameLong)); } // Get the tasks var tasks = new List <JobTask>(); foreach (dynamic element in tasksPanel.Children) { JobTask jobTask = element.createTask(); if (jobTask == null) { return; // Error during jobtask creation } tasks.Add(jobTask); } if (tasks.Count <= 0) { MessageBox.Show("Error : No task defined. At least one taks should be defined", "Job creation error"); return; } // OK, create the job var job = new Scheduling.Job { creationDateTime = DateTime.Now, cyclic = jobCyclicCheckbox.IsChecked.Value, executeNow = trigger == null, triggerDescription = trigger != null?trigger.ToString() : "As soon as possible", computers = selectedComputers, status = JobStatus.SCHEDULED, tasks = tasks, name = textBox_TaskName.Text }; // Insert into the job store App.jobStore.insertJob(job); // Create a windows task if (jobNowCheckbox.IsChecked.Value) { job.schedule(); } else { job.schedule(trigger); } parent.updateScheduledJobs(); reset(); }
/// <summary> /// 尝试更新任务状态 /// </summary> /// <returns><c>true</c>, if update task status was tryed, <c>false</c> otherwise.</returns> /// <param name="task">Task.</param> /// <param name="status">Status.</param> /// <param name="errCode">错误代码:0无错误 1不能设置为这个状态 2无需重复设置状态 3作业或任务不存在</param> /// <param name="latestJob">Latest job.</param> /// <param name="cancellationToken">Cancellation token.</param> public bool TryUpdateTaskStatus(JobTask task, EnumTaskStatus status, out int errCode, out JobBase latestJob, CancellationToken cancellationToken = default(CancellationToken)) { errCode = 0; latestJob = null; cancellationToken.ThrowIfCancellationRequested(); var jobRecordKey = GetJobRecordFullKey(task.Job.Cluster.Name, task.Job.Name, task.Job.Id); KVPair jobRecordKV; int updateIndex = 0; do { updateIndex++; Log.LogWriter.Write(string.Format("UpdateTaskStatus Execute Times: {0},{1}", jobRecordKey + ":" + task.Id, updateIndex), Log.LogLevel.Debug); if (updateIndex > 1) { Thread.Sleep(200); } jobRecordKV = ConsulKV.Get(jobRecordKey, cancellationToken); if (jobRecordKV == null) { errCode = 3; Log.LogWriter.Write(string.Format("the job missing: {0}", jobRecordKey), Log.LogLevel.Error); return(false); } var jobRecordJson = Encoding.UTF8.GetString(jobRecordKV.Value); Log.LogWriter.Write("UpdateTaskStatus Get Value[" + jobRecordKV.ModifyIndex + "]" + jobRecordJson, Log.LogLevel.Trace); var jobRecord = JobBase.Deserialize(jobRecordJson, task.Job.Cluster); jobRecord.ModifyIndex = jobRecordKV.ModifyIndex; // 从作业任务计划中查找出任务:Synced和SyncFailed是Manager更改的状态,其它情况下是任务所属的Worker来更改 var consulTask = jobRecord.TaskPlan.Where(d => d.Key == task.Job.Cluster.CurrentMember.Id).SelectMany(d => d.Value.Where(t => t.Id == task.Id)).FirstOrDefault(); if (status == EnumTaskStatus.Synced || status == EnumTaskStatus.SyncFailed) { consulTask = jobRecord.TaskPlan.SelectMany(d => d.Value.Where(t => t.Id == task.Id)).FirstOrDefault(); } if (consulTask == null) { errCode = 3; Log.LogWriter.Write(string.Format("the job task missing: {0}", jobRecordKey), Log.LogLevel.Error); return(false); } // 取消状态只能更新为 已取消或者取消失败 if (consulTask.Status == EnumTaskStatus.Canceling && status != EnumTaskStatus.Canceled && status != EnumTaskStatus.CancelFailed) { LogWriter.Write(string.Format("{0} can not change to {1}", jobRecord.Status, status)); errCode = 1; return(false); } if ((consulTask.Status == EnumTaskStatus.Completed || consulTask.Status == EnumTaskStatus.Synced) && status == EnumTaskStatus.Executing) { LogWriter.Write(string.Format("{0} can not change to {1}", jobRecord.Status, status)); errCode = 1; return(false); } if (status == EnumTaskStatus.Executing) { consulTask.StartTime = DateTime.Now; } if (status == EnumTaskStatus.Completed) { consulTask.FinishedTime = DateTime.Now; } consulTask.Status = status; jobRecord.ModifyIndex = jobRecordKV.ModifyIndex; latestJob = jobRecord; jobRecordJson = JsonConvert.SerializeObject(jobRecord); Log.LogWriter.Write("UpdateTaskStatus CAS Value[" + jobRecordKV.ModifyIndex + "]" + jobRecordJson, Log.LogLevel.Trace); jobRecordKV.Value = Encoding.UTF8.GetBytes(jobRecordJson); } while (!ConsulKV.CAS(jobRecordKV, cancellationToken)); return(true); }
public async Task<UpdateResult> UpdateJobTask(string jobId, int taskIndex, JobTask task) { return await store.UpdateJobTask(jobId, taskIndex, task); }
public void AddTask(JobTask jtask) { if (this.Tasks == null) Tasks = new List<JobTask>(); this.Tasks.Add(jtask); jtask.AssetUpdated += Jtask_AssetUpdated; }
public void Update(int taskId, string name) { JobTask task = db.JobTasks.Where(t => t.Id == taskId).FirstOrDefault(); task.Name = name; }
public void AddJob(JobTask task) { if (task == null) throw new ArgumentNullException("task"); lock (lockObj) { bool wasRunning = this.threadIsRunning || this.actions.Count > 0; this.totalWork += task.cost; this.actions.Enqueue(task); if (!wasRunning) loadSolutionProjects.RaiseThreadStarted(); } }
public Boolean Report(TaskModel task) { if (task == null || task.ID == 0) { throw new InvalidOperationException("无效操作 TaskID=" + task?.ID); } // 判断是否有权 var app = Session["App"] as App; var jt = JobTask.FindByID(task.ID); if (jt == null) { throw new InvalidOperationException($"找不到任务[{task.ID}]"); } var job = Job.FindByID(jt.JobID); if (job == null || job.AppID != app.ID) { XTrace.WriteLine(task.ToJson()); throw new InvalidOperationException($"应用[{app}]无权操作作业[{job}#{jt}]"); } // 只有部分字段允许客户端修改 if (task.Status > 0) { jt.Status = task.Status; } jt.Speed = task.Speed; jt.Total = task.Total; jt.Success = task.Success; jt.Cost = task.Cost; jt.Key = task.Key; jt.Message = task.Message; // 动态调整步进 if (task.Status == JobStatus.完成) { AdjustStep(job, jt, Session as IExtend); //// 更新积压数 //UpdateLatency(job, ji); } // 已终结的作业,汇总统计 if (task.Status == JobStatus.完成 || task.Status == JobStatus.错误) { jt.Times++; SetJobFinish(job, jt); // 记录状态 UpdateOnline(app, jt, Session as INetSession); } if (task.Status == JobStatus.错误) { var ps = ControllerContext.Current.Parameters; SetJobError(job, jt, ps); jt.Error++; //ji.Message = err.Message; // 出错时判断如果超过最大错误数,则停止作业 CheckMaxError(app, job); } // 从创建到完成的全部耗时 var ts = DateTime.Now - jt.CreateTime; jt.FullCost = (Int32)ts.TotalSeconds; jt.SaveAsync(); //ji.Save(); return(true); }
public void AddJob(JobTask task) { if (task == null) throw new ArgumentNullException("task"); lock (lockObj) { this.totalWork += task.cost; this.actions.Enqueue(task); } }