Exemplo n.º 1
0
        private void btnaddspdier_Click(object sender, EventArgs e)
        {
            //int cid = 1;
            int cid = bllspiderconfig.GetMaxId();

            if (cbxspider.SelectedItem == null)
            {
                NoteInfo(Info.Warning, "当前列表为空!");
                return;
            }
            Model.spider curspider = new Model.spider();
            curspider.SpiderName     = cbxspider.SelectedItem.ToString();
            curspider.SpiderConfigID = cid;
            curspider.IsDel          = 0;
            if (bllspider.Add(curspider))
            {
                NoteInfo(Info.Right, "添加新Spider成功!");
            }
            else
            {
                NoteInfo(Info.Error, "添加新Spider失败!");
            }

            //判断文件夹下的项目名字spider都是否唯一
        }
Exemplo n.º 2
0
        //整行选中进入编辑模式
        private void dgvconfigspider_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                DataGridView       dgvcurrnet     = sender as DataGridView;
                var                rowindex       = e.RowIndex;
                DataGridViewRow    row            = dgvconfigspider.Rows[rowindex];
                var                spiderConfigID = Convert.ToInt32(row.Cells["SpiderConfigID"].Value);
                var                sid            = Convert.ToInt32(row.Cells["Sid"].Value);
                Model.spiderconfig config         = bllspiderconfig.GetModel(spiderConfigID);
                Model.spider       spidermodel    = bllspider.GetModel(sid);
                if (config != null && config.Cid > 0)
                {
                    txtselectpath.Text   = config.SpiderPath;
                    cbxspider.DataSource = null;
                    cbxspider.Items.Clear();
                    cbxspider.Items.Insert(0, spidermodel.SpiderName);
                    cbxspider.SelectedIndex = 0;
                    if (!string.IsNullOrEmpty(config.LogName))
                    {
                        cbxlog.SelectedItem = Path.GetExtension(config.LogName);

                        if (config.LogName.Contains("nolog"))
                        {
                            cbxlog.SelectedItem = config.LogName;
                        }
                        txtlogname.Text = Path.GetFileNameWithoutExtension(config.LogName);
                    }

                    if (!string.IsNullOrEmpty(config.SpiderOutPut))
                    {
                        cbxoutput.SelectedItem = Path.GetExtension(config.SpiderOutPut);
                        txtoutputname.Text     = Path.GetFileNameWithoutExtension(config.SpiderOutPut);
                    }
                    txtconfigname.Text  = config.ConfigName;
                    txtautoparms.Text   = config.AutoParms;
                    lblhidconfigid.Text = config.Cid.ToString();

                    NoteInfo(Info.Right, "当前成功选中行:" + (e.RowIndex + 1).ToString());
                }
            }
            catch (Exception ex)
            {
                NoteInfo(Info.Error, "出现未知错误:" + ex.ToString());
            }
        }
Exemplo n.º 3
0
        //button click the value
        private void dgvconfigspider_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || e.ColumnIndex == 0)
            {
                return;
            }
            string buttontext = string.Empty;

            if (dgvconfigspider.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                buttontext = dgvconfigspider.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
            }
            //If button is save
            if (buttontext.ToLower() == "save")
            {
                int          spiderid = Convert.ToInt32(dgvconfigspider.Rows[e.RowIndex].Cells["Sid"].Value);
                DialogResult res      = MessageBox.Show("确定保存?", "编辑提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (res == System.Windows.Forms.DialogResult.Yes)
                {
                    //update the model
                    Model.spider currentspider = bllspider.GetModel(spiderid);
                    if (currentspider != null && currentspider.Sid > 0)
                    {
                        int configid = Convert.ToInt32(dgvconfigspider.Rows[e.RowIndex].Cells["SpiderConfigID"].Value);
                        currentspider.IsDel          = Convert.ToInt32(dgvconfigspider.Rows[e.RowIndex].Cells["IsDel"].Value);
                        currentspider.SpiderConfigID = configid;
                        currentspider.SpiderName     = dgvconfigspider.Rows[e.RowIndex].Cells["SpiderName"].Value.ToString();
                        if (bllspider.Update(currentspider))
                        {
                            NoteInfo(Info.Right);
                            LoadSpider();
                        }
                    }
                }
            }
            //MessageBox.Show(buttontext);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ScrapyForm.Model.spider model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(ScrapyForm.Model.spider model)
 {
     return(dal.Add(model));
 }