Exemple #1
0
        private bool IsMatchWithDataSegment(string docFullName, ref List <string> message)
        {
            try
            {
                // compare with data domain. if not exist in datadomain then highlight
                string key;
                ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key).ContentService;
                contentProfile.ValidateBookmark_ITemplateName = docFullName;

                mainManager.MainService.BookmarkService.ValidateBookmarkCollectionWithDomain(key);

                bool result = (bool)contentProfile.Result;

                message.AddRange(contentProfile.UnMatchedFields);

                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);

                return(result);
            }
            catch (BaseException baseExp)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckWbmWithDatasegment);
                mgrExp.Errors.Add(baseExp);

                throw mgrExp;
            }
            catch (Exception ex)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckWbmWithDatasegment,
                                                               MessageUtils.Expand(Properties.Resources.ipe_CheckWbmWithDatasegment, ex.Message), ex.StackTrace);

                throw mgrExp;
            }
        }
Exemple #2
0
        private void HighlightAllBookmark(InternalBookmark iBm)
        {
            try
            {
                if (iBm != null && iBm.InternalBookmarkDomains != null)
                {
                    string key;

                    ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key).ContentService;
                    foreach (InternalBookmarkDomain ibmDomain in iBm.InternalBookmarkDomains)
                    {
                        foreach (InternalBookmarkItem item in ibmDomain.InternalBookmarkItems)
                        {
                            contentProfile.HighlightBookmark_IBMName = item.Key;
                            mainManager.MainService.BookmarkService.HighlightWordBookmark(key);
                        }
                    }
                    Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);
                }
            }
            catch (BaseException baseExp)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_HighlightBookmarkError);
                mgrExp.Errors.Add(baseExp);
                throw mgrExp;
            }
            catch (Exception ex)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_HighlightBookmarkError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_HighlightBookmarkError, ex.Message), ex.StackTrace);

                throw mgrExp;
            }
        }
Exemple #3
0
        public void HighlightWordBookmark(string key)
        {
            try
            {
                ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService;
                string          keyService;
                ServicesProfile serviceProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out keyService);
                if (!string.IsNullOrEmpty(contentProfile.HighlightBookmark_IBMName))
                {
                    HighlightBookmark(keyService);
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_HighlightBookmarkError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Exemple #4
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;
            }
        }
Exemple #5
0
        public void EnableDomain()
        {
            string key;
            ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key).ContentService;

            GetDistinctBookmarks(key);

            if (contentProfile.GetDistinctBM_OListBM.Count <= 0)
            {
                EnableComboboxDomain();
            }

            Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);
        }
Exemple #6
0
        private bool IsMatchBetweenInternalAndWord(ref List <string> message, bool isUpdate, string templateName)
        {
            try
            {
                // update word bm (remove bm exist in word but not exist in internal)
                InternalBookmark interBm = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(templateName).InternalBookmark;
                string           serviceKey;

                //Add to WKL
                ServicesProfile       serviceProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out serviceKey);
                ContentServiceProfile contentProfile = serviceProfile.ContentService;
                contentProfile.ValidateBookmark_IIsUpdate     = isUpdate;
                contentProfile.ValidateBookmark_ITemplateName = templateName;
                mainManager.MainService.BookmarkService.ValidateBookmarkCollection(serviceKey);
                message.AddRange(contentProfile.ValidateBookmark_ORemovedList);

                // update internal bookmark (remove bm exist in internal but not exist in word)
                mainManager.MainService.BookmarkService.GetBookmarkCollection(serviceKey);

                IntegrationServiceProfile integrationPro = serviceProfile.IntegrationService;
                integrationPro.ValidateInternalBM_IListBM   = contentProfile.GetBookmarks_OListBM;
                integrationPro.ValidateInternalBM_IIsUpdate = isUpdate;
                mainManager.MainService.PropertyService.ValidateInternalBookmarkCollection(serviceKey);
                message.AddRange(integrationPro.ValidateInternalBM_OListError);

                //Remove objects in Wkl
                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(serviceKey);

                return(contentProfile.ValidateBookmark_ORemovedList.Count == 0 &&
                       integrationPro.ValidateInternalBM_OListError.Count == 0);
            }
            catch (BaseException baseExp)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckIbmAndWbmError);
                mgrExp.Errors.Add(baseExp);

                throw mgrExp;
            }
            catch (Exception ex)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckIbmAndWbmError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_CheckIbmAndWbmError, ex.Message), ex.StackTrace);
                throw mgrExp;
            }
        }
Exemple #7
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;
            }
        }
Exemple #8
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;
            }
        }
Exemple #9
0
        /// <summary>
        /// Highlight all word bookmark that not exist on data domain
        /// </summary>
        /// <param name="iBms"></param>
        public void ValidateBookmarkCollectionWithDomain(string key)
        {
            try
            {
                bool          isHighlight = false;
                List <string> unMatched   = new List <string>();

                //Get Bookmark Collection then put to WKL
                GetBookmarkCollection(key);

                ContentServiceProfile       contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService;
                Dictionary <string, string> wBm            = contentProfile.GetBookmarks_OListBM;

                //Get Internal Bookmark
                TemplateInfo templateInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(
                    contentProfile.ValidateBookmark_ITemplateName);
                InternalBookmark interBm = templateInfo.InternalBookmark;

                //Get Domain Data
                foreach (string domainName in templateInfo.DomainNames)
                {
                    DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName);
                    if (domainInfo != null)
                    {
                        InternalBookmarkDomain ibmDomain = interBm.GetInternalBookmarkDomain(domainName);
                        foreach (InternalBookmarkItem item in ibmDomain.InternalBookmarkItems)
                        {
                            if (!MarkupUtilities.IsExistOnDomain(item, domainInfo.Fields, true))
                            {
                                if (wBm.ContainsKey(item.Key) && wBm[item.Key] == item.BizName)
                                {
                                    contentProfile.HighlightBookmarkName = item.Key;
                                    unMatched.Add(item.BizName);
                                    HighlightBookmark(key);
                                    isHighlight = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        isHighlight = true;
                    }
                }

                contentProfile.UnMatchedFields = unMatched;
                contentProfile.Result          = !isHighlight;
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateWordBookmarkWithDomainError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }