Ejemplo n.º 1
0
        public static IEngineService Create(Guid tenantId)
        {
            if (Container == null)
            {
                throw new ArgumentNullException("Container", "Unity Container Not Initialized.");
            }

            if (string.IsNullOrEmpty(ConnectionString))
            {
                throw new ArgumentNullException("ConnectionString", "ConnectionString is empty.");
            }

            var iCommonMapper     = Container.Resolve <ICommonMapper>();
            var iCommonRepository = new CommonRepository(new Common_Entities(ConnectionString));
            var tenant            = iCommonRepository.RetrieveTenantById(tenantId);

            iCommonRepository.Dispose();
            if (tenant == null)
            {
                throw new Exception("Could not find schema for this tenantId:" + tenantId);
            }

            var            engineEntities   = new ANDP_Engine_Entities(ConnectionString, tenant.Schema);
            var            engineRepository = new EngineRepository(engineEntities);
            IEngineService service          = new EngineService(engineRepository, iCommonMapper);

            return(service);
        }
        public EngineRepositoryContext()
        {
            var repo = new EngineRepository <TState, TInput>();

            Schematics = repo;
            Machines   = repo;
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var engine = new EngineRepository().GetEngine(@"C:\Users\ack\src\AutoTest.Net\AutoTest.net.sln", true);

            if (engine == null)
            {
                engine = new EngineRepository().StartEngine(@"C:\Users\ack\src\AutoTest.Net\AutoTest.net.sln", @"C:\Users\ack\src\AutoTestExtensions\src\AutoTest.VS\bin");
            }
            engine.EngineConnecting    += engine_EngineConnecting;
            engine.EngineDisconnecting += engine_EngineDisconnecting;
            engine.SessionStarted      += engine_SessionStarted;
            engine.SessionFinished     += engine_SessionFinished;
            engine.BuildFinished       += engine_BuildFinished;
            engine.TestsFinished       += engine_TestsFinished;
            engine.TestProgress        += engine_TestProgress;
            engine.Connect();
            System.Console.WriteLine("Waiting for connection");
            engine.WaitForConnection();
            System.Console.WriteLine("System connected");
            engine.RunAll();
            //engine.RunPartial(@"C:\Users\ack\src\AutoTest.Net\src\AutoTest.Test\AutoTest.Test.csproj");
            //engine.RunTests(new TestScope(@"C:\Users\ack\src\AutoTest.Net\src\AutoTest.Test\AutoTest.Test.csproj"));
            System.Console.ReadLine();
            engine.Disconnect();
        }
Ejemplo n.º 4
0
		public int Save(BE.Engine engine)
		{
			EngineRepository repository = new EngineRepository();
			if(engine.ID > 0)
				return repository.Update(engine);
			else
				return repository.Insert(engine);
		}
Ejemplo n.º 5
0
 public UnitOfWork(AplicationContext context)
 {
     this.context = context;
     Cars         = new CarRepository(this.context);
     CarsUsers    = new CarUserRepository(this.context);
     Chassiss     = new ChassisRepository(this.context);
     Engines      = new EngineRepository(this.context);
     Users        = new UserRepository(this.context);
 }
Ejemplo n.º 6
0
        public Engine GetEngine(string url, string modelUrl, string manufacturerUrl)
        {
            List<QueryParameter> parameters = new List<QueryParameter>();
            parameters.Add(new QueryParameter("url", url));
            parameters.Add(new QueryParameter("modelUrl", modelUrl));
            parameters.Add(new QueryParameter("manufacturerUrl", manufacturerUrl));

            List<Engine> engines = new EngineRepository().GetByParameter("getByUrl", parameters, false);
            return engines.Count > 0 ? engines[0] : null;
        }
Ejemplo n.º 7
0
        protected IAdminEnginesService GetService(ApplicationDbContext dbContext)
        {
            var engineRepository   = new EngineRepository(dbContext);
            var adminDeleteService = new AdminCommonDeleteService(dbContext);
            var adminEditService   = new AdminCommonEditService(dbContext);
            var adminCreateService = new AdminCommonCreateService(dbContext);
            var service            = new AdminEnginesService(
                engineRepository,
                adminDeleteService,
                adminEditService,
                adminCreateService);

            return(service);
        }
