Esempio n. 1
0
        public void SetProductID(int productID)
        {
            _productID = productID;
            dBPMan.ProductAnanytic.Clear();
            DBPManTableAdapters.ProductTableAdapter adt = new DBPManTableAdapters.ProductTableAdapter();
            adt.Connection.ConnectionString = Server.ConnectionString;
            DBPMan.ProductDataTable dt = new DBPMan.ProductDataTable();
            adt.FillBy_SelectOne(dt, productID);
            if (dt.Rows.Count > 0)
            {
                nameProduct = dt.Rows[0]["Name"].ToString();
            }
            adt.Dispose();
            dt.Dispose();



            this.product_KeyComparisonTableAdapter.FillBy_ProductID(dBPMan.Product_KeyComparison, productID);

            if (dBPMan.Product_KeyComparison.Rows.Count <= 0)
            {
                this.dBPMan.Product_KeyComparison.IDProductColumn.DefaultValue = productID;
                //this.dBPMan.Product_KeyComparison.IDKeySearchColumn.DefaultValue = 0;
                this.product_KeyComparisonBindingSource.AddNew();
                this.product_KeyComparisonBindingSource.EndEdit();
            }
            txttcode.Text = "";
        }
Esempio n. 2
0
        private void btSiteMap_Click(object sender, EventArgs e)
        {
            DBPMan.ProductDataTable            dt           = new DBPMan.ProductDataTable();
            DBPMan.Product_PropertiesDataTable dtProperties = new DBPMan.Product_PropertiesDataTable();
            DBPManTableAdapters.Product_PropertiesTableAdapter adtProperties = new DBPManTableAdapters.Product_PropertiesTableAdapter();
            adtProperties.Connection.ConnectionString = Server.ConnectionString;
            this.productTableAdapter.FillBy_AllSPGocValid_orderByLastUpdate(dt, Common.GetIDCompany("quangtrung.vn"), DateTime.Now);
            String xml = "";

            xml += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
            xml += "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
            xml += "    <url>\n";
            xml += "        <loc>http://websosanh.vn/home.htm</loc>\n";
            xml += "        <changefreq>daily</changefreq>\n";
            xml += "        <priority>0.8</priority>\n";
            xml += "    </url>\n";
            string f = "";

            f += "    <url>\n";
            f += "        <loc>{0}</loc>\n";
            f += "        <changefreq>daily</changefreq>\n";
            f += "        <priority>0.8</priority>\n";
            f += "    </url>\n";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                long   id = 0;
                string name = "", url = "";
                id   = Common.Obj2Int64(dt.Rows[i]["ID"].ToString());
                name = dt.Rows[i]["Summary"].ToString();
                url  = Bussiness.UrlHelper.GetUrlOfProductIDSoSanh(id, name);
                xml += string.Format(f, url);
            }
            dt.Dispose();
            xml += "</urlset>\n";
            FileLog.WriteText(xml, "sitemap.xml");
        }
