Exemplo n.º 1
0
 public static IServiceCollection AddDocumentMetadata(this IServiceCollection services, Action <IServiceProvider, IDocumentMetadataService> options)
 {
     services.AddSingleton <IDocumentMetadataService>(sp =>
     {
         var documentMetadataService = new DocumentMetadataService();
         options?.Invoke(sp, documentMetadataService);
         return(documentMetadataService);
     });
     return(services);
 }
Exemplo n.º 2
0
        private static IEnumerable GetDocuments(string version, string configId)
        {
            if (!string.IsNullOrWhiteSpace(configId))
            {
                var documentService = new DocumentMetadataService(configId);
                return(documentService.GetItems());
            }

            return(null);
        }
Exemplo n.º 3
0
        public static IAnmatContext Initialize()
        {
            if (context != null)
            {
                return(context);
            }

            var configuration = new AnmatConfiguration {
                AnmatDataServiceUrl                = ConfigurationManager.AppSettings["AnmatDataServiceUrl"],
                DocumentsPath                      = ConfigurationManager.AppSettings["DocumentsPath"],
                TargetDatabaseName                 = ConfigurationManager.AppSettings["TargetDatabaseName"],
                TargetMedicinesTableName           = ConfigurationManager.AppSettings["TargetMedicinesTableName"],
                TargetActiveComponentsTableName    = ConfigurationManager.AppSettings["TargetActiveComponentsTableName"],
                TargetGroupsTableName              = ConfigurationManager.AppSettings["TargetGroupsTableName"],
                TargetPregnancyComponentsTableName = ConfigurationManager.AppSettings["TargetPregnancyComponentsTableName"],
                ReplaceExistingTargetDatabase      = bool.Parse(ConfigurationManager.AppSettings["ReplaceExistingTargetDatabase"]),
                FullInitialize                     = bool.Parse(ConfigurationManager.AppSettings["FullInitialize"]),
                DefaultCulture                     = ConfigurationManager.AppSettings["DefaultCulture"],
                DefaultTextEncoding                = ConfigurationManager.AppSettings["DefaultTextEncoding"]
            };
            var dataContext        = new AnmatDataContext(configuration);
            var metadataRepository = new SqlRepository <DocumentMetadata>(dataContext, configuration, new DocumentMetadataInitializer(configuration));
            var versionRepository  = new SqlRepository <UpdateVersion>(dataContext, configuration, new UpdateVersionInitializer());
            var jobRepository      = new SqlRepository <DataGenerationJob>(dataContext, configuration);

            var versionService  = new VersionService(versionRepository);
            var metadataService = new DocumentMetadataService(metadataRepository);
            var jobService      = new DataGenerationJobService(jobRepository);

            var documentReader     = new CsvDocumentReader(configuration);
            var documentGenerators = new List <IDocumentGenerator> ();

            documentGenerators.Add(new DocumentGenerator(configuration.TargetGroupsTableName,
                                                         documentReader, jobService, metadataService, configuration));
            documentGenerators.Add(new DocumentGenerator(configuration.TargetPregnancyComponentsTableName,
                                                         documentReader, jobService, metadataService, configuration));
            documentGenerators.Add(new DocumentGenerator(configuration.TargetMedicinesTableName,
                                                         documentReader, jobService, metadataService, configuration));
            documentGenerators.Add(new DocumentGenerator(configuration.TargetActiveComponentsTableName,
                                                         documentReader, jobService, metadataService, configuration));

            var sqlGenerator = new SQLiteGenerator(jobService, versionService, configuration);

            context = new AnmatContext(versionService, jobService, documentReader, documentGenerators, sqlGenerator, configuration);

            return(context);
        }
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            int seq       = 0;
            var renderers = DocumentMetadataService.GetRenderers(NavigationManager.GetCurrentPageName());

            if (renderers != null)
            {
                string tilteFormat = "{0}";
                foreach (var renderer in renderers)
                {
                    builder.AddContent(seq + 0, TabInsideHeadElement);
                    if (renderer.IsTitleFormat)
                    {
                        tilteFormat = renderer.Value;
                    }

                    seq = renderer.Render(builder, seq + 1, tilteFormat);
                }
            }
        }