예제 #1
0
        public DataTable GetTableStruct(string DBCode, string TableName, params string[] Columns)
        {
            var    db  = DataBaseFactoryEx.CreateDataBase(DBCode);
            string sql = GetStructSql(TableName, Columns);

            return(db.GetTable(sql, TableName, null));
        }
예제 #2
0
        private DataTable RefreshUserName(IDatabase db)
        {
            if (db == null)
            {
                db = DataBaseFactoryEx.CreateDataBase(Loginer.CurrentLoginer.SystemDBCode);
            }
            string    sql = bllDataCommon.Instance.GetAllDataSQL(dt_MyUser._TableName, dt_MyUser.Account, dt_MyUser.UserName);
            DataTable dt  = db.GetTable(sql, dt_MyUser._TableName, null);

            AddToCache(dt);
            return(dt);
        }
예제 #3
0
        public bool VerifyPwdEx(string User, string Pwd)
        {
            Pwd = PwdEncrypt(Pwd);
            const string         sql = "SELECT COUNT(0) FROM  dt_MyUser WHERE Account=@Account AND [Password]=@Pwd";
            SqlParameterProvider p   = new SqlParameterProvider();

            p.AddParameter("@Account", SqlDbType.VarChar, 20, User);
            p.AddParameter("@Pwd", SqlDbType.VarChar, 50, Pwd);
            long v = DataBaseFactoryEx.CreateDataBase(Loginer.CurrentLoginer.SystemDBCode).ExecuteScalar <int>(sql, p);

            return(v > 0);
        }
예제 #4
0
        /// <summary>
        /// 验证用户名密码
        /// </summary>
        /// <param name="User"></param>
        /// <param name="Pwd"></param>
        /// <param name="dr"></param>
        /// <returns></returns>
        public Loginer VerifyPwd(string User, string Pwd, string LoginDBCode)
        {
            Pwd = PwdEncrypt(Pwd);

            SqlParameterProvider p = new SqlParameterProvider();

            p.AddParameter("@Account", SqlDbType.VarChar, User);
            p.AddParameter("@Pwd", SqlDbType.VarChar, Pwd);
            p.AddParameter("@LoginDBCode", SqlDbType.VarChar, LoginDBCode);

            DataTable dt = DataBaseFactoryEx.CreateDataBase(Loginer.CurrentLoginer.SystemDBCode).GetTableSP("usp_UserLogin", "tmp", p);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                DataRow row  = dt.Rows[0];
                Loginer user = new Loginer();
                user.Account     = (string)row[dt_MyUser.Account];
                user.UserName    = (string)row[dt_MyUser.UserName];
                user.IsSysAdmin  = Object.Equals(row[dt_MyUser.IsSysAdmain], "Y");
                user.IsSysLock   = Object.Equals(row[dt_MyUser.IsSysLock], "Y");
                user.LoginDBCode = ConvertLib.ToString(row[dt_MyUserDBs.DBCode]);
                user.IsDBAdmin   = Object.Equals(row[dt_MyUserDBs.IsDBAdmin], "Y");
                user.IsDBLock    = Object.Equals(row[dt_MyUserDBs.IsDBLock], "Y");
                if (user.IsSysAdmin && String.IsNullOrEmpty(user.LoginDBCode))
                {
                    user.LoginDBCode = LoginDBCode;
                }
                return(user);
            }
            //var v = DatabaseFactory.CreateDataBaseEx(Loginer.CurrentLoginer.SystemDBCode).ExecuteDataReader(sql, new { Account = User, Pwd = Pwd }, row =>
            //{
            //    return new Loginer()
            //    {
            //        Account = (string)row[dt_MyUser.Account],
            //        UserName = (string)row[dt_MyUser.UserName],
            //        IsDBAdmin = Object.Equals(row[dt_MyUser.IsAdmain], "Y")
            //    };
            //});

            //if (v.Count() > 0)
            //    return v.First();
            //else
            //    return null;
        }
예제 #5
0
        public DataSet GetTableData(string DBCode, IEnumerable <string> TableNames, params string[] Columns)
        {
            DataSet ds = new DataSet();

            var DataBase = DataBaseFactoryEx.CreateDataBase(DBCode);

            DataBase.ExecuteTransaction(db =>
            {
                foreach (string TableName in TableNames)
                {
                    string sql = GetAllDataSQL(TableName, Columns);
                    ds.Tables.Add(db.GetTable(sql, TableName, null));
                }
            });
            return(ds);
        }
예제 #6
0
        public void LoadCatch()
        {
            List <System.Reflection.MethodInfo> MethodLogin  = new List <System.Reflection.MethodInfo>();
            List <System.Reflection.MethodInfo> MethodSystem = new List <System.Reflection.MethodInfo>();
            var ms = this.GetType().GetMethods(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            foreach (var v in ms)
            {
                var dp = (DataProviderAttribute)v.GetCustomAttributes(typeof(DataProviderAttribute), false).FirstOrDefault();
                if (dp != null)
                {
                    if (dp.DBName == EDBName.System)
                    {
                        MethodSystem.Add(v);
                    }
                    if (dp.DBName == EDBName.Login)
                    {
                        MethodLogin.Add(v);
                    }
                }
            }
            if (!String.IsNullOrEmpty(Loginer.CurrentLoginer.LoginDBCode))
            {
                var dbLogin = DataBaseFactoryEx.CreateDataBase(Loginer.CurrentLoginer.LoginDBCode);
                dbLogin.Excute(db =>
                {
                    foreach (var m in MethodLogin)
                    {
                        m.Invoke(this, new object[] { db });
                    }
                });
            }
            var dbSystem = DataBaseFactoryEx.CreateDataBase(Loginer.CurrentLoginer.SystemDBCode);

            dbSystem.Excute(db =>
            {
                foreach (var m in MethodSystem)
                {
                    m.Invoke(this, new object[] { db });
                }
            });
        }