Exemple #1
0
        private async Task CallHook(String hookName, AppUser user)
        {
            var hooks = ConfigurationManager.AppSettings["accountHooks"];

            if (hooks == null || hooks != "enable")
            {
                return;
            }

            var rm = await RequestModel.CreateFromUrl(_host, RequestUrlKind.Simple, "_hooks");

            if (rm == null)
            {
                return;
            }
            var cmd = rm.GetCommand(hookName);

            if (cmd == null)
            {
                return;
            }
            var dbEvent = new DbEvent()
            {
                Source  = _host.CatalogDataSource,
                ItemId  = user.Id,
                Command = hookName,
                Path    = "/_hooks"
            };

            /* add record to a2sys.DbEvents */
            await _dbContext.ExecuteAsync <DbEvent>(_host.CatalogDataSource, "a2sys.[DbEvent.Add]", dbEvent);

            /* and handle it */
            await _host.ProcessDbEvents(_dbContext, _host.CatalogDataSource);
        }
 public Task ProcessDbEvents(RequestBase rb)
 {
     if (!rb.processDbEvents)
     {
         return(Task.CompletedTask);
     }
     return(_host.ProcessDbEvents(_dbContext, rb.CurrentSource));
 }