コード例 #1
0
        internal static MailboxReplicationServiceClient Create(IConfigurationSession session, MRSJobType jobType, Guid mdbGuid, List <string> unreachableMrsServers)
        {
            MRSCapabilities     requiredCapability = RequestJobXML.MapJobTypeToCapability(jobType);
            string              text = null;
            DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.None);

            if (!string.IsNullOrEmpty(databaseInformation.ServerFqdn))
            {
                text = databaseInformation.ServerFqdn.ToLower(CultureInfo.InvariantCulture);
            }
            List <string> mrsServers = MailboxReplicationServiceClient.GetMrsServers(session, mdbGuid);
            List <string> list       = new List <string>(mrsServers.Count);

            foreach (string text2 in mrsServers)
            {
                string text3 = text2.ToLower(CultureInfo.InvariantCulture);
                if (string.Compare(text3, text, CultureInfo.InvariantCulture, CompareOptions.Ordinal) != 0 && !unreachableMrsServers.Contains(text3))
                {
                    list.Add(text2);
                }
            }
            List <string> list2 = CommonUtils.RandomizeSequence <string>(list);

            if (text != null)
            {
                list2.Insert(0, text);
            }
            foreach (string text4 in list2)
            {
                try
                {
                    return(MailboxReplicationServiceClient.Create(text4, requiredCapability));
                }
                catch (MailboxReplicationPermanentException ex)
                {
                    MrsTracer.Common.Warning("Attempt to connect to CAS Server {0} failed with error: {1}", new object[]
                    {
                        text4,
                        CommonUtils.FullExceptionMessage(ex)
                    });
                }
                catch (MailboxReplicationTransientException ex2)
                {
                    MrsTracer.Common.Warning("Attempt to connect to CAS Server {0} failed with error: {1}", new object[]
                    {
                        text4,
                        CommonUtils.FullExceptionMessage(ex2)
                    });
                }
                unreachableMrsServers.Add(text4.ToLower(CultureInfo.InvariantCulture));
            }
            throw new NoMRSAvailableTransientException();
        }
コード例 #2
0
 public static MailboxReplicationServiceClient Create(string serverName, MRSJobType jobType)
 {
     return(MailboxReplicationServiceClient.Create(serverName, RequestJobXML.MapJobTypeToCapability(jobType)));
 }