public TwitchPublishEvent(PublishEventType type) { Type = type; }
/// <summary> /// Notifies the publish events. /// </summary> /// <param name="model">The model.</param> /// <param name="fileName">Name of the file.</param> /// <param name="eventType">Type of the event.</param> internal static void NotifyPublishEvents(CandleModel model, string fileName, PublishEventType eventType) { ILogger logger = ServiceLocator.Instance.GetService <ILogger>(); if (logger != null) { logger.BeginStep("Custom strategy publishing actions", LogType.Info); } try { foreach (StrategyBase strategy in StrategyManager.GetStrategies(model.Component, null)) { if (!strategy.IsEnabled) { continue; } try { s_context = new GenerationContext(model, fileName, Guid.Empty); s_context.GenerationPass = GenerationPass.Publishing; strategy.InitializeContext(s_context, model.Component); switch (eventType) { case PublishEventType.EndPublish: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnPublicationEnded(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy before local custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.PublishFailed: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnPublicationError(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy before local custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.BeforeLocal: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnBeforeLocalPublication(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy before local custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.AfterLocal: if (strategy is IStrategyPublisher) { string folder = Path.GetDirectoryName(model.MetaData.GetFileName(PathKind.Absolute)); ((IStrategyPublisher)strategy).Publish(model, folder); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy custom publishing action for " + strategy.DisplayName, LogType.Info); } } if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnAfterLocalPublication(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy after local custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.BeforeServer: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnBeforeServerPublication(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy before server custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.AfterServer: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnAfterServerPublication(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy after server custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; } } catch (PublishingException pe) { if (logger != null) { logger.WriteError("Custom strategy publishing actions", "Publishing stopped for strategy custom publishing action for " + strategy.DisplayName, pe); } throw; } catch (Exception ex) { if (logger != null) { logger.WriteError("Custom strategy publishing actions", "Error for strategy custom publishing action for " + strategy.DisplayName, ex); } } finally { strategy.InitializeContext(null, null); } } } finally { if (logger != null) { logger.EndStep(); } } }