예제 #1
0
        private static void FillPayload()
        {
            using (var contextDestination = new ClientLocateDbContext())
            {
                var existing = contextDestination.People.Select(c => c.Id).ToList();

                foreach (var item in existing)
                {
                    try
                    {
                        var p = contextDestination.People.Where(g => g.Id == item).Include(d => d.Addresses).Include(c => c.Phones).Select(d => d).First();

                        contextDestination.ClientDocuments.Add(new ClientDocument
                        {
                            Id = p.Id,
                            PayloadXml = p.SerializeToXML(),
                            PayloadJson = p.SerializeToJSON()
                        });

                        contextDestination.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
        }
예제 #2
0
        public int CountClient(string name, string phone, string address, string policy)
        {
            StringBuilder sb = new StringBuilder(200);
            sb.Append("SELECT Id, '' as PayloadXML, '' as PayloadJSON ");
            sb.Append("FROM ClientDocuments ");
            sb.AppendFormat("WHERE {0}", BuildPredicate(name, phone, address, policy));

            List<int> list = null;
            using (var context = new ClientLocateDbContext())
            {
                list = context.ClientDocuments.SqlQuery(sb.ToString()).Select(c => c.Id).Distinct().ToList();
            }
            return list.Count;
        }
예제 #3
0
        public int CountClient(string query, string searchType)
        {
            //this function should just be a scalor.

            var queryPredicate = CreatePredicate(query);
            StringBuilder sb = new StringBuilder(200);
            sb.Append("SELECT Id, '' as PayloadXML, '' as PayloadJSON ");
            sb.Append("FROM ClientDocuments ");
            sb.AppendFormat("WHERE CONTAINS({0}, '{1}' );", Columns(searchType), queryPredicate);

            List<int> list = null;
            using (var context = new ClientLocateDbContext())
            {
                list = context.ClientDocuments.SqlQuery(sb.ToString()).Select(c => c.Id).Distinct().ToList();
            }
            return list.Count;
        }
예제 #4
0
        private static void FillTables()
        {
            using (var contextSource = new ClientDBContext())
            {
                using (var contextDestination = new ClientLocateDbContext())
                {
                    var existing = contextDestination.People.Select(c => c.ClientId).ToList();

                    var people = (from ci in contextSource.ClientInfoes
                                  where ci.PrimarySubtypeCode == null
                                  select (new Person
                                  {
                                      FirstName = ci.FirstName,
                                      LastName = ci.LastName,
                                      ClientId = ci.OasisClientId,
                                      DateOfBirth = ci.IndividualDateOfBirth.Value,
                                      MiddleName = ci.MiddleName,
                                      NamePrefix = ci.NamePrefixCode,
                                      NameSuffix = ci.NameSuffixCode
                                  }
                                      )).ToList();

                    StringBuilder sb = new StringBuilder();
                    sb.Append("Select LIne1,line2,cityname,statecode,postalcode,countrycode, rat.Description, ci.OasisClientId ");
                    sb.Append("From ClientAddress ca  ");
                    sb.Append("inner join Reference.AddressType rat on rat.AddressTypeCode = ca.AddressTypeCode ");
                    sb.Append("inner join ClientInfo ci on ca.ClientId = ci.ClientId, ");
                    sb.Append("(Select MAX(AddressSeqNum) AddressSeqNum, ClientId, AddressTypeCode ");
                    sb.Append("from ClientAddress ");
                    sb.Append("Group by ClientId, AddressTypeCode)  maxAdd ");
                    sb.Append("Where ca.ClientId = maxAdd.ClientId and ca.AddressTypeCode = maxAdd.AddressTypeCode and ca.AddressSeqNum = maxAdd.AddressSeqNum and PrimarySubtypecode is null ");
                    var dd = new ClientLocate.Tests.Model.CDbContext();

                    var clientAddresses = dd.ExecuteStoreQuery<ClientAddressModel>(sb.ToString()).ToList();
                    foreach (var person in people)
                    {
                        if (existing.Contains(person.ClientId)) continue;

                        contextDestination.People.Add(person);

                        List<ClientLocate.Models.Phone> phones = contextSource.ClientInfoes.Single(c => c.OasisClientId == person.ClientId).Phones.Select(pho => new ClientLocate.Models.Phone { Person = person, PhoneType = pho.PhoneTypeReference.Value.Description, LocalNumber = pho.PhoneNumber, AreaCode = pho.AreaCode, Extension = pho.Extension }).ToList();
                        foreach (var phone in phones)
                        {
                            contextDestination.Phones.Add(phone);
                        }

                        List<ClientLocate.Models.Address> addresses = clientAddresses.Where(f => f.OasisClientId == person.ClientId).Select(a => new ClientLocate.Models.Address { Person = person, AddressLine1 = a.Line1, AddressLine2 = a.line2, AddressType = a.Description, City = a.cityname, Country = a.countrycode, State = a.statecode, Zip = a.postalcode }).ToList();
                        foreach (var address in addresses)
                        {
                            contextDestination.Addresses.Add(address);
                        }

                        contextDestination.SaveChanges();
                    }

                }
            }
        }
예제 #5
0
        public List<string> LocateClient(string query, string searchType)
        {
            query = AddDateToQuery(query);

            AstNode root = _compiler.Parse(query);
            if (!CheckParseErrors())
            {
                throw new ApplicationException(error);
            }

            var queryPredicate = SearchGrammar.ConvertQuery(root, SearchGrammar.TermType.Inflectional);
            StringBuilder sb = new StringBuilder(200);
            sb.Append("SELECT top 50 Id, '' as PayloadXML, PayloadJSON ");
            sb.Append("FROM ClientDocuments ");
            sb.AppendFormat("WHERE CONTAINS({0}, '{1}' );", Columns(searchType), queryPredicate);

            List<string> list = null;
            using (var context = new ClientLocateDbContext())
            {
                list = context.ClientDocuments.SqlQuery(sb.ToString()).Select(c => c.PayloadJson).Distinct().ToList();
            }
            return list;
        }