Esempio n. 1
0
 /// <summary>
 /// Asks if an item can integrate.
 /// </summary>
 /// <param name="context">The context to use.</param>
 public override void AskToIntegrate(IntegrationContext context)
 {
     if (this.Host != null)
     {
         logger.Debug("Asking host if {0} can integrate", this.Name);
         this.Host.AskToIntegrate(context);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Checks if an integration can proceed.
        /// </summary>
        private void CheckForIntegration()
        {
            // Get the first trigger that has been tripped
            var request = this.Triggers
                          .Select(t => t.Check())
                          .FirstOrDefault(r => r != null);

            if (request != null)
            {
                logger.Info(
                    "Received integration request from '{0}' for '{1}'",
                    request.SourceTrigger,
                    this.Name);

                // Check if we can integrate
                var context = new IntegrationContext(this);
                this.AskToIntegrate(context);
                // TODO: make the time out configurable
                if (context.Wait(TimeSpan.FromDays(7)))
                {
                    // Make sure there is always a state object
                    if (this.PersistedState == null)
                    {
                        this.PersistedState = new PersistedProjectState();
                    }

                    // Perform the actual integration
                    logger.Info("Starting integration for '{0}'", this.Name);
                    var startTime = this.Clock.Now;
                    var status    = IntegrationStatus.Unknown;
                    try
                    {
                        status = this.Integrate(request);
                    }
                    catch (Exception error)
                    {
                        logger.ErrorException("An unexpected error crashed the integration", error);
                        status = IntegrationStatus.Error;
                    }
                    finally
                    {
                        this.PersistedState.LastIntegration = new IntegrationSummary
                        {
                            StartTime  = startTime,
                            FinishTime = this.Clock.Now,
                            Status     = status
                        };
                        this.SavePersistedState();
                    }
                    logger.Info("Completed integration for '{0}'", this.Name);
                }
                else
                {
                    logger.Info("Cancelling integration for '{0}'", this.Name);
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Asks if an item can integrate.
 /// </summary>
 /// <param name="context">The context to use.</param>
 public abstract void AskToIntegrate(IntegrationContext context);
Esempio n. 4
0
 /// <summary>
 /// Asks if an item can integrate.
 /// </summary>
 /// <param name="context">The context to use.</param>
 public abstract void AskToIntegrate(IntegrationContext context);