问题描述:

I'm trying to add a task to a queue programatically. I found this example code: http://msdn.microsoft.com/en-us/library/gg328106.aspx, but it simply creates the queues instead of using existing ones. Is there an easy way to find the id of a queue?

网友答案:

I figured it out. I found that one can use the Advanced Find tool to generate FetchXML. Using that I was able to query for my queue and then get the ID.

Here's what I ended up using:

string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                      <entity name='queue'>
                        <attribute name='name' />
                        <attribute name='emailaddress' />
                        <attribute name='queueid' />
                        <order attribute='name' descending='false' />
                        <filter type='and'>
                          <condition attribute='name' operator='eq' value='{0}' />
                        </filter>
                      </entity>
                    </fetch>";    

EntityCollection result = service.RetrieveMultiple(new FetchExpression(String.format(fetchXml, queueName)));
var myQueue = (Queue)result.Entities[0];
Console.WriteLine(myQueye.Id);
相关阅读:
Top