Beispiel #1
0
        private static CBB.ExceptionHelper.OperationResult UpdatePerMonthRanking(String permonthrankingtablename, String id, int year, int month, int scoresIncrease)
        {
            try
            {
                PerMonthRanking obj = GetPerMonthRanking(permonthrankingtablename, id, year, month);
                //该时段没有分值记录
                if (obj == null)
                {
                    obj = new PerMonthRanking();
                    obj.ObjID = id;
                    obj.Year = year;
                    obj.Month = month;
                }

                obj.Scores += scoresIncrease;

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