示例#1
0
        /// <summary>
        /// Remove all word bookmark that not exist on internal bookmark collection
        /// </summary>
        /// <param name="iBms"></param>
        public void ValidateBookmarkCollection(string key)
        {
            // 1. Get all word bookmark
            // 2. If bookmark in word not exist in internal bookmark
            // 2.1. markup this to return
            // 2.2. if isUpdate = true, we delete its
            try
            {
                ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService;
                InternalBookmark      iBms           = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(
                    contentProfile.ValidateBookmark_ITemplateName).InternalBookmark;

                GetBookmarkCollection(key);

                List <string> deletedList        = new List <string>();
                Dictionary <string, string> wBms = contentProfile.GetBookmarks_OListBM;

                foreach (string bmKey in wBms.Keys)
                {
                    InternalBookmarkItem item = iBms.GetInternalBookmarkItem(bmKey);

                    if (item == null || item.BizName != wBms[bmKey]) // compare key and value
                    {
                        if (MarkupUtilities.IsProntoDocCommentBookmark(bmKey) ||
                            MarkupUtilities.IsPdeTagBookmark(bmKey))
                        {
                            continue;
                        }

                        deletedList.Add(wBms[bmKey]);
                        contentProfile.HighlightBookmarkName = bmKey;
                        HighlightBookmark(key);

                        if (contentProfile.ValidateBookmark_IIsUpdate)
                        {
                            contentProfile.DeletedBookmarkName = bmKey;
                            contentProfile.DeleteWholeBookmark = false;
                            DeleteBookmark(key);
                        }
                    }
                }

                contentProfile.ValidateBookmark_ORemovedList = deletedList;
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateWordBookmarkError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_ValidateWordBookmarkError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_ValidateWordBookmarkError, ex.Message), ex.StackTrace);

                throw srvExp;
            }
        }