コード例 #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 ExecutePurge(int year, int month)
        {
            var source = SourceMongoDb.GetCollection("exevent");
            var query  = GeneratePurgeQuery(year, month);
            WriteConcernResult result = source.Remove(query);

            string cmd      = result.Command.ToString();
            long   affected = result.DocumentsAffected;
            string error    = result.ErrorMessage;

            int i = 0;
        }
コード例 #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);
        }