示例#1
0
        /// <summary>
        /// find the domain has max match with domain name
        /// </summary>
        /// <param name="ibmDomain"></param>
        /// <param name="matched"></param>
        /// <param name="domainName"></param>
        /// <returns></returns>
        private DomainMatch FindTheNearestDomain(InternalBookmarkDomain ibmDomain, DomainMatchItem matched, string domainName)
        {
            DomainMatch matchResult = new DomainMatch()
            {
                DomainName = domainName
            };

            matchResult.DomainMatchItems = new Dictionary <string, DomainMatchItem>();
            if (matched != null)
            {
                matchResult.DomainMatchItems.Add(domainName, matched);
            }

            // check all domain
            DataSegmentHelper.GetListDomain();
            List <string> domains = Wkl.MainCtrl.CommonCtrl.CommonProfile.ListDomains.Keys.ToList();

            foreach (string domain in domains)
            {
                if (domainName != domain)
                {
                    DomainMatchItem result = IsMatchWithDataSegment(ibmDomain, domain);
                    if (result != null)
                    {
                        matchResult.DomainMatchItems.Add(domain, result);
                    }
                }
            }

            return(matchResult);
        }
示例#2
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;
            }
        }
示例#3
0
        /// <summary>
        /// check internal bookmark is match with domain data in datasegment or no
        /// = 0: match (that mean same where clause and all field (biz name and unique name))
        /// > 0: number of field in internal not match with datasegment
        /// &lt; 0: where clause is not match
        /// </summary>
        /// <param name="ibmDomain"></param>
        /// <param name="domainName"></param>
        /// <returns>
        /// </returns>
        private DomainMatchItem IsMatchWithDataSegment(InternalBookmarkDomain ibmDomain, string domainName)
        {
            DataSegmentHelper.LoadDomainData(domainName);
            DomainMatchItem matchResult = new DomainMatchItem(domainName);

            matchResult.IsMatchWhereClause = true;
            DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName);

            if (domainInfo == null || domainInfo.DSDomainData == null)
            {
                return(null);
            }

            #region 1. Compare fields
            #region 1.2. get internal bookmark item collection from internal bookmark object
            List <InternalBookmarkItem> iItems = GetInternalBookmarkItemCollection(ibmDomain);
            #endregion

            #region 1.3. compare datasegment's field collection with internal bookmark's field collection
            foreach (InternalBookmarkItem item in iItems)
            {
                if (IsMatchWithDataSegment(item, domainInfo.Fields))
                {
                    matchResult.MatchedFields.Add(item.BizName);
                }
                else
                {
                    matchResult.NotMatchFields.Add(item.BizName);
                    if (item.Type == XsltType.Select)
                    {
                        matchResult.SetSingleBiz(item.Key);
                    }
                    else
                    {
                        matchResult.SetDoubleBiz(item.Key);
                    }
                }
            }
            #endregion

            if (!matchResult.IsMatch)
            {
                return(matchResult);
            }
            #endregion

            #region 2. Compare RelationOn
            foreach (RelationOn relationOn in ibmDomain.RelationOns)
            {
                DSOnClause item = domainInfo.DSDomainData.OnClauses.Items.FirstOrDefault(c =>
                                                                                         string.Equals(relationOn.UniqueName, c.UniqueName) &&
                                                                                         string.Equals(relationOn.OnClause, c.ExClause));
                if (item == null)
                {
                    matchResult.IsMatchRelationOn = false;
                    return(matchResult);
                }
            }
            #endregion

            #region 3. compare where clause
            if (ibmDomain.WhereClause != domainInfo.DSDomainData.WhereClause.Clause)
            {
                matchResult.IsMatchWhereClause = false;
            }
            #endregion
            return(matchResult);
        }