示例#1
0
        private void Button7_Click(object sender, EventArgs e)
        {
            DapperPlusManager.AddLicense("974;700-IRDEVELOPERS.COM", "FB90FB42600315DC035C24AADC7A6495D213");
            DapperPlusManager.Entity <TableLog>().Table("TableLog");

            string oracleStr       = "User Id=smart;Password=smart;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=121.40.101.29)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))";
            string oracleDevartStr = "User Id=smart;Password=smart;Server=121.40.101.29;Direct=True;Sid=orcl;";

//            using (var connection = new SqlConnection("Data Source=121.40.101.29;Initial Catalog=scm_main;Integrated Security=False;Password=sa123;Persist Security Info=True;User ID=sa"))
//            using (var connection = new OracleConnection("User Id=smart;Password=smart;Server=121.40.101.29;Direct=True;Sid=orcl;"))
            using (var connection = new OracleConnection(oracleStr))
            {
                var tableLog = new TableLog();
                tableLog.tableName  = "aaa";
                tableLog.createTime = DateTime.Now;

                connection.BulkInsert(new List <bd_TableLog>()
                {
                    new bd_TableLog()
                    {
                        tableName = "ExampleBulkInsert", createTime = DateTime.Now
                    }
                });
            }


//            using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
//            {
//                var customer = connection.Query<Customer>("Select * FROM CUSTOMERS WHERE CustomerName = 'ExampleBulkInsert'").ToList();
//
//                Console.WriteLine("Row Insert : " + customer.Count());
//
//                FiddleHelper.WriteTable(connection.Query<Customer>("Select TOP 10 * FROM CUSTOMERS WHERE CustomerName = 'ExampleBulkInsert'").ToList());
//            }
        }
        public void Init()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();
            var        connectionString = config["ConnectionStrings:DwapiConnectionDev"];
            var        liveSync         = config["LiveSync"];
            Uri        endPointA        = new Uri(liveSync); // this is the endpoint HttpClient will hit
            HttpClient httpClient       = new HttpClient()
            {
                BaseAddress = endPointA,
            };

            DapperPlusManager.AddLicense("1755;700-ThePalladiumGroup", "2073303b-0cfc-fbb9-d45f-1723bb282a3c");
            if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
            {
                throw new Exception(licenseErrorMessage);
            }

            _serviceProvider = new ServiceCollection()
                               .AddDbContext <MnchContext>(o => o.UseSqlServer(connectionString))

                               .AddScoped <IDocketRepository, DocketRepository>()
                               .AddScoped <IMasterFacilityRepository, MasterFacilityRepository>()

                               .AddScoped <IFacilityRepository, FacilityRepository>()
                               .AddScoped <IManifestRepository, ManifestRepository>()
                               .AddScoped <IPatientMnchRepository, PatientMnchRepository>()
                               .AddScoped <IAncVisitRepository, AncVisitRepository>()

                               .AddScoped <IFacilityRepository, FacilityRepository>()
                               .AddScoped <IMasterFacilityRepository, MasterFacilityRepository>()
                               .AddScoped <IPatientMnchRepository, PatientMnchRepository>()
                               .AddScoped <IManifestRepository, ManifestRepository>()


                               .AddScoped <IAncVisitRepository, AncVisitRepository>()


                               .AddScoped <IMnchService, MnchService>()
                               .AddScoped <ILiveSyncService, LiveSyncService>()
                               .AddScoped <IManifestService, ManifestService>()
                               .AddSingleton <HttpClient>(httpClient)
                               .AddMediatR(typeof(ValidateFacilityHandler))
                               .BuildServiceProvider();
            _context = _serviceProvider.GetService <MnchContext>();
            _context.Database.EnsureDeleted();
            _context.Database.Migrate();
            _context.MasterFacilities.AddRange(TestDataFactory.TestMasterFacilities());
            var facilities = TestDataFactory.TestFacilities();

            _context.Facilities.AddRange(facilities);
            _context.SaveChanges();
            _context.MnchPatients.AddRange(TestDataFactory.TestClients(1, facilities.First(x => x.SiteCode == 1).Id));
            _context.MnchPatients.AddRange(TestDataFactory.TestClients(2, facilities.First(x => x.SiteCode == 2).Id));
            _context.SaveChanges();

            //1,
        }
示例#3
0
 public void Init()
 {
     DapperPlusManager.AddLicense("1755;701-ThePalladiumGroup", "9005d618-3965-8877-97a5-7a27cbb21c8f");
     if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
     {
         throw new Exception(licenseErrorMessage);
     }
 }
示例#4
0
 private void RegisterLicence()
 {
     DapperPlusManager.AddLicense("1755;700-ThePalladiumGroup", "2073303b-0cfc-fbb9-d45f-1723bb282a3c");
     if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
     {
         throw new Exception(licenseErrorMessage);
     }
 }
