コード例 #1
0
        public static List <int> createTmUsers(this TM_UserData userData, string batchUserData)
        {
            var newUsers = new List <NewUser>();

            foreach (var line in batchUserData.fix_CRLF().split_onLines())
            {
                var newUser = new NewUser();
                //return _newUser;
                var items = line.split(",");

                newUser.Username  = items.size() > 0 ? items[0].trim() : "";
                newUser.Password  = items.size() > 1 ? items[1].trim() : "";
                newUser.Firstname = items.size() > 2 ? items[2].trim() : "";
                newUser.Lastname  = items.size() > 3 ? items[3].trim() : "";
                newUser.GroupId   = items.size() > 4 ? items[4].trim().toInt() : 0;

                //default values
                newUser.Company = "...";
                newUser.Country = "...";
                newUser.Email   = "{0}@randomm.xyz".format(10.randomLetters());
                newUser.Note    = "(Batch user created)";
                newUser.State   = "...";
                newUser.Title   = "...";
                if (newUser.validation_Failed())
                {
                    "[createTmUsers] failed validation for user data:{0}".error(newUser.toXml());
                    newUsers.Add(null);
                }
                else
                {
                    newUsers.Add(newUser);
                }
            }
            return(userData.createTmUsers(newUsers));
        }