Beispiel #1
0
 /// <summary>
 /// ��ȡIP����ɾ����¼
 /// </summary>
 /// <param name="iPCID">��ȡIP���ñ��</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">ɾ���ɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>ɾ���Ƿ�ɹ�</returns>
 public static bool DeleteByID(Int64? iPCID,  string dbkey = "", Where where = null, string[] delCache = null)
 {
     if (iPCID.IsNull()) return false;
     int value = new SQL().Database(dbkey).Delete(IpSetting._)
         .Where(new Where()
             .AndP(IpSetting._IPCID, iPCID, Operator.Equal, true)
         ).Where(where).ToExec();
     if (value != 1) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.IpSettingCache_", delCache);
     return true;
 }
 /// <summary>
 /// �����޸Ķ�����¼
 /// </summary>
 /// <param name="settingIDList">���ñ���б���á�,���ŷָ�</param>
 /// <param name="sendSetting">����ʵ����</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">�޸ijɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool UpdateByIDList(IEnumerable<int> settingIDList,  SendSetting sendSetting, string dbkey = "", Where where = null, string[] delCache = null)
 {
     int value = new SQL().Database(dbkey).Update(SendSetting._)
         .SetP(SendSetting._TemplateID, sendSetting.TemplateID)
         .SetP(SendSetting._ConnectType, sendSetting.ConnectType)
         .SetP(SendSetting._SendInterval, sendSetting.SendInterval)
         .SetP(SendSetting._IPInterval, sendSetting.IPInterval)
         .SetP(SendSetting._SmtpInterval, sendSetting.SmtpInterval)
         .SetP(SendSetting._DeleteInterval, sendSetting.DeleteInterval)
         .SetP(SendSetting._MaxRetryCount, sendSetting.MaxRetryCount)
         .SetP(SendSetting._SendRetryCount, sendSetting.SendRetryCount)
         .SetP(SendSetting._Status, sendSetting.Status)
         .Where(new Where()
             .And(SendSetting._SettingID, "(" + settingIDList .Join(",") + ")", Operator.In)
         ).Where(where).ToExec();
     if (value <= 0) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.SendSettingCache_", delCache);
     return true;
 }
Beispiel #3
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);
        }
 /// <summary>
 /// �������������޸Ķ�����¼
 /// </summary>
 /// <param name="tianYiIDList">�����������ñ���б���á�,���ŷָ�</param>
 /// <param name="tianYiSetting">������������ʵ����</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">�޸ijɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool UpdateByIDList(IEnumerable<int> tianYiIDList,  TianYiSetting tianYiSetting, string dbkey = "", Where where = null, string[] delCache = null)
 {
     int value = new SQL().Database(dbkey).Update(TianYiSetting._)
         .SetP(TianYiSetting._TianYiExePath, tianYiSetting.TianYiExePath)
         .Where(new Where()
             .And(TianYiSetting._TianYiID, "(" + tianYiIDList .Join(",") + ")", Operator.In)
         ).Where(where).ToExec();
     if (value <= 0) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.TianYiSettingCache_", delCache);
     return true;
 }
        /// <summary>
        /// �����������ò�ѯ���ݣ�����ҳ
        /// </summary>
        /// <param name="pageIndex">��ǰ�ڼ�ҳ����1��ʼ</param>
        /// <param name="pageSize">ÿҳ��¼��</param>
        /// <param name="totalRecords">�����ܼ�¼��</param>
        /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
        /// <param name="order">�����ֶΣ����ӡ�order by��</param>
        /// <param name="fieldList">������Ҫ���ص��ֶ�</param>
        /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
        /// <param name="pageEnum">ʹ�����ַ�ҳ��ʽ��not_in��max_top��top_top��row_number��mysql��oracle��sqlite��</param>
        /// <returns>����ʵ���¼��</returns>
        public static IList<TianYiSetting> SelectPageList(int pageIndex, int pageSize, out long totalRecords, string dbkey = "", Where where = null, string order = "", string fieldList = "", PagerSQLEnum pageEnum = PagerSQLEnum.sqlite)
        {
            string cacheNameKey = "TH.Mailer.TianYiSettingCache_SelectPageList_{0}_{1}_{2}_{3}_{4}".FormatWith(pageIndex, pageSize, where, order, fieldList);
            string cacheRecordsKey = "TH.Mailer.TianYiSettingCache_RecordsSelectPageList_{0}_{1}_{2}_{3}_{4}".FormatWith(pageIndex, pageSize, where, order, fieldList);
            IList<TianYiSetting> list = (IList<TianYiSetting>)Cache2.Get(cacheNameKey);
            if (!list.IsNull()) { totalRecords = (int)Cache2.Get(cacheRecordsKey); return list; }

            using (PagerSQLHelper s = new PagerSQLHelper(pageEnum)) {
                list = s.GetSQL(pageIndex, pageSize, TianYiSetting._, TianYiSetting._TianYiID, fieldList.IfNullOrEmpty("[TianYiID],[TianYiExePath],"), where, "", order).ToList<TianYiSetting>(out totalRecords, dbkey);
            }
            Cache2.Insert(cacheNameKey, list, cacheSeconds);
            Cache2.Insert(cacheRecordsKey, totalRecords, cacheSeconds);
            return list;
        }
 /// <summary>
 /// ������������ɾ����¼
 /// </summary>
 /// <param name="tianYiID">�����������ñ��</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">ɾ���ɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>ɾ���Ƿ�ɹ�</returns>
 public static bool DeleteByID(int tianYiID,  string dbkey = "", Where where = null, string[] delCache = null)
 {
     return DeleteByID((int?)tianYiID,  dbkey, where, delCache);
 }
