Пример #1
0
        public void PushHashNameOfProduct(long companyID, string domain, ProductAdapter productAdapter, IDatabase redisDatabase)
        {
            int iPage = 0;

            while (true)
            {
                DataTable tblProduct = productAdapter.GetTblProductHashPushRedisForCompany(companyID, iPage);
                if (tblProduct.Rows.Count == 0)
                {
                    break;
                }
                iPage++;

                foreach (DataRow rowProduct in tblProduct.Rows)
                {
                    string Name     = Common.Obj2String(rowProduct["Name"]);
                    int    Price    = Common.Obj2Int(rowProduct["Price"]);
                    string ImageUrl = Common.Obj2String(rowProduct["ImageUrls"]);
                    long   ID       = Common.Obj2Int64(rowProduct["ID"]);

                    string a   = domain + "_" + Name + "_" + Price.ToString() + "_" + ImageUrl;
                    string key = "dumplicate_product:" + Math.Abs(
                        GABIZ.Base.Tools.getCRC64(Price.ToString() + Name + ImageUrl));
                    int count = 0;
                    while (true)
                    {
                        try
                        {
                            redisDatabase.SetAdd(key, ID.ToString());
                            break;
                        }
                        catch (Exception ex)
                        {
                            count++;
                            if (count > 5)
                            {
                                break;
                            }
                            else
                            {
                                Thread.Sleep(1000);
                            }
                        }
                    }
                }
            }
            productAdapter.UpdateLastSyncProductHashRedisForCompany(companyID);
        }