Пример #1
0
        public List <User> importUsers()
        {
            string      line;
            List <User> users = new List <User>();

            // Read the file and display it line by line.
            string fileName = GetDirectory.getFilePath() + @"\GST_Badge_System.DAO\Data\BadgeSystemPeople.csv";

            using (System.IO.StreamReader file = new System.IO.StreamReader(fileName))
            {
                file.ReadLine();    // Read to get rid of the first line
                while ((line = file.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                    String[] splittedFields = line.Split(',');

                    User temp_user = new User();

                    if (!String.IsNullOrEmpty(splittedFields[0]) &&
                        !String.IsNullOrEmpty(splittedFields[1]))
                    {
                        temp_user.User_Name  = splittedFields[0];
                        temp_user.User_Email = splittedFields[1];
                    }
                    else
                    {
                        throw new Exception("One or more parameters failed to parse!");
                    }

                    users.Add(temp_user);
                }
            }

            return(users);
        }
Пример #2
0
        // upload badges to the database
        public int uploadBadges()
        {
            using (var conn = new SqlConnection(connectionString))
            {
                // get the badge give type
                // Student to peer
                string path = GetDirectory.getFilePath() + @"\GST_Badge_System.DAO\Data\Student-Peer.csv";
                pushBadgeHelper(conn, "Student to peer", path);

                // Student to self
                path = GetDirectory.getFilePath() + @"\GST_Badge_System.DAO\Data\Student-Self.csv";
                pushBadgeHelper(conn, "Student to self", path);

                // Faculty to student
                path = GetDirectory.getFilePath() + @"\GST_Badge_System.DAO\Data\Faculty-Student.csv";
                pushBadgeHelper(conn, "Faculty to student", path);

                // Staff to student
                path = GetDirectory.getFilePath() + @"\GST_Badge_System.DAO\Data\Staff-Student.csv";
                pushBadgeHelper(conn, "Staff to student", path);
            }
            return(1);
        }