예제 #1
0
 public bool?Run()
 {
     Logger.Info("Started task: {0}", GetType().Name);
     Initialize();
     try
     {
         Execute();
         TaskExecuter.StartExecuting();
         return(true);
     }
     catch (Exception e)
     {
         Logger.ErrorException("Could not execute task " + GetType().Name, e);
         OnError(e);
         return(false);
     }
     finally
     {
         TaskExecuter.Discard();
         Logger.Info("Finished task: {0}", GetType().Name);
     }
 }
예제 #2
0
 protected override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     ViewBag.IsAuthenticated = HttpContext.User.Identity.IsAuthenticated;
     ViewBag.Roles           = GetRoles();
     ViewBag.CanSeeAdminLink = AdminController.CanSeeAdminLink(ViewBag.Roles);
     if (ViewBag.IsAuthenticated)
     {
         var webAccount = DocumentSession.Load <WebAccount>(HttpContext.User.Identity.Name);
         ViewBag.Account = webAccount;
     }
     try {
         using (DocumentSession) {
             if (filterContext.Exception == null)
             {
                 DocumentSession.SaveChanges();
                 TaskExecuter.StartExecuting();
             }
         }
     } finally {
         TaskExecuter.Discard();
     }
 }