Beispiel #7
0
 /// <summary>
 /// ɾ����¼
 /// </summary>
 /// <param name="emailAddress">���͵�Email</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">ɾ���ɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>ɾ���Ƿ�ɹ�</returns>
 public static bool DeleteByID(string emailAddress,  string dbkey = "", Where where = null, string[] delCache = null)
 {
     if (emailAddress.IsNullEmpty()) return false;
     int value = new SQL().Database(dbkey).Delete(EmailList._)
         .Where(new Where()
             .AndP(EmailList._EmailAddress, emailAddress, Operator.Equal, true)
         ).Where(where).ToExec();
     if (value != 1) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.EmailListCache_", delCache);
     return true;
 }
Beispiel #8
0
 /// <summary>
 /// �޸Ķ�����¼
 /// </summary>
 /// <param name="emailAddressList">���͵�Email�б���á�,���ŷָ�</param>
 /// <param name="emailList">ʵ����</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">�޸ijɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool UpdateByIDList(IEnumerable<string> emailAddressList,  EmailList emailList, string dbkey = "", Where where = null, string[] delCache = null)
 {
     int value = new SQL().Database(dbkey).Update(EmailList._)
         .SetP(EmailList._NickName, emailList.NickName)
         .SetP(EmailList._LastSendStatus, emailList.LastSendStatus)
         .SetP(EmailList._LastSendError, emailList.LastSendError)
         .SetP(EmailList._LastSendTime, emailList.LastSendTime)
         .SetP(EmailList._LastSendSmtp, emailList.LastSendSmtp)
         .SetP(EmailList._SendCount, emailList.SendCount)
         .SetP(EmailList._CreateTime, emailList.CreateTime)
         .SetP(EmailList._ex0, emailList.ex0)
         .SetP(EmailList._ex1, emailList.ex1)
         .SetP(EmailList._ex2, emailList.ex2)
         .SetP(EmailList._ex3, emailList.ex3)
         .SetP(EmailList._ex4, emailList.ex4)
         .SetP(EmailList._ex5, emailList.ex5)
         .SetP(EmailList._ex6, emailList.ex6)
         .SetP(EmailList._ex7, emailList.ex7)
         .SetP(EmailList._ex8, emailList.ex8)
         .Where(new Where()
             .And(EmailList._EmailAddress, "(" + emailAddressList .Join(",") + ")", Operator.In)
         ).Where(where).ToExec();
     if (value <= 0) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.EmailListCache_", delCache);
     return true;
 }
Beispiel #9
0
 /// <summary>
 /// ��������ѯ���������ݵ�ʵ����
 /// </summary>
 /// <param name="smtpServer">SMTP������</param>
 /// <param name="smtpPort">SMTP�˿�</param>
 /// <param name="userName">��¼�û���</param>
 /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
 /// <returns>���ص�����¼��ʵ����</returns>
 public static SmtpList SelectByID(string smtpServer, int smtpPort, string userName,  string dbkey = "", Where where = null)
 {
     string cacheNameKey = "TH.Mailer.SmtpListCache_SelectByID_{0}".FormatWith(smtpServer + "_" + smtpPort + "_" + userName + "_" +  "_" + where);
     return Cache2.Get<SmtpList>(cacheNameKey, cacheSeconds, () => {
         SmtpList obj = new SQL().Database(dbkey).From(SmtpList._)
             .Select(SmtpList._SmtpServer)
             .Select(SmtpList._SmtpPort)
             .Select(SmtpList._UserName)
             .Select(SmtpList._SPassword)
             .Select(SmtpList._SSL)
             .Select(SmtpList._Status)
             .Select(SmtpList._Sends)
             .Select(SmtpList._SendFails)
             .Select(SmtpList._CreateTime)
             .Where(new Where()
                 .AndP(SmtpList._SmtpServer, smtpServer, Operator.Equal)
                 .AndP(SmtpList._SmtpPort, smtpPort, Operator.Equal)
                 .AndP(SmtpList._UserName, userName, Operator.Equal)
             ).Where(where).ToEntity<SmtpList>();
         return obj;
     });
 }
