Example #1
0
 private string[] GetCookieUserInfo()
 {
     string[] CookieValue = new string[0];
     CookieValue = "|||||".Split(new char[] { '|' });
     try
     {
         if (System.Web.HttpContext.Current.Request.Cookies[_CookieUserInfo] != null)
         {
             //CookieValue = rijndaelKey.Decrypt(System.Web.HttpContext.Current.Request.Cookies[_CookieUserInfo].Value.ToString()).Split(new char[] { '|' });
             return(CookieValue);
         }
         //else
         //    CookieValue = "|||||".Split(new char[] { '|' });
         var current = new object();
         var isLogin = HttpContext.Current.User.Identity.Name;
         if (string.IsNullOrEmpty(isLogin))
         {
             return(CookieValue);
         }
         current = isLogin;
         if (current == null)
         {
             return(CookieValue);
         }
         CookieValue = rijndaelKey.Decrypt(current.ToString()).Split(new char[] { '|' });
     }
     catch (Exception ex)
     {
         NLogLogger.LogInfo("_CookieUserInfo Exception null");
         CookieValue = "|||||".Split(new char[] { '|' });
         NLogLogger.PublishException(ex);
     }
     return(CookieValue);
 }
Example #2
0
        public JsonResult Login(string Username, string Password)
        {
            try
            {
                NLogLogger.LogInfo("Login-->Username:"******"Dữ liệu không được bỏ trống" }));
                }
                var password = Encrypt.Md5(Password.Trim());

                int checkLogin = AbstractDAOFactory.Instance().CreateUsersDAO().Authentication(Username.Trim(), password);
                if (checkLogin == -49)
                {
                    return(Json(new { success = false, statusCode = -102, msg = "Tài khoản của bạn đã bị block" }));
                }
                else if (checkLogin == -50)
                {
                    return(Json(new { success = false, statusCode = -102, msg = "Tài khoản của bạn chưa được cấp quyền" }));
                }
                else if (checkLogin == -53)
                {
                    return(Json(new { success = false, statusCode = -102, msg = "Mật khẩu không chính xác" }));
                }
                else if (checkLogin > 0)
                {
                    var m_Users = AbstractDAOFactory.Instance().CreateUsersDAO().GetByUsername(Username);
                    if (m_Users != null && m_Users.UserID > 0)
                    {
                        var Log = new UsersLog();
                        Log.ClientIP     = Config.GetIP();
                        Log.FunctionID   = 9999;
                        Log.UserID       = m_Users.UserID;
                        Log.LogType      = 1;
                        Log.FunctionName = "Đăng Nhập Hệ Thống";
                        Log.Description  = "Tài khoản " + m_Users.Username + " Đăng nhập hệ thống";
                        var insertLog = AbstractDAOFactory.Instance().CreateUsersLogDAO().InsertUsersLog(Log);

                        if (m_Users.Status)
                        {
                            Session["LoginType"] = 1;
                            string SessionID = Session.SessionID;
                            m_UserValidation.SignIn(m_Users.UserID, m_Users.Username, m_Users.IsAdministrator, SessionID);
                            var UrlRedirect = Config.UrlRoot; // Session["Redirect_Uri"] == null ? Config.UrlRoot : Server.UrlDecode(Session["Redirect_Uri"].ToString());
                            NLogLogger.LogInfo("UrlRedirect : " + UrlRedirect);
                            return(Json(new { success = true, statusCode = 1, msg = "Đăng Nhập Thành Công", url = UrlRedirect }));
                        }
                        return(Json(new { success = false, statusCode = -102, msg = "Tài khoản của bạn đã bị block" }));
                    }
                }
                return(Json(new { success = false, statusCode = -1, msg = "Username hoặc Password không đúng" }));
            }
            catch (Exception ex)
            {
                NLogLogger.PublishException(ex);
                return(Json(new { success = false, statusCode = -99, msg = "Hệ thống bận vui lòng quay lại sau" }));
            }
        }
Example #3
0
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                var account = new VTCeBank.SSO.Utils.Account(Request);
                NLogLogger.LogInfo("account.AccountName: " + account.AccountName);

                if (string.IsNullOrEmpty(account.AccountName))
                {
                    // Response.Redirect(SSOMAIL.SsoHelper.URLLoginMail);
                }
                else
                {
                    var pos = account.AccountName.IndexOf("@");
                    if (pos > 0)
                    {
                        account.AccountName = account.AccountName.Substring(0, pos);
                    }
                    var m_Users = AbstractDAOFactory.Instance().CreateUsersDAO().GetByUsername(account.AccountName);
                    if (m_Users != null && m_Users.UserID > 0)
                    {
                        var Log = new UsersLog();
                        Log.FunctionID   = 9999;
                        Log.ClientIP     = Config.GetIP();
                        Log.UserID       = m_Users.UserID;
                        Log.LogType      = 1;
                        Log.FunctionName = "Đăng Nhập Hệ Thống";
                        Log.Description  = "Tài khoản " + m_Users.Username + " Đăng nhập hệ thống";
                        var insertLog = AbstractDAOFactory.Instance().CreateUsersLogDAO().InsertUsersLog(Log);

                        if (m_Users.Status)
                        {
                            //Session[SessionsManager.SESSION_USERID] = m_Users.UserID;
                            //Session[SessionsManager.SESSION_USERNAME] = m_Users.Username;
                            //Session["LoginType"] = 0;
                            string SessionID = Session.SessionID;
                            m_UserValidation.SignIn(m_Users.UserID, m_Users.Username, m_Users.IsAdministrator, SessionID);
                            Url = Session["Redirect_Uri"] == null ? UrlRoot : Server.UrlDecode(Session["Redirect_Uri"].ToString());
                            Response.Redirect(Url);
                        }
                        Response.Redirect("Common/ErrorPermission");
                    }
                    Response.Redirect("Common/ErrorPermission");
                }
            }
            catch (Exception ex)
            {
                NLogLogger.PublishException(ex);
            }
            finally
            {
                Response.End();
            }
        }
