protected virtual void Process(IProgressStatus progress, ILogger additionalLogger) { var configurations = ResolveConfigurations(); int taskNumber = 1; foreach (var configuration in configurations) { var logger = configuration.Resolve <ILogger>(); var helper = configuration.Resolve <SerializationHelper>(); using (new LoggingContext(additionalLogger, configuration)) { try { logger.Info(configuration.Name + " is being synced."); using (new TransparentSyncDisabler()) { var pathResolver = configuration.Resolve <PredicateRootPathResolver>(); var roots = pathResolver.GetRootSerializedItems(); var index = 0; helper.SyncTree(configuration, item => { WebConsoleUtility.SetTaskProgress(progress, taskNumber, configurations.Length, (int)((index / (double)roots.Length) * 100)); index++; }, roots); } } catch (DeserializationSoftFailureAggregateException ex) { logger.Error(ex); // allow execution to continue, because the exception was non-fatal } catch (Exception ex) { logger.Error(ex); break; } } taskNumber++; } try { CorePipeline.Run("unicornSyncEnd", new UnicornSyncEndPipelineArgs(progress, configurations)); } catch (Exception exception) { Log.Error("Error occurred in unicornSyncEnd pipeline.", exception); progress.ReportException(exception); } }
protected virtual void Process(IProgressStatus progress, ILogger additionalLogger) { var configurations = ResolveConfigurations(); int taskNumber = 1; foreach (var configuration in configurations) { var logger = configuration.Resolve<ILogger>(); var helper = configuration.Resolve<SerializationHelper>(); using (new LoggingContext(additionalLogger, configuration)) { try { logger.Info(configuration.Name + " is being synced."); using (new TransparentSyncDisabler()) { var pathResolver = configuration.Resolve<PredicateRootPathResolver>(); var roots = pathResolver.GetRootSerializedItems(); var index = 0; helper.SyncTree(configuration, item => { WebConsoleUtility.SetTaskProgress(progress, taskNumber, configurations.Length, (int)((index / (double)roots.Length) * 100)); index++; }, roots); } } catch (DeserializationSoftFailureAggregateException ex) { logger.Error(ex); // allow execution to continue, because the exception was non-fatal } catch (Exception ex) { logger.Error(ex); break; } } taskNumber++; } try { CorePipeline.Run("unicornSyncEnd", new UnicornSyncEndPipelineArgs(progress, configurations)); } catch (Exception exception) { Log.Error("Error occurred in unicornSyncEnd pipeline.", exception); progress.ReportException(exception); } }
protected override void Process(IProgressStatus progress) { progress.ReportStatus("Starting WebForms demonstration..."); for (int i = 0; i <= 100; i++) { // slight delay to see loading time System.Threading.Thread.Sleep(50); // advance the progress bar status (you can use x % as well as x of y total items) progress.Report(i); // demonstrate setting a substatus of the progress bar (e.g. "making database backup") if (i % 10 == 0) progress.ReportTransientStatus(string.Format("{0}/{1}", i, 100)); // write some stuff to the console to demonstrate detailed output progress.ReportStatus("At {0}", MessageType.Info, i); if (i == 90) progress.ReportStatus("Oops, fake error", MessageType.Error); if (i == 91) progress.ReportStatus("Warning: this can be harmful if misused.", MessageType.Warning); if (i == 92) { progress.ReportStatus("You can also {0} {1}", MessageType.Debug, "use", "string formatting"); } if (i == 95) { progress.ReportStatus("I'm about to throw an exception and write its data to the console!"); // code that can throw an exception should have it caught and written to the console // normally you might wrap the whole processing in a try-catch block try { throw new Exception("I'm giving it all she's got Jim!", new Exception("Warp core breach")); } catch(Exception ex) { progress.ReportException(ex); } } } progress.ReportStatus("WebForms demo complete. See the <a href=\"Tasks.aspx\">tasks demo</a> and the <a href=\"customized.aspx\">customization demo</a>"); }
private static void ProcessPreset(IncludeEntry preset, IProgressStatus progress) { try { using (new SecurityDisabler()) { new SerializationLoader().LoadTree( new AdvancedLoadOptions(preset) { Progress = progress, ForceUpdate = false, DeleteOrphans = true }); } } catch (Exception ex) { if(Debugger.IsAttached) Debugger.Break(); progress.ReportException(ex); } }
private static void ProcessPreset(IncludeEntry preset, IProgressStatus progress) { try { using (new SecurityDisabler()) { new SerializationLoader().LoadTree( new AdvancedLoadOptions(preset) { Progress = progress, ForceUpdate = false, DeleteOrphans = true }); } } catch (Exception ex) { if (Debugger.IsAttached) { Debugger.Break(); } progress.ReportException(ex); } }
protected override void Process(IProgressStatus progress) { var configurations = ResolveConfigurations(); int taskNumber = 1; foreach (var configuration in configurations) { var logger = configuration.Resolve<ILogger>(); var helper = configuration.Resolve<SerializationHelper>(); using (new LoggingContext(new WebConsoleLogger(progress), configuration)) { try { logger.Info(string.Empty); logger.Info(configuration.Name + " is being synced."); using (new TransparentSyncDisabler()) { var pathResolver = configuration.Resolve<PredicateRootPathResolver>(); var roots = pathResolver.GetRootSerializedItems(); var index = 0; helper.SyncTree(configuration, item => { SetTaskProgress(progress, taskNumber, configurations.Length, (int)((index / (double)roots.Length) * 100)); index++; }, roots); } } catch (Exception ex) { logger.Error(ex); break; } } taskNumber++; } try { CorePipeline.Run("unicornSyncEnd", new UnicornSyncEndPipelineArgs(progress, configurations)); } catch (Exception exception) { Log.Error("Error occurred in unicornSyncEnd pipeline.", exception); progress.ReportException(exception); } }
public virtual void ReportException(Exception exception) { _mainTask.ReportException(exception); }