protected async Task LogWebAction(string lowellRef, string userId, WebActionType webActionType) { try { if (string.IsNullOrWhiteSpace(lowellRef) && string.IsNullOrWhiteSpace(userId)) { _logger.LogError($"Failed to send web log for WebActionId:{(int)webActionType}, as both lowell ref and user id is null or empty."); } else if (!string.IsNullOrWhiteSpace(userId) && !Guid.TryParse(userId, out var userIdAsGuid)) { _logger.LogError($"Failed to send web log for WebActionId:{(int)webActionType}, for lowell ref {lowellRef} as provided GUID for user id is invalid. user id {userId}."); } else { await _sendToRabbitMQProcess.SendToRabbitMQ(new WebActionDto() { Company = 0, DateTime = DateTime.Now, Guid = userId ?? "", LowellReference = lowellRef, WebActionType = webActionType }); } } catch (Exception e) { _logger.LogError(e, $"Error in WebActionLoggingService.LogWebAction ({webActionType.ToString()})"); } }
public WebActionCommand(int id, WebActionType type, String message, User user, ZmaSQLConnection sql) { this.Id = id; this.Type = type; this.Message = message; this.User = user; }
public WebActionCommand(int id, WebActionType type, String message,User user, ZmaSQLConnection sql) { this.Id = id; this.Type = type; this.Message = message; this.User = user; }
public async Task LogContactPreferecesEmailChange(string lowellReference, string userId, bool newValue, bool oldValue) { if (newValue != oldValue) { WebActionType webAction = newValue ? WebActionType.LFLEmailSelected : WebActionType.LFLEmailDeselected; await LogWebAction(lowellReference, userId, webAction); } }
private async Task LogWebActionAnonymousAsync(string lowellReference, string userId, WebActionType webActionType) { try { await _sendToRabbitMQProcess.SendToRabbitMQAnonymous(new WebActionDto() { Company = 0, DateTime = DateTime.Now, Guid = userId ?? "", LowellReference = lowellReference, WebActionType = webActionType }); } catch (Exception e) { _logger.LogError(e, $"Error in WebActionLoggingService.LogWebAction ({webActionType.ToString()})"); } }
public void GetCommands(MinecraftHandler mc, LockFreeQueue <WebActionCommand> webCommands) { try { if (mc.Started && mc.Config.StreamEnabled) { String guid = mc.Config.GuidString; MySqlCommand command = connection.CreateCommand(); String sql = String.Format( "SELECT * FROM zma_app.zma_web_queue w WHERE w.server_guid = '{0}';" , guid); command.CommandText = sql; MySqlDataReader reader = command.ExecuteReader(); List <int> ids = new List <int>(); int id = -1; while (reader.Read()) { id = reader.GetInt32("id"); WebActionType type = WebActionType.None; type = (WebActionType)reader.GetInt32("type"); string message = ""; message = reader.GetString("message"); UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); String userName = ""; try { userName = reader.GetString("name"); } catch { } if (id >= 0) { ids.Add(id); } User user = users.GetUserByName(userName); if (type == WebActionType.Chat && id >= 0 && !user.Generated) { WebActionCommand cmd = new WebActionCommand(id, type, message, user, this); webCommands.Enqueue(cmd); } } reader.Close(); foreach (int i in ids) { command.CommandText = String.Format("DELETE FROM zma_app.zma_web_queue WHERE id = {0};", i); command.ExecuteNonQuery(); } } } catch (Exception ex) { Log.Append(this, "GetCommands " + ex.Message, Log.ExceptionsLog); } }