private string GetInfoStr(UninUser user) { var sb=new StringBuilder(); sb.Append(user.User.Age+"岁 | "); if (!string.IsNullOrEmpty(user.BaseInfo.Height)) { sb.Append(user.BaseInfo.Height + " | "); } if (!string.IsNullOrEmpty(user.BaseInfo.Education)) { sb.Append(user.BaseInfo.Education + " | "); } if (!string.IsNullOrEmpty(user.BaseInfo.MonthlyIncome)) { sb.Append(user.BaseInfo.MonthlyIncome ); } sb.Append("<br/>"); sb.Append(LoveDb.IamgeCount(user.User.UserId) + "张照片 | "); sb.Append("资料完整度" + GetPersent(user.User.UserId)*100 + "%"); sb.Append("<br/>"); sb.Append(LastLoginstr(user.User.UserId)); return sb.ToString(); }
/// <summary> /// first和second比较,second为主体 到时候要改成返回对象 /// </summary> /// <param name="user">被比较者的Id</param> /// <param name="second">比较着的资料</param> /// <returns></returns> private double TomeRate(UninUser user, Requirement second) { var tomeInts = GetTomeInts(user, second); return (double)tomeInts.Sum()/ 5; }
/// <summary> /// 对比恋爱观 /// </summary> /// <param name="user"></param> /// <param name="me"></param> /// <returns></returns> private double GetLoveViewRate(UninUser user, UninUser me) { var loveInts = GetLoveInts(user, me); return (double)loveInts.Sum() / 10; }
public bool PartMathUser(Requirement condition, UninUser biguser) { var residenceflag = false; var ageflag = false; var hightflag = false; if (string.IsNullOrEmpty(condition.ResidenceCity)||(biguser.BaseInfo.ResidenceCity != null && biguser.BaseInfo.ResidenceCity.Contains(condition.ResidenceCity)) ) { residenceflag = true; } //年龄 if ((condition.AgeLl == 0 || (biguser.User.Age != 0 && biguser.User.Age <= condition.AgeUl && biguser.User.Age >= condition.AgeLl))//agelow 要比 ageup 大 || (condition.AgeUl == 0 && biguser.User.Age >= condition.AgeLl)) { ageflag = true; } //身高 int hight = Convert.ToInt32(biguser.BaseInfo.Height.Split('厘')[0]); if (condition.HightLl == 0 || (biguser.BaseInfo.Height != null && ((hight <= condition.HightUl && hight >= condition.HightLl && condition.HightUl != 0) || (condition.HightUl == 0 && hight >= condition.HightLl)))) { hightflag = true; } return hightflag && residenceflag && ageflag; }
/// <summary> /// 两者需求匹配度 /// </summary> /// <param name="user"></param> /// <param name="second"></param> /// <returns></returns> public int[] GetTomeInts(UninUser user, Requirement second) { var firstage = user.User.Age; var high =string.IsNullOrEmpty(user.BaseInfo.Height)?0:Convert.ToInt16(user.BaseInfo.Height.Split('厘')[0]); var tomeInts = new int[5]; //没有年龄限制,或者在second的要求范围内,Ageui=0表示是没有上限。 if (second.AgeLl == 0 || (second.AgeLl <= firstage && (second.AgeUl == 0 || second.AgeUl >= firstage))) { tomeInts[0] = 1; } // 地方 if (string.IsNullOrEmpty(second.ResidenceProvince) || (second.ResidenceProvince == user.BaseInfo.ResidenceProvince && (second.ResidenceCity == user.BaseInfo.ResidenceCity || string.IsNullOrEmpty(second.ResidenceCity)))) { tomeInts[1] = 1; } //身高 if (second.HightLl == 0 || (second.HightLl <= high && (second.HightUl == 0 || second.HightUl >= high))||high==0) { tomeInts[2] = 1; } //学历 null 大专 本科 硕士 博士 /不限 大专以下 大专及以上 本科+ 硕士+ 博士+ if (string.IsNullOrEmpty(second.Education) || (ChangEducationToNum(second.Education) <= ChangEducationToNum(user.BaseInfo.Education) && !string.IsNullOrEmpty(user.BaseInfo.Education))) { tomeInts[3] = 1; } //月收入 先算出中间值。 int mm=0; if (!string.IsNullOrEmpty(user.BaseInfo.MonthlyIncome)) { mm = user.BaseInfo.MonthlyIncome == "3000元以下" ? 2500 : Convert.ToInt16(user.BaseInfo.MonthlyIncome.Split('-')[0]) + 500; } if (second.MonthlyIncomeLl == 0 || (second.MonthlyIncomeLl < mm || (second.MonthlyIncomeUl == 0 || second.MonthlyIncomeUl > mm)) || mm==0) { tomeInts[4] = 1; } return tomeInts; }
public UninUser GetMyself() { var id = CheckValid(); if (id != -1) { return _meUninUser ?? (_meUninUser = LoveDb.GetUninUser(CheckValid())); } return null; }
public int[] GetLoveInts(UninUser user, UninUser me) { //工作安排 var loveInts = new int[10]; if (Workplan(user.LoveView.WorkTimePlan, me.LoveView.WorkTimePlan)) { loveInts[0] = 1; } // 抽烟 if (user.LoveView.Smoking != null && me.LoveView.Smoking != null) { var ostr = user.LoveView.Smoking; var istr = me.LoveView.Smoking; if (ostr == "不吸烟,但也不介意" || (ostr == "不吸烟,而且反感吸烟" && (istr == "不吸烟,但也不介意" || istr == "不吸烟,而且反感吸烟")) || ((ostr == "经常偶尔吸烟" || ostr == "经常吸烟") && istr == "不吸烟,但也不介意")) { loveInts[1] = 1; } } //喝酒 if (user.LoveView.Drinking != null && me.LoveView.Drinking != null) { var ostr = user.LoveView.Drinking; var istr = me.LoveView.Drinking; if (ostr == "不喝酒,但也不介意" || (ostr == "不喝酒,且很反感喝酒" && (istr == "不喝酒,但也不介意" || istr == "不喝酒,且很反感喝酒")) || ((ostr == "偶尔社交需要才喝酒" || ostr == "经常喝酒") && istr == "不喝酒,但也不介意")) { loveInts[2] = 1; } } //恋爱多久结婚 if (user.LoveView.LoveDuration != null && me.LoveView.LoveDuration != null && user.LoveView.LoveDuration == me.LoveView.LoveDuration) { loveInts[3] = 1; } //婚后是否要小孩 if (user.LoveView.WantaBaby != null && me.LoveView.WantaBaby != null && user.LoveView.WantaBaby == me.LoveView.WantaBaby) { loveInts[4] = 1; } //婚后是否与父母同住 if (user.LoveView.ParentLiveTogether != null && me.LoveView.ParentLiveTogether != null && user.LoveView.ParentLiveTogether == me.LoveView.ParentLiveTogether) { loveInts[5] = 1; } //家务事 if (user.LoveView.Housework != null && me.LoveView.Housework != null && user.LoveView.Housework == me.LoveView.Housework) { loveInts[6] = 1; } //理财 if (user.LoveView.ManageMoney != null && me.LoveView.ManageMoney != null && user.LoveView.ManageMoney == me.LoveView.ManageMoney) { loveInts[7] = 1; } //厨艺 if (user.LoveView.Cooking != null && me.LoveView.Cooking != null) { var ostr = user.LoveView.Cooking; var istr = me.LoveView.Cooking; if ((ostr == "会做饭,希望对方也会" && (istr == "会做饭,对另一半没要求" || istr == "会做饭,希望对方也会")) || ostr == "会做饭,对另一半没要求" || (ostr == "不太会,对另一半没要求" && istr != "会做饭,希望对方也会" && istr != "不太会,希望对方厨艺比我好") || (ostr == "不太会,希望对方厨艺比我好" && istr != "不太会,对另一半没要求" && istr != "不太会,希望对方厨艺比我好")) { loveInts[8] = 1; } } //异地 if (user.LoveView.Allopatry != null && me.LoveView.Allopatry != null && user.LoveView.Allopatry == me.LoveView.Allopatry) { loveInts[9] = 1; } return loveInts; }
/// <summary> /// 匹配user是否符合搜索条件 /// </summary> /// <param name="condition"></param> /// <param name="biguser"></param> /// <returns></returns> private bool MarchUser(Search condition, UninUser biguser) { // 先判断user的部分 var residenceflag = false; var ageflag = false; var educationflag = false; var incomeflag = false; var housingflag = false; var carflag = false; var conflag = false; var hightflag = false; var nativeflag = false; var peopleflag = false; var stateflag = false; // 还要判断user 自身的资料是否是不为null的。 if ((biguser.BaseInfo.ResidenceCity != null && biguser.BaseInfo.ResidenceCity.Contains(condition.ResidenceCity)) || string.IsNullOrEmpty(condition.ResidenceCity)) { residenceflag = true; } //年龄 if ((condition.AgeUp == 0 || (biguser.User.Age != 0 && biguser.User.Age <= condition.AgeLow && biguser.User.Age >= condition.AgeUp))//agelow 要比 ageup 大 || (condition.AgeLow == 0 && biguser.User.Age >= condition.AgeUp)) { ageflag = true; } //学历 if (string.IsNullOrEmpty(condition.Education) || condition.Education == "学历不限" || biguser.BaseInfo.Education != null && ((condition.Education.Contains("及以上") && IntEducation(biguser.BaseInfo.Education) >= IntEducation(condition.Education)) || (!condition.Education.Contains("及以上") && IntEducation(biguser.BaseInfo.Education) == IntEducation(condition.Education)))) { educationflag = true; } //收入 if (string.IsNullOrEmpty(condition.MonthlyIncome) || (biguser.BaseInfo.MonthlyIncome != null && ((IntIncome(biguser.BaseInfo.MonthlyIncome) >= IntIncome(condition.MonthlyIncome) && condition.MonthlyIncome != "3000元以下") || IntIncome(biguser.BaseInfo.MonthlyIncome) <= IntIncome(condition.MonthlyIncome) && condition.MonthlyIncome == "3000元以下"))) { incomeflag = true; } // 汽车 if (string.IsNullOrEmpty(condition.Car) || (biguser.DetailInfo.Car != null && biguser.DetailInfo.Car == condition.Car)) { carflag = true; } //住房 if (string.IsNullOrEmpty(condition.Housing) || (biguser.DetailInfo.Housing != null && biguser.DetailInfo.Housing == condition.Housing)) { housingflag = true; } //星座 if (string.IsNullOrEmpty(condition.Constellation) || (biguser.DetailInfo.Constellation != null && biguser.DetailInfo.Constellation == condition.Constellation)) { conflag = true; } //身高 int hight = Convert.ToInt32(biguser.BaseInfo.Height.Split('厘')[0]); if (condition.HightUp == 0 || (biguser.BaseInfo.Height != null && ((hight <= condition.HightLow && hight >= condition.HightUp && condition.HightLow != 0) || (condition.HightLow == 0 && hight >= condition.HightUp)))) { hightflag = true; } //籍贯 if (string.IsNullOrEmpty(condition.NativePlace) || (biguser.DetailInfo.NativePlace != null && (condition.NativePlace == Trimplace(biguser.DetailInfo.NativePlace) || biguser.DetailInfo.NativePlace.Contains(condition.NativePlace)))) { nativeflag = true; } if (string.IsNullOrEmpty(condition.People) || (biguser.DetailInfo.People != null && condition.People == biguser.DetailInfo.People)) { peopleflag = true; } if (string.IsNullOrEmpty(condition.State) || (biguser.BaseInfo.State != null && condition.State == biguser.BaseInfo.State)) { stateflag = true; } return residenceflag && ageflag && educationflag && incomeflag && housingflag && carflag && conflag && hightflag && nativeflag && peopleflag && stateflag; }