Ejemplo n.º 1
0
        internal StoreObjectId Find(string provider, string userId, string networkId)
        {
            Util.ThrowOnNullOrEmptyArgument(provider, "provider");
            Util.ThrowOnNullOrEmptyArgument(userId, "userId");
            Guid providerGuid;

            if (!OscProviderRegistry.TryGetGuidFromName(provider, out providerGuid))
            {
                OscSyncLockLocator.Tracer.TraceError <string>((long)this.GetHashCode(), "SyncLock locator: cannot find for unknown provider: {0}", provider);
                throw new ObjectNotFoundException(ServerStrings.UnknownOscProvider(provider));
            }
            OscNetworkMoniker oscNetworkMoniker = new OscNetworkMoniker(providerGuid, networkId, userId);

            foreach (IStorePropertyBag storePropertyBag in new OscSyncLockEnumerator(this.session, this.session.GetDefaultFolderId(DefaultFolderType.Contacts), this.xsoFactory))
            {
                VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                if (valueOrDefault == null)
                {
                    OscSyncLockLocator.Tracer.TraceError((long)this.GetHashCode(), "SyncLock locator: skipping SyncLock because its id is missing.");
                }
                else
                {
                    string text = this.ExtractNetworkMonikerFromSyncLock(storePropertyBag);
                    OscSyncLockLocator.Tracer.TraceDebug <StoreObjectId, string>((long)this.GetHashCode(), "SyncLock locator: SyncLock with id '{0}' has network moniker '{1}'", valueOrDefault.ObjectId, text);
                    if (oscNetworkMoniker.Equals(text))
                    {
                        OscSyncLockLocator.Tracer.TraceDebug((long)this.GetHashCode(), "SyncLock locator: found for provider '{0}', user id '{1}', and network id '{2}'.  Id is '{3}'", new object[]
                        {
                            provider,
                            userId,
                            networkId,
                            valueOrDefault.ObjectId
                        });
                        return(valueOrDefault.ObjectId);
                    }
                }
            }
            OscSyncLockLocator.Tracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "SyncLock locator: for provider '{0}', user id '{1}', and network id '{2}' not found.", provider, userId, networkId);
            throw new ObjectNotFoundException(ServerStrings.OscSyncLockNotFound(provider, userId, networkId));
        }
Ejemplo n.º 2
0
        internal StoreObjectId Find(string provider, string userId, string networkId)
        {
            Util.ThrowOnNullOrEmptyArgument(provider, "provider");
            Util.ThrowOnNullOrEmptyArgument(userId, "userId");
            Guid guid;

            if (!OscProviderRegistry.TryGetGuidFromName(provider, out guid))
            {
                OscFolderLocator.Tracer.TraceError <string>((long)this.GetHashCode(), "Folder locator: cannot find folder for unknown provider: {0}", provider);
                throw new ObjectNotFoundException(ServerStrings.UnknownOscProvider(provider));
            }
            OscNetworkMoniker arg = new OscNetworkMoniker(guid, networkId, userId);

            foreach (IStorePropertyBag storePropertyBag in new OscProviderCandidateFolderEnumerator(this.session, guid, this.xsoFactory))
            {
                VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(FolderSchema.Id, null);
                if (valueOrDefault == null)
                {
                    OscFolderLocator.Tracer.TraceError((long)this.GetHashCode(), "Folder locator: skipping folder with invalid id");
                }
                else
                {
                    OscFolderLocator.Tracer.TraceDebug <string, OscNetworkMoniker, StoreObjectId>((long)this.GetHashCode(), "Folder locator: looking for ContactSync FAI for provider '{0}' and moniker '{1}' in folder '{2}'", provider, arg, valueOrDefault.ObjectId);
                    foreach (IStorePropertyBag item in new OscContactSyncFAIEnumerator(this.session, valueOrDefault.ObjectId, this.xsoFactory))
                    {
                        foreach (OscNetworkMoniker oscNetworkMoniker in new OscFolderContactSourcesEnumerator(item))
                        {
                            OscFolderLocator.Tracer.TraceDebug <OscNetworkMoniker, StoreObjectId>((long)this.GetHashCode(), "Folder locator: found network moniker '{0}' in folder '{1}'", oscNetworkMoniker, valueOrDefault.ObjectId);
                            if (arg.Equals(oscNetworkMoniker))
                            {
                                OscFolderLocator.Tracer.TraceDebug <string, StoreObjectId>((long)this.GetHashCode(), "Folder locator: found folder for provider '{0}'.  Folder id is '{1}'", provider, valueOrDefault.ObjectId);
                                return(valueOrDefault.ObjectId);
                            }
                        }
                    }
                }
            }
            OscFolderLocator.Tracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "Folder locator: folder for provider: {0}; user id: {1}; network id: {2}; not found.", provider, userId, networkId);
            throw new ObjectNotFoundException(ServerStrings.OscFolderForProviderNotFound(provider));
        }