Exemple #1
0
        private static CBB.ExceptionHelper.OperationResult UpdateWeeklyRanking(String weeklyrankingtablename, String id, int year, int weekofyear, int scoresIncrease)
        {
            try
            {
                WeeklyRanking obj = GetWeeklyRanking(weeklyrankingtablename, id, year, weekofyear);
                //该时段没有分值记录
                if (obj == null)
                {
                    obj = new WeeklyRanking();
                    obj.ObjID = id;
                    obj.Year = year;
                    obj.WeekOfYear = weekofyear;
                }

                obj.Scores += scoresIncrease;

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