Ejemplo n.º 1
0
 /// <summary>
 /// 创建用户皮肤
 /// </summary>
 /// <param name="memberId">创建者</param>
 /// <param name="userType">创建者类别</param>
 /// <param name="personalityPicture">个性图片</param>
 /// <param name="personalityBackgroundPicture">个性背景图片</param>
 /// <returns>用户皮肤对象</returns>
 private static MemberSkin CreateMemberSkin(
     String memberId,
     Comm.UserType userType,
     String personalityPicture,
     String personalityBackgroundPicture)
 {
     MemberSkin obj = new MemberSkin();
     obj.Creater = memberId;
     obj.UserType = userType;
     obj.PersonalityPicture = personalityPicture;
     obj.PersonalityBackgroundPicture = personalityBackgroundPicture;
     obj.CreatedTime = DateTime.Now;
     obj.Random = new Random().NextDouble();
     try
     {
         MongoDatabase md = MongoDBHelper.MongoDB;
         MongoCollection<MemberSkin> mc = md.GetCollection<MemberSkin>(MemberSkin.GetCollectionName());
         mc.Save(obj);
         return obj;
     }
     catch (System.Exception err)
     {
         throw new CBB.ExceptionHelper.OperationException(
             CBB.ExceptionHelper.ErrType.SystemErr,
             CBB.ExceptionHelper.ErrNo.DBOperationError,
             err);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 按用户皮肤编号或创建者编号获取一条个性背景或图片为空的用户皮肤
        /// </summary>
        /// <param name="memberSkinId">用户皮肤编号</param>
        /// <param name="memberId">创建者用户编号</param>
        /// <returns>用户皮肤</returns>
        public static MemberSkin GetEmptyMemberSkin(String memberSkinId, String memberId)
        {
            MemberSkin ms = new MemberSkin();
            QueryComplete qc = null;
            try
            {
                //用户皮肤编号和创建者编号编号可以为null或空字符串,在为null或空字符串情况下过滤查询条件
                if ((memberSkinId != null && memberSkinId != "") && (memberId != null && memberId != ""))
                {
                    qc = Query.And(
                        Query.EQ("_id", ObjectId.Parse(memberSkinId)),
                        Query.EQ("Creater", memberId),
                        Query.Or(
                            Query.EQ("PersonalityPicture", ""),
                            Query.EQ("PersonalityPicture", "null"),
                            Query.EQ("PersonalityBackgroundPicture", ""),
                            Query.EQ("PersonalityBackgroundPicture", "null")
                            )
                        );
                }
                else if ((memberSkinId != null && memberSkinId != "") && (memberId == null || memberId == ""))
                {
                    qc = Query.And(
                            Query.EQ("_id", ObjectId.Parse(memberSkinId)),
                            Query.Or(
                                Query.EQ("PersonalityPicture", ""),
                                Query.EQ("PersonalityPicture", "null"),
                                Query.EQ("PersonalityBackgroundPicture", ""),
                                Query.EQ("PersonalityBackgroundPicture", "null")
                            )
                        );
                }
                else if ((memberSkinId == null || memberSkinId == "") && (memberId != null && memberId != ""))
                {
                    qc = Query.And(
                        Query.EQ("Creater", memberId),
                        Query.Or(
                            Query.EQ("PersonalityPicture", ""),
                            Query.EQ("PersonalityPicture", "null"),
                            Query.EQ("PersonalityBackgroundPicture", ""),
                            Query.EQ("PersonalityBackgroundPicture", "null")
                            )
                        );
                }

                MongoDatabase md = MongoDBHelper.MongoDB;
                MongoCollection<MemberSkin> mc = md.GetCollection<MemberSkin>(MemberSkin.GetCollectionName());
                ms = mc.FindOne(qc);
                return ms;
            }
            catch (System.Exception err)
            {
                throw new CBB.ExceptionHelper.OperationException(
                    CBB.ExceptionHelper.ErrType.SystemErr,
                    CBB.ExceptionHelper.ErrNo.DBOperationError,
                    err);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新用户皮肤
        /// </summary>
        /// <param name="memberSkinId">用户皮肤编号</param>
        /// <param name="memberId">创建者编号</param>
        /// <param name="personalityPicture">个性图片</param>
        /// <param name="personalityBackgroundPicture">个性背景图片</param>
        /// <returns>操作状态</returns>
        public static CBB.ExceptionHelper.OperationResult UpdateMemberSkin(
            String memberSkinId,
            String memberId,
            String personalityPicture,
            String personalityBackgroundPicture)
        {
            MemberSkin ms = new MemberSkin();
            QueryComplete qc = null;
            IMongoUpdate mu = null;
            try
            {
                //用户皮肤编号和创建者编号编号可以为null或空字符串,在为null或空字符串情况下过滤查询条件
                if ((memberSkinId != null && memberSkinId != "") && (memberId != null && memberId != ""))
                {
                    qc = Query.And(
                        Query.EQ("_id", ObjectId.Parse(memberSkinId)),
                        Query.EQ("Creater", memberId)
                        );
                }
                else if ((memberSkinId != null && memberSkinId != "") && (memberId == null || memberId == ""))
                {
                    qc = Query.EQ("_id", ObjectId.Parse(memberSkinId));
                }
                else if ((memberSkinId == null || memberSkinId == "") && (memberId != null && memberId != ""))
                {
                    qc = Query.EQ("Creater", memberId);
                }

                MongoDatabase md = MongoDBHelper.MongoDB;
                MongoCollection<MemberSkin> mc = md.GetCollection<MemberSkin>(MemberSkin.GetCollectionName());

                //个性图片和个性背景图片可以为null或空字符串,在为null或空字符串情况下过滤查询条件
                if ((personalityPicture != null && personalityPicture != "") && (personalityBackgroundPicture != null && personalityBackgroundPicture != ""))
                {
                    mu = Update.Combine(
                        Update.Set("PersonalityPicture", personalityPicture),
                        Update.Set("PersonalityBackgroundPicture", personalityBackgroundPicture)
                        );
                }
                else if ((personalityPicture != null && personalityPicture != "") && (personalityBackgroundPicture == null || personalityBackgroundPicture == ""))
                {
                    mu = Update.Set("PersonalityPicture", personalityPicture);
                }
                else if ((personalityPicture == null || personalityPicture == "") && (personalityBackgroundPicture != null && personalityBackgroundPicture != ""))
                {
                    mu = Update.Set("PersonalityBackgroundPicture", personalityBackgroundPicture);
                }

                mc.Update(qc, mu);

                return new CBB.ExceptionHelper.OperationResult(true);
            }
            catch (System.Exception err)
            {
                throw new CBB.ExceptionHelper.OperationException(
                    CBB.ExceptionHelper.ErrType.SystemErr,
                    CBB.ExceptionHelper.ErrNo.DBOperationError,
                    err);
            }
        }