Beispiel #10
0
 /// <summary>
 /// ��¼�Ƿ����
 /// </summary>
 /// <param name="smtpServer">SMTP������</param>
 /// <param name="smtpPort">SMTP�˿�</param>
 /// <param name="userName">��¼�û���</param>
 /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>��¼�Ƿ����</returns>
 public static bool IsExistByID(string smtpServer, int smtpPort, string userName,  string dbkey = "", Where where = null)
 {
     long value = new SQL().Database(dbkey).Count(SmtpList._SmtpServer).From(SmtpList._)
         .Where(new Where()
             .AndP(SmtpList._SmtpServer, smtpServer, Operator.Equal)
             .AndP(SmtpList._SmtpPort, smtpPort, Operator.Equal)
             .AndP(SmtpList._UserName, userName, Operator.Equal)
         ).Where(where).ToScalar().ToString().ToBigInt();
     return value == 1;
 }
Beispiel #11
0
 /// <summary>
 /// ɾ����¼
 /// </summary>
 /// <param name="smtpServer">SMTP������</param>
 /// <param name="smtpPort">SMTP�˿�</param>
 /// <param name="userName">��¼�û���</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">ɾ���ɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>ɾ���Ƿ�ɹ�</returns>
 public static bool DeleteByID(string smtpServer, int smtpPort, string userName,  string dbkey = "", Where where = null, string[] delCache = null)
 {
     return DeleteByID((string)smtpServer, (int?)smtpPort, (string)userName,  dbkey, where, delCache);
 }
Beispiel #12
0
 /// <summary>
 /// ɾ����¼
 /// </summary>
 /// <param name="smtpServer">SMTP������</param>
 /// <param name="smtpPort">SMTP�˿�</param>
 /// <param name="userName">��¼�û���</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">ɾ���ɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>ɾ���Ƿ�ɹ�</returns>
 public static bool DeleteByID(string smtpServer, int? smtpPort, string userName,  string dbkey = "", Where where = null, string[] delCache = null)
 {
     if (smtpServer.IsNullEmpty()  && smtpPort.IsNull()  && userName.IsNullEmpty()) return false;
     int value = new SQL().Database(dbkey).Delete(SmtpList._)
         .Where(new Where()
             .AndP(SmtpList._SmtpServer, smtpServer, Operator.Equal, true)
             .AndP(SmtpList._SmtpPort, smtpPort, Operator.Equal, true)
             .AndP(SmtpList._UserName, userName, Operator.Equal, true)
         ).Where(where).ToExec();
     if (value != 1) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.SmtpListCache_", delCache);
     return true;
 }
Beispiel #13
0
 /// <summary>
 /// ��ȡIP�����޸Ķ�����¼
 /// </summary>
 /// <param name="iPCIDList">��ȡIP���ñ���б���á�,���ŷָ�</param>
 /// <param name="ipSetting">��ȡIP����ʵ����</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">�޸ijɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool UpdateByIDList(IEnumerable<Int64> iPCIDList,  IpSetting ipSetting, string dbkey = "", Where where = null, string[] delCache = null)
 {
     int value = new SQL().Database(dbkey).Update(IpSetting._)
         .SetP(IpSetting._WebName, ipSetting.WebName)
         .SetP(IpSetting._IPUrl, ipSetting.IPUrl)
         .SetP(IpSetting._IPRegex, ipSetting.IPRegex)
         .SetP(IpSetting._DataEncode, ipSetting.DataEncode)
         .Where(new Where()
             .And(IpSetting._IPCID, "(" + iPCIDList .Join(",") + ")", Operator.In)
         ).Where(where).ToExec();
     if (value <= 0) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.IpSettingCache_", delCache);
     return true;
 }
Beispiel #14
0
 /// <summary>
 /// ��ȡIP�����޸ļ�¼
 /// </summary>
 /// <param name="ipSetting">��ȡIP����ʵ����</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">�޸ijɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool Update(IpSetting ipSetting, string dbkey = "", Where where = null, string[] delCache = null)
 {
     if (ipSetting.IPCID.IsNull()) return false;
     int value = new SQL().Database(dbkey).Update(IpSetting._)
         .SetP(IpSetting._WebName, ipSetting.WebName)
         .SetP(IpSetting._IPUrl, ipSetting.IPUrl)
         .SetP(IpSetting._IPRegex, ipSetting.IPRegex)
         .SetP(IpSetting._DataEncode, ipSetting.DataEncode)
         .Where(new Where()
             .AndP(IpSetting._IPCID, ipSetting.IPCID, Operator.Equal, true)
         ).Where(where).ToExec();
     if (value <= 0) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.IpSettingCache_", delCache);
     return true;
 }
