Пример #1
0
        public eMail GetEMail(string id)
        {
            MongoDatabase mongoDatabase = this._mongoServer.GetDatabase("email_user_" + this._id);
            MongoCollection <eMailEntity> mongoCollection = mongoDatabase.GetCollection <eMailEntity>("mails");

            IMongoQuery query = Query <eMailEntity> .Where(e => e.Id == new ObjectId(id));

            eMailEntity entity = mongoCollection.FindOne(query);

            if (entity != null)
            {
                eMail mail = new eMail();
                mail.SetId(entity.Id.ToString());
                mail.SetClientName(entity.ClientName);
                mail.SetFrom(entity.MailFrom);
                mail.SetMessage(entity.Message);
                mail.SetRecipient(entity.RecipientTo);
                mail.SetSubject(entity.Subject);
                mail.SetHeaderFrom(entity.HeaderFrom);
                mail.SetHeaderTo(entity.HeaderTo);
                mail.SetTime(entity.Time);
                return(mail);
            }

            return(null);
        }
Пример #2
0
        public List <eMail> GetEmails(int offset, int limit)
        {
            List <eMail> eMails = new List <eMail>();

            MongoDatabase mongoDatabase = this._mongoServer.GetDatabase("email_user_" + this._id);
            MongoCollection <eMailEntity> mongoCollection = mongoDatabase.GetCollection <eMailEntity>("mails");

            //IMongoQuery query = Query<eMailEntity>.Where(e => e.RecipientTo == this.eMail);
            //MongoCursor<eMailEntity> mongoCursor = mongoCollection.Find(query).SetSkip(offset).SetLimit(limit);
            MongoCursor <eMailEntity> mongoCursor = mongoCollection.FindAll().SetSkip(offset).SetLimit(limit);

            foreach (eMailEntity entity in mongoCursor)
            {
                eMail mail = new eMail();
                mail.SetId(entity.Id.ToString());
                mail.SetClientName(entity.ClientName);
                mail.SetFrom(entity.MailFrom);
                mail.SetMessage(entity.Message);
                mail.SetRecipient(entity.RecipientTo);
                mail.SetSubject(entity.Subject);
                mail.SetHeaderFrom(entity.HeaderFrom);
                mail.SetHeaderTo(entity.HeaderTo);
                mail.SetTime(entity.Time);
                eMails.Add(mail);
            }

            return(eMails);
        }
Пример #3
0
		public eMail GetEMail(string id) {
			MongoDatabase mongoDatabase = this._mongoServer.GetDatabase("email_user_" + this._id);
			MongoCollection<eMailEntity> mongoCollection = mongoDatabase.GetCollection<eMailEntity>("mails");

			IMongoQuery query = Query<eMailEntity>.Where(e => e.Id == new ObjectId(id));
			eMailEntity entity = mongoCollection.FindOne(query);
			if (entity != null) {
				eMail mail = new eMail();
				mail.SetId(entity.Id.ToString());
				mail.SetClientName(entity.ClientName);
				mail.SetFrom(entity.MailFrom);
				mail.SetMessage(entity.Message);
				mail.SetRecipient(entity.RecipientTo);
				mail.SetSubject(entity.Subject);
				mail.SetHeaderFrom(entity.HeaderFrom);
				mail.SetHeaderTo(entity.HeaderTo);
				mail.SetTime(entity.Time);
				return mail;
			}

			return null;
		}
Пример #4
0
		public List<eMail> GetEmails(int offset, int limit) {
			List<eMail> eMails = new List<eMail>();

			MongoDatabase mongoDatabase = this._mongoServer.GetDatabase("email_user_" + this._id);
			MongoCollection<eMailEntity> mongoCollection = mongoDatabase.GetCollection<eMailEntity>("mails");

			//IMongoQuery query = Query<eMailEntity>.Where(e => e.RecipientTo == this.eMail);
			//MongoCursor<eMailEntity> mongoCursor = mongoCollection.Find(query).SetSkip(offset).SetLimit(limit);
			MongoCursor<eMailEntity> mongoCursor = mongoCollection.FindAll().SetSkip(offset).SetLimit(limit);
			foreach(eMailEntity entity in mongoCursor) {
				eMail mail = new eMail();
				mail.SetId(entity.Id.ToString());
				mail.SetClientName(entity.ClientName);
				mail.SetFrom(entity.MailFrom);
				mail.SetMessage(entity.Message);
				mail.SetRecipient(entity.RecipientTo);
				mail.SetSubject(entity.Subject);
				mail.SetHeaderFrom(entity.HeaderFrom);
				mail.SetHeaderTo(entity.HeaderTo);
				mail.SetTime(entity.Time);
				eMails.Add(mail);
			}

			return eMails;
		}