public void TestPerformance() { var server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4572;file=performancetest.dat") { IdentifyableTechnicalName = "server" }; var client = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4572;server=localhost") { IdentifyableTechnicalName = "client" }; var svc = new ServicesManager(); svc.Start(); svc.AddService(server); svc.AddService(client); svc.StartServices(); var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 1000; i++) { User user = new User("User" + i, "Password", "*****@*****.**"); client.Db.Store(user); } client.Db.Commit(); sw.Stop(); svc.Stop(); }
public static void LoadAllService() { Console.Write(" 加载基础服务.........."); ServicesManager servicesManager = ServicesManager.GetServicesManager(); servicesManager.AddService("db", new DBAdaptor()); servicesManager.AddService("log", new LogHelp("db")); servicesManager.AddService("cache", new CacheHelp()); servicesManager.AddService("app", new AppHelp()); servicesManager.AddService("except", new ExceptionHelp("log")); CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); }
/// <summary> /// Initializes a new instance of the <see cref="BotEngineExample"/> class. /// /// You will have to have a valid app.Config settings file, please read documentation on codeplex. /// </summary> public BotEngineExample() { //ServicesManager.StartService(_commandInterpeter.TechnicalName); ConsoleHelpers.ParseCommandLine = ProcessCommandLine; Console.Title = string.Format("Managed Bot Engine Server {0}\r\n", base.Version()); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Clear(); ServicesManager.OnServiceStarted += ServicesManager_OnServiceStarted; LocalBotPluginServicesManager.OnServiceStarted += LocalBotPluginServicesManager_OnServiceStarted; BotEventSlaveStarted += HandleBotEventSlaveStarted; BotEventLoggedIn += HandleBotEventLoggedIn; BotEventEntersWorld += HandleBotEventEntersWorld; ConsoleHelpers.WriteLine(ConsoleColor.Yellow, string.Format("Managed Bot Engine Server {0}\r\nCopyright (C)2009-2010 TCPX\r\n", base.Version())); ConsoleHelpers.WriteLine(ConsoleColor.White, "Starting services"); ConsoleHelpers.ReadLine(); _sw1.Start(); // ensure creation of remote client test account for the AwManaged.RemotingTests console application. Start(); _commandInterpeter = new GenericInterpreterService <CCEnumTypeAttribute, CCEnumBindingAttribute, CCItemBindingAttribute> (Assembly.GetAssembly(GetType())) { TechnicalName = "Server Console interpeter" }; ServicesManager.AddService(_commandInterpeter); ServicesManager.StartService(_commandInterpeter.TechnicalName); }
public void SetUp() { server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4572;file=performancetest.dat") { IdentifyableTechnicalName = "server" }; client = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4572;server=localhost") { IdentifyableTechnicalName = "client" }; svc = new ServicesManager(); svc.Start(); svc.AddService(server); svc.AddService(client); svc.StartServices(); }
static Database() { Server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4572;file=performancetest.dat") { IdentifyableTechnicalName = "server" }; Storage = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4572;server=localhost") { IdentifyableTechnicalName = "client" }; var svc = new ServicesManager(); svc.Start(); svc.AddService(Server); svc.AddService(Storage); svc.StartServices(); }
/// <summary> /// Initializes a new instance of the <see cref="BotEngineExample"/> class. /// /// You will have to have a valid app.Config settings file, please read documentation on codeplex. /// </summary> public ServerConsole() { //ServicesManager.StartService(_commandInterpeter.TechnicalName); Console.ParseCommandLine = ProcessCommandLine; Console.Title = string.Format("Managed Bot Engine Server {0}\r\n", base.Version()); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Clear(); CrossAppDomainSingletonT <CrossAppDomainSingleton> .Instance.Shared = this; ServicesManager.OnServiceStarted += ServicesManager_OnServiceStarted; LocalBotPluginServicesManager.OnServiceStarted += LocalBotPluginServicesManager_OnServiceStarted; BotEventSlaveStarted += HandleBotEventSlaveStarted; BotEventLoggedIn += HandleBotEventLoggedIn; BotEventEntersWorld += HandleBotEventEntersWorld; Console.WriteLine(ConsoleMessageType.Information, string.Format("Managed Bot Engine Server {0}\r\nCopyright (C)2009-2010 TCPX\r\n", base.Version())); Console.WriteLine(ConsoleMessageType.Information, "Starting services"); Console.ReadLine(); _sw1.Start(); // ensure creation of remote client test account for the AwManaged.RemotingTests console application. Console.WriteLine("Connecting to your Universe"); try { Start(); } catch (Exception ex) { Console.WriteLine(ConsoleMessageType.Error, ex.Message); Console.WriteLine(ConsoleMessageType.Information, "Please check your application configuration universe connection settings."); Console.WriteLine(ConsoleMessageType.Information, "Press enter to exit."); System.Console.ReadLine(); Environment.Exit(0); } _commandInterpeter = new GenericInterpreterService <CCEnumTypeAttribute, CCEnumBindingAttribute, CCItemBindingAttribute> (Assembly.GetAssembly(GetType())) { IdentifyableTechnicalName = "Server Console interpeter" }; ServicesManager.AddService(_commandInterpeter); ServicesManager.StartService(_commandInterpeter.IdentifyableTechnicalName); // load persistent plugins. // persist thie command object if it does not exist. var q = from PersistedPlugin p in Storage.Db select p; foreach (var item in q.ToList()) { var instance = new LoadPlugin() { Name = item.Name }; instance.Interpreted = new List <ICommandGroup>(); instance.BotEngine = this; instance.Interpreted.Add(new Load()); var result = instance.ExecuteCommand(); Console.WriteLine(result.DisplayMessage); } }
public void TestAuthorization() { var server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4572;file=authorization.dat") { IdentifyableTechnicalName = "server" }; var client = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4572;server=localhost") { IdentifyableTechnicalName = "client" }; var svc = new ServicesManager(); svc.Start(); svc.AddService(server); svc.AddService(client); svc.Start(); var records = from User p in client.Db where p.NameToLower == "unittest" select p; User user; if (records.Count() == 0) { user = new User("unittest", "unittest", "*****@*****.**"); var result = user.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.Success); result = user.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.UserExists); var user2 = new User("unittest2", "unittest", "*****@*****.**"); result = user2.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.EmailExists); } else { user = records.Single(); var result = user.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.UserExists); user = new User("unittest2", "unittest", "*****@*****.**"); result = user.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.EmailExists); user = records.Single(); } Assert.IsTrue(user.IsAuthenticated(client.Db)); user = new User("unittest", "wrongpass"); Assert.IsFalse(user.IsAuthenticated(client.Db)); records = from User p in client.Db where p.NameToLower == "unittest" select p; user = records.Single(); var auth = new Authorization <User>(client.Db, user, "administrator"); auth.AddAuthorization(); Assert.IsTrue(auth.HasAuthorization()); auth.RemoveAuthorization(); auth = new Authorization <User>(client.Db, user, "backup-operator"); Assert.IsFalse(auth.HasAuthorization()); auth.AddAuthorization(); Assert.IsTrue(auth.HasAuthorization()); var roles = Authorization <User> .GetAuthorizations(client, user); Assert.IsTrue(roles.Count == 1 && roles[0] == "backup-operator"); auth.RemoveAuthorization(); svc.Stop(); }