Beispiel #15
0
 /// <summary>
 /// ��ѯ���м�¼
 /// </summary>
 /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="order">�����ֶΣ����ӡ�order by��</param>
 /// <param name="fieldList">������Ҫ���ص��ֶ�</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
 /// <returns>����ʵ���¼��</returns>
 public static IList<SmtpList> SelectListByAll(string dbkey = "", Where where = null, string order = "", string fieldList = "")
 {
     string cacheNameKey = "TH.Mailer.SmtpListCache_SelectListByAll_{0}_{1}_{2}".FormatWith(where, order, fieldList);
     return Cache2.Get<IList<SmtpList>>(cacheNameKey, cacheSeconds, () => {
         IList<SmtpList> list = new List<SmtpList>();
         if (fieldList.IsNullEmpty()) {
             list = new SQL().Database(dbkey).From(SmtpList._)
                 .Select(SmtpList._SmtpServer)
                 .Select(SmtpList._SmtpPort)
                 .Select(SmtpList._UserName)
                 .Select(SmtpList._SPassword)
                 .Select(SmtpList._SSL)
                 .Select(SmtpList._Status)
                 .Select(SmtpList._Sends)
                 .Select(SmtpList._SendFails)
                 .Select(SmtpList._CreateTime)
                 .Where(where).Order(order).ToList<SmtpList>();
         } else {
             list = new SQL().Database(dbkey).From(SmtpList._).Select(fieldList).Where(where).Order(order).ToList<SmtpList>();
         }
         return list;
     });
 }
Beispiel #16
0
        /// <summary>
        /// ��ѯ���ݣ�����ҳ
        /// </summary>
        /// <param name="pageIndex">��ǰ�ڼ�ҳ����1��ʼ</param>
        /// <param name="pageSize">ÿҳ��¼��</param>
        /// <param name="totalRecords">�����ܼ�¼��</param>
        /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
        /// <param name="order">�����ֶΣ����ӡ�order by��</param>
        /// <param name="fieldList">������Ҫ���ص��ֶ�</param>
        /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
        /// <param name="pageEnum">ʹ�����ַ�ҳ��ʽ��not_in��max_top��top_top��row_number��mysql��oracle��sqlite��</param>
        /// <returns>����ʵ���¼��</returns>
        public static IList<EmailList> SelectPageList(int pageIndex, int pageSize, out long totalRecords, string dbkey = "", Where where = null, string order = "", string fieldList = "", PagerSQLEnum pageEnum = PagerSQLEnum.sqlite)
        {
            string cacheNameKey = "TH.Mailer.EmailListCache_SelectPageList_{0}_{1}_{2}_{3}_{4}".FormatWith(pageIndex, pageSize, where, order, fieldList);
            string cacheRecordsKey = "TH.Mailer.EmailListCache_RecordsSelectPageList_{0}_{1}_{2}_{3}_{4}".FormatWith(pageIndex, pageSize, where, order, fieldList);
            IList<EmailList> list = (IList<EmailList>)Cache2.Get(cacheNameKey);
            if (!list.IsNull()) { totalRecords = (int)Cache2.Get(cacheRecordsKey); return list; }

            using (PagerSQLHelper s = new PagerSQLHelper(pageEnum)) {
                list = s.GetSQL(pageIndex, pageSize, EmailList._, EmailList._EmailAddress, fieldList.IfNullOrEmpty("[EmailAddress],[NickName],[LastSendStatus],[LastSendError],[LastSendTime],[LastSendSmtp],[SendCount],[CreateTime],[ex0],[ex1],[ex2],[ex3],[ex4],[ex5],[ex6],[ex7],[ex8],"), where, "", order).ToList<EmailList>(out totalRecords, dbkey);
            }
            Cache2.Insert(cacheNameKey, list, cacheSeconds);
            Cache2.Insert(cacheRecordsKey, totalRecords, cacheSeconds);
            return list;
        }
Beispiel #17
0
        /// <summary>
        /// ��ѯ���ݣ�����ҳ
        /// </summary>
        /// <param name="pageIndex">��ǰ�ڼ�ҳ����1��ʼ</param>
        /// <param name="pageSize">ÿҳ��¼��</param>
        /// <param name="totalRecords">�����ܼ�¼��</param>
        /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
        /// <param name="order">�����ֶΣ����ӡ�order by��</param>
        /// <param name="fieldList">������Ҫ���ص��ֶ�</param>
        /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
        /// <param name="pageEnum">ʹ�����ַ�ҳ��ʽ��not_in��max_top��top_top��row_number��mysql��oracle��sqlite��</param>
        /// <returns>����ʵ���¼��</returns>
        public static IList<SmtpList> SelectPageList(int pageIndex, int pageSize, out long totalRecords, string dbkey = "", Where where = null, string order = "", string fieldList = "", PagerSQLEnum pageEnum = PagerSQLEnum.sqlite)
        {
            string cacheNameKey = "TH.Mailer.SmtpListCache_SelectPageList_{0}_{1}_{2}_{3}_{4}".FormatWith(pageIndex, pageSize, where, order, fieldList);
            string cacheRecordsKey = "TH.Mailer.SmtpListCache_RecordsSelectPageList_{0}_{1}_{2}_{3}_{4}".FormatWith(pageIndex, pageSize, where, order, fieldList);
            IList<SmtpList> list = (IList<SmtpList>)Cache2.Get(cacheNameKey);
            if (!list.IsNull()) { totalRecords = (int)Cache2.Get(cacheRecordsKey); return list; }

            using (PagerSQLHelper s = new PagerSQLHelper(pageEnum)) {
                list = s.GetSQL(pageIndex, pageSize, SmtpList._, SmtpList._SmtpServer, fieldList.IfNullOrEmpty("[SmtpServer],[SmtpPort],[UserName],[SPassword],[SSL],[Status],[Sends],[SendFails],[CreateTime],"), where, "", order).ToList<SmtpList>(out totalRecords, dbkey);
            }
            Cache2.Insert(cacheNameKey, list, cacheSeconds);
            Cache2.Insert(cacheRecordsKey, totalRecords, cacheSeconds);
            return list;
        }
