Exemple #1
0
        private static bool InitializeMongo()
        {
            MongoUtilsTopicObj   = new MongoDBUtils <Topic>(Config.MongoUser, Config.MongoPassword, Config.MongoAddress, Config.MongoDatabase);
            MongoUtilsCommentObj = new MongoDBUtils <Comment>(Config.MongoUser, Config.MongoPassword, Config.MongoAddress, Config.MongoDatabase);
            MongoUtilsUserObj    = new MongoDBUtils <User>(Config.MongoUser, Config.MongoPassword, Config.MongoAddress, Config.MongoDatabase);

            // Sanit Check
            if (!MongoUtilsTopicObj.IsValidMongoData(Config))
            {
                return(false);
            }

            // Invalid Collection?
            if (!MongoUtilsTopicObj.CollectionExistsAsync(Config.MongoCollection).Result ||
                !MongoUtilsCommentObj.CollectionExistsAsync(CommentsCollection).Result ||
                !MongoUtilsUserObj.CollectionExistsAsync(UsersCollection).Result)
            {
                return(false);
            }

            // Open the Connection
            MongoUtilsTopicObj.GetCollection(Config.MongoCollection);
            MongoUtilsCommentObj.GetCollection(CommentsCollection);
            MongoUtilsUserObj.GetCollection(UsersCollection);

            return(true);
        }
        private static bool InitializeMongo()
        {
            MongoUtilsObj = new MongoDBUtils <Section>(Config.MongoUser, Config.MongoPassword, Config.MongoAddress, Config.MongoDatabase);

            // Sanit Check
            if (!MongoUtilsObj.IsValidMongoData(Config))
            {
                return(false);
            }

            // Is There no collection?
            if (!MongoUtilsObj.CollectionExistsAsync(Config.MongoCollection).Result)
            {
                MongoUtilsObj.CreateCollection(Config.MongoCollection);
            }

            return(true);
        }
Exemple #3
0
        public static void Main()
        {
            new Data();

            SqlConnection conn = DBSQLServerUtils.GetDBConnection();


            conn.Open();

            MongoDBUtils mongoutils = new MongoDBUtils("mongodb://localhost:27017");

            int numofrecords = getTotalRows(conn);
            int p            = numofrecords / 1000;
            int q            = numofrecords % 1000;

            //for (int i = 0; i < numofrecords; i += 1000)
            //{
            //    getIP(conn, i, i + 1000);

            //    while (Data.data.Count > 0)
            //    {
            //        mongoutils.insertData("fortest", "info", Data.data[0]);
            //        Data.data.RemoveAt(0);
            //    }
            //}

            getIP(conn, p * 1000, numofrecords);

            while (Data.data.Count > 0)
            {
                mongoutils.insertData("fortest", "info", Data.data[0]);
                Data.data.RemoveAt(0);
            }

            Console.WriteLine("cpmpleted");

            conn.Close();
        }
Exemple #4
0
 public MongoDBWorkflows(ICosmosDBAccount account)
 {
     this.mongodb = new MongoDBUtils(account);
 }