public bool UpdateStatistics(StatisticsInfo statistics) { string cmdText =string.Format( "update [{0}sites] set PostCount=@PostCount,CommentCount=@CommentCount,VisitCount=@VisitCount,TagCount=@TagCount",ConfigHelper.Tableprefix); OleDbParameter[] prams = { OleDbHelper.MakeInParam("@PostCount", OleDbType.Integer,4,statistics.PostCount), OleDbHelper.MakeInParam("@CommentCount", OleDbType.Integer,4,statistics.CommentCount), OleDbHelper.MakeInParam("@VisitCount", OleDbType.Integer,4,statistics.VisitCount), OleDbHelper.MakeInParam("@TagCount", OleDbType.Integer,4,statistics.TagCount), }; return OleDbHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams) == 1; }
/// <summary> /// 转换实体 /// </summary> /// <param name="read">OleDbDataReader</param> /// <returns>TermInfo</returns> private static List<StatisticsInfo> DataReaderToListSite(OleDbDataReader read) { var list = new List<StatisticsInfo>(); while (read.Read()) { var site = new StatisticsInfo { PostCount = Convert.ToInt32(read["PostCount"]), CommentCount = Convert.ToInt32(read["CommentCount"]), VisitCount = Convert.ToInt32(read["VisitCount"]), TagCount = Convert.ToInt32(read["TagCount"]) }; list.Add(site); } read.Close(); return list; }
/// <summary> /// 初始化 /// </summary> private static void LoadStatistics() { if (_statistics == null) { lock (lockHelper) { if (_statistics == null) { _statistics = DatabaseProvider.Instance.GetStatistics(); } } } }