예제 #1
0
        private static CBB.ExceptionHelper.OperationResult UpdateDailyRanking(String dailyrankingtablename, String id, int year, int dayofyear, int scoresIncrease)
        {
            try
            {
                DailyRanking obj = GetDailyRanking(dailyrankingtablename, id, year, dayofyear);
                //该时段没有分值记录
                if (obj == null)
                {
                    obj = new DailyRanking();
                    obj.ObjID = id;
                    obj.Year = year;
                    obj.DayOfYear = dayofyear;
                }

                obj.Scores += scoresIncrease;

                MongoDatabase md = MongoDBHelper.MongoDB;
                MongoCollection<DailyRanking> mc = md.GetCollection<DailyRanking>(dailyrankingtablename);
                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);
            }
        }
예제 #2
0
 private static DailyRanking GetDailyRanking(String dailyrankingtablename, String id, int year, int dayofyear)
 {
     DailyRanking iv = new DailyRanking();
     try
     {
         MongoDatabase md = MongoDBHelper.MongoDB;
         MongoCollection<DailyRanking> mc = md.GetCollection<DailyRanking>(dailyrankingtablename);
         iv = mc.FindOne(
                 Query.And(
                     Query.EQ("ObjID", id),
                     Query.EQ("Year", year),
                     Query.EQ("DayOfYear", dayofyear)
                 )
             );
         return iv;
     }
     catch (System.Exception err)
     {
         throw new CBB.ExceptionHelper.OperationException(
             CBB.ExceptionHelper.ErrType.SystemErr,
             CBB.ExceptionHelper.ErrNo.DBOperationError,
             err);
     }
 }