Exemplo n.º 1
0
        //
        public bool IsUserExist(string loginName)
        {
            //string sql = "select * from Users where loginName=@loginName and IsLocked=0";
            //SqlParameter[] Parameters = new SqlParameter[1];
            //Parameters[0] = new SqlParameter("@loginName", SqlDbType.NVarChar);
            //Parameters[0].Value = loginName.Replace("'", "''");
            //string sql = "select count(*) from Users where loginName = @loginName";
            //object obj = SqlHelper.ExecuteScalar(SqlHelper.SqlCon_QJVRMS, CommandType.Text, sql, Parameters);

            //if (obj != null && int.Parse(obj.ToString()) > 0)
            //{
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}

            QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
            return(mss.IsUserExist(loginName));
        }
Exemplo n.º 2
0
        //
        public bool IsUserExist(string loginName)
        {
            //string sql = "select * from Users where loginName=@loginName and IsLocked=0";
            //SqlParameter[] Parameters = new SqlParameter[1];
            //Parameters[0] = new SqlParameter("@loginName", SqlDbType.NVarChar);
            //Parameters[0].Value = loginName.Replace("'", "''");
            //string sql = "select count(*) from Users where loginName = @loginName";
            //object obj = SqlHelper.ExecuteScalar(SqlHelper.SqlCon_QJVRMS, CommandType.Text, sql, Parameters);

            //if (obj != null && int.Parse(obj.ToString()) > 0)
            //{
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}

            QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
            return mss.IsUserExist(loginName);

        }
