Ejemplo n.º 1
0
        /// <summary>
        /// handles copying of list items
        /// </summary>
        protected virtual int CopyListItem()
        {
            SPListItem destItem = DestinationList.Items.Add();

            CopyFieldValues(SourceItem, destItem, _options.LinkToOriginal);

            // attachment routine
            if (SourceList.EnableAttachments && DestinationList.EnableAttachments)
            {
                if (_options.IncludeAttachments)
                {
                    AttachmentInfo[] attachments = AttachmentHelper.GetListItemAttachments(SourceItem);

                    foreach (AttachmentInfo ai in attachments)
                    {
                        destItem.Attachments.Add(ai.FileName, AttachmentHelper.ReadFully(ai.Stream, Convert.ToInt32(ai.Stream.Length)));
                    }
                }
            }

            destItem.SystemUpdate();

            if (_options.OperationType == OperationType.Move)
            {
                SourceItem.Delete();
            }

            return(destItem.ID);
        }/// <summary>
Ejemplo n.º 2
0
        }/// <summary>

        /// handles copying of list items
        /// </summary>
        protected virtual void UpdateListItem(int destinationItemID)
        {
            SPListItem destItem = DestinationList.GetItemById(destinationItemID);

            CopyFieldValues(SourceItem, destItem, _options.LinkToOriginal);

            // attachment routine
            if (SourceList.EnableAttachments && DestinationList.EnableAttachments)
            {
                if (_options.IncludeAttachments)
                {
                    AttachmentHelper.DeleteAllAttachments(destItem);

                    AttachmentInfo[] attachments = AttachmentHelper.GetListItemAttachments(SourceItem);

                    foreach (AttachmentInfo ai in attachments)
                    {
                        destItem.Attachments.Add(ai.FileName, AttachmentHelper.ReadFully(ai.Stream, Convert.ToInt32(ai.Stream.Length)));
                    }
                }
            }

            destItem.SystemUpdate();
        }