<commit_before>﻿using System;
using ServiceStack.Redis;
using System.Collections.Generic;

namespace OperationsDashboard.Common
{
    class ServerMappingEntry
    {
        public long id;
        public string Servername;
        public string FriendlyName;
        public string LogicalEnvironment;
        public string Environment;
        public string Function;
        public string IPAddress;
        public string dnsHost;

        public ServerMappingEntry(string Servername, string friendlyname, string logicalEnvironment, string environment,string function, string iPAddress, string dnsHost)
        {
            this.Servername = Servername;
            this.FriendlyName = friendlyname;
            this.LogicalEnvironment = logicalEnvironment;
            this.Environment = environment;
            this.Function = function;
            this.IPAddress = iPAddress;
        }

        public void AddToRedis()
        {
            using(var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();
                this.id = ListServerMappingEntry.GetNextSequence();

                string key = string.Format("servermapping:{0}:{1}:{2}", this.LogicalEnvironment, this.Servername, this.IPAddress);
                ListServerMappingEntry.SetValue(key, this);
            }
        }
        public static ServerMappingEntry GetEntry(string logicalEnvironment = "*",string servername = "*",string function="*",string IPAddress = "*")        
        {
            using (var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();
                string key = string.Format("servermapping:{0}:{1}:{2}", logicalEnvironment, servername, IPAddress);
                return ListServerMappingEntry.GetValue(key);
            }
        }
        public static ServerMappingEntry GetEntryById(long id)
        {
            using (var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();                
                return ListServerMappingEntry.GetById(id);
            }
        }

        public static IList<ServerMappingEntry> GetAll()
        {
            using (var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();
                return ListServerMappingEntry.GetAll();
            }
        }
    }
}<commit_msg>added case for list of Entries, instead of just 1<commit_after>﻿using System;
using ServiceStack.Redis;
using System.Collections.Generic;

namespace OperationsDashboard.Common
{
    class ServerMappingEntry
    {
        public long id;
        public string Servername;
        public string FriendlyName;
        public string LogicalEnvironment;
        public string Environment;
        public string Function;
        public string IPAddress;
        public string dnsHost;

        public ServerMappingEntry(string Servername, string friendlyname, string logicalEnvironment, string environment,string function, string iPAddress, string dnsHost)
        {
            this.Servername = Servername;
            this.FriendlyName = friendlyname;
            this.LogicalEnvironment = logicalEnvironment;
            this.Environment = environment;
            this.Function = function;
            this.IPAddress = iPAddress;
        }

        public void AddToRedis()
        {
            using(var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();
                this.id = ListServerMappingEntry.GetNextSequence();

                string key = string.Format("servermapping:{0}:{1}:{2}", this.LogicalEnvironment, this.Servername, this.IPAddress);
                ListServerMappingEntry.SetValue(key, this);
            }
        }
        public static IList<ServerMappingEntry> GetEntries(string logicalEnvironment = "*",string servername = "*",string function="*",string IPAddress = "*")        
        {
            using (var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();
                string key = string.Format("servermapping:{0}:{1}:{2}", logicalEnvironment, servername, IPAddress);
                return ListServerMappingEntry.GetValue(key) as IList<ServerMappingEntry>;
            }
        }
        public static ServerMappingEntry GetEntry(string logicalEnvironment = "*", string servername = "*", string function = "*", string IPAddress = "*")
        {
            using (var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();
                string key = string.Format("servermapping:{0}:{1}:{2}", logicalEnvironment, servername, IPAddress);
                return ListServerMappingEntry.GetValue(key);
            }
        }
        public static ServerMappingEntry GetEntryById(long id)
        {
            using (var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();                
                return ListServerMappingEntry.GetById(id);
            }
        }

        public static IList<ServerMappingEntry> GetAll()
        {
            using (var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port")))
            {
                var ListServerMappingEntry = RedisConnection.As<ServerMappingEntry>();
                return ListServerMappingEntry.GetAll();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09218054672600128, 'fraction_numerical': 0.0025429116338207248, 'mean_word_length': 2.4387978142076503, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1991838', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1533, 'n_words': 317}