/// <summary> Log Message </summary> public static void LogMessage(ActionLogType logType, ReferenceType refType, int?refID, string message) { AuthenticationModel authentication = new AuthenticationModel(); LoginUser user = new LoginUser(authentication.UserID, authentication.OrganizationID); ActionLogs.AddActionLog(user, logType, refType, refID.HasValue ? refID.Value : 0, message); // 0 if no ID? }
public static void Reset() { _userCreatedType = null; _userChangedType = null; _userChangedPasswordType = null; _actionLogTypes = null; _passwordWasResetedForUserType = null; }
/// <summary> /// Registrar log de atividade do usuário /// </summary> /// <param name="type"></param> /// <param name="userIndetifier"></param> /// <param name="ipAdresss"></param> /// <returns></returns> public async Task RegisterLogAsync(ActionLogType type, Guid userIndetifier, string ipAdresss) { var log = new ActionLog(type.Id, userIndetifier, ipAdresss); _actionLogRepository.Add(log); await _actionLogRepository.UnitOfWork.SaveChangesAsync(); }
/// <summary> /// Registrar log de atividade do usuário /// </summary> /// <param name="type"></param> /// <returns></returns> public async Task RegisterLogAsync(ActionLogType type) { var log = new ActionLog(type.Id); _actionLogRepository.Add(log); await _actionLogRepository.UnitOfWork.SaveChangesAsync(); }
//public struct UserID //{ // public int _value; // static public explicit operator UserID(int refID) { return new UserID() { _value = refID }; } //} //public static void AddActionLog(LoginUser loginUser, ActionLogType type, UserID refID, string description) //{ // AddActionLog(loginUser, type, ReferenceType.Users, refID._value, description); //} //public struct TicketID //{ // public int _value; // static public explicit operator TicketID(int refID) { return new TicketID() { _value = refID }; } //} //public static void AddActionLog(LoginUser loginUser, ActionLogType type, TicketID refID, string description) //{ // TicketLog.AddLog(loginUser, type, refID._value, description); //} public static void AddActionLog(LoginUser loginUser, ActionLogType type, ReferenceType refType, int refID, string description) { ActionLogs actionLogs = new ActionLogs(loginUser); ActionLog actionLog = actionLogs.AddNewActionLog(); actionLog.Description = description; actionLog.OrganizationID = loginUser.OrganizationID < 0 ? null : (int?)loginUser.OrganizationID; actionLog.ActionLogType = type; actionLog.RefID = refID; actionLog.RefType = refType; actionLogs.Save(); }
private void SeedInitialData(ModelBuilder modelBuilder) { // Seed enumeration data // modelBuilder.Entity<ActionLogType>().HasData(new ActionLogType[] { // ActionLogType.UserCreated, // ActionLogType.UserLoginAttempt, // ActionLogType.UserLoginFail, // ActionLogType.UserLoginSuccess // }); var entities = ActionLogType.GetAll <ActionLogType>().ToArray(); modelBuilder.Entity <ActionLogType>().HasData(entities); }
public static void LogMessage(ActionLogType logType, ReferenceType refType, int?refID, string message, Exception ex) { // log to ExceptionLogs or New Relic, or windows event log? string fullMessage = message + ex.ToString() + " ----- STACK: " + ex.StackTrace.ToString(); if (Debugger.IsAttached) { Debug.WriteLine(fullMessage); // see the error in the debug output window Debugger.Break(); // something is wrong - fix the code! } LogMessage(logType, refType, refID, fullMessage); }