public static bool GetUnivDeptScore(string univName,string deptName,out double uscore,out double dscore) { using (SystemRepository repo = new SystemRepository()) { var univs = repo.GetUnivIdByName(univName); var dept = repo.GetDepByName(univs, deptName); uscore = dscore = 0; if (univs == null && dept == null) { return false; } if(univs!=null) uscore = Convert.ToDouble(univs.UnivsID); if(dept!=null) dscore = Convert.ToDouble(dept.ID); return true; } }
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 } } }