Пример #1
0
        public async Task<List<UserAcademic>> GetUCErrorUserAcademic(Guid uuid)
        {
            List<UserAcademic> ret = new List<UserAcademic>();

            using (UserRepository repo = new UserRepository())
            {
                ret = await repo.GetUserRecordsByUuid<UserAcademic>(uuid);
            }

            return ret;
        }
Пример #2
0
        public static async Task<List<string>> GetUserEducations(Guid uuid)
        {
            List<UserEducation> eduList = null;
            List<string> ret = null;
            using (UserRepository repo = new UserRepository())
            {
                var userinfo = await repo.GetUserInfoByUuidAsync(uuid);
                eduList = await repo.GetUserRecordsByUuid<UserEducation>(userinfo.uuid);
            }
            if(eduList!=null)
            {
                ret = new List<string>();
                foreach(var v in eduList)
                {
                    string school = v.School.Trim().ToLower();
                    if (!string.IsNullOrEmpty(school) && !ret.Contains(school))
                        ret.Add(school);
                }
            }

            return ret;
        }
Пример #3
0
        public static async Task<List<ProfessorIndex>> Search_rf3(Guid uuid, bool xiaoyou = false, string danwei = "", int diwei =0, string address = "", int pageIndex = 0, int pageSize = 10)
        {
            try
            {
                int from = pageIndex * pageSize;
                int size = pageSize;
                List<ProfessorIndex> ret = new List<ProfessorIndex>();
                UserInfo userinfo = null; List<UserEducation> eduList = null;
                using (UserRepository repo = new UserRepository())
                {
                    userinfo = await repo.GetUserInfoByUuidAsync(uuid);
                    eduList = await repo.GetUserRecordsByUuid<UserEducation>(userinfo.uuid);
                }

                //researchfieldid
                if (userinfo.ResearchFieldId == null)
                    return new List<ProfessorIndex>();
                string rfid = userinfo.ResearchFieldId.ToString();

                var rfContainer = Query<ProfessorIndex>.Term("ResearchId", rfid.ToString());
                var myuuidContainer = Query<ProfessorIndex>.Term("Id", uuid.ToString());
                QueryContainer container = rfContainer && !myuuidContainer;

                //标签
                if (diwei != 0 || xiaoyou)
                {
                    QueryContainer xyContainer = null;
                    QueryContainer diweiContainer = null;
                    QueryContainer lableContainer = null;
                    //地位
                    if (diwei != 0)
                    {
                        diweiContainer = MakeDiweiContainer(diwei);
                    }

                    //校友
                    if (xiaoyou && eduList != null)
                    {
                        List<string> tmpList = new List<string>();
                        foreach (UserEducation v in eduList)
                        {
                            if (string.IsNullOrEmpty(v.School))
                                continue;

                            if (xyContainer == null)
                            {
                                xyContainer = Query<ProfessorIndex>.QueryString(q => q.Query(v.School).OnFields(new string[] { "Education" }).DefaultOperator(Operator.And).Analyzer("ik_smart"));
                                tmpList.Add(v.School);
                            }
                            else
                            {
                                if (!tmpList.Contains(v.School))
                                {
                                    xyContainer = xyContainer || (Query<ProfessorIndex>.QueryString(q => q.Query(v.School).OnFields(new string[] { "Education" }).DefaultOperator(Operator.Or).Analyzer("ik_smart")));
                                    tmpList.Add(v.School);
                                }
                            }
                        }
                    }
                    //统计
                    if (xyContainer != null && diweiContainer != null)
                        lableContainer = diweiContainer || xyContainer;
                    else
                    {
                        lableContainer = xyContainer != null ? xyContainer : diweiContainer;
                    }

                    //合并
                    if (lableContainer != null)
                        container = container && lableContainer;
                }
                //单位
                if (!string.IsNullOrEmpty(danwei))
                {
                    container = container && (Query<ProfessorIndex>.QueryString(q => q.Query(danwei).DefaultOperator(Operator.And).Analyzer("ik_smart")));
                }

                //address
                if (!string.IsNullOrEmpty(address))
                {
                    var addressContainer = Query<ProfessorIndex>.QueryString(q => q.Query(address).DefaultOperator(Operator.Or).Analyzer("ik_smart"));
                    container = container && addressContainer;
                }
                //search
                var result = await _client.SearchAsync<ProfessorIndex>(s => s.Index(_config.IndexName).Query(container).Skip(from).Take(size).SortDescending("DiweiScore").SortDescending("AccessCount"));
                ret = result.Documents.ToList();

                return ret;
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return new List<ProfessorIndex>();
        }