示例#1
0
        public void ParseDirectoryContent_FullTest()
        {
            using var serviceProvider = InitializationHelper.CreateServiceCollection().BuildServiceProvider();
            using var scope           = serviceProvider.CreateScope();

            bool dbEmpty = false, dbInfoAdded = false, directoryParsed = false, dbCachesCleared = false,
                 dbContentChecked = false, dbContentDeleted = false;

            dbEmpty = CheckDbEmpty(serviceProvider);
            if (dbEmpty)
            {
                dbInfoAdded     = AddDbInfo(serviceProvider);
                directoryParsed = ParseDirectory(serviceProvider);
            }
            dbCachesCleared  = ClearDbCaches(serviceProvider);
            dbContentChecked = CheckDbContent(serviceProvider);
            dbContentDeleted = DeleteDbContent(serviceProvider);

            Assert.That(dbEmpty, "DB not empty");
            Assert.That(dbInfoAdded, "DB info not added");
            Assert.That(directoryParsed, "Directory not parsed");
            Assert.That(dbCachesCleared, "Db caches not cleared");
            Assert.That(dbContentChecked, "DB content not checked");
            Assert.That(dbContentDeleted, "db content not deleted");
        }
示例#2
0
        public static async Task<Guid> GetCostCentreAppicationIdAndAppInit(InitializationHelper helper)
        {
            TI.trace(section, "GetCostCentreAppicationIdAndAppInit");

            Guid ccAppId = await helper.GetCostCentreApplicationIdAndAppInitialise();
            return ccAppId;
        }
示例#3
0
        public void DirectoryContentApplication_IsResolvable()
        {
            using var serviceProvider = InitializationHelper.CreateServiceCollection().BuildServiceProvider();
            var controller = serviceProvider.GetService <FileImportApplication>();

            Assert.IsNotNull(controller);
        }
示例#4
0
        public void MaintenanceController_IsResolvable()
        {
            using var serviceProvider = InitializationHelper.CreateServiceCollection().BuildServiceProvider();
            var controller = serviceProvider.GetService <DatabaseInfoApplication>();

            Assert.IsNotNull(controller);
        }
示例#5
0
        internal ImportModule(CommandProcessorOptions options, ServiceDescriptor serviceDescriptor, WsdlImporter importer)
        {
            _codeCompileUnit  = new CodeCompileUnit();
            _options          = options;
            _codegenExtension = new WcfCodeGenerationExtension(options);

            _wsdlImporter      = importer;
            _contractGenerator = InitializationHelper.CreateServiceContractGenerator(options, _codeCompileUnit);
        }
示例#6
0
 public static async Task<bool> DoCompleteSetup(InitializationHelper helper)
 {
     AppIdSetup(helper);
     SetConfigWebserviceUrl(helper);
     CostCentreLoginResponse r = InitialLogin(helper);
     Guid ccappId = await GetCostCentreAppicationIdAndAppInit(helper);
     CanSync(helper);
     bool masterDataSync = await SyncMasterData(helper);
     return true;
 }
示例#7
0
        // *** OPERATIONS *** //

        #region CreateGame
        public Game CreateGame
            (string name,                                                //  name of game to create
            Dictionary <string, string> definitions = null,              //  optional dict of defined Game Variables
            InitializationHelper initHelper         = null)              //  optional init helper (null if non-interactive)
        {
            //	look up the Type of the requested Game class
            Type gameClass = GameClasses[name];

            //	look up the GameAttribute of the requested game
            GameAttribute gameAttribute = GameAttributes[name];

            //	use reflection to find the default constructor
            ConstructorInfo ci = gameClass.GetConstructor(new Type[] { });

            if (ci == null)
            {
                //	No appropriate constructor found.
                //	This is probably a template (abstract) Game
                return(null);
            }

            //	invoke the constructor to create the game object
            Game newgame;

            try
            {
                newgame = (Game)ci.Invoke(null);
            }
            catch (Exception ex)
            {
                throw new Exceptions.GameInitializationException(gameAttribute, "Exception in Manager.CreateGame: failed to create game", ex);
            }

            //	find the Game's Environment field and set it to a newly
            //	constructed interpreter/compiler Environment with this Manager's
            //	global Environment as the parent Environment.
            FieldInfo environmentField = newgame.GetType().GetField("Environment");

            if (environmentField != null)
            {
                environmentField.SetValue(newgame, new Compiler.Environment(Environment));
            }

            //	initialize the Game with the Initialize method - this is essential
            newgame.Initialize(gameAttribute, definitions, initHelper);

            //	return newly constructed Game object
            return(newgame);
        }
