static void Logger_Logged(object sender, LogEventArgs e) { try { DicomLogEntry entry = e.LogEntry as DicomLogEntry; if (entry != null && entry.DicomDataset != null) { LoggingModuleConfigurationManager loggingConfigManager = ServiceLocator.Retrieve <LoggingModuleConfigurationManager> ( ); if (null == loggingConfigManager) { return; } LoggingState state = loggingConfigManager.GetLoggingState( ); if (state.EnableLogging && state.EnableThreading && state.LogDicomDataSet && state.LogDicom) { try { entry.DicomDataset.Dispose(); } catch { } } } } catch {} }
public void Log(string user, string workstation, DateTime date, string details, XmlDocument extra) { DicomLogEntry logEntry = new DicomLogEntry() { LogType = LogType.Audit }; logEntry.Description = details; //logEntry.CustomInformation = additionalInfo; logEntry.TimeStamp = date; logEntry.Source = "AuditLogAddin"; logEntry.ClientAETitle = user; logEntry.ClientIPAddress = workstation; if (extra != null) { Dictionary <string, string> extraData = new Dictionary <string, string>(); XmlNodeList list = extra.GetElementsByTagName("extra"); string extraInfo = string.Empty; if (list.Count > 0) { extraData = list[0].ChildNodes.Cast <XmlNode>().ToDictionary(node => node.Name, node => node.InnerText); } extraInfo = string.Join("\n", extraData.Select(x => x.Key + " = " + x.Value).ToArray()); logEntry.Description += "\n\n" + extraInfo; } _DataAccessAgent.AddDicomEventLog(logEntry); }
private void WriteLog(string description, LogType type) { DicomLogEntry logEnrty = new DicomLogEntry( ); logEnrty.Command = Leadtools.Dicom.DicomCommandType.Undefined; logEnrty.Description = description; logEnrty.LogType = type; logEnrty.MachineName = Environment.MachineName; logEnrty.MessageDirection = MessageDirection.None; logEnrty.TimeStamp = DateTime.Now; Logger.Global.Log(logEnrty); }
private static void Log(string message, LogType logType) { DicomLogEntry logEntry = new DicomLogEntry( ); if (null != UserManager.User) { logEntry.ClientAETitle = UserManager.User.FriendlyName; } logEntry.LogType = logType; logEntry.Description = message; Logger.Global.Log(logEntry); }
public static void AddDicomEventLog(DicomLogEntry logEntry) { try { using (SqlCeConnection DbConnection = new SqlCeConnection(ConfigurationLoggingSession.ConnectionString)) { DbConnection.Open(); using (SqlCeCommand insertCommand = DbConnection.CreateCommand()) { insertCommand.CommandText = @"INSERT INTO [DICOMServerEventLog] ([ServerAETitle], [ServerIPAddress], [ServerPort], [ClientAETitle], [ClientHostAddress], [ClientPort], [Command], [EventDateTime], [Type], [MessageDirection], [Description], [CustomInformation], [DatasetPath]) VALUES (@ServerAETitle, @ServerIPAddress, @ServerPort, @ClientAETitle, @ClientHostAddress, @ClientPort, @Command, @EventDateTime, @Type, @MessageDirection, @Description, @CustomInformation, @DatasetPath)"; insertCommand.CommandType = CommandType.Text; insertCommand.Parameters.AddWithValue("@ServerAETitle", /*DbType.String,*/ logEntry.ServerAETitle); insertCommand.Parameters.AddWithValue("@ServerIPAddress", /*DbType.String,*/ logEntry.ServerIPAddress); insertCommand.Parameters.AddWithValue("@ServerPort", /*DbType.Int32,*/ logEntry.ServerPort); insertCommand.Parameters.AddWithValue("@ClientAETitle", /*DbType.String,*/ logEntry.ClientAETitle); insertCommand.Parameters.AddWithValue("@ClientHostAddress", /*DbType.String,*/ logEntry.ClientIPAddress); insertCommand.Parameters.AddWithValue("@ClientPort", /*DbType.Int32,*/ logEntry.ClientPort); insertCommand.Parameters.AddWithValue("@Command", /*DbType.String,*/ logEntry.Command.ToString()); insertCommand.Parameters.AddWithValue("@EventDateTime", /*DbType.DateTime,*/ logEntry.TimeStamp); insertCommand.Parameters.AddWithValue("@Type", /*DbType.String,*/ logEntry.LogType.ToString()); insertCommand.Parameters.AddWithValue("@MessageDirection", /*DbType.String,*/ logEntry.MessageDirection.ToString()); insertCommand.Parameters.AddWithValue("@Description", /*DbType.String,*/ logEntry.Description); insertCommand.Parameters.AddWithValue("@CustomInformation", /*DbType.Binary,*/ string.Empty); string fullPath = string.Empty; if (logEntry.DicomDataset != null && !string.IsNullOrEmpty(ConfigurationLoggingSession.LogDatasetDirectory)) { string fileName = Path.GetRandomFileName(); fullPath = Path.Combine(ConfigurationLoggingSession.LogDatasetDirectory, fileName); logEntry.DicomDataset.Save(fullPath, Leadtools.Dicom.DicomDataSetSaveFlags.None); } insertCommand.Parameters.AddWithValue("@DatasetPath", /*DbType.String,*/ fullPath); insertCommand.ExecuteNonQuery(); } } } catch (Exception exception) { System.Diagnostics.Debug.Assert(false); throw exception; } }
public static void FlushLogs(Logger logger, string user) { lock ( _lock ) { while (_audits.Count != 0) { DicomLogEntry logEntry = new DicomLogEntry( ); logEntry.ClientAETitle = user; logEntry.Description = _audits [0].ToString( ); logEntry.LogType = LogType.Audit; logger.Log(logEntry); _audits.RemoveAt(0); } } }
public static void Log(ILoggingDataAccessAgent loggingAgent, string authUser, string description) { DicomLogEntry logEntry = new DicomLogEntry() { LogType = LogType.Audit }; logEntry.Description = description; logEntry.ClientAETitle = authUser; logEntry.ClientIPAddress = GetClientIp(); logEntry.TimeStamp = DateTime.Now; logEntry.Source = "AuditLogAddin"; if (!string.IsNullOrEmpty(logEntry.ClientAETitle) && logEntry.ClientAETitle.Length > 16) { logEntry.ClientAETitle = logEntry.ClientAETitle.Substring(0, 16); } loggingAgent.AddDicomEventLog(logEntry); }
public static void LogMessage(string description, LogType logType) { DicomLogEntry logEntry = new DicomLogEntry( ); logEntry.LogType = logType; if (UserManager.User != null) { logEntry.ClientAETitle = UserManager.User.FriendlyName; } else { IOptionsDataAccessAgent optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); string lastUser = optionsAgent.Get <string>("LastUser", string.Empty); logEntry.ClientAETitle = lastUser; } logEntry.Description = description; Logger.Global.Log(logEntry); }
private static DicomDataSet Copy(DicomDataSet dsOriginal) { DicomDataSet copy = new DicomDataSet(); AutoResetEvent copyEvent = new AutoResetEvent(false); if (dsOriginal == null) { return(null); } try { copy.Copy(dsOriginal, null, null, DicomCopyCallback); } catch (Exception e) { Exception ex = e; string errorMessage = string.Empty; while (ex != null) { errorMessage += ex.ToString() + "\r\n"; ex = ex.InnerException; } try { DicomLogEntry logEntry = new DicomLogEntry(); logEntry.ClientAETitle = "Logger"; logEntry.Description = errorMessage; logEntry.LogType = LogType.Error; Logger.Global.Log(logEntry); } catch { } } return(copy); }
public void WriteLog(ILogEntry logEntry) { DicomLogEntry dicomLogEntry = (DicomLogEntry)logEntry; DB.AddDicomEventLog(dicomLogEntry); }