Ejemplo n.º 1
0
        private static void ExecuteServersRequest(ServerListArguments serverArguments, IService plugin)
        {
            string token   = ResolveToken(serverArguments, plugin);
            var    servers = plugin.GetServers(serverArguments.DataLocation, token);

            if (string.IsNullOrEmpty(servers.Result.Message))
            {
                logger.Info("===== Servers list =====");
                servers.Result.ForEach(it => logger.Info(it.Name));
                logger.Info(string.Format("Total servers count: {0}", servers.Result.Count));
            }
            else
            {
                throw new Exception(servers.Result.Message);
            }
        }
Ejemplo n.º 2
0
        private static string ResolveToken(ServerListArguments serverArguments, IService plugin)
        {
            string token = "";

            if (serverArguments.DataLocation == ServerDataLocation.Database)
            {
                var tokenResult = plugin.GetToken(null).Result;
                if (string.IsNullOrEmpty(tokenResult.Message))
                {
                    token = tokenResult.Token;
                }
                else
                {
                    throw new Exception(tokenResult.Message);
                }
            }
            return(token);
        }
Ejemplo n.º 3
0
        private static void ExecuteCmdRequest(object obj)
        {
            var container = _builder.Build();

            if (obj is Credentials)
            {
                using (var scope = container.BeginLifetimeScope())
                {
                    var plugin = scope.Resolve <IService>();
                    plugin.SaveCredentials(obj as Credentials);
                }
            }
            else if (obj is ServerListArguments)
            {
                ServerListArguments serverArguments = obj as ServerListArguments;
                using (var scope = container.BeginLifetimeScope())
                {
                    var plugin = scope.Resolve <IService>();
                    ExecuteServersRequest(serverArguments, plugin);
                }
            }
        }