2017-08-10 8 views
3

特定の医者が持っているセッションをヒーローカードに表示してボットに送信します。私はreplyToConversation.Attachments = GetSessionHeroCard()を行うとここボットフレームワークの添付ファイルにヒーローカードのリストを送信

はコード

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(','); 
    } 

です。

私はこれで私を助けてください、次のエラー

Cannot implicitly convert type 'Microsoft.Bot.Connector.Attachment' to 'System.Collections.Generic.List<Microsoft.Bot.Connector.Attachment>' 

を取得します。時間のために苦労しています。ありがとうございます。

答えて

4

プロパティList<Attachment>は、このエラーが表示されているため、添付ファイルをリストに割り当てようとしています。

あなたが行うことができます答えを

replyToConversation.Attachments = new List<Attachment>(); 
replyToConversation.Attachments.Add(GetSessionHeroCard()); 
+1

おかげで、これはそれを解決しました。 :) – Azmy

関連する問題