示例#5
0
 private void RegisterLicence()
 {
     DapperPlusManager.AddLicense("1755;700-ThePalladiumGroup", "218460a6-02d0-c26b-9add-e6b8d13ccbf4");
     if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
     {
         throw new Exception(licenseErrorMessage);
     }
 }
示例#6
0
        public void Setup()
        {
            try
            {
                string bulkConfigName = @"1755;701-ThePalladiumGroup";
                string bulkConfigCode = @"9005d618-3965-8877-97a5-7a27cbb21c8f";

                DapperPlusManager.AddLicense(bulkConfigName, bulkConfigCode);
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
            catch (Exception e)
            {
                Log.Fatal($"{e}");
                throw;
            }
        }
示例#7
0
        private void RegisterLicence()
        {
            if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DAPPER_LICENSENAME")))
            {
                DapperPlusManager.AddLicense(Environment.GetEnvironmentVariable("DAPPER_LICENSENAME"),
                                             Environment.GetEnvironmentVariable("DAPPER_LICENSEKEY"));
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
                return;
            }

            if (!string.IsNullOrWhiteSpace(Configuration["DapperPlusManager:licenseName"]))
            {
                DapperPlusManager.AddLicense(Configuration["DapperPlusManager:licenseName"],
                                             Configuration["DapperPlusManager:licenseKey"]);
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
        }
示例#8
0
文件: Startup.cs 项目: mgitonga/dwapi
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
        {
            //ServiceProvider = serviceProvider;
            app.UseResponseCompression();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(
                builder => builder.AllowAnyOrigin()
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials())
            .UseStaticFiles()
            .UseWebSockets();

            app.Use(async(context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404 &&
                    !Path.HasExtension(context.Request.Path.Value) &&
                    !context.Request.Path.Value.StartsWith("/api/"))
                {
                    context.Request.Path = "/index.html";
                    await next();
                }
            });

            app.UseMvcWithDefaultRoute();
            app.UseDefaultFiles();

            app.UseStaticFiles()
            .UseSwaggerUi();

            var hfServerOptions = new BackgroundJobServerOptions()
            {
                ServerName  = $"dwapi",
                WorkerCount = Environment.ProcessorCount * 5,
                Queues      = new string[] { "mpi", "default" }
            };

            app.UseHangfireDashboard();
            app.UseHangfireServer(hfServerOptions);
            GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute()
            {
                Attempts = 3
            });
            Log.Debug(@"initializing Database...");

            EnsureMigrationOfContext <SettingsContext>(serviceProvider);
            EnsureMigrationOfContext <ExtractsContext>(serviceProvider);



            app.UseSignalR(
                routes =>
            {
                routes.MapHub <ExtractActivity>($"/{nameof(ExtractActivity).ToLower()}");
                routes.MapHub <CbsActivity>($"/{nameof(CbsActivity).ToLower()}");
                routes.MapHub <HtsActivity>($"/{nameof(HtsActivity).ToLower()}");
                routes.MapHub <DwhSendActivity>($"/{nameof(DwhSendActivity).ToLower()}");
                routes.MapHub <CbsSendActivity>($"/{nameof(CbsSendActivity).ToLower()}");
                routes.MapHub <HtsSendActivity>($"/{nameof(HtsSendActivity).ToLower()}");
            }
                );


            Mapper.Initialize(cfg =>
            {
                cfg.AddDataReaderMapping();
                cfg.AddProfile <TempExtractProfile>();
                cfg.AddProfile <TempMasterPatientIndexProfile>();
                cfg.AddProfile <EmrProfiles>();
                cfg.AddProfile <TempHtsExtractProfile>();
            }
                              );

            DomainEvents.Init();
            try
            {
                DapperPlusManager.AddLicense("1755;700-ThePalladiumGroup", "2073303b-0cfc-fbb9-d45f-1723bb282a3c");
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
            catch (Exception e)
            {
                Log.Debug($"{e}");
                throw;
            }

            Log.Debug(@"initializing Database [Complete]");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug
                (@"

                                          _____                      _
                                         |  __ \                    (_)
                                         | |  | |_      ____ _ _ __  _
                                         | |  | \ \ /\ / / _` | '_ \| |
                                         | |__| |\ V  V / (_| | |_) | |
                                         |_____/  \_/\_/ \__,_| .__/|_|
                                                              | |
                                                              |_|
");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug("Dwapi started !");
        }
示例#9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // app.UseHsts();
            }

            // app.UseHttpsRedirection();
            app.UseMvc();

            EnsureMigrationOfContext <HtsContext>();
            Mapper.Initialize(cfg =>
            {
                cfg.AddDataReaderMapping();
            }
                              );

            #region HangFire
            try
            {
                app.UseHangfireDashboard();
                app.UseHangfireServer();
            }
            catch (Exception e)
            {
                Log.Fatal(e, "Hangfire is down !");
            }
            #endregion

            try
            {
                DapperPlusManager.AddLicense("1755;700-ThePalladiumGroup", "2073303b-0cfc-fbb9-d45f-1723bb282a3c");
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
            catch (Exception e)
            {
                Log.Debug($"{e}");
                throw;
            }

            Log.Debug(@"initializing Database [Complete]");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug(@"

                        ________                        .__    _________                __                .__
                        \______ \__  _  _______  ______ |__|   \_   ___ \  ____   _____/  |_____________  |  |
                         |    |  \ \/ \/ /\__  \ \____ \|  |   /    \  \/_/ __ \ /    \   __\_  __ \__  \ |  |
                         |    `   \     /  / __ \|  |_> >  |   \     \___\  ___/|   |  \  |  |  | \// __ \|  |__
                        /_______  /\/\_/  (____  /   __/|__| /\ \______  /\___  >___|  /__|  |__|  (____  /____/
                                \/             \/|__|        \/        \/     \/     \/                 \/

            ");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug("Dwapi Central started !");
        }
示例#10
0
        static void Main(string[] args)
        {
            bool hapiOffline     = true;
            var  environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

            System.AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Console()
                         .WriteTo.RollingFile("logs/hapisync-{Date}.txt")
                         .CreateLogger();

            Log.Debug("initializing Sync v[1.0.1.0] ...");

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{environmentName}.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();

            IConfigurationRoot configuration = builder.Build();

            var hapiendpoint = configuration["endpoints:hapi"];

            _startup = new SyncStartup(hapiendpoint);

            Log.Debug($"connecting to LiveHAPI on [{hapiendpoint}]");
            while (hapiOffline)
            {
                try
                {
                    HapiSettingsView = _startup.LoadSettings().Result;
                    if (null != HapiSettingsView)
                    {
                        Log.Debug($"LiveHAPI CONNECTED");
                        Log.Debug($"verifying LiveHAPI settings...");
                        if (HapiSettingsView.IsVerifed)
                        {
                            Log.Debug($"LiveHAPI settings [OK]");
                            Log.Debug($"starting sync...");
                            hapiOffline = false;
                        }
                        else
                        {
                            Log.Error($"invalid LiveHAPI settings ! please open {hapiendpoint} and verify and save all settings");
                            Log.Error($"Sync will retry in 30 secs...");
                            Thread.Sleep(30000);
                        }
                    }
                    else
                    {
                        Log.Error($"LiveHAPI connection FAILED");
                        Log.Error($"Sync will retry in 30 secs...");
                        Thread.Sleep(30000);
                    }
                }
                catch (Exception e)
                {
                    Log.Fatal(new string('*', 50));
                    Log.Fatal(e, "Sync Requires LiveHAPI to be online!");
                    Log.Fatal(new string('*', 50));
                }
            }

            var endpoint = HapiSettingsView.Url;
            //var endpoint = configuration["endpoints:iqcare"];
            var connectionString = HapiSettingsView.Connection;
            //var connectionString = configuration.GetConnectionString("hAPIConnection");
            var syncConfigInterval = configuration["syncInterval:config"];
            var syncClientInterval = configuration["syncInterval:clients"];
            var bulkConfigName     = configuration["bulkConfig:name"];
            var bulkConfigCode     = configuration["bulkConfig:code"];

            Log.Debug($"configured endpoint");
            Log.Debug(new string('-', 40));
            Log.Debug($"    {endpoint}");
            Log.Debug(new string('-', 40));
            Log.Debug($"configured connection");
            Log.Debug(new string('-', 40));
            Log.Debug($"    {connectionString}");
            Log.Debug(new string('-', 40));

            try
            {
                DapperPlusManager.AddLicense(bulkConfigName, bulkConfigCode);
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
            catch (Exception e)
            {
                Log.Fatal($"{e}");
                throw;
            }

            var allServices = new ServiceCollection()

                              .AddTransient <IRestClient>(s => new RestClient(endpoint))
                              .AddDbContext <LiveHAPIContext>(o => o.UseSqlServer(connectionString))

                              .AddTransient <LiveHAPIContext>()
                              .AddTransient <IUserRepository, UserRepository>()
                              .AddTransient <IPracticeRepository, PracticeRepository>()
                              .AddTransient <IPersonRepository, PersonRepository>()
                              .AddTransient <ISubscriberTranslationRepository, SubscriberTranslationRepository>()
                              .AddTransient <IClientRepository, ClientRepository>()
                              .AddTransient <IClientRelationshipRepository, ClientRelationshipRepository>()

                              .AddTransient <IClientStageRepository, ClientStageRepository>()
                              .AddTransient <IClientStageRelationshipRepository, ClientStageRelationshipRepository>()
                              .AddTransient <IClientPretestStageRepository, ClientPretestStageRepository>()
                              .AddTransient <IContactsEncounterRepository, ContactsEncounterRepository>()
                              .AddTransient <ISubscriberSystemRepository, SubscriberSystemRepository>()
                              .AddTransient <IClientEncounterRepository, ClientEncounterRepository>()
                              .AddTransient <IClientEncounterRepository, ClientEncounterRepository>()


                              .AddTransient <IClientUserReader, ClientUserReader>()
                              .AddTransient <IClientFacilityReader, ClientFacilityReader>()
                              .AddTransient <IClientLookupReader, ClientLookupReader>()

                              .AddTransient <IIndexClientMessageWriter, IndexClientMessageWriter>()
                              .AddTransient <IFamilyClientMessageWriter, FamilyClientMessageWriter>()
                              .AddTransient <IPartnerClientMessageWriter, PartnerClientMessageWriter>()
                              .AddTransient <IFamilyWriter, FamilyWriter>()
                              .AddTransient <IPartnerWriter, PartnerWriter>()
                              .AddTransient <IDemographicsWriter, DemographicsWriter>()

                              .AddTransient <IClientStageExtractor, ClientStageExtractor>()
                              .AddTransient <IClientPretestStageExtractor, ClientPretestStageExtractor>()
                              .AddTransient <IClientStageRelationshipExtractor, ClientStageRelationshipExtractor>()

                              .AddTransient <IClientFamilyScreeningStageExtractor, ClientFamilyScreeningStageExtractor>()
                              .AddTransient <IClientFamilyTracingStageExtractor, ClientFamilyTracingStageExtractor>()

                              .AddTransient <IClientPartnerScreeningStageExtractor, ClientPartnerScreeningStageExtractor>()
                              .AddTransient <IClientPartnerTracingStageExtractor, ClientPartnerTracingStageExtractor>()

                              .AddTransient <IClientTracingStageExtractor, ClientTracingStageExtractor>()
                              .AddTransient <IClientTestingStageExtractor, ClientTestingStageExtractor>()
                              .AddTransient <IClientFinalTestStageExtractor, ClientFinalTestStageExtractor>()
                              .AddTransient <IClientLinkageStageExtractor, ClientLinkageStageExtractor>()
                              .AddTransient <IClientReferralStageExtractor, ClientReferralStageExtractor>()


                              .AddTransient <IIndexClientMessageLoader, IndexClientMessageLoader>()
                              .AddTransient <IFamilyClientMessageLoader, FamilyClientMessageLoader>()
                              .AddTransient <IPartnerClientMessageLoader, PartnerClientMessageLoader>()

                              .AddTransient <ISyncUserService, SyncUserService>()
                              .AddTransient <ISyncFacilityService, SyncFacilityService>()
                              .AddTransient <ISyncLookupService, SyncLookupService>()
                              .AddTransient <ISyncUserService, SyncUserService>()

                              .AddTransient <IExtractClientsService, ExtractClientsService>()

                              .AddSingleton <ISyncConfigScheduler>(new SyncConfigScheduler(syncConfigInterval, syncClientInterval));



            if (null != HapiSettingsView && HapiSettingsView.SyncVersion > 0)
            {
                allServices.AddTransient <ISyncClientsService, SyncClientsService>();
            }
            else
            {
                allServices.AddTransient <ISyncClientsService, LegacySyncClientsService>();
                Log.Error(new string('*', 50));
                Log.Error(new string('*', 50));
                Log.Error("YOU ARE USING AN OLD IQCARE PLEASE UPGRADE !!!");
                Log.Error(new string('*', 50));
                Log.Error(new string('*', 50));
            }

            ServiceProvider = allServices.BuildServiceProvider();

            Mapper.Initialize(cfg => { cfg.AddProfile <ClientProfile>(); });

            Log.Debug("loading Sync...");

            try
            {
                SyncConfigScheduler = ServiceProvider.GetService <ISyncConfigScheduler>();
                SyncConfigScheduler.Run();
            }
            catch (Exception e)
            {
                Log.Fatal(e, "Sync startup error");
            }

            Console.ReadLine();
        }
        public void Init()
        {
            DapperPlusManager.AddLicense("1755;701-ThePalladiumGroup", "9005d618-3965-8877-97a5-7a27cbb21c8f");

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <ClientStateInfo, ClientState>();
                cfg.CreateMap <TempClientRelationship, ClientRelationship>();
                cfg.CreateMap <ClientRelationship, TempClientRelationship>();

                cfg.CreateMap <County, CountyInfo>();
                cfg.CreateMap <SubCounty, SubCountyInfo>();

                cfg.CreateMap <Category, CategoryInfo>();
                cfg.CreateMap <Item, ItemInfo>();
                cfg.CreateMap <CategoryItem, CategoryItemInfo>();

                cfg.CreateMap <PracticeType, PracticeTypeInfo>();
                cfg.CreateMap <IdentifierType, IdentifierTypeInfo>();
                cfg.CreateMap <RelationshipType, RelationshipTypeInfo>();
                cfg.CreateMap <KeyPop, KeyPopInfo>();
                cfg.CreateMap <MaritalStatus, MaritalStatusInfo>();
                cfg.CreateMap <ProviderType, ProviderTypeInfo>();
                cfg.CreateMap <Action, ActionInfo>();
                cfg.CreateMap <Condition, ConditionInfo>();
                cfg.CreateMap <ValidatorType, ValidatorTypeInfo>();
                cfg.CreateMap <CategoryItem, CategoryItemInfo>();
                cfg.CreateMap <ConceptType, ConceptTypeInfo>();
                cfg.CreateMap <Validator, ValidatorInfo>();
                cfg.CreateMap <EncounterType, EncounterTypeInfo>();

                cfg.CreateMap <SubscriberCohort, CohortInfo>();

                cfg.CreateMap <Encounter, EncounterInfo>();
                cfg.CreateMap <Obs, ObsInfo>();
                cfg.CreateMap <ObsTestResult, ObsTestResultInfo>();
                cfg.CreateMap <ObsFinalTestResult, ObsFinalTestResultInfo>();
                cfg.CreateMap <ObsTraceResult, ObsTraceResultInfo>();
                cfg.CreateMap <ObsLinkage, ObsLinkageInfo>();
                cfg.CreateMap <ObsMemberScreening, ObsMemberScreeningInfo>();
                cfg.CreateMap <ObsPartnerScreening, ObsPartnerScreeningInfo>();
                cfg.CreateMap <ObsFamilyTraceResult, ObsFamilyTraceResultInfo>();
                cfg.CreateMap <ObsPartnerTraceResult, ObsPartnerTraceResultInfo>();

                cfg.CreateMap <ClientSummaryInfo, ClientSummary>();

                int userId;
                cfg.CreateMap <Core.Model.People.User, UserDTO>()
                .ForMember(x => x.Password, o => o.MapFrom(s => s.DecryptedPassword))
                .ForMember(x => x.UserId, o => o.MapFrom(s => int.TryParse(s.SourceRef, out userId) ? userId : 0));

                cfg.CreateMap <Person, PersonDTO>()
                .ForMember(x => x.FirstName,
                           o => o.MapFrom(s => null != s.Names.FirstOrDefault() ? s.Names.FirstOrDefault().FirstName : ""))
                .ForMember(x => x.MiddleName,
                           o => o.MapFrom(s =>
                                          null != s.Names.FirstOrDefault() ? s.Names.FirstOrDefault().MiddleName : ""))
                .ForMember(x => x.LastName,
                           o => o.MapFrom(s => null != s.Names.FirstOrDefault() ? s.Names.FirstOrDefault().LastName : ""));
                cfg.CreateMap <Provider, ProviderDTO>();
            });
        }
示例#12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
        {
            //ServiceProvider = serviceProvider;

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(
                builder => builder.AllowAnyOrigin()
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials())
            .UseStaticFiles()
            .UseWebSockets();

            app.Use(async(context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404 &&
                    !Path.HasExtension(context.Request.Path.Value) &&
                    !context.Request.Path.Value.StartsWith("/api/"))
                {
                    context.Request.Path = "/index.html";
                    await next();
                }
            });

            app.UseMvcWithDefaultRoute();
            app.UseDefaultFiles();

            app.UseStaticFiles()
            .UseSwaggerUi();


            Log.Debug(@"initializing Database...");

            EnsureMigrationOfContext <SettingsContext>(serviceProvider);
            EnsureMigrationOfContext <ExtractsContext>(serviceProvider);



            app.UseSignalR(
                routes =>
            {
                routes.MapHub <ExtractActivity>($"/{nameof(ExtractActivity).ToLower()}");
                routes.MapHub <CbsActivity>($"/{nameof(CbsActivity).ToLower()}");
                routes.MapHub <DwhSendActivity>($"/{nameof(DwhSendActivity).ToLower()}");
                routes.MapHub <CbsSendActivity>($"/{nameof(CbsSendActivity).ToLower()}");
            }
                );


            Mapper.Initialize(cfg =>
            {
                cfg.AddDataReaderMapping();
                cfg.AddProfile <TempExtractProfile>();
                cfg.AddProfile <TempMasterPatientIndexProfile>();
            }
                              );

            DomainEvents.Init();

            try
            {
                DapperPlusManager.AddLicense("1755;701-ThePalladiumGroup", "9005d618-3965-8877-97a5-7a27cbb21c8f");
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
            catch (Exception e)
            {
                Log.Debug($"{e}");
                throw;
            }

            Log.Debug(@"initializing Database [Complete]");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug
                (@"

                                          _____                      _
                                         |  __ \                    (_)
                                         | |  | |_      ____ _ _ __  _
                                         | |  | \ \ /\ / / _` | '_ \| |
                                         | |__| |\ V  V / (_| | |_) | |
                                         |_____/  \_/\_/ \__,_| .__/|_|
                                                              | |
                                                              |_|
");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug("Dwapi started !");
        }
示例#13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, LiveHAPIContext dbcontext, IServiceProvider serviceProvider)
        {
            bool imHapi = true;

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });



            app.Use(async(context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404 &&
                    !Path.HasExtension(context.Request.Path.Value) &&
                    !context.Request.Path.Value.StartsWith("/api/"))
                {
                    context.Request.Path = "/index.html";
                    await next();
                }
            });

            app.UseMvcWithDefaultRoute();
            app.UseDefaultFiles();
            app.UseStaticFiles();

            Log.Debug($"database initializing...");

            var bulkConfigName = Startup.Configuration["bulkConfig:name"];
            var bulkConfigCode = Startup.Configuration["bulkConfig:code"];

            try
            {
                DapperPlusManager.AddLicense(bulkConfigName, bulkConfigCode);
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
            catch (Exception e)
            {
                Log.Debug($"{e}");
                throw;
            }



            string herror = "";

            try
            {
                EnsureMigrationOfContext <LiveHAPIContext>(serviceProvider);
            }
            catch (Exception e)
            {
                imHapi = false;
                Log.Error(new string('<', 30));
                Log.Error($"{e}");
                Log.Error(new string('>', 30));
            }

            #region HangFire
            try
            {
                app.UseHangfireDashboard("/api/hangfire", new DashboardOptions()
                {
                    Authorization = new[] { new CustomAuthorizeFilter() }
                });

                app.UseHangfireServer();
                GlobalJobFilters.Filters.Add(new ProlongExpirationTimeAttribute());
                GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute()
                {
                    Attempts = 3
                });
            }
            catch (Exception e)
            {
                Log.Fatal(e, "Hangfire is down !");
                imHapi = false;
            }


            #endregion



            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <PracticeDTO, Practice>();
                cfg.CreateMap <ClientStateInfo, ClientState>();
                cfg.CreateMap <TempClientRelationship, ClientRelationship>();
                cfg.CreateMap <ClientRelationship, TempClientRelationship>();

                cfg.CreateMap <County, CountyInfo>();
                cfg.CreateMap <SubCounty, SubCountyInfo>();

                cfg.CreateMap <Category, CategoryInfo>();
                cfg.CreateMap <Item, ItemInfo>();
                cfg.CreateMap <CategoryItem, CategoryItemInfo>();

                cfg.CreateMap <PracticeType, PracticeTypeInfo>();
                cfg.CreateMap <IdentifierType, IdentifierTypeInfo>();
                cfg.CreateMap <RelationshipType, RelationshipTypeInfo>();
                cfg.CreateMap <KeyPop, KeyPopInfo>();
                cfg.CreateMap <MaritalStatus, MaritalStatusInfo>();
                cfg.CreateMap <ProviderType, ProviderTypeInfo>();
                cfg.CreateMap <Action, ActionInfo>();
                cfg.CreateMap <Condition, ConditionInfo>();
                cfg.CreateMap <ValidatorType, ValidatorTypeInfo>();
                cfg.CreateMap <CategoryItem, CategoryItemInfo>();
                cfg.CreateMap <ConceptType, ConceptTypeInfo>();
                cfg.CreateMap <Validator, ValidatorInfo>();
                cfg.CreateMap <EncounterType, EncounterTypeInfo>();

                cfg.CreateMap <SubscriberCohort, CohortInfo>();

                cfg.CreateMap <Encounter, EncounterInfo>();
                cfg.CreateMap <Obs, ObsInfo>();
                cfg.CreateMap <ObsTestResult, ObsTestResultInfo>();
                cfg.CreateMap <ObsFinalTestResult, ObsFinalTestResultInfo>();
                cfg.CreateMap <ObsTraceResult, ObsTraceResultInfo>();
                cfg.CreateMap <ObsLinkage, ObsLinkageInfo>();
                cfg.CreateMap <ObsMemberScreening, ObsMemberScreeningInfo>();
                cfg.CreateMap <ObsPartnerScreening, ObsPartnerScreeningInfo>();
                cfg.CreateMap <ObsFamilyTraceResult, ObsFamilyTraceResultInfo>();
                cfg.CreateMap <ObsPartnerTraceResult, ObsPartnerTraceResultInfo>();

                cfg.CreateMap <ClientSummaryInfo, ClientSummary>();

                int userId;
                cfg.CreateMap <Core.Model.People.User, UserDTO>()
                .ForMember(x => x.Password, o => o.MapFrom(s => s.DecryptedPassword))
                .ForMember(x => x.UserId, o => o.MapFrom(s => int.TryParse(s.SourceRef, out userId) ? userId : 0));

                cfg.CreateMap <Person, PersonDTO>()
                .ForMember(x => x.FirstName,
                           o => o.MapFrom(s => null != s.Names.FirstOrDefault() ? s.Names.FirstOrDefault().FirstName : ""))
                .ForMember(x => x.MiddleName,
                           o => o.MapFrom(s =>
                                          null != s.Names.FirstOrDefault() ? s.Names.FirstOrDefault().MiddleName : ""))
                .ForMember(x => x.LastName,
                           o => o.MapFrom(s => null != s.Names.FirstOrDefault() ? s.Names.FirstOrDefault().LastName : ""));
                cfg.CreateMap <Provider, ProviderDTO>();
            });

            Log.Debug(@"
                            ╔═╗┌─┐┬ ┬┌─┐  ╔╦╗┌─┐┌┐ ┬ ┬  ┌─┐
                            ╠═╣├┤ └┬┘├─┤  ║║║│ │├┴┐│ │  ├┤
                            ╩ ╩└   ┴ ┴ ┴  ╩ ╩└─┘└─┘┴ ┴─┘└─┘
                      ");
            Log.Debug("");
            Log.Debug(@"
                                  _        _    ____ ___
                                 | |__    / \  |  _ \_ _|
                                 | '_ \  / _ \ | |_) | |
                                 | | | |/ ___ \|  __/| |
                                 |_| |_/_/   \_\_|  |___|
                    ");

            if (imHapi)
            {
                Log.Debug($"im hAPI !!! ");
            }
            else
            {
                Log.Error($"im NOT hAPI    >*|*< ");
                Log.Error($"cause: {herror}");
            }
        }
示例#14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
        {
            Stopwatch stopWatch = Stopwatch.StartNew();

            //ServiceProvider = serviceProvider;
            app.UseResponseCompression();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseCors(
                    builder => builder
                    .WithOrigins("http://*****:*****@"initializing Database...");

            EnsureMigrationOfContext <SettingsContext>(serviceProvider);
            EnsureMigrationOfContext <ExtractsContext>(serviceProvider);

            app.UseSignalR(
                routes =>
            {
                routes.MapHub <ExtractActivity>($"/{nameof(ExtractActivity).ToLower()}");
                routes.MapHub <CbsActivity>($"/{nameof(CbsActivity).ToLower()}");
                routes.MapHub <HtsActivity>($"/{nameof(HtsActivity).ToLower()}");
                routes.MapHub <MgsActivity>($"/{nameof(MgsActivity).ToLower()}");
                routes.MapHub <DwhSendActivity>($"/{nameof(DwhSendActivity).ToLower()}");
                routes.MapHub <CbsSendActivity>($"/{nameof(CbsSendActivity).ToLower()}");
                routes.MapHub <HtsSendActivity>($"/{nameof(HtsSendActivity).ToLower()}");
                routes.MapHub <MgsSendActivity>($"/{nameof(MgsSendActivity).ToLower()}");
            }
                );

            Mapper.Initialize(cfg =>
            {
                cfg.AddDataReaderMapping();
                cfg.AddProfile <TempExtractProfile>();
                cfg.AddProfile <TempMasterPatientIndexProfile>();
                cfg.AddProfile <EmrProfiles>();
                cfg.AddProfile <TempHtsExtractProfile>();
                if (null != AppFeature && AppFeature.PKV.IsValid)
                {
                    cfg.AddProfile <MasterPatientIndexProfileResearch>();
                }
                else
                {
                    cfg.AddProfile <MasterPatientIndexProfile>();
                }
                cfg.AddProfile <TempMetricExtractProfile>();
            }
                              );

            DomainEvents.Init();

            stopWatch.Stop();

            Log.Debug(@"initializing Database [Complete]");
            if (null != AppFeature)
            {
                Log.Debug(new string('=', 50));
                Log.Debug("Features");
                Log.Debug($"    {AppFeature.PKV}");
                Log.Debug(new string('=', 50));
            }

            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug
                (@"

                                          _____                      _
                                         |  __ \                    (_)
                                         | |  | |_      ____ _ _ __  _
                                         | |  | \ \ /\ / / _` | '_ \| |
                                         | |__| |\ V  V / (_| | |_) | |
                                         |_____/  \_/\_/ \__,_| .__/|_|
                                                              | |
                                                              |_|
");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");

            if (StartupErrors.Any())
            {
                Log.Error(new string('*', 60));
                Log.Error($"Dwapi startup FAILED, took {stopWatch.ElapsedMilliseconds} ms");
                Log.Error($"Startup Failed Due to the follwing {StartupErrors.Count} ERROR(s)");
                Log.Error(new string('-', 60));
                StartupErrors.ForEach(Log.Error);
                Log.Error(new string('-', 60));
                Log.Error(new string('*', 60));
            }
            else
            {
                Log.Debug($"Dwapi started in {stopWatch.ElapsedMilliseconds} ms");
            }
        }
示例#15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
                app.UseHttpsRedirection();
            }

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            app.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseRouting();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "DWAPI Central MNCH API");
                //c.SupportedSubmitMethods(new Swashbuckle.AspNetCore.SwaggerUI.SubmitMethod[] { });
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapDefaultControllerRoute();
            });

            EnsureMigrationOfContext <MnchContext>(serviceProvider);
            Mapper.Initialize(cfg =>
            {
                cfg.AddDataReaderMapping();
            }
                              );



            #region HangFire
            try
            {
                app.UseHangfireDashboard();

                var options = new BackgroundJobServerOptions {
                    ServerName = "DWAPIMNCHMAIN", WorkerCount = 1
                };
                app.UseHangfireServer(options);
                GlobalJobFilters.Filters.Add(new ProlongExpirationTimeAttribute());
                GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute()
                {
                    Attempts = 3
                });
            }
            catch (Exception e)
            {
                Log.Fatal(e, "Hangfire is down !");
            }
            #endregion

            try
            {
                DapperPlusManager.AddLicense("1755;700-ThePalladiumGroup", "218460a6-02d0-c26b-9add-e6b8d13ccbf4");
                if (!DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
            catch (Exception e)
            {
                Log.Debug($"{e}");
                throw;
            }

            Log.Debug(@"initializing Database [Complete]");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug(@"

                        ________                        .__    _________                __                .__
                        \______ \__  _  _______  ______ |__|   \_   ___ \  ____   _____/  |_____________  |  |
                         |    |  \ \/ \/ /\__  \ \____ \|  |   /    \  \/_/ __ \ /    \   __\_  __ \__  \ |  |
                         |    `   \     /  / __ \|  |_> >  |   \     \___\  ___/|   |  \  |  |  | \// __ \|  |__
                        /_______  /\/\_/  (____  /   __/|__| /\ \______  /\___  >___|  /__|  |__|  (____  /____/
                                \/             \/|__|        \/        \/     \/     \/                 \/

            ");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug("Dwapi Central MNCH started !");
        }
示例#16
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "DWAPI Central HTS API");
                c.SupportedSubmitMethods(new Swashbuckle.AspNetCore.SwaggerUI.SubmitMethod[] { });
            });

            // app.UseHttpsRedirection();
            app.UseMvc();

            EnsureMigrationOfContext <HtsContext>();
            Mapper.Initialize(cfg =>
            {
                cfg.AddDataReaderMapping();
            }
                              );

            #region HangFire
            try
            {
                app.UseHangfireDashboard();

                var options = new BackgroundJobServerOptions {
                    WorkerCount = 1
                };
                app.UseHangfireServer(options);
                GlobalJobFilters.Filters.Add(new ProlongExpirationTimeAttribute());
                GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute()
                {
                    Attempts = 3
                });
            }
            catch (Exception e)
            {
                Log.Fatal(e, "Hangfire is down !");
            }
            #endregion

            try
            {
                DapperPlusManager.AddLicense("1755;700-ThePalladiumGroup", "2073303b-0cfc-fbb9-d45f-1723bb282a3c");
                if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage))
                {
                    throw new Exception(licenseErrorMessage);
                }
            }
            catch (Exception e)
            {
                Log.Debug($"{e}");
                throw;
            }

            Log.Debug(@"initializing Database [Complete]");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug(@"

                        ________                        .__    _________                __                .__
                        \______ \__  _  _______  ______ |__|   \_   ___ \  ____   _____/  |_____________  |  |
                         |    |  \ \/ \/ /\__  \ \____ \|  |   /    \  \/_/ __ \ /    \   __\_  __ \__  \ |  |
                         |    `   \     /  / __ \|  |_> >  |   \     \___\  ___/|   |  \  |  |  | \// __ \|  |__
                        /_______  /\/\_/  (____  /   __/|__| /\ \______  /\___  >___|  /__|  |__|  (____  /____/
                                \/             \/|__|        \/        \/     \/     \/                 \/

            ");
            Log.Debug(
                @"---------------------------------------------------------------------------------------------------");
            Log.Debug("Dwapi Central started !");
        }