public void EquellaUpdate_DoUpdate(IRibbonControl button) { try { if (!EnsureLogin()) { return; } } catch (NoProfileException) { return; } catch (WebException) { Utils.Alert(String.Format(BAD_URL_MESSAGE, InstitutionURL)); return; } try { DocumentWrapper doc = Integ.CurrentDocument; DocumentMetadata meta = doc.Metadata; string ownerId = meta.OwnerId; string currentUserId = Soap.LoggedInUser; if (currentUserId != ownerId) { //make a new item regardless. this document was owned by someone else Utils.Alert("You are not the owner of this document. A new scrapbook resource will be created instead."); EquellaCreate_DoCreate(null); return; } string itemUuid = meta.ItemUuid; if (!Soap.ScrapbookItemExists(itemUuid)) { Utils.Alert("The scrapbook resource associated with this document could not be found. A new scrapbook resource will be created instead."); EquellaCreate_DoCreate(null); return; } string docFullPath = doc.FileName; string keywords = meta.Keywords ?? ""; string attachmentFilename = meta.AttachmentFilename ?? Path.GetFileName(docFullPath); string itemName = meta.ItemName ?? attachmentFilename; string documentUuid = meta.DocumentUuid; if (AskDetails(ref itemName, ref keywords, ref attachmentFilename)) { //Save the document with updated metadata Integ.AssociateMetadata(doc, new DocumentMetadata { ItemUuid = itemUuid, ItemName = itemName, Keywords = keywords, AttachmentFilename = attachmentFilename, DocumentUuid = documentUuid }); doc = Integ.Save(doc, Path.Combine(Path.GetTempPath(), attachmentFilename)); byte[] bytes = Integ.ReadFile(doc); Soap.UpdateScrapbookItem(itemUuid, itemName, keywords, attachmentFilename, bytes); Utils.Alert("A scrapbook resource has been updated in EQUELLA"); } } catch (Exception e) { Utils.ShowError(e); } }