Example #1
0
        protected async Task <Shared.ButtonBase> Alert(string title, string icon, string message, Shared.ButtonBase[] buttons)
        {
            WaitingContext <Shared.ButtonBase> waitingContext = new WaitingContext <Shared.ButtonBase>()
            {
                WaitId = Guid.NewGuid().ToString()
            };

            AlertMessage msg = new AlertMessage()
            {
                WaitId = waitingContext.WaitId, Title = title, Icon = icon, Message = message, Buttons = buttons
            };

            waitingContext.DialogMessage = msg;
            RuntimeContexts.Waits.TryAdd(waitingContext.WaitId, waitingContext);

            if (Response.ContentType == String.Empty)
            {
                Response.StatusCode  = 200;
                Response.ContentType = "application/json";
            }

            // await Json(msg).ExecuteResultAsync(ControllerContext);
            // await ControllerContext.HttpContext.Response.Body.FlushAsync();
            await SigRHub.Clients.Client(ControllerContext.HttpContext.Request.Headers["SignalRId"].SingleOrDefault()).SendAsync("Alert", msg);

            Task task = Task.Factory.StartNew(async() => { await keepConnectionAlive(waitingContext.DialogResultSource.Task); }, TaskCreationOptions.LongRunning);


            return(await waitingContext.DialogResultSource.Task);
        }
Example #2
0
        protected async Task <PromptResult <T> > Prompt <T>(string text, string[] buttons, T promptForm)
        {
            WaitingContext <PromptResult <T> > waitingContext = new WaitingContext <PromptResult <T> >()
            {
                WaitId = Guid.NewGuid().ToString()
            };

            PromptMessage msg = new PromptMessage()
            {
                WaitId = waitingContext.WaitId, Text = text, PromptForm = promptForm
            };

            waitingContext.DialogMessage = msg;
            RuntimeContexts.Waits.TryAdd(waitingContext.WaitId, waitingContext);

            if (Response.ContentType == String.Empty)
            {
                Response.StatusCode  = 200;
                Response.ContentType = "application/json";
            }

            // await Json(msg).ExecuteResultAsync(ControllerContext);
            // await ControllerContext.HttpContext.Response.Body.FlushAsync();
            await SigRHub.Clients.Client(ControllerContext.HttpContext.Request.Headers["SignalRId"].SingleOrDefault()).SendAsync("Prompt", msg);

            Task task = Task.Factory.StartNew(async() => { await keepConnectionAlive(waitingContext.DialogResultSource.Task); }, TaskCreationOptions.LongRunning);


            return(await waitingContext.DialogResultSource.Task);
        }