Example #1
0
 public WebWorkContext(IHttpContextAccessor httpContextAccessor,
                       IGrandAuthenticationService authenticationService,
                       IApiAuthenticationService apiauthenticationService,
                       ICurrencyService currencyService,
                       ICustomerService customerService,
                       IGenericAttributeService genericAttributeService,
                       ILanguageService languageService,
                       IStoreContext storeContext,
                       IStoreMappingService storeMappingService,
                       IVendorService vendorService,
                       IDetectionService detectionService,
                       LocalizationSettings localizationSettings,
                       TaxSettings taxSettings,
                       GrandConfig config)
 {
     _httpContextAccessor      = httpContextAccessor;
     _authenticationService    = authenticationService;
     _apiauthenticationService = apiauthenticationService;
     _currencyService          = currencyService;
     _customerService          = customerService;
     _genericAttributeService  = genericAttributeService;
     _languageService          = languageService;
     _storeContext             = storeContext;
     _storeMappingService      = storeMappingService;
     _vendorService            = vendorService;
     _detectionService         = detectionService;
     _localizationSettings     = localizationSettings;
     _taxSettings = taxSettings;
     _config      = config;
 }
Example #2
0
 public WorkContext(
     IHttpContextAccessor httpContextAccessor,
     IGrandAuthenticationService authenticationService,
     IApiAuthenticationService apiauthenticationService,
     ICurrencyService currencyService,
     ICustomerService customerService,
     IGroupService groupService,
     IUserFieldService userFieldService,
     ILanguageService languageService,
     IStoreHelper storeHelper,
     IAclService aclService,
     IVendorService vendorService,
     IDetectionService detectionService,
     LanguageSettings languageSettings,
     TaxSettings taxSettings,
     AppConfig config)
 {
     _httpContextAccessor      = httpContextAccessor;
     _authenticationService    = authenticationService;
     _apiauthenticationService = apiauthenticationService;
     _currencyService          = currencyService;
     _customerService          = customerService;
     _groupService             = groupService;
     _userFieldService         = userFieldService;
     _languageService          = languageService;
     _storeHelper      = storeHelper;
     _aclService       = aclService;
     _vendorService    = vendorService;
     _detectionService = detectionService;
     _languageSettings = languageSettings;
     _taxSettings      = taxSettings;
     _config           = config;
 }
 public HomeController(ILogger <HomeController> logger, IPublicMethodRepsoitory <DynamicPagesContent> dynamicrepeo, IDetectionService detectionService, IPromotionRepository promotionrepo)
 {
     _logger           = logger;
     _dynamicrepeo     = dynamicrepeo;
     _detectionService = detectionService;
     _promotionrepo    = promotionrepo;
 }
Example #4
0
 public ShopController(DBConnection context, IDetectionService detectionService, IHttpContextAccessor accessor, IOptions <SystemConfiguration> systemConfiguration)
 {
     _accessor            = accessor;
     _context             = context;
     _detectionService    = detectionService;
     _systemConfiguration = systemConfiguration.Value;
 }
Example #5
0
 public DetectionController(IDetectionService detectionService, IMapper mapper, IUriService uriService, IHttpContextAccessor httpContextAccessor)
 {
     _detectionService    = detectionService;
     _mapper              = mapper;
     _uriService          = uriService;
     _httpContextAccessor = httpContextAccessor;
 }
Example #6
0
 public AboutController(ILogger <AboutController> logger, IOptions <SystemConfiguration> systemConfiguration, IDetectionService detectionService, IHttpContextAccessor accessor, SessionManager sessionManager)
 {
     _logger = logger;
     _systemConfiguration = systemConfiguration.Value;
     _detectionService    = detectionService;
     _accessor            = accessor;
     _sessionManager      = sessionManager;
 }
Example #7
0
 public TestController(DBConnection context, ILogger <TestController> logger, IOptions <SystemConfiguration> systemConfiguration, IDetectionService detectionService, IHttpContextAccessor accessor)
 {
     _context             = context;
     _logger              = logger;
     _systemConfiguration = systemConfiguration.Value;
     _detectionService    = detectionService;
     _accessor            = accessor;
 }
