コード例 #1
0
		public void Process(UnicornSyncCompletePipelineArgs args)
		{
			foreach (var item in args.Changes)
			{
				if(item.Id != null) ManualPublishQueueHandler.AddItemToPublish(item.Id.Value);
			}
		}
コード例 #2
0
        public void Process(UnicornSyncCompletePipelineArgs args)
        {
            if (!NeedsPostProcessing(args)) return;

            var logger = args.Configuration.Resolve<ILogger>();

            logger.Debug(string.Empty);
            logger.Debug("> Preparing to post-process synced items (links/indexes). May take some time depending on change count...");

            // carpet bomb the cache since it can be out of date after a sync (before the serialization complete event has fired, which is after this happens)
            CacheManager.ClearAllCaches();
            var dbs = Factory.GetDatabases();
            foreach(var db in dbs) db.Engines.TemplateEngine.Reset();

            logger.Debug("> Caches have been cleared and template engine reset. Resolving items...");

            // resolve changed items from the sync. Note: this may not perform the most awesome with huge syncs.
            // but it's better than keeping stale items in memory during the sync. Note also that deleted items
            // from the sync will not resolve, because...they are gone. So the post processing here will not occur.
            var items = args.Changes
                .Where(change => change.ChangeType != ChangeType.Deleted && change.Id.HasValue)
                .Select(change => dbs.FirstOrDefault(db => db.Name.Equals(change.DatabaseName))?.GetItem(new ID(change.Id.Value)))
                .Where(item => item != null)
                .ToArray();

            logger.Debug("> Post process items resolved.");

            PostProcessItems(items, args.Configuration);
        }
コード例 #3
0
ファイル: SyncCompleteLogger.cs プロジェクト: sw08023/UNICORN
        public void Process(UnicornSyncCompletePipelineArgs args)
        {
            var logger = args.Configuration.Resolve <ILogger>();

            if (logger == null)
            {
                return;
            }

            var durationInMs = (DateTime.Now - args.SyncStartedTimestamp).TotalMilliseconds;
            var msPerItem    = (durationInMs / (args.ProcessedItemCount == 0 ? 1 : args.ProcessedItemCount)).ToString("N1");

            logger.Info("");
            logger.Info("{0} sync complete: {1} item{2} evaluated, {3} item{4} modified ({5} added, {6} updated, {7} recycled) in {8}ms (~{9}ms/item).".FormatWith(
                            args.Configuration.Name,
                            args.ProcessedItemCount,
                            args.ProcessedItemCount != 1 ? "s": string.Empty,
                            args.Changes.Count,
                            args.Changes.Count != 1 ? "s" : string.Empty,
                            args.Changes.Count(x => x.ChangeType == ChangeType.Created),
                            args.Changes.Count(x => x.ChangeType == ChangeType.Modified),
                            args.Changes.Count(x => x.ChangeType == ChangeType.Deleted),
                            (int)durationInMs,
                            msPerItem));
        }
コード例 #4
0
		public void Process(UnicornSyncCompletePipelineArgs args)
		{
			foreach (var item in args.Changes)
			{
				if(item.SerializedItem != null) ManualPublishQueueHandler.AddItemToPublish(item.SerializedItem.Id);
				if(item.SourceItem != null) ManualPublishQueueHandler.AddItemToPublish(item.SourceItem.Id);
			}
		}
コード例 #5
0
        protected virtual bool NeedsPostProcessing(UnicornSyncCompletePipelineArgs args)
        {
            if (args.Changes.Count == 0) return false;

            var syncConfiguration = args.Configuration.Resolve<ISyncConfiguration>();

            if (syncConfiguration != null && (syncConfiguration.UpdateLinkDatabase || syncConfiguration.UpdateSearchIndex)) return true;

            return false;
        }
コード例 #6
0
 public void Process(UnicornSyncCompletePipelineArgs args)
 {
     foreach (var item in args.Changes)
     {
         if (item.Id != null)
         {
             ManualPublishQueueHandler.AddItemToPublish(item.Id.Value);
         }
     }
 }
コード例 #7
0
		public void Process(UnicornSyncCompletePipelineArgs args)
		{
			var logger = args.Configuration.Resolve<ILogger>();
			
			if(logger == null) return;

			logger.Info("{0}: {1} item{5} modified ({2} added, {3} updated, {4} deleted)".FormatWith(args.Configuration.Name,
				args.Changes.Count,
				args.Changes.Count(x => x.ChangeType == ChangeType.Created),
				args.Changes.Count(x => x.ChangeType == ChangeType.Modified),
				args.Changes.Count(x => x.ChangeType == ChangeType.Deleted),
				args.Changes.Count != 1 ? "s" : string.Empty));
		}
コード例 #8
0
		public void Process(UnicornSyncCompletePipelineArgs args)
		{
			var targetId = TemplateIDs.DictionaryEntry.Guid;

			if (args.Changes.Any(item => (item.TemplateId ?? Guid.Empty).Equals(targetId)))
			{
				var log = args.Configuration.Resolve<ILogger>();

				log.Debug(string.Empty);
				log.Debug("> Dictionary entries were altered during sync. Clearing dictionary caches...");
				Translate.ResetCache();
			}
		}
