//根据商圈楼层获取电梯扶梯 public virtual List <AreaModels> GetLifts(int TradeAreaID, int FloorNum) { string sqlString = "dbo.dz_Area_GetLift"; SqlParameter[] parm = { new SqlParameter("@TradeAreaId", TradeAreaID), new SqlParameter("@FloorNum", FloorNum) }; List <AreaModels> lifts = new List <AreaModels>(); SqlDataReader reader = SqlSeverProvider.ExecuteReader(sqlString, CommandType.StoredProcedure, parm); while (reader.Read()) { lifts.Add(new AreaModels { AreaKeyID = (int)reader["a_allAreaKeyId"], TradeAreaID = (int)reader["a_tradeAreaId"], TradeAreaFloor = (int)reader["a_tradeAreaFloor"], Category = (int)reader["a_areaCategory"], AradID = (int)reader["a_areaId"], StartX = float.Parse(reader["a_startX"].ToString()), StartY = float.Parse(reader["a_startY"].ToString()), Width = float.Parse(reader["a_width"].ToString()), Height = float.Parse(reader["a_height"].ToString()), IsMark = (bool)reader["a_isMark"] }); } reader.Close(); return(lifts); }
public virtual storeActivity GetByPosition(int tradeAreaId, int floorNum, float mapX, float mapY, float scaling) { //存储过程名称 string sqlStr = "dbo.dz_Area_GetStoreByPosition "; storeActivity storeAct = null; SqlDataReader dr = SqlSeverProvider.ExecuteReader(sqlStr, CommandType.StoredProcedure); if (dr.Read()) { storeAct = new storeActivity { storeID = dr.GetInt32(0), storeCName = dr.GetString(1), storeEName = dr.GetString(2) }; } // 根据 storeId 获取活动信息 添加到 storeAct 后 在返回 ActivityModels activity = _ActivityManager.GetByStoreId(storeAct.storeID); storeAct.activityID = activity.activityID; storeAct.activityTitle = activity.activityTitle; storeAct.activityContent = activity.activityContent; return(storeAct); }
public virtual StoreModels GetById(int id) { string sqlStr = "select * from m_store where s_storeId='" + id + "'"; SqlDataReader dr = SqlSeverProvider.ExecuteReader(sqlStr); StoreModels store = null; if (dr.Read()) { store = new StoreModels { storeID = dr.GetInt32(0), areaKeyID = dr.GetInt32(1), storeCName = dr.GetString(2), storeEName = dr.GetString(3), categoryID = dr.GetInt32(4), logo = dr.GetString(5), brandsID = dr.GetInt32(6), address = dr.GetString(7), phoneNumber = dr.GetString(8), arrivalNum = dr.GetInt32(9) }; dr.Close(); return(store); } return(null); }
/// <summary> /// 将数据集分成训练集 和 测试集 ----------------Success /// </summary> /// <param name="i"></param> /// <param name="j"></param> public void SplitDataSet(int i, int j) { Array.Clear(TestSet, 0, itemTotal * userTotal); Array.Clear(TrainSet, 0, itemTotal * userTotal); Thread.Sleep(1000); string sqlStr = "select * from Ratings"; var dataReader = SqlSeverProvider.ExecuteReader(sqlStr); while (dataReader.Read()) { var userID = dataReader.GetInt32(0); var itemID = dataReader.GetInt32(1); var rate = dataReader.GetInt32(2); Random rand = new Random(DateTime.Now.Millisecond); try { if (rand.Next() % (i - 1) == j) { TestSet[itemID - 1, userID] = 1; } else { TrainSet[itemID - 1, userID - 1] = 1; } } catch { } } }
/// <summary> /// 根据购物车推荐 /// </summary> /// <param name="userId"></param> /// <param name="shoppingCart"></param> /// <returns></returns> public static List <int> GetRecommend(int userId, List <int> shoppingCart) { List <int> itemsList = new List <int>(); string sqlStr = string.Format("select top(10) itemID,COUNT(itemID) as total from Ratings group by itemID order by total desc"); SqlDataReader dataReader = SqlSeverProvider.ExecuteReader(sqlStr); while (dataReader.Read()) { itemsList.Add(dataReader.GetInt32(0)); } return(itemsList); }
/// <summary> /// 根据用户的评分行为进行推荐 /// </summary> /// <param name="userId"></param> /// <returns></returns> public static List <int> GetRecommend(int userId) { List <int> itemsList = new List <int>(); string sqlStr = string.Format("select itemID from Recommended where userID={0}", userId); SqlDataReader dataReader = SqlSeverProvider.ExecuteReader(sqlStr); while (dataReader.Read()) { itemsList.Add(dataReader.GetInt32(0)); } return(itemsList); }
public TradeAreaModels GetById(int id) { string sqlString = "select * from m_tradeArea where t_tradeAreaId = " + id; System.Data.SqlClient.SqlDataReader reader = SqlSeverProvider.ExecuteReader(sqlString); TradeAreaModels trade = null; if (reader.Read()) { trade = TradeAreaManager.GetTradeAreaByReader(reader); } return(trade); }
//Methods of ITradeAreaProvider public List <TradeAreaModels> GetTradeAreaByCity(string cityname) { string sqlString = "dbo.dz_TradeArea_GetByCityName"; SqlParameter[] parm = { new SqlParameter("@CityName", cityname) }; List <TradeAreaModels> trades = new List <TradeAreaModels>(); SqlDataReader reader = SqlSeverProvider.ExecuteReader(sqlString, CommandType.StoredProcedure, parm); while (reader.Read()) { trades.Add(GetTradeAreaByReader(reader)); } return(trades); }
private static void OutUsersInterest() { for (int i = 0; i < 5; i++) { Random rand = new Random(DateTime.Now.Millisecond); var user = rand.Next() % 6040; Console.WriteLine("User " + user + ":"); string sqlStr = string.Format("select top(100) itemID,interest from UserInterest where userID={0} and interest>0 order by itemID", user); SqlDataReader reader = SqlSeverProvider.ExecuteReader(sqlStr); int num = 1; while (reader.Read()) { Console.Write(reader.GetInt32(0) + ":"); Console.Write(reader.GetDouble(1).ToString("0.0000") + " ; "); if (num > 0 && num % 5 == 0) { Console.Write("\n"); } num++; } Console.Write("\n"); } }
private static void OutSimilarMatrix() { for (int i = 0; i < 3; i++) { Random rand = new Random(DateTime.Now.Millisecond); var item = rand.Next() % 3952; Console.WriteLine("item " + item + ":"); string sqlStr = string.Format("select top(100) itemTwo,similarity from SimilarityMatrix where itemOne={0} order by itemTwo", item); SqlDataReader reader = SqlSeverProvider.ExecuteReader(sqlStr); int num = 1; while (reader.Read()) { Console.Write(reader.GetInt32(0) + ":"); Console.Write(reader.GetDouble(1).ToString("0.0000") + " ; "); if (num > 0 && num % 5 == 0) { Console.Write("\n"); } num++; } Console.Write("\n"); } }
public virtual AreaModels GetById(int ID) { string sqlString = "select * from m_area where a_allAreaKeyId = " + ID; SqlDataReader reader = SqlSeverProvider.ExecuteReader(sqlString); AreaModels area = null; if (reader.Read()) { area = new AreaModels { AreaKeyID = (int)reader["a_allAreaKeyId"], TradeAreaID = (int)reader["a_tradeAreaId"], TradeAreaFloor = (int)reader["a_tradeAreaFloor"], Category = (int)reader["a_areaCategory"], AradID = (int)reader["a_areaId"], StartX = (float)reader["a_startX"], StartY = (float)reader["a_startY"], Width = (float)reader["a_width"], Height = (float)reader["a_height"], IsMark = (bool)reader["a_isMark"] }; } return(area); }