Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Class Task

A task assignable to users in the system

Inheritance
System.Object
Task
Implements
System.Runtime.Serialization.ISerializable
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Personalization
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
[Obsolete("The old workflow system have been removed as of CMS 9")]
public class Task : ISerializable

Constructors

Task()

Initializes a new instance of the Task class.

Declaration
public Task()

Task(Int32)

Initializes a new instance of the Task class.

Declaration
public Task(int taskID)
Parameters
Type Name Description
System.Int32 taskID

The task ID.

Task(SerializationInfo, StreamingContext)

Initializes a new instance of the Task class with serialized data.

Declaration
protected Task(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
System.Runtime.Serialization.SerializationInfo info

The object that holds the serialized object data.

System.Runtime.Serialization.StreamingContext context

The contextual information about the source or destination.

Task(Type)

Initializes a new instance of the Task class.

Declaration
public Task(Type handler)
Parameters
Type Name Description
System.Type handler

The handler.

Properties

Activity

Comments made by the user that has been assigned to the task

Declaration
public SimpleActivityLog Activity { get; set; }
Property Value
Type Description
SimpleActivityLog

AssignedIsRole

Gets or sets a value indicating whether this task is assigned to a role or a user.

Declaration
public bool AssignedIsRole { get; set; }
Property Value
Type Description
System.Boolean

true if the task is assigned to a role; otherwise, false.

AssignedTo

Security identifier for user or group that has been assigned to this task

Declaration
public string AssignedTo { get; set; }
Property Value
Type Description
System.String

Changed

The date when task was changed

Declaration
public DateTime Changed { get; }
Property Value
Type Description
System.DateTime

Created

The date when task was created

Declaration
public DateTime Created { get; }
Property Value
Type Description
System.DateTime

Description

Full description containing the nature of the task

Declaration
public string Description { get; set; }
Property Value
Type Description
System.String

DueDate

The date when task must be finished

Declaration
public DateTime DueDate { get; set; }
Property Value
Type Description
System.DateTime

EventActivityName

If task is created through workflow activity CreateTask then it is possible to associate task with a specific event activity.

Declaration
public string EventActivityName { get; set; }
Property Value
Type Description
System.String

LanguageBranchRepository

Gets or sets the language branch repository that should be used by the current instance.

Declaration
public Injected<ILanguageBranchRepository> LanguageBranchRepository { get; set; }
Property Value
Type Description
Injected<ILanguageBranchRepository>

LocalizationService

Gets or sets the localization service used by the current instance.

Declaration
public LocalizationService LocalizationService { get; set; }
Property Value
Type Description
LocalizationService

Owner

Security identifier for user that created this task or is responsible

Declaration
public string Owner { get; set; }
Property Value
Type Description
System.String

PlugInID

The identifier for the plugin that handles this task

Declaration
public int PlugInID { get; set; }
Property Value
Type Description
System.Int32

PreviousStatus

Previous status of task

Declaration
public TaskStatus PreviousStatus { get; }
Property Value
Type Description
TaskStatus

StateBag

Used to persist custom data for a task

Declaration
public IDictionary StateBag { get; }
Property Value
Type Description
System.Collections.IDictionary
Remarks

Data must be serializable

Status

Current status of task

Declaration
public TaskStatus Status { get; set; }
Property Value
Type Description
TaskStatus

Subject

Subject or title of task as displayed to the user

Declaration
public string Subject { get; set; }
Property Value
Type Description
System.String

TaskID

Identifier of task

Declaration
public int TaskID { get; }
Property Value
Type Description
System.Int32

WorkflowInstanceId

If associated with a workflow this gives workflow instance id

Declaration
public Guid WorkflowInstanceId { get; set; }
Property Value
Type Description
System.Guid
Remarks

If not associated with workflow Guid.Empty is returned

Methods

Delete(Int32)

Delete task

Declaration
public static bool Delete(int taskID)
Parameters
Type Name Description
System.Int32 taskID

The identifier for the task to be deleted

Returns
Type Description
System.Boolean

Return true if task was deleted

List(Guid)

Lists all task for the specified workflow instance id.

Declaration
public static IList<Task> List(Guid workflowInstanceId)
Parameters
Type Name Description
System.Guid workflowInstanceId

The workflow instance id.

Returns
Type Description
System.Collections.Generic.IList<Task>

List(String)

Lists the tasks for the specified user.

Declaration
public static IList<Task> List(string userName)
Parameters
Type Name Description
System.String userName

Name of the user.

Returns
Type Description
System.Collections.Generic.IList<Task>

A list of tasks.

Load(Int32)

Load a task from database

Declaration
public static Task Load(int taskID)
Parameters
Type Name Description
System.Int32 taskID

The identifier for the task to be loaded

Returns
Type Description
Task

A task object or null if task doesn't exist

OnStatusChanged(Object, EventArgs)

Raises the StatusChanged event.

Declaration
protected void OnStatusChanged(object source, EventArgs args)
Parameters
Type Name Description
System.Object source

The source of the event.

System.EventArgs args

The System.EventArgs instance containing the event data.

OnTaskDeleting(Object, EventArgs)

Raises the TaskDeleting event.

Declaration
protected static void OnTaskDeleting(object source, EventArgs args)
Parameters
Type Name Description
System.Object source

The source of the event.

System.EventArgs args

The System.EventArgs instance containing the event data.

Save()

Save or create task, this method will not save any activity

Declaration
public void Save()
Remarks

Notification will automatically be sent if status is changed

Save(Boolean)

Save or create task, this method will not save any activity

Declaration
public void Save(bool sendMailNotification)
Parameters
Type Name Description
System.Boolean sendMailNotification

SaveActivity()

Save activity changes

Declaration
public void SaveActivity()

SendNotification()

Send information about new task to owner

Declaration
public void SendNotification()

SendReminder()

Send reminder e-mail to owner

Declaration
public void SendReminder()

SendScheduledReminder()

For internal use only

Declaration
public void SendScheduledReminder()

SendUpdate()

Send updated task information to owner by e-mail

Declaration
public void SendUpdate()

TranslateStatus(TaskStatus)

Translates a TaskStatus into a display friendly text.

Declaration
public static string TranslateStatus(TaskStatus status)
Parameters
Type Name Description
TaskStatus status

The status to be translated.

Returns
Type Description
System.String

A translated text

TranslateStatus(TaskStatus, CultureInfo)

Translates a TaskStatus into a display friendly text.

Declaration
public static string TranslateStatus(TaskStatus status, CultureInfo culture)
Parameters
Type Name Description
TaskStatus status

The status to be translated.

System.Globalization.CultureInfo culture

The culture to translate into.

Returns
Type Description
System.String

A translated text

TranslateStatus(TaskStatus, String)

Translates a TaskStatus into a display friendly text.

Declaration
[Obsolete("Use TranslateStatus with CultureInfo argument to translate status to a specific language.")]
public static string TranslateStatus(TaskStatus status, string language)
Parameters
Type Name Description
TaskStatus status

The status to be translated.

System.String language

The language to translate into.

Returns
Type Description
System.String

A translated text

UnassignTasks(String)

Unassigns all tasks from specified user.

Declaration
public static void UnassignTasks(string userOrRoleName)
Parameters
Type Name Description
System.String userOrRoleName

Username or rolename that will be unassigned.

Remarks

Also removes ownership of tasks from user.

Events

StatusChanged

Occurs when the status of a task has changed.

Declaration
public static event EventHandler StatusChanged
Event Type
Type Description
System.EventHandler

TaskDeleting

Occurs when a task is beeing deleted.

Declaration
public static event EventHandler TaskDeleting
Event Type
Type Description
System.EventHandler

Explicit Interface Implementations

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Populates a System.Runtime.Serialization.SerializationInfo with the data needed to serialize the target object.

Declaration
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
System.Runtime.Serialization.SerializationInfo info

The System.Runtime.Serialization.SerializationInfo to populate with data.

System.Runtime.Serialization.StreamingContext context

The destination (see System.Runtime.Serialization.StreamingContext) for this serialization.

Exceptions
Type Condition
System.Security.SecurityException

The caller does not have the required permission.

Implements

System.Runtime.Serialization.ISerializable

Extension Methods