diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index 5d92bc6..5f8e712 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -914,6 +914,10 @@ namespace EduNetworkBuilder { return ValidateString(password, AllowedUsernameCharacters); } + public static bool ValidateFullName(string password) + { + return ValidateString(password, AllowedUsernameCharacters + " "); + } } } diff --git a/EduNetworkBuilder/PersonProfileForm.cs b/EduNetworkBuilder/PersonProfileForm.cs index e0a07ab..728c319 100644 --- a/EduNetworkBuilder/PersonProfileForm.cs +++ b/EduNetworkBuilder/PersonProfileForm.cs @@ -408,8 +408,12 @@ namespace EduNetworkBuilder if (result == System.Windows.Forms.DialogResult.Cancel) return; List tList = new List(); + List InvalidUsers = new List(); + List InvalidFullName = new List(); + List InvalidPasswords = new List(); //Now we have a csv file. Try to parse it + bool HadError = false; using (TextFieldParser parser = new TextFieldParser(mydialog.FileName)) { parser.TextFieldType = FieldType.Delimited; @@ -423,14 +427,54 @@ namespace EduNetworkBuilder foreach (string field in fields) { //TODO: Process field - if (index == 0) TStudent.Name = field; - if (index == 1) TStudent.FullName = field; - if (index == 2) TStudent.Password = field; + if (index == 0) + { + TStudent.Name = field; + if (!NB.ValidateUsername(field)) + { + HadError = true; + InvalidUsers.Add(TStudent.Name); + } + + } + if (index == 1) + { + TStudent.FullName = field; + if (!NB.ValidateFullName(field)) + { + HadError = true; + InvalidFullName.Add(TStudent.Name); + } + } + if (index == 2) + { + TStudent.Password = field; + if (!NB.ValidatePassword(field)) + { + HadError = true; + InvalidPasswords.Add(TStudent.Name); + } + } index++; //Track which field we are in. } tList.Add(TStudent); } } + if(HadError) + { + ShowInvalid("Username", InvalidUsers); + ShowInvalid("Full Name", InvalidFullName); + ShowInvalid("Password", InvalidPasswords); + } + } + + private void ShowInvalid(string What, List BadUsers) + { + if (BadUsers.Count < 1) return; + string message = NB.Translate("PPF_NoImportInvalid") + ": " + What; + foreach (string one in BadUsers) + message += "\n" + one; + MessageBox.Show(message); } } } \ No newline at end of file diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index d465bd3..15e4937 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -1781,4 +1781,8 @@ Launch PPF_Launch = Launch + + Error. Could not import students. List of invalid + PPF_NoImportInvalid = Error. Could not import students. List of invalid + \ No newline at end of file