private void SendMessage(LogEntry logEntry) { if (IsValidLogLevel(logEntry.LogLevel.ToString())) { IWebSocketWrapper _ws = null; try { _ws = _webSocketPool.Acquire(Dev2.Common.Config.Auditing.Endpoint); if (!_ws.IsOpen()) { _ws.Connect(); } var logCommand = new AuditCommand { Type = "LogEntryCommand", LogEntry = logEntry }; var msg = _serializer.Serialize(logCommand); _ws.SendMessage(msg); } finally { _webSocketPool.Release(_ws); } } }
public void LogAuditState(Object logEntry) { try { Enum.TryParse(Config.Server.ExecutionLogLevel, out LogLevel executionLogLevel); if (logEntry is Audit auditLog && IsValidLogLevel(executionLogLevel, auditLog.LogLevel.ToString())) { _ws = _webSocketFactory.Acquire(Config.Auditing.Endpoint); _ws.Connect(); var auditCommand = new AuditCommand { Audit = auditLog, Type = "LogEntry" }; string json = JsonConvert.SerializeObject(auditCommand); _ws.SendMessage(json); } } catch (Exception e) { Dev2Logger.Error("LogAuditState", e.Message); } finally { if (_ws != null) { _webSocketFactory.Release(_ws); _ws = null; } } }
public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { IWebSocketWrapper client = null; try { var serializer = new Dev2JsonSerializer(); var result = new List <IExecutionHistory>(); if (values == null) { throw new InvalidDataContractException(ErrorResource.NoParameter); } values.TryGetValue("ResourceId", out StringBuilder triggerID); if (triggerID != null) { client = _webSocketPool.Acquire(Config.Auditing.Endpoint).Connect(); Dev2Logger.Info("Get Execution History Data from Logger Service. " + triggerID, GlobalConstants.WarewolfInfo); var response = ""; var message = new AuditCommand { Type = "TriggerQuery", Query = values }; try { var ewh = new EventWaitHandle(false, EventResetMode.ManualReset); client.OnMessage((msgResponse, socket) => { response = msgResponse; result.AddRange(serializer.Deserialize <List <ExecutionHistory> >(response)); ewh.Set(); }); client.SendMessage(serializer.Serialize(message)); ewh.WaitOne(_waitTimeOut); return(serializer.SerializeToBuilder(result)); } catch (Exception e) { Dev2Logger.Info("Get Execution History Data ServiceError", e, GlobalConstants.WarewolfInfo); } return(serializer.SerializeToBuilder(result)); } Dev2Logger.Debug("No QueueName Provided", GlobalConstants.WarewolfDebug); return(serializer.SerializeToBuilder(new List <IExecutionHistory>())); } catch (Exception err) { Dev2Logger.Error(err, GlobalConstants.WarewolfError); throw; } finally { if (client != null) { _webSocketPool.Release(client); } } }
public void Publish(byte[] value) { IWebSocketWrapper _ws = null; try { _ws = _webSocketPool.Acquire(Config.Auditing.Endpoint); _ws.SendMessage(value); } finally { _webSocketPool.Release(_ws); } }
public void LogAuditState(Object logEntry) { if (!_ws.IsOpen()) { _ws = _webSocketFactory.Acquire(Config.Auditing.Endpoint); _ws.Connect(); } if (logEntry is Audit auditLog) { var auditCommand = new AuditCommand { Audit = auditLog, Type = "LogEntry" }; string json = JsonConvert.SerializeObject(auditCommand); _ws.SendMessage(json); } }
public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { IWebSocketWrapper client = null; Dev2Logger.Info("Get Log Data Service", GlobalConstants.WarewolfInfo); var serializer = new Dev2JsonSerializer(); var result = new List <Audit>(); var response = ""; var message = new AuditCommand() { Type = "LogQuery", Query = values }; try { client = _webSocketPool.Acquire(Config.Auditing.Endpoint).Connect(); var ewh = new EventWaitHandle(false, EventResetMode.ManualReset); client.OnMessage((msgResponse, socket) => { response = msgResponse; result.AddRange(serializer.Deserialize <List <Audit> >(response)); ewh.Set(); }); client.SendMessage(serializer.Serialize(message)); ewh.WaitOne(_waitTimeOut); LogDataCache.CurrentResults = result; return(serializer.SerializeToBuilder(result)); } catch (Exception e) { Dev2Logger.Info("Get Log Data ServiceError", e, GlobalConstants.WarewolfInfo); } finally { _webSocketPool.Release(client); } return(serializer.SerializeToBuilder("")); }
private void SendMessage(string jsonLogEntry) { IWebSocketWrapper client = null; try { client = _webSocketFactory.Acquire(Config.Auditing.Endpoint); if (!client.IsOpen()) { client = _webSocketFactory.Acquire(Config.Auditing.Endpoint); } client.SendMessage(jsonLogEntry); } catch (Exception ex) { Dev2Logger.Error("LogAuditState", ex.InnerException == null ? ex.Message : ex.InnerException.Message); } finally { _webSocketFactory.Release(client); } }