Exemplo n.º 1
0
 public bool UserAction(string userName, Restrictions action)
 {
     lock (Database.lockObjectDB)
     {
         if (userName.Length == 0)
         {
             return(false);
         }
         if (userName == "AkBarsAdmin" || userName == "UzcardAdmin")
         {
             if (action == Restrictions.Transport)
             {
                 return(false);
             }
             return(true);
         }
         //любая страница начинается здесь, поэтому здесь проверяем на активность коннекта
         if (Database.Conn == null || Database.Conn.State != ConnectionState.Open)
         {
             Database.Connect(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
             FormsAuthentication.SignOut();
             FormsAuthentication.RedirectToLoginPage();
         }
         if (Database2.Conn == null || Database2.Conn.State != ConnectionState.Open)
         {
             Database2.Connect(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
         }
         object obj = null;
         string res = Database.ExecuteScalar($"select activepassword from aspnet_Users where username='******'", ref obj, null);
         if (!(bool)obj)
         {
             return(false);
         }
         res = Database.ExecuteScalar(String.Format("select count(*) from V_UserAction where UserName='******' and ActionId={1}", userName, (int)action), ref obj, null);
         return((int)obj > 0);
     }
 }