Esempio n. 1
0
 public bool TeacherAdd(Entities db, Guid campusId, Guid departmentId, int ordinal, string name, string phone, string passwordInitial, State state, string email, string idCard, bool? gender, DateTime? birthday, string nationality, string birthplace, string address, string account, bool? perstaff, bool sync, out Guid gid, string ex)
 {
     gid = db.GetId();
     try
     {
         string key, salt;
         var password = HomoryCryptor.Encrypt(passwordInitial, out key, out salt);
         var user = new User
         {
             Id = gid,
             Account = account,
             RealName = name,
             DisplayName = name,
             Stamp = Guid.NewGuid(),
             Type = UserType.教师,
             Password = password,
             PasswordEx = null,
             CryptoKey = key,
             CryptoSalt = salt,
             Icon = "~/CommonX/默认/用户.png",
             State = state,
             Ordinal = ordinal,
             Description = null
         };
         var userTeacher = new Homory.Model.Teacher
         {
             Id = user.Id,
             Phone = phone,
             Email = email,
             Gender = gender,
             Birthday = birthday,
             Birthplace = birthplace,
             Address = address,
             Nationality = nationality,
             IDCard = idCard,
             PerStaff = perstaff ?? true,
             Sync = sync
         };
         var relation = new DepartmentUser
         {
             DepartmentId = departmentId,
             UserId = user.Id,
             TopDepartmentId = campusId,
             Type = DepartmentUserType.部门主职教师,
             State = State.启用,
             Ordinal = 0,
             Time = DateTime.Now
         };
         db.User.Add(user);
         db.Teacher.Add(userTeacher);
         db.DepartmentUser.Add(relation);
         db.SaveChanges();
         try { UserHelper.InsertUserEx(name, "C984AED014AEC7623A54F0591DA07A85FD4B762D", sync, state, account, departmentId.ToString().ToUpper(), gid.ToString().ToUpper(), phone, idCard, ordinal, 0, "1000", ex); } catch { }
         return true;
     }
     catch
     {
         return false;
     }
 }
Esempio n. 2
0
 public bool StudentAdd(Entities db, Guid campusId, Guid classId, int ordinal, string name, string account, string passwordInitial, State state, string uniqueId, string idCard, bool? gender, DateTime? birthday, string nationality, string birthplace, string address, string charger, string chargerContact)
 {
     try
     {
         string key, salt;
         var password = HomoryCryptor.Encrypt(passwordInitial, out key, out salt);
         var user = new User
         {
             Id = db.GetId(),
             Account = account,
             RealName = name,
             DisplayName = name,
             Stamp = Guid.NewGuid(),
             Type = UserType.学生,
             Password = password,
             PasswordEx = null,
             CryptoKey = key,
             CryptoSalt = salt,
             Icon = "~/Common/默认/用户.png",
             State = state,
             Ordinal = ordinal,
             Description = null
         };
         var userStudent = new Homory.Model.Student
         {
             Id = user.Id,
             UniqueId = uniqueId,
             Gender = gender,
             Birthday = birthday,
             Birthplace = birthplace,
             Address = address,
             Nationality = nationality,
             IDCard = idCard,
             Charger = charger,
             ChargerContact = chargerContact
         };
         var relation = new DepartmentUser
         {
             DepartmentId = classId,
             UserId = user.Id,
             TopDepartmentId = campusId,
             Type = DepartmentUserType.班级学生,
             State = State.启用,
             Ordinal = 0,
             Time = DateTime.Now
         };
         db.User.Add(user);
         db.Student.Add(userStudent);
         db.DepartmentUser.Add(relation);
         return true;
     }
     catch
     {
         return false;
     }
 }