2010-02-04 12 views
8

मैं राज्य "ए" से राज्य "एक्स" में जाने की कोशिश कर रहा हूं।टीएफएस एपीआई - क्या वर्कटाइम प्रकार के लिए संक्रमण की सूची प्राप्त करने का कोई तरीका है?

जगह में संक्रमण है कि मुझे केवल X को

मैं एक्सएमएल और उस पर काम के रूप में WorkItemType निर्यात कर सकते हैं जाने से रोकने के होते हैं, लेकिन इससे पहले कि मैं ऐसा कर, मैंने सोचा कि अगर वहाँ एक रास्ता है मैं पूछना होगा एपीआई के माध्यम से संक्रमण पर पाने के लिए।

उत्तर

9

Soooo .....

नहीं कई लोगों को WorkItemTypes के लिए संक्रमण की जरूरत है।

ठीक है, मैं जरूरत यह तो मैं यह करने के लिए एक विधि लिखा था। यहां किसी और को कभी इसकी आवश्यकता है:

// Hold a list of all the transistions we have done. This will help us not have run them again If we already have. 
private static Dictionary<WorkItemType, List<Transition>> _allTransistions = new Dictionary<WorkItemType, List<Transition>>(); 

/// <summary> 
/// Get the transitions for this <see cref="WorkItemType"/> 
/// </summary> 
/// <param name="workItemType"></param> 
/// <returns></returns> 
private static List<Transition> GetTransistions(this WorkItemType workItemType) 
{ 
    List<Transition> currentTransistions; 

    // See if this WorkItemType has already had it's transistions figured out. 
    _allTransistions.TryGetValue(workItemType, out currentTransistions); 
    if (currentTransistions != null) 
     return currentTransistions; 

    // Get this worktype type as xml 
    XmlDocument workItemTypeXml = workItemType.Export(false); 

    // Create a dictionary to allow us to look up the "to" state using a "from" state. 
    var newTransistions = new List<Transition>(); 

    // get the transistions node. 
    XmlNodeList transitionsList = workItemTypeXml.GetElementsByTagName("TRANSITIONS"); 

    // As there is only one transistions item we can just get the first 
    XmlNode transitions = transitionsList[0]; 

    // Iterate all the transitions 
    foreach (XmlNode transition in transitions) 
    { 
     // save off the transistion 
     newTransistions.Add(new Transition 
           { 
            From = transition.Attributes["from"].Value, 
            To = transition.Attributes["to"].Value 
           }); 

    } 

    // Save off this transition so we don't do it again if it is needed. 
    _allTransistions.Add(workItemType, newTransistions); 

    return newTransistions; 
} 

public class Transition 
{ 
    public string To { get; set; } 
    public string From { get; set; } 
} 
+0

मैं संक्रमण के बजाय सभी राज्यों को प्राप्त करना चाहता था, यह भी इसके लिए पूरी तरह से काम करता था। बहुत धन्यवाद। – 4imble

+0

ग्रेट, धन्यवाद !! – JobaDiniz