Пример #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>
        /// 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);
        }