private static SolidColorBrush ConvertToColor(string text) { SolidColorBrush fallback = new SolidColorBrush(Colors.Black); if (string.IsNullOrEmpty(text)) return fallback; if (!text.StartsWith("#")) text = "#" + text; SolidColorBrush brush = null; var converter = new BrushConverter(); if (converter.CanConvertFrom(typeof (string))) { try { brush = (SolidColorBrush)converter.ConvertFrom(text); } catch (Exception e) { ILogger Logger = ParagonLogManager.GetLogger(); Logger.Error("error ConvertFrom when converting color:" + text + ", exception: " + e.ToString()); // fallback in case of exception brush = fallback; } } if (brush == null) brush = fallback; return brush; }
public WebApplication( IApplicationMetadata metadata, int startupTimeout, IApplicationPackage package, Dictionary <string, object> args, // ReSharper disable once ParameterTypeCanBeEnumerable.Local IParagonPlugin[] kernelPlugins, Func <ICefWebBrowser> newBrowser, Func <IApplicationWindowEx> newAppWindow, Func <IApplicationWindowManagerEx> newWindowManager) { Logger = ParagonLogManager.GetLogger(); Metadata = metadata; Package = package; Args = args; Plugins = new List <IParagonPlugin>(kernelPlugins); _createNewWindow = newAppWindow; _createNewBrowser = newBrowser; _createWindowManager = newWindowManager; _eventPageLaunchTimeout = TimeSpan.FromSeconds(startupTimeout); _renderPlugins = new RenderSidePluginData() { PackagePath = Package != null ? Package.PackageFilePath : string.Empty, Plugins = new List <ApplicationPlugin>() }; SystemEvents.SessionEnding += OnSessionEnding; ParagonRuntime.RenderProcessInitialize += OnRenderProcessInitialize; }
public static int Main(string[] args) { InitLogging(args); var logger = ParagonLogManager.GetLogger(); var procId = Process.GetCurrentProcess().Id; logger.Info("Render process {0} starting", procId); try { if (!ExitWhenParentProcessExits()) { logger.Warn("Unable to monitor parent process for exit"); } CefRuntime.Load(); CefRuntime.ExecuteProcess(new CefMainArgs(args), new CefRenderApplication(), IntPtr.Zero); } catch (Exception ex) { logger.Error("Fatal error in render process {0} : {1}, StackTrace = {2}", procId, ex.Message, ex.StackTrace); return(1); } logger.Info("Render process {0} stopping.", procId); return(0); }
private static void InitLogging(IEnumerable <string> args) { var logFileArg = args.FirstOrDefault(a => a.StartsWith("--log-file=")); if (string.IsNullOrEmpty(logFileArg)) { return; } var startIdx = logFileArg.IndexOf("=", StringComparison.OrdinalIgnoreCase); if (startIdx == -1) { return; } startIdx++; var cefLogPath = logFileArg.Substring(startIdx, logFileArg.Length - startIdx); var logDir = Path.GetDirectoryName(cefLogPath); if (string.IsNullOrEmpty(logDir)) { return; } ParagonLogManager.ConfigureLogging(logDir, LogContext.Renderer, 5); }
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var logger = ParagonLogManager.GetLogger(); logger.Error(string.Format("An unhandled domain exception has occurred: {0}", e.ExceptionObject ?? string.Empty)); var errMessage = "A fatal error has occurred."; if (_appManager != null && _appManager.AllApplicaions != null) { var apps = _appManager.AllApplicaions.Select(app => app.Name).ToArray(); if (apps.Length > 0) { errMessage += "\n\nThe following applications will be closed: \n " + string.Join(", ", apps); } } errMessage += "\n\nPlease contact Technology Client Services if you require assistance.\n"; MessageBox.Show(errMessage, "Unhandled Exception", MessageBoxButton.OK); }
public string[] GetArchiveApplicationLogFilePaths() { return(ParagonLogManager.GetAppLogFiles()); }
protected virtual void RunApplicationInternal(ParagonCommandLineParser cmdLine, IApplicationPackage package, ApplicationMetadata metadata) { IParagonSplashScreen splash = null; IApplication application = null; Window splashWindow = null; var manifest = package.Manifest; #if ENFORCE_PACKAGE_SECURITY var isSigned = package.Signature != null; #endif try { ParagonLogManager.AddApplicationTraceListener(manifest.Id); // Load custom WPF theme for the application var stylePart = !string.IsNullOrEmpty(manifest.CustomTheme) ? package.GetPart(manifest.CustomTheme) : null; var styleStream = stylePart != null?stylePart.GetStream() : null; if (styleStream != null) { var theme = XamlReader.Load(styleStream) as ResourceDictionary; if (theme != null) { #if ENFORCE_PACKAGE_SECURITY if (isSigned) #endif Application.Current.Resources.MergedDictionaries.Add(theme); } } // Create and show the splash screen if needed if (cmdLine != null && !cmdLine.HasFlag("no-splash") && _createSplashScreen != null) { #if ENFORCE_PACKAGE_SECURITY splash = _createSplashScreen(isSigned ? manifest.Name : manifest.Name + " (Unsigned)", manifest.Version, package.GetIcon()); #else splash = _createSplashScreen(manifest.Name, manifest.Version, package.GetIcon()); #endif splashWindow = (Window)splash; metadata.UpdateLaunchStatus = s => { if (splash != null && splashWindow != null && splashWindow.IsVisible) { splash.ShowText(s); } }; #if ENFORCE_PACKAGE_SECURITY if (!isSigned) { splashWindow.Style = Application.Current.Resources["AlarmSplashScreenStyle"] as Style; } #endif splashWindow.Show(); } // Extract the application arguments from the command line Dictionary <string, object> args = null; if (cmdLine != null && _appArgumentParser != null) { string appArgs, appUrl; if (cmdLine.GetValue("args", out appArgs)) { args = _appArgumentParser(appArgs); } else if (cmdLine.GetValue("url", out appUrl)) { Uri uri; if (Uri.TryCreate(appUrl, UriKind.Absolute, out uri)) { if (!string.IsNullOrEmpty(uri.Query)) { args = _appArgumentParser(uri.Query.Substring(1)); } } } } //Create and register application application = _createApplication(package, metadata, args); Register(application); // Launch the application var stopWatch = AutoStopwatch.TimeIt("Launching"); application.Launched += delegate { if (splashWindow != null) { splashWindow.Dispatcher.BeginInvoke(new Action(() => { if (splashWindow != null) { splashWindow.Close(); } })); } this.RemoveSingleInstanceLaunchMarker(metadata.Id); stopWatch.Dispose(); }; application.Launch(); string protocolUri = null; if (cmdLine != null) { cmdLine.GetValue("url", out protocolUri); if (!string.IsNullOrEmpty(protocolUri)) { application.OnProtocolInvoke(protocolUri); } } } catch (Exception ex) { Logger.Info("Error starting paragon application : {0}", ex); MessageBox.Show("Unable to start:\n\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); if (splashWindow != null) { splashWindow.Close(); } if (application != null) { RemoveSingleInstanceLaunchMarker(metadata.Id); application.Close(); application = null; } } }
public void ShutdownLogger() { ParagonLogManager.Shutdown(); }
public void InitializeLogger(string paragonFolder, IApplicationPackage appPackage) { var cachePath = Path.Combine(paragonFolder, string.IsNullOrEmpty(appPackage.Manifest.ProcessGroup) ? appPackage.Manifest.Id : appPackage.Manifest.ProcessGroup); ParagonLogManager.ConfigureLogging(cachePath, LogContext.Browser, Settings.Default.MaxRolledLogFiles); }
protected override void OnInitialize() { base.OnInitialize(); _logger = ParagonLogManager.GetAppLogger(Application.Metadata.Id); }