Exemplo n.º 1
0
 /// <summary>
 /// 解析内容数据返回内容公共类集合
 /// </summary>
 /// <param name="bds">基础数据集</param>
 /// <returns>内容公共类集合</returns>
 public static IList<PublicContent> ContentResolve(MongoCursor<BsonDocument> bds)
 {
     IList<PublicContent> objlist = new List<PublicContent>();
     foreach (BsonDocument bd in bds)
     {
         ContentType contentType = (ContentType)Enum.Parse(typeof(ContentType), bd["ContentType"].AsInt32.ToString());
         switch (contentType)
         {
             case ContentType.Interest:
                 InterestContent interest = new InterestContent();
                 interest = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<InterestContent>(bd.ToJson());
                 objlist.Add((PublicContent)interest);
                 break;
             case ContentType.Member:
                 MemberContent member = new MemberContent();
                 member = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<MemberContent>(bd.ToJson());
                 objlist.Add((PublicContent)member);
                 break;
             case ContentType.CallFor:
                 CallForContent callfar = new CallForContent();
                 callfar = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<CallForContent>(bd.ToJson());
                 objlist.Add((PublicContent)callfar);
                 break;
             case ContentType.Image:
                 ImageContent image = new ImageContent();
                 image = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<ImageContent>(bd.ToJson());
                 objlist.Add((PublicContent)image);
                 break;
             case ContentType.InterView:
                 InterViewContent interview = new InterViewContent();
                 interview = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<InterViewContent>(bd.ToJson());
                 objlist.Add((PublicContent)interview);
                 break;
             case ContentType.IWant:
                 IWantContent iwant = new IWantContent();
                 iwant = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<IWantContent>(bd.ToJson());
                 objlist.Add((PublicContent)iwant);
                 break;
             case ContentType.Mood:
                 MoodContent mood = new MoodContent();
                 mood = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<MoodContent>(bd.ToJson());
                 objlist.Add((PublicContent)mood);
                 break;
             case ContentType.SuiSuiNian:
                 SuiSuiNianContent suisuinian = new SuiSuiNianContent();
                 suisuinian = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<SuiSuiNianContent>(bd.ToJson());
                 objlist.Add((PublicContent)suisuinian);
                 break;
         }
     }
     return objlist;
 }
Exemplo n.º 2
0
 public MemberContent(String contentID)
 {
     try
     {
         MemberContent obj = new MemberContent();
         MongoDatabase md = MongoDBHelper.MongoDB;
         MongoCollection<MemberContent> mc = md.GetCollection<MemberContent>(MoodContent.GetCollectionName());
         obj = mc.FindOne(Query.EQ("_id", ObjectId.Parse(contentID)));
         this._id = ObjectId.Parse(obj.ID);
         this.MemberID = obj.MemberID;
         this.Creater = obj.Creater;
         this.ContentPermissions = obj.ContentPermissions;
         this.MyFriends = obj.MyFriends;
         this.City = obj.City;
         this.Sex = obj.Sex;
         this.InterestID = obj.InterestID;
         this.ContentType = obj.ContentType;
         this.CreatedTime = obj.CreatedTime;
         this.UpdateTime = obj.UpdateTime;
         this.AnswerCount = obj.AnswerCount;
         this.AnswerList = obj.AnswerList;
         this.LikeCount = obj.LikeCount;
         this.LikeList = obj.LikeList;
         this.DeleteFlag = obj.DeleteFlag;
         this.Lat = obj.Lat;
         this.Lng = obj.Lng;
         this.Type = obj.Type;
     }
     catch (System.Exception err)
     {
         throw new CBB.ExceptionHelper.OperationException(
             CBB.ExceptionHelper.ErrType.SystemErr,
             CBB.ExceptionHelper.ErrNo.DBOperationError,
             err);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 心情内容的添加或更新
 /// </summary>
 /// <param name="obj">用户操作内容对象</param>
 /// <returns>添加或更新操作是否成功</returns>
 public MemberContent Save(MemberContent obj)
 {
     try
     {
         MongoDatabase md = MongoDBHelper.MongoDB;
         MongoCollection<MemberContent> mc = md.GetCollection<MemberContent>(PublicContent.GetCollectionName());
         mc.Save(obj);
         return obj;
     }
     catch (System.Exception err)
     {
         throw new CBB.ExceptionHelper.OperationException(
             CBB.ExceptionHelper.ErrType.SystemErr,
             CBB.ExceptionHelper.ErrNo.DBOperationError,
             err);
     }
 }