internal void AddUserToken(UserToken userToken) { // #1- Logger variables System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; string query = "INSERT INTO incuser(userName,password,token)"; query += "VALUES (@userName, @password, @token) "; Hashtable param = new Hashtable(); param.Add("@userName", userToken.User); param.Add("@password", userToken.Password); param.Add("@token", userToken.Token); // Comentario acá // #2- Logger pre query Logger.LogDebug("(%s) (%s) -- Ejecuta query para agregar un comentario al folio. QUERY: %s", className, methodName, query); }
public UserToken GetUserToken(string token) { // #1- Logger variables System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; UserToken userToken = null; string query = "SELECT userName, password FROM incuser WHERE token = @token"; Hashtable param = new Hashtable(); param.Add("@token", token); // #2- Logger pre query Logger.LogDebug("(%s) (%s) -- Ejecuta query para obtener un usuario por el token y en caso de encontrarlo lo limpia. QUERY: %s", className, methodName, query); using (DataTable dt = ExecuteDataTableQuery(query, param)) { if (dt != null && dt.Rows.Count > 0) { userToken = new UserToken(); userToken.Token = token; // #3- Logger post query Logger.LogDebug("Row count: %s", dt.Rows.Count.ToString()); foreach (DataRow dr in dt.Rows) { userToken.User = dr["userName"].ToString(); userToken.Password = dr["password"].ToString(); } // Clear user token ExecuteDataTableQuery("UPDATE incuser SET token = '' WHERE token = @token; ", param); } } return userToken; }