예제 #1
0
        public static async Task ReplyWithChart(IDialogContext context, string workbookId, string worksheetId, WorkbookChart chart)
        {
            try
            {
                // Create and save user nonce
                var userNonce = (Guid.NewGuid()).ToString();
                context.ConversationData.SetValue <ChartAttachment>(
                    userNonce,
                    new ChartAttachment()
                {
                    WorkbookId  = workbookId,
                    WorksheetId = worksheetId,
                    ChartId     = chart.Id
                });
                await context.FlushAsync(context.CancellationToken);

                // Reply with chart URL attached
                var reply = context.MakeMessage();
                reply.Recipient.Id = (reply.Recipient.Id != null) ? reply.Recipient.Id : (string)(HttpContext.Current.Items["UserId"]);

                var image = new Microsoft.Bot.Connector.Attachment()
                {
                    ContentType = "image/png",
                    ContentUrl  = $"{RequestHelper.RequestUri.Scheme}://{RequestHelper.RequestUri.Authority}/api/{reply.ChannelId}/{reply.Conversation.Id}/{reply.Recipient.Id}/{userNonce}/image"
                };

                reply.Attachments.Add(image);
                await context.PostAsync(reply);
            }
            catch (Exception ex)
            {
                await context.PostAsync($"Sorry, something went wrong getting the **{chart.Name}** chart ({ex.Message})");
            }
        }
예제 #2
0
파일: Auto.cs 프로젝트: tomeelog/wapic
 // Mandatory: you should have this ctor as it is used by the recognizer
 public MyAwaitableImage(Microsoft.Bot.Connector.Attachment source) : base(source)
 {
 }
예제 #3
0
파일: Auto.cs 프로젝트: tomeelog/wapic
        // Optional: here you can define your custom logic to get the attachment data or add custom logic to check it, etc..
        protected override async Task <Stream> ResolveFromSourceAsync(Microsoft.Bot.Connector.Attachment source)
        {
            var result = await base.ResolveFromSourceAsync(source);

            return(result);
        }