Esempio n. 1
0
 public UnitOfWork(IDbContextFactory <APPDbContext> dbContextFactory, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
 {
     _dbContext                        = dbContextFactory.GetContext();
     UserRepository                    = new UserRepository(_dbContext);
     AccountsRepository                = new AccountsRepository(_dbContext);
     Account_RolesRepository           = new Account_RolesRepository(_dbContext);
     RolesRepository                   = new RolesRepository(_dbContext);
     PermissionsRepository             = new PermissionsRepository(_dbContext);
     EmployeesRepository               = new EmployeesRepository(_dbContext);
     MenusRepository                   = new MenusRepository(_dbContext);
     JobPositionsRepository            = new JobPositionsRepository(_dbContext);
     MotorManufactureRepository        = new MotorManufactureRepository(_dbContext);
     MotorTypesRepository              = new MotorTypesRepository(_dbContext);
     ServicesRepository                = new ServicesRepository(_dbContext);
     MotorLiftsRepository              = new MotorLiftsRepository(_dbContext);
     SupplierRepository                = new SupplierRepository(_dbContext);
     CustomersRepository               = new CustomersRepository(_dbContext);
     AccessoriesRepository             = new AccessoriesRepository(_dbContext);
     TemporaryBill_ServiceRepository   = new TemporaryBill_ServiceRepository(_dbContext);
     TemporaryBillRepository           = new TemporaryBillRepository(_dbContext);
     TemporaryBill_AccesaryRepository  = new TemporaryBill_AccesaryRepository(_dbContext);
     ImportReceiptRepository           = new ImportReceiptRepository(_dbContext);
     ImportReceipt_AccessoryRepository = new ImportReceipt_AccessoryRepository(_dbContext);
     ServicePriceHistoryRepository     = new ServicePriceHistoryRepository(_dbContext);
     AccessoryPriceHistoryRepository   = new AccessoryPriceHistoryRepository(_dbContext);
 }
Esempio n. 2
0
        /// <summary>
        /// More info: http://www.dotnettips.info/post/2507
        /// </summary>
        public static void SetAuditableEntityPropertyValues
            (this Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker changeTracker,
            Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
        {
            var httpContext = httpContextAccessor?.HttpContext;
            var userAgent   = httpContext?.Request?.Headers["User-Agent"].ToString();
            var userIp      = httpContext?.Connection?.RemoteIpAddress?.ToString();

            var now = System.DateTimeOffset.UtcNow;
            //var userId = getUserId(httpContext);

            var modifiedEntries = changeTracker.Entries <Models.AuditableEntity.IAuditableEntity>()
                                  .Where(x => x.State == Microsoft.EntityFrameworkCore.EntityState.Modified);

            foreach (var modifiedEntry in modifiedEntries)
            {
                modifiedEntry.Property(ModifiedDateTime).CurrentValue      = now;
                modifiedEntry.Property(ModifiedByBrowserName).CurrentValue = userAgent;
                modifiedEntry.Property(ModifiedByIp).CurrentValue          = userIp;
                //modifiedEntry.Property(ModifiedByUserId).CurrentValue = userId;
            }

            var addedEntries = changeTracker.Entries <Models.AuditableEntity.IAuditableEntity>()
                               .Where(x => x.State == Microsoft.EntityFrameworkCore.EntityState.Added);

            foreach (var addedEntry in addedEntries)
            {
                addedEntry.Property(CreatedDateTime).CurrentValue      = now;
                addedEntry.Property(CreatedByBrowserName).CurrentValue = userAgent;
                addedEntry.Property(CreatedByIp).CurrentValue          = userIp;
                //addedEntry.Property(CreatedByUserId).CurrentValue = userId;
            }
        }
Esempio n. 3
0
 public static string RootPath(Microsoft​.AspNetCore​.Http.IHttpContextAccessor httpContextAccessor)
 {
     return
         ("http://" +
          httpContextAccessor.HttpContext.Request.Host +
          "/");
 }
Esempio n. 4
0
 public UnitOfWork(IDbContextFactory <APPDbContext> dbContextFactory, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
 {
     _dbContext                     = dbContextFactory.GetContext();
     UserRepository                 = new UserRepository(_dbContext);
     MenuRepository                 = new MenuRepository(_dbContext);
     RolesRepository                = new RolesRepository(_dbContext);
     Role_PermissionsRepository     = new Role_PermissionsRepository(_dbContext);
     AccountsRepository             = new AccountsRepository(_dbContext);
     AccountRolesRepository         = new AccountRolesRepository(_dbContext);
     CategoryRepository             = new CategoryRepository(_dbContext);
     Content_CategoriesRepository   = new Content_CategoriesRepository(_dbContext);
     AuthorsRepository              = new AuthorsRepository(_dbContext);
     GroupsRepository               = new GroupsRepository(_dbContext);
     NewsSourcesRepository          = new NewsSourcesRepository(_dbContext);
     TypesRepository                = new TypesRepository(_dbContext);
     ContentTypesRepository         = new ContentTypesRepository(_dbContext);
     Content_GroupsRepository       = new Content_GroupsRepository(_dbContext);
     TitleImagesRepository          = new TitleImagesRepository(_dbContext);
     MediasRepository               = new MediasRepository(_dbContext);
     ContentsRepository             = new ContentsRepository(_dbContext);
     QuanLyDonGiaNhuanButRepository = new QuanLyDonGiaNhuanButRepository(_dbContext);
     TheLoai_HeSoRepository         = new TheLoai_HeSoRepository(_dbContext);
     NhuanButRepository             = new NhuanButRepository(_dbContext);
     ContactRepository              = new ContactRepository(_dbContext);
 }
Esempio n. 5
0
        public ContentGlobalMethodsProvider(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
        {
            _contentByItemId = new GlobalMethod
            {
                Name   = "contentByItemId",
                Method = serviceProvider => (Func <string, ContentItem>)((contentItemId) =>
                {
                    var contentManager = serviceProvider.GetRequiredService <IContentManager>();
                    return(contentManager.GetAsync(contentItemId).GetAwaiter().GetResult());
                })
            };

            _contentByItemIdVersion = new GlobalMethod
            {
                Name   = "contentByItemIdVersion",
                Method = serviceProvider => (Func <string, string, ContentItem>)((contentItemId, version) =>
                {
                    var contentManager = serviceProvider.GetRequiredService <IContentManager>();
                    return(version.ToLower() switch
                    {
                        "published" => contentManager.GetAsync(contentItemId, VersionOptions.Published).GetAwaiter().GetResult(),
                        "latest" => contentManager.GetAsync(contentItemId, VersionOptions.Latest).GetAwaiter().GetResult(),
                        "draft" => contentManager.GetAsync(contentItemId, VersionOptions.Draft).GetAwaiter().GetResult(),
                        "draftrequired" => contentManager.GetAsync(contentItemId, VersionOptions.DraftRequired).GetAwaiter().GetResult(),
                        _ => contentManager.GetAsync(contentItemId).GetAwaiter().GetResult(),
                    });
                })
            };
Esempio n. 6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ILoggerFactory loggerFactory,
                              Domain.Data.ILoggingRepository loggingRepositor,
                              Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor,
                              Domain.Data.IServiceConfigurator serviceConfigurator)
        {
            if (env.IsDevelopment() || env.IsStaging())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseAuthentication();

            loggerFactory.AddProvider(new Services.Logging.LoggerProvider((cat, loglevel) => loglevel >= LogLevel.Warning, loggingRepositor, httpContextAccessor));

            app.UseMvc(routes =>
            {
                routes.MapAreaRoute("admin_route", "Admin", "Admin/{controller}/{action=Index}/{id?}");
                routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
            });

            serviceConfigurator.Migrate();
        }
 public WebCustomizeSession(Microsoft.JSInterop.IJSRuntime jsr
                            , Microsoft.AspNetCore.Http.IHttpContextAccessor hca
                            , Microsoft.AspNetCore.Hosting.IWebHostEnvironment whe)
     : base(jsr, hca)
 {
     _whe = whe;
 }
Esempio n. 8
0
 public static HtmlString IncludeScriptFile(this IHtmlHelper htmlHelper, Microsoft​.AspNetCore​.Http.IHttpContextAccessor hsttpContextAccessor, string fileName)
 {
     return(new HtmlString(
                "<script type=\"text/javascript\" src=\"" +
                StaticClassMethodLibrary.RootPath(hsttpContextAccessor) + "Scripts/" + StaticClassMethodLibrary.ViewsScriptFolder + fileName + "\">" +
                "</script>"
                ));
 }
 public Repository(ApplicationDbContext applicationDbContext,
                   Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor
                   )
 {
     _applicationDbContext = applicationDbContext;
     _userId = String.IsNullOrEmpty(httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value)
         ? 0
         : Int32.Parse(httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value);
 }
        public NHibernateHelper(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
        {
            _sessionFactory = Fluently.Configure()
                              .Database(MsSqlConfiguration.MsSql2012.ConnectionString(@"Server=.;Database=PlanetRepo;User Id=PlanetRepoUser;Password=123;"))
                              .Mappings(m => m.FluentMappings.AddFromAssemblyOf <NHibernate.Cfg.Mappings>())
                              .Mappings(m => m.FluentMappings.AddFromAssemblyOf <PlanetRepo.Program>())
                              .BuildSessionFactory();

            this.context = httpContextAccessor.HttpContext;
        }
Esempio n. 11
0
 public CustomSignInManager(
     UserManager <Volo.Abp.Identity.IdentityUser> userManager,
     Microsoft.AspNetCore.Http.IHttpContextAccessor contextAccessor,
     IUserClaimsPrincipalFactory <Volo.Abp.Identity.IdentityUser> claimsFactory,
     Microsoft.Extensions.Options.IOptions <IdentityOptions> optionsAccessor,
     Microsoft.Extensions.Logging.ILogger <SignInManager <Volo.Abp.Identity.IdentityUser> > logger,
     Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider schemes,
     IUserConfirmation <Volo.Abp.Identity.IdentityUser> confirmation) : base(userManager, contextAccessor, claimsFactory, optionsAccessor, logger, schemes, confirmation)
 {
 }
Esempio n. 12
0
 public ReactModel(
     Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor,
     Microsoft.Extensions.Logging.ILogger <ReactModel> logger,
     Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
     System.Net.Http.IHttpClientFactory httpClientFactory,
     Microsoft.Extensions.Options.IOptions <Web.App.Hypernova.HypernovaSettings> options
     )
 {
     BaseUrl         = $"{httpContextAccessor.HttpContext.Request.Scheme}://{httpContextAccessor.HttpContext.Request.Host}";
     hypernovaClient = new Web.App.Hypernova.HypernovaClient(logger, env, httpClientFactory, options, BaseUrl);
 }
Esempio n. 13
0
        public UnitOfWork(IDbContextFactory <KhaoSatDbContext> dbContextFactory, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
        {
            _dbContext = dbContextFactory.GetContext();

            UserAnswersRepository = new UserAnswersRepository(_dbContext);
            UserRepository        = new UserRepository(_dbContext);
            UserSurveysRepository = new UserSurveysRepository(_dbContext);
            SurveysRepository     = new SurveyRepository(_dbContext);
            AnswerRepository      = new AnswerRepository(_dbContext);
            QuestionsRepository   = new QuestionsRepository(_dbContext);
        }
Esempio n. 14
0
        public Logger(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor) : base()
        {
            //if (httpContextAccessor == null)
            //{
            //	throw new System.ArgumentNullException(nameof(httpContextAccessor));
            //}

            //HttpContextAccessor = httpContextAccessor;

            HttpContextAccessor =
                httpContextAccessor ?? throw new System.ArgumentNullException(nameof(httpContextAccessor));
        }
Esempio n. 15
0
 public UserController(
     Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor,
     UserManager <TechnicianModel> userManager,
     SignInManager <TechnicianModel> signInManager
     ) : base
     (
         httpContextAccessor,
         userManager,
         signInManager
     )
 {
 }
Esempio n. 16
0
 public UnitOfWork(IDbContextFactory <DoAnDbContext> dbContextFactory, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
 {//2
     _dbContext = dbContextFactory.GetContext();
     DanhSachPhongRepository   = new DanhSachPhongRepository(_dbContext);
     DuThuyenRepository        = new DuThuyenRepository(_dbContext);
     HangPhongRepository       = new HangPhongRepository(_dbContext);
     KhachHangRepository       = new KhachHangRepository(_dbContext);
     KieuGiuongRepository      = new KieuGiuongRepository(_dbContext);
     NhomPhongRepository       = new NhomPhongRepository(_dbContext);
     PhieuDatChiTietRepository = new PhieuDatChiTietRepository(_dbContext);
     PhieuDatPhongRepository   = new PhieuDatPhongRepository(_dbContext);
 }
 public BraksnListPartDriver(
     ISession session,
     IContentDefinitionManager contentDefinitionManager,
     IUpdateModelAccessor updateModelAccessor,
     IContainerService containerService,
     HttpContext httpContext
     ) : base(contentDefinitionManager, containerService, updateModelAccessor)
 {
     _session = session;
     _contentDefinitionManager = contentDefinitionManager;
     _updateModelAccessor      = updateModelAccessor;
     _httpContext = httpContext;
 }
Esempio n. 18
0
 public ContentController(
     IContentManager contentManager,
     IContentItemDisplayManager contentDisplay,
     ISession session,
     IUpdateModelAccessor updateModelAccessor,
     IAuthorizationService authorizationService,
     IHttpContextAccessor httpContextAccessor)
 {
     _contentManager       = contentManager;
     _contentDisplay       = contentDisplay;
     _session              = session;
     _updateModelAccessor  = updateModelAccessor;
     _authorizationService = authorizationService;
     _httpContextAccessor  = httpContextAccessor;
 }
Esempio n. 19
0
        public PonudaController(ISession session, ILoggerFactory loggerFactory, Microsoft.AspNetCore.Http.IHttpContextAccessor contextAccessor, IStringLocalizerFactory factory)
        {
            _logger              = loggerFactory.CreateLogger <PonudaController>();
            _session             = session;
            _httpContextAccessor = contextAccessor;

            var korisnik = _session.QueryOver <Korisnik>()
                           .Where(x => x.KorisnickoIme == contextAccessor.HttpContext.User.Identity.Name)
                           .SingleOrDefault <Korisnik>();

            var type         = typeof(Prevod);
            var assemblyName = new AssemblyName(type.GetTypeInfo().Assembly.FullName);

            _localizer = factory.Create("Prevod" + korisnik.Lang, assemblyName.Name);
        }
Esempio n. 20
0
 public AccountController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailSender emailSender,
     ILogger <AccountController> logger,
     Microsoft.AspNetCore.Http.IHttpContextAccessor contextAccessor,
     ApplicationDbContext context)
 {
     _userManager     = userManager;
     _signInManager   = signInManager;
     _emailSender     = emailSender;
     _logger          = logger;
     _contextAccessor = contextAccessor;
     _context         = context;
 }
Esempio n. 21
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="accessor"></param>
 public CurrentUser(Microsoft.AspNetCore.Http.IHttpContextAccessor accessor)
 {
     if (accessor.HttpContext != null)
     {
         string userIdConfig = Configs.AppSettings.IdentityServer.Enable ? ClaimAttributes.IdentityServerUserId : ClaimAttributes.UserId;
         var    _user        = accessor.HttpContext.User;
         var    userId       = _user.FindFirst(userIdConfig)?.Value;
         if (!string.IsNullOrEmpty(userId))
         {
             Id       = userId;
             Name     = _user.FindFirst(ClaimAttributes.UserName)?.Value;
             NickName = _user.FindFirst(ClaimAttributes.UserNickName)?.Value;
         }
     }
 }
 public LocalizationSetContentPickerAdminController(
     IContentDefinitionManager contentDefinitionManager,
     IContentLocalizationManager contentLocalizationManager,
     IContentManager contentManager,
     ISession session,
     IAuthorizationService authorizationService,
     IHttpContextAccessor httpContextAccessor)
 {
     _contentDefinitionManager   = contentDefinitionManager;
     _contentLocalizationManager = contentLocalizationManager;
     _contentManager             = contentManager;
     _session = session;
     _authorizationService = authorizationService;
     _httpContextAccessor  = httpContextAccessor;
 }
Esempio n. 23
0
        // services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
        // services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();

        public MyImageTagHelper(
            Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment,
            Microsoft.Extensions.Caching.Memory.IMemoryCache cache,
            Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor,
            Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor actionContextAccessor,
            // For base constructor
            System.Text.Encodings.Web.HtmlEncoder htmlEncoder,
            Microsoft.AspNetCore.Mvc.Routing.IUrlHelperFactory urlHelperFactory
            )
            : base(urlHelperFactory, htmlEncoder)
        {
            this.HostingEnvironment = hostingEnvironment;
            this.Cache         = cache;
            this.HttpContext   = httpContextAccessor.HttpContext;
            this.ActionContext = actionContextAccessor.ActionContext;
        }
Esempio n. 24
0
 public DefaultContentLocalizationManager(
     IContentManager contentManager,
     ISession session,
     Microsoft.AspNetCore.Http.IHttpContextAccessor httpContentAccessor,
     ILocalizationService localizationService,
     ILogger <DefaultContentLocalizationManager> logger,
     IEnumerable <IContentLocalizationHandler> handlers,
     Entities.IIdGenerator iidGenerator)
 {
     _contentManager      = contentManager;
     _session             = session;
     _httpContextAccessor = httpContentAccessor;
     _localizationService = localizationService;
     Handlers             = handlers;
     _iidGenerator        = iidGenerator;
     ReversedHandlers     = handlers.Reverse().ToArray();
     _logger = logger;
 }
Esempio n. 25
0
        public NHibernateHelper(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor,
                                IConnections connections)
        {
            this.httpContextAccessor = httpContextAccessor;

            string connectionString = connections.GetDefaultConnectionString();

            FluentConfiguration fluentConfiguration = Fluently.Configure();

            fluentConfiguration = fluentConfiguration.Database(OracleClientConfiguration.Oracle10
                                                               .ConnectionString(connectionString));

            _sessionFactory = fluentConfiguration
                              .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Mappings>())
                              .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Program>())
                              .ExposeConfiguration(x => x.SetProperty("hbm2ddl.keywords", "auto-quote"))
                              .BuildSessionFactory();
        }
Esempio n. 26
0
    public static HtmlString PageBar(this IHtmlHelper htmlHelper, Microsoft​.AspNetCore​.Http.IHttpContextAccessor hsttpContextAccessor, string baseUrl, object pageNumber, object pageCount, string className = "PageBar horizontal", string pageNumberLinkFormat = "{0}")
    {
        string str_items = "";

        for (int i = 1; i <= (int)pageCount; i++)
        {
            if (i != Convert.ToInt32(pageNumber))
            {
                str_items +=
                    string.Format(
                        @"<li>
            <a href = ""{0}"" > {1} </a>
 
          </li>"
                        ,
                        PlainMethods.RootPath(hsttpContextAccessor.HttpContext) + baseUrl + string.Format(pageNumberLinkFormat, i),
                        i);
            }
            else
            {
                str_items +=


                    string.Format(
                        @"<li class=""active"">
       <span>
            {0}
          </span>
        </li>"
                        , i);
            }
        }


        return(new HtmlString(
                   string.Format(
                       @"<ul class=""clearfix {0}"">
    {1}
    </ul>",
                       className,
                       str_items))
               );
    }
Esempio n. 27
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public UnitOfWork(CommonDbContext context,
                          ILogger <UnitOfWork> logger,
                          Microsoft.AspNetCore.Http.IHttpContextAccessor accessor)
        {
            this.context = context;
            this.logger  = logger;

            var identity = accessor.HttpContext.GetClaims();

            if (identity != null)
            {
                userName = identity.Name;
            }
            else
            {
                // Controller を経由せずに DI されると accessor.HttpContext.GetClaims() が null を返却する。よって、ユーザ名を暫定的に設定する。
                userName = "******";
            }
            requestId = accessor.HttpContext?.TraceIdentifier;
        }
Esempio n. 28
0
 public ContentGlobalMethodsProvider(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
 {
     _contentByItemId = new GlobalMethod
     {
         Name   = "contentByItemId",
         Method = serviceProvider => (Func <string, ContentItem>)((contentItemId) =>
         {
             var contentManager = serviceProvider.GetRequiredService <IContentManager>();
             return(contentManager.GetAsync(contentItemId).GetAwaiter().GetResult());
         }
                                                                  )
     };
     _ownContentByType = new GlobalMethod
     {
         Name   = "ownContentByType",
         Method = serviceProvider => (Func <string, IEnumerable <ContentItem> >)((type) =>
         {
             var session = serviceProvider.GetRequiredService <ISession>();
             var owner   = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
             return(session.Query <ContentItem, ContentItemIndex>(c => c.Owner == owner && c.ContentType == type && c.Published == true).ListAsync().GetAwaiter().GetResult());
         }
                                                                                 )
     };
 }
Esempio n. 29
0
 public static void Configure(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
 {
     _httpContextAccessor = httpContextAccessor;
 }
Esempio n. 30
0
 public HttpContextFactory(Microsoft.Extensions.ObjectPool.ObjectPoolProvider poolProvider, Microsoft.Extensions.Options.IOptions <Microsoft.AspNetCore.Http.Features.FormOptions> formOptions, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
 {
 }