private void 制任务ToolStripMenuItem_Click(object sender, EventArgs e) { int ID = Get_DataViewID(); DALTask dal = new DALTask(); int currentMaxId = dal.GetMaxId(); ModelTask model = dal.GetModelSingleTask(ID); string currentTaskName = model.TaskName + "复制" + DateTime.Now.Millisecond; model.ID = currentMaxId; model.TaskName = currentTaskName; dal.Add(model); DALTaskLabel dalLable = new DALTaskLabel(); DataTable dt = dalLable.GetList(" TaskId=" + ID).Tables[0]; if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { ModelTaskLabel modelLabel = dalLable.GetModel(StringHelper.Instance.SetNumber(dr["Id"].ToString())); modelLabel.TaskID = currentMaxId; dalLable.Add(modelLabel); } } CreateDataFile(currentTaskName, currentMaxId); this.ClassID = model.TaskClassID.Value; Bind_DataList(); }
public void Create(DALTask task) { TaskInfo newTaskInfo = new TaskInfo() { Description = task.Description, Deadline = task.Deadline, Implementation = task.Implementation, // CreatorUser = context.Set<User>().FirstOrDefault(user=>user.Email==task.CreatorUser.Email), CreatorUserId = context.Set <User>().FirstOrDefault(user => user.Email == task.CreatorUser.Email).UserId, Developer = task.Developer == null?null:context.Set <User>().FirstOrDefault(user => user.Email == task.Developer.Email) }; Task newTask = new Task() { Title = task.Title, Price = task.Price, Status = task.Status, CategoryId = context.Set <Category>().FirstOrDefault(categ => categ.Name == task.Category).CategoryId, // Category = context.Set<Category>().FirstOrDefault(categ => categ.Name == task.Category), TaskInfo = newTaskInfo }; // newTaskInfo.Task = newTask; context.Set <Task>().Add(newTask); context.Set <TaskInfo>().Add(newTaskInfo); context.SaveChanges(); }
/// <summary> /// 创建文件 /// </summary> /// <param name="taskName"></param> private void CreateDataFile(string taskName, int taskID) { string baseDir = AppDomain.CurrentDomain.BaseDirectory + "Data\\Collection\\"; string SQLiteName = baseDir + taskName + "\\SpiderResult.db"; string LocalSQLiteName = "Data\\Collection\\" + taskName + "\\SpiderResult.db"; string SQL = string.Empty; if (!Directory.Exists(baseDir + taskName + "\\")) { Directory.CreateDirectory(baseDir + taskName + "\\"); } if (!File.Exists(SQLiteName)) { DbHelper.CreateDataBase(SQLiteName); DALTask dal = new DALTask(); string createSQL = string.Empty; DataTable dt = new DALTaskLabel().GetList(" TaskID=" + taskID).Tables[0]; foreach (DataRow dr in dt.Rows) { createSQL += @" [" + dr["LabelName"] + @"] varchar,"; } if (createSQL.Trim() != "") { createSQL = createSQL.Remove(createSQL.Length - 1); } string ss = string.Empty; if (!string.IsNullOrEmpty(createSQL)) { ss = ","; } SQL = @" create table Content( ID integer primary key autoincrement, [HrefSource] varchar, [已采] int, [已发] int" + ss + @" " + createSQL + @" ); "; DbHelper.Execute(LocalSQLiteName, SQL); } else { DataTable dt = new DALTaskLabel().GetList(" TaskID=" + taskID).Tables[0]; foreach (DataRow dr in dt.Rows) { try { DbHelper.Execute(LocalSQLiteName, " ALTER TABLE Content ADD COLUMN [" + dr["LabelName"] + "] VARCHAR; "); } catch { continue; } } } }
private void 导出采集规则ToolStripMenuItem_Click(object sender, EventArgs e) { var id = this.Get_DataViewID(); if (id > 0) { var dal = new DALTask(); var model = dal.GetModelSingleTask(id); } }
public void Bind_DataList(string strWhere) { if (this.ClassID > 0) { strWhere += " And TaskClassID=" + this.ClassID + " "; } strWhere += " Order by Id Desc "; DALTask dal = new DALTask(); DataTable dt = dal.GetList(strWhere).Tables[0]; this.dataGridView_TaskList.DataSource = dt.DefaultView; }
/// <summary> /// 清除所有任务数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolStripMenuItem_ClearTaskAllData_Click(object sender, EventArgs e) { if (MessageBox.Show("你确定要清除数据吗?清除不可恢复!", "警告!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { ModelTask model = new ModelTask(); int ID = Get_DataViewID(); DALTask dal = new DALTask(); model = dal.GetModelSingleTask(ID); string LocalSQLiteName = "Data\\Collection\\" + model.TaskName + "\\SpiderResult.db"; string sql = " DELETE FROM Content"; DbHelper.Execute(LocalSQLiteName, sql); } }
private void ToolStripMenuItem_ViewTaskData_Click(object sender, EventArgs e) { ModelTask model = new ModelTask(); int ID = Get_DataViewID(); DALTask dal = new DALTask(); model = dal.GetModelSingleTask(ID); frmTaskDataList FromTaskDataList = new frmTaskDataList(); FromTaskDataList.TaskName = model.TaskName; FromTaskDataList.ShowDialog(this); }
private void toolStripButton_TaskDelete_Click(object sender, EventArgs e) { int taskId = m_frmTaskMain.Get_DataViewID(); if (taskId > 0) { if (MessageBox.Show("你确定要删除吗?删除不可恢复!", "警告!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { DALTask dal = new DALTask(); dal.Delete(taskId); m_frmTaskMain.Bind_DataList(); } } }
public void Delete(DALTask task) { Task taskToDel = context.Set <Task>().FirstOrDefault(t => t.TaskId == task.Id); if (ReferenceEquals(taskToDel, null)) { throw new InvalidOperationException(); } context.Set <TaskInfo>().Remove(taskToDel.TaskInfo); context.Set <Task>().Remove(taskToDel); context.SaveChanges(); }
/// <summary> /// 任务开始 /// </summary> private void ToolStripMenuItem_TaskStart_Click(object sender, EventArgs e) { try { DALTask dal = new DALTask(); ModelTask model = new ModelTask(); int ID = Get_DataViewID(); if (listGatherTask.ContainsKey(ID.ToString())) { var Spider = listGatherTask.FirstOrDefault().Value; if (Spider.Stopped) { Spider.Start(); } } else { model = dal.GetModelSingleTask(ID); if (model.Status != 1) { MainEvents.OutPutWindowEventArgs ev = new MainEvents.OutPutWindowEventArgs(); ev.Message = "任务关闭中.不可采集..."; OutPutWindowDelegate?.Invoke(this, ev); return; } string baseDir = AppDomain.CurrentDomain.BaseDirectory + "Data\\Collection\\"; string SQLiteName = baseDir + model.TaskName + "\\SpiderResult.db"; if (!File.Exists(SQLiteName)) { CreateDataFile(model.TaskName, ID); } var Spider = new SpiderHelper(); Spider.modelTask = model; Spider.GatherWorkDelegate = OutUrl; Spider.GatherComplateDelegate = GatherOverDelegate; Spider.OutPutTaskProgressBarDelegate = OutPutTaskProgressBarDelegate; Spider.TaskIndex = this.dataGridView_TaskList.SelectedRows[0].Index; Spider.Start(); lock (listGatherTask) { if (!listGatherTask.ContainsKey(ID.ToString())) { listGatherTask.Add(ID.ToString(), Spider); } } } } catch (Exception ex) { Log4Helper.Write(LogLevel.Error, ex.StackTrace, ex); } }
private void FrmTaskMain_Load(object sender, EventArgs e) { Bind_DataList(); Bind_Plugin(); tsmExportData.DropDownItems.Clear(); foreach (IOutPutFormat t in PluginUtility.ListIOutputFormatPlugin) { var item = new ToolStripMenuItem(t.Format); item.MouseEnter += (object s, EventArgs e1) => { var id = Get_DataViewID(); var Model = new DALTask().GetModel(id); if (Model.IsSaveLocal2 != null && Model.IsSaveLocal2.Value == 1) { item.Enabled = true; } else { item.Enabled = false; } }; item.Click += (object s, EventArgs e1) => { var id = Get_DataViewID(); var Model = new DALTask().GetModel(id); string LocalSQLiteName = "Data\\Collection\\" + Model.TaskName + "\\SpiderResult.db"; DataTable dtData = DbHelper.Query(LocalSQLiteName, "Select * From Content").Tables[0]; if (!Directory.Exists(Model.SaveDirectory2)) { Directory.CreateDirectory(Model.SaveDirectory2); } if (File.Exists(LocalSQLiteName)) { var r = t.RunSave(dtData, Model); MainEvents.OutPutWindowEventArgs ev = new MainEvents.OutPutWindowEventArgs(); if (r.IsOk) { ev.Message = r.Message; OutPutWindowDelegate?.Invoke(this, ev); } else { ev.Message = "保存过程出现错误" + r.Message; OutPutWindowDelegate?.Invoke(this, ev); } } }; tsmExportData.DropDownItems.Add(item); } }
public static TaskEntity ToBllEntity(this DALTask task) { return(new TaskEntity() { Id = task.Id, Title = task.Title, Price = task.Price, Status = (Status)task.Status, Category = task.Category, Description = task.Description, Deadline = task.Deadline, Implementation = task.Implementation, CreatorUser = task.CreatorUser == null ? null : task.CreatorUser.ToBllUser(), Developer = task.Developer == null ? null : task.Developer.ToBllUser() }); }
private void tsmOpenTaskDir_Click(object sender, EventArgs e) { ModelTask model = new ModelTask(); int ID = Get_DataViewID(); DALTask dal = new DALTask(); model = dal.GetModelSingleTask(ID); // if (!string.IsNullOrEmpty(model.TaskName)) // { Process p = new Process(); p.StartInfo.FileName = "explorer.exe"; p.StartInfo.Arguments = AppDomain.CurrentDomain.BaseDirectory + "Data\\Collection\\" + model.TaskName; p.Start(); // } }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolStripMenuItem_TaskDel_Click(object sender, EventArgs e) { if (MessageBox.Show("你确定要删除吗?删除不可恢复!", "警告!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { DALTask dal = new DALTask(); ModelTask model = dal.GetModel(Get_DataViewID()); string TaskName = model.TaskName; string RootPath = AppDomain.CurrentDomain.BaseDirectory + "Data\\Collection\\"; string TaskPath = RootPath + TaskName; if (Directory.Exists(TaskPath)) { Directory.Delete(TaskPath, true); } dal.Delete(Get_DataViewID()); this.Bind_DataList(); } }
private void 导出采集规则ToolStripMenuItem_Click(object sender, EventArgs e) { var id = this.Get_DataViewID(); if (id > 0) { var dal = new DALTask(); var model = dal.GetModelSingleTask(id); var saveDialog = new SaveFileDialog(); saveDialog.Filter = "(*.xml)|*.xml"; saveDialog.FileName = model.TaskName + DateTime.Now.ToString("yyyy-MM-dd"); if (saveDialog.ShowDialog() == DialogResult.OK) { if (SerializeHelper.SerializeObject <ModelTask>(model, saveDialog.FileName)) { MessageBox.Show("导出成功"); } } } }
public void Update(DALTask taskToUp) { Task task = context.Set <Task>().Find(taskToUp.Id); //context.Entry(task).CurrentValues.SetValues(taskToUp); task.Title = taskToUp.Title; task.Category = context.Set <Category>().First(c => c.Name == taskToUp.Category); task.Price = taskToUp.Price; task.Status = taskToUp.Status; TaskInfo taskInfo = task.TaskInfo; taskInfo.Developer = taskToUp.Developer == null?null:context.Set <User>().FirstOrDefault(u => u.UserId == taskToUp.Developer.Id); //context.Entry(taskInfo).CurrentValues.SetValues(taskToUp); taskInfo.Deadline = taskToUp.Deadline; taskInfo.Description = taskToUp.Description; taskInfo.Implementation = taskToUp.Implementation; context.SaveChanges(); }
public void Bind_DataList(string strWhere) { if (this.ClassID > 0) { strWhere += " And TaskClassID=" + this.ClassID + " "; } strWhere += " Order by Id Desc "; DALTask dal = new DALTask(); DataTable dt = dal.GetList(strWhere).Tables[0]; this.dataGridView_TaskList.DataSource = dt.DefaultView; for (int i = 0; i < this.dataGridView_TaskList.Rows.Count; i++) { var row = this.dataGridView_TaskList.Rows[i]; row.Selected = false; if (i == m_RowIndex) { row.Selected = true; } } }
/// <summary> /// 任务开始 /// </summary> private void ToolStripMenuItem_TaskStart_Click(object sender, EventArgs e) { try { DALTask dal = new DALTask(); ModelTask model = new ModelTask(); int ID = Get_DataViewID(); //检查目录是否存在 //model = dal.GetModelSingleTask(ID); if (listGatherTask.ContainsKey(ID.ToString())) { SpiderHelper Spider = listGatherTask.FirstOrDefault().Value; if (Spider.Stopped) { Spider.Start(); } } else { model = dal.GetModelSingleTask(ID); SpiderHelper Spider = new SpiderHelper(); Spider.modelTask = model; Spider.GatherWorkDelegate = OutUrl; Spider.GatherComplateDelegate = GatherOverDelegate; Spider.OutPutTaskProgressBarDelegate = OutPutTaskProgressBarDelegate; Spider.TaskIndex = this.dataGridView_TaskList.SelectedRows[0].Index; Spider.Start(); lock (listGatherTask) { if (!listGatherTask.ContainsKey(ID.ToString())) { listGatherTask.Add(ID.ToString(), Spider); } } } } catch (Exception ex) { Log4Helper.Write(LogLevel.Error, ex.StackTrace, ex); } }
private void tsmTaskOpenResourceDir_Click(object sender, EventArgs e) { ModelTask model = new ModelTask(); int ID = Get_DataViewID(); DALTask dal = new DALTask(); model = dal.GetModelSingleTask(ID); if (!string.IsNullOrEmpty(model.ResourceSavePath)) { Process p = new Process(); p.StartInfo.FileName = "explorer.exe"; p.StartInfo.Arguments = model.ResourceSavePath; p.Start(); } else { Process p = new Process(); p.StartInfo.FileName = "explorer.exe"; p.StartInfo.Arguments = AppDomain.CurrentDomain.BaseDirectory + "Data\\Collection\\" + model.TaskName + "\\Images\\"; p.Start(); } }
private void btnSubmit_Click(object sender, EventArgs e) { string WebCollectionModule = this.txtWebCollectionModule.Text; if (string.IsNullOrEmpty(WebCollectionModule)) { MessageBox.Show("采集模块不能为空!"); return; } var model = SerializeHelper.DeserializeObject <ModelTask>(WebCollectionModule); DALTask dal = new DALTask(); int currentMaxId = dal.GetMaxId(); model.ID = currentMaxId; dal.Add(model); foreach (ModelTaskLabel label in model.ListTaskLabel) { label.TaskID = currentMaxId; var d = new DALTaskLabel(); var m = d.GetMaxID(); label.ID = m; d.Add(label); } foreach (ModelWebPublishModule label in model.ListModelWebPublishModule) { label.TaskID = currentMaxId; var d = new DALWebPublishModule(); label.ID = 0; d.Add(label); } MessageBox.Show("导入成功"); RefreshParentForm?.Invoke(this, new EventArgs()); this.Hide(); this.Close(); }
private void btnSubmit_Click(object sender, EventArgs e) { DALTask dal = new DALTask(); ModelTask model = new ModelTask(); errorProvider.Clear(); if (string.IsNullOrEmpty(this.cmbSiteClassID.Text)) { errorProvider.SetError(this.cmbSiteClassID, "所属站点不能为空!"); return; } if (string.IsNullOrEmpty(this.txtTaskName.Text)) { errorProvider.SetError(this.txtTaskName, "任务名称不能为空!"); return; } if (string.IsNullOrEmpty(this.txtDemoListUrl.Text)) { errorProvider.SetError(this.txtDemoListUrl, "测试网站列表地址不能为空!"); return; } if (string.IsNullOrEmpty(this.ddlItemEncode.Text)) { errorProvider.SetError(this.ddlItemEncode, "网页编码不能为空!"); return; } int ID = int.Parse(this.txtID.Text); int TaskClassID = int.Parse(this.cmbSiteClassID.SelectedValue.ToString()); string TaskName = this.txtTaskName.Text; string OldTaskName = this.txtOldTaskName.Text; int IsSpiderUrl = this.chkIsSpiderUrl.Checked ? 1 : 0; int IsSpiderContent = this.chkIsSpiderContent.Checked ? 1 : 0; int IsPublishContent = this.chkIsPublishContent.Checked ? 1 : 0; string PageEncode = ((ListItem)this.ddlItemEncode.SelectedItem).Value; string CollectionContent = string.Empty; foreach (string str in listBoxLinkUrl.Items) { CollectionContent += str + "$$$$"; } string LinkUrlMustIncludeStr = this.txtLinkUrlMustIncludeStr.Text; string LinkUrlNoMustIncludeStr = this.txtLinkUrlNoMustIncludeStr.Text; string LinkUrlCutAreaStart = this.txtLinkUrlCutAreaStart.Text.Replace("'", "''"); string LinkUrlCutAreaEnd = this.txtLinkUrlCutAreaEnd.Text.Replace("'", "''"); string TestViewUrl = this.txtTextViewUrl.Text; int IsWebOnlinePublish1 = this.chkPublish01.Checked ? 1 : 0; int IsSaveLocal2 = this.chkPublish02.Checked ? 1 : 0; string SaveFileFormat2 = this.ddlSaveFileFormat2.Text; string SaveDirectory2 = this.txtSaveDirectory2.Text; string SaveHtmlTemplate2 = this.txtSaveHtmlTemplate2.Text; int IsSaveDataBase3 = this.chkPublish03.Checked ? 1 : 0; int SaveDataType3 = 0; if (this.rbtnAccess.Checked) { SaveDataType3 = 1; } else if (this.rbtnMsSql.Checked) { SaveDataType3 = 2; } else if (this.rbtnSqlite.Checked) { SaveDataType3 = 3; } else if (this.rbtnMySql.Checked) { SaveDataType3 = 4; } else if (this.rbtnSqlite.Checked) { SaveDataType3 = 5; } string SaveDataUrl3 = this.txtSaveDataUrl3.Text; string SaveDataSQL3 = this.txtSaveDataSQL3.Text; int IsSaveSQL4 = this.chkPublish04.Checked ? 1 : 0; decimal CollectionContentThreadCount = this.nudCollectionContentThreadCount.Value; decimal CollectionContentStepTime = this.nudCollectionContentStepTime.Value; decimal PublishContentThreadCount = this.nudPublishContentThreadCount.Value; decimal PublishContentStepTimeMin = this.nudPublishContentStepTimeMin.Value; decimal PublishContentStepTimeMax = this.nudPublishContentStepTimeMax.Value; int IsHandGetUrl = this.chkIsHandGetUrl.Checked ? 1 : 0; string HandCollectionUrlRegex = this.txtHandCollectionUrlRegex.Text; int IsPlan = this.chkTaskSetStatus.Checked ? 1 : 0; string PlanFormat = this.txtHiddenPlanFormat.Text; model.ID = ID; model.TaskClassID = TaskClassID; model.TaskName = TaskName; model.IsSpiderUrl = IsSpiderUrl; model.IsSpiderContent = IsSpiderContent; model.IsPublishContent = IsPublishContent; model.PageEncode = PageEncode; model.CollectionContent = CollectionContent; model.LinkUrlMustIncludeStr = LinkUrlMustIncludeStr; model.LinkUrlNoMustIncludeStr = LinkUrlNoMustIncludeStr; model.LinkUrlCutAreaStart = LinkUrlCutAreaStart; model.LinkUrlCutAreaEnd = LinkUrlCutAreaEnd; model.TestViewUrl = TestViewUrl; model.IsWebOnlinePublish1 = IsWebOnlinePublish1; model.IsSaveLocal2 = IsSaveLocal2; model.SaveFileFormat2 = SaveFileFormat2; model.SaveDirectory2 = SaveDirectory2; model.SaveHtmlTemplate2 = SaveHtmlTemplate2; model.IsSaveDataBase3 = IsSaveDataBase3; model.SaveDataType3 = SaveDataType3; model.SaveDataUrl3 = SaveDataUrl3; model.SaveDataSQL3 = SaveDataSQL3; model.IsSaveSQL4 = IsSaveSQL4; model.PluginSpiderUrl = this.cmbSpiderUrlPlugins.Text; model.PluginSaveContent = this.cmbSaveConentPlugins.Text; model.PluginPublishContent = this.cmbPublishContentPlugins.Text; model.CollectionUrlStepTime = int.Parse(nudCollectionUrlStepTime.Value.ToString()); model.CollectionContentThreadCount = Convert.ToInt32(CollectionContentThreadCount); model.CollectionContentStepTime = Convert.ToInt32(CollectionContentStepTime); model.PublishContentThreadCount = Convert.ToInt32(PublishContentThreadCount); model.PublishContentStepTimeMin = Convert.ToInt32(PublishContentStepTimeMin); model.PublishContentStepTimeMax = Convert.ToInt32(PublishContentStepTimeMax); model.IsHandGetUrl = IsHandGetUrl; model.HandCollectionUrlRegex = HandCollectionUrlRegex; model.DemoListUrl = this.txtDemoListUrl.Text; model.IsPlan = IsPlan; model.PlanFormat = PlanFormat; model.Status = this.cmbStatus.SelectedIndex == 0 ? 1 : 0; model.IsSource = this.chkIsSource.Checked ? 1 : 0; model.SourceText = this.txtSourceText.Text; if (ID == 0) { string guid = Guid.NewGuid().ToString(); ID = dal.GetMaxId(); model.ID = ID; model.Guid = guid; dal.Add(model); DALTaskLabel dalTaskLabel = new DALTaskLabel(); dalTaskLabel.UpdateTaskLabelByTaskID(ID); if (TaskOpDelegate != null) { TaskOpEv.TaskIndex = TaskIndex; TaskOpDelegate(this, TaskOpEv); } } else if (ID > 0) { if (TaskName != OldTaskName) { string RootPath = AppDomain.CurrentDomain.BaseDirectory + "Data\\Collection\\"; string OldTaskPath = RootPath + OldTaskName; string NewTaskPath = RootPath + TaskName; if (Directory.Exists(NewTaskPath)) { MessageBox.Show("任务名称存在!请换个名称试试!"); return; } try { Directory.Move(OldTaskPath, NewTaskPath); } catch (Exception ex) { MessageBox.Show("修改异常!" + ex.Message); return; } } if (!dal.CheckTaskGuid(ID)) { model.Guid = Guid.NewGuid().ToString(); } dal.Update(model); if (TaskOpDelegate != null) { TaskOpEv.TaskIndex = TaskIndex; TaskOpEv.OpType = 1; TaskOpDelegate(this, TaskOpEv); } } CreateDataFile(TaskName, ID); #region 更新计划任务 if (model.IsPlan == 1) { PlanTaskHelper.PushJobDetail(ID); } #endregion this.CloseForm(); }
private void Bind_DataEdit(int ID) { this.Text = "编辑任务"; ModelTask model = new DALTask().GetModel(ID); this.txtID.Text = model.ID.ToString(); this.cmbSiteClassID.SelectedValue = model.TaskClassID; this.txtTaskName.Text = model.TaskName; this.txtOldTaskName.Text = model.TaskName; this.chkIsSpiderUrl.Checked = model.IsSpiderUrl.ToString() == "1" ? true : false; this.chkIsSpiderContent.Checked = model.IsSpiderContent.ToString() == "1" ? true : false; this.chkIsPublishContent.Checked = model.IsPublishContent.ToString() == "1" ? true : false; ListItem item = new ListItem(model.PageEncode, model.PageEncode); this.ddlItemEncode.SelectedItem = item; if (!string.IsNullOrEmpty(model.CollectionContent)) { foreach (string str in model.CollectionContent.Split(new string[] { "$$$$" }, StringSplitOptions.RemoveEmptyEntries)) { this.listBoxLinkUrl.Items.Add(str); } } this.txtLinkUrlMustIncludeStr.Text = model.LinkUrlMustIncludeStr; this.txtLinkUrlNoMustIncludeStr.Text = model.LinkUrlNoMustIncludeStr; this.txtLinkUrlCutAreaStart.Text = model.LinkUrlCutAreaStart; this.txtLinkUrlCutAreaEnd.Text = model.LinkUrlCutAreaEnd; this.txtTextViewUrl.Text = model.TestViewUrl; this.chkPublish01.Checked = model.IsWebOnlinePublish1.ToString() == "1" ? true : false; this.chkPublish02.Checked = model.IsSaveLocal2.ToString() == "1" ? true : false; this.ddlSaveFileFormat2.Text = model.SaveFileFormat2; this.txtSaveDirectory2.Text = model.SaveDirectory2; this.txtSaveHtmlTemplate2.Text = model.SaveHtmlTemplate2; this.chkPublish03.Checked = model.IsSaveDataBase3.ToString() == "1" ? true : false; string SaveDataType3 = model.SaveDataType3.ToString(); switch (SaveDataType3) { case "1": this.rbtnAccess.Checked = true; break; case "2": this.rbtnMsSql.Checked = true; break; case "3": this.rbtnSqlite.Checked = true; break; case "4": this.rbtnMySql.Checked = true; break; case "5": this.rbtnOracle.Checked = true; break; } this.txtSaveDataUrl3.Text = model.SaveDataUrl3; this.txtSaveDataSQL3.Text = model.SaveDataSQL3; this.chkPublish04.Checked = model.IsSaveSQL4.ToString() == "1" ? true : false; this.cmbSpiderUrlPlugins.Text = model.PluginSpiderUrl; this.cmbSaveConentPlugins.Text = model.PluginSaveContent; this.cmbPublishContentPlugins.Text = model.PluginPublishContent; this.nudCollectionContentThreadCount.Value = model.CollectionContentThreadCount.Value; this.nudCollectionContentStepTime.Value = model.CollectionContentStepTime.Value; this.nudPublishContentThreadCount.Value = model.PublishContentThreadCount.Value; this.nudPublishContentStepTimeMin.Value = model.PublishContentStepTimeMin.Value; this.nudPublishContentStepTimeMax.Value = model.PublishContentStepTimeMax.Value; this.chkIsHandGetUrl.Checked = model.IsHandGetUrl.Value == 1 ? true : false; this.txtHandCollectionUrlRegex.Text = model.HandCollectionUrlRegex; this.txtDemoListUrl.Text = model.DemoListUrl; this.chkTaskSetStatus.Checked = model.IsPlan == 1 ? true : false; this.txtHiddenPlanFormat.Text = model.PlanFormat; this.cmbStatus.SelectedIndex = model.Status == 1 ? 0 : 1; this.chkIsSource.Checked = model.IsSource == 1 ? true : false; this.txtSourceText.Text = model.SourceText; }
public DALTask GetAdditionalInfo(DALTask user) { throw new NotImplementedException(); }
/// <summary> /// 创建文件 /// </summary> /// <param name="taskName"></param> private void CreateDataFile(string taskName, int taskID) { string baseDir = AppDomain.CurrentDomain.BaseDirectory + "Data\\Collection\\"; string SQLiteName = baseDir + taskName + "\\SpiderResult.db"; string LocalSQLiteName = "Data\\Collection\\" + taskName + "\\SpiderResult.db"; string SQL = string.Empty; if (!Directory.Exists(baseDir + taskName + "\\")) { Directory.CreateDirectory(baseDir + taskName + "\\"); } if (!File.Exists(SQLiteName)) { DbHelper.CreateDataBase(SQLiteName); DALTask dal = new DALTask(); string createSQL = string.Empty; DataTable dt = new DALTaskLabel().GetList(" TaskID=" + taskID).Tables[0]; foreach (DataRow dr in dt.Rows) { createSQL += @" " + dr["LabelName"] + @" varchar,"; } if (createSQL.Trim() != "") { createSQL = createSQL.Remove(createSQL.Length - 1); } SQL = @" create table Content( ID integer primary key autoincrement, [HrefSource] varchar, [已采] int, [已发] int, " + createSQL + @" ); "; DbHelper.Execute(LocalSQLiteName, SQL); } else { DataTable dt = new DALTaskLabel().GetList(" TaskID=" + taskID).Tables[0]; //20190522 更新原因,原来删除或更改字段时,本地数据库中原有列不能删除,或变更 var columns = "ID,[HrefSource],[已采],[已发],"; foreach (DataRow dr in dt.Rows) { try { //20190522 更新原因,原来删除或更改字段时,本地数据库中原有列不能删除,或变更 columns += "[" + dr["LabelName"] + "],"; DbHelper.Execute(LocalSQLiteName, " ALTER TABLE Content ADD COLUMN [" + dr["LabelName"] + "] VARCHAR; "); } catch { continue; } } //20190522 更新原因,原来删除或更改字段时,本地数据库中原有列不能删除,或变更 columns = columns.TrimEnd(','); if (!string.IsNullOrEmpty(columns)) { DbHelper.Execute(LocalSQLiteName, $"create table tempContent as select {columns} from Content "); DbHelper.Execute(LocalSQLiteName, $"drop table if exists Content "); DbHelper.Execute(LocalSQLiteName, $"alter table tempContent rename to Content "); } } }