public override void Initialize(IEventSource eventSource) { //parse the values passed in as parameters InitializeParameters(); if (string.IsNullOrEmpty(LogFile)) { //apply default log name here LogFile = "hello2.log"; } //always writes to a log with this name if (File.Exists(LogFile)) { File.Delete(LogFile); } //initialize the writer writer = new StreamWriter(LogFile); //register to the events you are interested in here eventSource.BuildStarted += BuildStarted; eventSource.BuildFinished += BuildFinished; eventSource.CustomEventRaised += CustomEvent; eventSource.ErrorRaised += ErrorRaised; eventSource.MessageRaised += MessageRaised; eventSource.ProjectStarted += ProjectStarted; eventSource.ProjectStarted += ProjectFinished; eventSource.TargetStarted += TargetStarted; eventSource.TargetFinished += TargetFinished; eventSource.TaskStarted += TaskStarted; eventSource.TaskFinished += TaskFinished; eventSource.WarningRaised += WarningRaised; }
protected override void DeleteEntity(IEventSource session, object entity, EntityEntry entityEntry, bool isCascadeDeleteEnabled, IEntityPersister persister, ISet transientEntities) { if (entity is IPermanent) { var e = (IPermanent)entity; e.IsDeleted = true; CascadeBeforeDelete(session, persister, entity, entityEntry, transientEntities); CascadeAfterDelete(session, persister, entity, transientEntities); } else { base.DeleteEntity(session, entity, entityEntry, isCascadeDeleteEnabled, persister, transientEntities); } }
private void AttachToRequiredEvents(IEventSource eventSource) { eventSource.ErrorRaised += eventSource_ErrorRaised; eventSource.WarningRaised += eventSource_WarningRaised; eventSource.BuildStarted += eventSource_BuildStartedHandler; eventSource.BuildFinished += eventSource_BuildFinishedHandler; if (Verbosity == LoggerVerbosity.Quiet) return; eventSource.MessageRaised += eventSource_MessageHandler; eventSource.CustomEventRaised += eventSource_CustomBuildEventHandler; eventSource.ProjectStarted += eventSource_ProjectStartedHandler; eventSource.ProjectFinished += eventSource_ProjectFinishedHandler; if (Verbosity == LoggerVerbosity.Minimal) return; eventSource.TargetStarted += eventSource_TargetStartedHandler; eventSource.TargetFinished += eventSource_TargetFinishedHandler; if (Verbosity == LoggerVerbosity.Normal) return; eventSource.TaskStarted += eventSource_TaskStartedHandler; eventSource.TaskFinished += eventSource_TaskFinishedHandler; }
public void Initialize(IEventSource eventSource) { eventSource.MessageRaised += (sender, e) => { var shouldLog = e.Importance == MessageImportance.High && Verbosity >= LoggerVerbosity.Minimal; shouldLog |= e.Importance == MessageImportance.Normal && Verbosity >= LoggerVerbosity.Normal; shouldLog |= e.Importance == MessageImportance.Low && Verbosity >= LoggerVerbosity.Detailed; if (shouldLog) { output.WriteLine(e.Message); Messages.Add(e); } }; if (Verbosity >= LoggerVerbosity.Detailed) eventSource.AnyEventRaised += (sender, e) => output.WriteLine(e.Message); eventSource.ErrorRaised += (sender, e) => { output.WriteLine(e.Message); Errors.Add(e); }; eventSource.WarningRaised += (sender, e) => { output.WriteLine(e.Message); Warnings.Add(e); }; }
public override void Initialize(IEventSource eventSource) { errorList = new List<string>(); warningList = new List<string>(); buildElements = new Stack<XmlElement>(); projectElements = new Stack<XmlElement>(); targetElements = new Stack<XmlElement>(); taskElements = new Stack<XmlElement>(); buildTypeList = new Stack<BuildType>(); //apply default values if (string.IsNullOrEmpty(LogFile)) { LogFile = @"build.log.xml"; } Append = false; ShowSummary = false; comparer = new MSBuildComparer(); //have base init the parameters base.Initialize(eventSource); this.InitializeEvents(eventSource); this.InitializeXmlDoc(); }
/// <summary> /// Initializes the logger and subscribes to the relevant events. /// </summary> /// <param name="eventSource">The available events that processEvent logger can subscribe to.</param> public override void Initialize(IEventSource eventSource) { ProcessParameters(); eventSource.BuildStarted += (s, args) => _build = new Build(args); eventSource.BuildFinished += (o, args) => _build.CompleteBuild(args, _logFile, _errors, _warings); eventSource.ProjectStarted += (o, args) => TryProcessEvent(() => _build.AddProject(args)); eventSource.ProjectFinished += (o, args) => TryProcessEvent(() => _build.CompleteProject(args)); eventSource.TargetStarted += (o, args) => TryProcessEvent(() => _build.AddTarget(args)); eventSource.TargetFinished += (o, args) => TryProcessEvent(() => _build.CompleteTarget(args)); eventSource.TaskStarted += (o, args) => TryProcessEvent(() => _build.AddTask(args)); eventSource.TaskFinished += (o, args) => TryProcessEvent(() => _build.CompleteTask(args)); eventSource.TaskFinished += (o, args) => TryProcessEvent(() => _build.CompleteTask(args)); eventSource.MessageRaised += HandleMessageRaised; eventSource.ErrorRaised += (o, args) => { _errors++; _build.AddMessage(args, string.Format("Error {0}: {1}", args.Code, args.Message)); }; eventSource.WarningRaised += (o, args) => { _warings++; _build.AddMessage(args, string.Format("Warning {0}: {1}", args.Code, args.Message)); }; }
/// <summary> /// Initializes the custom logger, hooking the ErrorRaised notification event. /// </summary> public void Initialize(IEventSource eventSource) { if (eventSource != null) { eventSource.ErrorRaised += ErrorRaised; } }
public void Initialize(IEventSource eventSource) { //always writes to a log with this name string logFile = "hello.log"; if (File.Exists(logFile)) { File.Delete(logFile); } //initialize the writer writer = new StreamWriter(logFile); writer.AutoFlush = true; //this write must be closed in the Shutdown() method //register to the events you are interested in here eventSource.AnyEventRaised += AnyEventRaised; eventSource.BuildStarted += BuildStarted; eventSource.BuildFinished += BuildFinished; eventSource.CustomEventRaised += CustomEvent; eventSource.ErrorRaised += ErrorRaised; eventSource.MessageRaised += MessageRaised; eventSource.ProjectStarted += ProjectStarted; eventSource.ProjectStarted += ProjectFinished; eventSource.StatusEventRaised += StatusEvent; eventSource.TargetStarted += TargetStarted; eventSource.TargetFinished += TargetFinished; eventSource.TaskStarted += TaskStarted; eventSource.TaskFinished += TaskFinished; eventSource.WarningRaised += WarningRaised; }
public override void Initialize(IEventSource eventSource) { this.handler = this.OnMessage; eventSource.BuildFinished += this.BuildFinished; eventSource.BuildStarted += this.BuildStarted; eventSource.ErrorRaised += this.ErrorRaised; eventSource.WarningRaised += this.WarningRaised; if (this.Verbosity != LoggerVerbosity.Quiet) { eventSource.MessageRaised += this.MessageRaised; eventSource.ProjectStarted += this.ProjectStarted; eventSource.ProjectFinished += this.ProjectFinished; } if (this.IsVerbosityAtLeast(LoggerVerbosity.Normal)) { eventSource.TargetStarted += this.TargetStarted; eventSource.TargetFinished += this.TargetFinished; } if (this.IsVerbosityAtLeast(LoggerVerbosity.Detailed)) { eventSource.TaskStarted += this.TaskStarted; eventSource.TaskFinished += this.TaskFinished; } }
/// <summary> /// Initialize Override /// </summary> /// <param name="eventSource">IEventSource</param> public override void Initialize(IEventSource eventSource) { this.logFileName = "securemsbuild.log"; this.encoding = Encoding.Default; this.InitializeFileLogger(); eventSource.BuildFinished += this.BuildFinished; eventSource.BuildStarted += this.BuildStarted; eventSource.ErrorRaised += this.ErrorRaised; eventSource.WarningRaised += this.WarningRaised; if (this.Verbosity != LoggerVerbosity.Quiet) { eventSource.MessageRaised += this.MessageRaised; eventSource.ProjectStarted += this.ProjectStarted; eventSource.ProjectFinished += this.ProjectFinished; } if (this.IsVerbosityAtLeast(LoggerVerbosity.Normal)) { eventSource.TargetStarted += this.TargetStarted; eventSource.TargetFinished += this.TargetFinished; } if (this.IsVerbosityAtLeast(LoggerVerbosity.Detailed)) { eventSource.TaskStarted += this.TaskStarted; eventSource.TaskFinished += this.TaskFinished; } }
protected virtual void Validate(object entity, IEntityPersister persister, IEventSource source) { if (persister.ImplementsValidatable(source.EntityMode)) { ((IValidatable)entity).Validate(); } }
protected override IEventSource OnSourceSet(IEventSource eventSource) { if (!(eventSource is IDatabase)) throw new ArgumentException("Session event sources can be only databases"); return base.OnSourceSet(eventSource); }
/// <summary> /// Initializes the logger by attaching events and parsing command line. /// </summary> /// <param name="eventSource">The event source.</param> public override void Initialize(IEventSource eventSource) { outputPath = this.Parameters; InitializeLogFile(); // attach only to events required in current log verbosity eventSource.ErrorRaised += new BuildErrorEventHandler(eventSource_ErrorRaised); eventSource.WarningRaised += new BuildWarningEventHandler(eventSource_WarningRaised); eventSource.BuildStarted += new BuildStartedEventHandler(eventSource_BuildStartedHandler); eventSource.BuildFinished += new BuildFinishedEventHandler(eventSource_BuildFinishedHandler); if (Verbosity != LoggerVerbosity.Quiet) // minimal and above { eventSource.MessageRaised += new BuildMessageEventHandler(eventSource_MessageHandler); eventSource.CustomEventRaised += new CustomBuildEventHandler(eventSource_CustomBuildEventHandler); eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStartedHandler); eventSource.ProjectFinished += new ProjectFinishedEventHandler(eventSource_ProjectFinishedHandler); if (Verbosity != LoggerVerbosity.Minimal) // normal and above { eventSource.TargetStarted += new TargetStartedEventHandler(eventSource_TargetStartedHandler); eventSource.TargetFinished += new TargetFinishedEventHandler(eventSource_TargetFinishedHandler); if (Verbosity != LoggerVerbosity.Normal) // only detailed and diagnostic { eventSource.TaskStarted += new TaskStartedEventHandler(eventSource_TaskStartedHandler); eventSource.TaskFinished += new TaskFinishedEventHandler(eventSource_TaskFinishedHandler); } } } }
void ILogger.Initialize(IEventSource eventSource) { eventSource.MessageRaised += EventSourceMessageRaised; eventSource.WarningRaised += EventSourceWarningRaised; eventSource.ErrorRaised += EventSourceErrorRaised; eventSource.BuildFinished += _buildFinished; }
public override void Initialize(IEventSource eventSource) { if (null == Parameters) { throw new LoggerException("Log file was not set."); } string[] parameters = Parameters.Split(';'); string logFile = parameters[0]; if (String.IsNullOrEmpty(logFile)) { throw new LoggerException("Log file was not set."); } if (parameters.Length > 1) { throw new LoggerException("Too many parameters passed."); } // Open the file _streamWriter = new StreamWriter(logFile); //eventSource.BuildStarted += new BuildStartedEventHandler(BuildStarted); eventSource.BuildFinished += new BuildFinishedEventHandler(BuildFinished); eventSource.ErrorRaised += new BuildErrorEventHandler(ErrorRaised); //eventSource.MessageRaised += new BuildMessageEventHandler(MessageRaised); eventSource.ProjectFinished += new ProjectFinishedEventHandler(ProjectFinished); //eventSource.ProjectStarted += new ProjectStartedEventHandler(ProjectStarted); //eventSource.StatusEventRaised += new BuildStatusEventHandler(StatusEventRaised); //eventSource.TargetFinished += new TargetFinishedEventHandler(TargetFinished); //eventSource.TargetStarted += new TargetStartedEventHandler(TargetStarted); //eventSource.TaskFinished += new TaskFinishedEventHandler(TaskFinished); //eventSource.TaskStarted += new TaskStartedEventHandler(TaskStarted); eventSource.WarningRaised += new BuildWarningEventHandler(WarningRaised); }
public RefreshEvent(object entity, IEventSource source) : base(source) { if (entity == null) throw new ArgumentNullException("entity", "Attempt to generate refresh event with null object"); this.entity = entity; }
public override void Initialize (IEventSource eventSource) { eventSource.TargetStarted += new TargetStartedEventHandler(TargetStarted); eventSource.TargetFinished += new TargetFinishedEventHandler(TargetFinished); eventSource.MessageRaised += new BuildMessageEventHandler(Message); eventSource.WarningRaised += new BuildWarningEventHandler(Warning); }
private NetworkEvent(INetwork network, IEventType type, IEventSource source) { Network = network; Type = type; TimeStamp = DateTime.UtcNow; Source = source; }
/// <summary> /// Initialize is guaranteed to be called by MSBuild at the start of the build /// before any events are raised. /// </summary> public override void Initialize(IEventSource eventSource) { // The name of the log file should be passed as the first item in the // "parameters" specification in the /logger switch. It is required // to pass a log file to this logger. Other loggers may have zero or more than // one parameters. if (null == Parameters) { throw new LoggerException("Log file was not set."); } string[] parameters = Parameters.Split(';'); string logFile = parameters[0]; if (String.IsNullOrEmpty(logFile)) { throw new LoggerException("Log file was not set."); } if (parameters.Length > 1) { throw new LoggerException("Too many parameters passed."); } try { // Open the file this.streamWriter = new StreamWriter(logFile); } catch (Exception ex) { if ( ex is UnauthorizedAccessException || ex is ArgumentNullException || ex is PathTooLongException || ex is DirectoryNotFoundException || ex is NotSupportedException || ex is ArgumentException || ex is SecurityException || ex is IOException ) { throw new LoggerException("Failed to create log file: " + ex.Message); } else { // Unexpected failure throw; } } // For brevity, we'll only register for certain event types. Loggers can also // register to handle TargetStarted/Finished and other events. eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStarted); eventSource.TaskStarted += new TaskStartedEventHandler(eventSource_TaskStarted); eventSource.MessageRaised += new BuildMessageEventHandler(eventSource_MessageRaised); eventSource.WarningRaised += new BuildWarningEventHandler(eventSource_WarningRaised); eventSource.ErrorRaised += new BuildErrorEventHandler(eventSource_ErrorRaised); eventSource.ProjectFinished += new ProjectFinishedEventHandler(eventSource_ProjectFinished); }
/// <summary> /// Converts the given method into an <see cref="ISourcedEventHandler"/> object. /// </summary> /// <param name="aggregateRoot">The event source from which we want to invoke the method.</param> /// <param name="method">The method to invoke</param> /// <param name="exact"><b>True</b> if we need to have an exact match, otherwise <b>False</b>.</param> /// <returns>An <see cref="ISourcedEventHandler"/> that handles the execution of the given method.</returns> private static ISourcedEventHandler CreateHandlerForMethod(IEventSource eventSource, MethodInfo method, bool exact) { Type firstParameterType = method.GetParameters().First().ParameterType; Action<IEvent> handler = e => method.Invoke(eventSource, new object[] { e }); return new TypeThresholdedActionBasedDomainEventHandler(handler, firstParameterType, exact); }
/// <summary> /// Gets the event handlers from aggregate root based on the given mapping. /// </summary> /// <param name="eventSource">The aggregate root.</param> /// <see cref="ExpressionBasedSourcedEventHandlerMappingStrategy"/> /// <returns>All the <see cref="ISourcedEventHandler"/>'s created based on the given mapping.</returns> public IEnumerable<ISourcedEventHandler> GetEventHandlersFromAggregateRoot(IEventSource eventSource) { Contract.Requires<ArgumentNullException>(eventSource != null, "The eventSource cannot be null."); if(!(eventSource is AggregateRootMappedWithExpressions)) { throw new ArgumentException("aggregateRoot need to be of type AggregateRootMappedWithExpressions to be used in a ExpressionBasedSourcedEventHandlerMappingStrategy."); } var handlers = new List<ISourcedEventHandler>(); foreach (ExpressionHandler mappinghandler in ((AggregateRootMappedWithExpressions)eventSource).MappingHandlers) { if (mappinghandler.ActionMethodInfo.IsStatic) { var message = String.Format("The method {0}.{1} could not be mapped as an event handler, since it is static.", mappinghandler.ActionMethodInfo.DeclaringType.Name, mappinghandler.ActionMethodInfo.Name); throw new InvalidEventHandlerMappingException(message); } var handler = CreateHandlerForMethod(eventSource, mappinghandler.ActionMethodInfo, mappinghandler.Exact); handlers.Add(handler); } return handlers; }
public override void Initialize(IEventSource eventSource) { _fileName = "build.log.md"; _messages = new StringBuilder(); //Register for the events here eventSource.BuildStarted += new BuildStartedEventHandler(this.BuildStarted); eventSource.BuildFinished += new BuildFinishedEventHandler(this.BuildFinished); eventSource.ProjectStarted += new ProjectStartedEventHandler(this.ProjectStarted); eventSource.ProjectFinished += new ProjectFinishedEventHandler(this.ProjectFinished); eventSource.TargetStarted += new TargetStartedEventHandler(this.TargetStarted); eventSource.TargetFinished += new TargetFinishedEventHandler(this.TargetFinished); eventSource.TaskStarted += new TaskStartedEventHandler(this.TaskStarted); eventSource.TaskFinished += new TaskFinishedEventHandler(this.TaskFinished); eventSource.ErrorRaised += new BuildErrorEventHandler(this.BuildError); eventSource.WarningRaised += new BuildWarningEventHandler(this.BuildWarning); eventSource.MessageRaised += new BuildMessageEventHandler(this.BuildMessage); this.InitializeParameters(); }
/// <summary> Constructs an event containing the pertinent information. </summary> /// <param name="source">The session from which the event originated. </param> /// <param name="entity">The entity to be invloved in the database operation. </param> /// <param name="id">The entity id to be invloved in the database operation. </param> /// <param name="persister">The entity's persister. </param> protected AbstractPreDatabaseOperationEvent(IEventSource source, object entity, object id, IEntityPersister persister) : base(source) { Entity = entity; Id = id; Persister = persister; }
public void Save(IEventSource source) { try { using (var session = _documentStore.OpenSession()) { session.UseOptimisticConcurrency = true; foreach (var sourcedEvent in source.GetUncommittedEvents()) { session.Store(new StoredEvent { Data = sourcedEvent, EventSequence = sourcedEvent.EventSequence, EventSourceId = sourcedEvent.EventSourceId, Id = sourcedEvent.EventSourceId + "/" + sourcedEvent.EventSequence }); } session.SaveChanges(); } } catch (Raven.Database.Exceptions.ConcurrencyException) { throw new ConcurrencyException(source.Id, source.Version); } }
protected override object PerformSave(object entity, object id, IEntityPersister persister, bool useIdentityColumn, object anything, IEventSource source, bool requiresImmediateIdAccess) { var entityValue = entity as EntityBase; if (entityValue != null) { if (entityValue.CreatedBy == null || entityValue.CreatedBy.Equals(string.Empty)) { entityValue.CreatedBy = EntityConstant.CreatedBy; entityValue.CreatedOn = DateTime.Now; } else { entityValue.UpdatedBy = EntityConstant.UpdatedBy; entityValue.UpdatedOn = DateTime.Now; } } foreach (var property in entity.GetType().GetProperties()) { var propertyValue = property.GetValue(entity, null); if (propertyValue == null) { continue; } if (propertyValue.GetType().IsSubclassOf(typeof(EntityBase))) { var value = propertyValue as EntityBase; value.CreatedBy = EntityConstant.CreatedBy; value.CreatedOn = DateTime.Now; } } return base.PerformSave(entityValue, id, persister, useIdentityColumn, anything, source, requiresImmediateIdAccess); }
/// <summary> /// When overridden in a derived class, subscribes the logger to specific events. /// </summary> /// <param name="eventSource">The available events that a logger can subscribe to.</param> /// <exception cref="Microsoft.Build.Framework.LoggerException"> /// Log file was not set. /// or /// Log file was not set. /// or /// Failed to create log file: + ex.Message /// </exception> public override void Initialize(IEventSource eventSource) { // The name of the log file should be passed as the first item in the // "parameters" specification in the /logger switch. It is required // to pass a log file to this logger. Other loggers may have zero or more than // one parameters. if (Parameters == null) throw new LoggerException("Log file was not set."); var logFilename = Parameters.Split(';').FirstOrDefault(); if (string.IsNullOrEmpty(logFilename)) throw new LoggerException("Log file was not set."); try { _streamWriter = new StreamWriter(logFilename, false, System.Text.Encoding.UTF8); } catch (Exception ex) { throw new LoggerException("Failed to create log file: " + ex.Message); } eventSource.WarningRaised += WarningRaisedEventHandler; eventSource.BuildFinished += BuildFinishedEventHandler; }
public override void Initialize(IEventSource eventSource) { _logFileName = "msbuildresult.xml"; _encoding = Encoding.Default; InitializeFileLogger(); eventSource.BuildFinished += BuildFinished; eventSource.BuildStarted += BuildStarted; eventSource.ErrorRaised += ErrorRaised; eventSource.WarningRaised += WarningRaised; if (Verbosity != LoggerVerbosity.Quiet) { eventSource.MessageRaised += MessageRaised; eventSource.CustomEventRaised += CustomBuildEventRaised; eventSource.ProjectStarted += ProjectStarted; eventSource.ProjectFinished += ProjectFinished; } if (IsVerbosityAtLeast(LoggerVerbosity.Normal)) { eventSource.TargetStarted += TargetStarted; eventSource.TargetFinished += TargetFinished; } if (IsVerbosityAtLeast(LoggerVerbosity.Detailed)) { eventSource.TaskStarted += TaskStarted; eventSource.TaskFinished += TaskFinished; } }
public void Initialize(IEventSource p0) { if (p0 != null) { p0.ErrorRaised += new BuildErrorEventHandler(this.m00024c); } }
public void Initialize(IEventSource eventSource) { this.eventSource = eventSource; engineWorker.OutputText("${res:ICSharpCode.CodeAnalysis.RunningFxCopOn} " + Path.GetFileNameWithoutExtension(engineWorker.CurrentProjectFile)); eventSource.ErrorRaised += OnError; eventSource.WarningRaised += OnWarning; }
public override void Initialize(IEventSource eventSource) { try { this.InitializeParameters(); this.SubscribeToEvents(eventSource); log.Info("Initialize MS Build Logger!"); string ipStr = GetParameterValue("ip"); IPAddress ipServer = IPAddress.Parse(ipStr); int port = int.Parse(GetParameterValue("port")); log.InfoFormat("MS Build Logger port to write {0}", port); clientSocketWriter = new System.Net.Sockets.TcpClient(); clientSocketWriter.Connect(ipServer, port); networkStream = clientSocketWriter.GetStream(); Thread.Sleep(1000); } catch(Exception ex) { log.Error("Exception in MS Build logger", ex); } }
public void Initialize(IEventSource eventSource) { loggerInstance.Initialize(eventSource); }
protected ReattachVisitor(IEventSource session, object ownerIdentifier, object owner) : base(session) { this.ownerIdentifier = ownerIdentifier; this.owner = owner; }
public void Initialize(IEventSource eventSource) { eventSource.TargetStarted += TargetStarted; eventSource.TargetFinished += TargetFinished; eventSource.BuildFinished += BuildFinished; }
public OrderRepository(IEventSource <OrderSnapshotObject> eventSource) { _eventSource = eventSource; }
/// <summary> /// Initializes the logger. /// </summary> public void Initialize(IEventSource eventSource, int nodeCount) { Initialize(eventSource); }
/// <summary> /// Subscribing to the events /// </summary> /// <param name="eventSource"></param> public void Initialize(IEventSource eventSource) { eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStarted); }
/// <summary> /// Signs up the console logger for all build events. /// </summary> /// <param name="eventSource">Available events.</param> public virtual void Initialize(IEventSource eventSource) { ParseParameters(); // Always show perf summary for diagnostic verbosity. if (IsVerbosityAtLeast(LoggerVerbosity.Diagnostic)) { this.showPerfSummary = true; } showTargetOutputs = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("MSBUILDTARGETOUTPUTLOGGING")); // If not specifically instructed otherwise, show a summary in normal // and higher verbosities. if (_showSummary == null && IsVerbosityAtLeast(LoggerVerbosity.Normal)) { _showSummary = true; } if (showOnlyWarnings || showOnlyErrors) { _showSummary = false; this.showPerfSummary = false; } // Put this after reading the parameters, since it may want to initialize something // specially based on some parameter value. For example, choose whether to have a summary, based // on the verbosity. ResetConsoleLoggerState(); // Event source is allowed to be null; this allows the logger to be wrapped by a class that wishes // to call its event handlers directly. The VS HostLogger does this. if (eventSource != null) { eventSource.BuildStarted += new BuildStartedEventHandler(BuildStartedHandler); eventSource.BuildFinished += new BuildFinishedEventHandler(BuildFinishedHandler); eventSource.ProjectStarted += new ProjectStartedEventHandler(ProjectStartedHandler); eventSource.ProjectFinished += new ProjectFinishedEventHandler(ProjectFinishedHandler); eventSource.TargetStarted += new TargetStartedEventHandler(TargetStartedHandler); eventSource.TargetFinished += new TargetFinishedEventHandler(TargetFinishedHandler); eventSource.TaskStarted += new TaskStartedEventHandler(TaskStartedHandler); eventSource.TaskFinished += new TaskFinishedEventHandler(TaskFinishedHandler); eventSource.ErrorRaised += new BuildErrorEventHandler(ErrorHandler); eventSource.WarningRaised += new BuildWarningEventHandler(WarningHandler); eventSource.MessageRaised += new BuildMessageEventHandler(MessageHandler); eventSource.CustomEventRaised += new CustomBuildEventHandler(CustomEventHandler); } }
/// <summary> /// Prepares the save call using the given requested id. /// </summary> /// <param name="entity">The entity to be saved. </param> /// <param name="requestedId">The id to which to associate the entity. </param> /// <param name="entityName">The name of the entity being saved. </param> /// <param name="anything">Generally cascade-specific information. </param> /// <param name="source">The session which is the source of this save event. </param> /// <returns> The id used to save the entity. </returns> protected virtual object SaveWithRequestedId(object entity, object requestedId, string entityName, object anything, IEventSource source) { return(PerformSave(entity, requestedId, source.GetEntityPersister(entityName, entity), false, anything, source, true)); }
protected virtual bool VisitCollectionsBeforeSave(object entity, object id, object[] values, IType[] types, IEventSource source) { WrapVisitor visitor = new WrapVisitor(source); // substitutes into values by side-effect visitor.ProcessEntityPropertyValues(values, types); return(visitor.SubstitutionRequired); }
/// <summary> /// Performs all the actual work needed to save an entity (well to get the save moved to /// the execution queue). /// </summary> /// <param name="entity">The entity to be saved </param> /// <param name="key">The id to be used for saving the entity (or null, in the case of identity columns) </param> /// <param name="persister">The entity's persister instance. </param> /// <param name="useIdentityColumn">Should an identity column be used for id generation? </param> /// <param name="anything">Generally cascade-specific information. </param> /// <param name="source">The session which is the source of the current event. </param> /// <param name="requiresImmediateIdAccess"> /// Is access to the identifier required immediately /// after the completion of the save? persist(), for example, does not require this... /// </param> /// <returns> /// The id used to save the entity; may be null depending on the /// type of id generator used and the requiresImmediateIdAccess value /// </returns> protected virtual object PerformSaveOrReplicate(object entity, EntityKey key, IEntityPersister persister, bool useIdentityColumn, object anything, IEventSource source, bool requiresImmediateIdAccess) { Validate(entity, persister, source); object id = key == null ? null : key.Identifier; // NH Different behavior (shouldDelayIdentityInserts=false anyway) //bool inTxn = source.ConnectionManager.IsInActiveTransaction; //bool shouldDelayIdentityInserts = !inTxn && !requiresImmediateIdAccess; bool shouldDelayIdentityInserts = false; // Put a placeholder in entries, so we don't recurse back and try to save() the // same object again. QUESTION: should this be done before onSave() is called? // likewise, should it be done before onUpdate()? source.PersistenceContext.AddEntry(entity, Status.Saving, null, null, id, null, LockMode.Write, useIdentityColumn, persister, false, false); CascadeBeforeSave(source, persister, entity, anything); // NH-962: This was originally done before many-to-one cascades. if (useIdentityColumn && !shouldDelayIdentityInserts) { log.Debug("executing insertions"); source.ActionQueue.ExecuteInserts(); } object[] values = persister.GetPropertyValuesToInsert(entity, GetMergeMap(anything), source); IType[] types = persister.PropertyTypes; bool substitute = SubstituteValuesIfNecessary(entity, id, values, persister, source); if (persister.HasCollections) { substitute = substitute || VisitCollectionsBeforeSave(entity, id, values, types, source); } if (substitute) { persister.SetPropertyValues(entity, values, source.EntityMode); } TypeHelper.DeepCopy(values, types, persister.PropertyUpdateability, values, source); new ForeignKeys.Nullifier(entity, false, useIdentityColumn, source).NullifyTransientReferences(values, types); new Nullability(source).CheckNullability(values, persister, false); if (useIdentityColumn) { EntityIdentityInsertAction insert = new EntityIdentityInsertAction(values, entity, persister, source, shouldDelayIdentityInserts); if (!shouldDelayIdentityInserts) { log.Debug("executing identity-insert immediately"); source.ActionQueue.Execute(insert); id = insert.GeneratedId; //now done in EntityIdentityInsertAction //persister.setIdentifier( entity, id, source.getEntityMode() ); key = new EntityKey(id, persister, source.EntityMode); source.PersistenceContext.CheckUniqueness(key, entity); //source.getBatcher().executeBatch(); //found another way to ensure that all batched joined inserts have been executed } else { log.Debug("delaying identity-insert due to no transaction in progress"); source.ActionQueue.AddAction(insert); key = insert.DelayedEntityKey; } } object version = Versioning.GetVersion(values, persister); source.PersistenceContext.AddEntity( entity, persister.IsMutable ? Status.Loaded : Status.ReadOnly, values, key, version, LockMode.Write, useIdentityColumn, persister, VersionIncrementDisabled, false); //source.getPersistenceContext().removeNonExist( new EntityKey( id, persister, source.getEntityMode() ) ); if (!useIdentityColumn) { source.ActionQueue.AddAction(new EntityInsertAction(id, values, entity, version, persister, source)); } CascadeAfterSave(source, persister, entity, anything); MarkInterceptorDirty(entity, persister, source); return(id); }
/// <summary> /// Prepares the save call by checking the session caches for a pre-existing /// entity and performing any lifecycle callbacks. /// </summary> /// <param name="entity">The entity to be saved. </param> /// <param name="id">The id by which to save the entity. </param> /// <param name="persister">The entity's persister instance. </param> /// <param name="useIdentityColumn">Is an identity column being used? </param> /// <param name="anything">Generally cascade-specific information. </param> /// <param name="source">The session from which the event originated. </param> /// <param name="requiresImmediateIdAccess"> /// does the event context require /// access to the identifier immediately after execution of this method (if /// not, post-insert style id generators may be postponed if we are outside /// a transaction). /// </param> /// <returns> /// The id used to save the entity; may be null depending on the /// type of id generator used and the requiresImmediateIdAccess value /// </returns> protected virtual object PerformSave(object entity, object id, IEntityPersister persister, bool useIdentityColumn, object anything, IEventSource source, bool requiresImmediateIdAccess) { if (log.IsDebugEnabled) { log.Debug("saving " + MessageHelper.InfoString(persister, id, source.Factory)); } EntityKey key; if (!useIdentityColumn) { key = new EntityKey(id, persister, source.EntityMode); object old = source.PersistenceContext.GetEntity(key); if (old != null) { if (source.PersistenceContext.GetEntry(old).Status == Status.Deleted) { source.ForceFlush(source.PersistenceContext.GetEntry(old)); } else { throw new NonUniqueObjectException(id, persister.EntityName); } } persister.SetIdentifier(entity, id, source.EntityMode); } else { key = null; } if (InvokeSaveLifecycle(entity, persister, source)) { return(id); //EARLY EXIT } return(PerformSaveOrReplicate(entity, key, persister, useIdentityColumn, anything, source, requiresImmediateIdAccess)); }
/// <summary> /// Prepares the save call using a newly generated id. /// </summary> /// <param name="entity">The entity to be saved </param> /// <param name="entityName">The entity-name for the entity to be saved </param> /// <param name="anything">Generally cascade-specific information. </param> /// <param name="source">The session which is the source of this save event. </param> /// <param name="requiresImmediateIdAccess"> /// does the event context require /// access to the identifier immediately after execution of this method (if /// not, post-insert style id generators may be postponed if we are outside /// a transaction). /// </param> /// <returns> /// The id used to save the entity; may be null depending on the /// type of id generator used and the requiresImmediateIdAccess value /// </returns> protected virtual object SaveWithGeneratedId(object entity, string entityName, object anything, IEventSource source, bool requiresImmediateIdAccess) { IEntityPersister persister = source.GetEntityPersister(entityName, entity); object generatedId = persister.IdentifierGenerator.Generate(source, entity); if (generatedId == null) { throw new IdentifierGenerationException("null id generated for:" + entity.GetType()); } else if (generatedId == IdentifierGeneratorFactory.ShortCircuitIndicator) { return(source.GetIdentifier(entity)); } else if (generatedId == IdentifierGeneratorFactory.PostInsertIndicator) { return(PerformSave(entity, null, persister, true, anything, source, requiresImmediateIdAccess)); } else { if (log.IsDebugEnabled) { log.Debug(string.Format("generated identifier: {0}, using strategy: {1}", persister.IdentifierType.ToLoggableString(generatedId, source.Factory), persister.IdentifierGenerator.GetType().FullName)); } return(PerformSave(entity, generatedId, persister, false, anything, source, true)); } }
public void Initialize(IEventSource eventSource) { eventSource.ErrorRaised += new BuildErrorEventHandler(ErrorHandler); }
public virtual void Initialize(IEventSource eventSource, int nodeCount) { numberOfProcessors = nodeCount; Initialize(eventSource); }
private async Task <bool> ScheduleUpdateAsync(FlushEntityEvent @event, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); EntityEntry entry = @event.EntityEntry; IEventSource session = @event.Session; object entity = @event.Entity; Status status = entry.Status; IEntityPersister persister = entry.Persister; object[] values = @event.PropertyValues; if (log.IsDebugEnabled()) { if (status == Status.Deleted) { if (!persister.IsMutable) { log.Debug("Updating immutable, deleted entity: {0}", MessageHelper.InfoString(persister, entry.Id, session.Factory)); } else if (!entry.IsModifiableEntity()) { log.Debug("Updating non-modifiable, deleted entity: {0}", MessageHelper.InfoString(persister, entry.Id, session.Factory)); } else { log.Debug("Updating deleted entity: {0}", MessageHelper.InfoString(persister, entry.Id, session.Factory)); } } else { log.Debug("Updating entity: {0}", MessageHelper.InfoString(persister, entry.Id, session.Factory)); } } bool intercepted; if (!entry.IsBeingReplicated) { // give the Interceptor a chance to process property values, if the properties // were modified by the Interceptor, we need to set them back to the object intercepted = await(HandleInterceptionAsync(@event, cancellationToken)).ConfigureAwait(false); } else { intercepted = false; } Validate(entity, persister, status); // increment the version number (if necessary) object nextVersion = await(GetNextVersionAsync(@event, cancellationToken)).ConfigureAwait(false); // if it was dirtied by a collection only int[] dirtyProperties = @event.DirtyProperties; if (@event.DirtyCheckPossible && dirtyProperties == null) { if (!intercepted && [email protected]) { throw new AssertionFailure("dirty, but no dirty properties"); } dirtyProperties = Array.Empty <int>(); } // check nullability but do not perform command execute // we'll use scheduled updates for that. new Nullability(session).CheckNullability(values, persister, true); // schedule the update // note that we intentionally do _not_ pass in currentPersistentState! session.ActionQueue.AddAction( new EntityUpdateAction( entry.Id, values, dirtyProperties, @event.HasDirtyCollection, status == Status.Deleted && !entry.IsModifiableEntity() ? persister.GetPropertyValues(entity) : entry.LoadedState, entry.Version, nextVersion, entity, persister, session)); return(intercepted); }
public void Initialize(IEventSource eventSource) { eventSource.ErrorRaised += OnError; eventSource.WarningRaised += OnWarning; }
public void Initialize(IEventSource eventSource) { if (null == Parameters) { throw new LoggerException("Log directory was not set."); } string[] parameters = Parameters.Split(';'); string logDir = parameters[0]; if (String.IsNullOrEmpty(logDir)) { throw new LoggerException("Log directory was not set."); } if (parameters.Length > 1) { throw new LoggerException("Too many parameters passed."); } string logFile = Path.Combine(logDir, "msbuild_log.txt"); string issuesFile = Path.Combine(logDir, "msbuild_issues.csv"); try { if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } this.logStreamWriter = new StreamWriter(logFile); this.issuesStreamWriter = new StreamWriter(issuesFile); } catch (Exception ex) { if ( ex is UnauthorizedAccessException || ex is ArgumentNullException || ex is PathTooLongException || ex is DirectoryNotFoundException || ex is NotSupportedException || ex is ArgumentException || ex is SecurityException || ex is IOException ) { throw new LoggerException("Failed to create log file: " + ex.Message); } else { // Unexpected failure throw; } } eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStarted); eventSource.TaskStarted += new TaskStartedEventHandler(eventSource_TaskStarted); eventSource.MessageRaised += new BuildMessageEventHandler(eventSource_MessageRaised); eventSource.WarningRaised += new BuildWarningEventHandler(eventSource_WarningRaised); eventSource.ErrorRaised += new BuildErrorEventHandler(eventSource_ErrorRaised); eventSource.ProjectFinished += new ProjectFinishedEventHandler(eventSource_ProjectFinished); }
private ContentItem GetByID(object o, IEventSource session) { int id = o is int?(int)o : -1; return(id == 0 ? null : session.Get <ContentItem>(o)); }
public void Initialize(IEventSource eventSource) { eventSource.AnyEventRaised += AnyEvent; eventSource.ErrorRaised += (_, __) => _hasError = true; }
/// <summary> /// Multiproc aware initialization /// </summary> public override void Initialize(IEventSource eventSource, int nodeCount) { InitializeFileLogger(eventSource, nodeCount); }
/// <summary> /// Signs up the console file logger for all build events. /// This is the backward-compatible overload. /// </summary> /// <param name="eventSource">Available events.</param> public override void Initialize(IEventSource eventSource) { ErrorUtilities.VerifyThrowArgumentNull(eventSource, nameof(eventSource)); eventSource.BuildFinished += FileLoggerBuildFinished; InitializeFileLogger(eventSource, 1); }
protected virtual async Task DoEvictAsync(object obj, EntityKey key, IEntityPersister persister, IEventSource session, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (log.IsDebugEnabled()) { log.Debug("evicting {0}", MessageHelper.InfoString(persister)); } // remove all collections for the entity from the session-level cache if (persister.HasCollections) { await(new EvictVisitor(session).ProcessAsync(obj, persister, cancellationToken)).ConfigureAwait(false); } await(new Cascade(CascadingAction.Evict, CascadePoint.AfterEvict, session).CascadeOnAsync(persister, obj, cancellationToken)).ConfigureAwait(false); }
public AzureTableClient(IEventSource eventSource, CloudTableClient cloudTableClient) { _eventSource = eventSource; _cloudTableClient = cloudTableClient; }
public EvictVisitor(IEventSource session) : base(session) { }
private async Task <object> AssembleCacheEntryAsync(CacheEntry entry, object id, IEntityPersister persister, LoadEvent @event, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); object optionalObject = @event.InstanceToLoad; IEventSource session = @event.Session; ISessionFactoryImplementor factory = session.Factory; if (log.IsDebugEnabled()) { log.Debug("assembling entity from second-level cache: {0}", MessageHelper.InfoString(persister, id, factory)); } IEntityPersister subclassPersister = factory.GetEntityPersister(entry.Subclass); object result = optionalObject ?? session.Instantiate(subclassPersister, id); // make it circular-reference safe EntityKey entityKey = session.GenerateEntityKey(id, subclassPersister); TwoPhaseLoad.AddUninitializedCachedEntity(entityKey, result, subclassPersister, LockMode.None, entry.AreLazyPropertiesUnfetched, entry.Version, session); IType[] types = subclassPersister.PropertyTypes; object[] values = await(entry.AssembleAsync(result, id, subclassPersister, session.Interceptor, session, cancellationToken)).ConfigureAwait(false); // intializes result by side-effect TypeHelper.DeepCopy(values, types, subclassPersister.PropertyUpdateability, values, session); object version = Versioning.GetVersion(values, subclassPersister); if (log.IsDebugEnabled()) { log.Debug("Cached Version: {0}", version); } IPersistenceContext persistenceContext = session.PersistenceContext; bool isReadOnly = session.DefaultReadOnly; if (persister.IsMutable) { object proxy = persistenceContext.GetProxy(entityKey); if (proxy != null) { // this is already a proxy for this impl // only set the status to read-only if the proxy is read-only isReadOnly = ((INHibernateProxy)proxy).HibernateLazyInitializer.ReadOnly; } } else { isReadOnly = true; } persistenceContext.AddEntry( result, isReadOnly ? Status.ReadOnly : Status.Loaded, values, null, id, version, LockMode.None, true, subclassPersister, false, entry.AreLazyPropertiesUnfetched); subclassPersister.AfterInitialize(result, entry.AreLazyPropertiesUnfetched, session); await(persistenceContext.InitializeNonLazyCollectionsAsync(cancellationToken)).ConfigureAwait(false); // upgrade the lock if necessary: //lock(result, lockMode); //PostLoad is needed for EJB3 //TODO: reuse the PostLoadEvent... PostLoadEvent postLoadEvent = new PostLoadEvent(session); postLoadEvent.Entity = result; postLoadEvent.Id = id; postLoadEvent.Persister = persister; IPostLoadEventListener[] listeners = session.Listeners.PostLoadEventListeners; for (int i = 0; i < listeners.Length; i++) { listeners[i].OnPostLoad(postLoadEvent); } return(result); }
public FakeStreamableRequestBuilder(Uri serverUri, string defaultSegment, HttpClient httpClient, IEventSource eventSource) : base(serverUri, defaultSegment, httpClient, eventSource) { }
public void RegisterForTracking(IEventSource eventSource) { }
private bool FlushIsReallyNeeded(AutoFlushEvent @event, IEventSource source) { return(source.ActionQueue.AreTablesToBeUpdated(@event.QuerySpaces) || ((ISessionImplementor)source).FlushMode == FlushMode.Always); }
protected virtual bool InvokeSaveLifecycle(object entity, IEntityPersister persister, IEventSource source) { // Sub-insertions should occur before containing insertion so // Try to do the callback now if (persister.ImplementsLifecycle(source.EntityMode)) { log.Debug("calling OnSave()"); if (((ILifecycle)entity).OnSave(source) == LifecycleVeto.Veto) { log.Debug("insertion vetoed by OnSave()"); return(true); } } return(false); }
protected virtual bool InvokeUpdateLifecycle(object entity, IEntityPersister persister, IEventSource source) { if (persister.ImplementsLifecycle) { log.Debug("calling onUpdate()"); if (((ILifecycle)entity).OnUpdate(source) == LifecycleVeto.Veto) { log.Debug("update vetoed by onUpdate()"); return(true); } } return(false); }