예제 #1
0
        private ADRawEntry GetADRawEntry(ulong puid, string emailAddress)
        {
            ADRawEntry result;

            try
            {
                List <ADPropertyDefinition> properties = new List <ADPropertyDefinition>(new ADPropertyDefinition[]
                {
                    ADMailboxRecipientSchema.ExchangeGuid,
                    ADUserSchema.NetID,
                    ADMailboxRecipientSchema.Database,
                    ADUserSchema.PrimaryMailboxSource,
                    ADUserSchema.SatchmoClusterIp,
                    ADUserSchema.SatchmoDGroup,
                    ADUserSchema.FblEnabled
                });
                ADRawEntry adrawEntry = this.tenantRecipientSession.FindByExchangeGuid(ConsumerIdentityHelper.GetExchangeGuidFromPuid(puid), properties) ?? this.tenantRecipientSession.FindByProxyAddress(ProxyAddress.Parse(emailAddress), properties);
                FBLPerfCounters.NumberOfSuccessfulMSERVReadRequests.Increment();
                result = adrawEntry;
            }
            catch (Exception ex)
            {
                FBLPerfCounters.NumberOfFailedMSERVReadRequests.Increment();
                LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_TransientFblErrorReadingMServ, new object[]
                {
                    ex.InnerException ?? ex
                });
                throw;
            }
            return(result);
        }
예제 #2
0
        private bool TryUpdateMservEntry(ADUser user, FblRequestParameters fblRequestParameters)
        {
            bool result;

            try
            {
                if (user == null || fblRequestParameters == null)
                {
                    result = false;
                }
                else
                {
                    if (this.tenantRecipientSession is IAggregateSession)
                    {
                        ((IAggregateSession)this.tenantRecipientSession).MbxReadMode = MbxReadMode.NoMbxRead;
                    }
                    user[ADUserSchema.FblEnabled] = fblRequestParameters.OptIn;
                    this.tenantRecipientSession.Save(user);
                    FBLPerfCounters.NumberOfSuccessfulMSERVWriteRequests.Increment();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                FBLPerfCounters.NumberOfFailedMSERVWriteRequests.Increment();
                LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_TransientFblErrorUpdatingMServ, new object[]
                {
                    ex.InnerException ?? ex
                });
                result = false;
            }
            return(result);
        }
예제 #3
0
 private void ProcessClassificationRequest(FblRequestParameters fblRequestParameters)
 {
     if (fblRequestParameters == null)
     {
         return;
     }
     Task.Factory.StartNew(delegate()
     {
         FBLPerfCounters.NumberOfFblClassificationRequestsReceived.Increment();
         ADRawEntry adrawEntry = this.GetADRawEntry(fblRequestParameters.Puid, fblRequestParameters.PrimaryEmail);
         if (!this.IsFblUser(adrawEntry))
         {
             FBLPerfCounters.NumberOfFblClassificationRequestsSuccessfullyProcessed.Increment();
             return;
         }
         if (this.TryPrepareAndSendXmrMessage(fblRequestParameters, "*****@*****.**"))
         {
             FBLPerfCounters.NumberOfFblClassificationRequestsSuccessfullyProcessed.Increment();
             return;
         }
         FBLPerfCounters.NumberOfFblClassificationRequestsFailed.Increment();
     }).ContinueWith(delegate(Task t)
     {
         if (t.Exception != null)
         {
             FBLPerfCounters.NumberOfFblClassificationRequestsFailed.Increment();
             Exception innerException = t.Exception.Flatten().InnerException;
             LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_FblUnableToProcessRequest, new object[]
             {
                 innerException
             });
         }
     }, TaskContinuationOptions.OnlyOnFaulted);
 }
예제 #4
0
        internal bool TryProcessFbl(string queryParams, out bool?isClassifyRequest, out bool?isOptIn)
        {
            isClassifyRequest = null;
            isOptIn           = null;
            FblRequestParameters fblRequestParameters = null;
            bool result;

            try
            {
                FBLPerfCounters.NumberOfFblRequestsReceived.Increment();
                if (!this.FblEnabled)
                {
                    result = true;
                }
                else if (string.IsNullOrEmpty(queryParams))
                {
                    FBLPerfCounters.NumberOfFblRequestsFailed.Increment();
                    result = false;
                }
                else
                {
                    fblRequestParameters = this.DecryptAndParseUrlParameters(queryParams);
                    if (fblRequestParameters == null)
                    {
                        result = false;
                    }
                    else
                    {
                        if (fblRequestParameters.IsClassifyRequest())
                        {
                            isClassifyRequest = new bool?(true);
                            this.ProcessClassificationRequest(fblRequestParameters);
                        }
                        else
                        {
                            isClassifyRequest = new bool?(false);
                            isOptIn           = new bool?(fblRequestParameters.OptIn);
                            if (!this.TryProcessSubscriptionRequest(fblRequestParameters))
                            {
                                FBLPerfCounters.NumberOfFblRequestsFailed.Increment();
                                return(false);
                            }
                        }
                        FBLPerfCounters.NumberOfFblRequestsSuccessfullyProcessed.Increment();
                        result = true;
                    }
                }
            }
            catch (Exception ex)
            {
                FBLPerfCounters.NumberOfFblRequestsFailed.Increment();
                LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_FblUnableToProcessRequest, new object[]
                {
                    ex.InnerException ?? ex
                });
                result = (fblRequestParameters != null && fblRequestParameters.IsClassifyRequest());
            }
            return(result);
        }
