private void _Click(string Name) { string text = this.Time.Text; if (!string.IsNullOrEmpty(text) && ConfigerHelper.SetAppSettingsConfig(new ConfigerParameterName().HistorySaveDays, text)) { OpenWindows.Prompt("设定成功"); base.Close(); } }
public static void DownLoad(string pdfpath, string pdfname, string typename, string title) { string configer = ConfigerHelper.GetConfiger(new ConfigerParameterName().Resource); pdfpath = string.Format(@"{0}\{1}", configer, pdfpath); switch (DownLoadUtils.DownloadPDF(pdfpath, pdfname, typename, title)) { case SystemEnum.DownloadType.ERROR: OpenWindows.Prompt(MESSAGE.DownLoadError); break; case SystemEnum.DownloadType.SUCCESS: OpenWindows.Prompt(MESSAGE.DownLoadSuccess); break; } }
private void TimerTick(object sender, EventArgs e) { try { double num = double.Parse(ConfigerHelper.GetAutoCloseTimer()); TimeSpan span = (TimeSpan)(DateTime.Now - this.time); if (span.TotalSeconds >= num) { this.timer.Stop(); this.timer.Tick -= new EventHandler(this.TimerTick); base.Close(); } } catch { } }
public bool BindFullImages() { try { this.wait.Visibility = Visibility.Visible; this.Up.Visibility = Visibility.Hidden; this.Down.Visibility = Visibility.Hidden; this.scrollviewer.ScrollToHome(); string str = this.IMGPath[this.page]; if (string.IsNullOrEmpty(str)) { return(true); } this.pdf.Source = new BitmapImage(new Uri(string.Format(@"{0}\{1}", ConfigerHelper.GetConfiger(new ConfigerParameterName().Resource), str))); } catch { this.wait.Content = "打开全文失败,请稍候重试。"; return(false); } return(true); }
private void _Loaded(object sender, RoutedEventArgs e) { char[] trimChars = new char[] { ';' }; char[] separator = new char[] { ';' }; string[] strArray = this.ImageList.TrimEnd(trimChars).Split(separator); if ((strArray != null) && (strArray.Length > 0)) { string configer = ConfigerHelper.GetConfiger(new ConfigerParameterName().Resource); int num = 0; foreach (string str2 in strArray) { if (!string.IsNullOrEmpty(str2)) { this.List.RowDefinitions.Add(new RowDefinition()); Image element = new Image { Source = new BitmapImage(new Uri(string.Format(@"{0}\{1}", configer, str2))) }; this.List.Children.Add(element); Grid.SetRow(element, num); num++; } } } }
protected void btnStop_Click(object sender, EventArgs e) { //设置配置文件为启动状态 ConfigerHelper.SetAppSetting("SendMessage", "false"); }
private void button3_Click(object sender, EventArgs e) { _fileTypeId = Convert.ToInt32(ConfigerHelper.GetAppConfig("FilePathId")); Download(); }
/// <summary> /// 提供文件类型与获取属性获取文件地址 /// file_type_id 获取的文件类型 0 顶层结构 1 目录结构 2 文件结构 /// </summary> /// <param name="fileTypeId">当前要获取的文件类型</param> public void GetService(int fileTypeId) { if (!Tool.validateHtml(HtmlModelTool.htmlModel.BasePath)) { MyMessageBox.Add("网站基址不是正确的格式"); return; } if (String.IsNullOrEmpty(HtmlModelTool.htmlModel.Match) || String.IsNullOrEmpty(HtmlModelTool.htmlModel.AttrName)) { MyMessageBox.Add("匹配字符不可为空"); Console.WriteLine("匹配字符不可为空"); return; } #region MyRegion //if(!ConnectionStatusTool.CheckServeStatus( _netPath).Equals("200")) //{ // Console.WriteLine("网络故障!地址不可访问!"); // return; //} // string netPath = "http://w1.vt97.biz/pw/thread.php?fid=16&page="; //获取目录地址 //string dirXpath = "//tr[@class='tr3 t_one']/td/h3/a"; // List<string> dirpathList = Tool.ReadPathByMySQL(1,2); #endregion GetHtml gt = new GetHtml(); //gt.Match = FileXpath; // gt.Html.Match = FileXpath; //List<string> currentPathList = new List<string>( ); //获取数据库中未操作和失败的 List <string> currentPathList = new List <string>(); if (fileTypeId.ToString().EndsWith("1")) { //获取目录地址 string MaxDirPath = ConfigerHelper.GetAppConfig("MaxDirPath"); int maxDirPath = Convert.ToInt32(MaxDirPath); currentPathList = Tool.ReadPathByLinq(fileTypeId - 1, 3) .Where(p => p.file_Path.StartsWith(HtmlModelTool.htmlModel.BasePath)) .Select(p => p.file_Path) .Take(maxDirPath) .ToList(); if (currentPathList.Count == 0) { string netpath = Tool.ConcatHttpPath(HtmlModelTool.htmlModel.BasePath, HtmlModelTool.htmlModel.ExtendPath); Tool.CreateRootDir(netpath); GetService(fileTypeId); } } else { //获取文件地址 currentPathList = Tool.ReadPathByLinq(fileTypeId - 1, 3).Select(p => p.file_Path).ToList(); } //-------------------------------------------------------- //List<filepath> currentPathListEntity = new List<filepath>(); //List<filepath> filterPathListEntity = Tool.ReadPathByLinq(fileTypeId - 1, 3); //-------------------------------------------------------- #region old 弃用 //不输入网址则取数据库中的网址 //if (string.IsNullOrEmpty(NetPath) || fileTypeId.ToString().EndsWith("2")) //{ // //读取目录地址,即当前访问的地址 // currentPathList = filterPathList; //} //else //{ // #region 创建根目录 // //创建根目录 // if (currentPathList.Count == 0) // if (String.IsNullOrEmpty(NetPath)) // { // MyMessageBox.Add("没有查询到可访问的目录!可能未填写地址?"); // Console.WriteLine("没有查询到可访问的目录!可能未填写地址?"); // return; // } // else // { // for (int i = 1; i < 20; i++) // { // string url = NetPath + i.ToString(); // if (!currentPathList.Contains(url) && !filterPathList.Contains(url)) // { // currentPathList.Add(url); // filepath filepath = new filepath() // { // file_Path = url, // file_innerTxt = "", // file_Type_id = fileTypeId - 1, // file_status_id = 0, // file_CreateTime = DateTime.Now, // file_parent_path = "0" // }; // Tool.InsertfilePathByLinq(filepath); // } // } // } // if (currentPathList.Count == 0) // { // if (filterPathList.Count == 0) // { // MyMessageBox.Add("没有查询到可访问的目录!"); // Console.WriteLine("没有查询到可访问的目录!"); // return; // } // currentPathList = filterPathList; // } // #endregion //} #endregion //获取数据库中已经有的文件地址,即过滤这些地址 List <string> targetPathList = Tool.ReadPathByLinq(fileTypeId, 4).Select(p => p.file_Path).ToList(); gt.dirPath = targetPathList; //-------------------------------------------------------- //List<filepath> targetPathListEntity = Tool.ReadPathByLinq(fileTypeId, 4); //gt.dirPathEntity = targetPathListEntity; //-------------------------------------------------------- #region 测试用 //foreach (string item in currentPathList) //{ // string url = string.Empty; // if (item.ToUpper( ).StartsWith("HTTP")) // { // url = item; // } // else // url = _basePath + item; // if (gt.run(_PropertyName, url, file_type_id)) // { // Tool.UpdatefilePath(url, file_type_id - 1, 1); // Console.WriteLine("线程 {0} 已经完成了文件 {1} 的获取!", Thread.CurrentThread.ManagedThreadId, url); // } // else // { // Tool.UpdatefilePath(url, file_type_id - 1, 2); // Console.WriteLine("线程 {0} 对 {1} 的获取失败了!", Thread.CurrentThread.ManagedThreadId, url); // } //} //Parallel.ForEach(currentPathListEntity, item => //{ // string url = string.Empty; // if (item.file_Path.ToUpper().StartsWith("HTTP")) // { // url = item.file_Path; // } // else // url = BasePath + item; // if (gt.run(PropertyName, url, fileTypeId)) // { // Tool.UpdatefilePath(item, fileTypeId - 1, 1); // Console.WriteLine("线程 {0} 已经完成了文件 {1} 的获取!", Thread.CurrentThread.ManagedThreadId, url); // } // else // { // Tool.UpdatefilePath(item, fileTypeId - 1, 2); // Console.WriteLine("线程 {0} 对 {1} 的获取失败了!", Thread.CurrentThread.ManagedThreadId, url); // } //}); #endregion Parallel.ForEach(currentPathList, item => { string url = string.Empty; if (item.ToUpper().StartsWith("HTTP")) { url = item; } else { url = Tool.ConcatHttpPath(HtmlModelTool.htmlModel.BasePath, item); } // url =String.Concat( HtmlModelTool.htmlModel.BasePath,'/' , item); // Console.WriteLine("线程 {0} 已经完成了文件 {1} 的获取!", Thread.CurrentThread.ManagedThreadId, url); gt = new GetHtml() { // Match = FileXpath, dirPath = targetPathList }; //gt.Html.Match = FileXpath; if (gt.run(HtmlModelTool.htmlModel.AttrName, url, fileTypeId)) { lock (locker) Tool.UpdatefilePath(item, fileTypeId - 1, 1); MyMessageBox.Add($"线程 {Thread.CurrentThread.ManagedThreadId} 已经完成了文件 {url} 的获取!"); Console.WriteLine("线程 {0} 已经完成了文件 {1} 的获取!", Thread.CurrentThread.ManagedThreadId, url); } else { lock (locker) Tool.UpdatefilePath(item, fileTypeId - 1, 2); // ReSharper disable once UseStringInterpolation MyMessageBox.Add(string.Format("线程 {0} 对 {1} 的获取失败了!", Thread.CurrentThread.ManagedThreadId, url)); Console.WriteLine("线程 {0} 对 {1} 的获取失败了!", Thread.CurrentThread.ManagedThreadId, url); } }); }