Exemplo n.º 1
0
        /// <summary>
        /// Tries to upload attachments to an xwiki page.
        /// Stops when one upload fails.
        /// </summary>
        public void Perform()
        {
            if (space == null || page == null)
            {
                Log.Error("Trying to attach a file to a page with an invalid name!");
                result = false;
            }
            if (!this.client.LoggedIn)
            {
                client.Login(addin.Username, addin.Password);
            }
            bool operationCompleted = false;

            if (addin.Application.ActiveDocument == null)
            {
                UserNotifier.Message(UIMessages.NO_OPENED_DOCUMENT);
            }
            operationCompleted = false;
            int totalUploadedAttachments = 0;

            foreach (string fileName in fileNames)
            {
                if (client.AddAttachment(space, page, fileName))
                {
                    totalUploadedAttachments++;
                }
                else
                {
                    break;
                }
            }
            operationCompleted = (totalUploadedAttachments == fileNames.Length);

            result = operationCompleted;
        }
Exemplo n.º 2
0
 public void UploadAttachments()
 {
     foreach (String filePath in newAttachments)
     {
         xwikiClient.AddAttachment(states.PageFullName, filePath);
     }
     //clean the list for future uploads
     newAttachments.Clear();
 }