/// <summary> /// 获取任务队列路径 /// </summary> /// <param name="taskQueue"></param> /// <returns></returns> public static string GetTaskQueueFileFullpath(TaskQueueType taskQueue) { string fullpath = ""; switch (taskQueue) { case TaskQueueType.Completed: fullpath = Path.Combine(AppPath.App_Root, "Completed_TaskQueue.dat"); break; case TaskQueueType.Processing: fullpath = Path.Combine(AppPath.App_Root, "Processing_TaskQueue.dat"); break; case TaskQueueType.UserManual: fullpath = Path.Combine(AppPath.App_Root, "UserManual_TaskQueue.dat"); break; case TaskQueueType.Error: fullpath = Path.Combine(AppPath.App_Root, "Error_TaskQueue.dat"); break; default: throw new ArgumentNullException($"获取任务队列路径失败,taskQueue参数为空"); } return(fullpath); }
public static TaskQueue Create(TaskQueueType type) { switch (type) { case TaskQueueType.Sequential: return(new SequentialQueue()); case TaskQueueType.Conditional: return(new ConditionalQueue()); default: throw new NotImplementedException(); } }
public void Add(long userId, Guid moduleId, TaskQueueType type, DateTime executionTime, int executionTimes, object parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } var parameterString = JsonConvert.SerializeObject(parameter); var model = new TaskQueue { ModuleId = moduleId, UserId = userId, Parameter = parameterString, Status = QueueStatus.Pending, CreateTime = DateTime.Now, HandleTime = DateTime.Now, ExecutionTime = executionTime, Type = type, MaxExecutionTimes = executionTimes }; Repository <ITaskQueueRepository>().AddSingle(model); }
/// <summary> /// 队列中删除队列 /// </summary> /// <param name="queue"></param> /// <param name="t8Task"></param> /// <returns></returns> public static bool RemoveTaskFromQueue(ConcurrentDictionary <string, T8TaskEntity> queue, T8TaskEntity t8Task, TaskQueueType taskQueue) { if (queue == null) { return(false); } T8TaskEntity tempT8Task; if (queue.TryRemove(t8Task.GenerateTaskQueueKey, out tempT8Task)) { string taskQueueFullpath = Common.GetTaskQueueFileFullpath(taskQueue); bool isAdd = SerializableHelper <T8TaskEntity> .BinarySerializeFile(taskQueueFullpath, queue.Values.ToList()); if (!isAdd) { queue.TryRemove(t8Task.GenerateTaskQueueKey, out tempT8Task); return(false); } } return(true); }
/// <summary> /// Returns information about pollers (AKA workers) that have communicated /// with the Temporal cluster in the last few minutes. /// </summary> /// <param name="taskQueue">Identifies the task queue.</param> /// <param name="taskQueueType"> /// Indicates whether to return information for decision (AKA workflow pollers) /// or activity pollers. /// </param> /// <param name="namespace">Optionally specifies the Temporal namespace.</param> /// <returns>The <see cref="TaskQueueDescription"/> for the pollers.</returns> public async Task <TaskQueueDescription> DescribeQueueListAsync(string taskQueue, TaskQueueType taskQueueType, string @namespace = null) { await SyncContext.Clear; Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(taskQueue), nameof(taskQueue)); EnsureNotDisposed(); @namespace = ResolveNamespace(@namespace); var reply = (DescribeTaskQueueReply) await CallProxyAsync( new DescribeTaskQueueRequest() { Name = taskQueue, TaskQueueType = taskQueueType, Namespace = @namespace, }); reply.ThrowOnError(); return(reply.Result); }