Exemplo n.º 1
0
        private void ParseSqlRedisFallback(Task <DbDataReader> task, object state)
        {
            if (task.IsCompletedSuccessfully)
            {
                DbDataReader reader = task.Result;
                if (reader?.Read() ?? false)
                {
                    ServerDetails server = new ServerDetails(reader);

                    this.Servers.GetOrAdd(server.Id, server).SetStatus((string)state);
                }
            }
            else if (task.IsFaulted)
            {
                ServerManager.Logger.Error("Failed to load server from sql", task.Exception);
            }
        }
Exemplo n.º 2
0
        private IReadOnlyCollection <ServerDetails> ParseSqlServers(Task <DbDataReader> task)
        {
            List <ServerDetails> servers = new List <ServerDetails>();

            if (task.IsCompletedSuccessfully)
            {
                DbDataReader reader = task.Result;
                while (reader?.Read() ?? false)
                {
                    ServerDetails server = new ServerDetails(reader);

                    servers.Add(this.Servers.GetOrAdd(server.Id, new ServerDetails(reader)));
                }
            }
            else if (task.IsFaulted)
            {
                ServerManager.Logger.Error("Failed to load servers from sql", task.Exception);
            }

            return(servers);
        }
 public bool TryGetServer(uint id, out ServerDetails server) => this.Servers.TryGetValue(id, out server);