private bool ExecuteRenderer(string inputFilename, bool askBugReport = true) { var engineCfg = GetRenderSettings(inputFilename); bool success = false; try { var engine = new RenderEngine(); engine.ConfigureFromSettings(engineCfg); var result = engine.Execute(); switch (result) { case EngineResult.Exception: Log("\r\nUnknown exception.\r\n"); if (askBugReport) { AskBugReport(null); } break; case EngineResult.RenderedOk: Log("\r\nSpecified action(s) completed.\r\n------------------------------\r\n"); // +" Please send an email to [email protected] with your map as an attachment."); success = true; break; case EngineResult.LoadTheaterFailed: Log("\r\nTheater loading failed. Please make sure the mix directory is correct and that the required expansion packs are installed " + "if they are required for the map you want to render.\r\n"); if (askBugReport) { AskBugReport(null); } break; case EngineResult.LoadRulesFailed: Log("\r\nRules loading failed. Please make sure the mix directory is correct and that the required expansion packs are installed " + "if they are required for the map you want to render.\r\n"); if (askBugReport) { AskBugReport(null); } break; } } catch (Exception exc) { if (askBugReport) { AskBugReport(exc); } } return(success); }
public static int Main(string[] args) { var engine = new RenderEngine(); if (engine.ConfigureFromArgs(args)) { var result = engine.Execute(); LogManager.Configuration = null; // required for mono release to flush possible targets return((int)result); } return(0); }
private static void Main(string[] args) { // Default execution options Options options = new Options() { Mode = EngineMode.Debugger, ItemURI = null, TemplateURI = null, PublicationTargetURI = null }; InitializeConsole(); if (Parser.Default.ParseArguments(args, options)) { LegacyInterface legacyInterface = null; try { using (new PreviewServer()) { // Initialize TcmDebugger.COM legacyInterface = new LegacyInterface(); legacyInterface.SetProvider(new LegacyProvider()); switch (options.Mode) { case EngineMode.LocalServer: using (new CompoundTemplateService2011()) { Logger.Log(System.Diagnostics.TraceEventType.Information, "Press any key to exit."); Console.ReadKey(); } break; case EngineMode.Debugger: case EngineMode.Publisher: if (String.IsNullOrEmpty(options.ItemURI)) { throw new Exception("ItemUri is required for Debugger or Publisher engines"); } if (!TcmUri.IsValid(options.ItemURI)) { throw new Exception(String.Format("Invalid tcm uri {0}", options.ItemURI)); } TcmUri tcmItemUri = new TcmUri(options.ItemURI); if (tcmItemUri.ItemType != ItemType.Page || options.Mode != EngineMode.Publisher) { if (String.IsNullOrEmpty(options.TemplateURI)) { throw new Exception("Template tcm uri is required for non-page type objects or debug engine"); } if (!TcmUri.IsValid(options.TemplateURI)) { throw new Exception(String.Format("Invalid template tcm uri {0}", options.TemplateURI)); } } if (!String.IsNullOrEmpty(options.PublicationTargetURI) && !TcmUri.IsValid(options.PublicationTargetURI)) { throw new Exception(String.Format("Invalid publication target tcm uri {0}", options.TemplateURI)); } Engine engine = null; switch (options.Mode) { case EngineMode.Debugger: engine = new Engines.DebugEngine(); break; case EngineMode.Publisher: engine = new RenderEngine(); break; } String output = engine.Execute(options.ItemURI, options.TemplateURI, options.PublicationTargetURI); output += ""; Console.WriteLine(); Console.WriteLine("{0} [!] {1}", DateTime.Now.ToString("HH:mm:ss"), "Execution finished. Press any key to exit."); Console.ReadKey(); break; } } } catch (Exception ex) { Logger.Log(System.Diagnostics.TraceEventType.Error, ex.Message); } finally { if (legacyInterface != null) { Marshal.ReleaseComObject(legacyInterface); } } } }