예제 #1
0
 public MsSQLClient(DatabaseManager dbManager, int id)
 {
     this.dbManager = dbManager;
     this.connection = new SqlConnection(dbManager.getConnectionString());
 }
예제 #2
0
        internal static void Initialize()
        {
            Console.Clear();
            DateTime Start = DateTime.Now;
            SystemMute = false;

            IrcEnabled = false;
            ServerStarted = DateTime.Now;
            Console.Title = PiciEnvironment.Title + " " + PiciEnvironment.Version;
            Console.WindowHeight = 30;
            DefaultEncoding = Encoding.Default;

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("");
            Console.WriteLine("          ______ _       _    _______             ");
            Console.WriteLine("         (_____ (_)     (_)  (_______)            ");
            Console.WriteLine("          _____) )  ____ _    _____   ____  _   _ ");
            Console.WriteLine(@"         |  ____/ |/ ___) |  |  ___) |    \| | | |");
            Console.WriteLine(@"         | |    | ( (___| |  | |_____| | | | |_| |");
            Console.WriteLine(@"         |_|    |_|\____)_|  |_______)_|_|_|____/ ");

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("                              "+PiciEnvironment.Title+" " + PiciEnvironment.Version + " (Build " + PiciEnvironment.Build + ")");

            Console.WriteLine();

            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine();

            cultureInfo = CultureInfo.CreateSpecificCulture("en-GB");
            LanguageLocale.Init();

            try
            {
                ChatCommandRegister.Init();
                PetCommandHandeler.Init();
                PetLocale.Init();
                Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath,@"config.conf"));

                DateTime Starts = DateTime.Now;

                dbType = DatabaseType.MySQL;

                manager = new DatabaseManager(uint.Parse(PiciEnvironment.GetConfig().data["db.pool.maxsize"]), uint.Parse(PiciEnvironment.GetConfig().data["db.pool.minsize"]), int.Parse(PiciEnvironment.GetConfig().data["db.pool.minsize"]), dbType);
                manager.setServerDetails(
                    PiciEnvironment.GetConfig().data["db.hostname"],
                    uint.Parse(PiciEnvironment.GetConfig().data["db.port"]),
                    PiciEnvironment.GetConfig().data["db.username"],
                    PiciEnvironment.GetConfig().data["db.password"],
                    PiciEnvironment.GetConfig().data["db.name"]);
                manager.init();

                TimeSpan TimeUsed2 = DateTime.Now - Starts;

                LanguageLocale.InitSwearWord();

                Game = new Game(int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conlimit"]));
                Game.ContinueLoading();

                ConnectionManager = new ConnectionHandeling(int.Parse(PiciEnvironment.GetConfig().data["game.tcp.port"]),
                    int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conlimit"]),
                    int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conperip"]),
                    PiciEnvironment.GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                ConnectionManager.init();

                ConnectionManager.Start();

                StaticClientMessageHandler.Initialize();
                ClientMessageFactory.Init();

                string[] arrayshit = PiciEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(","));

                MusSystem = new MusSocket(PiciEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(PiciEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0);

                //InitIRC();

                groupsEnabled = true;

                useSSO = true;

                TimeSpan TimeUsed = DateTime.Now - Start;

                Logging.WriteLine("Server -> Started! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
                isLive = true;

                Console.Beep();

                if (bool_0_12)
                {
                    Console.WriteLine("Coffee team, I appreciate you testing. ;-*");
                    System.Threading.Thread.Sleep(2500);
                    PreformShutDown(true);
                    return;
                }

            }
            catch (KeyNotFoundException e)
            {
                Logging.WriteLine("Please check your configuration file - some values appear to be missing.");
                Logging.WriteLine("Press any key to shut down ...");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                PiciEnvironment.Destroy();

                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("Failed to initialize PiciEmulator: " + e.Message);
                Logging.WriteLine("Press any key to shut down ...");

                Console.ReadKey(true);
                PiciEnvironment.Destroy();

                return;
            }

            catch (Exception e)
            {
                Console.WriteLine("Fatal error during startup: " + e.ToString());
                Console.WriteLine("Press a key to exit");

                Console.ReadKey();
                Environment.Exit(1);
            }
        }
예제 #3
0
        internal static void Save()
        {
            if (!enabled)
                return;

            lock (loggedMessages.SyncRoot)
            {
                int totalMessages = loggedMessages.Count;

                if (loggedMessages.Count > 0)
                {
                    DatabaseManager dbManager = new DatabaseManager(300, 5, 1, DatabaseType.MySQL);
                    //To-do: Init dbManager from configuration file

                    using (IQueryAdapter dbClient = dbManager.getQueryreactor())
                    {
                        while (loggedMessages.Count > 0)
                        {
                            Message message = (Message)loggedMessages.Dequeue();

                            dbClient.setQuery("INSERT INTO system_packetlog (connectionid, timestamp, data) VALUES @connectionid @timestamp, @data");
                            dbClient.addParameter("connectionid", message.ConnectionID);
                            dbClient.addParameter("timestamp", message.GetTimestamp);
                            dbClient.addParameter("data", message.GetData);

                            dbClient.runQuery();

                        }
                    }
                }
            }
        }