Beispiel #18
0
 /// <summary>
 /// �����������ѯ�Ļ���
 /// </summary>
 public static void ClearCacheSelectByID(string emailAddress,  Where where = null)
 {
     string cacheName = "TH.Mailer.EmailListCache_SelectByID_{0}";
     string cacheNameKey = string.Format(cacheName, emailAddress + "_" +  "_" + where);
     Cache2.Remove(cacheNameKey);
 }
Beispiel #19
0
 /// <summary>
 /// �޸ļ�¼
 /// </summary>
 /// <param name="smtpList">ʵ����</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">�޸ijɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool Update(SmtpList smtpList, string dbkey = "", Where where = null, string[] delCache = null)
 {
     if (smtpList.SmtpServer.IsNullEmpty()  && smtpList.SmtpPort.IsNull()  && smtpList.UserName.IsNullEmpty()) return false;
     int value = new SQL().Database(dbkey).Update(SmtpList._)
         .SetP(SmtpList._SPassword, smtpList.SPassword)
         .SetP(SmtpList._SSL, smtpList.SSL)
         .SetP(SmtpList._Status, smtpList.Status)
         .SetP(SmtpList._Sends, smtpList.Sends)
         .SetP(SmtpList._SendFails, smtpList.SendFails)
         .SetP(SmtpList._CreateTime, smtpList.CreateTime)
         .Where(new Where()
             .AndP(SmtpList._SmtpServer, smtpList.SmtpServer, Operator.Equal, true)
             .AndP(SmtpList._SmtpPort, smtpList.SmtpPort, Operator.Equal, true)
             .AndP(SmtpList._UserName, smtpList.UserName, Operator.Equal, true)
         ).Where(where).ToExec();
     if (value <= 0) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.SmtpListCache_", delCache);
     return true;
 }
