Beispiel #1
0
        //public static bool StartEclipse;
        //public static bool StartBloodMoon;

        public static void ProgramStart()
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            ProgramLog.Log("TDSM Rebind API build {0}{1} running on {2}",
                           Globals.Build,
                           Globals.PhaseToSuffix(Globals.BuildPhase),
                           Tools.RuntimePlatform.ToString()
                           );
            Console.ForegroundColor = Command.ConsoleSender.DefaultColour;

            Globals.Touch();
            ID.Lookup.Initialise();

            try
            {
                var lis = new Logging.LogTraceListener();
                System.Diagnostics.Trace.Listeners.Clear();
                System.Diagnostics.Trace.Listeners.Add(lis);
                System.Diagnostics.Debug.Listeners.Clear();
                System.Diagnostics.Debug.Listeners.Add(lis);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            //This will setup the assembly resolves
            PluginManager.Initialize(Globals.PluginPath);
            PluginManager.SetHookSource(typeof(HookPoints));

            //Load the logs
            if (!ProgramLog.IsOpen)
            {
                var logFile = Globals.DataPath + System.IO.Path.DirectorySeparatorChar + "server.log";
                ProgramLog.OpenLogFile(logFile);
                ConsoleSender.DefaultColour = ConsoleColor.Gray;
            }

            //Load plugins
            PluginManager.LoadPlugins();

//            if (!Permissions.PermissionsManager.IsSet)
//            {
//                var file = System.IO.Path.Combine(Globals.DataPath, "permissions.xml");
//                //if (System.IO.File.Exists(file)) System.IO.File.Delete(file);
//                if (System.IO.File.Exists(file))
//                {
//                    var handler = new Permissions.XmlSupplier(file);
//                    if (handler.Load())
//                        Permissions.PermissionsManager.SetHandler(handler);
//                }
//            }
        }
        //public static bool StartEclipse;
        //public static bool StartBloodMoon;

        public static void ProgramStart()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Tools.WriteLine("TDSM Rebind API build {0}{1} running on {2}",
                            Globals.Build,
                            Globals.PhaseToSuffix(Globals.BuildPhase),
                            Tools.RuntimePlatform.ToString()
                            );
            Console.ForegroundColor = Command.ConsoleSender.DefaultColour;

            Globals.Touch();
            ID.Lookup.Initialise();

            var lis = new Logging.LogTraceListener();

            System.Diagnostics.Trace.Listeners.Clear();
            System.Diagnostics.Trace.Listeners.Add(lis);
            System.Diagnostics.Debug.Listeners.Clear();
            System.Diagnostics.Debug.Listeners.Add(lis);

            PluginManager.SetHookSource(typeof(HookPoints));
            PluginManager.Initialize(Globals.PluginPath);
            PluginManager.LoadPlugins();

            //SQLite here
