Пример #1
0
        /// <summary>
        /// 修改学生手机号或联系人手机号,将手机号信息推送至家校互联账户
        /// <para>作     者:蔡亚康 </para>
        /// <para>创建时间: 2019-03-21 </para>
        /// </summary>
        /// <param name="rawStudent">原学生信息</param>
        /// <param name="newStudent">新学生信息</param>
        /// <param name="rawContacts">原学生联系人信息</param>
        /// <param name="newContacts">新学生联系人信息</param>
        private static void StudentPublish(TblCstStudent rawStudent, TblCstStudent newStudent, List <TblCstStudentContact> rawContacts, List <TblCstStudentContact> newContacts)
        {
            StudentPassportChangeInDto result = new StudentPassportChangeInDto();

            List <string> rawMobiles = new List <string>();   //原手机号
            List <string> newMobiles = new List <string>();   //新手机号


            //原手机号集合
            rawMobiles.Add(rawStudent.LinkMobile);
            rawMobiles.AddRange(rawContacts.Select(t => t.Mobile));
            rawMobiles = rawMobiles.Where(t => !string.IsNullOrEmpty(t))
                         .Distinct()
                         .ToList();


            //新手机号集合
            newMobiles.Add(newStudent.LinkMobile);
            newMobiles.AddRange(newContacts.Select(t => t.Mobile));
            newMobiles = newMobiles.Where(t => !string.IsNullOrEmpty(t))
                         .Distinct()
                         .ToList();


            result.MobileAddList    = newMobiles.Except(rawMobiles).ToList();
            result.MobileDeleteList = rawMobiles.Except(newMobiles).ToList();


            //获取手机号在在其他学生的账户列表
            TblCstStudentRepository        studentRepository = new TblCstStudentRepository();
            TblCstStudentContactRepository contactRepository = new TblCstStudentContactRepository();

            var studentList = studentRepository.SearchByMobiles(result.MobileDeleteList);
            var contactList = contactRepository.SearchByMobiles(result.MobileDeleteList);


            //被删除的号码,在studentList,contactList 还存在,说明还不允许删除
            List <string> existMobiles = new List <string>();

            existMobiles.AddRange(studentList.Select(t => t.LinkMobile));
            existMobiles.AddRange(contactList.Select(t => t.Mobile));
            existMobiles = existMobiles.Distinct().ToList();


            existMobiles.ForEach(item =>
            {
                result.MobileDeleteList.Remove(item);
            });

            // 推送至消息队列
            new StudentFamilyProducerService().Publish(result);
        }
Пример #2
0
        /// <summary>
        /// 学生注册
        /// <para>作     者:Huang GaoLiang </para>
        /// <para>创建时间: 2018-10-29 </para>
        /// </summary>
        /// <param name="request">学生注册提交数据</param>
        public string Register(StudentRegisterRequest request)
        {
            long studentId = IdGenerator.NextId();

            // 1、数据合法性验证
            Verification(0, request.StudentName, request.LinkMobile);

            // 2、处理电话号码和监护人信息
            string contactPersonMobile = ContactPersonMobile(request.ContactPerson);

            // 3、获取学生数据
            TblCstStudent student = this.GetStudent(request, studentId, contactPersonMobile);

            _studentRepository.Value.Add(student);

            // 4、构造学生联系人
            List <TblCstStudentContact> studentContactList = GetStudentContact(student.StudentId, student.ContactPerson);

            _studentContactRepository.Value.Add(studentContactList);

            // 5、推送学生至档案库
            StudentRequest s = GetStudentToAC(student);

            new ACService().StudentInfoToArtLibrary(s);

            // 6、将学生的家长账号保存推送至家校互联账户
            // 学生注册,学长的账号只会增加不会存在删除用。
            StudentPassportChangeInDto passportChangeInDto = new StudentPassportChangeInDto();

            passportChangeInDto.MobileAddList = new List <string>();
            passportChangeInDto.MobileAddList.Add(request.LinkMobile);
            passportChangeInDto.MobileAddList.AddRange(studentContactList.Select(t => t.Mobile));
            passportChangeInDto.MobileAddList = passportChangeInDto.MobileAddList.Distinct().ToList();
            new StudentFamilyProducerService().Publish(passportChangeInDto);

            return(studentId.ToString());
        }
Пример #3
0
 /// <summary>
 /// 发送一组消息推送
 /// <para>作    者:蔡亚康</para>
 /// <para>创建时间:2019-03-14</para>
 /// </summary>
 /// <param name="data">一组消息</param>
 public void Publish(StudentPassportChangeInDto data)
 {
     //当前采用线程池的线程处理!
     //后续家校互联独立后,才会考虑使用消息队列!
     Task.Run(() =>
     {
         TblHssPassportRepository repository = new TblHssPassportRepository();
         if (data.MobileAddList != null)
         {
             foreach (string mobile in data.MobileAddList)
             {
                 this.AddMobile(mobile, repository);
             }
         }
         if (data.MobileDeleteList != null)
         {
             foreach (string mobile in data.MobileDeleteList)
             {
                 repository.DeleteByUserCode(mobile);
             }
         }
     });
     //base.SendMessage(data);
 }