Beispiel #1
0
        public static void LogSignal(OfficeGraphSignalType signalType, string signal, string organizationId, string sharePointUrl)
        {
            LogRowFormatter logRowFormatter = new LogRowFormatter(OfficeGraphLog.officeGraphLogSchema);

            logRowFormatter[1] = signalType.ToString();
            logRowFormatter[2] = signal;
            logRowFormatter[3] = organizationId;
            logRowFormatter[4] = sharePointUrl;
            OfficeGraphLog.Append(logRowFormatter);
        }
 public void DeliveredMessageEventHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args)
 {
     try
     {
         StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = args as StoreDriverDeliveryEventArgsImpl;
         if (storeDriverDeliveryEventArgsImpl != null && this.IsInputValid(storeDriverDeliveryEventArgsImpl))
         {
             VariantConfigurationSnapshot snapshot = VariantConfiguration.GetSnapshot(storeDriverDeliveryEventArgsImpl.MailboxOwner.GetContext(null), null, null);
             if (snapshot.OfficeGraph.OfficeGraphAgent.Enabled)
             {
                 OfficeGraph.ItemsSeen.Increment();
                 bool flag = false;
                 OfficeGraphSignalType signalType = OfficeGraphSignalType.Attachment;
                 string   signal  = string.Empty;
                 bool     enabled = snapshot.OfficeGraph.OfficeGraphGenerateSignals.Enabled;
                 DateTime utcNow  = DateTime.UtcNow;
                 storeDriverDeliveryEventArgsImpl.MessageItem.Load();
                 string sharePointUrl;
                 List <Dictionary <string, string> > attachmentsProperties;
                 if (this.IsInterestingMailWithAttachments(storeDriverDeliveryEventArgsImpl.MessageItem, storeDriverDeliveryEventArgsImpl.MailboxSession, out sharePointUrl, out attachmentsProperties))
                 {
                     OfficeGraph.ItemsFilteredTotal.Increment();
                     if (enabled)
                     {
                         signal     = OfficeGraphAgentUtils.CreateAttachmentsSignal(storeDriverDeliveryEventArgsImpl.MessageItem, attachmentsProperties, storeDriverDeliveryEventArgsImpl.MailboxOwner.PrimarySmtpAddress.ToString(), storeDriverDeliveryEventArgsImpl.MailItem.TenantId);
                         signalType = OfficeGraphSignalType.Attachment;
                         flag       = true;
                     }
                     else
                     {
                         OfficeGraphAgent.tracer.TraceDebug((long)this.traceId, "Skipped generating signal since feature disabled.");
                     }
                 }
                 else
                 {
                     OfficeGraphAgent.tracer.TraceDebug((long)this.traceId, "Skipped item since it did not pass filter criteria.");
                 }
                 if (flag)
                 {
                     TimeSpan timeSpan = DateTime.UtcNow - utcNow;
                     OfficeGraph.LastSignalCreationTime.RawValue = (long)timeSpan.TotalMilliseconds;
                     OfficeGraph.AverageSignalCreationTime.IncrementBy((long)timeSpan.TotalMilliseconds);
                     OfficeGraph.AverageSignalCreationTimeBase.Increment();
                     utcNow = DateTime.UtcNow;
                     byte[] bytes          = storeDriverDeliveryEventArgsImpl.MailboxSession.OrganizationId.GetBytes(Encoding.ASCII);
                     string organizationId = Convert.ToBase64String(bytes);
                     OfficeGraphLog.LogSignal(signalType, signal, organizationId, sharePointUrl);
                     timeSpan = DateTime.UtcNow - utcNow;
                     OfficeGraph.LastSignalPersistingTime.RawValue = (long)timeSpan.TotalMilliseconds;
                     OfficeGraph.AverageSignalPersistingTime.IncrementBy((long)timeSpan.TotalMilliseconds);
                     OfficeGraph.AverageSignalPersistingTimeBase.Increment();
                     OfficeGraph.SignalPersisted.Increment();
                 }
             }
             else
             {
                 OfficeGraphAgent.tracer.TraceDebug((long)this.traceId, "Skipped item since agent is disabled.");
             }
         }
     }
     catch (Exception ex)
     {
         OfficeGraph.TotalExceptions.Increment();
         OfficeGraphAgent.tracer.TraceError <Exception>((long)this.traceId, "OfficeGraphAgent.DeliveredMessageEventHandler encountered an exception: {0}", ex);
         StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_OfficeGraphAgentException, ex.Message, new object[]
         {
             ex
         });
     }
 }
 static OfficeGraphAgent()
 {
     OfficeGraphLog.Start();
 }