Example #1
0
        public void btnHighlightBookmark_Click(Office.IRibbonControl control)
        {
            try
            {
                TemplateInfo templateInfo = Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo;
                if (templateInfo != null && templateInfo.InternalBookmark != null &&
                    templateInfo.DomainNames != null &&
                    templateInfo.DomainNames.Count > 0)
                {
                    DomainSelector domainSelector = new DomainSelector();
                    domainSelector.ShowDialog();
                    Dictionary <string, string> selectedDomains = domainSelector.DataTagColor;
                    bool   isHighlight = domainSelector.IsHighlight;
                    string colorNameDS = domainSelector.DocumentSpecificConditionColor;
                    DefineColors.DefineColor colorDS = DefineColors.GetColor(colorNameDS, false);
                    foreach (KeyValuePair <string, string> selectedDomain in selectedDomains)
                    {
                        InternalBookmarkDomain ibmDomain = templateInfo.InternalBookmark.GetInternalBookmarkDomain(selectedDomain.Key);
                        if (ibmDomain != null && ibmDomain.InternalBookmarkItems != null)
                        {
                            string colorNameDT = selectedDomain.Value;
                            DefineColors.DefineColor colorDT = DefineColors.GetColor(colorNameDT, false);

                            foreach (InternalBookmarkItem ibmItem in ibmDomain.InternalBookmarkItems)
                            {
                                string key = string.Empty;
                                Pdw.WKL.Profiler.Manager.ManagerProfile profile = Wkl.MainCtrl.ManagerCtrl.CreateProfile(out key);
                                profile.HighlightBookmarkName = ibmItem.Key;
                                Managers.DataIntegration.DataIntegrationManager bmMgr = new Managers.DataIntegration.DataIntegrationManager();
                                bool isDocumentSpecific = MarkupUtilities.IsProntoDocDocumentSpecificBookmark(ibmItem.Key);
                                if (isDocumentSpecific)
                                {
                                    if (colorDS != null)
                                    {
                                        profile.WdColorIndex = colorDS.Color;
                                    }
                                }
                                else
                                {
                                    if (colorDT != null)
                                    {
                                        profile.WdColorIndex = colorDT.Color;
                                    }
                                }

                                if (isHighlight)
                                {
                                    bmMgr.HighLightBookmark(key);
                                }
                                else
                                {
                                    bmMgr.UnHighLightBookmark(key);
                                }
                            }
                            ibmDomain.Color = isHighlight ? colorNameDT : string.Empty;
                            templateInfo.InternalBookmark.DocumentSpecificColor = isHighlight ? colorNameDS : string.Empty;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtils.Log("chkHighlightBookmark_Click", ex);
            }
        }
Example #2
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;
            }
        }
Example #3
0
        public void ValidateDataTagPosition(string key)
        {
            ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);

            GetForeachTagsBoundCurrentPosEvent(key);

            srvPro.ContentService.IsValid = true;
            InternalBookmark ibm = Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.InternalBookmark;

            //DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(srvPro.ContentService.DomainName);
            //Dictionary<int, int> tableIndexes = new Dictionary<int, int>();
            foreach (string wbmName in srvPro.ContentService.DicBookmarks.Keys)
            {
                string startName = string.Empty;
                string endName   = string.Empty;

                if (wbmName.EndsWith(ProntoMarkup.KeyStartForeach))
                {
                    startName = wbmName;
                    endName   = wbmName.Replace(ProntoMarkup.KeyStartForeach, ProntoMarkup.KeyEndForeach);
                }
                else if (wbmName.EndsWith(ProntoMarkup.KeyEndForeach))
                {
                    endName   = wbmName;
                    startName = wbmName.Replace(ProntoMarkup.KeyEndForeach, ProntoMarkup.KeyStartForeach);
                }
                //else
                //{
                //    InternalBookmarkItem ibmItem = ibm.GetInternalBookmarkItem(wbmName);
                //    if (ibmItem != null)
                //    {
                //        int tableIndex = Math.Max(0, ibmItem.TableIndex);
                //        if (!tableIndexes.ContainsKey(tableIndex))
                //            tableIndexes.Add(tableIndex, tableIndex);
                //    }
                //}

                #region check: all data tags can  inside only Domain
                if (srvPro.ContentService.DicBookmarks.ContainsKey(startName) && srvPro.ContentService.DicBookmarks.ContainsKey(endName))
                {
                    InternalBookmarkDomain ibmDomain = ibm.GetInternalBookmarkDomainByItemKey(startName);
                    if (ibmDomain.DomainName != srvPro.ContentService.DomainName)
                    {
                        srvPro.ContentService.IsValid = false;
                        srvPro.Message = "Only allow data tag of [" + ibmDomain.DomainName + "] in this foreach tag.";
                        return;
                    }

                    #region get order by
                    //Dictionary<string, OrderByType> sorteds = MarkupUtilities.GetOldOrderBy(srvPro.ContentService.DicBookmarks[startName].Range.Text, false);
                    //if (sorteds.Count > 0)
                    //{
                    //    foreach (string bizName in sorteds.Keys)
                    //    {
                    //        string originalBizName = domainInfo.GetUdfSortedBizName(bizName);
                    //        ProntoDoc.Framework.CoreObject.DataSegment.DSTreeView field = domainInfo.GetField(originalBizName);
                    //        if (field != null)
                    //        {
                    //            int tableIndex = field.TableIndex;
                    //            tableIndex = Math.Max(0, tableIndex);
                    //            if (!tableIndexes.ContainsKey(tableIndex))
                    //                tableIndexes.Add(tableIndex, tableIndex);
                    //        }
                    //    }
                    //}
                    #endregion
                }
                #endregion
            }

            #region check: all data tags can  inside only Domain
            //int pathCount = 0;
            //if (tableIndexes.Count > 0)
            //{
            //    foreach (var dsRelationRow in domainInfo.DSDomainData.TableRelations.Rows.Items)
            //    {
            //        if ("WhereClause".Equals(dsRelationRow.Name, StringComparison.OrdinalIgnoreCase))
            //            continue;

            //        string relations = ProntoDoc.Framework.Utils.BitHelper.ToBinaryFormat(dsRelationRow.Data, true);
            //        relations = BaseMarkupUtilities.ReverseString(relations);
            //    }
            //}
            #endregion
        }
