private async Task SearchProductAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result as Activity; using (var scope = WebApiApplication.Container.BeginLifetimeScope()) { ID365Service d356Service = scope.Resolve <ID365Service>(new TypedParameter(typeof(IDialogContext), context)); var products = await d356Service.GetProducts(message.Text); if (products.Count > 5) { await context.PostAsync(string.Format(Resource.Retry_More_Than_x_Items, 5)); context.Wait(SearchProductAsync); } else { Activity reply = message.CreateReply(); reply.AttachmentLayout = "carousel"; reply.Attachments = new List <Attachment>(); foreach (var product in products) { IAzureBlobService blobService = scope.Resolve <IAzureBlobService>(); var imageUrl = blobService.Upload(product.Image, product.Number); List <CardImage> cardImages = new List <CardImage>(); cardImages.Add(new CardImage(url: imageUrl)); List <CardAction> cardButtons = new List <CardAction>(); CardAction plButton = new CardAction() { //Value = $"ms-dynamicsxrm://?pagetype=create&etn=appointment", Value = $"{ConfigurationManager.AppSettings["D365Url"]}/m/ef.aspx?etn=product&id=%7b{product.Id}%7d", Type = "openUrl", Title = Resource.Detail }; cardButtons.Add(plButton); ThumbnailCard plCard = new ThumbnailCard() { Title = product.Name, Subtitle = product.Description, Images = cardImages, Buttons = cardButtons }; Attachment plAttachment = plCard.ToAttachment(); reply.Attachments.Add(plAttachment); } await context.PostAsync(reply); context.Done(true); } } }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result as Activity; using (var scope = WebApiApplication.Container.BeginLifetimeScope()) { ID365Service d356Service = scope.Resolve <ID365Service>(new TypedParameter(typeof(IDialogContext), context)); appointments = await d356Service.GetAppointmentsForToday(); if (appointments.Count() == 0) { await context.PostAsync(Resource.No_Appointment_Today); context.Done(true); } else { foreach (var appointment in appointments.OrderBy(x => x.FormattedStartDate)) { var startTime = appointment.FormattedStartDate.ToString("t", Thread.CurrentThread.CurrentCulture.DateTimeFormat); var endTime = appointment.FormattedEndDate.ToString("t", Thread.CurrentThread.CurrentCulture.DateTimeFormat); var reply = message.CreateReply($"{startTime}-{endTime}:{appointment.Title}"); await context.PostAsync(reply); } appointments.Add(new Appointment() { Title = Resource.Finish }); DisplayChoice(context); } } }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; // If it is directline, then ignore the first one as it just said "check result" // But it check the result for second time. if (message.ChannelId.ToLower() == "directline" && message.Text == Resource.Confirm) { context.Wait(MessageReceivedAsync); } else { var command = ""; using (var scope = WebApiApplication.Container.BeginLifetimeScope()) { ID365Service d356Service = scope.Resolve <ID365Service>(new TypedParameter(typeof(IDialogContext), context)); if (message.Text == Resource.Reboot) { command = "reboot"; } else if (message.Text == Resource.Reset_To_Default) { command = "reset"; } await d356Service.CreateIoTCommand(command, alertId, deviceId); await context.PostAsync(string.Format(Resource.Done_Operation, message.Text)); context.Done(true); } } }
private async Task ResumeAfterAuth(IDialogContext context, IAwaitable <string> result) { var message = await result; await context.PostAsync(message); using (var scope = WebApiApplication.Container.BeginLifetimeScope()) { ID365Service d356Service = scope.Resolve <ID365Service>(new TypedParameter(typeof(IDialogContext), context)); await d356Service.UpdateUserInfoForBot(); } await ShowHelp(context); }
private async Task GetTasks(IDialogContext context) { tasks.Clear(); using (var scope = WebApiApplication.Container.BeginLifetimeScope()) { ID365Service d356Service = scope.Resolve <ID365Service>(new TypedParameter(typeof(IDialogContext), context)); IO365Service o365Service = scope.Resolve <IO365Service>(new TypedParameter(typeof(IDialogContext), context)); var crmTasks = await d356Service.GetTasks(); var plannerTasks = await o365Service.GetTasks(); tasks.AddRange(crmTasks); tasks.AddRange(plannerTasks); tasks = tasks.OrderBy(x => x.DueDateTime).ToList(); } }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; if (message.ChannelId.ToLower() == "directline" && message.Text == Resource.Confirm) { context.Wait(MessageReceivedAsync); } else { using (var scope = WebApiApplication.Container.BeginLifetimeScope()) { ID365Service d356Service = scope.Resolve <ID365Service>(new TypedParameter(typeof(IDialogContext), context)); await d356Service.CreateDailyReport(message.Text); await context.PostAsync(Resource.Created_DailyReport); context.Done(true); } } }
public FilesController() { D365DataService = new D365Service(); }