//Costruttori //Da valutare se rendere privato -> nuovo user solo attraverso la funzione di Login private User(string nome, string password) : base() { //Console.Write("Creo un utente: nome ->"+nome+"; pass->"+password+"\n"); string[][] parameters = new string[2][]; parameters[0] = new string[2] { "@nome", nome }; parameters[1] = new string[2] { "@password", password }; int quantita = 0; this.ExecuteQuery(sql_get_user_data, parameters); //Get the data foreach (int i in this.GetResults()) { this.__nome = (string)(this.ResultGetValue("nome")); quantita = i; } //i contiene il numero di risultati; if (quantita < 1) { throw new DatabaseException("Utente non trovato", DatabaseErrorCode.UserNonEsistente); } else if (quantita > 1) { throw new DatabaseException("Panic! More than one user with same password and name or sql wrong", DatabaseErrorCode.UserNonEsistente); } //Create the snapshot list __s_list = new FileUtenteList(this.__nome); }
//Costruttori //Da valutare se rendere privato -> nuovo user solo attraverso la funzione di Login private User(string nome, string password) : base() { //Console.Write("Creo un utente: nome ->"+nome+"; pass->"+password+"\n"); string[][] parameters = new string[2][]; parameters[0] = new string[2] { "@nome", nome }; parameters[1] = new string[2] { "@password", password }; int quantita = 0; this.ExecuteQuery(sql_get_user_data, parameters); //Get the data foreach (int i in this.GetResults()) { this.__nome = (string)(this.ResultGetValue("nome")); quantita = i; } //i contiene il numero di risultati; if(quantita < 1){ throw new DatabaseException("Utente non trovato",DatabaseErrorCode.UserNonEsistente); } else if (quantita > 1) { throw new DatabaseException("Panic! More than one user with same password and name or sql wrong", DatabaseErrorCode.UserNonEsistente); } //Create the snapshot list __s_list = new FileUtenteList(this.__nome); }
//Metodi internal void Logout() { //Logout... this.__nome = null; this.__password = null; this.__s_list = null; }