//            if (!Permissions.PermissionsManager.IsSet)
//            {
//                var file = System.IO.Path.Combine(Globals.DataPath, "permissions.xml");
//                //if (System.IO.File.Exists(file)) System.IO.File.Delete(file);
//                if (System.IO.File.Exists(file))
//                {
//                    var handler = new Permissions.XmlSupplier(file);
//                    if (handler.Load())
//                        Permissions.PermissionsManager.SetHandler(handler);
//                }
//            }
        }
        //public static bool StartEclipse;
        //public static bool StartBloodMoon;
        /// <summary>
        /// The startup call (non vanilla) for both the client and server
        /// </summary>
        static void ProgramStart()
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            ProgramLog.Log("Open Terraria API build {0}{1} running on {2}",
                Globals.Build,
                Globals.PhaseToSuffix(Globals.BuildPhase),
                Tools.RuntimePlatform.ToString()
            );
            Console.ForegroundColor = Command.ConsoleSender.DefaultColour;

            Globals.Touch();
            ID.Lookup.Initialise();

            //            OTA.Data.Entity.ConnectionManager.ConnectionString = "Server=127.0.0.1;Database=tdsm;Uid=root;Pwd=;";
            //            OTA.Data.Entity.ConnectionManager.PrepareFromAssembly("MySql.Data", true);

            //            OTA.Data.Entity.ConnectionManager.ConnectionString = "Data Source=database.sqlite;Version=3;";
            //            OTA.Data.Entity.ConnectionManager.PrepareFromAssembly("System.Data.SQLite", true);

            try
            {
                var lis = new Logging.LogTraceListener();
                System.Diagnostics.Trace.Listeners.Clear();
                System.Diagnostics.Trace.Listeners.Add(lis);
                System.Diagnostics.Debug.Listeners.Clear();
                System.Diagnostics.Debug.Listeners.Add(lis);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            //This will setup the assembly resolves
            PluginManager.Initialize(Globals.PluginPath);
            PluginManager.SetHookSource(typeof(HookPoints));

            //Load the logs
            //TODO Why on earth did I put the log opening here?
            if (!ProgramLog.IsOpen)
            {
                if (!Directory.Exists(Globals.LogFolderPath)) Directory.CreateDirectory(Globals.LogFolderPath);
                var logFile = Path.Combine(Globals.LogFolderPath, "server.log");
                ProgramLog.OpenLogFile(logFile);
                ConsoleSender.DefaultColour = ConsoleColor.Gray;
            }

            //Load plugins
            PluginManager.LoadPlugins();

            //            OTA.Data.Storage.IsAvailable = (bool)Assembly.GetExecutingAssembly()
            //                .DefinedTypes
            //                .Where(x => x.Name == "OTAContext")
            //                .Select(y => y.GetMethod("HasConnection")).First().Invoke(null, null);
            OTA.Data.Storage.IsAvailable = OTA.Data.OTAContext.HasConnection();

            if (OTA.Data.Storage.IsAvailable) ProgramLog.Admin.Log("Entity framework has a registered connection.");
            else ProgramLog.Admin.Log("Entity framework has no registered connection.");

            if (OTA.Data.Storage.IsAvailable)
                using (var ctx = new OTA.Data.OTAContext())
                {
                    ctx.APIAccounts.Add(new OTA.Data.Entity.Models.APIAccount()
                        {
                            Username = "******",
                            Password = "******"
                        });

                    ctx.SaveChanges();
                }

            //            if (!Permissions.PermissionsManager.IsSet)
            //            {
            //                var file = System.IO.Path.Combine(Globals.DataPath, "permissions.xml");
            //                //if (System.IO.File.Exists(file)) System.IO.File.Delete(file);
            //                if (System.IO.File.Exists(file))
            //                {
            //                    var handler = new Permissions.XmlSupplier(file);
            //                    if (handler.Load())
            //                        Permissions.PermissionsManager.SetHandler(handler);
            //                }
            //            }

            //            Web.WebServer.Start("http://localhost:8448/");
        }
        //public static bool StartEclipse;
        //public static bool StartBloodMoon;
        public static void ProgramStart()
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            ProgramLog.Log("TDSM Rebind API build {0}{1} running on {2}",
                Globals.Build,
                Globals.PhaseToSuffix(Globals.BuildPhase),
                Tools.RuntimePlatform.ToString()
            );
            Console.ForegroundColor = Command.ConsoleSender.DefaultColour;

            Globals.Touch();
            ID.Lookup.Initialise();

            try
            {
                var lis = new Logging.LogTraceListener();
                System.Diagnostics.Trace.Listeners.Clear();
                System.Diagnostics.Trace.Listeners.Add(lis);
                System.Diagnostics.Debug.Listeners.Clear();
                System.Diagnostics.Debug.Listeners.Add(lis);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            //This will setup the assembly resolves
            PluginManager.Initialize(Globals.PluginPath);
            PluginManager.SetHookSource(typeof(HookPoints));

            //Load the logs
            if (!ProgramLog.IsOpen)
            {
                var logFile = Globals.DataPath + System.IO.Path.DirectorySeparatorChar + "server.log";
                ProgramLog.OpenLogFile(logFile);
                ConsoleSender.DefaultColour = ConsoleColor.Gray;
            }

            //Load plugins
            PluginManager.LoadPlugins();

            //            if (!Permissions.PermissionsManager.IsSet)
            //            {
            //                var file = System.IO.Path.Combine(Globals.DataPath, "permissions.xml");
            //                //if (System.IO.File.Exists(file)) System.IO.File.Delete(file);
            //                if (System.IO.File.Exists(file))
            //                {
            //                    var handler = new Permissions.XmlSupplier(file);
            //                    if (handler.Load())
            //                        Permissions.PermissionsManager.SetHandler(handler);
            //                }
            //            }
        }
        //public static bool StartEclipse;
        //public static bool StartBloodMoon;
        public static void ProgramStart()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Tools.WriteLine("TDSM Rebind API build {0}{1} running on {2}",
                Globals.Build,
                Globals.PhaseToSuffix(Globals.BuildPhase),
                Tools.RuntimePlatform.ToString()
            );
            Console.ForegroundColor = Command.ConsoleSender.DefaultColour;

            Globals.Touch();
            ID.Lookup.Initialise();

            var lis = new Logging.LogTraceListener();
            System.Diagnostics.Trace.Listeners.Clear();
            System.Diagnostics.Trace.Listeners.Add(lis);
            System.Diagnostics.Debug.Listeners.Clear();
            System.Diagnostics.Debug.Listeners.Add(lis);

            PluginManager.SetHookSource(typeof(HookPoints));
            PluginManager.Initialize(Globals.PluginPath);
            PluginManager.LoadPlugins();

            //SQLite here
            //            if (!Permissions.PermissionsManager.IsSet)
            //            {
            //                var file = System.IO.Path.Combine(Globals.DataPath, "permissions.xml");
            //                //if (System.IO.File.Exists(file)) System.IO.File.Delete(file);
            //                if (System.IO.File.Exists(file))
            //                {
            //                    var handler = new Permissions.XmlSupplier(file);
            //                    if (handler.Load())
            //                        Permissions.PermissionsManager.SetHandler(handler);
            //                }
            //            }
        }