Exemple #1
0
        public override void Work()
        {
            Thread.Sleep(15000);
            int num = 1440;

            for (;;)
            {
                try
                {
                    if (!int.TryParse(ConfigurationManager.AppSettings["CertificateNotificationPollIntervalInMinutes"], out num))
                    {
                        num = 1440;
                    }
                }
                catch (ConfigurationException)
                {
                    num = 1440;
                }
                if (num <= 0 || num > 14400)
                {
                    num = 1440;
                }
                try
                {
                    if (!int.TryParse(ConfigurationManager.AppSettings["CertificateNotificationWarningDays"], out this.warningDays))
                    {
                        this.warningDays = 30;
                    }
                }
                catch (ConfigurationException)
                {
                    this.warningDays = 30;
                }
                if (this.warningDays <= 0 || this.warningDays > 400)
                {
                    this.warningDays = 30;
                }
                this.adSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 185, "Work", "f:\\15.00.1497\\sources\\dev\\Management\\src\\ServiceHost\\Servicelets\\CertificateNotification\\Program\\CertificateNotificationServicelet.cs");
                this.orgId     = ADSessionSettings.FromRootOrgScopeSet().CurrentOrganizationId;
                ExchangeCertificateRpc exchangeCertificateRpc = new ExchangeCertificateRpc();
                byte[] outputBlob = null;
                ExchangeCertificateRpcClient  exchangeCertificateRpcClient  = null;
                ExchangeCertificateRpcClient2 exchangeCertificateRpcClient2 = null;
                try
                {
                    IEnumerable <Server> objects = new ServerIdParameter().GetObjects <Server>(this.orgId.ConfigurationUnit, this.adSession);
                    if (objects == null || objects.Count <Server>() == 0)
                    {
                        goto IL_28B;
                    }
                    this.serverObj = objects.First <Server>();
                    ExchangeCertificateRpcVersion exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version1;
                    try
                    {
                        byte[] inBlob = exchangeCertificateRpc.SerializeInputParameters(ExchangeCertificateRpcVersion.Version2);
                        exchangeCertificateRpcClient2 = new ExchangeCertificateRpcClient2(this.serverObj.Name);
                        outputBlob = exchangeCertificateRpcClient2.GetCertificate2(0, inBlob);
                        exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version2;
                    }
                    catch (RpcException)
                    {
                        exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version1;
                    }
                    if (exchangeCertificateRpcVersion == ExchangeCertificateRpcVersion.Version1)
                    {
                        byte[] inBlob2 = exchangeCertificateRpc.SerializeInputParameters(exchangeCertificateRpcVersion);
                        exchangeCertificateRpcClient = new ExchangeCertificateRpcClient(this.serverObj.Name);
                        outputBlob = exchangeCertificateRpcClient.GetCertificate(0, inBlob2);
                    }
                    ExchangeCertificateRpc exchangeCertificateRpc2 = new ExchangeCertificateRpc(exchangeCertificateRpcVersion, null, outputBlob);
                    this.UpdateDataInMbx(exchangeCertificateRpc2.ReturnCertList);
                }
                catch (RpcClientException ex)
                {
                    this.EventLog.LogEvent(CertificateNotificationEventLogConstants.Tuple_TransientException, string.Empty, new object[]
                    {
                        ex.ToString()
                    });
                }
                catch (LocalizedException ex2)
                {
                    this.EventLog.LogEvent(CertificateNotificationEventLogConstants.Tuple_TransientException, string.Empty, new object[]
                    {
                        ex2.ToString()
                    });
                }
                catch (RpcException ex3)
                {
                    this.EventLog.LogEvent(CertificateNotificationEventLogConstants.Tuple_TransientException, string.Empty, new object[]
                    {
                        ex3.ToString()
                    });
                }
                finally
                {
                    if (exchangeCertificateRpcClient2 != null)
                    {
                        exchangeCertificateRpcClient2.Dispose();
                    }
                    if (exchangeCertificateRpcClient != null)
                    {
                        exchangeCertificateRpcClient.Dispose();
                    }
                    this.adSession         = null;
                    this.asyncDataProvider = null;
                    this.serverObj         = null;
                    this.orgId             = null;
                }
                goto IL_252;
IL_28B:
                if (base.StopEvent.WaitOne(TimeSpan.FromMinutes((double)num), false))
                {
                    break;
                }
                continue;
IL_252:
                this.EventLog.LogEvent(CertificateNotificationEventLogConstants.Tuple_OneRoundCompleted, string.Empty, new object[]
                {
                    ExDateTime.Now.AddMinutes((double)num)
                });
                goto IL_28B;
            }
        }