public static void trackuser(User user, string connectionstring, string type)
        {
            using(OleDbConnection conn = new OleDbConnection(connectionstring))
              {

              using (var command = new OleDbCommand())
              {
                  conn.Open();
                  command.Connection = conn;
                  command.CommandType = System.Data.CommandType.Text;
                  command.CommandText = "INSERT INTO TRACKING ([username], [firstname], [lastname], [email], [course], [group], [type]) VALUES (?,?,?,?,?,?,?)";

                  command.Parameters.Add("?", OleDbType.VarChar).Value = user.username;
                  command.Parameters.Add("?", OleDbType.VarChar).Value = user.firstname;
                  command.Parameters.Add("?", OleDbType.VarChar).Value = user.lastname;
                  command.Parameters.Add("?", OleDbType.VarChar).Value = user.email;
                  command.Parameters.Add("?", OleDbType.VarChar).Value = user.course1;
                  command.Parameters.Add("?", OleDbType.VarChar).Value = user.group1;
                  command.Parameters.Add("?", OleDbType.Integer).Value = (type.Equals("profesores")) ? 3 : 1;

                  command.ExecuteNonQuery();
              }

              }
        }
        public Extraction getTeachers(string plantel, string connectionstring)
        {
            List<object[]> usersq = this.QueryFb(connectionstring, this.getTeacherQuery(plantel));

            if (usersq.Count > 0)
            {
                Console.WriteLine(string.Format("{0} profesores a subir...", usersq.Count));
                string planteldeco = this.plantel[0].ToString().ToUpper() + this.plantel.Substring(1);

                int cont = 0;
                foreach (object user in usersq)
                {
                    User MyUser = new User();
                    try
                    {
                        MyUser.username = usersq[cont][0].ToString();
                        MyUser.password = usersq[cont][0].ToString();
                        MyUser.firstname = "Profesor";
                        MyUser.lastname = usersq[cont][1].ToString();
                        MyUser.email = usersq[cont][2].ToString().ToLower();
                        MyUser.course1 = usersq[cont][4].ToString();
                        MyUser.group1 = string.Format("{0}-{1}", usersq[cont][3].ToString(), planteldeco);
                        MyUser.type1 = 3;

                    }
                    catch (Exception oe)
                    {
                        Console.WriteLine(oe.ToString());
                        this.Errors.Add(oe.Message.ToString());
                    }

                    try
                    {
                        bool isvalid = MyUser.isValid();
                        if (isvalid)
                        {
                            this.Users.Add(MyUser);
                            Console.WriteLine(string.Format("Se agrega {0} al envio...", MyUser.username));
                        }
                    }
                    catch (Exception oe)
                    {
                        this.Errors.Add(oe.Message.ToString());
                        Console.WriteLine(oe.Message.ToString());
                    }

                    cont++;
                }
            }

            return this;
        }
        public static bool uniqueinscription(User user, string connectionstring, string type)
        {
            bool val = false;

            using (OleDbConnection conn = new OleDbConnection(connectionstring))
            {
                using (var command = new OleDbCommand())
                {
                    conn.Open();
                    command.Connection = conn;
                    command.CommandType = System.Data.CommandType.Text;

                    string sqlcommand = "SELECT [username] FROM TRACKING WHERE [username] = ? AND [course] = ?";
                    if (type.Equals("profesores"))
                    {
                        sqlcommand = "SELECT [username] FROM TRACKING WHERE [username] = ? AND [course] = ? AND [group] = ?";
                    }

                    command.CommandText = sqlcommand;
                    command.Parameters.Add("?", OleDbType.VarChar).Value = user.username;
                    command.Parameters.Add("?", OleDbType.VarChar).Value = user.course1;

                    if (type.Equals("profesores"))
                    {
                        command.Parameters.Add("?", OleDbType.VarChar).Value = user.group1;
                    }

                    OleDbDataReader reader = command.ExecuteReader();
                    val = reader.HasRows;
                }
            }

            if (val)
            {
                Console.WriteLine(string.Format("El usuario {0} ya está inscrito en el curso {1}.", user.username, user.course1));
            }

            return val;
        }
        public void toREST()
        {
            //Moodle.Instance.token   = ConfigurationSettings.AppSettings["token"];
            //Moodle.Instance.domain = "elearning.univermilenium.edu.mx";

            //obtener id del curso
            //obtener id del grupo
            //obtener id del usuari
            //enrolar idusuario a curso
            //enrolar idusuario a grupo

            List<string> groups = new List<string>();
            List<string> errors = new List<string>();

            /*
                dummies users
             */

            this.Users = new List<User>();
            User dummy = new User();

            dummy.username  = "******";
            dummy.firstname = "crash";
            dummy.lastname  = "test dummy";
            dummy.password  = "******";
            dummy.email     = "*****@*****.**";
            dummy.course1   = "PRUEBA";
            dummy.group1    = "GRUPODUMMIES";
            dummy.type1     = 1;

            this.Users.Add(dummy);

            if (this.Users.Count() > 0)
            {
                foreach (User user in this.Users)
                {
                    try
                    {
                        //obtener id del curso.
                        MoodleCourse course = Moodle.Instance.getCourse(user.course1);

                        //crear - obtener grupo
                        if (Moodle.Instance.createGroup(course, user.course1, "Grupo para " + course.name))
                        {

                        }
                    }
                    catch
                    {
                        this.Errors.Add(user.toString());
                    }
                }
            }
        }