3
我想向英雄卡中的特定醫生顯示Sessions並將其發送到機器人。發送Hero卡列表以附加到Bot框架中
這裏是代碼
private async Task ShowSessionsHeroCard(IDialogContext context)
{
var replyToConversation = context.MakeMessage();
replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel;
replyToConversation.Attachments = GetSessionHeroCard();
await context.PostAsync(replyToConversation);
}
private Attachment GetSessionHeroCard()
{
var heroCard = new HeroCard();
foreach (var sessionDetails in scheduleList)
{
string[] session = GetSplittedDetails(sessionDetails);
string hospitalName = session[0]; //Hospital Name: {0}
string availableDay = session[1]; //Available Day: {1}
string appointmentNo = session[2]; // Appoinment No: {2}
string sessionAvailable = session[3]; // Session: {3}
heroCard.Title = hospitalName;
heroCard.Subtitle = availableDay;
heroCard.Text = sessionAvailable + appointmentNo;
}
return heroCard.ToAttachment();
}
private string[] GetSplittedDetails(string sessionDetails)
{
return sessionDetails.Split(',');
}
當我做replyToConversation.Attachments = GetSessionHeroCard();
我收到以下錯誤
Cannot implicitly convert type 'Microsoft.Bot.Connector.Attachment' to 'System.Collections.Generic.List<Microsoft.Bot.Connector.Attachment>'
請幫助我。我掙扎了幾個小時。在此先感謝:)
謝謝回答這個問題解決了它。 :) – Azmy