Пример #1
0
 private void ProcessProfessors()
 {
     using (UserRepository repo = new UserRepository())
     {
         foreach(var u in repo.GetAllUserInfo())
         {
             try
             {
                 ProfessorIndex index = ProfessorManager.GenObject(u.uuid);
                 if(index!=null)
                     ProfessorManager.AddOrUpdate(index);
             }
             catch(Exception ex)
             {
                 LogHelper.LogErrorAsync(typeof(Service1), ex);
             }
         }
     }
 }
Пример #2
0
        private void ProcessData()
        {
            int count = 0;
            using (UserRepository userRepo = new UserRepository())
            {
                using (SystemRepository repo = new SystemRepository())
                {
                    foreach (var u in userRepo.GetAllUserInfo())
                    {
                        Univs univs=null;
                        if (!string.IsNullOrEmpty(u.Unit))
                        {
                            string xuexiao = u.Unit;
                            univs = repo.GetUnivIdByName(xuexiao);
                            if(univs!=null)
                            {
                                try
                                {
                                    //更新uuid到学校的zset
                                    double score = Convert.ToDouble(univs.UnivsID);
                                    _redis.SetScore<NameCardRedis, UnivZsetAttribute>(u.uuid.ToString().ToUpper(), score);

                                    //更新到教授
                                    if(u.IsBusiness==0)
                                        _redis.SetScore<NameCardRedis, UnivProfessorZsetAttribute>(u.uuid.ToString().ToUpper(), score);
                                    //更新到学生
                                    if (u.IsBusiness == 2)
                                        _redis.SetScore<NameCardRedis, UnivStudentZsetAttribute>(u.uuid.ToString().ToUpper(), score);

                                }
                                catch(Exception ex)
                                {
                                    LogHelper.LogErrorAsync(typeof(Service1), ex);
                                }
                            }
                            else
                            {
                                //如果没有找到则什么都不做
                            }
                        }

                        //学院zset
                        if (!string.IsNullOrEmpty(u.Faculty))
                        {
                            string xueyuan = u.Faculty;
                            var dept =repo.GetDepByName(univs,xueyuan);
                            if (dept != null)
                            {
                                try
                                {
                                    double score = Convert.ToDouble(dept.ID);
                                    //更新整体
                                    _redis.SetScore<NameCardRedis, DeptZsetAttribute>(u.uuid.ToString().ToUpper(), score);

                                    //更新教授
                                    if (u.IsBusiness == 0)
                                        _redis.SetScore<NameCardRedis, DeptProfessorZsetAttribute>(u.uuid.ToString().ToUpper(), score);
                                    //更新学生
                                    if (u.IsBusiness == 2)
                                        _redis.SetScore<NameCardRedis, DeptStudentZsetAttribute>(u.uuid.ToString().ToUpper(), score);
                                }
                                catch(Exception ex)
                                {
                                    LogHelper.LogErrorAsync(typeof(Service1), ex);
                                }
                            }
                        }

                        //专业与研究领域zset
                        if (u.ResearchFieldId!=null)
                        {
                            try
                            {
                                double score = Convert.ToDouble(u.ResearchFieldId);

                                //更新整体
                                _redis.SetScore<NameCardRedis, ResearchFieldZsetAttribute>(u.uuid.ToString().ToUpper(), score);
                                //更新教授
                                if (u.IsBusiness == 0)
                                    _redis.SetScore<NameCardRedis, ResearchFieldProfessorZsetAttribute>(u.uuid.ToString().ToUpper(), score);
                                //更新学生
                                if (u.IsBusiness == 2)
                                    _redis.SetScore<NameCardRedis, ResearchFieldStudentZsetAttribute>(u.uuid.ToString().ToUpper(), score);
                            }
                            catch (Exception ex)
                            {
                                LogHelper.LogErrorAsync(typeof(Service1), ex);
                            }
                        }
                        //LogHelper.LogInfoAsync(typeof(Service1), "第"+(++count)+"条!");
                    }//userinfo loop
                }
            }
        }