Example #4
0
        private void ReplaceBookmarkTag()
        {
            _foreach = new List <ForeachItem>();
            for (int index = 0; index < _bookmarks.Count; index++)
            {
                PartBookmark  bookmark      = _bookmarks[index];
                List <string> selectedTable = GetSelectedTables(bookmark);
                Relations     relations     = GetRelations(bookmark);
                if (!bookmark.IsDelete)
                {
                    string xslPath = string.Empty;
                    switch (bookmark.Type)
                    {
                    case Core.BookmarkType.EndForeach:
                        bookmark.XslString = XslContent.XslFormat.XslEndForeach;
                        if (_foreach.Count > 0)
                        {
                            _foreach.RemoveAt(_foreach.Count - 1);
                        }
                        UpdateBookmarkPart(bookmark, index);
                        break;

                    case Core.BookmarkType.EndIf:
                        bookmark.XslString = XslContent.XslFormat.XslEndIf;
                        UpdateBookmarkPart(bookmark, index);
                        break;

                    case Core.BookmarkType.Image:
                        xslPath            = GetXslPath(bookmark, bookmark.BizName, false, selectedTable, relations);
                        bookmark.XslString = XslContent.XslValueOfTag(xslPath);
                        UpdateImageBookmark(bookmark);
                        break;

                    case Core.BookmarkType.Select:
                        xslPath            = GetXslPath(bookmark, bookmark.BizName, false, selectedTable, relations);
                        bookmark.XslString = XslContent.XslValueOfTag(xslPath,
                                                                      bookmark.BizName == ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwWatermark ? false : true);
                        UpdateBookmarkPart(bookmark, index);
                        break;

                    case Core.BookmarkType.StartIf:
                        xslPath            = GetXslPath(bookmark, bookmark.BizName, true, selectedTable, relations);
                        bookmark.XslString = XslContent.XslStartIfTag(xslPath);
                        UpdateBookmarkPart(bookmark, index);
                        break;

                    case Core.BookmarkType.StartForeach:
                        int    indexForeach = _foreach.Count + 1;
                        string variant      = Core.MarkupConstant.XslVariableImage + index.ToString();
                        InternalBookmarkDomain ibmDomain = _ibm.GetInternalBookmarkDomainByItemKey(bookmark.Key);
                        ForeachItem            fItem     = new ForeachItem(index, _bookmarks.Cast <Base.BaseBookmark>(),
                                                                           relations, ibmDomain.SelectedTables, indexForeach, variant, string.Empty);
                        _foreach.Add(fItem);

                        xslPath = GetXslPath(bookmark, string.Empty, false, selectedTable, relations);
                        InternalBookmarkItem ibmItem = _ibm.GetInternalBookmarkItem(bookmark.Key);
                        string sort = GetSortXsl(bookmark.BizName, ibmItem.DomainName, selectedTable, relations, true);
                        bookmark.XslString = XslContent.XslStartForeachTag(xslPath,
                                                                           variant, Core.MarkupConstant.XslMultiPosition, sort);
                        fItem.XslString = bookmark.XslString;

                        UpdateBookmarkPart(bookmark, index);
                        break;

                    default:
                        break;
                    }
                }
            }
        }