Esempio n. 1
0
        /// <summary>
        /// 绑定任务单元到UI界面,用于新建/修改任务
        /// </summary>
        private void SetUnitToUI()
        {
            #region 常规选项设置
            this.txtName.Text                              = this._TaskUnit.TaskConfig.Name;                                                      //任务名称
            this.txtDescription.Text                       = this._TaskUnit.TaskConfig.Description;                                               //任务描述
            this.txtCookie.Text                            = this._TaskUnit.TaskConfig.Cookie;                                                    //Cookie
            this.nudThreadNumber.Value                     = this._TaskUnit.TaskConfig.ThreadNumber;                                              //线程数量
            this.txtStartingUrlTemplate.Text               = this._TaskUnit.TaskConfig.UrlListManager.StartingUrlTemplate;                        //起始Url地址模板
            this.txtConnectionString.Text                  = this._TaskUnit.TaskConfig.ConnectionString;                                          //数据库连接字符串
            this.chbDeleteResultAfterPublication.Checked   = this._TaskUnit.TaskConfig.DeleteResultAfterPublication;                              //发布结果后删除数据
            this.chbDisableScheduleAfterFinish.Checked     = this._TaskUnit.TaskConfig.DisableScheduleAfterFinish;                                //取消定时采集
            this.txtPluginPath.Text                        = this._TaskUnit.TaskConfig.PluginPath;                                                //插件路径
            this.chbUseProcedure.Checked                   = this._TaskUnit.TaskConfig.UseProcedure;                                              //使用存储过程
            this.chbIgnoreDataColumnNotFound.Checked       = this._TaskUnit.TaskConfig.IgnoreDataColumnNotFound;                                  //忽略不存在的数据列
            this.rdbAutoLogin.Checked                      = this._TaskUnit.TaskConfig.LoginAutomatically;                                        //自动登录
            this.chbOutputDetailedLog.Checked              = this._TaskUnit.TaskConfig.OutputDetailedLog;                                         //输出详细日志
            this.cbxPublicationTarget.Text                 = this._TaskUnit.TaskConfig.PublicationTarget;                                         //发布目标
            this.chbSaveLogToFile.Checked                  = this._TaskUnit.TaskConfig.SaveLogToFile;                                             //保存日志到文件
            this.chbSaveErrorRows.Checked                  = this._TaskUnit.TaskConfig.SaveErrorRows;                                             //保存错误行到文件
            this.chbSaveRepeatedRows.Checked               = this._TaskUnit.TaskConfig.SaveRepeatedRows;                                          //保存重复行到文件
            this.chbUsePluginOfDownloadContentFile.Checked = this._TaskUnit.TaskConfig.UsePluginOfDownloadContentFile;                            //使用插件下载内容文件
            this.chbUsePluginOfDownloadSingleFile.Checked  = this._TaskUnit.TaskConfig.UsePluginOfDownloadSingleFile;                             //使用插件下载独立文件
            this.chbUsePluginOfProcessResultRow.Checked    = this._TaskUnit.TaskConfig.UsePluginOfProcessResultRow;                               //使用插件处理采集结果数据行
            this.chbUsePluginOfGetWebProxy.Checked         = this._TaskUnit.TaskConfig.UsePluginOfGetWebProxy;                                    //从插件载入代理服务器
            this.chbUsePluginOfProcessContentFile.Checked  = this._TaskUnit.TaskConfig.UsePluginOfProcessContentFile;                             //使用插件处理下载后的内容文件
            this.chbUsePluginOfProcessSingleFile.Checked   = this._TaskUnit.TaskConfig.UsePluginOfProcessSingleFile;                              //使用插件处理单个文件
            this.cbxUrlEncoding.Text                       = this._TaskUnit.TaskConfig.UrlListManager.UrlEncoding;                                //网址编码
            this.nudHistoryCount.Value                     = this._TaskUnit.TaskConfig.UrlListManager.HistoryUrlCapacity;                         //历史记录网址最大容量
            this.chbStartingUrlEncoded.Checked             = this._TaskUnit.TaskConfig.UrlListManager.StartingUrlEncoded;                         //起始地址已编码
            this.lblUrlAddressCount.Text                   = "地址总数 " + this._TaskUnit.TaskConfig.UrlListManager.StartingUrlList.Count.ToString(); //地址总数
            //未设置(使用插件对采集结果进行筛选,将在软件内置筛选之后进行)
            #endregion

            #region 定时采集(任务调度)
            //调度模式
            this.chbScheduleEnabled.Checked = this._TaskUnit.TaskConfig.ScheduleEnabled;
            if (this._TaskUnit.TaskConfig.ScheduleMode == ScheduleMode.Time)
            {
                //每隔时间段
                rdoScheduleModeTime.Checked = true;
                rdoScheduleModeDay.Checked  = false;

                this.nudScheduleDays.Value    = this._TaskUnit.TaskConfig.ScheduleDays;    //天
                this.nudScheduleHours.Value   = this._TaskUnit.TaskConfig.ScheduleHours;   //时
                this.nudScheduleMinutes.Value = this._TaskUnit.TaskConfig.ScheduleMinutes; //分
            }
            else
            {
                //(每当模式)
                rdoScheduleModeTime.Checked = false;
                rdoScheduleModeDay.Checked  = true;

                //每当时间
                //this._TaskUnit.TaskConfig.ScheduleFromDayOfWeek; //每当星期几开始
                //this._TaskUnit.TaskConfig.ScheduleFromDay; //每当星期几开始
                //this._TaskUnit.TaskConfig.ScheduleFromHour; //每当X小时调度

                //预定时间
                //this._TaskUnit.TaskConfig.ScheduleFromDayOfWeek; //预定星期几结束
                //this._TaskUnit.TaskConfig.ScheduleToDay; //预定天
                //this._TaskUnit.TaskConfig.ScheduleToHour; //预定小时
            }
            #endregion

            #region 数据库类型
            switch (this._TaskUnit.TaskConfig.DatabaseType)
            {
            case DatabaseType.Access:
                rdoDataTypeAccess.Checked = true;
                break;

            case DatabaseType.MySql:
                rdoDataTypeMySql.Checked = true;
                break;

            case DatabaseType.Oracle:
                rdoDataTypeOracle.Checked = true;
                break;

            case DatabaseType.SqlLite:
                rdoDataTypeSqlLite.Checked = true;
                break;

            case DatabaseType.SqlServer:
                rdoDataTypeSqlServer.Checked = true;
                break;
            }
            #endregion

            #region 发布结果选项
            if (this._TaskUnit.TaskConfig.PublishResultDircetly)
            {
                this.rdoResultSaveDB.Checked   = true;
                this.rdoResultSaveFile.Checked = false;
            }
            else
            {
                this.rdoResultSaveFile.Checked = true;
                this.rdoResultSaveDB.Checked   = false;
            }
            #endregion

            #region 采集规则
            this.LivExtractionRule.Items.Clear();
            for (int i = 0; i < this._TaskUnit.TaskConfig.ExtractionRules.Count; i++)
            {
                Utility.ExtractionRulesItem item = new Utility.ExtractionRulesItem(this._TaskUnit.TaskConfig.ExtractionRules[i], i);
                LivExtractionRule.Items.Add(item);
            }
            #endregion

            #region 导航规则
            this.livNavigationRule.Items.Clear();
            for (int i = 0; i < this._TaskUnit.TaskConfig.UrlListManager.NavigationRules.Count; i++)
            {
                Utility.NavigationRuleItem item = new Utility.NavigationRuleItem(this._TaskUnit.TaskConfig.UrlListManager.NavigationRules[i], i);
                this.livNavigationRule.Items.Add(item);
            }
            #endregion

            #region 起始地址列表
            this.libStartingUrlList.Items.Clear();
            foreach (string url in this._TaskUnit.TaskConfig.UrlListManager.StartingUrlList)
            {
                this.libStartingUrlList.Items.Add(url);
            }
            foreach (PagedUrlPatterns p in this._TaskUnit.TaskConfig.UrlListManager.PagedUrlPattern)
            {
                this.libStartingUrlList.Items.Add(p.PagedUrlPattern);
            }
            #endregion
        }