Example #8
0
        //, SessionManager sessionManager
        //_sessionManager = sessionManager;

        public AdvertsController(DBConnection context, ILogger <AdvertsController> logger, IOptions <SystemConfiguration> systemConfiguration, IDetectionService detectionService, IHttpContextAccessor accessor, SessionManager sessionManager)
        {
            _context             = context;
            _logger              = logger;
            _systemConfiguration = systemConfiguration.Value;
            _detectionService    = detectionService;
            _accessor            = accessor;
            _sessionManager      = sessionManager;
        }
 public AccountService(IConfiguration configuration, IUnitOfWork uow,
                       IStringLocalizer <IAccountService> localizer,
                       IDetectionService detectionService, IStorageService storageService)
 {
     _configuration    = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _uow              = uow ?? throw new ArgumentNullException(nameof(uow));
     _localizer        = localizer ?? throw new ArgumentNullException(nameof(localizer));
     _detectionService = detectionService ?? throw new ArgumentNullException(nameof(detectionService));
     _storageService   = storageService ?? throw new ArgumentNullException(nameof(storageService));
 }
Example #10
0
        /// <summary>
        /// Main middleware method required for asp.net
        /// </summary>
        /// <param name="context"></param>
        /// <param name="detectionService"></param>
        /// <returns></returns>
        public async Task InvokeAsync(HttpContext context, IDetectionService detectionService)
        {
            if (_options.ListingDictionary.Keys.Any(k => context.Request.Path.StartsWithSegments("/" + k)))
            {
                context.Response.StatusCode = 404;
                var file = _environment.WebRootFileProvider.GetFileInfo("/resource-not-found.html");
                await SendFile(context, file);

                return;
            }
            var isCrawler  = detectionService.Crawler.IsCrawler;
            var isWhatsApp = detectionService.Crawler.Type == Wangkanai.Detection.Models.Crawler.WhatsApp;

            if (isCrawler && context.Request.Path.StartsWithSegments("/share"))
            {
                var url = await _repository.GetUrlById(context.Request.Path.Value.Split("/").Last());

                var title        = string.IsNullOrWhiteSpace(url.Title) ? "Israel Hiking Map Route Share" : url.Title;
                var thumbnailUrl = context.Request.GetDisplayUrl().Replace("/share/", "/api/images/");
                if (isWhatsApp)
                {
                    thumbnailUrl += "?width=256&height=256";
                }
                await Write(context, GetPage(title, thumbnailUrl, url.Description));

                return;
            }
            if (isCrawler && context.Request.Path.StartsWithSegments("/poi"))
            {
                var split = context.Request.Path.Value.Split("/");
                context.Request.Query.TryGetValue("language", out var language);
                var point = await _pointsOfInterestProvider.GetPointOfInterestById(split[split.Length - 2], split.Last(), language.FirstOrDefault());

                if (point == null)
                {
                    var invalidPoi = _environment.WebRootFileProvider.GetFileInfo("/index.html");
                    await SendFile(context, invalidPoi);

                    return;
                }
                var thumbnailUrl = point.ImagesUrls.FirstOrDefault() ?? string.Empty;
                if (isWhatsApp)
                {
                    thumbnailUrl = Regex.Replace(thumbnailUrl, @"(http.*\/\/upload\.wikimedia\.org\/wikipedia\/commons\/)(.*\/)(.*)", "$1thumb/$2$3/200px-$3");
                }
                await Write(context, GetPage(point.Title, thumbnailUrl, point.Description));

                return;
            }

            var defaultFile = _environment.WebRootFileProvider.GetFileInfo("/index.html");

            await SendFile(context, defaultFile);
        }
 public AboutTabViewModel(DataContext dataContext,
                          IDbService dbService,
                          ILogger logger,
                          IConfigService configService,
                          DrawService drawService,
                          IMessageBoxService messageBoxService,
                          CamsDetectionBoard camsDetectionBoard,
                          IDetectionService detectionService)
     : base(dataContext, dbService, logger, configService, drawService, messageBoxService, camsDetectionBoard, detectionService)
 {
 }
Example #12
0
 public TagsController(DBConnection context, ILogger <TagsController> logger, IOptions <SystemConfiguration> systemConfiguration,
                       SessionManager sessionManager, IWebHostEnvironment hostingEnvironment, IDetectionService detectionService, IHttpContextAccessor accessor)
 {
     _context             = context;
     _logger              = logger;
     _sessionManager      = sessionManager;
     _systemConfiguration = systemConfiguration.Value;
     _hostingEnvironment  = hostingEnvironment;
     _detectionService    = detectionService;
     _accessor            = accessor;
 }
