Exemplo n.º 1
0
        public bool UploadData()
        {
            IEsDbOperation esDbOperation      = new EsDbOperation();
            int            customerTotalCount = esDbOperation.GetCustomersCount();

            int size = 500, index = 0;

            while (index <= customerTotalCount)
            {
                List <KcaCustomer> customers  = esDbOperation.GetCustomers(size, index);
                List <Customer>    esCustomer = new List <Customer>();

                customers.ForEach(x => esCustomer.Add(new Customer
                {
                    Email            = x.Email,
                    EmailSuggest     = x.Email,
                    FirstName        = x.FirstName,
                    FirstNameSuggest = x.FirstName,
                    LastName         = x.LastName,
                    LastNameSuggest  = x.LastName,
                    Landline         = x.Landline,
                    Id         = x.Id,
                    CustomerId = x.Id.ToString(),
                    school     = new School
                    {
                        schoolid       = x.School.Id,
                        schoolname     = x.School.Name,
                        schooladdress1 = x.School.Address,
                        postcode       = x.School.Suburb.Postcode.Code,
                        suburb         = x.School.Suburb.Name,
                        state          = x.School.Suburb.Postcode.State.Name
                    }
                }));
                EsClient.BulkAsync(b => b.Index("customer").IndexMany(esCustomer));
                index += size;
            }


            return(true);
        }