Exemple #1
0
        public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp)
        {
            IServiceProvider services = ai.GetContext().Services;
            string           actionID = string.Empty;;

            if (dp.Read())
            {
                actionID = (string)dp["ActionID"];
            }

            IActionManager am = services.GetRequiredService <IActionManager>();

            return(new DataPackage(
                       new string[] { "ActionInfo" },
                       new object[] { (await am.GetActionInfoAsync(actionID))?.ToString() }));
        }
Exemple #2
0
        private async Task <ActionInfo> BuildContext(DataPackage message)
        {
            var    config       = _services.GetRequiredService <IConfiguration>();
            string actionID     = (string)message.Headers["ActionID"];
            string userName     = (string)message.Headers["UserName"];
            string sessionID    = (string)message.Headers["SessionID"];
            string encryptedKey = (string)message.Headers["EncryptedKey"];

            if (!message.Headers.TryGetValue("ConnectionName", out object connectionName))
            {
                connectionName = config["appSettings:defaultConnection"];
            }
            ;

            ActionInfo ai = await _actionManager.GetActionInfoAsync(actionID);

            ActionContext ctx = new ActionContext(_services)
            {
                CancellationToken = _token,
                UserName          = userName,
                SessionID         = sessionID,
                ConnectionName    = (string)connectionName
            };

            if (ai.AuthenticationRequired)
            {
                var ui = await _loginProvider.LogonAsync(userName, sessionID, encryptedKey);

                ctx.Principal = ui;
            }
            else
            {
                ctx.Principal = _guest;
            }

            ai.SetContext(ctx);
            return(ai);
        }
Exemple #3
0
        private async Task <ActionInfo> BuildContext()
        {
            string     actionID = (string)_routeValues.Action;
            ActionInfo ai       = await _actionManager.GetActionInfoAsync(actionID);

            ActionContext ctx = new ActionContext(_context.RequestServices)
            {
                CancellationToken = _context.RequestAborted
            };

            if (ai.AuthenticationRequired)
            {
                var ui = await _loginProvider.LogonAsync(null, null, GetToken());

                ctx.Principal = ui;
            }
            else
            {
                ctx.Principal = _guest;
            }

            ai.SetContext(ctx);
            return(ai);
        }