コード例 #9
0
        public void Process(UnicornSyncCompletePipelineArgs args)
        {
            var targetId = TemplateIDs.DictionaryEntry.Guid;

            if (args.Changes.Any(item => (item.TemplateId ?? Guid.Empty).Equals(targetId)))
            {
                var log = args.Configuration.Resolve <ILogger>();

                log.Debug(string.Empty);
                log.Debug("> Dictionary entries were altered during sync. Clearing dictionary caches...");
                Translate.ResetCache();
            }
        }
コード例 #10
0
 public void Process(UnicornSyncCompletePipelineArgs args)
 {
     foreach (var item in args.Changes)
     {
         if (item.SerializedItem != null)
         {
             ManualPublishQueueHandler.AddItemToPublish(item.SerializedItem.Id);
         }
         if (item.SourceItem != null)
         {
             ManualPublishQueueHandler.AddItemToPublish(item.SourceItem.Id);
         }
     }
 }
コード例 #11
0
        protected virtual bool NeedsPostProcessing(UnicornSyncCompletePipelineArgs args)
        {
            if (args.Changes.Count == 0)
            {
                return(false);
            }

            var syncConfiguration = args.Configuration.Resolve <ISyncConfiguration>();

            if (syncConfiguration != null && (syncConfiguration.UpdateLinkDatabase || syncConfiguration.UpdateSearchIndex))
            {
                return(true);
            }

            return(false);
        }
コード例 #12
0
        public void Process(UnicornSyncCompletePipelineArgs args)
        {
            var logger = args.Configuration.Resolve <ILogger>();

            if (logger == null)
            {
                return;
            }

            logger.Info("{0}: {1} item{5} modified ({2} added, {3} updated, {4} deleted)".FormatWith(args.Configuration.Name,
                                                                                                     args.Changes.Count,
                                                                                                     args.Changes.Count(x => x.ChangeType == ChangeType.Created),
                                                                                                     args.Changes.Count(x => x.ChangeType == ChangeType.Modified),
                                                                                                     args.Changes.Count(x => x.ChangeType == ChangeType.Deleted),
                                                                                                     args.Changes.Count != 1 ? "s" : string.Empty));
        }
コード例 #13
0
ファイル: SyncUsers.cs プロジェクト: Eldblom/Unicorn
        public void Process(UnicornSyncCompletePipelineArgs args)
        {
            var userPredicate = args.Configuration.Resolve<IUserPredicate>();

            // no predicate = configuration doesn't include any users
            if (userPredicate == null) return;

            var loader = args.Configuration.Resolve<IUserLoader>();
            var logger = args.Configuration.Resolve<ILogger>();

            logger.Info(string.Empty);
            logger.Info($"{args.Configuration.Name} users are being synced.");

            loader.Load(args.Configuration);

            logger.Info($"{args.Configuration.Name} user sync complete.");
        }
コード例 #14
0
        public void Process(UnicornSyncCompletePipelineArgs args)
        {
            var logger = args.Configuration.Resolve<ILogger>();

            if(logger == null) return;

            var durationInMs = (DateTime.Now - args.SyncStartedTimestamp).TotalMilliseconds;
            var msPerItem = (durationInMs/(args.ProcessedItemCount == 0 ? 1 : args.ProcessedItemCount)).ToString("N1");

            logger.Info("{0}: {1} item{2} evaluated, {3} item{4} modified ({5} added, {6} updated, {7} recycled) in {8}ms (~{9}ms/item)".FormatWith(
                args.Configuration.Name,
                args.ProcessedItemCount,
                args.ProcessedItemCount != 1 ? "s": string.Empty,
                args.Changes.Count,
                args.Changes.Count != 1 ? "s" : string.Empty,
                args.Changes.Count(x => x.ChangeType == ChangeType.Created),
                args.Changes.Count(x => x.ChangeType == ChangeType.Modified),
                args.Changes.Count(x => x.ChangeType == ChangeType.Deleted),
                (int)durationInMs,
                msPerItem));
        }
コード例 #15
0
        public void Process(UnicornSyncCompletePipelineArgs args)
        {
            if (!"true".Equals(UnconditionalCacheClearing, StringComparison.OrdinalIgnoreCase))
            {
                if (!NeedsPostProcessing(args))
                {
                    return;
                }
            }

            var logger = args.Configuration.Resolve <ILogger>();

            logger.Debug(string.Empty);
            logger.Debug("> Preparing to post-process synced items (links/indexes). May take some time depending on change count...");

            // carpet bomb the cache since it can be out of date after a sync (before the serialization complete event has fired, which is after this happens)
            CacheManager.ClearAllCaches();
            var dbs = Factory.GetDatabases();

            foreach (var db in dbs)
            {
                db.Engines.TemplateEngine.Reset();
            }

            logger.Debug("> Caches have been cleared and template engine reset. Resolving items...");

            // resolve changed items from the sync. Note: this may not perform the most awesome with huge syncs.
            // but it's better than keeping stale items in memory during the sync. Note also that deleted items
            // from the sync will not resolve, because...they are gone. So the post processing here will not occur.
            var items = args.Changes
                        .Where(change => change.ChangeType != ChangeType.Deleted && change.Id.HasValue)
                        .Select(change => dbs.FirstOrDefault(db => db.Name.Equals(change.DatabaseName))?.GetItem(new ID(change.Id.Value)))
                        .Where(item => item != null)
                        .ToArray();

            logger.Debug("> Post process items resolved.");

            PostProcessItems(items, args.Configuration);
        }