更新了与​​Kentico10

时间:2017-02-03 14:06:42

标签: kentico

由于在Kentico 10中更改了DocumentHelper.AddAttachment()方法,我需要替代方法来处理以下代码::

 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的建议 如果我用DocumentAttach返回类型替换AttachmentInfo并删除AddAttachment方法中的最后一个参数,那么SetAttachmentInfo方法怎么样?如何将添加的附件与树相关联?什么代码应该替换我的这行代码 AttachmentInfoProvider.SetAttachmentInfo(附着);

2 个答案:

答案 0 :(得分:1)

Here are the examples here

 // Saves the modified attachment into the database
 attachment.Update();

答案 1 :(得分:0)

我认为您可以在将附件添加到文档后更新附件:

if(paramMethod == 'path'){
 // build parameter api/id/1
} else if(paramMethod =='query'{
 // build queryString api/apiPoint?id=1
} else if(paramMethod == 'none') {
 // var result = "";
 // return result;
}