Example #4
0
 /// Check quyền người dùng khi truy cập chức năng
 /// <param name="UserID"></param>
 /// <param name="FunctionID"></param>
 /// <returns></returns>
 public UserFunction CheckPermission(int UserID, string ActionName)
 {
     try
     {
         var pars = new SqlParameter[2];
         pars[0] = new SqlParameter("@_UserID", UserID);
         pars[1] = new SqlParameter("@_ActionName", ActionName);
         var result = new DBHelper(Config.Site1400ConnectionString).GetInstanceSP <UserFunction>("SP_CheckPermission", pars);
         return(result);
     }
     catch (Exception e)
     {
         NLogLogger.PublishException(e);
         return(null);
     }
 }
Example #5
0
        public static string GenerateSign(string dataSign, string keySign)
        {
            var sign = string.Empty;

            try
            {
                var ticks         = DateTime.Now.Ticks;
                var plaintextSign = string.Format("{0}|{1}|{2}", dataSign, keySign, ticks);
                sign = string.Format("{0}.{1}", ticks, W1400.Utility.Security.Encrypt.Md5(plaintextSign));
                return(sign);
            }
            catch (Exception ex)
            {
                NLogLogger.PublishException(ex);
                return(sign);
            }
        }
Example #6
0
 /// <summary>
 /// Lấy dữ liệu test theo
 /// </summary>
 /// <param name="accountId"></param>
 /// <param name="betType"></param>
 /// <returns></returns>
 public string GetSlotData(int accountId, int betType)
 {
     try
     {
         var pars = new SqlParameter[3];
         pars[0] = new SqlParameter("@_AccountID", accountId);
         pars[1] = new SqlParameter("@_SlotData", SqlDbType.NVarChar, 50)
         {
             Direction = ParameterDirection.Output
         };
         pars[2] = new SqlParameter("@_BetType", betType);
         new DBHelper(ConnectionString.GameConnectionString).ExecuteNonQuerySP("SP_SlotData_Get", pars);
         return(pars[1].Value.ToString());
     }
     catch (Exception e)
     {
         NLogLogger.PublishException(e);
         return(string.Empty);
     }
 }
Example #7
0
        public virtual bool IsSigned()
        {
            try
            {
                //this.Get();
                NLogLogger.LogInfo(this._UserName + " - " + this._ClientIP + " - " + this._IsExpires);
                bool bLoged = (this._UserName.Length > 0 && this._ClientIP.Length > 0 && !this._IsExpires);
                if (bLoged)
                {
                    this.SetCookieUserInfo(this._UserId, this._UserName, this._IsAdministrator, this._SessionID);
                }
                return(bLoged);
            }
            catch (Exception ex)
            {
                NLogLogger.PublishException(ex);
                SignOut();

                return(false);
            }
        }
Example #8
0
        /// <summary>
        /// Set dữ liệu test
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="slotData"></param>
        /// <param name="betType"></param>
        /// <returns></returns>
        public int SetSlotData(int accountId, string slotData, int betType)
        {
            try
            {
                var pars = new SqlParameter[4];
                pars[0] = new SqlParameter("@_AccountID", accountId);
                pars[1] = new SqlParameter("@_SlotData", slotData);
                pars[2] = new SqlParameter("@_BetType", betType);
                pars[3] = new SqlParameter("@_ResponseStatus", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                };

                new DBHelper(ConnectionString.GameConnectionString).ExecuteNonQuerySP("SP_SlotData_Set", pars);

                return((int)pars[3].Value);
            }
            catch (Exception e)
            {
                NLogLogger.PublishException(e);
                return(-99);
            }
        }
Example #9
0
        public SSOInfo Get()
        {
            try
            {
                string[] CookieValueArray = GetCookieUserInfo();
                int.TryParse(CookieValueArray[0], out _UserId);
                _UserName = CookieValueArray[1];
                bool.TryParse(CookieValueArray[2], out _IsAdministrator); //_IsAdministrator = Convert.ToBoolean();
                _SessionID = CookieValueArray[3];
                _ClientIP  = CookieValueArray[4];
                if (!String.IsNullOrEmpty(CookieValueArray[5]) && DateTime.Parse(CookieValueArray[5]) > DateTime.Now)
                {
                    _IsExpires = false;
                }
            }
            catch (Exception ex)
            {
                NLogLogger.PublishException(ex);
                throw;
            }

            return(this);
        }