/// <summary> /// Конструктор /// </summary> /// <param name="listItem">Элемент списка</param> /// <param name="fileName">Название файла</param> /// <param name="mode">Режим загрузки</param> public ItemRecordAttachment(SPListItem listItem, string fileName, AttachmentsLoadMode mode) { this.Name = fileName;//Name; this.Url = listItem.Attachments.UrlPrefix + fileName;//Name; if ((mode == AttachmentsLoadMode.None))// || (mode == AttachmentsLoadMode.Present)) { throw new ArgumentException("Incorrect value of 'mode' parameter"); } SPFile file = listItem.Web.GetFile(listItem.Attachments.UrlPrefix + fileName); this.Size = file.Length; if (mode == AttachmentsLoadMode.Full) { this._content = file.OpenBinary(); } }
/// <summary> /// Инициализация /// </summary> /// <param name="listItem">Элемент списка</param> /// <param name="mode">Режим загрузки</param> public virtual void Init(SPListItem listItem, AttachmentsLoadMode mode) { //LoadDataFromSPListItem(listItem); ??? base.GetSPListItemData(listItem); if (mode != AttachmentsLoadMode.None) { if (listItem.Attachments == null || listItem.Attachments.Count <= 0) { return; } for (int i = 0; i < listItem.Attachments.Count; i++) { //SPAttachmentCollection var curItem = listItem.Attachments[i]; Attachments.Add(new ItemRecordAttachment(listItem, curItem, mode)); } } }