Example #1
0
        /// <summary>
        /// 保存Ranking对象
        /// </summary>
        /// <param name="yearrankingtablename">表名</param>
        /// <param name="id">对象id</param>
        /// <param name="year">年度</param>
        /// <param name="scoresIncrease">分值增长</param>
        /// <returns></returns>
        private static CBB.ExceptionHelper.OperationResult UpdateEachYearRanking(String yearrankingtablename, String id, int year, int scoresIncrease)
        {
            try
            {
                EachYearRanking obj = GetEachYearRanking(yearrankingtablename, id, year);
                //该时段没有分值记录
                if (obj == null)
                {
                    obj = new EachYearRanking();
                    obj.ObjID = id;
                    obj.Year = year;
                }

                obj.Scores += scoresIncrease;

                MongoDatabase md = MongoDBHelper.MongoDB;
                MongoCollection<EachYearRanking> mc = md.GetCollection<EachYearRanking>(yearrankingtablename);
                mc.Save(obj);

                return new CBB.ExceptionHelper.OperationResult(true);

            }
            catch (System.Exception err)
            {
                throw new CBB.ExceptionHelper.OperationException(
                    CBB.ExceptionHelper.ErrType.SystemErr,
                    CBB.ExceptionHelper.ErrNo.DBOperationError,
                    err);
            }
        }
Example #2
0
 //获取Ranking对象
 private static EachYearRanking GetEachYearRanking(String yearrankingtablename, String id, int year)
 {
     EachYearRanking iv = new EachYearRanking();
     try
     {
         MongoDatabase md = MongoDBHelper.MongoDB;
         MongoCollection<EachYearRanking> mc = md.GetCollection<EachYearRanking>(yearrankingtablename);
         iv = mc.FindOne(
                 Query.And(
                     Query.EQ("ObjID", id),
                     Query.EQ("Year", year)
                 )
             );
         return iv;
     }
     catch (System.Exception err)
     {
         throw new CBB.ExceptionHelper.OperationException(
             CBB.ExceptionHelper.ErrType.SystemErr,
             CBB.ExceptionHelper.ErrNo.DBOperationError,
             err);
     }
 }