Exemplo n.º 1
0
 public static bool IsFromPublicStore(StoreObjectId id)
 {
     Util.ThrowOnNullArgument(id, "id");
     return(IdConverter.IsFromPublicStore(id.ProviderLevelItemId));
 }
Exemplo n.º 2
0
        public static Participant[] ExpandDeep(StoreSession storeSession, StoreObjectId distributionListId, bool shouldAddNonExistPDL)
        {
            Dictionary <StoreObjectId, Participant> dictionary = new Dictionary <StoreObjectId, Participant>();
            Queue <StoreObjectId> queue = new Queue <StoreObjectId>();
            List <Participant>    list  = new List <Participant>();

            queue.Enqueue(distributionListId);
            while (queue.Count > 0)
            {
                StoreObjectId    storeObjectId    = queue.Dequeue();
                DistributionList distributionList = null;
                try
                {
                    distributionList = DistributionList.Bind(storeSession, storeObjectId);
                }
                catch (ObjectNotFoundException arg)
                {
                    if (storeSession.ItemBinder != null)
                    {
                        Item item = storeSession.ItemBinder.BindItem(storeObjectId, IdConverter.IsFromPublicStore(storeObjectId), IdConverter.GetParentIdFromMessageId(storeObjectId));
                        distributionList = (item as DistributionList);
                        if (item != null && distributionList == null)
                        {
                            item.Dispose();
                        }
                    }
                    if (distributionList == null)
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug <ObjectNotFoundException>(0L, "DistributionList::ExpandDeep. A PDL member in PDL doesn't exist. Ignore it and continue to expand other members. Exception = {0}.", arg);
                        if (shouldAddNonExistPDL && dictionary.ContainsKey(storeObjectId))
                        {
                            list.Add(new Participant(dictionary[storeObjectId].DisplayName, null, "MAPIPDL"));
                        }
                    }
                }
                if (distributionList != null)
                {
                    using (distributionList)
                    {
                        foreach (DistributionListMember distributionListMember in distributionList)
                        {
                            if (!(distributionListMember.Participant == null))
                            {
                                if (distributionListMember.IsDistributionList() == true && distributionListMember.Participant.Origin is StoreParticipantOrigin && distributionListMember.Participant.ValidationStatus == ParticipantValidationStatus.NoError)
                                {
                                    StoreObjectId originItemId = ((StoreParticipantOrigin)distributionListMember.Participant.Origin).OriginItemId;
                                    if (!dictionary.ContainsKey(originItemId) && !originItemId.Equals(distributionListId))
                                    {
                                        queue.Enqueue(originItemId);
                                        dictionary.Add(originItemId, distributionListMember.Participant);
                                    }
                                }
                                else
                                {
                                    list.Add(distributionListMember.Participant);
                                }
                            }
                        }
                    }
                }
            }
            return(list.ToArray());
        }