Esempio n. 2
0
        /// <summary>
        /// 绑定任务单元到UI界面,用于新建/修改任务
        /// </summary>
        private void SetUnitToUI() {
            #region 常规选项设置
            this.txtName.Text = this._TaskUnit.TaskConfig.Name;                                                         //任务名称
            this.txtDescription.Text = this._TaskUnit.TaskConfig.Description;                                           //任务描述
            this.txtCookie.Text = this._TaskUnit.TaskConfig.Cookie;                                                     //Cookie
            this.nudThreadNumber.Value = this._TaskUnit.TaskConfig.ThreadNumber;                                        //线程数量
            this.txtStartingUrlTemplate.Text = this._TaskUnit.TaskConfig.UrlListManager.StartingUrlTemplate;            //起始Url地址模板
            this.txtConnectionString.Text = this._TaskUnit.TaskConfig.ConnectionString;                                 //数据库连接字符串
            this.chbDeleteResultAfterPublication.Checked = this._TaskUnit.TaskConfig.DeleteResultAfterPublication;      //发布结果后删除数据
            this.chbDisableScheduleAfterFinish.Checked = this._TaskUnit.TaskConfig.DisableScheduleAfterFinish;          //取消定时采集
            this.txtPluginPath.Text = this._TaskUnit.TaskConfig.PluginPath;                                             //插件路径
            this.chbUseProcedure.Checked = this._TaskUnit.TaskConfig.UseProcedure;                                      //使用存储过程
            this.chbIgnoreDataColumnNotFound.Checked = this._TaskUnit.TaskConfig.IgnoreDataColumnNotFound;              //忽略不存在的数据列
            this.rdbAutoLogin.Checked = this._TaskUnit.TaskConfig.LoginAutomatically;                                   //自动登录            
            this.chbOutputDetailedLog.Checked = this._TaskUnit.TaskConfig.OutputDetailedLog;                            //输出详细日志
            this.cbxPublicationTarget.Text = this._TaskUnit.TaskConfig.PublicationTarget;                               //发布目标
            this.chbSaveLogToFile.Checked = this._TaskUnit.TaskConfig.SaveLogToFile;                                    //保存日志到文件
            this.chbSaveErrorRows.Checked = this._TaskUnit.TaskConfig.SaveErrorRows;                                    //保存错误行到文件
            this.chbSaveRepeatedRows.Checked = this._TaskUnit.TaskConfig.SaveRepeatedRows;                              //保存重复行到文件
            this.chbUsePluginOfDownloadContentFile.Checked = this._TaskUnit.TaskConfig.UsePluginOfDownloadContentFile;  //使用插件下载内容文件
            this.chbUsePluginOfDownloadSingleFile.Checked = this._TaskUnit.TaskConfig.UsePluginOfDownloadSingleFile;    //使用插件下载独立文件
            this.chbUsePluginOfProcessResultRow.Checked = this._TaskUnit.TaskConfig.UsePluginOfProcessResultRow;        //使用插件处理采集结果数据行
            this.chbUsePluginOfGetWebProxy.Checked = this._TaskUnit.TaskConfig.UsePluginOfGetWebProxy;                  //从插件载入代理服务器
            this.chbUsePluginOfProcessContentFile.Checked = this._TaskUnit.TaskConfig.UsePluginOfProcessContentFile;    //使用插件处理下载后的内容文件
            this.chbUsePluginOfProcessSingleFile.Checked = this._TaskUnit.TaskConfig.UsePluginOfProcessSingleFile;      //使用插件处理单个文件
            this.cbxUrlEncoding.Text = this._TaskUnit.TaskConfig.UrlListManager.UrlEncoding;                            //网址编码
            this.nudHistoryCount.Value = this._TaskUnit.TaskConfig.UrlListManager.HistoryUrlCapacity;                   //历史记录网址最大容量
            this.chbStartingUrlEncoded.Checked = this._TaskUnit.TaskConfig.UrlListManager.StartingUrlEncoded;           //起始地址已编码
            this.lblUrlAddressCount.Text = "地址总数 " + this._TaskUnit.TaskConfig.UrlListManager.StartingUrlList.Count.ToString(); //地址总数
            //未设置(使用插件对采集结果进行筛选,将在软件内置筛选之后进行)
            #endregion

            #region 定时采集(任务调度)
            //调度模式
            this.chbScheduleEnabled.Checked = this._TaskUnit.TaskConfig.ScheduleEnabled;
            if (this._TaskUnit.TaskConfig.ScheduleMode == ScheduleMode.Time) {
                //每隔时间段
                rdoScheduleModeTime.Checked = true;
                rdoScheduleModeDay.Checked = false;

                this.nudScheduleDays.Value = this._TaskUnit.TaskConfig.ScheduleDays;    //天
                this.nudScheduleHours.Value = this._TaskUnit.TaskConfig.ScheduleHours;  //时
                this.nudScheduleMinutes.Value = this._TaskUnit.TaskConfig.ScheduleMinutes;  //分
            } else {
                //(每当模式)
                rdoScheduleModeTime.Checked = false;
                rdoScheduleModeDay.Checked = true;

                //每当时间
                //this._TaskUnit.TaskConfig.ScheduleFromDayOfWeek; //每当星期几开始
                //this._TaskUnit.TaskConfig.ScheduleFromDay; //每当星期几开始
                //this._TaskUnit.TaskConfig.ScheduleFromHour; //每当X小时调度

                //预定时间
                //this._TaskUnit.TaskConfig.ScheduleFromDayOfWeek; //预定星期几结束
                //this._TaskUnit.TaskConfig.ScheduleToDay; //预定天
                //this._TaskUnit.TaskConfig.ScheduleToHour; //预定小时
            }
            #endregion

            #region 数据库类型
            switch (this._TaskUnit.TaskConfig.DatabaseType) {
                case DatabaseType.Access:
                    rdoDataTypeAccess.Checked = true;
                    break;
                case DatabaseType.MySql:
                    rdoDataTypeMySql.Checked = true;
                    break;
                case DatabaseType.Oracle:
                    rdoDataTypeOracle.Checked = true;
                    break;
                case DatabaseType.SqlLite:
                    rdoDataTypeSqlLite.Checked = true;
                    break;
                case DatabaseType.SqlServer:
                    rdoDataTypeSqlServer.Checked = true;
                    break;
            }
            #endregion

            #region 发布结果选项
            if (this._TaskUnit.TaskConfig.PublishResultDircetly) {
                this.rdoResultSaveDB.Checked = true;
                this.rdoResultSaveFile.Checked = false;
            } else {
                this.rdoResultSaveFile.Checked = true;
                this.rdoResultSaveDB.Checked = false;
            }
            #endregion

            #region 采集规则
            this.LivExtractionRule.Items.Clear();
            for (int i = 0; i < this._TaskUnit.TaskConfig.ExtractionRules.Count; i++) {
                Utility.ExtractionRulesItem item = new Utility.ExtractionRulesItem(this._TaskUnit.TaskConfig.ExtractionRules[i], i);
                LivExtractionRule.Items.Add(item);
            }
            #endregion

            #region 导航规则
            this.livNavigationRule.Items.Clear();
            for (int i = 0; i < this._TaskUnit.TaskConfig.UrlListManager.NavigationRules.Count; i++) {
                Utility.NavigationRuleItem item = new Utility.NavigationRuleItem(this._TaskUnit.TaskConfig.UrlListManager.NavigationRules[i], i);
                this.livNavigationRule.Items.Add(item);
            }
            #endregion

            #region 起始地址列表
            this.libStartingUrlList.Items.Clear();
            foreach (string url in this._TaskUnit.TaskConfig.UrlListManager.StartingUrlList) {
                this.libStartingUrlList.Items.Add(url);
            }
            foreach (PagedUrlPatterns p in this._TaskUnit.TaskConfig.UrlListManager.PagedUrlPattern) {
                this.libStartingUrlList.Items.Add(p.PagedUrlPattern);
            }
            #endregion
        }