Пример #1
0
        protected override CacheResult CreateResult(string query)
        {
            List <int> resIds = new List <int>();

            if (string.IsNullOrEmpty(query))
            {
                return(null);
            }

            string likequery = "%" + query + "%";
            SWResultset <BAccount> accts;

            accts = SWSelect <BAccount, Where <BAccount.acctName, Like <Required <BAccount.acctName> >, Or <BAccount.acctCD, Like <Required <BAccount.acctCD> > > > > .Select(this.graph, likequery, likequery);

            foreach (BAccount ba in accts)
            {
                if (ba.Type != "UN")
                {
                    resIds.Add(ba.BAccountID.Value);
                }
            }
            foreach (BAccount ba in this.GetAccountsByAddress(likequery))
            {
                resIds.Add(ba.BAccountID.Value);
            }
            foreach (BAccount ba in this.GetAccountsByContact(likequery))
            {
                resIds.Add(ba.BAccountID.Value);
            }

            return(new BAccountCacheResult(query, resIds));
        }
Пример #2
0
        private List <BAccount> GetAccountsByAddress(string likequery)
        {
            List <BAccount> result = new List <BAccount>();

            foreach (Address addr in SWSelect <Address, Where <Address.city, Like <Required <Address.city> >,
                                                               Or <Address.postalCode, Like <Required <Address.postalCode> > > > > .Select(this.graph, likequery, likequery))
            {
                BAccount ba = SWSelect <BAccount, Where <BAccount.defAddressID, Equal <Required <Address.addressID> > > > .SelectWindowed(this.graph, 0, 1, addr.AddressID);

                if (ba != null && ba.Type != "UN")
                {
                    result.Add(ba);
                }
            }

            foreach (Address addr in this.GetAddressesByCountry(likequery))
            {
                BAccount ba = SWSelect <BAccount, Where <BAccount.defAddressID, Equal <Required <Address.addressID> > > > .SelectWindowed(this.graph, 0, 1, addr.AddressID);

                if (ba != null && ba.Type != "UN")
                {
                    result.Add(ba);
                }
            }
            return(result);
        }
Пример #3
0
        private List <Address> GetAddressesByCountry(string likequery)
        {
            List <Address> result = new List <Address>();

            foreach (Country country in SWSelect <Country, Where <Country.description, Like <Required <Country.description> > > > .Select(this.graph, likequery))
            {
                Address addr = SWSelect <Address, Where <Address.countryID, Equal <Required <Country.countryID> > > > .SelectWindowed(this.graph, 0, 1, country.CountryID);

                if (addr != null)
                {
                    result.Add(addr);
                }
            }
            return(result);
        }
Пример #4
0
        private List <BAccount> GetAccountsByContact(string likequery)
        {
            List <BAccount> result = new List <BAccount>();

            foreach (Contact cont in SWSelect <Contact, Where <Contact.salutation, Like <Required <Contact.salutation> >,
                                                               Or <Contact.eMail, Like <Required <Contact.eMail> >,
                                                                   Or <Contact.webSite, Like <Required <Contact.webSite> >,
                                                                       Or <Contact.phone1, Like <Required <Contact.phone1> >,
                                                                           Or <Contact.phone2, Like <Required <Contact.phone2> >,
                                                                               Or <Contact.phone3, Like <Required <Contact.phone3> > > > > > > > > .Select(this.graph, likequery, likequery, likequery, likequery, likequery, likequery))
            {
                BAccount ba = SWSelect <BAccount, Where <BAccount.defContactID, Equal <Required <Contact.contactID> > > > .SelectWindowed(this.graph, 0, 1, cont.ContactID);

                if (ba != null && ba.Type != "UN")
                {
                    result.Add(ba);
                }
            }
            return(result);
        }