// 返回要存入数据库的参数串
 public override string getString()
 {
     return(BaseJsonSerializer.serialize(this));
 }
Esempio n. 2
0
    public override OpRes doGrantBenefit(object param, GMUser user)
    {
        ParamGrant       p         = (ParamGrant)param;
        List <ParamItem> item_list = new List <ParamItem>();

        try
        {
            Match match = Regex.Match(p.m_grantParam, Exp.TWO_NUM_BY_SPACE);
            if (!match.Success)
            {
                match = Regex.Match(p.m_grantParam, Exp.TWO_NUM_BY_SPACE_SEQ);
                if (!match.Success)
                {
                    return(OpRes.op_res_param_not_valid);
                }
            }
            parseItem(p.m_grantParam, item_list);
        }
        catch (System.Exception ex)
        {
            return(OpRes.op_res_failed);
        }

        if (item_list.Count == 0)
        {
            return(OpRes.op_res_param_not_valid);
        }

        for (int i = 0; i < item_list.Count; i++)
        {
        }

        if (p.m_target == GrantTarget.grant_target_someone)
        {
            OpRes res = addItemToSomeOne(p, item_list, user);
            if (res == OpRes.opres_success)
            {
            }
            return(res);
        }

        int level = 1;

        if (p.m_level != "")
        {
            try
            {
                // 转至level
                level = Convert.ToInt32(p.m_level);
                if (level <= 0)
                {
                    level = 1;
                }
            }
            catch (System.Exception ex)
            {
                return(OpRes.op_res_failed);
            }
        }
        IMongoQuery imq = getLevelImq(p.m_target == GrantTarget.grant_target_vip, level);

        /*string guid = firstPlayerGUID(p.m_target == GrantTarget.grant_target_vip, user, imq, getPlatformName(p.m_platIndex));
         * while (guid != "")
         * {
         *  for (int i = 0; i < item_list.Count; i++)
         *  {
         *      DBAddBenefit tmp = new DBAddBenefit();
         *      tmp.m_playerGUID = guid;
         *      tmp.m_grantType = (int)GrantType.gran_type_item;
         *      tmp.m_count = item_list[i].m_itemCount;
         *      tmp.m_exParam1 = item_list[i].m_itemId;       // 这个参数存储道具ID
         *      addBenefitToDB(tmp, user);
         *  }
         *  guid = nextPlayerGUID(user);
         * }*/
#if _OLD_BENEFIT_
        List <string> guid_list = new List <string>();
        initBenefit(p.m_target == GrantTarget.grant_target_vip, user, imq, getPlatformName(p.m_platIndex));
        bool run = nextPlayerGUIDList(user, 1000, guid_list);
        while (run)
        {
            for (int j = 0; j < guid_list.Count; j++)
            {
                for (int i = 0; i < item_list.Count; i++)
                {
                    DBAddBenefit tmp = new DBAddBenefit();
                    tmp.m_playerGUID = guid_list[j];
                    tmp.m_grantType  = (int)GrantType.gran_type_item;
                    tmp.m_count      = item_list[i].m_itemCount;
                    tmp.m_exParam1   = item_list[i].m_itemId;     // 这个参数存储道具ID
                    addBenefitToDB(tmp, user);
                }
            }
            run = nextPlayerGUIDList(user, 1000, guid_list);
        }
#else
        DBAddBenefit tmp = new DBAddBenefit();
        tmp.m_grantType = (int)GrantType.gran_type_item;
        tmp.m_exParam2  = BaseJsonSerializer.serialize(item_list);
        addFullBenefitToDB(tmp, user, p.m_platIndex);
#endif
//         OpLogMgr.getInstance().addLog(LogType.LOG_TYPE_ADD_BENEFIT_ITEM,
//             new ParamAddBenefitItem(p.m_playerId, item_list, (int)p.m_target, level, getPlatformName(p.m_platIndex, false)), user);
        return(OpRes.opres_success);
    }