Пример #1
0
        static public List <KeyValuePair <int, string> > getReportsOfThisUser(string email)
        {
            try
            {
                databaseLayer.myConnection.Open();
                userAccountTable user            = findUserByEmail(email);
                Int32            ID              = user.ID;
                SqlCommand       myCommand       = new SqlCommand("select report.reportID, ApkInfo.apkName , ApkInfo.packageName , ApkInfo.versionCode , report.reportDate from report inner join ApkInfo on report.apkInfoID=ApkInfo.apkID where report.userAccountID=@y", databaseLayer.myConnection);
                SqlParameter     secondParamater = new SqlParameter("@y", ID);
                myCommand.Parameters.Add(secondParamater);
                SqlDataReader reader = myCommand.ExecuteReader();
                List <KeyValuePair <int, string> > reportsID = new List <KeyValuePair <int, string> >();
                while (reader.Read())
                {
                    Int32  Id = (Int32)reader[0];
                    string concatinatedInfo = "";
                    concatinatedInfo += reader[1].ToString() + "#";
                    concatinatedInfo += reader[2].ToString() + "#";
                    concatinatedInfo += reader[3].ToString() + "#";
                    concatinatedInfo += reader[4].ToString();

                    reportsID.Add(new KeyValuePair <int, string>(Id, concatinatedInfo));
                }
                reader.Dispose();
                databaseLayer.myConnection.Close();

                return(reportsID);
            }
            catch
            {
                databaseLayer.myConnection.Close();
                return(null);
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session.Timeout = 80;
                androDatabase   = new databaseLayer();

                if (Request.UrlReferrer == null && Request.Cookies["androUsername"] != null && Request.Cookies["androPassword"] != null)
                {
                    Session["tempUsername"] = Request.Cookies["androUsername"].Value;
                    Session["password"]     = Request.Cookies["androPassword"].Value;
                    Session["userAccount"]  = userAccountTable.userLogin(Request.Cookies["androUsername"].Value.ToString(), Request.Cookies["androPassword"].Value.ToString());
                    userAccountTable test = (userAccountTable)Session["userAccount"];
                    handleLogin();
                }
            }
        }
Пример #3
0
 static public userAccountTable findUserByFBID(long fbID)
 {
     try
     {
         bool close = false;
         if (databaseLayer.myConnection.State == System.Data.ConnectionState.Closed)
         {
             databaseLayer.myConnection.Open();
             close = true;
         }
         SqlCommand   myCommand      = new SqlCommand("Select * from userAccount where facebookUserID =@y", databaseLayer.myConnection);
         SqlParameter firstParamater = new SqlParameter("@y", fbID);
         myCommand.Parameters.Add(firstParamater);
         SqlDataReader reader = myCommand.ExecuteReader();
         if (reader.Read())
         {
             Int32            ID        = (Int32)reader[0];
             DateTime         date      = (DateTime)reader[1];
             String           password  = (String)reader[2];
             String           Email     = (String)reader[3];
             String           firstName = (String)reader[4];
             String           lastName  = (String)reader[5];
             long             fb        = (long)reader[6];
             userAccountTable user      = new userAccountTable(ID, date, password, Email, firstName, lastName, fb);
             reader.Dispose();
             if (close)
             {
                 databaseLayer.myConnection.Close();
             }
             return(user);
         }
         else
         {
             if (close)
             {
                 databaseLayer.myConnection.Close();
             }
             return(null);
         }
     }
     catch
     {
         //databaseLayer.myConnection.Close();
         return(null);
     }
 }
Пример #4
0
        } //tested

        static public userAccountTable userLogin(string Email, string password)
        {
            try
            {
                databaseLayer.myConnection.Open();
                SqlCommand   checkExistenceOfUser = new SqlCommand("select userID from userAccount where email=@y and password=@x", databaseLayer.myConnection);
                SqlParameter Paramater            = new SqlParameter("@y", Email);
                SqlParameter secondParamater      = new SqlParameter("@x", password);
                checkExistenceOfUser.Parameters.Add(Paramater);
                checkExistenceOfUser.Parameters.Add(secondParamater);
                checkExistenceOfUser.ExecuteNonQuery();
                SqlDataReader reader = checkExistenceOfUser.ExecuteReader();
                if (reader.Read())
                {
                    SqlCommand   myCommand      = new SqlCommand("Select userID,lastLoginDate,password,email,firstName,lastName,facebookUserID from userAccount where email=@y AND password=@z", databaseLayer.myConnection);
                    SqlParameter thirdParamater = new SqlParameter("@y", Email);
                    SqlParameter forthParamater = new SqlParameter("@z", password);
                    myCommand.Parameters.Add(thirdParamater);
                    myCommand.Parameters.Add(forthParamater);
                    reader.Dispose();
                    SqlDataReader myReader = myCommand.ExecuteReader();
                    myReader.Read();
                    Int32            userID        = (Int32)myReader[0];
                    DateTime         lastLoginDate = (DateTime)myReader[1];
                    String           userPassword  = (String)myReader[2];
                    String           email         = (String)myReader[3];
                    String           firstName     = (String)myReader[4];
                    String           lastName      = (String)myReader[5];
                    long             fb            = (long)myReader[6];
                    userAccountTable user          = new userAccountTable(userID, lastLoginDate, userPassword, email, firstName, lastName, fb);
                    reader.Dispose();
                    databaseLayer.myConnection.Close();
                    return(user);
                }
            }
            catch (System.InvalidOperationException)
            {
                databaseLayer.myConnection.Close();
                return(null);
            }
            databaseLayer.myConnection.Close();
            return(null);
        } //tested