/// ------------------------------------------------------------------------------------ private void ProcessContributorNameChange(ElementIdChangedArgs e) { foreach (var file in GetComponentFiles().Where(f => (f.FileType as FileTypeWithContributors) != null)) { var values = file.MetaDataFieldValues.FirstOrDefault(v => v.FieldId == SessionFileType.kContributionsFieldName); if (values == null) { continue; } var contributions = values.Value as ContributionCollection; if (contributions == null) { continue; } foreach (var contribution in contributions.Where(contribution => contribution.ContributorName == e.OldId)) { contribution.ContributorName = e.NewId; } string failureMessage; file.SetValue(SessionFileType.kContributionsFieldName, contributions, out failureMessage); if (failureMessage == null) { file.Save(); } else { ErrorReport.NotifyUserOfProblem(failureMessage); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// We get this message from the person informant when a person's name has changed. /// When that happens, we need to make sure we update the participant field in case /// it contains a name that changed. /// </summary> /// ------------------------------------------------------------------------------------ private void HandlePersonsNameChanged(object sender, ElementIdChangedArgs e) { var allParticipants = GetAllParticipants(); var newNames = allParticipants.Select(name => (name == e.OldId ? e.NewId : name)); MetaDataFile.SetStringValue(SessionFileType.kParticipantsFieldName, FieldInstance.GetTextFromMultipleValues(newNames)); MetaDataFile.Save(); ProcessContributorNameChange(e); }
/// ------------------------------------------------------------------------------------ protected void HandlePersonNameChanged(object sender, ElementIdChangedArgs args) { // If the new "ID" is the real underlying ID of a person, then this was an actual // name change (or the "code"was removed and this can be treated as a legitimate name // change). var person = _peopleRepository.GetById(args.NewId); if (person != null) { if (PersonNameChanged != null) { PersonNameChanged(this, args); } } if (PersonUiIdChanged != null) { PersonUiIdChanged(this, args); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// We get this message from the person informant when a person's UI ID has changed. /// When that happens, we need to update any matching contributors in any metadata files /// for any of this session's media files. /// </summary> /// ------------------------------------------------------------------------------------ private void HandlePersonsUiIdChanged(object sender, ElementIdChangedArgs e) { ProcessContributorNameChange(e); }