Example #13
0
 public IdentityController(
     IIdentityRepoService identityService,
     IMediator mediator,
     IMeasureService measure,
     IDetectionService detection)
 {
     _identityService = identityService;
     _mediator        = mediator;
     _measure         = measure;
     _detection       = detection;
 }
 public ArticleController(ArticleService articleService,
                          UsersService userService,
                          PdfService pdfService,
                          MailingSettingsService mailingSettingsService,
                          IDetectionService detectionService)
 {
     _articleService         = articleService;
     _userService            = userService;
     _pdfService             = pdfService;
     _mailingSettingsService = mailingSettingsService;
     _detectionService       = detectionService;
 }
 public Task Invoke(HttpContext context, IDetectionService detection)
 {
     if (detection.Browser.Name == Browser.InternetExplorer || detection.Browser.Name == Browser.Edge)
     {
         context.Response.WriteAsync("Przegladarka nie jest obslugiwana");
         return(_next(context));
     }
     else
     {
         return(_next(context));
     }
 }
        public async Task <bool> Is2FAForSMSEnabledOnMobileAsync(IDetectionService detector)
        {
            var multiplefFA = await _security.ScrewIdentifierGrid.Where(a => a.Module == (int)Modules.CENTRAL && a.Media == (int)Media.SMS).ToListAsync();

            if (multiplefFA.Count() > 0)
            {
                if (detector.Device.Type.ToString().ToLower() == Device.Mobile.ToString().ToLower())
                {
                    return(multiplefFA.FirstOrDefault(a => a.Media == (int)Media.SMS && a.Module == (int)Modules.CENTRAL).ActiveOnMobileApp);
                }
            }
            return(await Task.Run(() => false));
        }
