自动化点胶机:纯真IP地址库ajax处理

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 09:00:13
/// 纯真IP地址库ajax处理 [C#源代码来自http://www.showjim.com/]

using System;
using System.Web.UI;
using System.Collections.Generic;
using sys.sql;
using sys.sql.sqlServer;

namespace web.ajax.dataWarehouse
{
    ///
    /// 纯真IP地址库ajax处理
    ///

    public static class cz88NetIP
    {
        ///
        /// 纯真IP地址库查询int64集合
        ///

        private static string[] queryInt64 = new string[] { "startIP", "endIP" };

        #region 获取纯真IP地址库列表
        ///
        /// 获取纯真IP地址库列表
        ///

        /// 当前http请求页面信息
        /// 是POST还是GET请求
        /// 纯真IP地址库列表
        public static string list(Page httpPage, bool isPost)
        {
            int uid = sys.module.user.sqlTable.users.currentAdminUid;
            string ajaxString = String.Empty;
            if (uid != 0 && sys.module.user.sqlTable.userTablePurview.isPurview(uid, (short)sys.sql.config.tableNames.dataWarehouse_ip_cz88_net, (byte)sys.module.user.sqlTable.userTablePurview.purviewBitmap.read))
            {
                sys.sql.sqlServer.wholeTableCache.singleKeySingleDictionary cache = sys.module.dataWarehouse.ip.cz88.ipCache;
                long[] query = sys.web.http.request.formQuery.getInt63(queryInt64, 0, isPost);
                string addressName = "address", address = sys.web.http.request.formQuery.getString(addressName, String.Empty, isPost), where = String.Empty;
                bool isWhere = false;
                ajaxString += "{" + sys.sql.page.ajaxQueryName + ":{";
                if (query[0] != 0)
                {
                    foreach (sys.module.dataWarehouse.sqlTable.structs.dataWarehouse_ip_cz88_net ip in cache.getEntitys("startIP<=" + query[0], "startIP desc", 0, 1)) query[0] = ip.startIP_;
                    if (isWhere) { where += " and"; ajaxString += ","; }
                    where += " " + queryInt64[0] + ">=" + query[0];
                    ajaxString += queryInt64[0] + ":" + query[0];
                    isWhere = true;
                }
                if (query[1] != 0)
                {
                    foreach (sys.module.dataWarehouse.sqlTable.structs.dataWarehouse_ip_cz88_net ip in cache.getEntitys("endIP>=" + query[1], "endIP", 0, 1)) query[1] = ip.endIP_;
                    if (isWhere) { where += " and"; ajaxString += ","; }
                    where += " " + queryInt64[0] + "<" + query[0];
                    ajaxString += queryInt64[1] + ":" + query[0];
                    isWhere = true;
                }
                if (address.Length != 0)
                {
                    if (isWhere) { where += " and"; ajaxString += ","; }
                    where += " " + addressName + " like '%" + address.toLike(256) + "%'";
                    ajaxString += addressName + ":" + sys.web.http.request.formQuery.ajaxSingleQuoteString + query[0] + sys.web.http.request.formQuery.ajaxSingleQuoteString;
                }
                sys.sql.page.queryPage pageInfo = sys.sql.page.getInfo(cache.getCount(where), isPost);
                ajaxString += "}," + sys.sql.page.ajaxPageName + ":" + pageInfo.ajaxString() + "," + sys.sql.page.ajaxListName + ":";
                if (pageInfo.count == 0) ajaxString += "[]";
                else ajaxString += sys.module.dataWarehouse.sqlTable.structs.getAjaxString_dataWarehouse_ip_cz88_net(cache.getEntitys(where, "startIP", pageInfo.page == 1 ? 0 : ((pageInfo.page - 1) * pageInfo.notPerPage), pageInfo.notPerPage));
                ajaxString += "}";
            }
            return ajaxString;
        }
        #endregion
    }
}