Beispiel #20
0
        private int SendEmails(int sends = 0)
        {
            int sendIndex = 0; //当前发送的邮件索引
            int ips = 0; //记录发送多少邮件后更换IP
            int smtps = 0; int smtps2 = 0; int smtpIndex = 0; //记录发送多少邮件后更换SMTP、smtp发送失败次数、当前使用的smtp索引

            EmailListHelper.ClearCacheAll();
            Where where = new Where().And("LastSendStatus", 0, Operator.Equal);
            emailList = EmailListHelper.SelectListByAll(null, where).Where(e => e.LastSendError.IndexOf("Mailbox not found") == -1).ToList();
            if (emailList.Count == 0) return 0; //0正常发送结束

            //循环发送所有email
            foreach (EmailList e in emailList) {
                sendIndex++;
                if (exit) { clear(); WriteLog("已停止发送邮件!"); thread.Abort(); return -1; } //-1停止发送邮件

                string name = smtpInfo.UserName;
                if (name.IndexOf("@") != -1) name = name.Split('@')[0]; //显示发件人

                int index = smtpInfo.SmtpServer.IndexOf(".");
                string smtpDomail = smtpInfo.SmtpServer.Substring(index + 1);
                string emailAddress = name + "@" + smtpDomail; //显示发件人EMAIL

                if (!template.ShowName.IsNullEmpty()) name = template.ShowName;  //显示模版里设置的发件人

                bool success = false; string msg = string.Empty;
                if (emailAddress.Trim().ToLower() == e.EmailAddress.Trim().ToLower()) success = true; //不允许自己发给自己

                if (!success) {
                    success = email.ClearTo()
                        .From(name, emailAddress)
                        .Subject(processText(template.Subject, e))
                        .Body(processText(template.Body, e))
                        .To(t => t.Add(e.NickName.IfNullOrEmpty(e.EmailAddress.Split('@')[0]), e.EmailAddress))
                        .Send();
                    msg = processError(email.ErrorMessage);
                    if (sendSetting.SendInterval > 0) Thread.Sleep(sendSetting.SendInterval.Value); //暂停时间
                }

                WriteLog("<" + e.NickName + ">" + e.EmailAddress + (success ? " 发送成功!" : " 发送出错:" + msg));

                //最后一次发送情况
                EmailList emailInfo = new EmailList();
                emailInfo.EmailAddress = e.EmailAddress;
                emailInfo.LastSendStatus = success ? 1 : (sendSetting.SendRetryCount == e.SendCount + 1 ? 2 : 0);
                emailInfo.LastSendTime = DateTime.Now;
                emailInfo.LastSendSmtp = smtpInfo.SmtpServer + "|" + smtpInfo.UserName;
                emailInfo.LastSendError = msg;
                emailInfo.SendCount = e.SendCount + 1;
                EmailListHelper.Update(emailInfo);

                ips++;
                if (sendSetting.IPInterval > 0 && ips >= sendSetting.IPInterval) { //换IP
                    ips = 0;
                    WriteLog("正在更换IP.....");
                    string ip = NetHelper.ChangeIP(sendSetting.ConnectType.Value, uiMsg, uiDone);
                    if (ip.IsNullEmpty()) { WriteLog(sendSetting.MaxRetryCount + "次更换IP失败!"); return 1; } //1更换IP失败结束
                    WriteLog("更换IP:" + ip);
                }

                smtps++;
                if (!success) smtps2++;
                if (sendSetting.SmtpInterval > 0 && smtps >= sendSetting.SmtpInterval && smtpList.Count > 1) { //换SMTP
                    UpdateSmtpListSendCount(smtpIndex, sendSetting.SmtpInterval.Value, smtps2); //更新smtp发送次数

                    smtps = 0; smtps2 = 0;
                    smtpIndex++;
                    if (smtpIndex + 1 > smtpList.Count) smtpIndex = 0; //如果所有smtp发送完,将重新循环更换
                    smtpInfo = smtpList[smtpIndex]; //更换下一个smtp
                    WriteLog("更换SMTP:" + smtpInfo.SmtpServer + "|" + smtpInfo.UserName);
                    email.Host(smtpInfo.SmtpServer)
                        .Ssl(smtpInfo.SSL.Value)
                        .Port(smtpInfo.SmtpPort.Value)
                        .Credentials(smtpInfo.UserName, smtpInfo.SPassword);
                }
            };

            if (smtps > 0) UpdateSmtpListSendCount(smtpIndex, smtps, smtps2); //更新smtp发送次数
            WriteLog("第" + (sends + 1) + "轮发送完成!");
            return SendEmails(sends + 1);
        }
Beispiel #21
0
 /// <summary>
 /// �����������ѯ�Ļ���
 /// </summary>
 public static void ClearCacheSelectByID(string smtpServer, int smtpPort, string userName,  Where where = null)
 {
     string cacheName = "TH.Mailer.SmtpListCache_SelectByID_{0}";
     string cacheNameKey = string.Format(cacheName, smtpServer + "_" + smtpPort + "_" + userName + "_" +  "_" + where);
     Cache2.Remove(cacheNameKey);
 }
 /// <summary>
 /// �����������ð�������ѯ���������ݵ�ʵ����
 /// </summary>
 /// <param name="tianYiID">�����������ñ��</param>
 /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
 /// <returns>���ص�����¼��ʵ����</returns>
 public static TianYiSetting SelectByID(int tianYiID,  string dbkey = "", Where where = null)
 {
     string cacheNameKey = "TH.Mailer.TianYiSettingCache_SelectByID_{0}".FormatWith(tianYiID + "_" +  "_" + where);
     return Cache2.Get<TianYiSetting>(cacheNameKey, cacheSeconds, () => {
         TianYiSetting obj = new SQL().Database(dbkey).From(TianYiSetting._)
             .Select(TianYiSetting._TianYiID)
             .Select(TianYiSetting._TianYiExePath)
             .Where(new Where()
                 .AndP(TianYiSetting._TianYiID, tianYiID, Operator.Equal)
             ).Where(where).ToEntity<TianYiSetting>();
         return obj;
     });
 }
Beispiel #23
0
 /// <summary>
 /// ɾ��������¼
 /// </summary>
 /// <param name="emailAddressList">���͵�Email�б���á�,���ŷָ�</param>
 /// <param name="where">ɾ��ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">�޸ijɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>ɾ���Ƿ�ɹ�</returns>
 public static bool DeleteByIDList(IEnumerable<string> emailAddressList,  string dbkey = "", Where where = null, string[] delCache = null)
 {
     int value = new SQL().Database(dbkey).Delete(EmailList._)
         .Where(new Where()
             .And(EmailList._EmailAddress, "(" + emailAddressList .Join(",") + ")", Operator.In)
         ).Where(where).ToExec();
     if (value <= 0) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.EmailListCache_", delCache);
     return true;
 }
 /// <summary>
 /// �������������޸ļ�¼
 /// </summary>
 /// <param name="tianYiSetting">������������ʵ����</param>
 /// <param name="where">�޸�ʱ����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="delCache">�޸ijɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool Update(TianYiSetting tianYiSetting, string dbkey = "", Where where = null, string[] delCache = null)
 {
     if (tianYiSetting.TianYiID.IsNull()) return false;
     int value = new SQL().Database(dbkey).Update(TianYiSetting._)
         .SetP(TianYiSetting._TianYiExePath, tianYiSetting.TianYiExePath)
         .Where(new Where()
             .AndP(TianYiSetting._TianYiID, tianYiSetting.TianYiID, Operator.Equal, true)
         ).Where(where).ToExec();
     if (value <= 0) return false;
     if (delCache.IsNull()) return true;
     Cache2.Remove("TH.Mailer.TianYiSettingCache_", delCache);
     return true;
 }
