コード例 #1
0
        public DatabaseGuidRoutingEntry GetDatabaseGuidRoutingEntry(DatabaseGuidRoutingKey databaseGuidRoutingKey, IRoutingDiagnostics diagnostics)
        {
            if (databaseGuidRoutingKey == null)
            {
                throw new ArgumentNullException("databaseGuidRoutingKey");
            }
            DatabaseGuidRoutingEntry result;

            try
            {
                MailboxServerCacheEntry mailboxServerCacheEntry;
                if (this.sharedCache.TryGet <MailboxServerCacheEntry>(databaseGuidRoutingKey.DatabaseGuid.ToString(), out mailboxServerCacheEntry, diagnostics))
                {
                    result = new SuccessfulDatabaseGuidRoutingEntry(databaseGuidRoutingKey, new ServerRoutingDestination(mailboxServerCacheEntry.BackEndServer.Fqdn, new int?(mailboxServerCacheEntry.BackEndServer.Version)), DateTime.UtcNow.ToFileTimeUtc());
                }
                else
                {
                    result = null;
                }
            }
            catch (SharedCacheException ex)
            {
                ErrorRoutingDestination destination = new ErrorRoutingDestination(ex.Message);
                result = new FailedDatabaseGuidRoutingEntry(databaseGuidRoutingKey, destination, DateTime.UtcNow.ToFileTimeUtc());
            }
            return(result);
        }
コード例 #2
0
        IRoutingEntry IRoutingLookup.GetRoutingEntry(IRoutingKey routingKey, IRoutingDiagnostics diagnostics)
        {
            if (routingKey == null)
            {
                throw new ArgumentNullException("routingKey");
            }
            if (diagnostics == null)
            {
                throw new ArgumentNullException("diagnostics");
            }
            ServerRoutingKey serverRoutingKey = routingKey as ServerRoutingKey;

            if (serverRoutingKey == null)
            {
                string message = string.Format("Routing key type {0} is not supported", routingKey.GetType());
                throw new ArgumentException(message, "routingKey");
            }
            if (!string.IsNullOrEmpty(serverRoutingKey.Server))
            {
                int?version = null;
                if (serverRoutingKey.Version != null)
                {
                    version = serverRoutingKey.Version;
                }
                else
                {
                    version = this.versionLookup.LookupVersion(serverRoutingKey.Server);
                }
                return(new SuccessfulServerRoutingEntry(serverRoutingKey, new ServerRoutingDestination(serverRoutingKey.Server, version), DateTime.UtcNow.ToFileTimeUtc()));
            }
            ErrorRoutingDestination destination = new ErrorRoutingDestination("Could not extract server from ServerRoutingKey");

            return(new FailedServerRoutingEntry(serverRoutingKey, destination, DateTime.UtcNow.ToFileTimeUtc()));
        }
コード例 #3
0
 public FailedMailboxRoutingEntry(IRoutingKey key, ErrorRoutingDestination destination, long timestamp) : base(key, timestamp)
 {
     if (destination == null)
     {
         throw new ArgumentNullException("destination");
     }
     this.destination = destination;
 }
コード例 #4
0
        private static IRoutingDestination DeserializeRoutingDestination(string type, string value)
        {
            int num = value.IndexOf('+');

            string[] properties = Array <string> .Empty;
            if (num != -1)
            {
                properties = value.Substring(num + 1).Split(new char[]
                {
                    '+'
                });
                value = value.Substring(0, num);
            }
            if (type != null)
            {
                DatabaseGuidRoutingDestination result3;
                if (!(type == "DatabaseGuid"))
                {
                    ErrorRoutingDestination result2;
                    if (!(type == "Error"))
                    {
                        if (type == "Server")
                        {
                            ServerRoutingDestination result;
                            if (ServerRoutingDestination.TryParse(value, properties, out result))
                            {
                                return(result);
                            }
                        }
                    }
                    else if (ErrorRoutingDestination.TryParse(value, properties, out result2))
                    {
                        return(result2);
                    }
                }
                else if (DatabaseGuidRoutingDestination.TryParse(value, properties, out result3))
                {
                    return(result3);
                }
            }
            return(new UnknownRoutingDestination(type, value, properties));
        }
