Пример #1
0
        private static void Execute(Options opts)
        {
            try
            {
                var config = new LoggerConfiguration();
                config.WriteTo.ColoredConsole(outputTemplate: "{Message:lj}{NewLine}{Exception}");

                if (opts.Verbose)
                {
                    config.MinimumLevel.Debug();
                }
                else
                {
                    config.MinimumLevel.Information();
                }

                Log.Logger = config.CreateLogger();
                var connection = LoginWindow.Connect(opts.Appliance);
                Log.Information(connection.InvokeMethod(Service.Core, Method.Get, "Me"));
                Log.Information("Press any key to quit...");
                Console.ReadKey();
                connection.LogOut();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Fatal exception occurred");
                Log.Information("Press any key to quit...");
                Console.ReadKey();
                Environment.Exit(1);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: SafeguardSignalrClient [URL] [EVENT]");
                Environment.Exit(1);
            }

            //extract URL, event name from command line arguments
            string url     = args[0];
            string sgEvent = args[1];

            //connect to Safeguard and open login prompt window to prompt for creds
            var connection = LoginWindow.Connect(url);

            //create listener and connect to signalr. Assign handler function defined below
            //to execute when an event is received
            var listener = connection.GetEventListener();

            listener.RegisterEventHandler(sgEvent, Handler);

            //start listener and wait for any input, then stop.
            listener.Start();
            Console.WriteLine($"Listening for {sgEvent} events...\npress any key to exit");
            Console.ReadKey();
            listener.Stop();
        }
Пример #3
0
 public Task Authenticate(string appliance)
 {
     if (_safeguardConnection != null)
     {
         _safeguardConnection.LogOut();
         _safeguardConnection.Dispose();
     }
     _safeguardConnection = LoginWindow.Connect(appliance);
     return(Task.CompletedTask);
 }