Esempio n. 3
0
        //Không sử dụng nữa 02-12-2015
        void doUpdateFulltext()
        {
            DBPMan.ProductDataTable            dt           = new DBPMan.ProductDataTable();
            DBPMan.Product_PropertiesDataTable dtProperties = new DBPMan.Product_PropertiesDataTable();
            DBPManTableAdapters.Product_PropertiesTableAdapter adtProperties = new DBPManTableAdapters.Product_PropertiesTableAdapter();
            adtProperties.Connection.ConnectionString = Server.ConnectionString;
            if (chkAll.Checked == true)
            {
                this.productTableAdapter.FillBy_AllSPGocValid_orderByLastUpdate(dt, Common.GetIDCompany("quangtrung.vn"), DateTime.Now);
            }
            else
            {
                this.productTableAdapter.FillBy_CompanyID_Valid_Category(dt, Common.GetIDCompany("quangtrung.vn"), true, Common.Obj2Int(this.iDListClassificationTextBox.Text));
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                try
                {
                    long   id         = 0;
                    int    categoryID = 0;
                    string nameCat    = "";
                    id         = Common.Obj2Int64(dt.Rows[i]["ID"].ToString());
                    categoryID = Common.Obj2Int(dt.Rows[i]["CategoryID"].ToString());
                    var filter = GetFilterCategory(categoryID);
                    nameCat = dt.Rows[i]["CategoryName"].ToString();



                    //adtProperties.FillBy_FillterByProductID(dtProperties, id);

                    //foreach (DBPMan.Product_PropertiesRow dr in dtProperties)
                    //{
                    //    int proid = Common.Obj2Int(dr.PropertiesID);
                    //    int provalue = Common.Obj2Int(dr.PropertiesValueID);

                    //    filter += string.Format(" {0}_{1}", proid, provalue);
                    //}

                    //for (int ii = 0; ii < dtProperties.Rows.Count; ii++)
                    //{
                    //    int proid = Common.Obj2Int(dtProperties.Rows[ii]["PropertiesID"].ToString());
                    //    int provalue = Common.Obj2Int(dtProperties.Rows[ii]["PropertiesValueID"].ToString());

                    //    filter += string.Format(" {0}_{1}", proid, provalue);
                    //}
                    string nameFT    = Common.UnicodeToKoDauFulltext(dt.Rows[i]["Name"].ToString() + " " + nameCat) + " " + nameCat;
                    var    contentft = Common.UnicodeToKoDauFulltext(nameCat) + " " +
                                       filter;
                    if (contentft.Contains("c000"))
                    {
                        contentft = contentft;
                    }
                    this.productTableAdapter.UpdateQuery_ContentFT_NameFT_ByID(
                        contentft,
                        nameFT,
                        id);
                    int delay = 1000;
                    this.Invoke(
                        (MethodInvoker) delegate
                    {
                        this.laMess1.Text = String.Format("Update thông tin search {0}/{1} sản phẩm gốc: {2}\n ", i, dt.Rows.Count, dt.Rows[i]["Name"].ToString());
                        delay             = Common.Obj2Int(txtDelay.Text.Trim());
                    });

                    contentft = nameFT + " " + filter;
                    if (contentft.Contains("c000"))
                    {
                        contentft = contentft;
                    }
                    this.productTableAdapter.UpdateQuery_ContentFT_CategoryID_ByProductID(
                        contentft,
                        Common.Obj2Int(dt.Rows[i]["CategoryID"]),
                        Common.Obj2Int(id));
                    Thread.Sleep(delay);
                }
                catch (Exception ex)
                {
                    var error = ex.Message;
                    error += "";
                }
            }
            dt.Dispose();

            if (updateFulltextThread != null)
            {
                if (updateFulltextThread.IsAlive)
                {
                    updateFulltextThread.Abort();
                    updateFulltextThread.Join();
                    updateFulltextThread = null;
                }
            }
        }
