Exemple #1
0
        /// <summary>
        /// Login to SkyResponse API
        /// </summary>
        /// <returns></returns>
        public async Task Login()
        {
            _accesstoken = await _userService.GetAccessToken();

            if (!string.IsNullOrEmpty(_accesstoken))
            {
                _userService.SaveUserInfo();

                try
                {
                    await _httpRequest.RegisterForPush(_accesstoken);
                }
                catch (HttpRequestException)
                {
                    ReConnect();
                    return;
                }

                try
                {
                    var webSocketUrl = string.Concat(WebSocketUrl, _accesstoken);
                    _webSocket.Connect(webSocketUrl);
                }
                catch (WebSocketException)
                {
                    ReConnect();
                    return;
                }

                _webSocket.OnMessage(OnMessageAsync);
                _webSocket.OnDisconnect(OnDisconnect);
            }
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        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 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 StateAuditLogger(IWebSocketPool webSocketFactory)
 {
     _webSocketFactory = webSocketFactory;
     _ws = webSocketFactory.Acquire(Config.Auditing.Endpoint);
     _ws.Connect();
 }
Exemple #6
0
 public StateAuditLogger(IWebSocketFactory webSocketFactory)
 {
     _webSocketFactory = webSocketFactory;
     _ws = webSocketFactory.New();
     _ws.Connect();
 }