Example #1
0
        private static void Check()
        {
            Console.WriteLine("running precheck...");

            MongoServer mongoServer = MyMongoDB.GetServer();

            MongoDatabase mongoDatabase = mongoServer.GetDatabase("email");
            MongoCollection <LazyBsonDocument> mongoCollection = mongoDatabase.GetCollection <LazyBsonDocument>("mails");

            MongoCursor <LazyBsonDocument> mongoCursor = mongoCollection.FindAll();

            foreach (LazyBsonDocument bsonDocument in mongoCursor)
            {
                if (Options.Verbose)
                {
                    Console.WriteLine("checking email-id: " + bsonDocument["_id"].ToString());
                }
                try {
                    if (User.EMailExists(bsonDocument["RecipientTo"].AsString))
                    {
                        Console.WriteLine("user with email-address found: " + bsonDocument["RecipientTo"].AsString);
                        User newMailUser = new User();
                        newMailUser.RefreshById(User.GetIdByEMail(bsonDocument["RecipientTo"].AsString));
                        eMail mail = new eMail(bsonDocument);
                        mail.AssignToUser(newMailUser);
                    }
                } catch (Exception ex) {
                    logger.ErrorException(ex.Message, ex);
                }
            }

            Console.WriteLine("precheck finished...");
        }
Example #2
0
		private static void Check() {
			Console.WriteLine("running precheck...");
			
			MongoServer mongoServer = MyMongoDB.GetServer();
			
			MongoDatabase mongoDatabase = mongoServer.GetDatabase("email");
			MongoCollection<LazyBsonDocument> mongoCollection = mongoDatabase.GetCollection<LazyBsonDocument>("mails");
			
			MongoCursor<LazyBsonDocument> mongoCursor = mongoCollection.FindAll();
			foreach(LazyBsonDocument bsonDocument in mongoCursor) {
				if (Options.Verbose) {
					Console.WriteLine("checking email-id: " + bsonDocument["_id"].ToString());
				}
				try {
					if (User.EMailExists(bsonDocument["RecipientTo"].AsString)) {
						Console.WriteLine("user with email-address found: " + bsonDocument["RecipientTo"].AsString);
						User newMailUser = new User();
						newMailUser.RefreshById(User.GetIdByEMail(bsonDocument["RecipientTo"].AsString));
						eMail mail = new eMail(bsonDocument);
						mail.AssignToUser(newMailUser);
					}
				} catch(Exception ex) {
					logger.ErrorException(ex.Message, ex);
				}
			}
			
			Console.WriteLine("precheck finished...");
		}