Exemplo n.º 1
0
        private void HighlightNotMatchFields(DomainMatch domainMatch)
        {
            try
            {
                foreach (DomainMatchItem matchItem in domainMatch.DomainMatchItems.Values)
                {
                    foreach (string wBmValue in matchItem.NotMatchBizs)
                    {
                        foreach (Bookmark wBm in Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc.Bookmarks)
                        {
                            if (MarkupUtilities.GetRangeText(wBm.Range) == wBmValue)
                            {
                                wBm.Range.HighlightColorIndex = ProntoMarkup.BackgroundHighLight;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_HighlightBookmarkError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_HighlightBookmarkError, ex.Message), ex.StackTrace);

                throw mgrExp;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get bookmark collection in word
        /// </summary>
        /// <returns>Dictionary with key is bookmark name and value is bookmark text</returns>
        public void GetBookmarkCollection(string key)
        {
            try
            {
                ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService;

                Dictionary <string, string> bookmarks = new Dictionary <string, string>();

                Bookmarks bms = Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks;

                foreach (Bookmark bookmark in bms)
                {
                    if (bookmark.Name.Contains(ProntoMarkup.KeyImage))
                    {
                        bookmarks.Add(bookmark.Name, MarkupUtilities.GetBizNameOfBookmarkImage(bookmark.Name,
                                                                                               Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc.InlineShapes));
                    }
                    else
                    {
                        bookmarks.Add(bookmark.Name, MarkupUtilities.GetRangeText(bookmark.Range));
                    }
                }

                contentProfile.GetBookmarks_OListBM = bookmarks;
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetWordBookmarksError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Exemplo n.º 3
0
        //public bool DeleteAllBookmark(string value)
        //{
        //    try
        //    {
        //        foreach (Bookmark bookmark in Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks)
        //            if (MarkupUtilities.GetRangeText(bookmark.Range).Equals(value))
        //                DeleteBookmark(bookmark);
        //        return true;
        //    }
        //    catch (System.Exception ex)
        //    {
        //        ManagerException mgrExp = new ManagerException(ErrorCode.ipe_DeleteBookmarkError,
        //            MessageUtils.Expand(Properties.Resources.ipe_DeleteBookmarkError, ex.Message), ex.StackTrace);

        //        throw mgrExp;
        //    }
        //}

        private void DeleteBookmark(Bookmark bookmark, bool isDeleteWhole)
        {
            if (bookmark != null)
            {
                // 1. remove order by if bookmark is data tag
                string name = bookmark.Name;
                string text = MarkupUtilities.GetRangeText(bookmark.Range);
                if (name.EndsWith(ProntoMarkup.KeySelect))
                {
                    System.Collections.Generic.List <Bookmark>  bms        = GetBookmarksOrderByPosition();
                    System.Collections.Generic.Stack <Bookmark> foreachBms = new System.Collections.Generic.Stack <Bookmark>();
                    bool isExist = false;
                    foreach (Bookmark bm in bms)
                    {
                        if (bm.Name.EndsWith(ProntoMarkup.KeyStartForeach))
                        {
                            foreachBms.Push(bm);
                        }
                        if (bm.Name.EndsWith(ProntoMarkup.KeyEndForeach))
                        {
                            foreachBms.Pop();
                        }
                        if (bm.Name == name)
                        {
                            isExist = true;
                            break;
                        }
                    }
                    if (isExist && foreachBms.Count > 0)
                    {
                        Bookmark foreachBm = foreachBms.Pop();
                        string   oldText   = MarkupUtilities.GetRangeText(foreachBm.Range);
                        string   newText   = oldText.Replace(text +
                                                             Constants.OrderBy.Concat +
                                                             Constants.OrderBy.AscMark +
                                                             Constants.OrderBy.Delimiter, "");
                        newText = newText.Replace(text +
                                                  Constants.OrderBy.Concat +
                                                  Constants.OrderBy.DescMark +
                                                  Constants.OrderBy.Delimiter, "");
                        newText = newText.Replace(Constants.OrderBy.Delimiter + text +
                                                  Constants.OrderBy.Concat +
                                                  Constants.OrderBy.AscMark, "");
                        newText = newText.Replace(Constants.OrderBy.Delimiter + text +
                                                  Constants.OrderBy.Concat +
                                                  Constants.OrderBy.DescMark, "");
                        if (oldText != newText)
                        {
                            UpdateBookmarkText(foreachBm, newText);
                        }
                    }
                }

                // 2. remove bookmark
                if (isDeleteWhole)
                {
                    bookmark.Range.Text = "";
                }
                else
                {
                    bookmark.Delete();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get bookmark collection in word
        /// </summary>
        /// <returns>Dictionary with key is bookmark name and value is bookmark text</returns>
        public void GetDistinctBookmarks(string key)
        {
            //1.Get All Bookmarks
            //2.Do not add EndIf, EndForEach bookmark
            //3.If a bookmark is existed in List, increase number entry
            //4.Else insert to list.
            try
            {
                ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService;
                List <BookmarkItem>   listBookmarks  = new List <BookmarkItem>();
                Bookmarks             bms            = Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks;

                for (int j = 1; j <= bms.Count; j++)
                {
                    Bookmark bookmark = bms[j];

                    //2.Do not add EndIf, EndForEach bookmark
                    if (!MarkupUtilities.GetRangeText(bookmark.Range).Contains(Constants.BookMarkControl.EndIfTag))
                    {
                        BookmarkItem item = new BookmarkItem(bookmark.Name, string.Empty, string.Empty, bookmark);
                        if (bookmark.Name.Contains("Image"))
                        {
                            GetInternalBookmark(key);
                            InternalBookmark internalBM = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).Ibm;
                            foreach (InternalBookmarkDomain ibmDomain in internalBM.InternalBookmarkDomains)
                            {
                                foreach (InternalBookmarkItem internalItem in ibmDomain.InternalBookmarkItems)
                                {
                                    if (internalItem.Key.CompareTo(bookmark.Name) == 0)
                                    {
                                        item.Value       = internalItem.BizName;
                                        item.DisplayName = SplitValue(internalItem.BizName);
                                    }
                                }
                            }
                        }
                        else
                        {
                            item.Value       = MarkupUtilities.GetRangeText(bookmark.Range);
                            item.DisplayName = SplitValue(item.Value);
                        }

                        if (listBookmarks.Count == 0)
                        {
                            listBookmarks.Add(item);
                        }
                        else
                        {
                            int  n       = -1;
                            bool existed = false;
                            for (int i = 0; i < listBookmarks.Count; i++)
                            {
                                n += 1;
                                if (listBookmarks[i].Value.Equals(item.Value))
                                {
                                    existed = true;
                                    break;
                                }
                            }

                            //3.
                            if (existed)
                            {
                                listBookmarks[n].NumberEntry += 1;
                                listBookmarks[n].Items.Add(bookmark);
                            }
                            else//4.
                            {
                                listBookmarks.Add(item);
                            }
                        }
                    }
                }
                contentProfile.GetDistinctBM_OListBM = listBookmarks;
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetDistinctBookmarkError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }