Ejemplo n.º 1
0
 public void UpdateFields()
 {
     if (_parent != null)
     {
         UpdateFields(SitecoreClient.ForceReadArticleDetails(_parent.GetArticleNumber()));
     }
 }
Ejemplo n.º 2
0
        private void uxWorkflowButton_Click(object sender, EventArgs e)
        {
            var history = SitecoreClient.GetItemWorkflowHistory(_parent.ArticleDetails.ArticleGuid);

            if (_parent.ArticleDetails.IsPublished)
            {
                DateTime actualPublishDate = SitecoreClient.GetArticleActualPublishedDate(_parent.ArticleDetails.ArticleGuid);

                if (actualPublishDate != DateTime.MinValue)
                {
                    MessageBox.Show(string.Format("Published on '{0}'", actualPublishDate.ToLocalTime().ToString("MM/dd/yyyy hh:mm:00 tt")));
                }
            }
            else
            {
                MessageBox.Show(string.Format("Workflow state: '{0}' since {1}", _parent.ArticleDetails.ArticleWorkflowState?.DisplayName, history.LastOrDefault().Item1.ToLocalTime().ToString("MM/dd/yyyy hh:mm:00 tt")));
            }
            return;

            var articleWorkFlowInfo = new ArticleWorkflowInfo(_parent)
            {
                StartPosition = FormStartPosition.CenterParent
            };

            articleWorkFlowInfo.ShowDialog();
        }
Ejemplo n.º 3
0
        public string RetrieveSidebarToken(string paragraph)
        {
            const string regex       = @"\[Sidebar#.*\]";
            string       articleGuid = "";
            Match        match       = Regex.Match(paragraph, regex);

            if (match.Success)
            {
                string matchStr      = match.Groups[0].Value;
                string articleNumber = matchStr.Replace("[Sidebar#", "");
                articleNumber = articleNumber.Replace("]", "");
                articleGuid   = SitecoreClient.GetArticleGuidByArticleNumber(articleNumber);
                if (new Guid(articleGuid) == Guid.Empty)
                {
                    throw new ArgumentException("Invalid sidebar article number inside paragraph contents: \"" + paragraph.TrimEnd() + "\"");
                }
            }
            else
            {
                throw new ArgumentException("Invalid content for sidebar articles: \"" + paragraph.TrimEnd() + "\"");
            }
            if (!articleGuid.IsNullOrEmpty())
            {
                Guid actualGuid = new Guid(articleGuid);
                if (!_sidebarArticleGuids.Contains(actualGuid))
                {
                    _sidebarArticleGuids.Add(actualGuid);
                }
                return("[Sidebar#{" + articleGuid + "}]");
            }
            return(null);
        }
