TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rahul Kaushik
1.1k
625
66.6k
Collection was modified; enumeration operation may not exec.
May 6 2018 4:48 AM
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace windowsserviceTest
{
class velocityActivity
{
public static Uri collectionUri = new Uri("****---My uri---****);
public static IList<Tuple<int, string, string>> iterationListing = new List<Tuple<int, string, string>>();
public static IList<userstoryPoints> spoint = new List<userstoryPoints>();
public static int task = 0;
public velocityActivity()
{
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(collectionUri);
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(collectionUri);
tpc.Authenticate();
teamProjectCollection.EnsureAuthenticated();
var wis = new WorkItemStore(tpc);
ProjectCollection proj = wis.Projects;
foreach (Project projs in proj)
{
if (projs.Name == "AT_ERG")
{
foreach (Node iter in projs.IterationRootNodes)
{
iterationListing.Add(new Tuple<int, string, string>(iter.Id, iter.Name, iter.Uri.Segments.ElementAt(3)));
}
}
}
WorkItemCollection workItemCollection = wis.Query(@"Select * from WorkItems");
int count = 0;
var workList = new List<WorkItem>();
var taskLists = new List<Task>();
IList<userstoryPoints> spoints = new List<userstoryPoints>();
foreach (WorkItem item in workItemCollection)
{
workList.Add(item);
}
Parallel.ForEach(workList.ToList(), (i) => activityAction(i));
Console.WriteLine(spoint);
}
public void activityAction(WorkItem item)
{
try
{
task++;
Console.WriteLine("~Started {0}", task);
int storyPoint = 0;
int flag = 0;
// var fel = item.Fields.AsQueryable();
foreach (Field fields in item.Fields)
{
if (fields.Name.ToString() == "Story Points")
{
if (fields.OriginalValue == null)
{
storyPoint = 0;
continue;
}
else
{
storyPoint = Convert.ToInt32(fields.OriginalValue);
continue;
}
}
if (fields.OriginalValue != null)
{
if (fields.OriginalValue.ToString() == "User Story")
{
flag = 1;
}
}
}
if (flag == 1)
{
string iterID = "";
foreach (var lis in iterationListing)
{
if (lis.Item1 == item.IterationId)
{
iterID = lis.Item3;
break;
}
else
{
iterID = "Deleted";
}
}
string userStoryID = item.Id.ToString();
spoint.Add(new userstoryPoints
{
IterID = iterID,
userStoryID = userStoryID,
storyPoint = storyPoint
});
}
Console.WriteLine("Completed {0}", task);
}
catch(Exception e)
{
Console.WriteLine($"~Failed {task} exception-----{e.ToString()}");
}
}
}
}
Reply
Answers (
1
)
Crystal Report with Mailing Label not working properply.
Save, update and delete data from sql server over net