public static void ApplicationStart() { try { SqlSettings.AutoQuotedIdentifiers = true; Serenity.Web.CommonInitialization.Run(); var registrar = Dependency.Resolve <IDependencyRegistrar>(); registrar.RegisterInstance <IAuthorizationService>(new Administration.AuthorizationService()); registrar.RegisterInstance <IAuthenticationService>(new Administration.AuthenticationService()); registrar.RegisterInstance <IPermissionService>(new LogicOperatorPermissionService(new Administration.PermissionService())); registrar.RegisterInstance <IUserRetrieveService>(new Administration.UserRetrieveService()); registrar.RegisterInstance <ISMSService>(new Administration.FakeSMSService()); if (!ConfigurationManager.AppSettings["LDAP"].IsTrimmedEmpty()) { registrar.RegisterInstance <IDirectoryService>(new LdapDirectoryService()); } if (!ConfigurationManager.AppSettings["ActiveDirectory"].IsTrimmedEmpty()) { registrar.RegisterInstance <IDirectoryService>(new ActiveDirectoryService()); } InitializeExceptionLog(); BackgroundTaskManager.Register(new MailingBackgroundTask()); BackgroundTaskManager.Initialize(); } catch (Exception ex) { ex.Log(); throw; } foreach (var databaseKey in databaseKeys) { EnsureDatabase(databaseKey); RunMigrations(databaseKey); } }
public static async Task RegisterBackgroundTasks() { //BackgroundExecutionManager.RemoveAccess(); //foreach (var t in BackgroundTaskRegistration.AllTasks) //{ // if (t.Value.Name == "NotificationTask") // { // t.Value.Unregister(false); // } //} var access = await BackgroundExecutionManager.RequestAccessAsync(); if (access == BackgroundAccessStatus.DeniedByUser || access == BackgroundAccessStatus.DeniedBySystemPolicy) { return; } // TODO: remove the "new" when releasing to the store BackgroundTaskManager.Register("NewNotificationTask", "Unigram.Native.Tasks.NotificationTask", new PushNotificationTrigger()); BackgroundTaskManager.Register("InteractiveTask", "Unigram.Tasks.InteractiveTask", new ToastNotificationActionTrigger()); }
/// <summary> /// Executes an <c>async</c> background operation, registering it with ASP.NET. /// </summary> /// <param name="operation">The background operation.</param> public static void Run(Func <Task> operation) { instance.Register(Task.Run(operation)); }