2017-02-03 4 views
0

でDocumentHelper.AddAttachment()メソッドに関連するAPIを更新::は私は以下のコードへの代替アプローチを必要Kentico10

public void InsertAttachment(string url, SKUTreeNode productDoc) 
    { 
     string file = DownloadImage(url); 

     if (!String.IsNullOrEmpty(file)) 
     { 
      Bitmap bmp = (Bitmap)System.Drawing.Image.FromFile(Server.MapPath(file), true); 
      AttachmentInfo attachment = DocumentHelper.AddAttachment(productDoc, "ProductImage", file, tree); 
      attachment.AttachmentImageHeight = getRelativeHeight(bmp); 
      attachment.AttachmentImageWidth = 300; 
      attachment.AttachmentIsUnsorted = true; 
      AttachmentInfoProvider.SetAttachmentInfo(attachment); 
      productDoc.Update(); 
     } 
    } 

this linkからの提案に基づいて AttachmentInfoをDocumentAttachの戻り値の型に置き換え、AddAttachmentメソッドの最後の引数を削除すると、SetAttachmentInfoメソッドはどうなりますか、追加された添付ファイルをツリーとどのように関連づけますか?私のこのコード行を置き換えるべきコード AttachmentInfoProvider.SetAttachmentInfo(添付);

答えて

0

私は、ドキュメントに追加した後、添付ファイルを更新することができると思います。

attachment.AttachmentImageHeight = getRelativeHeight(bmp); 
attachment.AttachmentImageWidth = 300; 
attachment.AttachmentIsUnsorted = true; 
DocumentHelper.UpdateAttachment(Node, attachment); 
関連する問題