public void ExecuteWithoutAuditTrail(Func <object, object> action) { try { IsTemporarilyDisabled = true; #if NETFRAMEWORK MiniSessionManager.ExecuteInUoW(manager => { var result = action?.Invoke(this); }, MiniSessionManager.InstanceSafe); #else MiniSessionManager.ExecuteInUoW(manager => { var result = action?.Invoke(this); }); #endif IsTemporarilyDisabled = false; } catch (Exception) { IsTemporarilyDisabled = false; throw; } }
public void IsDirtyPropertyTest() { var manager = new MiniSessionManager(); var session = manager.OpenSession(); Assert.IsFalse(session.IsDirtyProperty(new User(), "Name")); }
public void GetOriginalEntityPropertyTest() { var manager = new MiniSessionManager(); var session = manager.OpenSession(); Assert.AreEqual(null, session.GetOriginalEntityProperty(new User(), "Name")); }
public IWorkflowExecutionResult ExecuteSchedule(WorkflowSchedule schedule) { _log.Debug("------------------------------------------------------"); _log.DebugFormat("Executing Scheduled Activity: {0} - {1}", schedule.Workflow, schedule.Workflow); IWorkflowExecutionResult result = null; try { MiniSessionManager .ExecuteInUoW(manager => { result = WorkflowManager.Current.ExecuteWorkflow(schedule.Workflow); }); schedule.IsLastExecutionSuccess = true; schedule.LastExecutionMessage = "Executed Successfully"; } catch (Exception ex) { _log.Error($"Error executing Scheduled Activity: {schedule.Workflow}", ex); schedule.IsLastExecutionSuccess = false; schedule.LastExecutionMessage = $"{ex.Message} - {ex.StackTrace}"; result = new WorkflowExecutionResult { Status = WorkflowStatus.Failed }; } schedule.LastExecution = DateTime.UtcNow; MiniSessionManager.ExecuteInUoW(manager => { Builder.CreateCreateRepository(manager).Save(schedule); }); _log.DebugFormat("Finished Executing Scheduled Activity: {0} - {1}", schedule.Workflow, schedule.Workflow); _log.Debug("------------------------------------------------------"); return(result); }
public void IsDirtyEntityTest() { var manager = new MiniSessionManager(); var session = manager.OpenSession(); Assert.IsTrue(session.IsDirtyEntity(new User())); }
public HealthCheckResult Check() { // TODO - do additional checks here, besides checking the db return(MiniSessionManager.ExecuteInUoW(manager => new HealthCheckResult { status = "ok" })); }
public void PrintSessionStatisticsTest() { var manager = new MiniSessionManager(); var session = manager.OpenSession(); session.PrintSessionStatistics(); }
public void IsPersistedTest() { var obj = new ObjectGraphWalker(); var manager = new MiniSessionManager(); var session = manager.OpenSession(); Assert.AreEqual(null, obj.IsPersisted(new User(), session)); }
private List <WorkflowContextBase> GetExpiredAndDelayedPendingJobs() { return(MiniSessionManager.ExecuteInUoW(manager => { var expiredAndDelayedPendingJobs = Builder.CreateRetrieveRepository(manager).GetAsQueryable <WorkflowContextBase>() .Where(p => p.Expires && p.ExpirationDateTime <= DateTime.UtcNow) .ToList(); return expiredAndDelayedPendingJobs; })); }
public void ExecuteInUoWTest() { var manager = new MiniSessionManager(); MiniSessionManager.ExecuteInUoW((mgr) => { }); Assert.ThrowsException <Exception>(() => { MiniSessionManager.ExecuteInUoW((mgr) => { throw new Exception(); }); }); }
public void AssociateGraphWithSessionTest() { var obj = new ObjectGraphWalker(); var manager = new MiniSessionManager(); var session = manager.OpenSession(); Assert.AreEqual(null, obj.IsPersisted(new User(), session)); var user = obj.AssociateGraphWithSession(new User(), manager); //Assert.AreEqual("", user.Name); }
public static void OnDuplicateSessionDetected(string username) { using (var manager = new MiniSessionManager()) { var repo = ServiceLocator.Current .GetInstance <Data.DAL.IRepositoryBuilder>() .CreateCreateRepository(manager); var user = repo.GetById <ApplicationUser>(username); SignOutUserFromAllSessions(user); } }
public Repository(MiniSessionManager manager = null) { _sessionManager = manager; if (_sessionManager == null) { _sessionManager = MiniSessionManager.Instance; } // Make sure the session is open _sessionManager.OpenSession(); _currentSession = _sessionManager.Session; }
public void ExecuteInTransactionTest() { var manager = new MiniSessionManager(); manager.ExecuteInTransaction(() => { }); Assert.ThrowsException <Exception>(() => { manager.ExecuteInTransaction(() => { throw new Exception(); }); }); }
public void DeleteSchedules() { MiniSessionManager .ExecuteInUoW(manager => { var allSchedules = Builder.CreateRetrieveRepository(manager).GetAll <WorkflowSchedule>().ToList(); foreach (var schedule in allSchedules) { Builder.CreateDeleteRepository(manager).Delete(schedule); } }); }
internal List <WorkflowSchedule> GetSchedules(bool onlyactive = true) { return(MiniSessionManager .ExecuteInUoW(manager => { var data = Builder.CreateRetrieveRepository(manager).GetAsQueryable <WorkflowSchedule>(); if (onlyactive) { data = data.Where(s => s.Active); } return data.ToList(); })); }
public void SetSchedules(List <WorkflowSchedule> schedules) { MiniSessionManager .ExecuteInUoW(manager => { var allScheduleNames = Builder.CreateRetrieveRepository(manager).GetAll <WorkflowSchedule>().Select(s => s.Workflow).ToList(); //add new foreach (var newSchedule in schedules.Where(s => !allScheduleNames.Contains(s.Workflow))) { newSchedule.Active = true; Builder.CreateCreateRepository(manager).Save(newSchedule); } }); }
private static void UpdateDatabaseSchema(NHibernate.Cfg.Configuration cfg, string connectionString) { MiniSessionManager.ExecuteScript(connectionString, @" IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'wf') EXEC('CREATE SCHEMA wf AUTHORIZATION [dbo]'); IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'security') EXEC('CREATE SCHEMA security AUTHORIZATION [dbo]'); IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'audit') EXEC('CREATE SCHEMA audit AUTHORIZATION [dbo]');" ); var updateCode = new System.Text.StringBuilder(); var schemaUpdate = new SchemaUpdate(cfg); schemaUpdate.Execute(row => { updateCode.AppendLine(row); updateCode.AppendLine(); }, true); }
public void FlowTest() { var manager = new MiniSessionManager(); var session = manager.OpenSession(); var sessionNew = manager.OpenSession(); Assert.AreSame(session, sessionNew); manager.LastAction = RepositoryAction.INSERT; Assert.AreEqual(RepositoryAction.INSERT, manager.LastAction); manager.BeginTransaction(); manager.WillFlush = true; manager.CommitChanges(); }
public void InitTest() { #if NETFRAMEWORK var manager = new MiniSessionManager(); Assert.IsNotNull(manager.InstanceId); manager = MiniSessionManager.Create(); Assert.IsNotNull(manager.InstanceId); manager.WillFlush = false; Assert.IsFalse(manager.WillFlush); Assert.IsNull(manager.SingleUseSession); manager.SingleUseSession = false; Assert.IsFalse(manager.SingleUseSession.Value); #endif }
public static void InvalidateUserSecurityData(ApplicationUser user) { if (user == null) { return; } using (var manager = new MiniSessionManager()) { manager.OpenSessionWithTransaction(); var repo = ServiceLocator.Current .GetInstance <Data.DAL.IRepositoryBuilder>() .CreateCreateRepository(manager); user.SecurityStamp = Guid.NewGuid().ToString(); repo.Save(user); manager.CommitChanges(); } }
public static void LogAction(string controller, string action, bool success, string errorMessage) { using (var manager = new MiniSessionManager()) { 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", true) == 0 || string.Compare(logSetting.Value, "0", true) == 0 ) { return; } ApplicationUser user = null; List <string> 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 static List <ApplicationUser> GetAllConnectedUsers() { var connectedUsernames = ServiceLocator.Current.GetInstance <IApplicationHub>()?.GetAllConnectedUsers(); if (connectedUsernames?.Any() != true) { return(new List <ApplicationUser>()); } using (var manager = new MiniSessionManager()) { var repo = ServiceLocator.Current .GetInstance <Data.DAL.IRepositoryBuilder>() .CreateCreateRepository(manager); return(repo.Get <ApplicationUser>(x => connectedUsernames.Contains(x.UserName))); } }
private ApplicationUser PersistApplicationUser(ApplicationUser user) { if (MiniSessionManager.TryGetInstance() == null) { MiniSessionManager.ExecuteInUoW(manager => { _repositoryBuilder .CreateCreateRepository() .Save(user); }, _sessionManager); } else { _repositoryBuilder .CreateCreateRepository(_sessionManager) .Save(user); } return(user); }
private static void ProcessListeners(IEnumerable <Action> listeners, bool parallel, bool throwErrors = false) { if (parallel) { Parallel.ForEach(listeners, listener => { try { MiniSessionManager.ExecuteInUoW(manager => { listener(); }); } catch (Exception x) { LogManager.GetLogger(typeof(EventsHub)).Warn("Error in Listener", x); if (throwErrors) { throw; } } }); } else { foreach (var listener in listeners) { try { listener(); } catch (Exception x) { // continue to the next listener on error LogManager.GetLogger(typeof(EventsHub)).Warn("Error in Listener", x); if (throwErrors) { throw; } } } } }
private void ProcessAutoStartSchedules() { var schedules = GetSchedules(); _log.DebugFormat("Found {0} Active Schedules.", schedules.Count); foreach (var schedule in schedules.Where(a => a.Active)) { try { var expireDateTime = schedule.ExpireOn.HasValue ? schedule.ExpireOn.Value : DateTime.MaxValue; if (expireDateTime <= DateTime.UtcNow) { // Schedule has Expired but it is still active // Mark as Inactive and update the database schedule.Active = false; MiniSessionManager .ExecuteInUoW(manager => { Builder.CreateCreateRepository(manager).Save(schedule); }); continue; } // Should be evaluated? var nextExecTime = GetNextExecutionTime(schedule); if (nextExecTime != DateTime.MinValue && nextExecTime <= DateTime.UtcNow) { // Execute ExecuteSchedule(schedule); } else { _log.DebugFormat("Scheduled Activity: {0} - {1} will be executed on: {2}", schedule.Workflow, schedule.Workflow, nextExecTime); } } catch (Exception ex) { _log.Error($"Error processing Scheduled Activity: {schedule.Workflow} - {schedule.Workflow}", ex); } } }
public void FlowExceptionTest() { var manager = new MiniSessionManager { Session = null }; Assert.ThrowsException <ApplicationException>(() => { manager.CommitChanges(); }); manager.CommitChanges(new Exception()); var session = manager.OpenSession(); var sessionNew = manager.OpenSession(); Assert.AreSame(session, sessionNew); manager.BeginTransaction(); manager.CommitChanges(new Exception()); }
public void ClearAuditTrailCache() { MiniSessionManager.ExecuteInUoW(manager => { var repo = ServiceLocator.Current.GetInstance <IRepositoryBuilder>().CreateCreateRepository(manager); _auditableEntities = new Dictionary <string, AuditableEntity>(); repo.GetAll <AuditEntityConfiguration>() .ForEach(entity => { var auditableEntity = new AuditableEntity { Name = entity.FullName }; entity.Properties .Where(property => property.IsAuditable) .ToList() .ForEach(property => auditableEntity.Properties.Add(property.Name, new AuditableProperty { Name = property.Name, Datatype = property.DataType, IsComplex = property.IsComplex, IsCollection = property.IsCollection })); if (!auditableEntity.Properties.Any()) { return; } _log.Debug($@"Monitoring object: [{entity.ShortName}]. Monitored Properties: * {string.Join("\r\n* ", auditableEntity.Properties.Keys)}"); _auditableEntities.Add(entity.FullName, auditableEntity); }); _auditLogEntryTypes = new Dictionary <string, AuditLogEntryType>(); repo.GetAll <AuditLogEntryType>() .ForEach(type => _auditLogEntryTypes.Add(type.Code, type)); _auditLogPropertyActionTypes = new Dictionary <string, AuditLogPropertyActionType>(); repo.GetAll <AuditLogPropertyActionType>() .ForEach(type => _auditLogPropertyActionTypes.Add(type.Code, type)); }); }
public static void ForEach <T>(IEnumerable <T> items, Action <T, long> iterationFunction) { var exceptions = new ConcurrentQueue <Exception>(); var logger = LogManager.GetLogger(typeof(ParallelTask)); var taskid = Guid.NewGuid(); var outerWatch = new Stopwatch(); outerWatch.Start(); Parallel.ForEach(items, (item, state, idx) => { var innerWatch = new Stopwatch(); innerWatch.Start(); MiniSessionManager.ExecuteInUoW(manager => { try { iterationFunction(item, idx); } catch (Exception e) { exceptions.Enqueue(e); } }); innerWatch.Stop(); logger.Debug($"Parallel task item {idx}, took: {innerWatch.Elapsed}. ({taskid})"); }); outerWatch.Stop(); logger.Debug($"OVERALL: Parallel ForEach Task took: {outerWatch.Elapsed}."); // Throw the exceptions here after the loop completes. if (exceptions.Count > 0) { throw new AggregateException(exceptions); } }
public void UpdateAuthorizationTables() { var confValue = System.Configuration.ConfigurationManager.AppSettings["SeedSecurityTables"]; bool seedSecurityTables = true; bool bSeedSecurityTables; if (bool.TryParse(confValue, out bSeedSecurityTables)) { seedSecurityTables = bSeedSecurityTables; } if (!seedSecurityTables) { return; } var watch = new System.Diagnostics.Stopwatch(); watch.Start(); MiniSessionManager.ExecuteInUoW(manager => { var repo = new Repository(manager); var allRoles = new List <ApplicationRole>(); #region Permissions var manageUsersPermission = CreateOrUpdatePermission("ManageUsers", "Can Manage Users", false, repo); var manageRolesPermission = CreateOrUpdatePermission("ManageRoles", "Can Manage Roles", false, repo); var managePermissionsPermission = CreateOrUpdatePermission("ManagePermissions", "Can Manage Permissions", false, repo); var manageOperationsPermission = CreateOrUpdatePermission("ManageOperations", "Can Manage Operations", false, repo); var manageSettingsPermission = CreateOrUpdatePermission("ManageSettings", "Can Manage Settings", false, repo); var manageApplicationDataPermission = CreateOrUpdatePermission("ManageApplicationData", "Can Manage Application Data", false, repo); var customerSelectionAndAdminAddPermission = CreateOrUpdatePermission("CustomerSelectionAndAdmin_Add", "CustomerSelectionAndAdmin_Add", false, repo); #endregion #region Operations CreateOrUpdateOperation("GeneralOperation", "ErrorPage", ClaimTypes.GenericAction, true, true, null, repo); CreateOrUpdateOperation("Render", "ErrorPage", ClaimTypes.ControllerAction, true, true, null, repo); CreateOrUpdateOperation("SendErrorToAdministrator", "ErrorPage", ClaimTypes.ControllerAction, true, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "FirstAdminSetup", ClaimTypes.GenericAction, true, false, null, repo); CreateOrUpdateOperation("Render", "FirstAdminSetup", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("Save", "FirstAdminSetup", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("GeneralOperation", "HomePage", ClaimTypes.GenericAction, true, true, null, repo); CreateOrUpdateOperation("Render", "HomePage", ClaimTypes.ControllerAction, true, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "NotFoundPage", ClaimTypes.GenericAction, true, true, null, repo); CreateOrUpdateOperation("Render", "NotFoundPage", ClaimTypes.ControllerAction, true, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "SignInPage", ClaimTypes.GenericAction, false, true, null, repo); CreateOrUpdateOperation("Load", "SignInPage", ClaimTypes.ControllerAction, false, true, null, repo); CreateOrUpdateOperation("SignIn", "SignInPage", ClaimTypes.ControllerAction, false, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "SignOutPage", ClaimTypes.GenericAction, true, false, null, repo); CreateOrUpdateOperation("SignOut", "SignOutPage", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("Render", "SignOutPage", ClaimTypes.ControllerAction, false, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "Unauthorized", ClaimTypes.GenericAction, true, true, null, repo); CreateOrUpdateOperation("Render", "Unauthorized", ClaimTypes.ControllerAction, true, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "UserPreferences", ClaimTypes.GenericAction, true, false, null, repo); CreateOrUpdateOperation("Render", "UserPreferences", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("Save", "UserPreferences", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("LanguageBoxDataSet", "UserPreferences", ClaimTypes.Dataset, true, false, null, repo); CreateOrUpdateOperation("LocaleBoxDataSet", "UserPreferences", ClaimTypes.Dataset, true, false, null, repo); CreateOrUpdateOperation("ApplicationThemeDataSet", "UserPreferences", ClaimTypes.Dataset, true, false, null, repo); CreateOrUpdateOperation("GeneralOperation", "MasterPage", ClaimTypes.GenericAction, true, true, null, repo); CreateOrUpdateOperation("Render", "MasterPage", ClaimTypes.ControllerAction, true, true, null, repo); CreateOrUpdateOperation("SignOut", "MasterPage", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("GeneralOperation", "MasterPageForSlide", ClaimTypes.GenericAction, true, true, null, repo); CreateOrUpdateOperation("Render", "MasterPageForSlide", ClaimTypes.ControllerAction, true, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "ApplicationSettingForm", ClaimTypes.GenericAction, false, false, new [] { manageSettingsPermission }, repo); CreateOrUpdateOperation("AddApplicationSetting", "ApplicationSettingForm", ClaimTypes.ControllerAction, false, false, new [] { manageSettingsPermission }, repo); CreateOrUpdateOperation("EditApplicationSetting", "ApplicationSettingForm", ClaimTypes.ControllerAction, false, false, new [] { manageSettingsPermission }, repo); CreateOrUpdateOperation("SaveApplicationSetting", "ApplicationSettingForm", ClaimTypes.ControllerAction, false, false, new [] { manageSettingsPermission }, repo); CreateOrUpdateOperation("DeleteApplicationSetting", "ApplicationSettingForm", ClaimTypes.ControllerAction, false, false, new [] { manageSettingsPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "ApplicationSettingsList", ClaimTypes.GenericAction, false, false, new [] { manageSettingsPermission }, repo); CreateOrUpdateOperation("Refresh", "ApplicationSettingsList", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Retrieve", "ApplicationSettingsList", ClaimTypes.ControllerAction, false, false, new [] { manageSettingsPermission }, repo); CreateOrUpdateOperation("List1DataSet", "ApplicationSettingsList", ClaimTypes.Dataset, false, false, new [] { manageSettingsPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "ChangePassword", ClaimTypes.GenericAction, true, false, null, repo); CreateOrUpdateOperation("Render", "ChangePassword", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("ChangePassword", "ChangePassword", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("GeneralOperation", "ForgotPassword", ClaimTypes.GenericAction, true, true, null, repo); CreateOrUpdateOperation("Render", "ForgotPassword", ClaimTypes.ControllerAction, false, true, null, repo); CreateOrUpdateOperation("ResetPasswordRequest", "ForgotPassword", ClaimTypes.ControllerAction, false, true, null, repo); CreateOrUpdateOperation("ResetPassword", "ForgotPassword", ClaimTypes.ControllerAction, true, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "ManageOperation", ClaimTypes.GenericAction, false, false, new [] { manageOperationsPermission }, repo); CreateOrUpdateOperation("EditOperation", "ManageOperation", ClaimTypes.ControllerAction, false, false, new [] { manageOperationsPermission }, repo); CreateOrUpdateOperation("SaveOperation", "ManageOperation", ClaimTypes.ControllerAction, false, false, new [] { manageOperationsPermission }, repo); CreateOrUpdateOperation("Button2DataSet", "ManageOperation", ClaimTypes.Dataset, false, false, new [] { manageOperationsPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "ManagePermission", ClaimTypes.GenericAction, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("NewPermission", "ManagePermission", ClaimTypes.ControllerAction, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("EditPermission", "ManagePermission", ClaimTypes.ControllerAction, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("SavePermission", "ManagePermission", ClaimTypes.ControllerAction, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("DeletePermission", "ManagePermission", ClaimTypes.ControllerAction, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("Button4DataSet", "ManagePermission", ClaimTypes.Dataset, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("Button41DataSet", "ManagePermission", ClaimTypes.Dataset, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("Button5DataSet", "ManagePermission", ClaimTypes.Dataset, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "ManageRole", ClaimTypes.GenericAction, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("NewRole", "ManageRole", ClaimTypes.ControllerAction, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("EditRole", "ManageRole", ClaimTypes.ControllerAction, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("SaveRole", "ManageRole", ClaimTypes.ControllerAction, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("DeleteRole", "ManageRole", ClaimTypes.ControllerAction, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("AddPermissionDataSet", "ManageRole", ClaimTypes.Dataset, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "ManageUser", ClaimTypes.GenericAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("NewUser", "ManageUser", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("SetPassword", "ManageUser", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("EditUser", "ManageUser", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("SaveUser", "ManageUser", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("DeleteUser", "ManageUser", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Button1DataSet", "ManageUser", ClaimTypes.Dataset, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Button2DataSet", "ManageUser", ClaimTypes.Dataset, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "OperationsList", ClaimTypes.GenericAction, false, false, new [] { manageOperationsPermission }, repo); CreateOrUpdateOperation("Refresh", "OperationsList", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Retrieve", "OperationsList", ClaimTypes.ControllerAction, false, false, new [] { manageOperationsPermission }, repo); CreateOrUpdateOperation("List1DataSet", "OperationsList", ClaimTypes.Dataset, false, false, new [] { manageOperationsPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "PermissionsList", ClaimTypes.GenericAction, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("Refresh", "PermissionsList", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Retrieve", "PermissionsList", ClaimTypes.ControllerAction, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("List1DataSet", "PermissionsList", ClaimTypes.Dataset, false, false, new [] { managePermissionsPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "RolesList", ClaimTypes.GenericAction, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("Refresh", "RolesList", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Retrieve", "RolesList", ClaimTypes.ControllerAction, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("List1DataSet", "RolesList", ClaimTypes.Dataset, false, false, new [] { manageRolesPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "UsersList", ClaimTypes.GenericAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Retrieve", "UsersList", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Refresh", "UsersList", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("List1DataSet", "UsersList", ClaimTypes.Dataset, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("GeneralOperation", "MasterPageSignIn", ClaimTypes.GenericAction, true, false, null, repo); CreateOrUpdateOperation("Render", "MasterPageSignIn", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("GeneralOperation", "CreateAdmin", ClaimTypes.GenericAction, false, true, null, repo); CreateOrUpdateOperation("Index", "CreateAdmin", ClaimTypes.ControllerAction, false, true, null, repo); CreateOrUpdateOperation("Create", "CreateAdmin", ClaimTypes.ControllerAction, false, true, null, repo); CreateOrUpdateOperation("AuthorizeAccess", "CreateAdmin", ClaimTypes.ControllerAction, false, true, null, repo); CreateOrUpdateOperation("GeneralOperation", "DashboardStatistics", ClaimTypes.GenericAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("Render", "DashboardStatistics", ClaimTypes.ControllerAction, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("CloseModal", "DashboardStatistics", ClaimTypes.ControllerAction, true, false, null, repo); CreateOrUpdateOperation("SupplierStatisticDataSet", "DashboardStatistics", ClaimTypes.Dataset, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("SupplierStatisticDataSetOnTime", "DashboardStatistics", ClaimTypes.Dataset, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("SupplierTurnoverDataSet", "DashboardStatistics", ClaimTypes.Dataset, false, false, new [] { manageUsersPermission }, repo); CreateOrUpdateOperation("OnTimeDataSet", "DashboardStatistics", ClaimTypes.Dataset, false, false, new [] { manageUsersPermission }, repo); #endregion #region Roles allRoles = new List <ApplicationRole> { CreateOrUpdateRole("Administrator", "Administrator", new [] { manageUsersPermission, manageRolesPermission, managePermissionsPermission, manageOperationsPermission, manageSettingsPermission, manageApplicationDataPermission }, repo), }; #endregion }); watch.Stop(); log4net.LogManager.GetLogger(typeof(DatabaseSeeder)).Info($"Startup.Database finished in {watch.ElapsedMilliseconds}ms"); }