Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtWebName.Text)) {
                MessageBox.Show("网址名称不能为空", "系统提示");
                return;
            }
            if (string.IsNullOrEmpty(this.txtIPUrl.Text)) {
                MessageBox.Show("网址地址不能为空", "系统提示");
                return;
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;

            IpSetting info = new IpSetting();

            info.WebName = this.txtWebName.Text;
            info.IPUrl = this.txtIPUrl.Text;
            info.IPRegex = this.txtIPRegex.Text;
            info.DataEncode = this.txtDataEncode.Text;

            if (this.id != 0) {
                info.IPCID = this.id;
                IpSettingHelper.Update(info);
                IpSettingHelper.ClearCacheAll();
            } else {
                IpSettingHelper.Insert(info);
                IpSettingHelper.ClearCacheAll();
            }

            MessageBox.Show("保存数据成功!", " 系统提示");
            this.Close();
        }
Пример #2
0
 /// <summary>
 /// ��ȡIP�����޸Ķ�����¼
 /// </summary>
 /// <param name="iPCIDList">��ȡIP���ñ���б���á�,���ŷָ�</param>
 /// <param name="ipSetting">��ȡIP����ʵ����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool UpdateByIDList(IEnumerable<Int64> iPCIDList,  IpSetting ipSetting, string dbkey)
 {
     return UpdateByIDList(iPCIDList,  ipSetting, dbkey, null, null);
 }
Пример #3
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;
 }
Пример #4
0
 /// <summary>
 /// ��ȡIP�����޸ļ�¼
 /// </summary>
 /// <param name="ipSetting">��ȡIP����ʵ����</param>
 /// <returns>�޸��Ƿ�ɹ�</returns>
 public static bool Update(IpSetting ipSetting, string dbkey)
 {
     return Update(ipSetting, dbkey, null, null);
 }
Пример #5
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;
 }
Пример #6
0
 /// <summary>
 /// ��ȡIP������Ӽ�¼
 /// </summary>
 /// <param name="ipSetting">��ȡIP����ʵ����</param>
 /// <returns>������ӳɹ����ID</returns>
 public static Int64 Insert(IpSetting ipSetting, string dbkey)
 {
     return Insert(ipSetting, dbkey, null);
 }
Пример #7
0
 /// <summary>
 /// ��ȡIP������Ӽ�¼
 /// </summary>
 /// <param name="ipSetting">��ȡIP����ʵ����</param>
 /// <param name="delCache">��ӳɹ��������CACHE key��֧������</param>
 /// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
 /// <returns>������ӳɹ����ID</returns>
 public static Int64 Insert(IpSetting ipSetting, string dbkey = "", string[] delCache = null)
 {
     object obj = new SQL().Database(dbkey).Insert(IpSetting._)
         .ValueP(IpSetting._IPCID, ipSetting.IPCID)
         .ValueP(IpSetting._WebName, ipSetting.WebName)
         .ValueP(IpSetting._IPUrl, ipSetting.IPUrl)
         .ValueP(IpSetting._IPRegex, ipSetting.IPRegex)
         .ValueP(IpSetting._DataEncode, ipSetting.DataEncode)
         .ToExec();
     if (obj.ToInt() != 1) return 0;
     obj = new SQL().Database(dbkey).From(IpSetting._).Max("IPCID").ToScalar();
     if (obj.IsAllNull()) return 0;
     Int64 value = obj.ToString().ToBigInt();
     if (delCache.IsNull()) return value;
     Cache2.Remove("TH.Mailer.IpSettingCache_", delCache);
     return value;
 }