Exemplo n.º 3
0
        /// <summary>
        /// and IPAddress validate
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="password"></param>
        /// <param name="returnObj"></param>
        /// <returns></returns>
        public bool AuthUserByForm(string loginName, string password, string IPAddress, ref object returnObj)
        {
            string encryptPassword = Encryption.Encrypt(password);

            //SqlParameter[] Parameters = new SqlParameter[4];
            //Parameters[0] = new SqlParameter("@loginName", SqlDbType.NVarChar);
            //Parameters[1] = new SqlParameter("@password", SqlDbType.VarChar, 50);
            //Parameters[2] = new SqlParameter("@IPAddress", SqlDbType.NVarChar, 15);
            //Parameters[3] = new SqlParameter("@IsValidated", SqlDbType.Bit);

            //Parameters[0].Value = loginName;
            //Parameters[1].Value = encryptPassword;
            //Parameters[2].Value = IPAddress;
            //Parameters[3].Direction = ParameterDirection.Output;

            //try
            //{
            //    using (DataTable resTable = SqlHelper.ExecuteDataset(SqlHelper.SqlCon_QJVRMS, CommandType.StoredProcedure, "dbo.Users_ValidateUserAndGetUser", Parameters).Tables[0])
            //    {
            //        if (resTable.Rows.Count != 0)
            //        {
            //            if (!bool.Parse(Parameters[3].Value.ToString()))
            //            {
            //                return false;
            //            }
            //            DataRow reader = resTable.Rows[0];
            //            User user = new User();
            //            user.UserId = new Guid(reader["UserId"].ToString());
            //            user.GroupId = new Guid(reader["Groupid"].ToString());
            //            user.UserName = reader["UserName"].ToString();
            //            user.GroupName = reader["GroupName"].ToString();
            //            user.IsDownLoad = reader["IsDownLoad"].ToString();
            //            returnObj = user;

            //            return true;
            //        }
            //        else
            //        {
            //            return false;
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    LogWriter.WriteExceptionLog(ex, true);
            //    return false;
            //}

            QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
            SerializeObjectFactory sof = new SerializeObjectFactory();



            try
            {
                string objStr = null;
                ///mss.GetUserByLoginName

                string isAuthByRemote = ConfigurationManager.AppSettings["AuthByRemote"];
                if (string.IsNullOrEmpty(isAuthByRemote))
                {
                    isAuthByRemote = "0";
                }


                if (isAuthByRemote.Equals("1"))
                {
                    //objStr = mss.GetUserByLoginName(loginName);
                    bool isUser = mss.IsUserExist(loginName);

                    //表里没有用户,调用集成验证
                    if (!isUser)
                    {
                        return(AuthUserByRequest(loginName, password, IPAddress, ref returnObj, true));
                    }
                    else
                    {
                        objStr = mss.GetUserByLoginName(loginName);
                        object o = sof.DesializeFromBase64(objStr);
                        QJVRMS.Business.User user = (QJVRMS.Business.User)o;

                        returnObj = user;
                        //用户不是系统管理员,调用集成验证
                        string superAdminId = ConfigurationManager.AppSettings["superAdminId"];
                        if (user.UserId.ToString().ToLower() != superAdminId.ToLower())
                        {
                            return(AuthUserByRequest(loginName, password, IPAddress, ref returnObj, false));
                        }
                        else
                        {
                            //是管理员,调用数据库验证
                            objStr = mss.AuthUserByForm(loginName, password, IPAddress);
                            if (string.IsNullOrEmpty(objStr))
                            {
                                return(false);
                            }
                            else
                            {
                                object o1 = sof.DesializeFromBase64(objStr);
                                QJVRMS.Business.User user1 = (QJVRMS.Business.User)o1;
                                returnObj = user1;
                                return(true);
                            }
                        }

                        //returnObj = user;

                        return(true);
                    }
                }
                else
                {
                    objStr = mss.AuthUserByForm(loginName, password, IPAddress);
                    object o = sof.DesializeFromBase64(objStr);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)o;
                    returnObj = user;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogWriter.WriteExceptionLog(ex);
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// and IPAddress validate
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="password"></param>
        /// <param name="returnObj"></param>
        /// <returns></returns>
        public bool AuthUserByForm(string loginName, string password, string IPAddress, ref object returnObj)
        {

            string encryptPassword = Encryption.Encrypt(password);
            //SqlParameter[] Parameters = new SqlParameter[4];
            //Parameters[0] = new SqlParameter("@loginName", SqlDbType.NVarChar);
            //Parameters[1] = new SqlParameter("@password", SqlDbType.VarChar, 50);
            //Parameters[2] = new SqlParameter("@IPAddress", SqlDbType.NVarChar, 15);
            //Parameters[3] = new SqlParameter("@IsValidated", SqlDbType.Bit);

            //Parameters[0].Value = loginName;
            //Parameters[1].Value = encryptPassword;
            //Parameters[2].Value = IPAddress;
            //Parameters[3].Direction = ParameterDirection.Output;

            //try
            //{
            //    using (DataTable resTable = SqlHelper.ExecuteDataset(SqlHelper.SqlCon_QJVRMS, CommandType.StoredProcedure, "dbo.Users_ValidateUserAndGetUser", Parameters).Tables[0])
            //    {
            //        if (resTable.Rows.Count != 0)
            //        {
            //            if (!bool.Parse(Parameters[3].Value.ToString()))
            //            {
            //                return false;
            //            }
            //            DataRow reader = resTable.Rows[0];
            //            User user = new User();
            //            user.UserId = new Guid(reader["UserId"].ToString());
            //            user.GroupId = new Guid(reader["Groupid"].ToString());
            //            user.UserName = reader["UserName"].ToString();
            //            user.GroupName = reader["GroupName"].ToString();
            //            user.IsDownLoad = reader["IsDownLoad"].ToString();
            //            returnObj = user;

            //            return true;
            //        }
            //        else
            //        {
            //            return false;
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    LogWriter.WriteExceptionLog(ex, true);
            //    return false;
            //}

            QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
            SerializeObjectFactory sof = new SerializeObjectFactory();



            try
            {
                string objStr = null; 
                ///mss.GetUserByLoginName

                string isAuthByRemote = ConfigurationManager.AppSettings["AuthByRemote"];
                if (string.IsNullOrEmpty(isAuthByRemote))
                {
                    isAuthByRemote = "0";
                }


                if (isAuthByRemote.Equals("1"))
                {
                    //objStr = mss.GetUserByLoginName(loginName);
                    bool isUser = mss.IsUserExist(loginName);

                    //表里没有用户,调用集成验证
                    if (!isUser)
                    {
                        return AuthUserByRequest(loginName, password, IPAddress, ref returnObj, true);
                    }
                    else
                    {
                        objStr = mss.GetUserByLoginName(loginName);
                        object o = sof.DesializeFromBase64(objStr);
                        QJVRMS.Business.User user = (QJVRMS.Business.User)o;

                        returnObj = user;
                        //用户不是系统管理员,调用集成验证
                        string superAdminId = ConfigurationManager.AppSettings["superAdminId"];
                        if (user.UserId.ToString().ToLower() != superAdminId.ToLower())
                        {
                            return AuthUserByRequest(loginName, password, IPAddress, ref returnObj, false);
                        }
                        else
                        { 
                            //是管理员,调用数据库验证
                            objStr = mss.AuthUserByForm(loginName, password, IPAddress);
                            if(string.IsNullOrEmpty(objStr))
                            {
                                return false;
                            }
                            else
                            {
                                object o1 = sof.DesializeFromBase64(objStr);
                                QJVRMS.Business.User user1 = (QJVRMS.Business.User)o1;
                                returnObj = user1;
                                return true;    
                            }
                        }

                        //returnObj = user;

                        return true;
                    }
                }
                else
                {
                    objStr = mss.AuthUserByForm(loginName, password, IPAddress);
                    object o = sof.DesializeFromBase64(objStr);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)o;
                    returnObj = user;
                    return true;                
                }




            }
            catch(Exception ex)
            {
                LogWriter.WriteExceptionLog(ex);
                return false;
            }


        }