Exemplo n.º 1
0
        private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            NewsModel mod = (NewsModel)dgv.Rows[e.RowIndex].Tag;
            if (mod.IsGetted)
            {
                MessageBox.Show("سىز بۇ خەۋەرنى يىغىپ بولغان");
                return;
            }
            DataGridViewCell cell = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];
            if (cell is DataGridViewButtonCell)
            {
                DataGridViewButtonCell cel = (DataGridViewButtonCell)cell;
                mod = news.GetNews(mod);
                if (mod == null)
                {
                    MessageBox.Show("بۇ خەۋەرنى يىغىشتا خاتالىق بار، قايتا سىناپ بېقىڭ");
                    return;
                }
                IGetBase dal = new ZuklanDAL();
                if (dal.Insert(mod) > 0)
                {
                    //写入日记
                    news.WriteGettedLog(mod);
                    mod.IsGetted = true;
                    dgv.Rows[e.RowIndex].DefaultCellStyle = new DataGridViewCellStyle() { ForeColor = Color.Gray };
                    MessageBox.Show("بولدى");
                }
                else
                {
                    MessageBox.Show("بۇ خەۋەرنى يىغىشتا خاتالىق بار");
                }

            }
        }
Exemplo n.º 2
0
        private void GetAuto()
        {
            //设置状态
            btnAuto.Enabled = false;
            lblAuto.Text = "ئاپتۇماتىك ئۇچۇر يىغىۋاتىدۇ، سىستىمىنى تاقىماڭ ياكى مەجبۇرى چىكىندۈرمەڭ";
            INewsBase newsAuto = null;
            int autoPage = 1;
            IGetBase dal = new ZuklanDAL();
            //获取所有涞源
            List<NewsSourceModel> sources = GetNewsSource();
            //根据涞源获取所有所有类别
            foreach (var source in sources)
            {
                //根据类别获取获取新闻集合
                switch (source.Source)
                {
                    case NewsSource.Nur:
                        newsAuto = new NurNews();
                        break;
                    case NewsSource.TS:
                        newsAuto = new TSNews();
                        break;
                    default: continue;
                }
                foreach (var typ in newsAuto.NewsTypes)
                {
                NextPage:
                    List<NewsModel> newsList = newsAuto.GetNewsList(Convert.ToInt32(typ.CatID), autoPage);
                    if (newsList == null || newsList.Count <= 0) continue;
                    bool b = true;
                    NewsModel mod;
                    foreach (var newsItem in newsList)
                    {
                        //新闻集合中搜索没有记录的
                        if (newsItem.IsGetted)
                        {
                            b = false;
                            autoPage = 1;
                            break;
                        }
                        mod = newsAuto.GetNews(newsItem);
                        if (mod == null) continue;
                        //写入到数据库
                        if (dal.Insert(mod) > 0)
                        {
                            newsAuto.WriteGettedLog(mod);
                        }
                    }
                    if (!b) continue;
                    autoPage++;
                    goto NextPage;
                }

            }
            btnAuto.Enabled = true;
            DateTime tim = DateTime.Now;
            TimeSpan tp = new TimeSpan(36000000000);
            tim = tim + tp;
            lblAuto.Text = "ئاپتۇماتىك ئۇچۇر يىغىشقا تەڭشىدىڭىز، كىيىنكى قېتىم ئاپتۇماتىك ئۇچۇر يىغىدىغان ۋاقىت\r\n" + tim.ToString("0000-00-00 00:00:00");
        }
Exemplo n.º 3
0
        private void btnGetAll_Click(object sender, EventArgs e)
        {
            int count = 0;
            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                NewsModel mod = (NewsModel)dgv.Rows[i].Tag;
                if (mod.IsGetted) continue;

                mod = news.GetNews(mod);
                IGetBase dal = new ZuklanDAL();
                if (dal.Insert(mod) > 0)
                {
                    //写入日记
                    news.WriteGettedLog(mod);
                    mod.IsGetted = true;
                    dgv.Rows[i].DefaultCellStyle = new DataGridViewCellStyle() { ForeColor = Color.Gray };
                    count++;
                }
            }
            MessageBox.Show(string.Format("{0} پارۋە خەۋەر يىغىلدى", count));
        }