예제 #1
0
        private void Execute(Common.Day item)
        {
            var source      = SourceMongoDb.GetCollection("exevent");
            var destination = DestinationMongoDb.GetCollection("exevent");

            item.BeganAt = DateTime.Now.ToString();
            foreach (var hour in item.Hours)
            {
                try
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    IMongoQuery query  = GenerateMongoQuery(item.Year, item.Month, item.Ordinality, hour.Index);
                    var         cursor = source.Find(query);
                    //var local = cursor.ToList();
                    var pickedup = destination.InsertBatch(cursor);
                    hour.Source = pickedup.Count();
                    WriteConcernResult written = source.Remove(query);
                    hour.Destination = (int)written.DocumentsAffected;
                    sw.Stop();
                    hour.Elapsed = sw.Elapsed.TotalMilliseconds;
                }
                catch (Exception ex)
                {
                    hour.Error = ex.Message;
                }
            }
            item.EndedAt = DateTime.Now.ToString();
        }
예제 #2
0
        public void Execute(int year, int month, int day, int hour)
        {
            XF.Common.Day item = new Common.Day()
            {
                Year = year, Month = month, Ordinality = day
            };
            item.Hours.Add(new Common.Hour()
            {
                Index = hour
            });
            Execute(item);

            MongoCollection <XF.Common.Day> process = DestinationMongoDb.GetCollection <XF.Common.Day>("day");

            process.Insert <XF.Common.Day>(item);
        }
예제 #3
0
        private bool InitializeDatastores()
        {
            bool b           = false;
            var  source      = ConfigurationManager.ConnectionStrings[Settings.Source];
            var  destination = ConfigurationManager.ConnectionStrings[Settings.Destination];

            if (source != null && destination != null)
            {
                XF.Common.MongoConnectionInfo sourceInfo      = new XF.Common.MongoConnectionInfo();
                XF.Common.MongoConnectionInfo destinationInfo = new XF.Common.MongoConnectionInfo();
                if (sourceInfo.Initialize(source) && destinationInfo.Initialize(destination))
                {
                    SourceMongoDb      = sourceInfo.GetDatabase();
                    DestinationMongoDb = destinationInfo.GetDatabase();

                    SourceCollection      = SourceMongoDb.GetCollection <eXEvent>("exevent");
                    DestinationCollection = DestinationMongoDb.GetCollection <eXEvent>("exevent");
                    b = true;
                }
            }

            return(b);
        }
예제 #4
0
        public void Execute(int year, int month, int day)
        {
            Stopwatch sw = new Stopwatch();

            XF.Common.Day item = new Common.Day()
            {
                Year = year, Month = month, Ordinality = day
            };
            for (int i = 0; i < 24; i++)
            {
                item.Hours.Add(new Common.Hour()
                {
                    Index = i
                });
            }
            sw.Start();
            Execute(item);
            sw.Stop();
            item.Elapsed = sw.Elapsed.TotalMilliseconds;
            MongoCollection <XF.Common.Day> process = DestinationMongoDb.GetCollection <XF.Common.Day>("day");

            process.Insert <XF.Common.Day>(item);
        }