Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Delete all bookmarks with same value
        /// </summary>
        /// <param name="bmItem"></param>
        /// <returns></returns>
        public bool DeleteAllBookmarks(BookmarkItem bmItem)
        {
            try
            {
                for (int i = 0; i < bmItem.Items.Count; i++)
                {
                    DeleteBookmarkWithPair(bmItem.Items[i]);
                }
                return(true);
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_DeleteBookmarkError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Ejemplo n.º 3
0
        public string GetInternalBookmarkString()
        {
            try
            {
                string          srvKey = string.Empty;
                ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);
                GetInternalBookmark(srvKey);
                InternalBookmark internalBm = srvPro.Ibm;
                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);

                return(ObjectSerializeHelper.SerializeToString <InternalBookmark>(internalBm));
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_LoadInternalBookmarkError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// update table index and relation for internal bookmark
        /// </summary>
        /// <param name="key"></param>
        public void UpdateInternalBookmark(string key)
        {
            try
            {
                TemplateInfo templateInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(key);
                foreach (string domainName in templateInfo.DomainNames)
                {
                    DomainInfo             domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName);
                    InternalBookmarkDomain ibmDomain  = templateInfo.InternalBookmark.GetInternalBookmarkDomain(domainName);
                    foreach (InternalBookmarkItem iBmItem in ibmDomain.InternalBookmarkItems)
                    {
                        if (domainInfo.Fields.ContainsKey(iBmItem.BizName))
                        {
                            iBmItem.TableIndex = domainInfo.Fields[iBmItem.BizName].TableIndex;
                            iBmItem.Relation   = domainInfo.Fields[iBmItem.BizName].Relation;
                            iBmItem.DomainName = domainName;
                        }
                    }
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_UpdateIbmItemError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_UpdateIbmItemError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_UpdateIbmItemError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// update unique name for all fields in UscItem before add to internal bookmark when tagging
        /// ngocbv: need to confirm with Mery
        /// </summary>
        /// <param name="item"></param>
        /// <param name="domainName"></param>
        public void UpdateUniqueNameForUscItem(string key)
        {
            try
            {
                IntegrationServiceProfile inteProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).IntegrationService;

                if (inteProfile.UscItem != null && inteProfile.UscItem.Fields != null)
                {
                    DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(inteProfile.UscItem.DomainName);
                    foreach (USCItem field in inteProfile.UscItem.Fields)
                    {
                        if (domainInfo.Fields.ContainsKey(field.BusinessName))
                        {
                            field.UniqueName = domainInfo.Fields[field.BusinessName].UniqueName;
                        }
                    }
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_UpdateUSCItemError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_UpdateUSCItemError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_UpdateUSCItemError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 6
0
        public UserData GetLastSelectedDomain()
        {
            try
            {
                string data = FileAdapter.ReadUserData();

                UserData userData = string.IsNullOrWhiteSpace(data) ? null :
                                    ObjectSerializeHelper.Deserialize <UserData>(data);

                return(userData);
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_LoadResourceError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(Core.ErrorCode.ipe_LoadResourceError,
                                                               Core.MessageUtils.Expand(Properties.Resources.ipe_LoadResourceError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 7
0
        public static void LoadDomainData(string domainName)
        {
            try
            {
                //If not existed in Domain WKL
                if (!Wkl.MainCtrl.CommonCtrl.CommonProfile.DomainInfos.ContainsKey(domainName))
                {
                    DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.CreateDomainInfo(domainName);

                    DSDomain domainData = MemorySegment.GetDomain(AssetManager.FileAdapter.DataSegmentDllPath,
                                                                  domainName);
                    domainInfo.DSDomainData = domainData;
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_LoadDomainDataError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                Services.ServiceException srvExp = new Services.ServiceException(ErrorCode.ipe_LoadDomainDataError,
                                                                                 MessageUtils.Expand(Properties.Resources.ipe_LoadDomainDataError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 8
0
        public string GenXsl(string key)
        {
            try
            {
                ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);

                ValidateBookmarks();

                // prepare data
                _ibm = srvPro.Ibm;

                // replace bookmarks by xslt tags
                ReplaceBookmarkTag();

                // add multi-section
                AddMultiSection();

                // build xsl string (put header, body, footer)
                return(GetXslString());
            }
            catch (Pdw.Core.BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(Pdw.Core.ErrorCode.ipe_GetXslContentError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Delete internal bookmark that not exist in word bookmark
        /// </summary>
        public void ValidateInternalBookmarkCollection(string key)
        {
            // 1. Get internal bookmark object
            // 2. Get all key of internal bookmark item that not exist in word bookmark collection
            // 3. Remove all internal bookmark item has key in key collection above
            try
            {
                IntegrationServiceProfile integrationProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).IntegrationService;
                List <string>             removed            = new List <string>();
                InternalBookmark          iBms       = null;
                List <string>             removeKeys = new List <string>();

                string          srvKey = string.Empty;
                ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);
                GetInternalBookmark(srvKey);
                iBms = srvPro.Ibm;
                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);

                foreach (InternalBookmarkDomain ibmDomain in iBms.InternalBookmarkDomains)
                {
                    ValidateInternalBookmarkDomain(ibmDomain, integrationProfile.ValidateInternalBM_IListBM,
                                                   ref removed, ref removeKeys);
                }

                if (integrationProfile.ValidateInternalBM_IIsUpdate)
                {
                    srvKey = string.Empty;
                    srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);
                    foreach (string bmKey in removeKeys)
                    {
                        srvPro.WbmKey = bmKey;
                        RemoveInternalBookmark(srvKey);
                    }
                    Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);
                }

                integrationProfile.ValidateInternalBM_OListError = removed;
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateIbmsError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_ValidateIbmsError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_ValidateIbmsError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 11
0
        public ChecksumInfo GetChecksum()
        {
            try
            {
                string          srvKey = string.Empty;
                ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);
                GetPdwInformation(srvKey);
                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);
                List <XmlObject> customXmls = srvPro.XmlObjects;
                ChecksumInfo     checksum   = null;
                string           osql       = string.Empty;

                foreach (XmlObject xmlObject in customXmls)
                {
                    if (xmlObject == null)
                    {
                        continue;
                    }

                    if (xmlObject.ContentType == ContentType.Checksum)
                    {
                        checksum = ObjectSerializeHelper.Deserialize <ChecksumInfo>(xmlObject.Content);
                        checksum.InternalBookmark = GetInternalBookmarkString();
                        checksum.Osql             = osql;
                    }
                    else if (xmlObject.ContentType == ContentType.Osql)
                    {
                        osql = xmlObject.Content;
                        if (checksum != null)
                        {
                            checksum.Osql = osql;
                        }
                    }
                }

                return(checksum != null ? checksum : new ChecksumInfo());
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetChecksumError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_GetChecksumError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_GetChecksumError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Validate Internal Bookmark is match with any Domain. Key is full name of document
        /// </summary>
        /// <param name="fullDocName"></param>
        public void IsInternalBMMatchWithDomain(string key)
        {
            //1.Get InternalBM
            //2.Get Checksum information
            //3.Load Data from datasegment.
            //4.Check match
            try
            {
                IntegrationServiceProfile integrationProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).IntegrationService;
                TemplateInfo templateInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(integrationProfile.TemplateFileName);

                string          srvKey = string.Empty;
                ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);
                GetInternalBookmark(srvKey);
                templateInfo.InternalBookmark = srvPro.Ibm;
                templateInfo.UpdateDomainNames();
                templateInfo.PdeContent = srvPro.PdeContent;
                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);

                //Get Checksum Info.
                ChecksumInfo checksum = GetChecksum();

                integrationProfile.CheckMatchWithDomain_OListMatch = new List <DomainMatch>();
                integrationProfile.Result = true;
                foreach (InternalBookmarkDomain ibmDomain in templateInfo.InternalBookmark.InternalBookmarkDomains)
                {
                    DomainMatchItem domainMatchItem = IsMatchWithDataSegment(ibmDomain, ibmDomain.DomainName);
                    if (domainMatchItem != null && (!domainMatchItem.IsMatch || !domainMatchItem.IsMatchRelationOn)) // not match
                    {
                        DomainMatch domainMatch = FindTheNearestDomain(ibmDomain, domainMatchItem, ibmDomain.DomainName);
                        integrationProfile.CheckMatchWithDomain_OListMatch.Add(domainMatch);
                        integrationProfile.Result = false;
                    }
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateIbmWithDomainError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_ValidateIbmWithDomainError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_ValidateIbmWithDomainError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Delete Current Bookmark.
        /// </summary>
        /// <param name="bmItem"></param>
        /// <returns></returns>
        public bool DeleteOneBookmark(BookmarkItem bmItem)
        {
            //1.If selected text is bookmark, delete current bookmark
            //2.else: delete first bookmark
            //3. If bookmark is data tag, delete one bookmark only
            //4. If bookmark is a pair of bookmark, delete both.

            try
            {
                string          srvKey = string.Empty;
                ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);
                GetCurrentSelection(srvKey);
                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);
                Selection selectedText = srvPro.ContentService.WSelection;
                Bookmark  deletedBM;

                if (selectedText.Text.Trim().Equals(bmItem.Value) && (selectedText.Bookmarks.Count > 0))
                {
                    deletedBM = selectedText.Bookmarks[1];
                }
                else
                {
                    deletedBM = GetFirstBookmark(bmItem);
                }

                bmItem.Items.Remove(deletedBM);
                DeleteBookmarkWithPair(deletedBM);

                return(true);
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_DeleteBookmarkError);
                newSrvExp.Errors.Add(srvExp);

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

                return(false);

                throw srvExp;
            }
        }
Ejemplo n.º 14
0
        public string GenXsl(string key)
        {
            try
            {
                ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);
                if (_htmlPart == null)
                {
                    return(string.Empty);
                }

                // check struct of xml file
                _bookmarks = _htmlPart.GetBookmarks();
                if (_bookmarks.Count == 0)
                {
                    return(string.Empty);
                }

                ValidateBookmarks();

                // prepare data
                _ibm = srvPro.Ibm;

                // replace bookmarks by xslt tags
                ReplaceBookmarkTag();

                // add mht add-on and multi-section
                AddMhtAddOnAndSection();

                // build xsl string (put header, body, footer)
                return(GetXslString());
            }
            catch (Pdw.Core.BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(Pdw.Core.ErrorCode.ipe_GetXslContentError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Ejemplo n.º 15
0
        public static void GetListDomain()
        {
            try
            {
                if (Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers == null)
                {
                    Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers     = new Dictionary <string, Classifer>();
                    Wkl.MainCtrl.CommonCtrl.CommonProfile.ListDomains     = new Dictionary <string, bool>();
                    Wkl.MainCtrl.CommonCtrl.CommonProfile.DataSegmentInfo =
                        MemorySegment.GetAllDomain(AssetManager.FileAdapter.DataSegmentDllPath);

                    if (Wkl.MainCtrl.CommonCtrl.CommonProfile.DataSegmentInfo != null)
                    {
                        foreach (DSHeaderInfo domain in Wkl.MainCtrl.CommonCtrl.CommonProfile.DataSegmentInfo.DSHeaderInfos)
                        {
                            string classifier = (domain.Classifier == null) ? string.Empty : domain.Classifier;
                            string domainName = domain.Name;
                            if (!Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers.ContainsKey(classifier))
                            {
                                Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers.Add(classifier,
                                                                                      new Classifer(classifier));
                            }

                            Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers[classifier].DomainNames.Add(domainName);
                            if (!Wkl.MainCtrl.CommonCtrl.CommonProfile.ListDomains.ContainsKey(domainName))
                            {
                                Wkl.MainCtrl.CommonCtrl.CommonProfile.ListDomains.Add(domainName, domain.IsMultiSection);
                            }
                        }
                    }
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetListDomainError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                Services.ServiceException srvExp = new Services.ServiceException(ErrorCode.ipe_GetListDomainError,
                                                                                 MessageUtils.Expand(Properties.Resources.ipe_GetListDomainError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 16
0
        public static DSPlugin GetPlugInInfo()
        {
            try
            {
                return(MemorySegment.GetPluginInfo(AssetManager.FileAdapter.DataSegmentDllPath));
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetPluginInfoError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                Services.ServiceException srvExp = new Services.ServiceException(ErrorCode.ipe_GetPluginInfoError,
                                                                                 MessageUtils.Expand(Properties.Resources.ipe_GetPluginInfoError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 17
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;
            }
        }
Ejemplo n.º 18
0
        public bool IsProntoDoc()
        {
            try
            {
                ProntoDoc.Framework.CoreObject.PdwxObjects.ChecksumInfo checksum = mainService.PropertyService.GetChecksum();

                return(IsProntoDoc(checksum));
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateChecksumError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (System.Exception ex)
            {
                ServiceException srvExp = new ServiceException(Core.ErrorCode.ipe_ValidateChecksumError,
                                                               Core.MessageUtils.Expand(Properties.Resources.ipe_ValidateChecksumError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 19
0
        public void SaveSelectedDomainToFile(UserData userData)
        {
            try
            {
                string dataSerialize = ProntoDoc.Framework.Utils.ObjectSerializeHelper.SerializeToString(userData);
                FileAdapter.SaveUserData(dataSerialize);
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_SaveFileError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Gen check sum
        /// </summary>
        /// <param name="srvPro"></param>
        /// <param name="lstJParam">List JParameter just buit with select (-> has new order)</param>
        private void GetCheckSum(ServicesProfile srvPro, List <ChecksumInfoItem> checksumItems, string dscColor, bool hasDsc)
        {
            try
            {
                GenChecksumHelper genChkHelper = new GenChecksumHelper();
                srvPro.PdwInfo.ChecksumString = genChkHelper.GenChecksum(
                    srvPro.PdwInfo.OsqlString, checksumItems, srvPro.TemplateType, dscColor, hasDsc, srvPro.FullDocName);
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GenChecksumError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(
                    ErrorCode.ipe_GenChecksumError,
                    MessageUtils.Expand(Properties.Resources.ipe_GenChecksumError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// new: gen pdw file with word xml document (save docx as xml file for gen xslt)
        /// </summary>
        /// <param name="fullDocName"></param>
        /// <param name="isFull"></param>
        /// <returns></returns>
        public void GetPdwInfo(string key)
        {
            ServicesProfile         srvPro            = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);
            List <ChecksumInfoItem> checksumInfoItems = new List <ChecksumInfoItem>();

            srvPro.PdwInfo = new PdwInfo();
            TemplateInfo template = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(srvPro.FullDocName);

            if (srvPro.IsFullDoc)
            {
                #region gen osql
                GenOsqlHelper genOsqlHelper = new GenOsqlHelper();
                try
                {
                    srvPro.DomainInfos = new List <DomainInfo>();
                    int domainCount = template.DomainNames.Count;
                    int domainIndex = 0;
                    while (domainIndex < domainCount)
                    {
                        string domainName = template.DomainNames[domainIndex];
                        InternalBookmarkDomain ibmDomain = template.InternalBookmark.GetInternalBookmarkDomain(domainName);
                        if (ibmDomain != null && ibmDomain.InternalBookmarkItems != null &&
                            ibmDomain.InternalBookmarkItems.Count > 0)
                        {
                            srvPro.DomainInfos.Add(Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName));
                            domainIndex++;
                        }
                        else
                        {
                            template.RemoveDomainAt(domainIndex);
                            domainCount--;
                        }
                    }
                    genOsqlHelper.GenOsql(srvPro.DomainInfos, template.InternalBookmark);
                    srvPro.PdwInfo.OsqlString = genOsqlHelper.OsqlString;
                    checksumInfoItems         = genOsqlHelper.ChecksumInfoItems;
                }
                catch (BaseException srvExp)
                {
                    Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GenOsqlError);
                    newSrvExp.Errors.Add(srvExp);
                    LogUtils.Log("GenOsql_ServiceException", srvExp);
                    throw newSrvExp;
                }
                catch (Exception ex)
                {
                    ServiceException srvExp = new ServiceException(
                        ErrorCode.ipe_GenOsqlError,
                        MessageUtils.Expand(Properties.Resources.ipe_GenOsqlError, ex.Message), ex.StackTrace);
                    LogUtils.Log("GenOsql_SystemException", ex);
                    throw srvExp;
                }
                #endregion

                #region gen xsl
                GenXsltHelper genXsltHelper = new GenXsltHelper();
                try
                {
                    srvPro.Ibm = genOsqlHelper.Ibm;
                    genXsltHelper.GenXsl2007(key);
                    srvPro.PdwInfo.XsltString = srvPro.XsltString;
                }
                catch (BaseException srvExp)
                {
                    Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GenXsltError);
                    newSrvExp.Errors.Add(srvExp);

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

                // update RelationOn into InternalBookmark
                UpdateRelationOns(key);

                // pde content
                Integration.PdeService pdeService = new Integration.PdeService();
                pdeService.AddExportXSD(template.PdeContent);
                foreach (PdeContentItem item in template.PdeContent.Items)
                {
                    if (System.IO.File.Exists(item.FilePath))
                    {
                        try
                        {
                            string pdeFileContent = FileHelper.ExcelToBase64(item.FilePath);
                            item.FileContent = pdeFileContent;
                        }
                        catch { }
                    }
                }
                srvPro.PdwInfo.PdeContent = ObjectSerializeHelper.SerializeToString <PdeContent>(template.PdeContent);
            }

            // get checksum
            GetCheckSum(srvPro, checksumInfoItems, template.InternalBookmark.DocumentSpecificColor, template.InternalBookmark.HasDocumentSpecific);
        }
Ejemplo n.º 22
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;
            }
        }
Ejemplo n.º 23
0
        public void IsCorrectFileStructure(string key)
        {
            try
            {
                IntegrationServiceProfile integrationPro = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).IntegrationService;
                string filePath = integrationPro.CheckCorrectContent_IFilePath;

                bool hasOsql                = true;
                bool hasXslt                = true;
                bool hasChks                = true;
                bool hasInternalBookmark    = false;
                bool passPdmControlChecking = true;

                string          srvKey = string.Empty;
                ServicesProfile srvPro = null;

                bool isPdm = MarkupUtilities.GetTemplateType(filePath) == TemplateType.Pdm;

                if (Path.GetExtension(filePath).ToLower() == FileExtension.ProntoDocumenentWord || isPdm)
                {
                    hasOsql = false;
                    hasXslt = false;
                    hasChks = false;

                    srvKey = string.Empty;
                    srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);

                    if (isPdm)
                    {
                        passPdmControlChecking = false;
                        srvPro.TemplateType    = TemplateType.Pdm;
                    }

                    GetPdwInformation(srvKey);

                    Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);
                    List <XmlObject> xmlObjects = srvPro.XmlObjects;

                    foreach (XmlObject xmlObject in xmlObjects)
                    {
                        if (xmlObject == null)
                        {
                            continue;
                        }
                        switch (xmlObject.ContentType)
                        {
                        case ContentType.Osql:
                            hasOsql = true;
                            break;

                        case ContentType.Xslt:
                            hasXslt = true;
                            break;

                        case ContentType.Checksum:
                            hasChks = true;
                            break;

                        case ContentType.FormControls:
                            passPdmControlChecking = true;
                            break;

                        default:
                            break;
                        }
                    }
                }

                srvKey = string.Empty;
                srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);
                GetInternalBookmark(srvKey);
                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);

                hasInternalBookmark = srvPro.Ibm == null ? false : !srvPro.Ibm.IsNull();

                if (hasOsql && hasXslt && hasChks && hasInternalBookmark && passPdmControlChecking)
                {
                    integrationPro.Result = true;
                }
                else
                {
                    integrationPro.Result = false;
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateStructError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Add a bookmark into current document
        /// </summary>
        /// <param name="name">Name of bookmark</param>
        /// <param name="value">Value of bookmark</param>
        /// <param name="xsltType">XsltType (Select, Foreach or If)</param>
        /// <returns></returns>
        public bool AddBookmark(string key)
        {
            try
            {
                ServicesProfile      serviceProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);
                InternalBookmarkItem bm             = serviceProfile.ContentService.AddBookmark_IBookmark;
                Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.IsAdding = true;

                serviceProfile.ContentService.MarkProntDoc = true;
                switch (bm.Type)
                {
                case XsltType.Foreach:
                    AddDoubleBookmark(bm);
                    MarkProntoDoc(key);
                    break;

                case XsltType.If:
                    AddDoubleBookmark(bm);
                    MarkProntoDoc(key);
                    break;

                case XsltType.Select:
                    if (bm.IsImage())
                    {
                        serviceProfile.WbmKey          = bm.Key + ProntoMarkup.KeyImage;
                        serviceProfile.WbmValue        = MarkupUtilities.GenTextXslTag(bm.BizName, bm.Type, true);
                        serviceProfile.AlternativeText = MarkupUtilities.CreateAlternativeText(serviceProfile.WbmKey,
                                                                                               serviceProfile.WbmValue);
                        AddBookmarkImageEvent(key);
                    }
                    else
                    {
                        AddSingleBookmark(bm);
                    }
                    MarkProntoDoc(key);
                    break;

                case XsltType.Comment:
                    AddCommentBookmark(bm);
                    break;

                default:
                    break;
                }

                Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.IsAdding = false;
                return(true);
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_AddBookmarkError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Add internal bookmark item
        /// </summary>
        /// <param name="bm"></param>
        public void AddInternalBookmark(string key)
        {
            try
            {
                ServicesProfile           serviceProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);
                IntegrationServiceProfile integrationPro = serviceProfile.IntegrationService;
                InternalBookmarkItem      ibmItem        = integrationPro.AddInternalBM_IBookmark;
                if (string.IsNullOrWhiteSpace(ibmItem.DomainName))
                {
                    ibmItem.DomainName = Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.SelectedDomainName;
                }
                switch (ibmItem.Type)
                {
                case XsltType.Foreach:
                case XsltType.If:
                    InternalBookmarkItem start = ibmItem.Clone();
                    InternalBookmarkItem end   = ibmItem.Clone();

                    start.BizName = MarkupUtilities.GenTextXslTag(ibmItem.BizName, ibmItem.Type, true);
                    start.Key     = MarkupUtilities.GenKeyForXslTag(ibmItem.Key, ibmItem.Type, true);

                    serviceProfile.IbmItem = start;
                    AddInternalBookmarkItem(key);

                    end.BizName            = MarkupUtilities.GenTextXslTag(ibmItem.BizName, ibmItem.Type, false);
                    end.Key                = MarkupUtilities.GenKeyForXslTag(ibmItem.Key, ibmItem.Type, false);
                    serviceProfile.IbmItem = end;
                    AddInternalBookmarkItem(key);
                    break;

                case XsltType.Select:
                    InternalBookmarkItem select = ibmItem.Clone();
                    select.BizName = MarkupUtilities.GenTextXslTag(select.BizName, select.Type, true);
                    select.Key     = ibmItem.IsImage() ? select.Key + ProntoMarkup.KeyImage
                            : MarkupUtilities.GenKeyForXslTag(select.Key, select.Type, true);

                    serviceProfile.IbmItem = select;
                    AddInternalBookmarkItem(key);
                    break;

                case XsltType.Comment:
                    InternalBookmarkItem comment = ibmItem.Clone();
                    comment.BizName = MarkupUtilities.GenTextXslTag(comment.BizName, comment.Type, true);
                    comment.Key     = ibmItem.IsImage() ? comment.Key + ProntoMarkup.KeyImage
                            : MarkupUtilities.GenKeyForXslTag(comment.Key, comment.Type, true);

                    serviceProfile.IbmItem = comment;
                    AddInternalBookmarkItem(key);
                    break;

                default:
                    break;
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_AddIbmItemError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_AddIbmItemError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_AddIbmItemError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Ejemplo n.º 26
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;
            }
        }