Beispiel #25
0
 /// <summary>
 /// ��¼�Ƿ����
 /// </summary>
 /// <param name="emailAddress">���͵�Email</param>
 /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>��¼�Ƿ����</returns>
 public static bool IsExistByID(string emailAddress,  string dbkey = "", Where where = null)
 {
     long value = new SQL().Database(dbkey).Count(EmailList._EmailAddress).From(EmailList._)
         .Where(new Where()
             .AndP(EmailList._EmailAddress, emailAddress, Operator.Equal)
         ).Where(where).ToScalar().ToString().ToBigInt();
     return value == 1;
 }
Beispiel #26
0
 /// <summary>
 /// 分页SQL调用方法
 /// </summary>
 /// <param name="pageIndex">当前页码</param>
 /// <param name="pageSize">每页显示数量</param>
 /// <param name="tableName">表名称</param>
 /// <param name="pk">主键</param>
 /// <param name="fieldList">字段列表</param>
 /// <param name="where">where条件 and or 开始</param>
 /// <param name="groupBy">分组条件</param>
 /// <param name="orderBy">排序条件</param>
 /// <returns>分页SQL</returns>
 public PagerSql GetSQL(int pageIndex, int pageSize, string tableName, string pk = "*", string fieldList = "*", Where where = null, string groupBy = "", string orderBy = "") {
     if (pk.IsNullEmpty() && !fieldList.IsNullEmpty() && fieldList.IndexOf(",") > 0) pk = fieldList.Split(',')[0];
     if (pk.IsNullEmpty() && !fieldList.Equals("*") && fieldList.IndexOf(",") == -1) pk = fieldList;
     if (fieldList.IsNullEmpty()) fieldList = "*";
     if (pk.IsNullEmpty()) pk = "*";
     pk = pk.Trim(','); fieldList = fieldList.Trim(',');
     if (orderBy.IsNullEmpty() && !pk.IsNullEmpty() && !pk.Equals("*")) orderBy = pk + " desc";
     if (pageIndex < 1) pageIndex = 1;
     if (pageSize < 1) pageSize = 10;
     string _where = "";
     if (!where.IsNull()) _where = "1=1 " + where.ToString();
     return PagerSQL.GetSQL(pageIndex, pageSize, tableName, pk, fieldList, _where, groupBy, orderBy);
 }
Beispiel #27
0
 /// <summary>
 /// ��������ѯ���������ݵ�ʵ����
 /// </summary>
 /// <param name="emailAddress">���͵�Email</param>
 /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
 /// <returns>���ص�����¼��ʵ����</returns>
 public static EmailList SelectByID(string emailAddress,  string dbkey = "", Where where = null)
 {
     string cacheNameKey = "TH.Mailer.EmailListCache_SelectByID_{0}".FormatWith(emailAddress + "_" +  "_" + where);
     return Cache2.Get<EmailList>(cacheNameKey, cacheSeconds, () => {
         EmailList obj = new SQL().Database(dbkey).From(EmailList._)
             .Select(EmailList._EmailAddress)
             .Select(EmailList._NickName)
             .Select(EmailList._LastSendStatus)
             .Select(EmailList._LastSendError)
             .Select(EmailList._LastSendTime)
             .Select(EmailList._LastSendSmtp)
             .Select(EmailList._SendCount)
             .Select(EmailList._CreateTime)
             .Select(EmailList._ex0)
             .Select(EmailList._ex1)
             .Select(EmailList._ex2)
             .Select(EmailList._ex3)
             .Select(EmailList._ex4)
             .Select(EmailList._ex5)
             .Select(EmailList._ex6)
             .Select(EmailList._ex7)
             .Select(EmailList._ex8)
             .Where(new Where()
                 .AndP(EmailList._EmailAddress, emailAddress, Operator.Equal)
             ).Where(where).ToEntity<EmailList>();
         return obj;
     });
 }
 /// <summary>
 /// ���ð�������ѯ���������ݵ�ʵ����
 /// </summary>
 /// <param name="settingID">���ñ��</param>
 /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
 /// <returns>���ص�����¼��ʵ����</returns>
 public static SendSetting SelectByID(int settingID,  string dbkey = "", Where where = null)
 {
     string cacheNameKey = "TH.Mailer.SendSettingCache_SelectByID_{0}".FormatWith(settingID + "_" +  "_" + where);
     return Cache2.Get<SendSetting>(cacheNameKey, cacheSeconds, () => {
         SendSetting obj = new SQL().Database(dbkey).From(SendSetting._)
             .Select(SendSetting._SettingID)
             .Select(SendSetting._TemplateID)
             .Select(SendSetting._ConnectType)
             .Select(SendSetting._SendInterval)
             .Select(SendSetting._IPInterval)
             .Select(SendSetting._SmtpInterval)
             .Select(SendSetting._DeleteInterval)
             .Select(SendSetting._MaxRetryCount)
             .Select(SendSetting._SendRetryCount)
             .Select(SendSetting._Status)
             .Where(new Where()
                 .AndP(SendSetting._SettingID, settingID, Operator.Equal)
             ).Where(where).ToEntity<SendSetting>();
         return obj;
     });
 }
