Beispiel #1
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());
            }
        }
Beispiel #2
0
        //edit the config spider model
        private void btnconfigedit_Click(object sender, EventArgs e)
        {
            int spiderconfigid = Convert.ToInt32(lblhidconfigid.Text.ToString());

            if (spiderconfigid == 0)
            {
                return;
            }
            Model.spiderconfig spiderconfig = bllspiderconfig.GetModel(spiderconfigid);
            if (spiderconfig == null || spiderconfig.Cid < 1)
            {
                return;
            }

            spiderconfig.ConfigName   = txtconfigname.Text.Trim();
            spiderconfig.SpiderPath   = txtselectpath.Text.Trim();
            spiderconfig.AutoParms    = txtautoparms.Text.Trim();
            spiderconfig.LogName      = "";
            spiderconfig.SpiderOutPut = "";
            if (txtlogname.Visible)
            {
                spiderconfig.LogName = txtlogname.Text.Trim() + cbxlog.SelectedItem.ToString();
            }
            if (cbxlog.SelectedItem.ToString().Contains("nolog") && !txtlogname.Visible)
            {
                spiderconfig.LogName = cbxlog.SelectedItem.ToString();
            }

            if (txtoutputname.Visible)
            {
                spiderconfig.SpiderOutPut = txtoutputname.Text.Trim() + cbxoutput.SelectedItem.ToString();
            }

            if (bllspiderconfig.Update(spiderconfig))
            {
                NoteInfo(Info.Right, "更新方案成功");
                LoadSpider();
            }
            else
            {
                NoteInfo(Info.Error, "更新方案失败");
            }
        }
Beispiel #3
0
        //AddConfig
        private void btnaddconfig_Click(object sender, EventArgs e)
        {
            NoteInfo(Info.Loading, "增加方案中...");
            try
            {
                Model.spiderconfig spiderconfig = new Model.spiderconfig();
                spiderconfig.ConfigName   = txtconfigname.Text.Trim();
                spiderconfig.SpiderPath   = txtselectpath.Text.Trim();
                spiderconfig.AutoParms    = txtautoparms.Text.Trim();
                spiderconfig.LogName      = "";
                spiderconfig.SpiderOutPut = "";
                if (txtlogname.Visible)
                {
                    spiderconfig.LogName = txtlogname.Text.Trim() + cbxlog.SelectedItem.ToString();
                }
                if (cbxlog.SelectedItem.ToString().Contains("nolog") && !txtlogname.Visible)
                {
                    spiderconfig.LogName = cbxlog.SelectedItem.ToString();
                }

                if (txtoutputname.Visible)
                {
                    spiderconfig.SpiderOutPut = txtoutputname.Text.Trim() + cbxoutput.SelectedItem.ToString();
                }

                if (bllspiderconfig.Add(spiderconfig))
                {
                    NoteInfo(Info.Right, "新增一条配置成功!");
                    LoadSpider();
                }
                else
                {
                    NoteInfo(Info.Error, "新增失败!");
                }
            }
            catch (Exception ex)
            {
                NoteInfo(Info.Error, "增加方案失败:" + ex.ToString());
                throw;
            }
        }
Beispiel #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ScrapyForm.Model.spiderconfig model)
 {
     return(dal.Update(model));
 }
Beispiel #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(ScrapyForm.Model.spiderconfig model)
 {
     return(dal.Add(model));
 }