private void btnLogin_Click(object sender, RoutedEventArgs e) { Control.Loading load = new Control.Loading(() => { System.Threading.Thread.Sleep(500); }); load.Msg = "稍等。。。"; load.Owner = this; load.Start(); load.ShowDialog(); Error rt = new Error(); rt = LoginBLL.Instance.ssp_login(txtuid.Text, txtpwd.Password); if (rt.ErrCode != 0) { Helper.Instance.AlertWarning(rt.ErrText); } else { ProU.Instance.PspUser = LoginBLL.Instance.GetUser(txtuid.Text, txtpwd.Password); PM.isAutoLogin = (bool)chkisAutoLogin.IsChecked; PM.isSavePass = (bool)chkisSavePass.IsChecked; PM.UserCode = txtuid.Text; PM.UserPass = txtpwd.Password; ConfigHelper config = new ConfigHelper(PM.Config); config.SetValue("isSavePass", PM.isSavePass == true ? "1" : "0"); config.SetValue("isAutoLogin", PM.isAutoLogin == true ? "1" : "0"); config.SetValue("UserCode", PM.UserCode); if (PM.isSavePass) { config.SetValue("UserPass", Encrypt.Instance.EncryptString(PM.UserPass)); } config.Save(); this.DialogResult = true; } }
public NewsList() { InitializeComponent(); Control.Loading load = new Control.Loading(Service.Task.Instance.SpiderNewsToHtml); load.Msg = "正在加载。。。"; load.Start(); load.ShowDialog(); LoadNewsList(); }
private void btnQuery_Click(object sender, RoutedEventArgs e) { if (this.txtQueryTitle.Text.Trim().Length == 0 && this.cboQueryType.SelectedValue == null) { MessageBox.Show("查询条件不能为空!"); return; } uPager.PageIndex = 1; Control.Loading load = new Control.Loading(BindList); load.Msg = "稍等。。。"; load.Start(); load.ShowDialog(); }
/// <summary> /// 下载图片 /// </summary> /// <param name="url"></param> private void ImageDown(string url) { if (String.IsNullOrEmpty(url)) { this.StatusInfo = "网址不能为空!"; } string html = String.Empty;// System.Collections.Generic.List <string> list = null; string savePath = Model.PM.StartPath + "\\Down\\Img\\"; #region 进度 Control.Loading load = new Control.Loading(() => { try { html = Utility.HtmlHelper.Instance.GetHtml(url); html = Utility.HtmlHelper.Instance.GetBody(html); Utility.HtmlHelper.Instance.FixUrl(url, html); list = Utility.HtmlHelper.Instance.GetImgLinks(html); } catch (Exception ex) { Utility.Log.SaveLog("ViewModel PageIamgeDownViewModel ImageDown url[" + url + "]", ex.ToString()); return; } }); load.Msg = "正在加载。。。"; load.Start(); load.ShowDialog(); #endregion Helper.Instance.DeleteFolder(savePath); Helper.Instance.CreateFolder(savePath); int yesNum = 0; int noNum = 0; if (list != null && list.Count > 0) { Utility.DownFile downFile = new Utility.DownFile(); System.Threading.Tasks.Task.Factory.StartNew(() => { string suffix = String.Empty; for (int i = 0; i < list.Count; i++) { if (!list[i].Contains(".")) { continue; } suffix = list[i].Substring(list[i].LastIndexOf(".")); if (downFile.DownloadFileByWebClient(list[i], savePath + Guid.NewGuid().ToString() + suffix)) { yesNum++; this.StatusInfo = "共有图片链接" + list.Count + "个,下载成功" + yesNum + ",失败" + noNum + ""; continue; } noNum++; } System.Diagnostics.Process.Start("explorer.exe", savePath); }); this.StatusInfo = "共有图片链接" + list.Count + "个,下载成功" + yesNum + ",失败" + noNum + ""; } else { this.StatusInfo = "没有发现图片链接的存在!"; } }