internal static void Send(this Message Message) { try { try { Message.Encode(); } catch (Exception ex) { Exceptions.Log(ex, $"Exception while encoding message {Message.GetType()}"); return; } #if DEBUG Loggers.Log(Message, Utils.Padding(Message.Device.Socket.RemoteEndPoint.ToString(), 15)); #endif Message.Encrypt(); Gateway.Send(Message); Message.Process(); } catch (Exception) { // } }
internal override void Process() { #if DEBUG Loggers.Log($"Village Manager : Changing mode to {(Village_Mode)this.Device.Player.Avatar.Variables.Get(Variable.VillageToGoTo)}", true); //Console.WriteLine($"Village Manager : Changing mode to {(Village_Mode)this.Device.Player.Avatar.Variables.Get(Variable.VillageToGoTo)}", true); #endif }
internal Gateway() { this.AcceptPool = new SocketAsyncEventArgsPool(); this.ReadPool = new SocketAsyncEventArgsPool(); this.WritePool = new SocketAsyncEventArgsPool(); this.BufferPool = new Pool <byte[]>(); this.Initialize(); this.Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { ReceiveBufferSize = Constants.ReceiveBuffer, SendBufferSize = Constants.SendBuffer, Blocking = false, NoDelay = true }; this.Listener.Bind(new IPEndPoint(IPAddress.Any, 9339)); this.Listener.Listen(200); Program.Stopwatch.Stop(); Loggers.Log( Assembly.GetExecutingAssembly().GetName().Name + $" has been started on {Utils.LocalNetworkIP} in {Math.Round(Program.Stopwatch.Elapsed.TotalSeconds, 4)} Seconds!", true); this.StartAccept(); }
internal Gateway() { this.ReadPool = new SocketAsyncEventArgsPool(); this.WritePool = new SocketAsyncEventArgsPool(); this.Initialize(); this.Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { ReceiveBufferSize = Constants.ReceiveBuffer, SendBufferSize = Constants.SendBuffer, Blocking = false, NoDelay = true }; this.Listener.Bind(new IPEndPoint(IPAddress.Any, 9339)); this.Listener.Listen(200); Program.Stopwatch.Stop(); Loggers.Log($"Project BL.Servers.CoC has been started on {this.Listener.LocalEndPoint} in {Math.Round(Program.Stopwatch.Elapsed.TotalSeconds, 4)} Seconds !", true); SocketAsyncEventArgs AcceptEvent = new SocketAsyncEventArgs(); AcceptEvent.Completed += this.OnAcceptCompleted; this.StartAccept(AcceptEvent); }
internal static long GetPlayerSeed() { try { const string SQL = "SELECT coalesce(MAX(ID), 0) FROM player"; long Seed = -1; using (MySqlConnection Connections = new MySqlConnection(Credentials)) { Connections.Open(); using (MySqlCommand CMD = new MySqlCommand(SQL, Connections)) { CMD.Prepare(); Seed = Convert.ToInt64(CMD.ExecuteScalar()); } } return(Seed); } catch (Exception ex) { Loggers.Log("An exception occured when reconnecting to the MySQL Server.", true, Defcon.ERROR); Loggers.Log("Please check your database configuration!", true, Defcon.ERROR); Loggers.Log(ex.Message, true, Defcon.ERROR); Console.ReadKey(); } return(0); }
private void button1_Click(object sender, EventArgs e) { try { throw new Exception("Whoopsie"); } catch (Exception ex) { Loggers.Log(Level.Error, "Caught whoopsie", ex, new object[] { sender, e, null }); } }
internal void ProcessAccept(SocketAsyncEventArgs AsyncEvent) { Socket Socket = AsyncEvent.AcceptSocket; if (Socket.Connected && AsyncEvent.SocketError == SocketError.Success) { if (Constants.Local) { if (!Constants.AuthorizedIP.Contains(Socket.RemoteEndPoint.ToString().Split(':')[0])) { Socket.Close(); AsyncEvent.AcceptSocket = null; this.StartAccept(AsyncEvent); return; } } #if DEBUG Loggers.Log($"New client connected -> {((IPEndPoint) Socket.RemoteEndPoint).Address}", true); #endif SocketAsyncEventArgs ReadEvent = this.ReadPool.Dequeue(); if (ReadEvent != null) { Device device = new Device(Socket) { IPAddress = ((IPEndPoint)Socket.RemoteEndPoint).Address.ToString() }; Token Token = new Token(ReadEvent, device); device.Token = Token; Interlocked.Increment(ref this.ConnectedSockets); Resources.Devices.Add(device); try { if (!Socket.ReceiveAsync(ReadEvent)) { this.ProcessReceive(ReadEvent); } } catch (Exception) { this.Disconnect(ReadEvent); } } } else { Loggers.Log("Not connected or error at ProcessAccept.", false, Defcon.ERROR); Socket.Close(5); } this.StartAccept(AsyncEvent); }
internal override void Process() { int ResourceID = (CSV.Tables.Get(Gamefile.Resources).GetData((CSV.Tables.Get(Gamefile.Globals).GetData("ALLIANCE_CREATE_RESOURCE") as Globals).TextValue) as Files.CSV_Logic.Resource).GetGlobalID(); int Cost = (CSV.Tables.Get(Gamefile.Globals).GetData("ALLIANCE_CREATE_COST") as Globals).NumberValue; if (this.Device.Player.Avatar.HasEnoughResources(ResourceID, Cost)) { this.Device.Player.Avatar.Resources.Minus(ResourceID, Cost); this.Device.Player.Avatar.ClanId = Clan.Clan_ID; this.Device.Player.Avatar.Alliance_Level = Clan.Level; this.Device.Player.Avatar.Alliance_Name = Clan.Name; this.Device.Player.Avatar.Alliance_Role = (int)Role.Leader; this.Device.Player.Avatar.Badge_ID = Clan.Badge; this.Clan.Members.Add(this.Device.Player.Avatar); this.Clan.Chats.Add(new Entry { Stream_Type = Alliance_Stream.EVENT, Sender_ID = this.Device.Player.Avatar.UserId, Sender_Name = this.Device.Player.Avatar.Name, Sender_Level = this.Device.Player.Avatar.Level, Sender_League = this.Device.Player.Avatar.League, Sender_Role = Role.Leader, Event_ID = Events.JOIN_ALLIANCE, Event_Player_ID = this.Device.Player.Avatar.UserId, Event_Player_Name = this.Device.Player.Avatar.Name }); Resources.Clans.Save(this.Clan); new Alliance_Full_Entry(this.Device) { Clan = this.Clan }.Send(); new Server_Commands(this.Device) { Command = new Joined_Alliance(this.Device) { Clan = this.Clan }.Handle() }.Send(); new Server_Commands(this.Device) { Command = new Role_Update(this.Device) { Clan = this.Clan, Role = (int)Role.Leader }.Handle() }.Send(); } else { new Out_Of_Sync(this.Device).Send(); Resources.Clans.Delete(this.Clan); Loggers.Log("User tried to create alliance without enough [" + this.Device.Player.Avatar.UserId + ":" + GameUtils.GetHashtag(this.Device.Player.Avatar.UserId) + ']', true, Defcon.WARN); } }
internal static void ProcessAccept(SocketAsyncEventArgs e, bool startNew) { var acceptSocket = e.AcceptSocket; if (e.SocketError != SocketError.Success) { Loggers.Log("Not connected or error at ProcessAccept.", false, Defcon.ERROR); Drop(e); e = GetArgs(); } else { try { /*if (Constants.Local) * { * if (!Constants.AuthorizedIP.Contains(socket.RemoteEndPoint.ToString().Split(':')[0])) * { * socket.Close(); * e.AcceptSocket = null; * if (startNew) * StartAccept(e); * return; * } * }*/ //Loggers.Log($"New client connected -> {socket.RemoteEndPoint}", true); var device = new Device(acceptSocket); Devices.Add(device); var args = GetArgs(); var buffer = GetBuffer(); args.UserToken = device; args.SetBuffer(buffer, 0, buffer.Length); StartReceive(args); } catch (Exception ex) { Exceptions.Log(ex, "Exception while processing accept"); } } // Clean shit up for reuse. e.AcceptSocket = null; if (startNew) { StartAccept(e); } }
public static void AddOrUpdate(VMwareHostConnectionInfo row) { try { var propNames = new List <string>(); var paramNames = new List <string>(); var parameters = new List <SQLiteParameter>(); int paramI = 0; foreach (PropertyInfo propInfo in row.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) { propNames.Add(propInfo.Name); string paramName = "@param" + (++paramI); paramNames.Add(paramName); parameters.Add(new SQLiteParameter(paramName, propInfo.GetValue(row))); } if (row.username == ".&DO_NOT_UPDATE_Credentials&.") { int fieldI = propNames.IndexOf("username"); propNames.RemoveAt(fieldI); paramNames.RemoveAt(fieldI); parameters.RemoveAt(fieldI); fieldI = propNames.IndexOf("password"); propNames.RemoveAt(fieldI); paramNames.RemoveAt(fieldI); parameters.RemoveAt(fieldI); } if (Get(row.ipOrHostname) == null) { SQLiteDataAccess.ExecuteSQL("Insert into VMwareHostConnectionInfos(" + string.Join(",", propNames) + ") values(" + string.Join(",", paramNames) + ")", CommandType.Text, null, parameters.ToArray()); } else { var set = new List <string>(); for (int i = 0; i != propNames.Count; i++) { set.Add(propNames[i] + "=" + paramNames[i]); } string paramName = "@param" + (++paramI); parameters.Add(new SQLiteParameter(paramName, row.ipOrHostname)); SQLiteDataAccess.ExecuteSQL("Update VMwareHostConnectionInfos set " + string.Join(",", set) + " where ipOrHostname=" + paramName, CommandType.Text, null, parameters.ToArray()); } } catch (Exception ex) { //Let IIS handle the errors, but using own logging. Loggers.Log(Level.Error, "Failed adding or updating vhost connection info", ex, new object[] { row }); throw; } }
public static void Clear() { try { SQLiteDataAccess.ExecuteSQL("Delete from VMwareHostSystemInformations"); } catch (Exception ex) { //Let IIS handle the errors, but using own logging. Loggers.Log(Level.Error, "Failed clearing vhost system info", ex); throw; } }
public static bool HasKey(string key) { try { return(SQLiteDataAccess.GetDataTable("Select key from APIKeys where key=@param1", CommandType.Text, null, new SQLiteParameter("@param1", key)).Rows.Count != 0); } catch (Exception ex) { //Let IIS handle the errors, but using own logging. Loggers.Log(Level.Error, "Failed getting API key from database", ex, new object[] { key }); throw; } }
internal void Process(byte[] Buffer) { if (Buffer.Length >= 7) { int[] _Header = new int[3]; using (Reader Reader = new Reader(Buffer)) { _Header[0] = Reader.ReadUInt16(); // Message ID Reader.Seek(1); _Header[1] = Reader.ReadUInt16(); // Length _Header[2] = Reader.ReadUInt16(); // Version if (MessageFactory.Messages.ContainsKey(_Header[0])) { Message _Message = Activator.CreateInstance(MessageFactory.Messages[_Header[0]], this, Reader) as Message; _Message.Identifier = (ushort)_Header[0]; _Message.Length = (ushort)_Header[1]; _Message.Version = (ushort)_Header[2]; _Message.Reader = Reader; try { _Message.Decrypt(); #if DEBUG Loggers.Log(Utils.Padding(_Message.Device.Socket.RemoteEndPoint.ToString(), 15) + " --> " + _Message.GetType().Name, true); Loggers.Log(_Message, Utils.Padding(_Message.Device.Socket.RemoteEndPoint.ToString(), 15)); #endif _Message.Decode(); _Message.Process(); } catch (Exception Exception) { Loggers.Log(Utils.Padding(Exception.GetType().Name, 15) + " : " + Exception.Message + ". [" + (this.Player != null ? this.Player.Avatar.UserId + ":" + GameUtils.GetHashtag(this.Player.Avatar.UserId) : "---") + ']' + Environment.NewLine + Exception.StackTrace, true, Defcon.ERROR); } } else { #if DEBUG Loggers.Log(Utils.Padding(this.GetType().Name, 15) + " : Aborting, we can't handle the following message : ID " + _Header[0] + ", Length " + _Header[1] + ", Version " + _Header[2] + ".", true, Defcon.WARN); #endif this.Keys.SNonce.Increment(); } this.Token.Packet.RemoveRange(0, _Header[1] + 7); if ((Buffer.Length - 7) - _Header[1] >= 7) { this.Process(Reader.ReadBytes((Buffer.Length - 7) - _Header[1])); } } } }
static void Main(string[] args) { string path = @"C:\1\2\..\..\..\3.txt"; path = Path.GetFullPath(path); Loggers logger = new Loggers(new FileLogger(@"D:\Recycle\!delete\ProjectsGarbage\test_log.log", LogLevel.Debug), new ConsoleLogger(LogLevel.Debug)); //logger.WriteLogMode = FileLogger.WriteLogOptions.LockAndFlushAfterEveryWrite; //logger.WriteLogMode = FileLogger.WriteLogOptions.Lock; //logger.TypeWord = new LoggerBase.LogTypeWord("I", "W", "E", "D"); //logger.FormatMessage = (msgLogLevel, message) => { return string.Format("{2} {0}: {1}", msgLogLevel, message, DateTime.Now.ToString(@"HH\:mm\:ss")); }; logger.Log(LogLevel.Info, "Test infooo"); logger.Log(LogLevel.Info, "2"); logger.Log(LogLevel.Info, "3"); logger.Log(LogLevel.Info, "4"); logger.Log(LogLevel.Info, "5"); logger.Log(LogLevel.Info, "6"); //try //{ // int i = TestMethod2(0.321F); //} //catch (Exception ex) //{ // logger.Log(LogLevel.Error, ex); //} //Console.WriteLine(ProgramInfo.FullProgramName); //Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); //asm = Assembly.Get //ProgramInfo.SetProgramMainAssembly(asm); //Console.WriteLine(ExtendedPath.GetRightFileNameFromString(ProgramInfo.Name)); Console.WriteLine("end."); Console.ReadKey(); }
internal static void GetAllSeed() { try { MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder() { Server = Utils.ParseConfigString("MysqlIPAddress"), UserID = Utils.ParseConfigString("MysqlUsername"), Port = (uint)Utils.ParseConfigInt("MysqlPort"), Pooling = false, Database = Utils.ParseConfigString("MysqlDatabase"), MinimumPoolSize = 1 }; if (!string.IsNullOrWhiteSpace(Utils.ParseConfigString("MysqlPassword"))) { builder.Password = Utils.ParseConfigString("MysqlPassword"); } Credentials = builder.ToString(); using (MySqlConnection Conn = new MySqlConnection(Credentials)) { Conn.Open(); using (MySqlCommand CMD = new MySqlCommand("SELECT coalesce(MAX(ID), 0) FROM player", Conn)) { CMD.Prepare(); Players.Seed = Convert.ToInt64(CMD.ExecuteScalar()) + 1; } using (MySqlCommand CMD = new MySqlCommand("SELECT coalesce(MAX(ID), 0) FROM clan", Conn)) { CMD.Prepare(); Resources.Clans.Seed = Convert.ToInt64(CMD.ExecuteScalar()) + 1; } using (MySqlCommand CMD = new MySqlCommand("SELECT coalesce(MAX(ID), 0) FROM battle", Conn)) { CMD.Prepare(); Resources.Battles.Seed = Convert.ToInt64(CMD.ExecuteScalar()) + 1; } } } catch (Exception ex) { Loggers.Log("An exception occured when reconnecting to the MySQL Server.", true, Defcon.ERROR); Loggers.Log("Please check your database configuration!", true, Defcon.ERROR); Loggers.Log(ex.Message, true, Defcon.ERROR); Console.ReadKey(); } }
internal static void Listen() { Listener.Bind(new IPEndPoint(IPAddress.Any, Convert.ToInt32(Constants.Port))); Listener.Listen(100); Program.Stopwatch.Stop(); var args = GetArgs(); StartAccept(args); Loggers.Log(Assembly.GetExecutingAssembly().GetName().Name + $" has been started on {Utils.LocalNetworkIP} in {Math.Round(Program.Stopwatch.Elapsed.TotalSeconds, 4)} Seconds!", true); }
internal override void Decode() { Loggers.Log(this, Utils.Padding(this.Device.Player != null ? this.Device.Player.Avatar.UserId + ":" + GameUtils.GetHashtag(this.Device.Player.Avatar.UserId) : "Player is null", 15), Defcon.TRACE); this.CTick = this.Reader.ReadInt32(); this.Checksum = this.Reader.ReadUInt32(); this.Count = this.Reader.ReadInt32(); this.Commands = this.Reader.ReadBytes((int)(this.Reader.BaseStream.Length - this.Reader.BaseStream.Position)); #if DEBUG this.LCommands = new List <Command>((int)this.Count); #endif }
public Region() { if (!Directory.Exists("Gamefiles/database/")) { throw new DirectoryNotFoundException("Directory Gamefiles/database does not exist!"); } if (!File.Exists(DbPath)) { throw new FileNotFoundException($"{DbPath} does not exist in current directory!"); } Reader = new DatabaseReader(DbPath, FileAccessMode.Memory); Loggers.Log("Region database loaded into memory.", true); }
internal static void Listen() { IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; Listener.Bind(new IPEndPoint(IPAddress.Parse(ipAddress.ToString()), Convert.ToInt32(ConfigurationManager.AppSettings["Port"]))); Listener.Listen(100); Program.Stopwatch.Stop(); var args = GetArgs(); StartAccept(args); Loggers.Log(Assembly.GetExecutingAssembly().GetName().Name + $" has been started on {Utils.LocalNetworkIP} in {Math.Round(Program.Stopwatch.Elapsed.TotalSeconds, 4)} Seconds!", true); }
public Region() { if (!Directory.Exists("Gamefiles/database/")) { throw new Exception("Directory Gamefiles/database does not exist!"); } if (!File.Exists(DbPath)) { throw new Exception($"{DbPath} does not exist in current directory!"); } this.Reader = new DatabaseReader(DbPath, FileAccessMode.Memory); Loggers.Log("CRepublic.Boom region database loaded into memory."); }
public Region() { if (!Directory.Exists("Gamefiles/database/")) { throw new DirectoryNotFoundException("Directory Gamefiles/database does not exist!"); } if (!File.Exists(DbPath)) { throw new FileNotFoundException($"{DbPath} does not exist in current directory!"); } //Reader = new DatabaseReader(DbPath, FileAccessMode.Memory); Reader = new DatabaseReader(DbPath, FileAccessMode.MemoryMapped); //Lower ram usage on start but idk the speed Loggers.Log("Region database loaded into memory.", true); }
internal Redis() { ConfigurationOptions Configuration = new ConfigurationOptions(); Configuration.EndPoints.Add(Utils.ParseConfigString("RedisIPAddress"), Utils.ParseConfigInt("RedisPort")); Configuration.Password = Utils.ParseConfigString("RedisPassword"); Configuration.ClientName = this.GetType().Assembly.FullName; ConnectionMultiplexer Connection = ConnectionMultiplexer.Connect(Configuration); Redis.Players = Connection.GetDatabase((int)Database.Players); Redis.Clans = Connection.GetDatabase((int)Database.Clans); Loggers.Log("Redis Database has been succesfully loaded.", true); }
public static void Remove(params VMwareHostSystemInformation[] rows) { try { var hostnames = new string[rows.Length]; for (int i = 0; i != rows.Length; i++) { hostnames[i] = rows[i].ipOrHostname; } Remove(hostnames); } catch (Exception ex) { //Let IIS handle the errors, but using own logging. Loggers.Log(Level.Error, "Failed removing vhost system info", ex, new object[] { rows }); throw; } }
public static VMwareHostSystemInformation Get(string ipOrHostname) { try { var dt = SQLiteDataAccess.GetDataTable("Select * from VMwareHostSystemInformations where ipOrHostname=@param1", CommandType.Text, null, new SQLiteParameter("@param1", ipOrHostname)); if (dt.Rows.Count == 0) { return(null); } return(Parse(dt.Rows[0])); } catch (Exception ex) { //Let IIS handle the errors, but using own logging. Loggers.Log(Level.Error, "Failed retrieving vhost system info", ex, new object[] { ipOrHostname }); throw; } }
public static long GetPlayerSeed() { try { const string SQL = "SELECT coalesce(MAX(ID), 0) FROM player"; long Seed = -1; MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder() { Server = Utils.ParseConfigString("MysqlIPAddress"), UserID = Utils.ParseConfigString("MysqlUsername"), Port = (uint)Utils.ParseConfigInt("MysqlPort"), Pooling = false, Database = Utils.ParseConfigString("MysqlDatabase"), MinimumPoolSize = 1 }; if (!string.IsNullOrWhiteSpace(Utils.ParseConfigString("MysqlPassword"))) { builder.Password = Utils.ParseConfigString("MysqlPassword"); } Credentials = builder.ToString(); Connections = new MySqlConnection(Credentials); Connections.Open(); using (MySqlCommand CMD = new MySqlCommand(SQL, Connections)) { CMD.Prepare(); Seed = Convert.ToInt64(CMD.ExecuteScalar()); } return(Seed); } catch (Exception ex) { Loggers.Log("An exception occured when reconnecting to the MySQL Server.", true, Defcon.ERROR); Loggers.Log("Please check your database configuration!", true, Defcon.ERROR); Loggers.Log(ex.Message, true, Defcon.ERROR); Console.ReadKey(); } return(0); }
internal override void Process() { var ca = this.Device.Player.Avatar; var go = this.Device.Player.Avatar.Variables.IsBuilderVillage ? this.Device.Player.GameObjectManager.GetBuilderVillageGameObjectByID(BuildingId) : this.Device.Player.GameObjectManager.GetGameObjectByID(BuildingId); var b = (ConstructionItem)go; var bd = (Buildings)b.GetConstructionItemData(); if (ca.HasEnoughResources(bd.GetBuildResource(b.GetUpgradeLevel()).GetGlobalID(), bd.GetBuildCost(b.GetUpgradeLevel()))) { var name = go.GetData().Row.Name; #if DEBUG Loggers.Log($"Building: Unlocking {name} with ID {BuildingId}", true); #endif if (bd.IsAllianceCastle()) { var a = (Building)go; var al = a.GetBuildingData; ca.Castle_Level++; ca.Castle_Total = al.GetUnitStorageCapacity(ca.Castle_Level); ca.Castle_Total_SP = al.GetAltUnitStorageCapacity(ca.Castle_Level); } if (name == "Hero Altar Warmachine") { if (b.GetHeroBaseComponent(true) != null) { Buildings data = (Buildings)b.GetData(); Heroes hd = CSV.Tables.Get(Gamefile.Heroes).GetData(data.HeroType) as Heroes; this.Device.Player.Avatar.SetUnitUpgradeLevel(hd, 0); this.Device.Player.Avatar.SetHeroHealth(hd, 0); this.Device.Player.Avatar.SetHeroState(hd, 3); } } var rd = bd.GetBuildResource(b.GetUpgradeLevel()); ca.Resources.Minus(rd.GetGlobalID(), bd.GetBuildCost(b.GetUpgradeLevel())); b.Unlock(); } }
public static void AddOrUpdate(VMwareHostSystemInformation row) { try { var propNames = new List <string>(); var paramNames = new List <string>(); var parameters = new List <SQLiteParameter>(); int paramI = 0; foreach (PropertyInfo propInfo in row.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) { propNames.Add(propInfo.Name); string paramName = "@param" + (++paramI); paramNames.Add(paramName); parameters.Add(new SQLiteParameter(paramName, propInfo.GetValue(row))); } if (Get(row.ipOrHostname) == null) { SQLiteDataAccess.ExecuteSQL("Insert into VMwareHostSystemInformations(" + string.Join(",", propNames) + ") values(" + string.Join(",", paramNames) + ")", CommandType.Text, null, parameters.ToArray()); } else { var set = new List <string>(); for (int i = 0; i != propNames.Count; i++) { set.Add(propNames[i] + "=" + paramNames[i]); } string paramName = "@param" + (++paramI); parameters.Add(new SQLiteParameter(paramName, row.ipOrHostname)); SQLiteDataAccess.ExecuteSQL("Update VMwareHostSystemInformations set " + string.Join(",", set) + " where ipOrHostname=" + paramName, CommandType.Text, null, parameters.ToArray()); } } catch (Exception ex) { //Let IIS handle the errors, but using own logging. Loggers.Log(Level.Error, "Failed adding or updating vhost system info to the database", ex, new object[] { row }); throw; } }
internal Redis() { ConfigurationOptions Configuration = new ConfigurationOptions(); Configuration.EndPoints.Add(Utils.ParseConfigString("RedisIPAddress"), Utils.ParseConfigInt("RedisPort")); Configuration.Password = Utils.ParseConfigString("RedisPassword"); Configuration.ClientName = this.GetType().Assembly.FullName; Configuration.HighPrioritySocketThreads = true; Configuration.SyncTimeout = (int)TimeSpan.FromSeconds(10).TotalMilliseconds; ConnectionMultiplexer Connection = ConnectionMultiplexer.Connect(Configuration); Redis.Players = Connection.GetDatabase((int)Logic.Enums.Database.Players); Redis.Clans = Connection.GetDatabase((int)Logic.Enums.Database.Clans); Redis.Battles = Connection.GetDatabase((int)Logic.Enums.Database.Battles); Redis.ClanWars = Connection.GetDatabase((int)Logic.Enums.Database.ClanWars); Loggers.Log("Redis Database has been succesfully loaded.", true); }
public static void Remove(params string[] ipOrHostnames) { try { var paramNames = new List <string>(); var parameters = new List <SQLiteParameter>(); int paramI = 0; foreach (string hostname in ipOrHostnames) { string paramName = "@param" + (++paramI); paramNames.Add(paramName); parameters.Add(new SQLiteParameter(paramName, hostname)); } SQLiteDataAccess.ExecuteSQL("Delete from VMwareHostSystemInformations where ipOrHostname in(" + string.Join(",", paramNames) + ")", CommandType.Text, null, parameters.ToArray()); } catch (Exception ex) { //Let IIS handle the errors, but using own logging. Loggers.Log(Level.Error, "Failed removing vhost system info", ex, new object[] { ipOrHostnames }); throw; } }
internal static void Send(this Message Message) { try { Message.Encode(); #if DEBUG if (Message.Device.Connected()) { Console.WriteLine(Utils.Padding(Message.Device.Socket.RemoteEndPoint.ToString(), 15) + " <-- " + Message.GetType().Name); Loggers.Log(Message, Utils.Padding(Message.Device.Socket.RemoteEndPoint.ToString(), 15)); } #endif Message.Encrypt(); Resources.Gateway.Send(Message); Message.Process(); } catch (Exception) { } }