Esempio n. 4
0
        void doConvertSPGoc()
        {
            this.Invoke((MethodInvoker) delegate
            {
                this.lamssconvert.Text = "Start convert";
            });
            DBPManTableAdapters.ProductTableAdapter adtProduct = new DBPManTableAdapters.ProductTableAdapter();
            DBPMan.ProductDataTable dtP = new DBPMan.ProductDataTable();
            adtProduct.Connection.ConnectionString = Server.ConnectionString;
            int i = 0;

            foreach (DBMap.ProductRow dr in dBMap.Product)
            {
                //if (Common.Obj2Int64(dr.ProductID) <= 0)
                //{
                //insert to productid
                // vatgia
                if ((dBMap.Product.Rows[i]["ImageUrls"].ToString().Trim() != "")
                    //&& (dBMap.Product.Rows[i]["ProductContent"].ToString().Trim().Length > 10)
                    && (dBMap.Product.Rows[i]["ImageUrls"].ToString().Trim() != ""))
                {
                    int ID = Common.GetID_ProductID(dr.Name, IDCategory);
                    try
                    {
                        string name      = dr.Name.Replace("- Thông số kỹ thuật", "").Trim();
                        string contentft = Common.UnicodeToKoDauFulltext(name + " " + labelControlListIDSearch.Text);
                        if (adtProduct.Connection.State == ConnectionState.Closed)
                        {
                            adtProduct.Connection.Open();
                        }
                        try
                        {
                            /// check san pham nay da được tạo chưa
                            /// nếu chưa thì insert
                            /// đã có thì update lại thông số kỹ thuật
                            ///
                            dtP = new DBPMan.ProductDataTable();
                            adtProduct.FillBy_CheckID(dtP, ID);
                            if (dtP.Rows.Count > 0)
                            {
                                //adtProduct.UpdateQuery_SPGoc(
                                //    12,
                                //    Common.GetIDCompany("quangtrung.vn"),
                                //    DateTime.Now,
                                //    dBMap.Product.Rows[i]["ProductContent"].ToString(),
                                //    name,
                                //    dr.DetailUrl,
                                //    dr.ImageUrls,
                                //    Common.UnicodeToKoDauFulltext(name),
                                //    false,
                                //    Common.GetHashNameProduct("quangtrung.vn", name),
                                //    "",
                                //    IDCategory,
                                //    ID);
                            }
                            else
                            {
                                // chuyển sang làm sản phẩm gốc
                                adtProduct.InsertQuery_SPGoc(
                                    ID,
                                    Common.GetIDCompany("quangtrung.vn"),
                                    DateTime.Now,
                                    name,
                                    dBMap.Product.Rows[i]["ProductContent"].ToString(),
                                    name,
                                    dr.DetailUrl,
                                    dr.ImageUrls,
                                    Common.UnicodeToKoDauFulltext(name) + " " + NameCategory + " " + Common.UnicodeToKoDauFulltext(NameCategory),
                                    false,
                                    Common.GetHashNameProduct("quangtrung.vn", name),
                                    "",
                                    IDCategory,
                                    Common.Obj2Int(dBMap.Product.Rows[i]["Price"].ToString()),
                                    dr.ID,  // lưu product id vào trường classification vì productid chỉ là kiểu int
                                    contentft);
                                LogJobAdapter.SaveLog(JobName.FrmEditeProductByCat_Them_moi_san_pham_goc, "Thêm mới sản phẩm gốc MAP PRODUCT!", ID, (int)JobTypeData.Product);
                            }
                            dtP.Dispose();
                            List <PropertyEntyties> ls = new List <PropertyEntyties>();
                            ls = ContentAnalytic.GetListProperties(dBMap.Product.Rows[i]["ProductContent"].ToString().Trim(),
                                                                   dBMap.Product.Rows[i]["DetailUrl"].ToString().Trim());
                            ContentAnalytic.UpdateContent(ID, ls);
                        }
                        catch (Exception)
                        {
                            //  tên sản phẩm trong chuyên mục này đã có
                        }

                        // update lại sản phẩm vừa chuyển đã chuyển
                        adtProduct.UpdateQuery_ProductID(ID, dr.ID);
                    }
                    catch (Exception)
                    {
                    }
                    this.Invoke((MethodInvoker) delegate
                    {
                        this.lamssconvert.Text = string.Format("{0}/{1} - {2}", i, dBMap.Product.Count, dr.Name);
                    });
                    Application.DoEvents();
                    adtProduct.Connection.Close();
                    //String[] images = dBMap.Product.Rows[i++]["Promotion"].ToString().Split('\n');
                    //if ((images.Length > 0) && (images[0].Trim().Length > 0))
                    //{

                    //try
                    //{
                    //    adtID.Insert(
                    //    ID,
                    //    images[0].ToString(),
                    //    IDCategory,
                    //    0, 0, 0,
                    //    dr.ProductContent,
                    //    dr.DetailUrl,
                    //    dr.Name,
                    //    dr.NameFT,
                    //    Common.Obj2Int(Common.ProductIDStatus.NotValid));
                    //}
                    //catch (Exception)
                    //{

                    //}

                    //}
                }
                //}
                i++;
            }
        }