Exemplo n.º 1
0
        public SS14Server(ICommandLineArgs args)
        {
            var    assemblies  = new List <Assembly>();
            string assemblyDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            assemblies.Add(Assembly.LoadFrom(Path.Combine(assemblyDir, "SS14.Server.Services.dll")));

            IoCManager.AddAssemblies(assemblies);


            IoCManager.Resolve <ISS14Server>().SetServerInstance(this);

            //Init serializer
            var serializer = IoCManager.Resolve <ISS14Serializer>();

            Runlevel   = RunLevel.Init;
            _singleton = this;

            var configMgr = IoCManager.Resolve <IServerConfigurationManager>();

            configMgr.Initialize(PathHelpers.ExecutableRelativeFile("server_config.xml"));
            string logPath = configMgr.LogPath;

            if (!Path.IsPathRooted(logPath))
            {
                logPath = PathHelpers.ExecutableRelativeFile(logPath);
            }

            LogManager.Initialize(logPath, configMgr.LogLevel);

            TickRate   = IoCManager.Resolve <IServerConfigurationManager>().TickRate;
            ServerRate = 1000.0f / TickRate;
        }
Exemplo n.º 2
0
 public static IFileAggregateReportProcessor Create(ICommandLineArgs commandLineArgs)
 {
     return(new ServiceCollection()
            .AddSingleton(commandLineArgs)
            .AddTransient <IFileAggregateReportProcessor, FileAggregateReportProcessor>()
            .AddTransient <IAggregateReportParser, AggregateReportParser>()
            .AddTransient <IMimeMessageFactory, MimeMessageFactory>()
            .AddTransient <IAttachmentStreamNormaliser, AttachmentStreamNormaliser>()
            .AddTransient <IAggregateReportDeserialiser, AggregateReportDeserialiser>()
            .AddTransient <IContentTypeProvider, ContentTypeProvider>()
            .AddTransient <IGZipDecompressor, GZipDecompressor>()
            .AddTransient <IZipDecompressor, ZipDecompressor>()
            .AddTransient <IReportMetadataDeserialiser, ReportMetadataDeserialiser>()
            .AddTransient <IPolicyPublishedDeserialiser, PolicyPublishedDeserialiser>()
            .AddTransient <IRecordDeserialiser, RecordDeserialiser>()
            .AddTransient <IDomainValidator, DomainValidator>()
            .AddTransient <IRowDeserialiser, RowDeserialiser>()
            .AddTransient <IIdentifiersDeserialiser, IdentifiersDeserialiser>()
            .AddTransient <IAuthResultDeserialiser, AuthResultDeserialiser>()
            .AddTransient <IPolicyEvaluatedDeserialiser, PolicyEvaluatedDeserialiser>()
            .AddTransient <IPolicyOverrideReasonDeserialiser, PolicyOverrideReasonDeserialiser>()
            .AddTransient <IDkimAuthResultDeserialiser, DkimAuthResultDeserialiser>()
            .AddTransient <ISpfAuthResultDeserialiser, SpfAuthResultDeserialiser>()
            .AddTransient <IAggregateReportPersistorComposite, AggregateReportPersistorComposite>()
            .AddTransientConditional <IAggregateReportPersistor, DenormalisedRecordPersistorAdaptor>(commandLineArgs.CsvFile != null || commandLineArgs.SqlFile != null)
            .AddTransientConditional <IDenormalisedRecordPersistorComposite, DenormalisedRecordPersistorComposite>(commandLineArgs.CsvFile != null || commandLineArgs.SqlFile != null)
            .AddTransientConditional <ICsvDenormalisedRecordSerialiser, CsvDenormalisedRecordSerialiser>(commandLineArgs.CsvFile != null)
            .AddTransientConditional <IAggregateReportPersistor, XmlAttachmentPersistor>(commandLineArgs.XmlDirectory != null)
            .AddTransientConditional <IDenormalisedRecordPersistor, CsvPersistor>(commandLineArgs.CsvFile != null)
            .AddTransientConditional <IDenormalisedRecordPersistor, SqlLitePersistor>(commandLineArgs.SqlFile != null)
            .AddSerilogLogging()
            .BuildServiceProvider()
            .GetRequiredService <IFileAggregateReportProcessor>());
 }
 public CsvPersistor(
     ICommandLineArgs args,
     ICsvDenormalisedRecordSerialiser csvDenormalisedRecordSerialiser)
 {
     _args = args;
     _csvDenormalisedRecordSerialiser = csvDenormalisedRecordSerialiser;
 }