Ejemplo n.º 8
0
        static void Train(EngineRepository repository)
        {
            int iteration = 0;

            while (true)
            {
                Console.WriteLine($"Running iteration { iteration }");

                repository.Purge(80);
                var tournament = new Tournament(repository, 80);
                tournament.Train(10);

                iteration++;
            }
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            string mode   = "";
            string folder = "";
            string engine = "";

            var options = new OptionSet {
                { "m|mode=", "Either train, play or human. The default is train.", str => mode = str.ToLowerInvariant() },
                { "f|folder=", "The folder where the engines are stored.", str => folder = str },
                { "e|engine=", "The specific engine to play against", str => engine = str }
            };

            if (args.Length == 0 || args.Any(x => x == "/?" || x == "-?" || x == "?" || x == "help" || x == "--help"))
            {
                options.WriteOptionDescriptions(Console.Out);
                return;
            }

            options.Parse(args);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var repository = new EngineRepository(folder);

            if (mode == "train")
            {
                Train(repository);
            }
            else if (mode == "play")
            {
                Play(repository, engine);
            }
            else if (mode == "human")
            {
                PlayAgainsHuman(repository, engine);
            }
            else
            {
                Console.WriteLine("The mode should either be 'train', 'play' or 'human'");
            }
        }
Ejemplo n.º 10
0
            public async Task CreateEngineAsync(TimeSpan inactiveTimeout = default(TimeSpan))
            {
                Engine = new Engine
                {
                    Id = "engine1",
                    SourceLanguageTag = "es",
                    TargetLanguageTag = "en",
                    IsShared          = false,
                    Projects          = { "project1" }
                };
                await EngineRepository.InsertAsync(Engine);

                var options = new EngineOptions {
                    InactiveEngineTimeout = inactiveTimeout
                };

                EngineRunner = new EngineRunner(new OptionsWrapper <EngineOptions>(options), EngineRepository,
                                                BuildRepository, CreateSmtModelFactory(), CreateRuleEngineFactory(), CreateTextCorpusFactory(),
                                                Substitute.For <ILogger <EngineRunner> >(), Engine.Id);
            }
Ejemplo n.º 11
0
 static void Main(string[] args)
 {
     var engine = new EngineRepository().GetEngine(@"C:\Users\ack\src\AutoTest.Net\AutoTest.net.sln", true);
     if (engine == null)
         engine = new EngineRepository().StartEngine(@"C:\Users\ack\src\AutoTest.Net\AutoTest.net.sln", @"C:\Users\ack\src\AutoTestExtensions\src\AutoTest.VS\bin");
     engine.EngineConnecting += engine_EngineConnecting;
     engine.EngineDisconnecting += engine_EngineDisconnecting;
     engine.SessionStarted += engine_SessionStarted;
     engine.SessionFinished += engine_SessionFinished;
     engine.BuildFinished += engine_BuildFinished;
     engine.TestsFinished += engine_TestsFinished;
     engine.TestProgress += engine_TestProgress;
     engine.Connect();
     System.Console.WriteLine("Waiting for connection");
     engine.WaitForConnection();
     System.Console.WriteLine("System connected");
     engine.RunAll();
     //engine.RunPartial(@"C:\Users\ack\src\AutoTest.Net\src\AutoTest.Test\AutoTest.Test.csproj");
     //engine.RunTests(new TestScope(@"C:\Users\ack\src\AutoTest.Net\src\AutoTest.Test\AutoTest.Test.csproj"));
     System.Console.ReadLine();
     engine.Disconnect();
 }
Ejemplo n.º 12
0
        static void Play(EngineRepository repository, string engineId)
        {
            IEngine trained;

            if (String.IsNullOrEmpty(engineId))
            {
                trained = repository.GetTopEngines(1).First();
            }
            else
            {
                trained = repository.Load(engineId);
            }

            int White = 0;
            int Black = 0;

            do
            {
                IEngine randomEngine = repository.CreateRandom();
                var     game         = new Game(randomEngine, trained);
                var     printer      = new TicTacToePrinter(game.Board);

                CellValue color = game.Play();

                if (color == CellValue.White)
                {
                    White++;
                }
                else if (color == CellValue.Black)
                {
                    Black++;
                }

                Console.Write(printer.Print());

                Console.WriteLine($"{color} has won");
                Console.WriteLine($"White: {White} Black: {Black}");
            }while (Console.ReadKey(true).KeyChar != 'q');
        }
Ejemplo n.º 13
0
        static void PlayAgainsHuman(EngineRepository repository, string engineId)
        {
            IEngine engine;
            IEngine human = new Human();

            if (String.IsNullOrEmpty(engineId))
            {
                engine = repository.GetTopEngines(1).First();
            }
            else
            {
                engine = repository.Load(engineId);
            }

            var game    = new Game(human, engine);
            var color   = game.Play();
            var printer = new TicTacToePrinter(game.Board);

            Console.Write(printer.Print());
            Console.WriteLine($"{color} has won");
            Console.ReadKey(true);
        }