public static bool ImportMallDataBulk(string IndexNew)
        {
            int        PageSize   = int.Parse(ConfigurationManager.AppSettings["PageSize"].ToString());
            int        PageNumber = 1;
            var        clinet     = GetClient(IndexNew);
            List <int> rs         = new List <int>();

            Utils.WriteLogFile("ImportMallDataBulk开始导入数据(" + IndexNew + ")页大小" + PageSize);
            while (true)
            {
                SQLinq.Dynamic.DynamicSQLinq sql = new SQLinq.Dynamic.DynamicSQLinq("v_ProductInfo_s ");
                sql = sql.Select("*");
                sql = sql.Skip(PageSize * (PageNumber - 1)).Take(PageSize).OrderByDescending("pid");
                var list = db.Query <dynamic>(sql);
                if (list.Count == 0)
                {
                    break;
                }
                var bk = clinet.Bulk(a => a.IndexMany(list));
                if (bk.Errors)
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入有错误,数据来源sql语句--" + sql.ToSQL().ToQuery());
                    rs.Add(0);
                }
                else
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入成功");
                    rs.Add(1);
                }
                PageNumber++;
            }
            Utils.WriteLogFile("ImportMallDataBulk导入数据结束(" + IndexNew + ")");
            return(rs.Where(a => a == 0).Count() == 0);
        }
        public static bool ImportStoreSuggestDataBulk(string IndexNew)
        {
            int        PageSize   = int.Parse(ConfigurationManager.AppSettings["PageSize"].ToString());
            int        PageNumber = 1;
            var        clinet     = GetClient(IndexNew);
            List <int> rs         = new List <int>();

            Utils.WriteLogFile("ImportStoreSuggestDataBulk开始导入数据(" + IndexNew + ")页大小" + PageSize);
            while (true)
            {
                SQLinq.Dynamic.DynamicSQLinq sql = new SQLinq.Dynamic.DynamicSQLinq("v_ProductInfo_s ");
                sql = sql.Select("storeid,StoreName name").GroupBy("storeid,StoreName");
                sql = sql.Skip(PageSize * (PageNumber - 1)).Take(PageSize).OrderByDescending("storeid");
                var list = db.Query <dynamic>(sql);
                if (list.Count == 0)
                {
                    break;
                }
                string initials     = "";
                var    keywordslist = list.Select(a => new { keywords = new { input = new List <string>()
                                                                              {
                                                                                  a.name, ChineseToPinYin.ToPinYin(a.name, ref initials), initials
                                                                              }, output = a.name, payload = new { id = a.storeid.ToString(), type = "store", keyword = "" }, weight = 10 } });
                var bk = clinet.Bulk(a => a.IndexMany <object>(keywordslist));
                if (bk.Errors)
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入有错误,数据来源sql语句--" + sql.ToSQL().ToQuery());
                    rs.Add(0);
                }
                else
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入成功");
                    rs.Add(1);
                }
                PageNumber++;
            }
            Utils.WriteLogFile("ImportStoreSuggestDataBulk导入数据结束(" + IndexNew + ")");
            return(rs.Where(a => a == 0).Count() == 0);
        }
        public static bool ImportBrandSuggestDataBulk(string IndexNew)
        {
            int        PageSize   = int.Parse(ConfigurationManager.AppSettings["PageSize"].ToString());
            int        PageNumber = 1;
            var        clinet     = GetClient(IndexNew);
            List <int> rs         = new List <int>();

            Utils.WriteLogFile("ImportBrandSuggestDataBulk开始导入数据(" + IndexNew + ")页大小" + PageSize);
            while (true)
            {
                SQLinq.Dynamic.DynamicSQLinq sql = new SQLinq.Dynamic.DynamicSQLinq("v_ProductInfo_s ");
                sql = sql.Select("brandid,BrandName name").GroupBy("brandid,BrandName");
                sql = sql.Skip(PageSize * (PageNumber - 1)).Take(PageSize).OrderByDescending("brandid");
                var list = db.Query <dynamic>(sql);
                if (list.Count == 0)
                {
                    break;
                }
                List <object> keywordslist = new List <object>();
                string        initials     = "";
                string        pinyin       = "";
                string        output       = "";

                SQLinq.Dynamic.DynamicSQLinq sqlkeywords = new SQLinq.Dynamic.DynamicSQLinq("bma_brands ");
                sqlkeywords = sqlkeywords.Select("brandid,keywords");
                var listkeywords = db.Query <dynamic>(sqlkeywords).ToList();

                foreach (var item in list)
                {
                    output   = item.name;
                    initials = "";
                    pinyin   = ChineseToPinYin.ToPinYin(output, ref initials);
                    keywordslist.Add(new { keywords = new { input = new List <string>()
                                                            {
                                                                output, pinyin, initials
                                                            }, output = output, payload = new { id = item.brandid.ToString(), type = "brand", keyword = "" }, weight = 20 } });

                    //添加关键词
                    var brandinfo = listkeywords.FirstOrDefault(a => a.brandid == item.brandid);
                    if (brandinfo != null && brandinfo.keywords != null)
                    {
                        List <string> brandkeywords = ((string)brandinfo.keywords).Split(',').ToList();
                        foreach (var key in brandkeywords)
                        {
                            if (key == "")
                            {
                                continue;
                            }
                            output   = item.name + key;
                            initials = "";
                            pinyin   = ChineseToPinYin.ToPinYin(output, ref initials);
                            keywordslist.Add(new { keywords = new { input = new List <string>()
                                                                    {
                                                                        output, pinyin, initials
                                                                    }, output = output, payload = new { id = item.brandid.ToString(), type = "brand", keyword = key }, weight = 20 } });
                        }
                    }
                }
                var bk = clinet.Bulk(a => a.IndexMany <object>(keywordslist));
                if (bk.Errors)
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入有错误,数据来源sql语句--" + sql.ToSQL().ToQuery());
                    rs.Add(0);
                }
                else
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入成功");
                    rs.Add(1);
                }
                PageNumber++;
            }
            Utils.WriteLogFile("ImportBrandSuggestDataBulk导入数据结束(" + IndexNew + ")");
            return(rs.Where(a => a == 0).Count() == 0);
        }