Beispiel #1
0
        private void mnuDeleteAll_Click(object sender, EventArgs e)
        {
            switch (type)
            {
            case 1:
                if (MessageBox.Show("确认要删除全部记录吗?", " 系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    int rows = new SQL().Database("ConnString").Delete(EmailList._).ToExec();
                    EmailListHelper.ClearCacheAll();
                    BindData();
                }
                break;

            case 2:
                if (MessageBox.Show("确认要删除全部记录吗?", " 系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    int rows = new SQL().Database("ConnString").Delete(SmtpList._).ToExec();
                    SmtpListHelper.ClearCacheAll();
                    BindData();
                }
                break;

            case 3:
                if (MessageBox.Show("确认要删除全部记录吗?", " 系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    int rows = new SQL().Database("ConnString").Delete(IpHistory._).ToExec();
                    IpHistoryHelper.ClearCacheAll();
                    BindData();
                }
                break;
            }
        }
Beispiel #2
0
 /// <summary>
 /// 清理缓存
 /// </summary>
 private void clear()
 {
     SmtpListHelper.ClearCacheAll(); smtpList         = null;
     EmailListHelper.ClearCacheAll(); emailList       = null;
     SendSettingHelper.ClearCacheAll(); sendSetting   = null;
     HtmlTemplateHelper.ClearCacheAll(); templateList = null;
     IpHistoryHelper.ClearCacheAll();
 }
Beispiel #3
0
        private void mnuSearch_Click(object sender, EventArgs e)
        {
            switch (type)
            {
            case 1:
                EmailListHelper.ClearCacheAll();
                break;

            case 2:
                SmtpListHelper.ClearCacheAll();
                break;

            case 3:
                IpHistoryHelper.ClearCacheAll();
                break;
            }
            BindData();
        }
Beispiel #4
0
        private void mnuDisable_Click(object sender, EventArgs e)
        {
            switch (type)
            {
            case 1:
                EmailListHelper.ClearCacheAll();
                break;

            case 2:
                SmtpListHelper.ClearCacheAll();
                foreach (ListViewItem item in listView1.Items)
                {
                    if (item.Checked)
                    {
                        string[] list = item.Tag.ToString().Split(',');

                        SmtpList info = new SmtpList();
                        info.SmtpServer = list[0].ToString();
                        info.SmtpPort   = list[1].ToString().ToInt(25);
                        info.UserName   = list[2].ToString();
                        info.SPassword  = list[3].ToString();
                        info.Status     = 1;
                        SmtpListHelper.Update(info);
                        //if (!info.SmtpServer.IsNullEmpty() || SmtpListHelper.IsExistByID(info.SmtpServer, info.SmtpPort.Value, info.UserName)) {
                        //    SmtpListHelper.Update(info);
                        //}
                    }
                }
                break;

            case 3:
                IpHistoryHelper.ClearCacheAll();
                break;
            }
            BindData();
        }
Beispiel #5
0
        /// <summary>
        /// 更换IP
        /// </summary>
        /// <param name="netType">0表示路由 1表示拨号连接</param>
        /// <param name="msg">通知输出消息</param>
        /// <param name="done">完成时执行</param>
        /// <param name="index">第几次执行</param>
        /// <returns></returns>
        public static string ChangeIP(int netType, Action <string> msg = null, Pub.Class.Action done = null, int index = 0)
        {
            string name = GetNetName(netType);

            setting = SendSettingHelper.SelectByID(1);

            if (setting.IsNull())
            {
                if (!msg.IsNull())
                {
                    msg("请修改发送设置!");
                }
                if (!done.IsNull())
                {
                    done();
                }
                return("");
            }
            else
            {
                if (index == setting.MaxRetryCount)
                {
                    if (!done.IsNull())
                    {
                        done();
                    }
                    return("");
                }
                if (!msg.IsNull())
                {
                    msg((index + 1).ToString());
                }

                //清空多少分钟前的历史IP
                if (Data.Pool("ConnString").DBType == "SqlServer")
                {
                    "delete from IpHistory where CreateTime < DateAdd(MINUTE , -{0}, getdate())".FormatWith(setting.DeleteInterval).ToSQL().ToExec();
                }
                else if (Data.Pool("ConnString").DBType == "SQLite" || Data.Pool("ConnString").DBType == "MonoSQLite")
                {
                    "delete from IpHistory where datetime(CreateTime) < datetime('now','localtime', '-{0} minute')".FormatWith(setting.DeleteInterval).ToSQL().ToExec();
                }
                if (!msg.IsNull())
                {
                    msg("正在重启" + name + "......");
                }
                IController connect;
                switch (netType)
                {
                case 1: connect = new ModelController(); break;

                case 2: connect = new TianYiController(); break;

                default: connect = new RouteController(); break;
                }
                string error = connect.Reset();
                if (!error.IsNullEmpty())
                {
                    if (!msg.IsNull())
                    {
                        msg("重启" + name + "失败:" + error);
                    }
                    return(ChangeIP(netType, msg, done, index + 1));
                }
                else
                {
                    if (!msg.IsNull())
                    {
                        msg("已重启" + name + ",正在检测是否联网......");
                    }
                    bool isTrue = NetHelper.CheckNetwork(msg);
                    if (!isTrue)
                    {
                        return(ChangeIP(netType, msg, done, index + 1));
                    }

                    if (!msg.IsNull())
                    {
                        msg("已联接网络,正在获取IP......");
                    }
                    string ip = IPHelper.GetIpFast();

                    if (!msg.IsNull())
                    {
                        msg("获取到IP:" + ip);
                    }
                    if (IpHistoryHelper.IsExistByID(ip))
                    {
                        if (!msg.IsNull())
                        {
                            msg("检测到IP:" + ip + "最近已使用!");
                        }
                        return(ChangeIP(netType, msg, done, index + 1));
                    }
                    else
                    {
                        IpHistoryHelper.Insert(new IpHistory()
                        {
                            IP = ip, CreateTime = DateTime.Now.ToDateTime().ToDateTime()
                        });
                    };
                    return(ip);
                }
            }
        }
Beispiel #6
0
        private void BindData()
        {
            long   totals    = 0;
            string strStatus = this.toolStripComboBox1.Text.Trim();

            ThreadPool.QueueUserWorkItem(new WaitCallback((o) => {
                switch (type)
                {
                case 1:
                    Where where = null;
                    switch (strStatus)
                    {
                    case "等待发送":
                        where = new Where().And("LastSendStatus", 0, Operator.Equal);
                        break;

                    case "发送成功":
                        where = new Where().And("LastSendStatus", 1, Operator.Equal);
                        break;

                    case "发送失败":
                        where = new Where().And("LastSendStatus", 2, Operator.Equal);
                        break;

                    default:
                        where = null;
                        break;
                    }
                    IList <EmailList> emailList = EmailListHelper.SelectPageList(page, pageSize, out totals, "", where);

                    pages = (int)(totals / pageSize + (totals % pageSize == 0 ? 0 : 1));

                    EmailListobj obj1 = new EmailListobj();
                    obj1.list         = emailList;
                    obj1.page         = page;
                    obj1.pages        = pages;
                    obj1.totals       = totals;

                    this.Invoke(new CallFormInThread(loadData), obj1);

                    break;

                case 2:
                    IList <SmtpList> smtpList = SmtpListHelper.SelectPageList(page, pageSize, out totals);
                    pages = (int)(totals / pageSize + (totals % pageSize == 0 ? 0 : 1));

                    SmtpListobj obj2 = new SmtpListobj();
                    obj2.list        = smtpList;
                    obj2.page        = page;
                    obj2.pages       = pages;
                    obj2.totals      = totals;

                    this.Invoke(new CallFormInThread(loadData), obj2);

                    break;

                case 3:
                    IList <IpHistory> ipList = IpHistoryHelper.SelectPageList(page, pageSize, out totals);

                    pages             = (int)(totals / pageSize + (totals % pageSize == 0 ? 0 : 1));
                    IpHistoryobj obj3 = new IpHistoryobj();
                    obj3.list         = ipList;
                    obj3.page         = page;
                    obj3.pages        = pages;
                    obj3.totals       = totals;

                    this.Invoke(new CallFormInThread(loadData), obj3);
                    break;
                }
            }), null);
        }