Exemplo n.º 4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            commandLineArgs = new CommandLineArgs(e.Args);

            ViewManager.SetImplementation(new DefaultViewManager(t => kernel.Get(t)));

            var splashVM = new SplashScreenVM();

            ViewManager.ShowWindow(splashVM);

            // in order to ensure the UI stays responsive, we need to
            // do the work on a different thread
            Task.Factory.StartNew(() =>
            {
                ConfigureContainer(splashVM);
                Dispatcher.Invoke(() =>
                {
                    ViewManager.ShowWindow <MainVM>();
                    splashVM.Close();
                });
            });

            Dispatcher.UnhandledException += (s, ea) =>
            {
                string message = $"An unhandled exception occurred:\n\n{ea.Exception.Message}\nStack trace:\n\n{ea.Exception.StackTrace}";
                Trace.TraceError(message);
                ViewManager.ShowMessageBox("Error", message, MessageBoxButton.OK);
                ea.Handled = true;
            };
        }
Exemplo n.º 5
0
 /// <summary>
 /// Try to parse command line arguments
 /// </summary>
 /// <param name="args">The arguments to parse.</param>
 /// <param name="result">The parsed result if successful.  Null if parse failed.</param>
 /// <returns><c>true</c> if arguments were successfully parsed, <c>false</c> otherwise.</returns>
 public virtual bool TryParse(string[] args, out ICommandLineArgs result)
 {
     if (args == null || args.Length == 0)
     {
         result = null;
         return(false);
     }
     result = Parse(args);
     return(result != null);
 }
Exemplo n.º 6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            commandLineArgs = new CommandLineArgs(e.Args);

            ViewManager.SetImplementation(new DefaultViewManager(t => kernel.Get(t)));
            Log.SetImplementation((DefaultLogger)LogManager.GetLogger("", typeof(DefaultLogger)));
            if (commandLineArgs.Contains("-debug", StringComparer.OrdinalIgnoreCase))
            {
                Log.Level = "Debug";
            }

            Log.Info($"Starting Astrarium {FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion}");

            var splashVM = new SplashScreenVM();

            ViewManager.ShowWindow(splashVM);

            // in order to ensure the UI stays responsive, we need to
            // do the work on a different thread
            Task.Factory.StartNew(() =>
            {
                ConfigureContainer(splashVM);
                Dispatcher.Invoke(() =>
                {
                    ViewManager.ShowWindow <MainVM>();
                    splashVM.Close();
                });
            });

            Dispatcher.UnhandledException += (s, ea) =>
            {
                string message = $"An unhandled exception occurred:\n\n{ea.Exception.Message}\nStack trace:\n\n{ea.Exception.StackTrace}";
                Log.Error(message);
                ViewManager.ShowMessageBox("Error", message, MessageBoxButton.OK);
                ea.Handled = true;
            };
        }
Exemplo n.º 7
0
 private static void HandleArgs(string[] args)
 {
     //TODO parse args
     Logger.LogInfo("Parsing CommandLine Args");
     commandLineArgs = new CommandLineArgs();
     try {
         if (!args.Any())
         {
         }
         else if (args.Any(x => x.StartsWith("-h")))
         {
             Logger.LogInfo(HelpText);
         }
         if (args.Any(x => x.StartsWith("-f")))
         {
             var files = args.FirstOrDefault(x => x.Contains("-f"))?.Split('=', ',');
             files = files.Where(x => x != "-f" && x != "=").ToArray();
             commandLineArgs.FilesToProcess = files;
         }
         if (args.Any(x => x.StartsWith("-w")))
         {
             var wDir = args.FirstOrDefault(x => x.Contains("-w"))?.Split('=');
             var dir  = wDir.FirstOrDefault(x => x != "-w" && x != "=");
             commandLineArgs.WorkingDir = dir;
         }
         if (args.Any(x => x.StartsWith("-o")))
         {
             var oDir = args.FirstOrDefault(x => x.Contains("-o"))?.Split('=');
             var dir  = oDir.FirstOrDefault(x => x != "-o" && x != "=");
             commandLineArgs.OutputLocation = dir;
         }
     }
     catch (Exception ex)
     {
         Logger.LogError("Got an invalid Command Line argument", ex);
     }
 }
Exemplo n.º 8
0
 public CommandLineConfigurationProvider(ICommandLineArgs args)
 {
     this.m_Args = args;
 }
Exemplo n.º 9
0
 public CommandLineConfigurationSource(ICommandLineArgs args)
 {
     _args = args;
 }
Exemplo n.º 10
0
 public SqlLitePersistor(ICommandLineArgs commandLineArgs)
 {
     _commandLineArgs = commandLineArgs;
 }
Exemplo n.º 11
0
 public CommandLine(ICommandLineArgs commandLineArgs, IConsole console)
 {
     _commandLineArgs = commandLineArgs;
     _console         = console;
 }
Exemplo n.º 12
0
 public Worker(ICommandLineArgs commandLineArgs)
 {
     this.commandLineArgs = commandLineArgs;
     csvRows = new List <PlotPOLCNTOutput>();
 }
Exemplo n.º 13
0
 public SkyMap(ISettings settings, ICommandLineArgs commandLineArgs)
 {
     this.settings        = settings;
     this.commandLineArgs = commandLineArgs;
 }
Exemplo n.º 14
0
 public XmlAttachmentPersistor(ICommandLineArgs commandLineArgs)
 {
     _commandLineArgs = commandLineArgs;
 }