public static void LogAction(string controller, string action, bool success, string errorMessage) { var factory = ServiceLocator.Current.GetInstance <ISessionFactory>(); using (var manager = new MiniSessionService(factory)) { manager.OpenSessionWithTransaction(); var repo = ServiceLocator.Current .GetInstance <Data.DAL.IRepositoryBuilder>() .CreateCreateRepository(manager); // If Logging is disabled, return var logSetting = repo.Get <ApplicationSetting>(s => s.Key == "OperationAccessLog").FirstOrDefault(); if ( logSetting == null || string.IsNullOrWhiteSpace(logSetting.Value) || string.Compare(logSetting.Value, "false", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(logSetting.Value, "0", StringComparison.OrdinalIgnoreCase) == 0 ) { return; } ApplicationUser user = null; var activePermissions = new List <string>(); try { user = GetCurrentApplicationUser(); activePermissions = GetCurrentApplicationUserPermissions(); } catch (Exception e) { var log = LogManager.GetLogger(typeof(IdentityHelper)); log.Error($"Failed to GetCurrentApplicationUser while Logging action: {controller}.{action}", e); } var entry = new ApplicationUserAction { UserName = user == null ? "Anonymous" : user.UserName, Action = action, Controller = controller, Date = DateTime.UtcNow, ActivePermissions = user == null ? "" : string.Join(";", activePermissions), ActiveRoles = user == null ? "" : string.Join(";", user.Roles.Select(x => x.Name)), Success = success, ErrorMessage = errorMessage }; repo.Save(entry); manager.CommitChanges(); } }
public IAuditingRepository CreateAuditingRepository(MiniSessionService manager) => throw new NotImplementedException();
public IRetrieveRepository CreateRetrieveRepository(MiniSessionService manager = null) => new Repository(manager);
public IIdentityRepository CreateIdentityRepository(MiniSessionService manager = null) => new Repository(manager);
public IDeleteRepository CreateDeleteRepository(MiniSessionService manager = null) => new Repository(manager);
public IWorkflowRepository CreateWorkflowRepository(MiniSessionService manager = null) { throw new NotImplementedException(); }
public IIdentityRepository CreateIdentityRepository(MiniSessionService sessionManager = null) { throw new NotImplementedException(); }
public IRetrieveRepository CreateRetrieveRepository(MiniSessionService manager = null) { return(CreateCreateRepository((IMiniSessionService)manager)); }
public IDeleteRepository CreateDeleteRepository(MiniSessionService manager = null) { throw new NotImplementedException(); }
public IIdentityRepository CreateIdentityRepository(MiniSessionService sessionManager) { return(null); }
public IDeleteRepository CreateDeleteRepository(MiniSessionService manager) { return(null); }
public IWorkflowRepository CreateWorkflowRepository(MiniSessionService manager) { return(null); }
public IRetrieveRepository CreateRetrieveRepository(MiniSessionService manager) { return(null); }