private void ProcessReserialize(ProgressReporter progress) { foreach (var configuration in ResolveConfigurations()) { var logger = configuration.Resolve<ILogger>(); using (new LoggingContext(progress, configuration)) { try { logger.Info("Control Panel Reserialize: Processing Unicorn configuration " + configuration.Name); var predicate = configuration.Resolve<IPredicate>(); var serializationProvider = configuration.Resolve<ISerializationProvider>(); var roots = configuration.Resolve<PredicateRootPathResolver>().GetRootSourceItems(); int index = 1; foreach (var root in roots) { var rootReference = serializationProvider.GetReference(root); if (rootReference != null) { logger.Warn("[D] existing serialized items under {0}".FormatWith(rootReference.DisplayIdentifier)); rootReference.Delete(); } logger.Info("[U] Serializing included items under root {0}".FormatWith(root.DisplayIdentifier)); Serialize(root, predicate, serializationProvider, logger); progress.ReportProgress((int)((index / (double)roots.Length) * 100)); index++; } logger.Info("Control Panel Reserialize: Finished reserializing Unicorn configuration " + configuration.Name); } catch (Exception ex) { logger.Error(ex); break; } } } }
private void Process(HttpContext context, Action<ProgressReporter> action) { context.Response.Buffer = false; context.Response.BufferOutput = false; context.Response.ContentType = "text/plain"; SetSuccessResponse(context); using (var outputStream = context.Response.OutputStream) { using (var streamWriter = new StreamWriter(outputStream)) { var progress = new ProgressReporter(streamWriter); using (new SecurityDisabler()) { using (new ItemFilterDisabler()) { action(progress); } } } } }
private void ProcessSync(ProgressReporter progress) { foreach (var configuration in ResolveConfigurations()) { using (new LoggingContext(progress, configuration)) { try { progress.ReportSimple("Control Panel Sync: Processing Unicorn configuration " + configuration.Name, MessageLevel.Info); var pathResolver = configuration.Resolve<PredicateRootPathResolver>(); var retryer = configuration.Resolve<IDeserializeFailureRetryer>(); var consistencyChecker = configuration.Resolve<IConsistencyChecker>(); var loader = configuration.Resolve<SerializationLoader>(); var roots = pathResolver.GetRootSerializedItems(); int index = 1; loader.LoadAll(roots, retryer, consistencyChecker, item => { progress.ReportProgress((int)((index / (double)roots.Length) * 100)); index++; }); progress.ReportSimple("Control Panel Sync: Completed syncing Unicorn configuration " + configuration.Name, MessageLevel.Info); } catch (Exception ex) { progress.Error(ex); break; } } } }