Base class for Audit helpers.
コード例 #1
0
ファイル: AuditLogHelper.cs プロジェクト: hksonngan/Xian
 /// <summary>
 /// Logs an event to the audit log using the format as described in DICOM Supplement 95.
 /// </summary>
 /// <param name="message">The audit message to log.</param>
 public static void Log(DicomAuditHelper message)
 {
     if (AuditingEnabled)
     {
         AuditLog.WriteEntry(message.Operation, message.Serialize(false));
     }
 }
コード例 #2
0
ファイル: AuditLogHelper.cs プロジェクト: hksonngan/Xian
 /// <summary>
 /// Logs an event to the audit log using the format as described in DICOM Supplement 95.
 /// </summary>
 /// <remarks>
 /// Use this overload to explicitly specify the user and session ID.
 /// </remarks>
 /// <param name="message">The audit message to log.</param>
 /// <param name="username"></param>
 /// <param name="sessionId"></param>
 private static void Log(DicomAuditHelper message, string username, string sessionId)
 {
     if (AuditingEnabled)
     {
         AuditLog.WriteEntry(message.Operation, message.Serialize(false), username, sessionId);
     }
 }
コード例 #3
0
ファイル: AuditHelper.cs プロジェクト: nhannd/Xian
		/// <summary>
		/// Logs an event to the audit log using the format as described in DICOM Supplement 95.
		/// </summary>
		/// <param name="message">The audit message to log.</param>
		public static void Log(DicomAuditHelper message)
		{
			AuditLogHelper.Log(message);
		}
コード例 #4
0
        /// <summary>
        /// Log an Audit message.
        /// </summary>
        /// <param name="helper"></param>
        public static void LogAuditMessage(DicomAuditHelper helper)
        {
			// Found doing this on the local thread had a performance impact with some DICOM operations,
			// make run as a task in the background to make it work faster.
	        
	        Task.Factory.StartNew(delegate
		        {
			        lock (_syncLock)
			        {
				        if (_log == null)
					        _log = new AuditLog(ProductInformation.Component, "DICOM");

				        string serializeText = null;
				        try
				        {
					        serializeText = helper.Serialize(false);
							_log.WriteEntry(helper.Operation, serializeText, GetUserName(), GetUserSessionId());
				        }
				        catch (Exception ex)
				        {
					        Platform.Log(LogLevel.Error, ex, "Error occurred when writing audit log");

					        var sb = new StringBuilder();
					        sb.AppendLine("Audit Log failed to save:");
					        sb.AppendLine(String.Format("Operation: {0}", helper.Operation));
					        sb.AppendLine(String.Format("Details: {0}", serializeText));
					        Platform.Log(LogLevel.Info, sb.ToString());
				        }
			        }
		        });
        }
コード例 #5
0
		/// <summary>
		/// Log an Audit message.
		/// </summary>
		/// <param name="helper"></param>
		public static void LogAuditMessage(DicomAuditHelper helper)
		{
			lock (_syncLock)
			{
				if (_log == null)
					_log = new AuditLog(ProductInformation.Component,"DICOM");

                string serializeText = null;
                try
                {
                    serializeText = helper.Serialize(false);
                    _log.WriteEntry(helper.Operation, serializeText);
                }
                catch(Exception ex)
                {
                    Platform.Log(LogLevel.Error, ex, "Error occurred when writing audit log");

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Audit Log failed to save:");
                    sb.AppendLine(String.Format("Operation: {0}", helper.Operation));
                    sb.AppendLine(String.Format("Details: {0}", serializeText));
                    Platform.Log(LogLevel.Info, sb.ToString());
                }
			}
		}