private static void CleanUpContactLinkingInformation(Item contactItem) { contactItem.OpenAsReadWrite(); contactItem.SetOrDeleteProperty(ContactSchema.PersonId, PersonId.CreateNew()); contactItem.SetOrDeleteProperty(ContactSchema.Linked, false); contactItem.SetOrDeleteProperty(ContactSchema.LinkRejectHistory, null); contactItem.SetOrDeleteProperty(ContactSchema.GALLinkState, GALLinkState.NotLinked); contactItem.SetOrDeleteProperty(ContactSchema.GALLinkID, null); contactItem.SetOrDeleteProperty(ContactSchema.SmtpAddressCache, null); contactItem.SetOrDeleteProperty(ContactSchema.AddressBookEntryId, null); contactItem.SetOrDeleteProperty(ContactSchema.UserApprovedLink, false); contactItem.Save(SaveMode.NoConflictResolution); }
public static Player CreatePlayer ( PersonName name, Gender gender, BirthInfo birthInfo, Foot favouriteFoot, BodyMassIndex bmi, Percentile percentile, PhysicalFeatureSet physicalFeatureSet, PlayerPosition playerPosition, params Country[] nationalities ) => new Player ( PersonId.CreateNew(), name, gender, birthInfo, favouriteFoot, bmi, percentile, physicalFeatureSet, playerPosition, nationalities );
private GetGroupResponse GetPDLData() { GetGroupResponse getGroupResponse = new GetGroupResponse(); MailboxSession mailboxIdentityMailboxSession = base.CallContext.SessionCache.GetMailboxIdentityMailboxSession(); ItemId sourceId = this.itemId; IdAndSession idAndSession = null; if (this.parentFolderid != null && this.parentFolderid.BaseFolderId != null) { IdAndSession idAndSession2 = base.GetIdAndSession(this.parentFolderid.BaseFolderId); if (idAndSession2 != null && idAndSession2.Session.IsPublicFolderSession) { idAndSession = idAndSession2; } } if (IdConverter.EwsIdIsConversationId(this.itemId.Id)) { try { Persona persona; if (idAndSession != null) { persona = Persona.LoadFromPersonaId(idAndSession.Session, null, this.itemId, Persona.FullPersonaShape, null, idAndSession.Id); } else { persona = Persona.LoadFromPersonIdWithGalAggregation(mailboxIdentityMailboxSession, IdConverter.EwsIdToPersonId(this.itemId.Id), Persona.FullPersonaShape, null); } if (persona.Attributions.Length > 0) { sourceId = persona.Attributions[0].SourceId; for (int i = 1; i < persona.Attributions.Length; i++) { StoreId storeId = IdConverter.EwsIdToMessageStoreObjectId(persona.Attributions[i].SourceId.Id); using (Item item = Item.Bind(mailboxIdentityMailboxSession, storeId, new PropertyDefinition[] { ContactSchema.PersonId })) { item.OpenAsReadWrite(); item[ContactSchema.PersonId] = PersonId.CreateNew(); item.Save(SaveMode.NoConflictResolution); } } RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Success"); } else { ExTraceGlobals.GetGroupTracer.TraceError((long)this.hashCode, "ItemId is PersonaId but Persona has no linked contacts (attributions array is empty)."); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Skipped"); } } catch (LocalizedException arg) { ExTraceGlobals.GetGroupTracer.TraceError <LocalizedException>((long)this.hashCode, "Failed to unlink PDLs: {0}", arg); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Failed"); } } IdAndSession idAndSession3 = base.IdConverter.ConvertItemIdToIdAndSessionReadOnly(sourceId); StoreSession storeSession; if (idAndSession != null) { storeSession = idAndSession.Session; } else { storeSession = ((idAndSession3.Session as MailboxSession) ?? base.CallContext.SessionCache.GetMailboxIdentityMailboxSession()); } using (DistributionList distributionList = DistributionList.Bind(storeSession, idAndSession3.Id)) { if (distributionList == null) { this.WriteDebugTrace("No PDL was found"); return(getGroupResponse); } PersonId personId = (PersonId)distributionList[ContactSchema.PersonId]; getGroupResponse.PersonaId = IdConverter.PersonaIdFromPersonId(storeSession.MailboxGuid, personId); if (!distributionList.GetValueOrDefault <bool>(ItemSchema.ConversationIndexTracking, false)) { try { distributionList.OpenAsReadWrite(); distributionList[ItemSchema.ConversationIndexTracking] = true; distributionList.Save(SaveMode.NoConflictResolution); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "SetConversationIndexTracking", "Success"); } catch (LocalizedException arg2) { ExTraceGlobals.GetGroupTracer.TraceError <LocalizedException>((long)this.hashCode, "Failed to set ConversationIndexTracking on PDL: {0}", arg2); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "SetConversationIndexTracking", "Failed"); } } if (!this.IsMembersInResultSet) { return(getGroupResponse); } int count = distributionList.Count; getGroupResponse.MembersCount = count; this.WriteDebugTrace("Total PDL members count is " + count); if (this.paging.Offset < 0 || count <= this.paging.Offset) { this.WriteDebugTrace(string.Format("Provided offset is out of range - members count is {0}, offset is {1}.", count, this.paging.Offset)); return(getGroupResponse); } distributionList.Sort(this.PDlMembersComparer); List <Persona> list = new List <Persona>(); List <string> list2 = new List <string>(); Dictionary <string, int> dictionary = new Dictionary <string, int>(); int num = Math.Min(count, this.paging.Offset + this.paging.MaxRows); for (int j = this.paging.Offset; j < num; j++) { DistributionListMember distributionListMember = distributionList[j]; if (distributionListMember.Participant == null) { if (num < count) { num++; } getGroupResponse.MembersCount--; } else { bool flag = false; Persona persona2 = GetGroupCommand.CreatePersonaFromDistributionListMember(mailboxIdentityMailboxSession, distributionListMember, out flag); if (flag) { list2.Add(persona2.EmailAddress.EmailAddress); dictionary.Add(persona2.EmailAddress.EmailAddress, list.Count); } list.Add(persona2); } } if (list2.Count > 0) { IRecipientSession galscopedADRecipientSession = base.CallContext.ADRecipientSessionContext.GetGALScopedADRecipientSession(base.CallContext.EffectiveCaller.ClientSecurityContext); Result <ADRawEntry>[] array = galscopedADRecipientSession.FindByLegacyExchangeDNs(list2.ToArray(), new PropertyDefinition[] { ADObjectSchema.Id, ADRecipientSchema.DisplayName, ADRecipientSchema.PrimarySmtpAddress, ADRecipientSchema.RecipientType, ADRecipientSchema.RecipientTypeDetails, ADRecipientSchema.LegacyExchangeDN }); foreach (Result <ADRawEntry> result in array) { if (result.Data != null) { Persona personaFromADObject = GetGroupCommand.GetPersonaFromADObject(result.Data); string key = result.Data[ADRecipientSchema.LegacyExchangeDN] as string; int num2; if (dictionary.ContainsKey(key) && dictionary.TryGetValue(key, out num2) && num2 >= 0) { list[num2] = personaFromADObject; } } } } list.Sort(this.PersonaComparer); Persona[] array3 = new Persona[list.Count]; list.CopyTo(0, array3, 0, list.Count); getGroupResponse.Members = array3; this.WriteDebugTrace("PDL members count loaded in the response is " + getGroupResponse.Members.Length); } return(getGroupResponse); }