示例#8
0
        public void BeforeImportMetadata(ServiceDescriptor serviceDescriptor)
        {
            _nonWsdlImportErrors = _wsdlImporter.Errors.Count;

            _wsdlImporter.WsdlImportExtensions.Add(new BindingImportTracker());
            _wsdlImporter.WsdlImportExtensions.Add(new HttpBindingTracker());

            InitializationHelper.RemoveUnneededSerializers(_options, serviceDescriptor, _wsdlImporter.WsdlImportExtensions);
            InitializationHelper.ConfigureSerializers(_options, _codeCompileUnit, _wsdlImporter);

            try
            {
                _codegenExtension.WsdlImporting(_wsdlImporter);
            }
            catch (Exception e)
            {
                ToolConsole.WriteError(e);
            }
        }
示例#9
0
文件: Program.cs 项目: JnRMnT/jmovies
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{EnvironmentUtilities.GetEnvironmentName()}.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables()
                          .AddCommandLine(args);

            var config = builder.Build();
            BaseJobConfiguration configuration       = config.Get <BaseJobConfiguration>();
            CustomConfiguration  customConfiguration = config.Get <CustomConfiguration>();

            InitializationHelper.Initialize(configuration);
            var services = new ServiceCollection();

            services.AddOptions();
            services.Configure <CustomConfiguration>(config.GetSection(ConfigurationConstants.CustomConfigurationSectionName));
            services.AddSingleton <IElasticSearchConnectionProvider, ElasticSearchConnector>();
            var serviceProvider = services.BuildServiceProvider();

            IElasticSearchConnectionProvider elasticSearchProvider = serviceProvider.GetRequiredService <IElasticSearchConnectionProvider>();
            ElasticClient elasticClient = elasticSearchProvider.GetElasticClient(ElasticSearchIndexNameConstants.Productions);

            using (JMoviesEntities entities = new JMoviesEntities())
            {
                foreach (var production in entities.Production)
                {
                    long productionID = production.ID;
                    if (production is JMovies.IMDb.Entities.Movies.Movie)
                    {
                        using (JMoviesEntities innerEntities = new JMoviesEntities())
                        {
                            JMovies.IMDb.Entities.Movies.Movie movie = production as JMovies.IMDb.Entities.Movies.Movie;
                            movie.AKAs     = innerEntities.AKA.Where(e => e.ProductionID == productionID).ToArray();
                            movie.Genres   = innerEntities.Genre.Where(e => e.ProductionID == productionID).ToArray();
                            movie.Keywords = innerEntities.Keyword.Where(e => e.ProductionID == productionID).ToArray();
                            movie.TagLines = innerEntities.TagLine.Where(e => e.ProductionID == productionID).ToArray();
                        }
                    }
                    elasticClient.IndexDocument(MapProduction(production as IMDb.Entities.Movies.Movie));
                }
            }
        }
示例#10
0
        public void Configuration(IAppBuilder app)
        {
            const string connectionName = "WebKikConnection";
            var          config         = new HttpConfiguration {
                IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always
            };
            var container = config.UseUnity(connectionName);

            WebApiConfig.Register(config, container);
            app.UseWebApi(config);

            config.EnableEnumPrefixFree(true);

            ConfigureJsonSerializer(config);

            InitializationHelper.Initialize(typeof(AutomapperInitializationAttribute).Assembly);

            WebKikDataContext.Initialize(connectionName);

            app.UseSpaRazor("index.cshtml");
        }
 private void UpdatePreviewImage()
 {
     try
     {
         Type                 gameClass     = Program.Manager.GameClasses[game.GameAttribute.GameName];
         GameAttribute        gameAttribute = game.GameAttribute;
         ConstructorInfo      ci            = gameClass.GetConstructor(new Type[] { });
         Game                 newgame;
         InitializationHelper initHelper = PreviewHelper;
         newgame = (Game)ci.Invoke(null);
         FieldInfo environmentField = newgame.GetType().GetField("Environment");
         if (environmentField != null)
         {
             environmentField.SetValue(newgame, new Compiler.Environment(Program.Manager.Environment));
         }
         newgame.Initialize(gameAttribute, null, initHelper);
         BoardPresentation presentation = PresentationFactory.CreatePresentation(newgame, true);
         Bitmap            b            = presentation.Render();
         if (b != null)
         {
             Bitmap scaled = null;
             double xscale = (double)pictSubGamePreview.Size.Width / (double)b.Width;
             xscale = xscale > 1.0 ? 1.0 : xscale;
             double yscale = (double)pictSubGamePreview.Size.Height / (double)b.Height;
             yscale = yscale > 1.0 ? 1.0 : yscale;
             double scale = xscale > yscale ? yscale : xscale;
             scaled = new Bitmap(b, (int)(b.Width * scale), (int)(b.Height * scale));
             pictSubGamePreview.Image = scaled;
         }
     }
     catch (Exception ex)
     {
         ExceptionForm form = new ExceptionForm(ex, game);
         form.ShowDialog();
     }
 }