Example #17
0
        public DeviceResolver(IDetectionService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            _service = service;

            // testing failed because no default Httpcontext
            //if (_context == null) throw new ArgumentNullException(nameof(_context));
            _device = new Device(GetDeviceType(), GetCrawler());
        }
 public PlayerTabViewModel(DataContext dataContext,
                           ILogger logger,
                           IConfigService configService,
                           DrawService drawService,
                           IDbService dbService,
                           IMessageBoxService messageBoxService,
                           CamsDetectionBoard camsDetectionBoard,
                           IDetectionService detectionService)
     : base(dataContext, dbService, logger, configService, drawService, messageBoxService, camsDetectionBoard, detectionService)
 {
     ChooseNewPlayerAvatarCommand = new ChooseNewPlayerAvatarCommand(SelectAvatarImage);
     SaveNewPlayerCommand         = new SaveNewPlayerCommand(SaveNewPlayer);
     PlayerStatisticsLoadCommand  = new PlayerStatisticsLoadCommand(PlayerStatisticsLoad);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FacesToSmileys.ViewModels.TakePhotoViewModel"/> class.
        /// </summary>
        /// <param name="photoService">Photo service.</param>
        /// <param name="imageProcessiongService">Image processiong service.</param>
        /// <param name="detectionService">Detection service.</param>
        /// <param name="fileService">File service.</param>
        public TakePhotoViewModel(IPhotoService photoService,
                                  IImageProcessingService imageProcessiongService,
                                  IDetectionService detectionService,
                                  IFileService fileService,
                                  IAnalyticService analyticService)
        {
            PhotoService           = photoService;
            ImageProcessingService = imageProcessiongService;
            DetectionService       = detectionService;
            FileService            = fileService;
            AnalyticService        = analyticService;

            Initialize();
        }
Example #20
0
 public LoginCommandHandler(
     IIdentityServerRequest identityRepoService,
     UserManager <ApplicationUser> userManager,
     DataContext dataContext,
     IIdentityService identityService,
     IDetectionService detectionService,
     ILoggerService loggerService)
 {
     _userManager      = userManager;
     _service          = identityRepoService;
     _securityContext  = dataContext;
     _logger           = loggerService;
     _detectionService = detectionService;
     _identityService  = identityService;
 }
 public MappingService(IDistributedCacheWrapper distributedCache,
                       IElementMapper elementMapper,
                       ISchemaFactory schemaFactory,
                       IWebHostEnvironment environment,
                       IOptions <DistributedCacheExpirationConfiguration> distributedCacheExpirationConfiguration,
                       IDetectionService detectionService,
                       ILogger <MappingService> logger)
 {
     _distributedCache = distributedCache;
     _elementMapper    = elementMapper;
     _schemaFactory    = schemaFactory;
     _environment      = environment;
     _detectionService = detectionService;
     _distributedCacheExpirationConfiguration = distributedCacheExpirationConfiguration.Value;
     _logger = logger;
 }
Example #22
0
 public HomeController(
     IDetectionService detectionService,
     IDeviceResolver deviceResolver,
     IBrowserResolver browserResolver,
     IEngineResolver engineResolver,
     IPlatformResolver platformResolver)
 {
     client = new ClientInfo
     {
         UserAgent = detectionService.UserAgent,
         Device    = deviceResolver.Device,
         Browser   = browserResolver.Browser,
         Engine    = engineResolver.Engine,
         Platform  = platformResolver.Platform
     };
 }
Example #23
0
 public LoginCommandHandler(
     IIdentityRepoService identityRepoService,
     UserManager <cor_useraccount> userManager,
     IMeasureService measure,
     DataContext dataContext,
     IDetectionService detectionService,
     ILoggerService loggerService,
     IResponseCacheService responseCacheService)
 {
     _userManager      = userManager;
     _cacheService     = responseCacheService;
     _service          = identityRepoService;
     _measure          = measure;
     _securityContext  = dataContext;
     _logger           = loggerService;
     _detectionService = detectionService;
 }
 public SettingsTabViewModel(DataContext dataContext,
                             IDbService dbService,
                             ILogger logger,
                             IConfigService configService,
                             DrawService drawService,
                             IMessageBoxService messageBoxService,
                             CamsDetectionBoard camsDetectionBoard,
                             IDetectionService detectionService)
     : base(dataContext, dbService, logger, configService, drawService, messageBoxService, camsDetectionBoard, detectionService)
 {
     CalibrateCamsSetupPointsCommand = new CalibrateCamsSetupPointsCommand(CalibrateCamsSetupPoints);
     CheckCamsCommand              = new CheckCamsCommand(CheckCamsSimultaneousWork);
     FindCamsCommand               = new FindCamsCommand(FindConnectedCams);
     StartRuntimeCrossingCommand   = new StartRuntimeCrossingCommand(StartCrossing);
     StopRuntimeCrossingCommand    = new StopRuntimeCrossingCommand(StopCrossing);
     StartCamSetupCapturingCommand = new StartCamSetupCapturingCommand(StartCamSetupCapturing);
     StopCamSetupCapturingCommand  = new StopCamSetupCapturingCommand(StopCamSetupCapturing);
 }
        protected TabViewModelBase(DataContext dataContext,
                                   IDbService dbService,
                                   ILogger logger,
                                   IConfigService configService,
                                   DrawService drawService,
                                   IMessageBoxService messageBoxService,
                                   CamsDetectionBoard camsDetectionBoard,
                                   IDetectionService detectionService)
        {
            DataContext             = dataContext;
            this.dbService          = dbService;
            this.logger             = logger;
            this.configService      = configService;
            this.drawService        = drawService;
            this.messageBoxService  = messageBoxService;
            this.camsDetectionBoard = camsDetectionBoard;
            this.detectionService   = detectionService;

            HyperLinkNavigateCommand = new HyperLinkNavigateCommand(OnHyperlinkNavigate);
        }
        public GameTabViewModel(DataContext dataContext,
                                IDbService dbService,
                                ILogger logger,
                                IConfigService configService,
                                DrawService drawService,
                                IMessageBoxService messageBoxService,
                                CamsDetectionBoard camsDetectionBoard,
                                IDetectionService detectionService,
                                GameService gameService,
                                ScoreBoardService scoreBoardService,
                                ManualThrowPanel manualThrowPanel)
            : base(dataContext, dbService, logger, configService, drawService, messageBoxService, camsDetectionBoard, detectionService)
        {
            this.gameService       = gameService;
            this.scoreBoardService = scoreBoardService;
            this.manualThrowPanel  = manualThrowPanel;

            StartNewGameCommand = new StartNewGameCommand(StartGame);
            StopGameCommand     = new StopGameCommand(StopGameByButton);
        }
 public MeasureService(
     IHttpContextAccessor accessor,
     DataContext dataContext,
     IEmailService service,
     IWebHostEnvironment webHostEnvironment,
     IBaseURIs uRIs,
     IDetectionService detectionService,
     IResponseCacheService cacheService,
     ILoggerService logger,
     UserManager <cor_useraccount> userManager)
 {
     _accessor         = accessor;
     _mailservice      = service;
     _security         = dataContext;
     _env              = webHostEnvironment;
     _logger           = logger;
     _uRIs             = uRIs;
     _cacheService     = cacheService;
     _userManager      = userManager;
     _detectionService = detectionService;
 }
 public MapperService(IDetectionService detectionService)
 {
     _detectionService = detectionService;
     DetectedDevice    = _detectionService.Device.Type == Device.Desktop ? "desktop" : "mobile";
 }
Example #29
0
 public BaseRepository(DatabaseContext dbContext, IDetectionService detectionService)
 {
     _dbContext        = dbContext;
     _detectionService = detectionService;
     DetectedDevice    = _detectionService.Device.Type == Device.Desktop ? "desktop" : "mobile";
 }
Example #30
0
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            var response = new MiddlewareResponse {
                Status = new APIResponseStatus {
                    IsSuccessful = false, Message = new APIResponseMessage()
                }
            };
            string       userId     = context.HttpContext.User?.FindFirst("userId")?.Value ?? string.Empty;
            StringValues authHeader = context.HttpContext.Request.Headers["Authorization"];

            bool hasAllowAnonymous = context.ActionDescriptor.EndpointMetadata.Any(em => em.GetType() == typeof(AllowAnonymousAttribute));

            if (context == null || hasAllowAnonymous)
            {
                await next();

                return;
            }
            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(authHeader))
            {
                context.HttpContext.Response.StatusCode = 401;
                context.Result = new UnauthorizedObjectResult(response);
                return;
            }
            string token    = authHeader.ToString().Replace("Bearer ", "").Trim();
            var    handler  = new JwtSecurityTokenHandler();
            var    tokena   = handler.ReadJwtToken(token);
            var    FromDate = tokena.IssuedAt.AddHours(1);
            var    EndDate  = tokena.ValidTo.AddHours(1);

            var expieryMatch = DateTime.UtcNow.AddHours(1);

            if (expieryMatch > EndDate)
            {
                context.HttpContext.Response.StatusCode = 401;
                context.Result = new UnauthorizedObjectResult(response);
                return;
            }

            using (var scope = context.HttpContext.RequestServices.CreateScope())
            {
                try
                {
                    IServiceProvider scopedServices = scope.ServiceProvider;
                    JwtSettings      tokenSettings  = scopedServices.GetRequiredService <JwtSettings>();
                    DataContext      _dataContext   = scopedServices.GetRequiredService <DataContext>();

                    IDetectionService _detectionService = scopedServices.GetRequiredService <IDetectionService>();
                    if (_detectionService.Device.Type.ToString().ToLower() == Device.Desktop.ToString().ToLower())
                    {
                        var currentDeviceDetail = _dataContext.Tracker.Where(q => q.UserId == userId && q.Token == token).ToList();
                        if (currentDeviceDetail.Count() == 0)
                        {
                            context.HttpContext.Response.StatusCode = 401;
                            response.Status.Message.FriendlyMessage = "Duplicate Login Detected";
                            context.Result = new UnauthorizedObjectResult(response);
                            return;
                        }
                    }
                    IMeasureService _measureService = scopedServices.GetRequiredService <IMeasureService>();
                    //if(_measureService.CheckForSessionTrailAsync(userId, (int)Modules.CENTRAL).Result.StatusCode == 401)
                    //{
                    //    context.HttpContext.Response.StatusCode = 401;
                    //    context.Result = new UnauthorizedObjectResult(response);
                    //    return;
                    //}
                    await next();

                    return;
                }
                catch (Exception ex)
                {
                    context.HttpContext.Response.StatusCode  = 500;
                    response.Status.IsSuccessful             = false;
                    response.Status.Message.FriendlyMessage  = ex.Message;
                    response.Status.Message.TechnicalMessage = ex.ToString();
                    context.Result = new InternalServerErrorObjectResult(response);
                    return;
                }
            }
        }