private string MapUserIdentity( FieldMap fieldMap, SourceSideTypeEnum fromSide, string srcFieldRefName, string tgtFieldRefName, string srcFieldValue) { RichIdentity srcUserId = new RichIdentity(); UserIdFieldElement userIdField = fieldMap.GetUserIdField(fromSide, srcFieldRefName); srcUserId[userIdField.UserIdPropertyName] = srcFieldValue; RichIdentity mappedUserId; if (UserIdLookupService.TryLookup(srcUserId, m_contexts[fromSide], out mappedUserId)) { SourceSideTypeEnum toSide = (fromSide == SourceSideTypeEnum.Left) ? SourceSideTypeEnum.Right : SourceSideTypeEnum.Left; UserIdFieldElement tgtUserField = fieldMap.GetUserIdField(toSide, tgtFieldRefName); if (null != tgtUserField) { return(mappedUserId[tgtUserField.UserIdPropertyName]); } else { return(srcFieldValue); } } else { return(srcFieldValue); } }
public override void Translate(IMigrationAction action, Guid migrationSourceIdOfChangeGroup) { MigrationAction migrAction = action as MigrationAction; Debug.Assert(migrAction != null, "action is not a MigrationActin"); migrAction.Path = GetMappedPath(action.Path, migrationSourceIdOfChangeGroup); migrAction.FromPath = GetMappedPath(action.FromPath, migrationSourceIdOfChangeGroup); if (UserIdLookupService.IsConfigured) { if (action.ChangeGroup.ChangeGroupId != m_cachedUserIdLookupResult.Key) { IdentityLookupContext context = new IdentityLookupContext( migrationSourceIdOfChangeGroup, m_migratinSourcePair[migrationSourceIdOfChangeGroup]); UserIdPropertyNameEnum srcDefaultUserIdProperty; UserIdPropertyNameEnum targetDefaultUserIdProperty; if (UserIdLookupService.TryGetDefaultUserIdProperty(context.SourceMigrationSourceId, out srcDefaultUserIdProperty) && UserIdLookupService.TryGetDefaultUserIdProperty(context.TargetMigrationSourceId, out targetDefaultUserIdProperty)) { RichIdentity srcUserId = new RichIdentity(); srcUserId[srcDefaultUserIdProperty.ToString()] = action.ChangeGroup.Owner; // todo: parse qualified name? RichIdentity mappedUserId; if (UserIdLookupService.TryLookup(srcUserId, context, out mappedUserId)) { action.ChangeGroup.Owner = mappedUserId[targetDefaultUserIdProperty.ToString()]; } } m_cachedUserIdLookupResult = new KeyValuePair <long, string>(action.ChangeGroup.ChangeGroupId, action.ChangeGroup.Owner); } else { action.ChangeGroup.Owner = m_cachedUserIdLookupResult.Value; } } }
private void MapOwnerUserId( XmlElement rootNode, SourceSideTypeEnum fromSide) { if (!UserIdLookupService.IsConfigured) { return; } var authorAttr = rootNode.Attributes["Author"]; if (authorAttr == null || string.IsNullOrEmpty(authorAttr.Value)) { return; } RichIdentity srcUserId = new RichIdentity(); var authorUserIdPropertyAttr = rootNode.Attributes[Constants.WITAuthorUserIdPropertyName]; string authorUserIdProperty; if (authorUserIdPropertyAttr == null || string.IsNullOrEmpty(authorUserIdPropertyAttr.Value)) { authorUserIdProperty = "DisplayName"; } else { authorUserIdProperty = authorUserIdPropertyAttr.Value; } srcUserId[authorUserIdProperty] = authorAttr.Value; RichIdentity mappedUserId; if (UserIdLookupService.TryLookup(srcUserId, m_contexts[fromSide], out mappedUserId)) { authorAttr.Value = mappedUserId.DisplayName; } }