Ejemplo n.º 1
0
 protected WorkItemData GetFromCache(ReflectedWorkItemId reflectedWorkItemId)
 {
     if (_Cache.ContainsKey(reflectedWorkItemId.ToString()))
     {
         return(_Cache[reflectedWorkItemId.ToString()]);
     }
     return(null);
 }
        protected WorkItemData FindReflectedWorkItemByMigrationRef(ReflectedWorkItemId refId)
        {
            IWorkItemQueryBuilder wiqb         = Services.GetRequiredService <IWorkItemQueryBuilder>();
            StringBuilder         queryBuilder = FindReflectedWorkItemQueryBase(wiqb);

            queryBuilder.Append(" [System.Description] Contains @KeyToFind");
            wiqb.AddParameter("KeyToFind", string.Format("##REF##{0}##", refId));
            wiqb.Query = queryBuilder.ToString();
            return(FindWorkItemByQuery(wiqb));
        }
        protected WorkItemData FindReflectedWorkItemByReflectedWorkItemId(ReflectedWorkItemId refId, bool cache = true)
        {
            var foundWorkItem = GetFromCache(refId);

            if (foundWorkItem is null)
            {
                IWorkItemQueryBuilder wiqb = Services.GetRequiredService <IWorkItemQueryBuilder>();
                wiqb.Query = string.Format(@"SELECT [System.Id] FROM WorkItems  WHERE [System.TeamProject]=@TeamProject AND [{0}] = '@idToFind'", MigrationClient.Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName);
                wiqb.AddParameter("idToFind", refId.ToString());
                wiqb.AddParameter("TeamProject", MigrationClient.Config.AsTeamProjectConfig().Project);
                var query = wiqb.BuildWIQLQuery(MigrationClient);
                var items = query.GetWorkItems();

                foundWorkItem = items.FirstOrDefault(wi => wi.ToWorkItem().Fields[MigrationClient.Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName].Value.ToString() == refId.ToString());
                if (cache && foundWorkItem != null)
                {
                    AddToCache(foundWorkItem);
                }
            }
            return(foundWorkItem);
        }