Ejemplo n.º 4
0
 public static List <CharacterStyle> GetCharacterStyles()
 {
     if (CharacterStyles == null)
     {
         List <WordStyleStruct> styles = SitecoreClient.GetCharacterStyles().ToList();
         var    characterStyles        = styles.ToDictionary(style => style.WordStyle, style => style.CssElement);
         string boldElement;
         string italicElement;
         string underlineElement;
         string strikethroughElement;
         string superscriptElement;
         string subscriptElement;
         characterStyles.TryGetValue("Bold", out boldElement);
         characterStyles.TryGetValue("Italic", out italicElement);
         characterStyles.TryGetValue("Underline", out underlineElement);
         characterStyles.TryGetValue("Strikethrough", out strikethroughElement);
         characterStyles.TryGetValue("Superscript", out superscriptElement);
         characterStyles.TryGetValue("Subscript", out subscriptElement);
         BoldStyle          = new BoldStyle(boldElement);
         HyperlinkStyle     = new HyperlinkStyle("a");
         ItalicStyle        = new ItalicStyle(italicElement);
         StrikethroughStyle = new StrikethroughStyle(strikethroughElement);
         SubscriptStyle     = new SubscriptStyle(subscriptElement);
         SuperscriptStyle   = new SuperscriptStyle(superscriptElement);
         UnderlineStyle     = new UnderlineStyle(underlineElement);
         CharacterStyles    = new List <CharacterStyle>
         {
             BoldStyle, ItalicStyle, StrikethroughStyle,
             SubscriptStyle, SuperscriptStyle, UnderlineStyle
         };
     }
     return(CharacterStyles);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// The Method would open up and initialze the Article Information Plugin window. You can use this to set Taxonomy items, Article MetaData etc.
        /// </summary>
        private void OpenArticleInformation()
        {
            try
            {
                ArticleDetail.Open();

                if (GetArticleNumber() != null)
                {
                    CheckoutStatus checkedOut = SitecoreClient.GetLockedStatus(GetArticleNumber());
                    if (checkedOut.User == SitecoreUser.GetUser().Username)
                    {
                        SaveToSitecoreBtn.Enabled  = true;
                        ArticlePreviewMenu.Enabled = true;
                    }
                    else
                    {
                        SaveToSitecoreBtn.Enabled  = false;
                        ArticlePreviewMenu.Enabled = false;
                    }
                }
            }
            catch (UnauthorizedAccessException uax)
            {
                Globals.SitecoreAddin.LogException("ESRibbon.OpenArticleInformation: Error loading the article information window! Unauthorized access to API handler. Asking user to login again", uax);
                MessageBox.Show(Constants.SESSIONTIMEOUTERRORMESSAGE);
            }
            catch (Exception ex)
            {
                Globals.SitecoreAddin.LogException("ESRibbon.OpenArticleInformation: Error loading the article information window!", ex);
                MessageBox.Show
                    (@"An error has occurred while attempting to display the article information window. Please restart Word and try again." +
                    Environment.NewLine + Environment.NewLine +
                    @"If the problem persists, contact your system administrator.", @"Informa", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 6
0
        public static void PromptAndReExportNLMFeed(string articleNumber, bool isArticlePublished)
        {
            try
            {
                if (isArticlePublished)//Check if article is already published
                {
                    //If yes, ask author whether to reExport NLM feed which should have already been exported
                    if (MessageBox.Show("This story has already been published via XML feed. Do you want this story to be re-published to feed customers?", "Export NLM?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        //Call Web API to do the reExporting via the article Number
                        string result = SitecoreClient.ReExportArticleNlm(articleNumber);

                        if (string.IsNullOrEmpty(result))
                        {
                            //export success
                        }
                        else
                        {
                            Globals.SitecoreAddin.LogException("Something went wrong in the server side while reExporting NLM feed" + result);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.SitecoreAddin.LogException("Error when requesting an article NLM Reexport", ex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="metadataParser"></param>
        /// <returns>True if user wishes to break</returns>
        private bool PreSavePrompts(ArticleDocumentMetadataParser metadataParser)
        {
            if (string.IsNullOrEmpty(metadataParser.Title))
            {
                MessageBox.Show(@"Please enter an article title.", @"Informa", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(true);
            }

            if (NotifyTitleTooLong(metadataParser.Title.Trim().Length))
            {
                return(true);
            }

            if (metadataParser.TitleCount > 1)
            {
                if (!AskContinueMultipleTitles())
                {
                    return(true);
                }
            }
            int maxLengthLongSummary = SitecoreClient.GetMaxLengthLongSummary();

            if (metadataParser.ExecutiveSummary.Length > maxLengthLongSummary)
            {
                if (!AskExceededCharacterLimit("Summary", maxLengthLongSummary))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 8
0
        private void InitializeLogin()
        {
            try
            {
                loginControl1.ToReveal = uxArticlePanel;
                loginControl1.ShowLogin();


                if (!SitecoreClient.IsAvailable())
                {
                    SitecoreUser.GetUser().Logout();
                }
                if (SitecoreUser.GetUser().IsLoggedIn)
                {
                    _wordUtils = new WordUtils();
                    loginControl1.HideLogin();
                    UpdateFieldsUsingSitecore();
                }
            }
            catch (UnauthorizedAccessException uax)
            {
                Globals.SitecoreAddin.LogException("ArticleDetail.InitializeLogin: Unauthorized access to API handler. Must re-login", uax);
                throw uax;
            }
            catch (Exception ex)
            {
                var ax = new ApplicationException("ArticleDetail.InitializeLogin: Error setting up the login screen!", ex);
                Globals.SitecoreAddin.LogException(ax.Message, ex);
                throw ax;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Ascertain valid article number
        /// Link to article
        /// Indicate item is locked
        /// </summary>
        /// <param name="articleNumber"></param>
        /// <param name="prompt">Flag to prompt user if problem occurs</param>
        public bool CheckOut(string articleNumber, bool prompt = true)
        {
            if (articleNumber.IsNullOrEmpty())
            {
                MessageBox.Show
                    (@"Please enter an article number to link to.", @"Informa",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            try
            {
                bool exists = SitecoreClient.DoesArticleExist(articleNumber);
                if (!exists && prompt)
                {
                    MessageBox.Show
                        (@"Article number entered does not exist.", @"Informa",
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }
                ArticleNumber = articleNumber;
                //uxArticleNumberLabel.Text = articleNumber;

                PluginModels.CheckoutStatus checkedOut = SitecoreClient.GetLockedStatus(articleNumber);

                if (!checkedOut.Locked)
                { //if unlocked, then lock it by current user
                    if (SitecoreClient.DoesArticleHaveText(articleNumber) && prompt)
                    {
                        DialogResult dialogResult = MessageBox.Show
                                                        (@"This article already has some content uploaded. "
                                                        + @"If you choose to check out the article now and later upload, "
                                                        + @"you will overwrite that content. "
                                                        + @"Are you sure you wish to checkout this article?",
                                                        @"Informa",
                                                        MessageBoxButtons.YesNo,
                                                        MessageBoxIcon.Question);
                        if (dialogResult != DialogResult.Yes)
                        {
                            return(false);
                        }
                    }
                    SitecoreClient.CheckOutArticle(articleNumber, SitecoreUser.GetUser().Username);
                }
                SetCheckedOutStatus();
                if (_parent.CloseOnSuccessfulLock && IsCheckedOutByMe)
                {
                    return(true);
                }
                //establish link, regardless of lock status
                _parent.SetArticleDetails(SitecoreClient.ForceReadArticleDetails(articleNumber));
                _parent.UpdateFields();
                return(true);
            }
            catch (Exception ex)
            {
                Globals.SitecoreAddin.LogException("Error in article details when checking out article: [" + articleNumber + "]", ex);
                throw;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Authenticates username and password.
        /// </summary>
        /// <param name="username">User's username</param>
        /// <param name="password">User's password</param>
        /// <returns>True if authentication successful; otherwise, false.</returns>
        public UserStatusStruct Authenticate(string username, string password)
        {
            Globals.SitecoreAddin.Log("SitecoreUser.Authenticate: Trying to authenticate user [" + username + "]...");
            var domainAndUsername = DefaultDomain + @"\" + username;

            try
            {
                var userStatus = SitecoreClient.AuthenticateUser(domainAndUsername, password);
                if (userStatus.LoginSuccessful)
                {
                    Globals.SitecoreAddin.Log("SitecoreUser.Authenticate: Authentication succeeded.");
                    IsLoggedIn = true;
                    Username   = domainAndUsername;
                    Password   = password;
                    UserCookie = UserCredentialReader.GetReader().GetCookie(username);
                    InvokeAuthenticated(EventArgs.Empty);
                }
                return(userStatus);
            }
            catch (SoapException ex)
            {
                Globals.SitecoreAddin.LogException("SitecoreUser.Authenticate: Error during login or login failed!", ex);
                throw ex;
            }
        }
Ejemplo n.º 11
0
        public string ParseForInlineReferences(string doc)
        {
            const string regex     = @"\[A#.*?\]";
            string       parsedDoc = doc;
            var          match     = Regex.Match(doc, regex);

            while (match.Success)
            {
                string articleNumber = match.ToString();
                articleNumber = Regex.Replace(articleNumber, @"\<.*?>", "");
                articleNumber = Regex.Replace(articleNumber, @"\[A#", "");
                articleNumber = Regex.Replace(articleNumber, @"\]", "");
                if (!SitecoreClient.DoesArticleExist(articleNumber))
                {
                    match = match.NextMatch();
                    continue;
                }
                var articleGuid = new Guid(SitecoreClient.GetArticleGuidByArticleNumber(articleNumber));
                if (articleGuid == Guid.Empty)
                {
                    match = match.NextMatch();
                    continue;
                }
                if (!_inlineReferenceGuids.Contains(articleGuid))
                {
                    _inlineReferenceGuids.Add(articleGuid);
                }
                match = match.NextMatch();
            }
            return(parsedDoc);
        }
        private void uxViewDocument_Click(object sender, EventArgs e)
        {
            if (uxBrowseDocuments.SelectedNode != null && uxBrowseDocuments.SelectedNode.Tag is SitecorePath)
            {
                var path     = (SitecorePath)uxBrowseDocuments.SelectedNode.Tag;
                var itemPath = SitecoreClient.MediaPreviewUrl(path.Path);

                if ((itemPath.Contains(".mp3") || itemPath.Contains(".doc") || itemPath.Contains(".docx") || itemPath.Contains(".xls") ||
                     itemPath.Contains(".xlsx") || itemPath.Contains(".ppt") || itemPath.Contains(".pptx") ||
                     itemPath.Contains(".pdf")))
                {
                    try
                    {
                        Process.Start(itemPath);
                    }
                    catch (WebException)
                    {
                        Globals.SitecoreAddin.AlertConnectionFailure();
                    }
                }
                else
                {
                    MessageBox.Show(Resources.SupportingDocumentsControl_uxViewDocument_Click_Please_select_a_valid_document);
                }
            }
            else
            {
                MessageBox.Show(Resources.SupportingDocumentsControl_uxViewDocument_Click_Please_select_a_valid_document);
            }
        }
Ejemplo n.º 13
0
        public void UpdateFields(ArticleWorkflowState state, ArticleStruct articleStruct)
        {
            if (_staff == null)
            {
                _staff = SitecoreClient.GetStaffAndGroups();
            }

            uxNotifyPicker.DataSource    = _staff;
            uxNotifyPicker.DisplayMember = "Name";
            uxNotifyPicker.ValueMember   = "ID";
            if (state == null)
            {
                return;
            }
            _ArticleStruct = articleStruct;
            uxCurrentWorkflowValue.Text = state.DisplayName;
            Commands = new List <ArticleWorkflowCommand>();
            Commands.Insert(0, new ArticleWorkflowCommand {
                DisplayName = "Move in Workflow...", StringID = Guid.Empty.ToString()
            });
            if (state.Commands != null)
            {
                Commands.AddRange(state.Commands);
            }
            else
            {
                Globals.SitecoreAddin.Log("No workflow actions were available.");
                uxWorkflowActions.Enabled = false;
            }
            uxWorkflowActions.DataSource    = Commands;
            uxWorkflowActions.DisplayMember = "DisplayName";
            uxWorkflowActions.ValueMember   = "StringID";
            uxUnlockOnSave.Checked          = false;
            subjectLbl.Text = "Subject :";
        }
Ejemplo n.º 14
0
        public static bool Protect(DocumentCustomProperties props)
        {
            Document wordDoc    = props._wordDoc;
            var      dirtyState = wordDoc.Saved;

            try
            {
                var pass = SitecoreClient.GetDocumentPassword();
                if (wordDoc.ProtectionType == WdProtectionType.wdNoProtection)
                {
                    wordDoc.Protect(WdProtectionType.wdAllowOnlyReading, true, pass, false, true);
                    props.DocumentPassword = pass;
                }
            }
            catch (Exception ex)
            {
                Globals.SitecoreAddin.LogException("Problem protecting the word document!", ex);
                return(false);
            }
            finally
            {
                wordDoc.Saved = dirtyState;
            }
            return(true);
        }
        private void uxRefresh_Click(object sender, EventArgs e)
        {
            var values = SitecoreClient.GetSupportingDocumentsRootNode();

            uxBrowseDocuments.Nodes.Clear();
            AddRootNode(uxBrowseDocuments, values[1], values[0]);
            PreviewInfo(false);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// This method is used to perform the lock action. This is called when "Yes" is clicked in the lock confirmation box.
 /// </summary>
 public void LockYesActionMethod()
 {
     if (SitecoreClient.CheckOutArticle(_articleNumber, SitecoreUser.GetUser().Username))
     {
         _articleInformationControl.CheckWordDocVersion(_parent.ArticleDetails);
     }
     SetCheckedOutStatus();
 }
Ejemplo n.º 17
0
        /// <summary>
        ///
        ///
        /// Be sure to catch WebException indicating server could not be contacted
        /// Saves a locked document (and unlocks the local document)
        /// </summary>
        public bool SaveArticle(ArticleDocumentMetadataParser metadataParser = null, string body = null)
        {
            var documentCustomProperties = new DocumentCustomProperties(SitecoreAddin.ActiveDocument);
            var articleNumber            = GetArticleNumber();

            if (!string.IsNullOrEmpty(documentCustomProperties.ArticleNumber) && !string.IsNullOrEmpty(articleNumber))
            {
                if (articleNumber != documentCustomProperties.ArticleNumber)
                {
                    string alertMessage = "Article numbers do not match, are you sure you would like to continue? " +
                                          "This can happen accidentally if you switching between documents quickly during saving.";
                    DialogResult result = MessageBox.Show(alertMessage, "Article numbers do not match",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (result == DialogResult.No)
                    {
                        return(false);
                    }
                }
            }

            try
            {
                if (HasArticleNumber())
                {
                    var copy = ArticleDetails.ArticleGuid;
                    ArticleDetails = GetArticleDetails(articleNumber, metadataParser);
                    //TamerM 2016-09-13: Removed the below since copy doesn't always contain the active document Guid and GetArticleDetails does return the ArticleGuid from the server
                    //if (copy.Equals(new Guid()) == false)
                    //ArticleDetails.ArticleGuid = copy;
                    _sitecoreArticle = new SitecoreClient();
                    //TODO - Add workflow stuff here
                    List <string> errors = _sitecoreArticle.SaveArticle(SitecoreAddin.ActiveDocument, ArticleDetails,
                                                                        new Guid(), new List <StaffStruct>(), GetArticleNumber(), body);
                    if (errors != null && errors.Any())
                    {
                        foreach (string error in errors)
                        {
                            if (!String.IsNullOrEmpty(error))
                            {
                                MessageBox.Show(error, error.Contains("not secure") ? @" Non-Secure Multimedia Content" : @"Informa");
                            }
                        }
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.SitecoreAddin.LogException("Error when saving article!", ex);
                throw;
            }

            //TamerM - 2016-03-22: Prompt and ReExport  NLM FEED
            NLMFeedUtils.PromptAndReExportNLMFeed(ArticleDetails.ArticleNumber, ArticleDetails.IsPublished);

            return(true);
        }
Ejemplo n.º 18
0
        private void CompanyTreeView_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                _wrappers = SitecoreClient.GetAllCompaniesWithRelated();

                LoadCompanies(_wrappers);
            }
        }
Ejemplo n.º 19
0
        private string GetPreviewUrl(bool isMobile)
        {
            string guid           = SitecoreClient.GetArticleGuidByArticleNumber(GetArticleNumber());
            string domain         = Constants.EDITOR_ENVIRONMENT_SERVERURL;
            string mobileUrlParam = isMobile ? "&mobile=1" : String.Empty;
            string redirect       = (domain + @"?sc_itemid={" + guid + @"}&sc_mode=preview&sc_lang=en" + mobileUrlParam);

            return(redirect);
        }
 private void SupportingDocumentsControl_Load(object sender, EventArgs e)
 {
     if (!DesignMode)
     {
         SetSitecoreItemGetter(new SitecoreItemGetter());
         var values = SitecoreClient.GetSupportingDocumentsRootNode();
         AddRootNode(uxBrowseDocuments, values[1], values[0]);
     }
 }
Ejemplo n.º 21
0
        public void UpdateFields(ArticleStruct articleDetails)
        {
            List <TaxonomyStruct> taxonomyItems     = SitecoreClient.SearchTaxonomy("").ToList();
            HDirectoryStruct      taxonomyDirectory = SitecoreClient.GetHierarchyByGuid(new Guid(Constants.TAXONOMY_GUID));

            TabController.InitializeSitecoreValues(taxonomyItems, taxonomyDirectory);

            _isLive = articleDetails.IsPublished;
            label4.Refresh();
        }
Ejemplo n.º 22
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.º 23
0
        public void InitializePublications()
        {
            List <PluginModels.ItemStruct> publications = SitecoreClient.GetPublications();

            publications.Insert(0, new PluginModels.ItemStruct {
                ID = Guid.Empty, Name = "Select Publication"
            });
            uxPublication.DataSource    = publications;
            uxPublication.DisplayMember = "Name";
            uxPublication.ValueMember   = "ID";
        }
Ejemplo n.º 24
0
        public void InitializeMediaType()
        {
            List <PluginModels.ItemStruct> mediaTypes = SitecoreClient.GetMediaTypes();

            mediaTypes.Insert(0, new PluginModels.ItemStruct {
                ID = Guid.Empty, Name = "Select Media Type"
            });
            uxMediaTypes.DataSource    = mediaTypes;
            uxMediaTypes.DisplayMember = "Name";
            uxMediaTypes.ValueMember   = "ID";
        }
Ejemplo n.º 25
0
        public void InitializeContentType()
        {
            List <PluginModels.ItemStruct> contentTypes = SitecoreClient.GetContentTypes();

            contentTypes.Insert(0, new PluginModels.ItemStruct {
                ID = Guid.Empty, Name = "Select Content Type"
            });
            uxLabel.DataSource    = contentTypes;
            uxLabel.DisplayMember = "Name";
            uxLabel.ValueMember   = "ID";
        }
Ejemplo n.º 26
0
        public void UpdateFields(ArticleStruct articleDetails)
        {
            List <TaxonomyStruct> subjects =
                SitecoreClient.SearchTaxonomy("").ToList();
            HDirectoryStruct subjectDirectory = SitecoreClient.GetHierarchyByGuid(new Guid(Constants.SUBJECT_GUID));

            TabController.InitializeSitecoreValues(subjects, subjectDirectory);

            _isLive = articleDetails.IsPublished;
            label8.Refresh();
        }
Ejemplo n.º 27
0
 private byte[] GetData()
 {
     try
     {
         return(SitecoreClient.GetMediaLibraryItemData(_path));
     }
     catch (WebException e)
     {
         throw e;
     }
 }
Ejemplo n.º 28
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.º 29
0
        public void InitializeItems(ArticleStruct articleDetails)
        {
            if (articleDetails != null)
            {
                var featuredImage  = articleDetails.FeaturedImageSource;
                var imageMediaItem = SitecoreClient.GetMediaLibraryItem(featuredImage);
            }

            var values = SitecoreClient.GetGraphicsRootNode();

            AddRootNode(uxFeaturedImageTreeView, values[1], values[0]);
        }
Ejemplo n.º 30
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();
            }
        }