WorkItem Class
Represents a work item on Team Foundation Server.
Namespace:
Microsoft.TeamFoundation.WorkItemTracking.Client
Assembly: Microsoft.TeamFoundation.WorkItemTracking.Client (in Microsoft.TeamFoundation.WorkItemTracking.Client.dll)
The WorkItem type exposes the following members.
| Name | Description | |
|---|---|---|
|
WorkItem | Initializes a new instance of the WorkItem class of the specified WorkItemType. |
| Name | Description | |
|---|---|---|
|
AreaId | Gets or sets the integer value of the AreaId field for this work item. |
|
AreaPath | Gets or sets the string value of the AreaPath field for this work item. |
|
AttachedFileCount | Gets the number of attached files for this work item. |
|
Attachments | Gets the AttachmentCollection object that represents the attachments that belong to this work item. |
|
ChangedBy | Gets the string value of the ChangedBy field for this work item. |
|
ChangedDate | Gets the DateTime object that represents the date and time that this work item was last changed. |
|
CreatedBy | Gets the string value of the CreatedBy field for this work item. |
|
CreatedDate | Gets the DateTime object that represents the date and time that this work item was created. |
|
Description | Gets or sets a string that describes this work item. |
|
DisplayForm | Gets the display form that is associated with this work item. |
|
ExternalLinkCount | Gets the number of external links in this work item. |
|
Fields | Gets the FieldCollection object that contains the Fields of this work item. |
|
History | Gets or sets the string value of the History field for this work item. |
|
HyperLinkCount | Gets the number of hyperlinks in this work item. |
|
Id | Gets the ID of this work item. |
|
IsDirty | Gets a flag that describes whether this work item has been changed since its last save. |
|
IsNew | Gets a flag that describes whether this work item is new. |
|
IsOpen | Gets a flag that describes whether this work item is currently open for edit. |
|
IsPartialOpen | Gets a flag that describes whether the work item is partially opened. |
|
IsReadOnly | Gets a flag that describes whether the work item is read-only. |
|
IsReadOnlyOpen | Gets a flag that describes whether the work item is open as read-only. |
|
Item[String] | Gets or sets the value of a field in this work item that is specified by the field name. |
|
Item[CoreField] | Gets or sets the value of a field in this work item that is specified by the field ID. |
|
IterationId | Gets or sets the integer value of the IterationId field of this work item. |
|
IterationPath | Gets or sets the string value of the IterationPath field of this work item. |
|
Links | Gets the collection of the links in this work item. |
|
NodeName | Gets or sets the string value of the NodeName field of this work item. |
|
Project | Gets the current project that is associated with this work item. |
|
Reason | Gets or sets the string value of the Reason field for this work item. |
|
RelatedLinkCount | Gets the number of related links of this work item. |
|
Rev | Gets the integer that represents the revision number of this work item. |
|
RevisedDate | Gets a DateTime object that represents the revision date and time of this work item. |
|
Revision | Gets the integer that represents the revision number of this work item. |
|
Revisions | Gets a RevisionCollection object that represents a collection of valid revision numbers for this work item. |
|
State | Gets or sets a string that describes the state of this work item. |
|
Store | Gets the WorkItemStore to which this work item belongs. |
|
TemporaryId | Gets the temporary ID of this work item. |
|
Title | Gets or sets a string that describes the title of this work item. |
|
Type | Gets a WorkItemType object that represents the type of this work item. |
|
Uri | Gets the uniform resource identifier (Uri) of this work item. |
|
WorkItemLinkHistory | Gets a WorkItemLinkCollection object that represents a collection of the WorkItemLinks that link to this work item now or linked to it in the past. |
|
WorkItemLinks | Gets a WorkItemLinkCollection object that represents a collection of the WorkItemLinks that currently link to this work item. |
| Name | Description | |
|---|---|---|
|
Close | Closes this WorkItem instance and frees memory that is associated with it. |
|
Copy() | Creates a copy of this WorkItem instance. |
|
Copy(WorkItemType) | Creates a copy of this WorkItem instance that is of the specified WorkItemType. |
|
Copy(WorkItemType, WorkItemCopyFlags) | Creates a copy of this WorkItem instance that is of the specified WorkItemType. |
|
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
|
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
|
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
|
GetNextState | Gets the next state of this work item based on the action of a user. |
|
GetType | Gets the Type of the current instance. (Inherited from Object.) |
|
IsValid | Validates the fields of this work item. |
|
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
|
Open | Opens this work item for modification. |
|
PartialOpen | Opens this work item for modification when transmitting minimal amounts of data over the network. |
|
Reset | Reverts all changes that were made since the last save. |
|
Save() | Saves any pending changes on this work item. |
|
Save(SaveFlags) | Saves any pending changes on this work item. |
|
SyncToLatest | Synchronizes the work item to the latest revision. |
|
ToString | Returns a string that represents the current object. (Inherited from Object.) |
|
Validate | Gets an ArrayList of fields in this work item that are not valid. |
Create a new work item using work item type name
Public Function NewWorkItem(ByVal collectionName as String,
ByVal projectName As String,
ByVal workItemTypeName As String) As WorkItem
Dim retval As WorkItem = Nothing
If Not String.IsNullOrWhiteSpace(collectionName) _
AndAlso Not String.IsNullOrWhiteSpace(projectName) _
AndAlso Not String.IsNullOrWhiteSpace(workItemTypeName) Then
Try
Dim TFSInstance = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(New Uri(String.Concat("http://myserver:8080/tfs/",collectionName)),
New UICredentialsProvider())
Dim workItemService = CType(TFSInstance.GetService(Of WorkItemStore)(), WorkItemStore)
Dim prj = (From p In workItemService.Projects.OfType(Of Project)()
Where p.Name = projectName
Select p).FirstOrDefault()
If prj IsNot Nothing Then
Dim wiType = (From i In prj.WorkItemTypes.OfType(Of WorkItemType)()
Where i.Name = workItemTypeName
Select i).FirstOrDefault()
If wiType IsNot Nothing Then
retval = wiType.NewWorkItem()
Else
Throw New ArgumentOutOfRangeException()
End If
End If
Catch ex As Exception
Throw
End Try
Else
Throw New ArgumentNullException()
End If
Return retval
End Function
ByVal projectName As String,
ByVal workItemTypeName As String) As WorkItem
Dim retval As WorkItem = Nothing
If Not String.IsNullOrWhiteSpace(collectionName) _
AndAlso Not String.IsNullOrWhiteSpace(projectName) _
AndAlso Not String.IsNullOrWhiteSpace(workItemTypeName) Then
Try
Dim TFSInstance = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(New Uri(String.Concat("http://myserver:8080/tfs/",collectionName)),
New UICredentialsProvider())
Dim workItemService = CType(TFSInstance.GetService(Of WorkItemStore)(), WorkItemStore)
Dim prj = (From p In workItemService.Projects.OfType(Of Project)()
Where p.Name = projectName
Select p).FirstOrDefault()
If prj IsNot Nothing Then
Dim wiType = (From i In prj.WorkItemTypes.OfType(Of WorkItemType)()
Where i.Name = workItemTypeName
Select i).FirstOrDefault()
If wiType IsNot Nothing Then
retval = wiType.NewWorkItem()
Else
Throw New ArgumentOutOfRangeException()
End If
End If
Catch ex As Exception
Throw
End Try
Else
Throw New ArgumentNullException()
End If
Return retval
End Function
- 5/6/2011
- Massimo Bonanni
- 5/6/2011
- Massimo Bonanni