Example #1
0
        /// <summary>
        /// Get from sitecore checked out status, then set control accordingly
        ///
        /// Unprotects document if locked by current user
        /// </summary>
        public void SetCheckedOutStatus()
        {
            if (_parent == null || _parent.ArticleDetails == null)
            {
                return;
            }
            DocumentCustomProperties = new DocumentCustomProperties(SitecoreAddin.ActiveDocument);
            string articleNum = _parent.GetArticleNumber();

            if (!string.IsNullOrEmpty(_articleNumber))
            { //document is linked to an article
                SetArticleNumber(articleNum);
                CheckoutStatus checkedOut;
                if (_parent.ArticleDetails.ArticleGuid != Guid.Empty)
                {
                    checkedOut = SitecoreClient.GetLockedStatus(_parent.ArticleDetails.ArticleGuid);
                }
                else
                {
                    checkedOut = SitecoreClient.GetLockedStatus(articleNum);
                }
                _articleInformationControl.IsCheckedOut = checkedOut.Locked;
                if (_articleInformationControl.IsCheckedOut)
                {
                    if (SitecoreUser.GetUser().Username == checkedOut.User)
                    { //locked by me
                        IndicateCheckedOutByMe(checkedOut);
                        _parent.articleStatusBar1.ChangeLockButtonStatus(LockStatus.Locked);
                        _articleInformationControl.UpdateControlsForLockedStatus();
                    }
                    else
                    { //locked by other
                        IndicateCheckedOutByOther(checkedOut);
                        _parent.articleStatusBar1.ChangeLockButtonStatus(LockStatus.Locked);
                        _articleInformationControl.UpdateControlsForUnlockedStatus();
                    }
                    uxLockStatusLabel.Text = @"Locked";
                }
                else
                { //unlocked
                    IndicateUnlocked();
                    _articleInformationControl.UpdateControlsForUnlockedStatus();
                }
                uxRefreshStatus.Enabled = true;
            }
            else
            { //document is not linked to an article
                DocumentProtection.Unprotect(DocumentCustomProperties);
                _articleInformationControl.IsCheckedOutByMe = false;
                _articleInformationControl.IsCheckedOut     = false;
                _parent.PreLinkEnable();
            }
        }
Example #2
0
        /// <summary>
        /// Get from sitecore checked out status, then set control accordingly
        ///
        /// Unprotects document if locked by current user
        /// </summary>
        public void SetCheckedOutStatus()
        {
            if (_parent == null || _parent.ArticleDetails == null)
            {
                return;
            }
            _documentCustomProperties = new DocumentCustomProperties(SitecoreAddin.ActiveDocument);
            string articleNum = _parent.GetArticleNumber();

            if (!articleNum.IsNullOrEmpty())
            { //document is linked to an article
                SetArticleNumber(articleNum);
                PluginModels.CheckoutStatus checkedOut;
                if (_parent.ArticleDetails.ArticleGuid != Guid.Empty)
                {
                    checkedOut = SitecoreClient.GetLockedStatus(_parent.ArticleDetails.ArticleGuid);
                }
                else
                {
                    checkedOut = SitecoreClient.GetLockedStatus(articleNum);
                }
                IsCheckedOut = checkedOut.Locked;
                if (IsCheckedOut)
                {
                    if (SitecoreUser.GetUser().Username == checkedOut.User)
                    { //locked by me
                        IndicateCheckedOutByMe(checkedOut);
                    }
                    else
                    { //locked by other
                        IndicateCheckedOutByOther(checkedOut);
                    }
                    //uxLockStatusLabel.Text = @"Locked";
                }
                else
                { //unlocked
                    IndicateUnlocked();
                }
                //uxRefreshStatus.Enabled = true;
            }
            else
            { //document is not linked to an article
                DocumentProtection.Unprotect(_documentCustomProperties);
                IsCheckedOutByMe = false;
                IsCheckedOut     = false;

                _parent.PreLinkEnable();
            }
        }
