Пример #1
0
        private void btUpDateToDay_Click(object sender, EventArgs e)
        {
            Data.KW.KeywordsDataTable dt = new Data.KW.KeywordsDataTable();
            this.keywordsTableAdapter.FillBy_LessLastUpdate(dt, DateTime.Now.AddDays(-1));
            DBTableAdapters.ProductTableAdapter adtp = new DBTableAdapters.ProductTableAdapter();
            adtp.Connection.ConnectionString = QT.Entities.Server.ConnectionString;
            int i = 0;

            foreach (Data.KW.KeywordsRow dr in dt)
            {
                i++;
                int a = 0;
                try
                {
                    String keyword = dr.KeyName.Trim().Replace(" ", "+");
                    a = (int)Convert.ToInt32(adtp.Product_SelectCountByFreetext_Name(keyword));
                }
                catch (Exception)
                { }
                this.keywordsTableAdapter.UpdateQuery_KeyFreq(a, DateTime.Now, dr.KeyHash);
                this.lamess.Text = String.Format("({0}/{1}) keyword:{2}={3}", i, dt.Rows.Count, dr.KeyName, a);
                Application.DoEvents();
            }
            this.lamess.Text = "Finish";
            dt.Clear();
            dt.Dispose();
        }
Пример #2
0
        void doUpdateKeyword()
        {
            Moduls.Data.KW.View_KeywordLogDataTable dtview = new Data.KW.View_KeywordLogDataTable();
            Moduls.Data.KWTableAdapters.View_KeywordLogTableAdapter adtView = new Data.KWTableAdapters.View_KeywordLogTableAdapter();
            adtView.Connection.ConnectionString = QT.Entities.Server.LogConnectionString;
            DateTime dtime = DateTime.Now.AddMonths(-2);

            this.Invoke((MethodInvoker) delegate
            {
                this.lames.Text = "Start download";
            });
            adtView.FillBy_FromDate(dtview, dtime.Year, dtime.Month);
            int i = 0;

            Data.KW.KeywordsDataTable dtkw = new Data.KW.KeywordsDataTable();
            foreach (Moduls.Data.KW.View_KeywordLogRow dr in dtview)
            {
                keywordsTableAdapter.FillBy_SelectOne(dtkw, dr.IDHash);
                if (dtkw.Rows.Count > 0)
                {
                    keywordsTableAdapter.UpdateQuery_KeyClickByIDHash(dr.Count, DateTime.Now, dr.IDHash);
                }
                else
                {
                    keywordsTableAdapter.Insert(
                        dr.IDHash,
                        dr.Name,
                        "", 0, 0, DateTime.Now,
                        dr.IDHash,
                        dr.Count);
                }
                this.Invoke((MethodInvoker) delegate
                {
                    this.lames.Text = String.Format("{0}/{1} - {2}\n{3}", i++, dtview.Rows.Count, dr.Name, dr.Count);
                });
                Thread.Sleep(100);
            }
            adtView.Dispose();
            dtview.Dispose();
            if (updateKeywordThread != null)
            {
                if (updateKeywordThread.IsAlive)
                {
                    updateKeywordThread.Abort();
                    updateKeywordThread.Join();
                    updateKeywordThread = null;
                }
            }
        }