Пример #1
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;
            }
        }
Пример #2
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;
            }
        }
Пример #3
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;
            }
        }
Пример #4
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;
            }
        }
Пример #5
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;
            }
        }
Пример #6
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;
            }
        }