private void GetList() { var(list, total) = EA_Repository.GetList(this.tbAddress.Text, this.tbGroup.Text, this.ucPage.PageIndex, this.ucPage.PageSize); EmailList = list.ToList(); dgEmail.ItemsSource = list; this.ucPage.InitData(total); }
public bool Start(HostControl hostControl) { if (!IsStart) { IsStart = true; _Thread = new Thread((s) => { while (IsStart) { try { var list = Repository.GetList(); LogHelper.Debug(string.Format("MainServices : 获取到发件箱数量【{0}】", list.Count())); foreach (var ea in list) { SmartSendEmail task; if (EmailAccountDic.ContainsKey(ea.EmailAccountID)) { task = EmailAccountDic[ea.EmailAccountID]; //如果服务线程已经终止,则重新启动 if (!task.IsStart) { LogHelper.Info(string.Format("MainServices : 再次启动已经停止的发件箱【{0}:{1}】", ea.EmailAccountID, ea.EmailAccountAddress)); task.Run(ea); EmailAccountDic[ea.EmailAccountID] = task; } } else { LogHelper.Debug(string.Format("MainServices : 准备将发件箱【{0}:{1}】的占用IP改为【{2} -> {3}】", ea.EmailAccountID, ea.EmailAccountAddress, ea.OccupyIP, NetHelper.LANIP)); //2. 修改邮箱使用的服务器信息-增加占用信息和占用时间 ea.OccupyIP = NetHelper.LANIP; if (!Repository.UpdateEmailAccountOccupy(ea)) { LogHelper.Debug(string.Format("MainServices : 将发件箱【{0}:{1}】的占用IP改为【{2} -> {3}】失败", ea.EmailAccountID, ea.EmailAccountAddress, ea.OccupyIP, NetHelper.LANIP)); //占用失败,已经被其他服务器占用,跳过当前邮箱 continue; } LogHelper.Info(string.Format("MainServices : 将发件箱【{0}:{1}】的占用IP改为【{2} -> {3}】成功", ea.EmailAccountID, ea.EmailAccountAddress, ea.OccupyIP, NetHelper.LANIP)); task = new SmartSendEmail(); task.Run(ea); EmailAccountDic[ea.EmailAccountID] = task; } } } catch (Exception ex) { LogHelper.Error(string.Format("MainServices : Exception:{0}", ex.Message), ex); } finally { SleepInterval(Interval); } } }); _Thread.Start(); } return(true); }