示例#12
0
文件: Program.cs 项目: JnRMnT/jmovies
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{EnvironmentUtilities.GetEnvironmentName()}.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables()
                          .AddCommandLine(args);

            BaseJobConfiguration configuration = builder.Build().Get <BaseJobConfiguration>();

            InitializationHelper.Initialize(configuration);
            var services = new ServiceCollection();

            services.AddOptions();
            var serviceProvider = services.BuildServiceProvider();

            if (configuration.MaxRecordCount == default(int))
            {
                configuration.MaxRecordCount = ConfigurationConstants.PersisterRecordCountPerRun;
            }

            using (JMoviesEntities entities = new JMoviesEntities())
            {
                IIMDbDataProvider imdbDataProvider = new IMDbScraperDataProvider();
                if (configuration.StartRecordID == default(long) || configuration.WorkingType == PersisterWorkingTypeEnum.UpdateInternalData)
                {
                    configuration.StartRecordID = PersisterHelper.DetermineTheStartID(EntityType, DataSource, configuration.WorkingType, configuration.StartRecordID, entities);
                }
                long dataID = configuration.StartRecordID;
                for (int i = 0; i < configuration.MaxRecordCount; i++)
                {
                    if (i != 0)
                    {
                        dataID = PersisterHelper.GetNextID(EntityType, DataSource, configuration.WorkingType, entities, dataID);
                    }

                    if (dataID != default(long))
                    {
                        if (dataID > ConfigurationConstants.IMDBMaxID)
                        {
                            dataID = 1;
                        }

                        try
                        {
                            Production production = imdbDataProvider.GetProduction(dataID, ProductionDataFetchSettings);
                            DbContextOptionsBuilder <JMoviesEntities> dbContextOptionsBuilder = new DbContextOptionsBuilder <JMoviesEntities>();
                            dbContextOptionsBuilder.UseLazyLoadingProxies(true);
                            using (JMoviesEntities productionPersistanceEntities = new JMoviesEntities(dbContextOptionsBuilder.Options))
                            {
                                ProductionPersistanceManager.Persist(productionPersistanceEntities, production);
                            }
                            PersisterHelper.SavePersisterHistory(entities, dataID, DataSource, EntityType, string.Empty);
                        }
                        catch (Exception exception)
                        {
                            PersisterHelper.SavePersisterHistory(entities, dataID, DataSource, EntityType, exception.ToString());
                        }
                        entities.SaveChanges();
                    }
                }
            }
        }
示例#13
0
        public static void SetConfigWebserviceUrl(InitializationHelper helper)
        {
            TI.trace(section, "SetConfigWebserviceUrl");

            helper.SetConfigWebserviceUrl(WSUrl);
        }
示例#14
0
 public static void AppIdSetup(InitializationHelper helper)
 {
     TI.trace(section, "AppIdSetup");
     helper.AppIdSetup();
 }
示例#15
0
        public static CostCentreLoginResponse InitialLogin(InitializationHelper helper)
        {
            TI.trace(section, "InitialLogin");

            return helper.InitialLogin(InitialLoginUserName, InitialLoginPassword, UserType.WarehouseManager);
        }
示例#16
0
 /// <summary>
 /// Creates input directory if doesn't exist.
 /// </summary>
 public void Initialize() => InitializationHelper.Initialize(_fileSystem);
示例#17
0
        public static void CanSync(InitializationHelper helper)
        {
            TI.trace(section, "CanSync");

            helper.CanSync();
        }
示例#18
0
 public static async Task<bool> SyncMasterData(InitializationHelper helper)
 {
     TI.trace(section, "Sync master data");
     bool r = await helper.SyncMasterData();
     return r;
 }
示例#19
0
 /// <summary>
 /// Main entrypoint of the application.
 /// </summary>
 /// <param name="args">The argumentss.</param>
 static void Main(string[] args)
 {
     InitializationHelper.Initialize();
 }