Exemple #1
0
        public override WorkItemData FindReflectedWorkItem(WorkItemData workItem, bool cache)
        {
            string ReflectedWorkItemId = CreateReflectedWorkItemId(workItem);

            var workItemToFind = workItem.ToWorkItem();

            WorkItem found = null;

            if (Cache.ContainsKey(workItemToFind.Id))
            {
                return(Cache[workItemToFind.Id]);;
            }

            // If we have a Reflected WorkItem ID field on the source store, assume it is pointing to the desired work item on the target store
            if (Config.ReflectedWorkItemIDFieldName != null && workItemToFind.Fields.Contains(Config.ReflectedWorkItemIDFieldName) && !string.IsNullOrEmpty(workItemToFind.Fields[Config.ReflectedWorkItemIDFieldName]?.Value?.ToString()))
            {
                string rwiid    = workItemToFind.Fields[Config.ReflectedWorkItemIDFieldName].Value.ToString();
                int    idToFind = GetReflectedWorkItemId(workItem);
                if (idToFind == 0)
                {
                    found = null;
                }
                else
                {
                    try
                    {
                        found = Store.GetWorkItem(idToFind);
                    }
                    catch (DeniedOrNotExistException)
                    {
                        found = null;
                    }
                }
            }
            if (found == null)
            {
                found = FindReflectedWorkItemByReflectedWorkItemId(ReflectedWorkItemId)?.ToWorkItem();
            }
            if (Config.ReflectedWorkItemIDFieldName != null && !workItemToFind.Fields.Contains(Config.ReflectedWorkItemIDFieldName))
            {
                if (found == null)
                {
                    found = FindReflectedWorkItemByMigrationRef(ReflectedWorkItemId)?.ToWorkItem();
                }                                                                                                      // Too slow!
                                                                                                                       //if (found == null) { found = FindReflectedWorkItemByTitle(workItemToFind.Title); }
            }
            if (found != null && cache)
            {
                AddToCache(workItemToFind.Id, found.AsWorkItemData());/// TODO MEMORY LEAK
            }
            return(found?.AsWorkItemData());
        }
        public override WorkItemData FindReflectedWorkItem(WorkItemData workItemToReflect, bool cache)

        {
            TfsReflectedWorkItemId ReflectedWorkItemId = new TfsReflectedWorkItemId(workItemToReflect);

            var workItemToFind = workItemToReflect.ToWorkItem();

            WorkItem found = GetFromCache(ReflectedWorkItemId)?.ToWorkItem();

            // SHOULD NEVER HAVE A rEFLECTEDiD ON SOURCE! IF WE DO ITS IRRELEVENT AS ITS FROM A PREVIOUS MIGRATION
            // If we have a Reflected WorkItem ID field on the source store, assume it is pointing to the desired work item on the target store
            //if (Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName != null && workItemToFind.Fields.Contains(Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName) && !string.IsNullOrEmpty(workItemToFind.Fields[Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName]?.Value?.ToString()))
            //{
            //    string rwiid = workItemToFind.Fields[Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName].Value.ToString();
            //    ReflectedWorkItemId idToFind = GetReflectedWorkItemId(workItemToReflect);
            //    if (int.Parse(idToFind.WorkItemId) == 0)
            //    {
            //        found = null;
            //    }
            //    else
            //    {
            //        try
            //        {
            //            found = Store.GetWorkItem(int.Parse(idToFind.WorkItemId));
            //        }
            //        catch (DeniedOrNotExistException)
            //        {
            //            found = null;
            //        }
            //    }
            //}
            if (found == null)
            {
                found = FindReflectedWorkItemByReflectedWorkItemId(ReflectedWorkItemId)?.ToWorkItem();
            }
            if (Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName != null && !workItemToFind.Fields.Contains(Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName))
            {
                if (found == null)
                {
                    found = FindReflectedWorkItemByMigrationRef(ReflectedWorkItemId)?.ToWorkItem();
                }                                                                                                      // Too slow!
                                                                                                                       //if (found == null) { found = FindReflectedWorkItemByTitle(workItemToFind.Title); }
            }
            if (found != null && cache)
            {
                AddToCache(found.AsWorkItemData());/// TODO MEMORY LEAK
            }
            return(found?.AsWorkItemData());
        }
Exemple #3
0
        public override WorkItemData FindReflectedWorkItem(WorkItemData workItemToReflect, bool cache)
        {
            TfsReflectedWorkItemId ReflectedWorkItemId = new TfsReflectedWorkItemId(workItemToReflect);
            WorkItem found = GetFromCache(ReflectedWorkItemId)?.ToWorkItem();

            if (found == null)
            {
                found = FindReflectedWorkItemByReflectedWorkItemId(ReflectedWorkItemId)?.ToWorkItem();
            }
            if (found != null && cache)
            {
                AddToCache(found.AsWorkItemData());// TODO MEMORY LEAK
            }
            return(found?.AsWorkItemData());
        }