Exemplo n.º 1
0
        protected internal virtual void CreateFailedJobIncident()
        {
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration = org.camunda.bpm.engine.impl.context.Context.GetProcessEngineConfiguration();
            ProcessEngineConfigurationImpl processEngineConfiguration = context.Impl.Context.ProcessEngineConfiguration;

            if (processEngineConfiguration.CreateIncidentOnFailedJobEnabled)
            {
                string incidentHandlerType = IncidentEntity.FailedJobHandlerType;

                // make sure job has an ID set:
                if (Id == null)
                {
                    Id = processEngineConfiguration.IdGenerator.NewGuid();//.NextId;
                }
                else
                {
                    // check whether there exists already an incident
                    // for this job
                    IList <IIncident> failedJobIncidents = context.Impl.Context.CommandContext.IncidentManager.FindIncidentByConfigurationAndIncidentType(Id, incidentHandlerType);

                    if (failedJobIncidents.Count > 0)
                    {
                        return;
                    }
                }

                IncidentContext incidentContext = CreateIncidentContext();
                incidentContext.ActivityId = ActivityId;

                processEngineConfiguration.getIncidentHandler(incidentHandlerType).HandleIncident(incidentContext, exceptionMessage);
            }
        }