Example #1
0
        /// <summary>
        /// Instantiate recursive a new incident a super execution
        /// (i.e. super process instance) which is affected from this
        /// incident.
        /// For example: a super process instance called via CallActivity
        /// a new process instance on which an incident happened, so that
        /// the super process instance has an incident too.
        /// </summary>
        protected internal virtual void CreateRecursiveIncidents(string rootCauseIncidentId, IList <IncidentEntity> createdIncidents)
        {
            //TODO ÐÔÄÜÎÊÌâ
            ExecutionEntity execution = Execution;

            if (execution != null)
            {
                ExecutionEntity superExecution = (ExecutionEntity)execution.ProcessInstance.SuperExecution;//.getSuperExecution();

                if (superExecution != null)
                {
                    // create a new incident
                    IncidentEntity newIncident = Create(IncidentType);
                    newIncident.Execution           = superExecution;
                    newIncident.ActivityId          = superExecution.CurrentActivityId;
                    newIncident.ProcessDefinitionId = superExecution.ProcessDefinitionId;
                    newIncident.TenantId            = superExecution.TenantId;

                    // set cause and root cause
                    newIncident.CauseIncidentId     = Id;
                    newIncident.RootCauseIncidentId = rootCauseIncidentId;

                    // insert new incident (and create a new historic incident)
                    Insert(newIncident);

                    // add new incident to result set
                    createdIncidents.Add(newIncident);

                    newIncident.CreateRecursiveIncidents(rootCauseIncidentId, createdIncidents);
                }
            }
        }
Example #2
0
        public static IncidentEntity CreateAndInsertIncident(string incidentType, IncidentContext context, string message)
        {
            // create new incident
            IncidentEntity newIncident = Create(incidentType);

            newIncident.IncidentMessage = message;

            // set properties from incident context
            newIncident.Configuration       = context.Configuration;
            newIncident.ActivityId          = context.ActivityId;
            newIncident.ProcessDefinitionId = context.ProcessDefinitionId;
            newIncident.TenantId            = context.TenantId;
            newIncident.JobDefinitionId     = context.JobDefinitionId;

            if (context.ExecutionId != null)
            {
                // fetch execution
                ExecutionEntity execution = Engine.context.Impl.Context.CommandContext.ExecutionManager.FindExecutionById(context.ExecutionId);

                // link incident with execution
                newIncident.Execution = execution;
            }

            // insert new incident (and create a new historic incident)
            Insert(newIncident);

            return(newIncident);
        }
Example #3
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            IncidentEntity other = (IncidentEntity)obj;

            if (Id == null)
            {
                if (other.Id != null)
                {
                    return(false);
                }
            }
            else if (!Id.Equals(other.Id))
            {
                return(false);
            }
            return(true);
        }
Example #4
0
        protected internal static void Insert(IncidentEntity incident)
        {
            // persist new incident
            context.Impl.Context.CommandContext.IncidentManager.Add(incident);

            incident.FireHistoricIncidentEvent(HistoryEventTypes.IncidentCreate);
        }
Example #5
0
        protected internal static IncidentEntity Create(string incidentType)
        {
            //string incidentId = context.Impl.Context.ProcessEngineConfiguration.IdGenerator.DbSqlSessionFactory.IdGenerator.NextId;
            string incidentId = context.Impl.Context.CommandContext.Scope.Resolve <IDGenerator>().NewGuid();

            // decorate new incident
            IncidentEntity newIncident = new IncidentEntity();

            newIncident.Id = incidentId;
            newIncident.IncidentTimestamp   = ClockUtil.CurrentTime;
            newIncident.IncidentType        = incidentType;
            newIncident.CauseIncidentId     = incidentId;
            newIncident.RootCauseIncidentId = incidentId;

            return(newIncident);
        }
Example #6
0
        protected internal virtual void Remove(bool resolved)
        {
            ExecutionEntity execution = Execution;

            if (execution != null)
            {
                // Extract possible super execution of the assigned execution
                ExecutionEntity superExecution = null;
                if (execution.Id == execution.ProcessInstanceId)
                {
                    superExecution = (ExecutionEntity)execution.SuperExecution;
                }
                else
                {
                    //superExecution = execution.getProcessInstance().getSuperExecution();
                    superExecution = (ExecutionEntity)execution.ProcessInstance.SuperExecution;
                }

                if (superExecution != null)
                {
                    // get the incident, where this incident is the cause
                    IncidentEntity parentIncident = superExecution.GetIncidentByCauseIncidentId(Id);

                    if (parentIncident != null)
                    {
                        // remove the incident
                        parentIncident.Remove(resolved);
                    }
                }

                // remove link to execution
                execution.RemoveIncident(this);
            }

            // always delete the incident
            context.Impl.Context.CommandContext.IncidentManager.Delete(this);//.DbEntityManager.Delete(this);

            // update historic incident
            HistoryEventTypes eventType = resolved ? HistoryEventTypes.IncidentResolve : HistoryEventTypes.IncidentDelete;

            FireHistoricIncidentEvent(eventType);
        }
Example #7
0
 public HistoryEventCreatorAnonymousInnerClassHelper(IncidentEntity outerInstance, HistoryEventTypes eventType)
 {
     this._outerInstance = outerInstance;
     this._eventType     = eventType;
 }