예제 #1
0
 internal void AddName(DecreeReferent dr)
 {
     Pullenti.Ner.Slot s = dr.FindSlot(ATTR_NAME, null, true);
     if (s == null)
     {
         return;
     }
     Pullenti.Ner.Slot ss = this.AddSlot(ATTR_NAME, s.Value, false, 0);
     if (ss != null && ss.Tag == null)
     {
         ss.Tag = s.Tag;
     }
 }
예제 #2
0
        bool _CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ, bool ignoreGeo)
        {
            DecreeReferent dr = obj as DecreeReferent;

            if (dr == null)
            {
                return(false);
            }
            if (dr.Typ0 != null && Typ0 != null)
            {
                if (dr.Typ0 != Typ0)
                {
                    return(false);
                }
            }
            int numEq = 0;

            if (Number != null || dr.Number != null)
            {
                if (Number != null && dr.Number != null)
                {
                    List <string> di1 = this._allNumberDigits();
                    List <string> di2 = dr._allNumberDigits();
                    foreach (string d1 in di1)
                    {
                        if (di2.Contains(d1))
                        {
                            numEq = 1;
                            break;
                        }
                    }
                    if (numEq == 0 && !IsLaw)
                    {
                        return(false);
                    }
                    foreach (Pullenti.Ner.Slot s in Slots)
                    {
                        if (s.TypeName == ATTR_NUMBER)
                        {
                            if (dr.FindSlot(s.TypeName, s.Value, true) != null)
                            {
                                numEq = 2;
                                break;
                            }
                        }
                    }
                    if (numEq == 0)
                    {
                        return(false);
                    }
                }
            }
            if (CaseNumber != null && dr.CaseNumber != null)
            {
                if (CaseNumber != dr.CaseNumber)
                {
                    return(false);
                }
            }
            if (this.FindSlot(ATTR_GEO, null, true) != null && dr.FindSlot(ATTR_GEO, null, true) != null)
            {
                if (this.GetStringValue(ATTR_GEO) != dr.GetStringValue(ATTR_GEO))
                {
                    return(false);
                }
            }
            bool srcEq    = false;
            bool srcNotEq = false;

            Pullenti.Ner.Slot src = this.FindSlot(ATTR_SOURCE, null, true);
            if (src != null && dr.FindSlot(ATTR_SOURCE, null, true) != null)
            {
                if (dr.FindSlot(src.TypeName, src.Value, true) == null)
                {
                    srcNotEq = true;
                }
                else
                {
                    srcEq = true;
                }
            }
            bool   dateNotEq  = false;
            bool   dateIsEqu  = false;
            bool   yearsIsEqu = false;
            string date1      = this.GetStringValue(ATTR_DATE);
            string date2      = dr.GetStringValue(ATTR_DATE);

            if (date1 != null || date2 != null)
            {
                if (IsLaw)
                {
                    List <int> ys1 = this._allYears();
                    List <int> ys2 = dr._allYears();
                    foreach (int y1 in ys1)
                    {
                        if (ys2.Contains(y1))
                        {
                            yearsIsEqu = true;
                            break;
                        }
                    }
                    if (yearsIsEqu)
                    {
                        List <DateTime> dts1 = this._allDates();
                        List <DateTime> dts2 = dr._allDates();
                        foreach (DateTime d1 in dts1)
                        {
                            if (dts2.Contains(d1))
                            {
                                dateIsEqu = true;
                                break;
                            }
                        }
                    }
                    if (!dateIsEqu)
                    {
                        if (Typ == "КОНСТИТУЦИЯ")
                        {
                            return(false);
                        }
                        if (Date != null && dr.Date != null)
                        {
                            dateNotEq = true;
                        }
                    }
                }
                else if (date1 == date2 || ((Date != null && dr.Date != null && Date == dr.Date)))
                {
                    if (numEq > 1)
                    {
                        return(true);
                    }
                    dateIsEqu = true;
                }
                else if (Date != null && dr.Date != null)
                {
                    if (Date.Value.Year != dr.Date.Value.Year)
                    {
                        return(false);
                    }
                    if (numEq >= 1)
                    {
                        if (srcEq)
                        {
                            return(true);
                        }
                        if (srcNotEq)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts || Kind == DecreeKind.Publisher)
                {
                    dateNotEq = true;
                }
            }
            if (this.FindSlot(ATTR_NAME, null, true) != null && dr.FindSlot(ATTR_NAME, null, true) != null)
            {
                foreach (Pullenti.Ner.Slot s in Slots)
                {
                    if (s.TypeName == ATTR_NAME)
                    {
                        if (dr.FindSlot(s.TypeName, s.Value, true) != null)
                        {
                            return(true);
                        }
                        foreach (Pullenti.Ner.Slot ss in dr.Slots)
                        {
                            if (ss.TypeName == s.TypeName)
                            {
                                string n0 = s.Value.ToString();
                                string n1 = ss.Value.ToString();
                                if (n0.StartsWith(n1) || n1.StartsWith(n0))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
                if (dateNotEq)
                {
                    return(false);
                }
                if (IsLaw && !dateIsEqu)
                {
                    return(false);
                }
                if (numEq > 0)
                {
                    if (srcEq)
                    {
                        return(true);
                    }
                    if (srcNotEq && typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts)
                    {
                        return(false);
                    }
                    else if ((!srcNotEq && numEq > 1 && Date == null) && dr.Date == null)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            else if (IsLaw && dateNotEq)
            {
                return(false);
            }
            if (dateNotEq)
            {
                return(false);
            }
            string ty = Typ;

            if (ty == null)
            {
                return(numEq > 0);
            }
            DecreeKind t = Pullenti.Ner.Decree.Internal.DecreeToken.GetKind(ty);

            if (t == DecreeKind.Ustav || ty == "КОНСТИТУЦИЯ")
            {
                return(true);
            }
            if (numEq > 0)
            {
                return(true);
            }
            if (this.ToString() == obj.ToString())
            {
                return(true);
            }
            return(false);
        }