Ejemplo n.º 1
0
        void Application_BeforeDocumentClose(Word.Document doc, ref bool cancel)
        {
            var documentCustomProps = new DocumentCustomProperties(doc);

            Application.DocumentChange -= Application_DocumentChange_UpdateRibbon;

            if (documentCustomProps.ArticleNumber.IsNullOrEmpty())
            { // If this isn't an elsevier article, default to the normal process
                return;
            }

            if (!doc.Saved)
            {
                var dialog = new SaveDialog();
                dialog.ShowDialog();

                switch (dialog.SelectedChoice)
                {
                case SaveDialog.SaveChoice.SaveToSitecoreAndUnlock:
                    // at this point, there can be no metadata changes, only body text changes.
                    var _sitecoreClient = new SitecoreClient();
                    var errors          = _sitecoreClient.SaveArticle(doc, SitecoreClient.ForceReadArticleDetails(documentCustomProps.ArticleNumber),
                                                                      Guid.Empty, new List <StaffStruct>(), documentCustomProps.ArticleNumber);

                    if (errors.Count > 0)
                    {
                        MessageBox.Show
                            (@"There was an error saving the document to Sitecore. Please try again." + Environment.NewLine +
                            Environment.NewLine + @"If the problem persists, contact your system administrator.",
                            @"Informa",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                        cancel = true;
                    }
                    else
                    {
                        doc.Saved = true;
                        SitecoreClient.CheckInArticle(documentCustomProps.ArticleNumber);
                    }
                    break;

                case SaveDialog.SaveChoice.SaveLocal:
                    doc.Save();
                    break;

                case SaveDialog.SaveChoice.Cancel:
                    cancel = true;
                    break;

                case SaveDialog.SaveChoice.DontSave:
                    doc.Saved = true;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 private void uxUnlockButton_Click(object sender, System.EventArgs e)
 {
     _articleNumber = _parent.GetArticleNumber();
     if (!SitecoreClient.DoesArticleExist(_articleNumber))
     {
         return;
     }
     SitecoreClient.CheckInArticle(_articleNumber);
     SetCheckedOutStatus();
     Close();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// transfers current material to sitecore
        /// versions it
        /// unlocks the item if current user is the one who has a lock on it
        ///
        /// Be sure to catch potential WebException
        /// </summary>
        public bool CheckIn(bool save = true)
        {
            bool saved = false;

            try
            {
                //SitecoreAddin.WordApp.ActiveDocument.Saved = true;
                if (save)
                {
                    saved = _parent.SaveArticle();

                    if (!saved)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.SitecoreAddin.LogException("Error in article details when saving article.", ex);

                if (ex is WebException)
                {
                    throw;
                }
                else
                {
                    MessageBox.Show(@"Error in article details when checking in article.", @"Informa");
                }
            }
            finally
            {
                Guid articleGuid = _parent.ArticleDetails.ArticleGuid;
                if (articleGuid != Guid.Empty)
                {
                    SitecoreClient.CheckInArticle(articleGuid);
                }
                else
                {
                    SitecoreClient.CheckInArticle(_parent.GetArticleNumber());
                }
                IsCheckedOutByMe = false;
                IsCheckedOut     = false;
            }
            return(saved);
        }