Example #3
0
        public void IndicateCheckedOutByMe(PluginModels.CheckoutStatus checkedOut)
        {
            DocumentProtection.Unprotect(_documentCustomProperties);
            IsCheckedOutByMe = true;
            if (_parent.CloseOnSuccessfulLock && CheckWordDocVersion(_parent.ArticleDetails, false))
            {
                _parent.Close();
                return;
            }
            _parent.CloseOnSuccessfulLock = false;
            //uxLockStatus.BackColor = Color.FromArgb(255, 217, 234, 211);

            //uxLockUser.Text = FormatUserName(checkedOut.User);
            _parent.PostLinkEnable();
            //uxUnlockButton.Visible = true;
            //uxLockButton.Visible = false;
            //uxUnlockButton.Enabled = true;
        }
Example #4
0
        protected void SendWordDocumentToSitecore(Document activeDocument, DocumentCustomProperties documentCustomProperties, string articleNumber, ArticleStruct articleDetails)
        {
            string extension = GetExtension(activeDocument);

            DocumentProtection.Protect(documentCustomProperties);

            byte[] data = _wordUtils.GetWordBytes(activeDocument);
            if (data == null)
            {
                throw new Exception("Error saving file to disk.");
            }

            DocumentProtection.Unprotect(documentCustomProperties);
            string uploader = SitecoreUser.GetUser().Username;
            int    wordSitecoreVersionNumber = articleDetails.ArticleGuid != Guid.Empty
                                                ? this.SendDocumentToSitecoreByGuid(articleDetails.ArticleGuid, data, extension, uploader)
                                                : this.SendDocumentToSitecore(articleNumber, data, extension, uploader);

            documentCustomProperties.WordSitecoreVersionNumber = wordSitecoreVersionNumber;
        }
Example #5
0
        void OpenArticleInformationWindowIfNeeded(Word.Document doc)
        {
            var props = new DocumentCustomProperties(doc);

            if (props.PluginName != Constants.InformaPluginName)
            {
                return;
            }
            string articleNumber = props.ArticleNumber;

            if (!string.IsNullOrEmpty(articleNumber))
            {
                Log("Document opened with article number: " + articleNumber);
                if (!SitecoreUser.GetUser().IsLoggedIn)
                {
                    ArticleDetail.Open(true);
                }
                else
                {
                    CheckoutStatus checkedOut = SitecoreClient.GetLockedStatus(articleNumber);
                    if (checkedOut.User == SitecoreUser.GetUser().Username)
                    {
                        DocumentProtection.Unprotect(props);
                        return;
                    }
                    if (!checkedOut.Locked)
                    {
                        if (DialogFactory.PromptAutoLock() == DialogResult.Yes &&
                            SitecoreClient.CheckOutArticle(articleNumber, SitecoreUser.GetUser().Username))
                        {
                            DocumentProtection.Unprotect(props);
                        }
                    }
                    else
                    {
                        ArticleDetail.Open();
                    }
                }
            }
        }
Example #6
0
        public void IndicateCheckedOutByMe(CheckoutStatus checkedOut)
        {
            DocumentProtection.Unprotect(DocumentCustomProperties);
            _articleInformationControl.IsCheckedOutByMe = true;
            if (_parent.CloseOnSuccessfulLock && _articleInformationControl.CheckWordDocVersion(_parent.ArticleDetails, false))
            {
                _parent.Close();
                return;
            }
            _parent.CloseOnSuccessfulLock = false;
            var lockUserInfo = SitecoreClient.GetFullNameAndEmail(checkedOut.User);

            if (lockUserInfo.Count == 2)
            {
                uxLockUser.Text = lockUserInfo[0];
                label1.Text     = lockUserInfo[1];
            }
            //			uxLockUser.Text = _articleInformationControl.FormatUserName(checkedOut.User);
            _parent.PostLinkEnable();
            uxUnlockButton.Visible = true;
            uxLockButton.Visible   = false;
            uxUnlockButton.Enabled = true;
            _statusBar.ChangeLockButtonStatus(LockStatus.Locked);
        }