Beispiel #29
0
 /// <summary>
 /// ��ѯ���м�¼
 /// </summary>
 /// <param name="where">����������ͳһ��ǰ��Ҫ�����ӷ���and��or�ȵȣ�</param>
 /// <param name="order">�����ֶΣ����ӡ�order by��</param>
 /// <param name="fieldList">������Ҫ���ص��ֶ�</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱ���ȡ����key</param>
 /// <returns>����ʵ���¼��</returns>
 public static IList<EmailList> SelectListByAll(string dbkey = "", Where where = null, string order = "", string fieldList = "")
 {
     string cacheNameKey = "TH.Mailer.EmailListCache_SelectListByAll_{0}_{1}_{2}".FormatWith(where, order, fieldList);
     return Cache2.Get<IList<EmailList>>(cacheNameKey, cacheSeconds, () => {
         IList<EmailList> list = new List<EmailList>();
         if (fieldList.IsNullEmpty()) {
             list = new SQL().Database(dbkey).From(EmailList._)
                 .Select(EmailList._EmailAddress)
                 .Select(EmailList._NickName)
                 .Select(EmailList._LastSendStatus)
                 .Select(EmailList._LastSendError)
                 .Select(EmailList._LastSendTime)
                 .Select(EmailList._LastSendSmtp)
                 .Select(EmailList._SendCount)
                 .Select(EmailList._CreateTime)
                 .Select(EmailList._ex0)
                 .Select(EmailList._ex1)
                 .Select(EmailList._ex2)
                 .Select(EmailList._ex3)
                 .Select(EmailList._ex4)
                 .Select(EmailList._ex5)
                 .Select(EmailList._ex6)
                 .Select(EmailList._ex7)
                 .Select(EmailList._ex8)
                 .Where(where).Order(order).ToList<EmailList>();
         } else {
             list = new SQL().Database(dbkey).From(EmailList._).Select(fieldList).Where(where).Order(order).ToList<EmailList>();
         }
         return list;
     });
 }
 /// <summary>
 /// ������ð�������ѯ�Ļ���
 /// </summary>
 public static void ClearCacheSelectByID(int settingID,  Where where = null)
 {
     string cacheName = "TH.Mailer.SendSettingCache_SelectByID_{0}";
     string cacheNameKey = string.Format(cacheName, settingID + "_" +  "_" + where);
     Cache2.Remove(cacheNameKey);
 }
Beispiel #31
0
        /// <summary>
        /// 分页SQL调用方法
        /// </summary>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页显示数量</param>
        /// <param name="tableName">表名称</param>
        /// <param name="pk">主键</param>
        /// <param name="fieldList">字段列表</param>
        /// <param name="where">where条件 and or 开始</param>
        /// <param name="groupBy">分组条件</param>
        /// <param name="orderBy">排序条件</param>
        /// <returns>分页SQL</returns>
        public PagerSql GetSQL(int pageIndex, int pageSize, string tableName, string pk = "*", string fieldList = "*", Where where = null, string groupBy = "", string orderBy = "")
        {
            if (pk.IsNullEmpty() && !fieldList.IsNullEmpty() && fieldList.IndexOf(",") > 0)
            {
                pk = fieldList.Split(',')[0];
            }
            if (pk.IsNullEmpty() && !fieldList.Equals("*") && fieldList.IndexOf(",") == -1)
            {
                pk = fieldList;
            }
            if (fieldList.IsNullEmpty())
            {
                fieldList = "*";
            }
            if (pk.IsNullEmpty())
            {
                pk = "*";
            }
            pk = pk.Trim(','); fieldList = fieldList.Trim(',');
            if (orderBy.IsNullEmpty() && !pk.IsNullEmpty() && !pk.Equals("*"))
            {
                orderBy = pk + " desc";
            }
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }
            if (pageSize < 1)
            {
                pageSize = 10;
            }
            string _where = "";

            if (!where.IsNull())
            {
                _where = "1=1 " + where.ToString();
            }
            return(PagerSQL.GetSQL(pageIndex, pageSize, tableName, pk, fieldList, _where, groupBy, orderBy));
        }