コード例 #1
0
         /// <summary>
         /// Inserts Audit Log.
         /// </summary>
         /// <param name="request">The audit log request.</param>
         /// <returns>The response.</returns>
         private static NullResponse InsertAuditLog(InsertAuditLogServiceRequest request)
         {
             string storeId = string.Empty;
             string terminalId = string.Empty;
             bool auditEnabled = true;
 
             try
             {
                 var context = request.RequestContext;
 
                 if (context.GetPrincipal() != null)
                 {
                     Terminal terminal = context.GetTerminal();
                     if (terminal != null)
                     {
                         terminalId = terminal.TerminalId;
 
                         // Get device information
                         if (!context.GetPrincipal().IsChannelAgnostic)
                         {
                             try
                             {
                                 DeviceConfiguration deviceConfiguration = context.GetDeviceConfiguration();
                                 if (deviceConfiguration != null)
                                 {
                                     auditEnabled = deviceConfiguration.AuditEnabled;
                                 }
 
                                 // Try to get store information
                                 if (request.RequestContext.GetOrgUnit() != null)
                                 {
                                     storeId = request.RequestContext.GetOrgUnit().OrgUnitNumber ?? string.Empty;
                                 }
                             }
                             catch (Exception ex)
                             {
                                 // If anything bad happens, log an event and continue.
                                 RetailLogger.Log.CrtServicesLoggingServiceWriteEntryFailure(ex);
                             }
                         }
                     }
                 }
 
                 if (auditEnabled)
                 {
                     if (string.IsNullOrEmpty(storeId))
                     {
                         storeId = @"<not set>";
                     }
 
                     if (string.IsNullOrEmpty(terminalId))
                     {
                         terminalId = @"<not set>";
                     }
 
                     var dataRequest = new InsertAuditLogDataRequest(
                         request.Source,
                         request.LogEntry,
                         request.LogLevel,
                         storeId,
                         terminalId,
                         request.DurationInMilliseconds);
 
                     context.Execute<NullResponse>(dataRequest);
                 }
             }
             catch (Exception ex)
             {
                 RetailLogger.Log.CrtServicesLoggingServiceWriteEntryFailure(ex);
             }
 
             return new NullResponse();
         }
コード例 #2
0
            /// <summary>
            /// Writes an entry into the audit table.
            /// </summary>
            /// <param name="context">The request context.</param>
            /// <param name="source">The log source.</param>
            /// <param name="value">The log entry.</param>
            /// <param name="traceLevel">The trace level.</param>
            private static void LogAuditEntry(RequestContext context, string source, string value, AuditLogTraceLevel traceLevel = AuditLogTraceLevel.Trace)
            {
                var auditLogServiceRequest = new InsertAuditLogServiceRequest(source, value, traceLevel, unchecked ((int)context.RequestTimer.ElapsedMilliseconds));

                context.Execute <NullResponse>(auditLogServiceRequest);
            }