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()); } }
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 BoMServerMapping(string filename = "") { if (filename == "") { filename = EnvVar.AsString("BoM_CsvFileName"); } Console.WriteLine("Loading BoMServerMapping from file" + filename); this.ReadBomAsCsv(filename); this.AddAllToRedis(); }
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); } }
void AddAllToRedis() { using (var RedisConnection = new RedisClient(EnvVar.AsString("Redis_Hostname"), EnvVar.AsInt("Redis_Port"))) { var ListServerMappingContext = RedisConnection.As <ServerMappingEntry>(); foreach (ServerMappingEntry ServerMappingEntry in ListServerMapping) { ServerMappingEntry.id = ListServerMappingContext.GetNextSequence(); } ListServerMappingContext.StoreAll(ListServerMapping); } }
void ReadBomAsCsv(string filename) { Console.WriteLine("Reading file " + filename); using (System.IO.TextReader textReader = new System.IO.StreamReader(filename)){ var csv = new CsvReader(textReader); //this.ListServerMapping = csv.GetRecords<ServerMappingEntryMap>(); csv.Configuration.HasHeaderRecord = true; csv.Configuration.RegisterClassMap <ServerMappingEntryMap>(); this.ListServerMapping = csv.GetRecords <ServerMappingEntry>().ToList(); //this section will limit how many entries we get **FOR TESTING** int Servermapping_Limit = EnvVar.AsInt("Servermapping_Limit"); if (Servermapping_Limit > 0) { this.ListServerMapping = this.ListServerMapping.Take(Servermapping_Limit); } } }
public static int AsInt(string key) { int environmentVariableValue = int.Parse(EnvVar.AsString(key)); return(environmentVariableValue); }
void ReadBomAsCsv() => ReadBomAsCsv(EnvVar.AsString("BoM_CsvFileName"));