예제 #5
0
        private bool TryProcessSubscriptionRequest(FblRequestParameters fblRequestParameters)
        {
            if (fblRequestParameters == null)
            {
                return(false);
            }
            ExPerformanceCounter exPerformanceCounter       = fblRequestParameters.OptIn ? FBLPerfCounters.NumberOfFblOptInRequestsReceived : FBLPerfCounters.NumberOfFblOptOutRequestsReceived;
            ExPerformanceCounter successSubscriptionCounter = fblRequestParameters.OptIn ? FBLPerfCounters.NumberOfFblOptInRequestsSuccessfullyProcessed : FBLPerfCounters.NumberOfFblOptOutRequestsSuccessfullyProcessed;
            ExPerformanceCounter failedSubscriptionCounter  = fblRequestParameters.OptIn ? FBLPerfCounters.NumberOfFblOptInRequestsFailed : FBLPerfCounters.NumberOfFblOptOutRequestsFailed;

            try
            {
                FBLPerfCounters.NumberOfFblSubscriptionRequestsReceived.Increment();
                exPerformanceCounter.Increment();
                ADUser aduser = this.GetADUser(fblRequestParameters.Puid, fblRequestParameters.PrimaryEmail);
                if (aduser == null || !this.TryUpdateMservEntry(aduser, fblRequestParameters))
                {
                    FBLPerfCounters.NumberOfFblSubscriptionRequestsFailed.Increment();
                    failedSubscriptionCounter.Increment();
                    return(false);
                }
                Task.Factory.StartNew(delegate()
                {
                    if (this.TryPrepareAndSendXmrMessage(fblRequestParameters, "*****@*****.**"))
                    {
                        FBLPerfCounters.NumberOfFblSubscriptionRequestsSuccessfullyProcessed.Increment();
                        successSubscriptionCounter.Increment();
                        return;
                    }
                    FBLPerfCounters.NumberOfFblSubscriptionRequestsFailed.Increment();
                    failedSubscriptionCounter.Increment();
                }).ContinueWith(delegate(Task t)
                {
                    if (t.Exception != null)
                    {
                        FBLPerfCounters.NumberOfFblSubscriptionRequestsFailed.Increment();
                        failedSubscriptionCounter.Increment();
                        Exception innerException = t.Exception.Flatten().InnerException;
                        LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_FblUnableToProcessRequest, new object[]
                        {
                            innerException
                        });
                    }
                }, TaskContinuationOptions.OnlyOnFaulted);
            }
            catch (Exception ex)
            {
                FBLPerfCounters.NumberOfFblSubscriptionRequestsFailed.Increment();
                failedSubscriptionCounter.Increment();
                LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_FblUnableToProcessRequest, new object[]
                {
                    ex.InnerException ?? ex
                });
                return(false);
            }
            return(true);
        }
예제 #6
0
        private ADUser GetADUser(ulong puid, string emailAddress)
        {
            ADUser result;

            try
            {
                ADUser aduser = ((ADUser)this.tenantRecipientSession.FindByObjectGuid(ConsumerIdentityHelper.GetExchangeGuidFromPuid(puid))) ?? this.tenantRecipientSession.FindByProxyAddress <ADUser>(ProxyAddress.Parse(emailAddress));
                FBLPerfCounters.NumberOfSuccessfulMSERVReadRequests.Increment();
                result = aduser;
            }
            catch (Exception ex)
            {
                FBLPerfCounters.NumberOfFailedMSERVReadRequests.Increment();
                LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_TransientFblErrorReadingMServ, new object[]
                {
                    ex.InnerException ?? ex
                });
                throw;
            }
            return(result);
        }
예제 #7
0
 private bool TryPrepareAndSendXmrMessage(FblRequestParameters fblRequestParameters, string recipientAddress)
 {
     if (fblRequestParameters == null || string.IsNullOrEmpty(recipientAddress))
     {
         return(false);
     }
     try
     {
         EmailMessage msg = this.CreateFblRequestMessage(fblRequestParameters);
         this.SendMessage(msg, recipientAddress);
         FBLPerfCounters.NumberOfXMRMessagesSuccessfullySent.Increment();
         return(true);
     }
     catch (FailedToConnectToSMTPServerException ex)
     {
         LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_FblFailedToConnectToSmtpServer, new object[]
         {
             ex
         });
     }
     catch (UnexpectedSmtpServerResponseException ex2)
     {
         LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_FblSmtpServerResponse, new object[]
         {
             ex2
         });
     }
     catch (Exception ex3)
     {
         LoggingUtilities.LogEvent(ClientsEventLogConstants.Tuple_FblErrorSendingMessage, new object[]
         {
             ex3.InnerException ?? ex3
         });
     }
     FBLPerfCounters.NumberOfXMRMessagesFailedToSend.Increment();
     return(false);
 }