Example #1
0
 /// <summary>
 /// 用户生成邀请码
 /// </summary>
 /// <param name="generatedMember">用户编号</param>
 /// <returns></returns>
 public static InvitationCode GenerateInviteCode(string generatedMember)
 {
     try
     {
         int[] arrInviteCodes = GenerateNumber3(1, 999999);
         InvitationCode inviteCode = new InvitationCode(arrInviteCodes[0], null, generatedMember, generatedMember, Comm.UsedFlag.No);
         return Save(inviteCode);
     }
     catch (System.Exception err)
     {
         throw new CBB.ExceptionHelper.OperationException(
             CBB.ExceptionHelper.ErrType.SystemErr,
             CBB.ExceptionHelper.ErrNo.DBOperationError,
             err);
     }
 }
Example #2
0
 /// <summary>
 /// 添加邀请码
 /// </summary>
 /// <param name="obj">邀请码对象</param>
 /// <returns>操作状态</returns>
 public static CBB.ExceptionHelper.OperationResult Add(InvitationCode obj)
 {
     try
     {
         MongoDatabase md = MongoDBHelper.MongoDB;
         MongoCollection<InvitationCode> mc = md.GetCollection<InvitationCode>(InvitationCode.GetCollectionName());
         mc.Insert(obj);
         return new CBB.ExceptionHelper.OperationResult(true);
     }
     catch (Exception excep)
     {
         throw new CBB.ExceptionHelper.OperationException(
            CBB.ExceptionHelper.ErrType.SystemErr,
            CBB.ExceptionHelper.ErrNo.DBOperationError,
            excep);
     }
 }
Example #3
0
        /// <summary>
        /// 生成邀请码
        /// </summary>
        /// <param name="count">生成数量</param>
        /// <param name="generatedMember">操作用户</param>
        /// <returns>操作状态</returns>
        public static CBB.ExceptionHelper.OperationResult GenerateInviteCodes(short count, string generatedMember, string generatedMemberId)
        {
            try
            {
                //int rndint = 0;
                //long tick = 0;

                if(count > 100) return new CBB.ExceptionHelper.OperationResult(false, "最多只能生成100个邀请码");

                //for(byte i = 0; i < count; i++)
                //{
                    //tick = DateTime.Now.Ticks;
                    //Random rnd = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
                    //rndint = rnd.Next(0, 999999);

                    int[] arrInviteCodes = GenerateNumber3(count, 999999);

                    for (short i = 0; i < arrInviteCodes.Length; i++)
                    {

                        InvitationCode inviteCode = new InvitationCode(arrInviteCodes[i], null, generatedMember, generatedMemberId, Comm.UsedFlag.No);
                        Add(inviteCode);
                    }
                //}

                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 #4
0
 /// <summary>
 /// 更新邀请码
 /// </summary>
 /// <param name="obj">邀请码对象</param>
 /// <returns>邀请码对象</returns>
 public static InvitationCode Save(InvitationCode obj)
 {
     try
     {
         MongoDatabase md = MongoDBHelper.MongoDB;
         MongoCollection<InvitationCode> mc = md.GetCollection<InvitationCode>(InvitationCode.GetCollectionName());
         mc.Save(obj);
         return obj;
     }
     catch (System.Exception err)
     {
         throw new CBB.ExceptionHelper.OperationException(
             CBB.ExceptionHelper.ErrType.SystemErr,
             CBB.ExceptionHelper.ErrNo.DBOperationError,
             err);
     }
 }