Beispiel #1
0
        /// <summary>
        /// IP是否允许访问
        /// 作者:苑峰      时间:2009-8-11
        /// 修改:          时间:
        /// </summary>
        public static int CheckIPLimit(string SPID, string IP, HttpContext context, out string ErrMsg)
        {
            int Result = ErrorDefinition.IError_Result_UnknowError_Code;

            ErrMsg = "";
            DataTable dt = null;

            try
            {
                string IsIPLimit = System.Configuration.ConfigurationManager.AppSettings["IsIPLimit"];
                //若不启用则返回允许
                if (IsIPLimit == "1")
                {
                    Result = 0;
                    return(Result);
                }
                //根据传入IP获取IPNumber
                long IPNumber = CommonBizRules.GetIPAddressIPNumber(IP);
                //从缓存中获取数据
                SPInfoManager spInfo       = new SPInfoManager();
                SPIPListData  SPIPListData = (SPIPListData)spInfo.GetSPData(context, "SPIPListData");

                dt = SPIPListData.Tables[SPIPListData.TableName];
                long StartIPIPNumber = 0;
                long EndIPIPNumber   = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (SPID == dt.Rows[i][SPIPListData.Field_SPID].ToString())
                    {
                        StartIPIPNumber = long.Parse(dt.Rows[i][SPIPListData.Field_StartIPNumber].ToString());
                        EndIPIPNumber   = long.Parse(dt.Rows[i][SPIPListData.Field_EndIPNumber].ToString());
                        //如果IP在限制列表中则成功
                        if (IPNumber >= StartIPIPNumber && IPNumber <= EndIPIPNumber)
                        {
                            Result = 0;
                            return(Result);
                        }
                    }
                }

                Result = ErrorDefinition.BT_IError_Result_BizIPLimit_Code;
                ErrMsg = ErrorDefinition.BT_IError_Result_BizIPLimit_Msg;
            }
            catch (Exception e)
            {
                Result = ErrorDefinition.IError_Result_System_UnknowError_Code;
                ErrMsg = e.Message;
            }

            return(Result);
        }
Beispiel #2
0
        /// <summary>
        /// �����ݿ��ȡSP���ݼ���
        /// ���ߣ�Է��      ʱ�䣺2009-7-31
        /// �޸ģ�          ʱ�䣺
        /// </summary>
        private object GetSPData( string SPDataCacheName)
        {
            object ResultData = null;
            DataSet tmpData = new DataSet();

            try
            {
                SqlCommand selCmd = new SqlCommand();
                selCmd.CommandType = CommandType.Text;
                DataTable dt = new DataTable();
                if (SPDataCacheName == "SPData")
                {
                    selCmd.CommandText = SPInfoManager.SqlGetSPInfo;
                    SPData SPData = new SPData();
                    dt = SPData.Tables[SPData.TableName];
                    ResultData = SPData;
                }
                else if (SPDataCacheName == "SPIPListData")
                {
                    selCmd.CommandText = SPInfoManager.SqlGetSPIPList;
                    SPIPListData SPIPListData = new SPIPListData();
                    dt = SPIPListData.Tables[SPIPListData.TableName];
                    ResultData = SPIPListData;
                }
                else if (SPDataCacheName == "SPInterfaceLimitData")
                {
                    selCmd.CommandText = SPInfoManager.SqlGetSPInterfaceLimit;
                    SPInterfaceLimitData SPInterfaceLimitData = new SPInterfaceLimitData();
                    dt = SPInterfaceLimitData.Tables[SPInterfaceLimitData.TableName];
                    ResultData = SPInterfaceLimitData;
                }
                else if (SPDataCacheName == "SPCAData")
                {
                    selCmd.CommandText = SPInfoManager.SqlGetSPCAInfo;
                    SPCAData SPCAData = new SPCAData();
                    dt = SPCAData.Tables[SPCAData.TableName];
                    ResultData = SPCAData;
                }

                // ��ȡ����
                tmpData = DBUtility.FillData(selCmd, DBUtility.BestToneCenterConStr);

                // ����ת��
                // DataSet --> Object

                int intTargetColumnCount = dt.Columns.Count;
                foreach (DataRow row in tmpData.Tables[0].Rows)
                {
                    object[] newRow = new object[intTargetColumnCount];
                    for (int j = 0; j < intTargetColumnCount; j++)
                    {
                        newRow[j] = row[j];
                    }
                    dt.Rows.Add(newRow);
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return ResultData;
        }
Beispiel #3
0
        /// <summary>
        /// 从数据库获取SP数据集合
        /// 作者:苑峰      时间:2009-7-31
        /// 修改:          时间:
        /// </summary>
        private object GetSPData(string SPDataCacheName)
        {
            object  ResultData = null;
            DataSet tmpData    = new DataSet();

            try
            {
                SqlCommand selCmd = new SqlCommand();
                selCmd.CommandType = CommandType.Text;
                DataTable dt = new DataTable();
                if (SPDataCacheName == "SPData")
                {
                    selCmd.CommandText = SPInfoManager.SqlGetSPInfo;
                    SPData SPData = new SPData();
                    dt         = SPData.Tables[SPData.TableName];
                    ResultData = SPData;
                }
                else if (SPDataCacheName == "SPIPListData")
                {
                    selCmd.CommandText = SPInfoManager.SqlGetSPIPList;
                    SPIPListData SPIPListData = new SPIPListData();
                    dt         = SPIPListData.Tables[SPIPListData.TableName];
                    ResultData = SPIPListData;
                }
                else if (SPDataCacheName == "SPInterfaceLimitData")
                {
                    selCmd.CommandText = SPInfoManager.SqlGetSPInterfaceLimit;
                    SPInterfaceLimitData SPInterfaceLimitData = new SPInterfaceLimitData();
                    dt         = SPInterfaceLimitData.Tables[SPInterfaceLimitData.TableName];
                    ResultData = SPInterfaceLimitData;
                }
                else if (SPDataCacheName == "SPCAData")
                {
                    selCmd.CommandText = SPInfoManager.SqlGetSPCAInfo;
                    SPCAData SPCAData = new SPCAData();
                    dt         = SPCAData.Tables[SPCAData.TableName];
                    ResultData = SPCAData;
                }

                // 获取数据
                tmpData = DBUtility.FillData(selCmd, DBUtility.BestToneCenterConStr);

                // 数据转换
                // DataSet --> Object

                int intTargetColumnCount = dt.Columns.Count;
                foreach (DataRow row in tmpData.Tables[0].Rows)
                {
                    object[] newRow = new object[intTargetColumnCount];
                    for (int j = 0; j < intTargetColumnCount; j++)
                    {
                        newRow[j] = row[j];
                    }
                    dt.Rows.Add(newRow);
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(ResultData);
        }