示例#1
0
        private static void Main(string[] args)
        {
            NLogUtils.CreateConfigFileIfNotExists();

            SimpleLayout simpleLayout;

            LogLayout = LogManager.Configuration.Variables.TryGetValue("TextBoxLayout", out simpleLayout)
                ? simpleLayout.Text
                : "${date:format=HH\\:MM\\:ss.ffff} [${level:upperCase=true}]\t[${logger:shortName=true}] ${message}";

            MinLogLevel = LogManager.Configuration.Variables.TryGetValue("MinLogLevel", out simpleLayout)
                ? LogLevel.FromString(simpleLayout.Text)
                : LogLevel.Info;

            if (
                args.Any(
                    x =>
                    string.Equals(x, "/v", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(x, "/verbose", StringComparison.OrdinalIgnoreCase)))
            {
                MinLogLevel = LogLevel.Debug;
                EnabledDebugForAllRules();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ServerApplicationContext());
        }
示例#2
0
        public Result OnStartup(UIControlledApplication app)
        {
            // (Konrad) Initiate Nlog logger.
            NLogUtils.CreateConfiguration();
            _logger = LogManager.GetCurrentClassLogger();

            // (Konrad) Setup Document events.
            app.ControlledApplication.DocumentOpened  += OnDocumentOpened;
            app.ControlledApplication.DocumentCreated += OnDocumentCreated;
            app.ControlledApplication.DocumentSaving  += OnDocumentSaving;
            app.ControlledApplication.DocumentSynchronizingWithCentral += OnDocumentSynchronizingWithCentral;
            app.ControlledApplication.DocumentSynchronizedWithCentral  += OnDocumentSynchronizedWithCentral;
            app.ControlledApplication.FailuresProcessing += FailureProcessor.CheckFailure;
            app.ViewActivated += OnViewActivated;

            app.CreateRibbonTab("Honeybee");
            var panel = app.CreateRibbonPanel("Honeybee", "Honeybee");

            SettingsCommand.CreateButton(panel);
            var hbButton    = CreateHbModelCommand.CreateButton();
            var dfButton    = CreateDfModelCommand.CreateButton();
            var splitButton = new SplitButtonData("CreateModelCommand", "Split");
            var sb          = (SplitButton)panel.AddItem(splitButton);

            sb.AddPushButton(hbButton);
            sb.AddPushButton(dfButton);

            CreateModelHandler = new CreateModelRequestHandler();
            CreateModelEvent   = ExternalEvent.Create(CreateModelHandler);

            // (Konrad) Register an updater that will watch annotations for changes.
            AnnotationUpdater = new AnnotationUpdater(app.ActiveAddInId);

            return(Result.Succeeded);
        }
示例#3
0
        public static Logger GetLogger()
        {
            // var logger = CRM.ServerBusinessModule.CronNode.WorksSheetsGeneration.Logging.LogManager.Instance.GetCurrentClassLogger();
            var logger = NLogUtils.GetLoggerFromModuleConfig("Authentication");

            return(logger);
        }
示例#4
0
        public void StartLauncherApplication()
        {
            NLogUtils.SetLoggingForAppDomain();
            var app = new LauncherApp();

            app.Run();
        }
        private static void RunHostApplication()
        {
            NLogUtils.SetLoggingForAppDomain();
            Logger.Info("Starting Splash Screen on new AppDomain");
            var app = new HostApplication();

            app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
            app.Run();
            app.Shutdown(0);
        }
        public static void Main(string[] args)
        {
            if (!Get48FromRegistry())
            {
                Environment.Exit(0);
            }

            // Gotta catch 'em all.
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledExceptionReceived;

            var lastResult = ExternalUpdaterResult.NoUpdate;

            if (args.Length >= 1)
            {
                var argument = args[0];
                if (int.TryParse(argument, out var value) && Enum.IsDefined(typeof(ExternalUpdaterResult), value))
                {
                    lastResult = (ExternalUpdaterResult)value;
                }
            }

            InitializeApplicationBasePath();
            if (lastResult == ExternalUpdaterResult.NoUpdate)
            {
                NLogUtils.DeleteOldLogFile();
            }
            NLogUtils.SetLoggingForAppDomain();

            Logger.Debug($"Started FoC Launcher with arguments: {lastResult}");

            var update = LauncherInitializer.Initialize(lastResult);

#if !DEBUG
            if (update)
            {
                ShowSplashScreen();
            }
#endif


            StartLauncher();
            LogManager.Shutdown();
        }
示例#7
0
        private static void InitializeLogger()
        {
            NLogUtils.CreateConfigFileIfNotExists();

            SimpleLayout simpleLayout;
            var          layout = LogManager.Configuration.Variables.TryGetValue("TextBoxLayout", out simpleLayout)
                ? simpleLayout.Text
                : "${date:format=HH\\:MM\\:ss.ffff} [${level:upperCase=true}]\t[${logger:shortName=true}] ${message}";

            var minLogLevel = LogManager.Configuration.Variables.TryGetValue("MinLogLevel", out simpleLayout)
                ? LogLevel.FromString(simpleLayout.Text)
                : LogLevel.Info;

            var reconfigLoggers = false;

            var fileTarget = LogManager.Configuration.FindTargetByName <FileTarget>("file");

            if (fileTarget != null && LogManager.Configuration.Variables.TryGetValue("VerboseLayout", out simpleLayout))
            {
                simpleLayout.Text = simpleLayout.Text.Replace("${callsite", "${callsite:skipFrames=3");
                fileTarget.Layout = simpleLayout;
                reconfigLoggers   = true;
            }

            var target = new ColoredConsoleTarget {
                Layout = layout, Name = "console"
            };

            LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", minLogLevel, target));

            LogManager.Configuration.Reload(); //important, refreshes the config

            if (reconfigLoggers)
            {
                LogManager.ReconfigExistingLoggers();
            }
        }
示例#8
0
 public NLogMonitor()
 {
     NLogUtils.Init(false);
 }
示例#9
0
 public NLogLogger()
 {
     NLogUtils.Init(true);
     _logger = LogManager.GetCurrentClassLogger();
 }
示例#10
0
 public NLogMonitor()
 {
     NLogUtils.Init(true);
 }