Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Data Migration");
            IServiceCollection services = ConfigureServices();

            InfrastructureDependency.RegisterAppCoreMigration(services);
            var serviceProvider = services.BuildServiceProvider();

            Console.WriteLine("Synching user from active directory");
            serviceProvider.GetService <SyncUser>().SyncUserFromActiveDirectory();
            serviceProvider.GetService <UserRole>().AssignRoleToUser();
            bool isImported = false;

            //var appSettingPath = Console.ReadLine();
            var appSettingPath = string.Empty;

            Console.Write("Username: "******"BaseURL");
                    //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseURL + "Scheduler");
                    //request.Method = "GET";
                    ////specify other request properties
                    //var response = (HttpWebResponse)request.GetResponse();


                    isImported = serviceProvider.GetService <Migration>().MigrateData(userName);
                    if (isImported)
                    {
                        Console.WriteLine("Data import executed successfully");
                    }
                }
                else
                {
                    Console.WriteLine("Invalid username");
                }
            }

            serviceProvider.Dispose();
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Пример #2
0
        //public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureRequiredWebInfrastructureServices(services);
            //Register Default Repositories And Services
            InfrastructureDependency.RegisterWebRequiredServices(services);


            services.AddScoped <IHangfireScheduler, HangfireScheduler>();
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <IActionContextAccessor, ActionContextAccessor>();
            services.AddSingleton <IUrlHelperFactory, UrlHelperFactory>();
            services.AddScoped(x => x.GetService <IUrlHelperFactory>()
                               .GetUrlHelper(x.GetService <IActionContextAccessor>().ActionContext));
            services.AddHangfire(x => x.UseSqlServerStorage(Configuration.GetConnectionString("ESSConnectionString")));


            ConfigurationServicesForPFS(services);

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });
            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.Configure <AntiforgeryOptions>(options =>
            {
                options.Cookie.Name = "X-CSRF-TOKEN";
            });

            services.AddAntiforgery(o =>
            {
                o.Cookie.Name = "X-CSRF-TOKEN";
                o.HeaderName  = "X-CSRF-TOKEN";
            });
        }
Пример #3
0
        //register missing services
        private static IServiceCollection ConfigureServices()
        {
            IServiceCollection services = new ServiceCollection();
            var importService           = InfrastructureDependency.RegisterImportServices(services);
            var config = LoadConfiguration();

            services.AddScoped <IRegionService, RegionService>();
            services.AddScoped <IRegionRepository, RegionRepository>();
            services.AddScoped <ICompanyService, CompanyService>();
            services.AddScoped <ICompanyRepository, CompanyRepository>();
            services.AddScoped <ICustomerContactService, CustomerContactService>();
            services.AddScoped <ICustomerContactRepository, CustomerContactRepository>();
            services.AddScoped <ICustomerService, CustomerService>();
            services.AddScoped <ICustomerRepository, CustomerRepository>();
            services.AddScoped <ICustomerContactTypeService, CustomerContactTypeService>();
            services.AddScoped <ICustomerContactTypeRepository, CustomerContactTypeRepository>();
            services.AddScoped <IDatabaseContext>(options =>
            {
                return(new ESSDbContext(config.GetConnectionString("ESSConnectionString")));
            });
            services.AddSingleton <IDatabaseSingletonContext>(options =>
            {
                return(new ESSSingletonDbContext(config.GetConnectionString("ESSConnectionString")));
            });
            services.AddScoped <IActiveDirectoryContext>(options =>
            {
                var ldapServer   = config.GetSection("LDAPConnection")["LDAPServer"];
                var ldapUsername = config.GetSection("LDAPConnection")["LDAPUsername"];
                var ldapPassword = config.GetSection("LDAPConnection")["LDAPPassword"];
                var ldapDomain   = config.GetSection("LDAPConnection")["LDAPDomainController"];
                return(new ActiveDirectoryContext(ldapServer, ldapDomain, ldapUsername, ldapPassword));
            });
            services.AddSingleton(config);
            services.AddTransient <Migration>();
            services.AddTransient <SyncUser>();
            services.AddTransient <UserRole>();
            services.AddMemoryCache();
            return(services);
        }