Пример #1
0
 private void addNew(EventArgs e)
 {
     QT.Moduls.Company.DBComTableAdapters.Job_WebsiteConfigLogTableAdapter adtJob = new QT.Moduls.Company.DBComTableAdapters.Job_WebsiteConfigLogTableAdapter();
     adtJob.Connection.ConnectionString = Server.ConnectionString;
     Company.frmAddWeb frm = new Company.frmAddWeb();
     frm.Text = "Thêm mới website";
     if (frm.ShowDialog() == DialogResult.OK)
     {
         TimeSpan timestartup = new TimeSpan(0, 1, 1, 0);
         TimeSpan timeSleep   = new TimeSpan(0, 1, 1, 0);
         Uri      uri         = new Uri(frm.Website);
         String   domain      = uri.Host.ToLower();
         domain = domain.Replace("www.", "");
         Alexa a = new Alexa();
         a = Common.GetRankAlexa(uri.Host);
         try
         {
             this.companyTableAdapter1.Insert(
                 Common.GetIDCompany(domain),
                 "",
                 "",
                 frm.Website,
                 domain,
                 DateTime.Now,
                 "",
                 "",
                 "",
                 "",
                 Common.CompanyStatus.NOTCONFIG,
                 "",
                 a.AlexaRankContries,
                 a.AlexaRank,
                 timestartup,
                 timeSleep,
                 0,
                 0,
                 DateTime.Now,
                 DateTime.Now,
                 30,
                 0,
                 0,
                 0,
                 "",
                 DateTime.Now,
                 0, 0, "", false, 0, DateTime.Now.AddYears(-1), DateTime.Now.AddYears(-1));
             adtJob.Insert(QT.Users.User.UserID, Common.GetIDCompany(domain), "", "", QT.Users.JobNhapLieuStatus.NhapMoi, DateTime.Now);
             LogJobAdapter.SaveLog(JobName.FrmCompany_AddNew, "Thêm mới công ty " + domain, Convert.ToInt64(Common.GetIDCompany(domain)), (int)JobTypeData.Company);
         }
         catch (Exception)
         {
             MessageBox.Show("Website này đã có trong hệ thống");
         }
         _command            = Common.ListWebCommand.ViewProfile;
         GetIDCompanyCurrent = Common.GetIDCompany(domain);
         ExcuteCommand(_command, e);
     }
 }
Пример #2
0
        public void IdentifyProducts()
        {
            if (_productID == 0)
            {
                MakeListProductUpToDate();
                return;
            }

            UpdateObjectValue();
            this.dBMap.ProductInfo.Rows.Clear();
            int  numProductFound = 0;
            long minPriceFound   = 0;
            long maxPriceFound   = 0;
            var  client          = new ProtoBufServiceStackClient(_searchEnginesServiceUrl);

            try
            {
                var response = client.Send <GetRootProductMappingResponse>(new GetRootProductMappingByProductIdentityRequest {
                    ProductIdentity = _productIdentity, RegionID = 0, IncludeBlackList = false, GetFacet = true
                });
                if (response.RootProductMapping != null)
                {
                    listProductFound = new List <long>();
                    foreach (var merchantProductIDs in response.RootProductMapping.ListMerchantProducts)
                    {
                        listProductFound.AddRange(merchantProductIDs.Value);
                    }
                    this.dBMap.ProductInfo.Clear();
                    var productIDMap             = new Dictionary <RedisKey, RedisValue>();
                    var listProductMapReverseKey =
                        listProductFound.Select(x => (RedisKey)(ProductConstants.REDIS_PREFIX_PRODUCT_MAP_REVERSE + x)).ToArray();
                    if (listProductMapReverseKey.Length > 0)
                    {
                        //try
                        //{
                        //    foreach (var item in listProductMapReverseKey)
                        //    {
                        //        bool bOK = _productMapRedisServer.Exist(item);
                        //        if (bOK == false)
                        //        {
                        //            MessageBox.Show("dfSD");
                        //        }
                        //    }
                        productIDMap = _productMapRedisServer.MGet(listProductMapReverseKey);
                        //    }
                        //    catch(Exception ex)
                        //    {
                        //        MessageBox.Show(ex.Message);
                        //    }
                    }
                    var merchantProducts = WebMerchantProductBAL.GetWebMerchantProductsFromCache(listProductFound);
                    foreach (var item in merchantProducts.Values)
                    {
                        var row = this.dBMap.ProductInfo.NewRow();//.NewRow();
                        row["Name"]    = item.Name;
                        row["Price"]   = item.Price;
                        row["ID"]      = item.ID;
                        row["Url"]     = item.DetailUrl;
                        row["Company"] = item.CompanyID;
                        var redisProductMapReverseKey = ProductConstants.REDIS_PREFIX_PRODUCT_MAP_REVERSE + item.ID;
                        if (productIDMap.ContainsKey(redisProductMapReverseKey))
                        {
                            row["RootID"] = productIDMap[redisProductMapReverseKey];
                        }
                        this.dBMap.ProductInfo.Rows.Add(row);
                    }
                    this.dBMap.ProductInfo.AcceptChanges();
                    //
                    numProductFound = response.RootProductMapping.ListMerchantProducts.Sum(x => x.Value.Count);
                    minPriceFound   = response.RootProductMapping.MinPrice;
                    maxPriceFound   = response.RootProductMapping.MaxPrice;
                }
                else
                {
                    numProductFound = 0;
                    minPriceFound   = 0;
                    maxPriceFound   = 0;
                }
            }
            catch (Exception ex)
            {
                Log.Error("ERROR client.Send<GetRootProductMappingResponse>", ex);
            }



            //XT-2015_08_07
            //this.RefreshDataChart(dBMap.ProductInfo);
            //Comment vì ko dùng đến nữa 19.11.2015

            textBoxNumFound.Text        = numProductFound.ToString();
            spinEditMinPriceFound.Value = minPriceFound;
            spinEditMaxPriceFound.Value = maxPriceFound;
            MakeListProductUpToDate();

            var adtJob = new QT.Moduls.Company.DBComTableAdapters.Job_WebsiteConfigLogTableAdapter();

            adtJob.Connection.ConnectionString = Server.ConnectionString;
            try
            {
                adtJob.Insert(QT.Users.User.UserID, _productID, richTextBoxNote.Text, textBoxNumFound.Text, QT.Users.JobNhapLieuStatus.NhanDienSanPham, DateTime.Now);
            }
            catch (Exception)
            {
            }
        }