Esempio n. 1
0
        private WitMappingIndex BuildIndex(WorkItemStore destWIStore, IEnumerable <WorkItem> existingTargetWorkItems, WorkItemsStageConfiguration mapping)
        {
            var index = new WitMappingIndex();

            if (mapping.HasIndex)
            {
                if (!System.IO.File.Exists(mapping.IndexFile))
                {
                    //HACK on first run the file cannot exists, so create an empty one
                    index = WitMappingIndex.CreateEmpty(mapping.IndexFile);
                }
                else
                {
                    index = WitMappingIndex.Load(mapping.IndexFile, destWIStore);
                }//if
            }
            else
            {
                index.Clear();
                foreach (var targetWI in existingTargetWorkItems)
                {
                    var originatingFieldMap = mapping.FindIdFieldForTargetWorkItemType(targetWI.Type.Name);
                    var v = targetWI.Fields[originatingFieldMap.Destination].Value;
                    // could be that the destination exists, with no origin (e.g. manual intervention)
                    int originatingId = (int)(v ?? 0);
                    index.Add(originatingId, targetWI);
                } //for
            }     //if

            return(index);
        }
Esempio n. 2
0
 private void UpdateIndex(WitMappingIndex index, IEnumerable <WorkItem> updatedWorkItems, WorkItemsStageConfiguration mapping)
 {
     if (mapping.HasIndex)
     {
         index.Update(updatedWorkItems);
         index.Save(mapping.IndexFile);
     }
     else
     {
         foreach (var dst in updatedWorkItems)
         {
             var originatingFieldMap = mapping.FindIdFieldForTargetWorkItemType(dst.Type.Name);
             int originatingId       = (int)dst.Fields[originatingFieldMap.Destination].Value;
             index.Update(originatingId, dst);
         }//for
     }
 }