Esempio n. 1
0
        private void OnMailItem(object sender, MailScanEventArgs e)
        {
			if (!m_continue)
				return;
			
            //need to notify clients even when we could do nothing with message.
            if (null == e.Uro)
            {
                //Skip the actual call to the audit engine. 
                //Clients need to be able to handle null notifications.
                m_traceClient.NotifyItemAudited(null);
            }
            else if (m_engine != null)
            {
                StringBuilder info = new StringBuilder();
				try
				{
					info.AppendFormat(Properties.Resources.AUDIT_PROCESS, e.Uro.Properties[MailMessagePropertyKeys.Subject]);

					System.Diagnostics.Trace.WriteLine(info.ToString(), "AuditInfo");
					Logging.Trace.WriteLine("Passing a message to the policy engine: \"" + e.Uro.Properties[MailMessagePropertyKeys.Subject] + "\"", "TraceAuditHelper.m_emailScanner_MailItem");

                    IPolicyResponseObject pro = m_engine.ProcessConditions(Workshare.Policy.RunAt.Client, e.Uro);

                    InternalExternalHelper.SetMessageRouting(pro);

					OnAuditMail(new AuditEventArgs(pro));
				}
				catch (Exception ex)
				{
					info.Remove(0, info.Length);
					info.AppendFormat(Properties.Resources.AUDIT_PROCESSEX, e.Uro.Properties[MailMessagePropertyKeys.Subject], ex.Message);
					System.Diagnostics.Trace.WriteLine(info.ToString(), "AuditInfo");
					m_traceClient.NotifyItemAudited(null);
					Logging.Trace.WriteLine(ex.Message, "TraceAuditManager.OnMailItem Exception");
				}
				finally
				{
					e.Dispose();
				}
            }
        }