Exemplo n.º 1
0
 public KeepItUpService(KeepItUpContext keepItUpContext, ETClient etClient, IConfigurationRoot configuration, ILogger <KeepItUpService> logger)
 {
     _keepItUpContext = keepItUpContext;
     _etClient        = etClient;
     _configuration   = configuration;
     _logger          = logger;
 }
Exemplo n.º 2
0
        private static int Start(StartOptions opts)
        {
            var ctx   = new KeepItUpContext();
            var match = ctx.Servers.FirstOrDefault(s => s.Name == opts.Name);

            if (match != null)
            {
                match.Enabled = true;
            }
            ctx.SaveChanges();
            return(0);
        }
Exemplo n.º 3
0
        private static int RemoveServer(RemoveOptions opts)
        {
            var ctx   = new KeepItUpContext();
            var match = ctx.Servers.FirstOrDefault(s => s.Name == opts.Name);

            if (match != null)
            {
                ctx.Remove(match);
            }
            ctx.SaveChanges();
            return(0);
        }
Exemplo n.º 4
0
        private static int Add(AddOptions opts)
        {
            var ctx = new KeepItUpContext();

            ctx.Add(new Server
            {
                Name     = opts.Name,
                HomePath = opts.HomePath,
                BasePath = opts.BasePath,
                Port     = opts.Port
            });
            ctx.SaveChanges();
            return(0);
        }
Exemplo n.º 5
0
        private static int ListServers(ListOptions opts)
        {
            var ctx = new KeepItUpContext();

            var servers = string.IsNullOrEmpty(opts.Name)
                ? ctx.Servers.ToList()
                : ctx.Servers.Where(s => s.Name.Contains(opts.Name)).ToList();

            foreach (var server in ctx.Servers)
            {
                Console.WriteLine(server.Name);
                Console.WriteLine($"\tname: {server.Name}");
                Console.WriteLine($"\tport: {server.Port}");
                Console.WriteLine($"\tbasepath: {server.BasePath}");
                Console.WriteLine($"\thomepath: {server.HomePath}");
            }

            return(0);
        }