/// <summary> /// 更新餐馆看了又看 /// </summary> public bool UpdResSeeAndSee() { List <SeeCount> list = new List <SeeCount>(); RestaurantInfoBLL _RestaurantInfoBLL = new RestaurantInfoBLL(); ClickLogBLL _ClickLogBLL = new ClickLogBLL(); DataTable ResDT = _RestaurantInfoBLL.GetCityRes(1); for (int k = 0; k < ResDT.Rows.Count; k++) { int CurrentResID = int.Parse(ResDT.Rows[k]["RestaurantID"].ToString()); list.Clear(); //1.查询出所有餐馆信息 并加入链表 for (int i = 0; i < ResDT.Rows.Count; i++) { SeeCount _SeeCount = new SeeCount(); _SeeCount.KeyName = ResDT.Rows[i]["RestaurantName"].ToString(); _SeeCount.KeyID = int.Parse(ResDT.Rows[i]["RestaurantID"].ToString()); list.Add(_SeeCount); } //2.查询出看了当前餐馆用户IP DataTable ViewerIPDT = _ClickLogBLL.GetSeeResIDPeople(CurrentResID); List <String> IPList = new List <String>(); for (int j = 0; j < ViewerIPDT.Rows.Count; j++) { if (!IPList.Contains(ViewerIPDT.Rows[j]["IP"].ToString())) { IPList.Add(ViewerIPDT.Rows[j]["IP"].ToString()); } } //3.查询出当前IP 看过的餐馆 并统计次数 for (int l = 0; l < IPList.Count; l++) { DataTable CurrentResDT = _ClickLogBLL.GetAllOneSee(IPList[l], "餐馆"); //将餐馆合并 List <int> ResList = new List <int>(); for (int m = 0; m < CurrentResDT.Rows.Count; m++) { if (!ResList.Contains(int.Parse(CurrentResDT.Rows[m]["ContentFlag"].ToString()))) { ResList.Add(int.Parse(CurrentResDT.Rows[m]["ContentFlag"].ToString())); } } for (int p = 0; p < ResList.Count; p++) { for (int n = 0; n < list.Count; n++) { if (list[n].KeyID == ResList[p]) { list[n].Count++; } } } } //4.先删除当前餐馆ID再根据次数排序 for (int a = 0; a < list.Count; a++) { if (list[a].KeyID == CurrentResID) { list.RemoveAt(a); } } //先根据餐馆ID删除该餐馆的看了又看 然后按次序执行插入 _LookAnotherBLL.DelByIDType(CurrentResID, "餐馆"); ; for (int v = 0; v < 1; v++) { LookAnotherInfo _LookAnotherInfo = new LookAnotherInfo(); _LookAnotherInfo.KeyID = CurrentResID; _LookAnotherInfo.AnotherLookID = list[v].KeyID; _LookAnotherInfo.GoalType = "餐馆"; _LookAnotherBLL.AddLookAnother(_LookAnotherInfo); } } return(true); }