The task data.
예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Task"/> class.
 /// </summary>
 /// <param name="action">
 /// The action.
 /// </param>
 /// <param name="taskData">
 /// The task data.
 /// </param>
 /// <param name="result">
 /// The result.
 /// </param>
 /// <param name="controllerName">
 /// The controller name.
 /// </param>
 /// <param name="thread">
 /// The thread.
 /// </param>
 private Task(Func<Dictionary<string, object>> action, TaskData taskData, Dictionary<string, object> result, string controllerName, Thread thread)
 {
     Action = action;
     TaskData = taskData.Clone();
     Result = result;
     ControllerName = controllerName;
     Thread = thread;
 }
        /// <summary>
        /// Send web socket message to all clients.
        /// </summary>
        /// <param name="taskEvent">
        /// Task event.
        /// </param>
        /// <param name="task">
        /// Task itself.
        /// </param>
        public static void Send(TaskEvent taskEvent, TaskData task)
        {
            var hubContext = GlobalHost.ConnectionManager.GetHubContext<TasksManagerHub>();

            lock (task)
            {
                var result = new
                {
                    task.Id,
                    task.DisplayName,
                    Created = task.Created.ToString(OutputFormats.DateTimeFormat),
                    Started = task.Started == null ? string.Empty : ((DateTimeOffset)task.Started).ToString(OutputFormats.DateTimeFormat),
                    Completed = task.Completed == null ? string.Empty : ((DateTimeOffset)task.Completed).ToString(OutputFormats.DateTimeFormat),
                    ExecutionTime = task.ExecutionTime == null ? string.Empty : ((TimeSpan)task.ExecutionTime).ToString(OutputFormats.TimeFormat),
                    TaskState = task.TaskState.ToString(),
                    TaskStateName = task.TaskState.GetDisplayValue(),
                    task.UserId,
                    task.UserName
                };

                hubContext.Clients.All.TaskEvent(taskEvent.ToString(), result);
            }
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Task"/> class.
 /// </summary>
 /// <param name="id">
 /// The id.
 /// </param>
 /// <param name="action">
 /// The action.
 /// </param>
 /// <param name="userId">
 /// Creator id.
 /// </param>
 /// <param name="taskType">
 /// The task Type.
 /// </param>
 public Task(long id, Func <Dictionary <string, string> > action, int userId, TaskType taskType)
 {
     Action   = action;
     TaskData = new TaskData(id, userId, taskType);
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Task"/> class.
 /// </summary>
 /// <param name="id">
 /// The id.
 /// </param>
 /// <param name="action">
 /// The action.
 /// </param>
 /// <param name="controllerName">
 /// The controller name.
 /// </param>
 /// <param name="displayName">
 /// The display name.
 /// </param>
 /// <param name="userId">
 /// Creator id.
 /// </param>
 public Task(int id, Func<Dictionary<string, object>> action, string controllerName, string displayName, string userId)
 {
     Action = action;
     ControllerName = controllerName;
     TaskData = new TaskData(id, displayName, userId);
 }