コード例 #5
0
        public MailboxRoutingEntry GetMailboxRoutingEntry(T routingKey, IRoutingDiagnostics diagnostics)
        {
            if (routingKey == null)
            {
                throw new ArgumentNullException("routingKey");
            }
            MailboxRoutingEntry result;

            try
            {
                User user = this.FindUser(routingKey, diagnostics);
                if (user == null)
                {
                    result = this.CreateFailedEntry(routingKey, "Unable to find user");
                }
                else
                {
                    Guid?  guid           = null;
                    string resourceForest = null;
                    this.SelectDatabaseGuidResourceForest(routingKey, user, out guid, out resourceForest);
                    if (guid == null)
                    {
                        result = this.CreateFailedEntry(routingKey, "User object missing database GUID");
                    }
                    else
                    {
                        long   timestamp  = (user.LastModifiedTime != null) ? user.LastModifiedTime.Value.ToFileTimeUtc() : DateTime.UtcNow.ToFileTimeUtc();
                        string domainName = this.GetDomainName(routingKey);
                        result = new SuccessfulMailboxRoutingEntry(routingKey, new DatabaseGuidRoutingDestination(guid.Value, domainName, resourceForest), timestamp);
                    }
                }
            }
            catch (UserProviderException ex)
            {
                ErrorRoutingDestination destination = new ErrorRoutingDestination(ex.Message);
                result = new FailedMailboxRoutingEntry(routingKey, destination, DateTime.UtcNow.ToFileTimeUtc());
            }
            return(result);
        }
コード例 #6
0
        IRoutingEntry IRoutingLookup.GetRoutingEntry(IRoutingKey routingKey, IRoutingDiagnostics diagnostics)
        {
            if (routingKey == null)
            {
                throw new ArgumentNullException("routingKey");
            }
            if (diagnostics == null)
            {
                throw new ArgumentNullException("diagnostics");
            }
            if (routingKey.RoutingItemType != this.validItemType)
            {
                string message = string.Format("Routing key type {0} is not supported in {1}", RoutingEntryHeaderSerializer.RoutingTypeToString(routingKey.RoutingItemType), base.GetType());
                throw new ArgumentException(message, "routingKey");
            }
            string sharedCacheKeyFromRoutingKey = this.sharedCache.GetSharedCacheKeyFromRoutingKey(routingKey);

            try
            {
                byte[] bytes;
                if (this.sharedCache.TryGet(sharedCacheKeyFromRoutingKey, out bytes, diagnostics))
                {
                    AnchorMailboxCacheEntry anchorMailboxCacheEntry = new AnchorMailboxCacheEntry();
                    anchorMailboxCacheEntry.FromByteArray(bytes);
                    if (anchorMailboxCacheEntry.Database != null)
                    {
                        DatabaseGuidRoutingDestination destination = new DatabaseGuidRoutingDestination(anchorMailboxCacheEntry.Database.ObjectGuid, anchorMailboxCacheEntry.DomainName, anchorMailboxCacheEntry.Database.PartitionFQDN);
                        return(new SuccessfulMailboxRoutingEntry(routingKey, destination, DateTime.Now.ToFileTimeUtc()));
                    }
                }
            }
            catch (SharedCacheException ex)
            {
                ErrorRoutingDestination destination2 = new ErrorRoutingDestination(ex.Message);
                return(new FailedMailboxRoutingEntry(routingKey, destination2, DateTime.UtcNow.ToFileTimeUtc()));
            }
            return(null);
        }
コード例 #7
0
        private FailedMailboxRoutingEntry CreateFailedEntry(IRoutingKey smtpRoutingKey, string message)
        {
            ErrorRoutingDestination destination = new ErrorRoutingDestination(message);

            return(new FailedMailboxRoutingEntry(smtpRoutingKey, destination, DateTime.UtcNow.ToFileTimeUtc()));
        }
コード例 #8
0
        private FailedDatabaseGuidRoutingEntry CreateFailedEntry(DatabaseGuidRoutingKey databaseGuidRoutingKey, string message)
        {
            ErrorRoutingDestination destination = new ErrorRoutingDestination(message);

            return(new FailedDatabaseGuidRoutingEntry(databaseGuidRoutingKey, destination, DateTime.UtcNow.ToFileTimeUtc()));
        }