Пример #1
0
        /// <summary>
        /// 接口访问权限判断
        /// 作者:苑峰      时间:2009-8-11
        /// 修改:          时间:
        /// </summary>
        public static int CheckInterfaceLimit(string SPID, string InterfaceName, HttpContext context, out string ErrMsg)
        {
            int Result = ErrorDefinition.IError_Result_UnknowError_Code;

            ErrMsg = "";
            DataTable dt = null;

            try
            {
                string IsInterfaceLimit = System.Configuration.ConfigurationManager.AppSettings["IsInterfaceLimit"];
                //若不启用则返回允许
                if (IsInterfaceLimit == "1")
                {
                    Result = 0;
                    return(Result);
                }
                //从缓存中获取数据
                SPInfoManager        spInfo = new SPInfoManager();
                SPInterfaceLimitData SPInterfaceLimitData = (SPInterfaceLimitData)spInfo.GetSPData(context, "SPInterfaceLimitData");

                dt = SPInterfaceLimitData.Tables[SPInterfaceLimitData.TableName];
                string tmpInterfaceName = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (SPID == dt.Rows[i][SPInterfaceLimitData.Field_SPID].ToString())
                    {
                        tmpInterfaceName = dt.Rows[i][SPInterfaceLimitData.Field_InterfaceName].ToString().Trim();
                        //如果IP在限制列表中则成功
                        if (tmpInterfaceName == InterfaceName)
                        {
                            Result = 0;
                            return(Result);
                        }
                    }
                }

                Result = ErrorDefinition.BT_IError_Result_BizInterfaceLimit_Code;
                ErrMsg = ErrorDefinition.BT_IError_Result_BizInterfaceLimit_Msg;
            }
            catch (Exception e)
            {
                Result = ErrorDefinition.IError_Result_System_UnknowError_Code;
                ErrMsg = e.Message;
            }

            return(Result);
        }
Пример #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;
        }
Пример #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);
        }