Exemplo n.º 1
0
        public MonitoringService(
            SettingsProvider settingsProvider,
            MessageAdapter messageAdapter,
            InstagramExplorer instagramExplorer,
            ImageUtils imageUtils,
            IImageRepository imageRep)
        {
            _messageAdapter    = messageAdapter;
            _instagramExplorer = instagramExplorer;
            _imageUtils        = imageUtils;
            _imageRep          = imageRep;
            AppSettingsDto settings = settingsProvider.GetAppSettings();

            if (settings == null)
            {
                throw new InvalidOperationException();
            }

            _hashTag = settings.HashTag;
            var startSessionTime = imageRep.GetActiveSession(includeImages: false);

            if (startSessionTime == null)
            {
                imageRep.StartSession();
            }
            _startTime   = startSessionTime?.StartTime ?? DateTime.Now;
            _endTime     = settings.DateEnd;
            _printerName = settings.PrinterName;
        }
Exemplo n.º 2
0
        public static void Configure(ContainerBuilder builder, AppSettingsDto settings)
        {
            AppSettings.Init(settings);

            Data.Startup.Configure(builder, AppSettings.WAConnectionString, AppSettings.WAEdmxConnectionString);

            builder.RegisterType <UserCredService>().As <IUserCredService>();
        }
Exemplo n.º 3
0
 public UsersController(
     IUserService userService,
     IMapper mapper,
     IOptions <AppSettingsDto> appSettings)
 {
     _userService = userService;
     _mapper      = mapper;
     _appSettings = appSettings.Value;
 }
Exemplo n.º 4
0
        internal static void Init(AppSettingsDto settings)
        {
            #region Connection strings

            UpExchangeConnectionString     = settings.UpExchangeConnectionString;
            UpExchangeEdmxConnectionString = settings.UpExchangeEdmxConnectionString;

            #endregion
        }
Exemplo n.º 5
0
        public IActionResult GetAppSettings(string app)
        {
            var response = Deferred.Response(() =>
            {
                return(AppSettingsDto.FromApp(App, Resources));
            });

            return(Ok(response));
        }
Exemplo n.º 6
0
        public static void Configure(ContainerBuilder builder, AppSettingsDto settings)
        {
            AppSettings.Init(settings);

            Data.StartUp.Configure(builder, AppSettings.UpExchangeConnectionString);

            builder.RegisterType <PersonService>().As <IPersonService>();
            builder.RegisterType <ColorService>().As <IColorService>();
        }
Exemplo n.º 7
0
        internal static void Init(AppSettingsDto settings)
        {
            #region Connection strings

            WAConnectionString     = settings.WAConnectionString;
            WAEdmxConnectionString = settings.WAEdmxConnectionString;

            #endregion
        }
Exemplo n.º 8
0
 public ProfessionalService(IProfissionalRepository professionalRepository,
                            IProfissionalAcessoRepository profissionalAcessoRepository,
                            IPermissaoRepository permissaoRepository,
                            IOptions <AppSettingsDto> appSettings) : base(professionalRepository)
 {
     _profissionalRepository       = professionalRepository;
     _profissionalAcessoRepository = profissionalAcessoRepository;
     _permissaoRepository          = permissaoRepository;
     _appSettings = appSettings.Value;
 }
Exemplo n.º 9
0
        public void UpdateSettings(AppSettingsDto input)
        {
            SettingManager.ChangeSettingForApplication(SettingNames.HoldTime, input.HoldTime.ToString());
            SettingManager.ChangeSettingForApplication(SettingNames.MaxHoldTime, input.MaxHoldTime.ToString());
            SettingManager.ChangeSettingForApplication(SettingNames.DaysInAdvance, input.DaysInAdvance.ToString());

            SettingManager.ChangeSettingForApplication(SettingNames.AvailableColor, input.AvailableColor);
            SettingManager.ChangeSettingForApplication(SettingNames.WithheldColor, input.WitheldColor);
            SettingManager.ChangeSettingForApplication(SettingNames.BookedColor, input.BookedColor);
            SettingManager.ChangeSettingForApplication(SettingNames.NotAvailableColor, input.NotAvailableColor);
        }
Exemplo n.º 10
0
 public ActionResult <AppSettingsDto> UpdateAppSettings([FromBody] AppSettingsDto dto)
 {
     try
     {
         return(Ok(_settingsService.AppSettingsRepo.Update(1, dto)));
     }
     catch (Exception e)
     {
         return(NotFound($"Problem updating app settings, error occured: \n{e.Message}"));
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// method to pass appsettings with ease to service layer
        /// </summary>
        /// <returns></returns>
        public static AppSettingsDto ToServiceAppSettingsDto()
        {
            var dto = new AppSettingsDto();

            #region Connection strings

            dto.WAConnectionString     = WAConnectionString;
            dto.WAEdmxConnectionString = WAEdmxConnectionString;

            #endregion

            return(dto);
        }
        /// <summary>
        /// Gets the token.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="appSettings">The application settings.</param>
        /// <returns></returns>
        /// <exception cref="ExceptionDto">
        /// Username or Password are incorrect.
        /// or
        /// There was an error generating the Authentication Token. The user could not be authenticated
        /// </exception>
        public async Task <IdentityTokenDto> GetToken(CredentialsDto model, AppSettingsDto appSettings)
        {
            try
            {
                var identityToken = new IdentityTokenDto();
                var appUser       = await FindUserAsync(model.Username, model.Password);

                if (appUser == null)
                {
                    throw new ExceptionDto(Guid.NewGuid(), "Username or Password are incorrect.");
                }

                var userRoles = await _userManager.GetRolesAsync(appUser);

                var tokenHandler = new JwtSecurityTokenHandler();
                var secret       = Encoding.ASCII.GetBytes(appSettings.Secret);

                var listaClaims = new List <Claim>();
                listaClaims.Add(new Claim(ClaimTypes.Name, appUser.UserName));
                listaClaims.Add(new Claim(ClaimTypes.NameIdentifier, appUser.Id.ToString()));
                foreach (var rol in userRoles)
                {
                    listaClaims.Add(new Claim(ClaimTypes.Role, rol));
                }
                var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Subject            = new ClaimsIdentity(listaClaims),
                    Expires            = DateTime.UtcNow.AddDays(appSettings.ExpiresDays),
                    Audience           = appSettings.Audience,
                    Issuer             = appSettings.Issuer,
                    SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(secret), SecurityAlgorithms.HmacSha256Signature)
                };
                var token = tokenHandler.CreateToken(tokenDescriptor);
                identityToken.Token        = tokenHandler.WriteToken(token);
                identityToken.ValidateFrom = token.ValidFrom;
                identityToken.ValidateTo   = token.ValidTo;

                return(identityToken);
            }
            catch (ExceptionDto)
            {
                throw;
            }
            catch (Exception ex)
            {
                var guid = Guid.NewGuid();
                _logger.Log(LogLevel.Error, ex, guid.ToString());
                throw new ExceptionDto(guid, "There was an error generating the Authentication Token. The user could not be authenticated");
            }
        }
Exemplo n.º 13
0
        public static AppSettingsDto ToServicesAppSettingsDto()
        {
            var dto = new AppSettingsDto();

            #region Connection strings

            dto.UpExchangeConnectionString     = UpExchangeConnectionString;
            dto.UpExchangeEdmxConnectionString = UpExchangeEdmxConnectionString;

            #endregion


            return(dto);
        }
Exemplo n.º 14
0
        public override void Initialize()
        {
            ModuleSettingDto moduleSettings = _settingsProvider.GetAvailableModules();

            if (moduleSettings != null)
            {
                SelfyBoxVisible = moduleSettings.AvailableModules.Any(x => x == AppModules.SelfyBox);
                InstaBoxVisible = moduleSettings.AvailableModules.Any(x => x == AppModules.InstaBox);
            }

            AppSettingsDto settings = _settingsProvider.GetAppSettings();

            IsPrinterVisible = settings != null && settings.ShowPrinterOnStartup;
        }
Exemplo n.º 15
0
        public CurrentSessionViewModel(
            IViewModelNavigator navigator,
            SessionService sessionService,
            ImagePrinter printer,
            SettingsProvider settings
            )
        {
            _navigator      = navigator;
            _sessionService = sessionService;
            _printer        = printer;
            AppSettingsDto appSettings = settings.GetAppSettings();

            if (appSettings != null)
            {
                _printerName = appSettings.PrinterName;
            }
        }
Exemplo n.º 16
0
        public override void Initialize()
        {
            ModuleSettingDto moduleSetting = _settingsProvider.GetAvailableModules();

            if (moduleSetting != null)
            {
                InstaPrinterVisible = moduleSetting.AvailableModules.Any(x => x == AppModules.InstaPrinter);
                SelfyPrinterVisible = moduleSetting.AvailableModules.Any(x => x != AppModules.InstaPrinter);
            }

            AppSettingsDto settings = _settingsProvider.GetAppSettings();

            if (settings == null)
            {
                HashTag    = string.Empty;
                _dateStart = new Hour(TimeSpan.FromHours(DateTime.Now.Hour));
                _dateEnd   = new Hour(TimeSpan.FromHours(DateTime.Now.Hour).Add(TimeSpan.FromMinutes(5)));

                RaisePropertyChanged(() => DateStart);
                RaisePropertyChanged(() => DateEnd);

                ShowPrinterOnStartup = false;

                return;
            }

            _printerName          = settings.PrinterName;
            _hashTag              = settings.HashTag;
            _maxPrinterCopies     = settings.MaxPrinterCopies;
            _showPrinterOnStartup = settings.ShowPrinterOnStartup;
            // var dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).Add(_dateStart.GetCurrentTime());

            _dateStart = new Hour(TimeSpan.FromHours(settings.DateStart.Hour).Add(TimeSpan.FromMinutes(settings.DateStart.Minute)));
            _dateEnd   = new Hour(TimeSpan.FromHours(settings.DateEnd.Hour).Add(TimeSpan.FromMinutes(settings.DateEnd.Minute)));
            /*Из-за того что само время меняется в другом классе*/
            _dateStart.PropertyChanged += OnTimePropertyChange;
            _dateEnd.PropertyChanged   += OnTimePropertyChange;
            RaisePropertyChanged(() => DateStart);
            RaisePropertyChanged(() => DateEnd);
            RaisePropertyChanged(() => PrinterName);
            RaisePropertyChanged(() => HashTag);
            RaisePropertyChanged(() => MaxPrinterCopies);
            RaisePropertyChanged(() => ShowPrinterOnStartup);
        }
        public PrinterActivityViewerViewModel(
            IViewModelNavigator navigator,
            PrinterMessageProvider messageProvider,
            ImagePrinter imagePrinter,
            SettingsProvider settingsProvider
            )
        {
            _navigator       = navigator;
            _messageProvider = messageProvider;
            _imagePrinter    = imagePrinter;
            _copiesCount     = 1;
            AppSettingsDto appSettings = settingsProvider.GetAppSettings();

            if (appSettings != null)
            {
                HashTag      = appSettings.HashTag;
                _printerName = appSettings.PrinterName;
            }
        }
Exemplo n.º 18
0
        public InstagramExplorerViewModel(
            IViewModelNavigator navigator,
            InstagramExplorer instagramExplorer,
            SettingsProvider settings,
            ImagePrinter printer, PatternViewModelProvider patternVMProvider,
            ImageUtils imageUtils, IMappingEngine mappingEngine)
        {
            _navigator         = navigator;
            _printer           = printer;
            _patternVmProvider = patternVMProvider;
            _imageUtils        = imageUtils;
            _mappingEngine     = mappingEngine;
            _instagramExplorer = instagramExplorer;
            AppSettingsDto appSettings = settings.GetAppSettings();

            if (appSettings != null)
            {
                _printerName = appSettings.PrinterName;
            }

            IsHashTag            = true;
            SearchAsyncOperation = new NotifyTaskCompletion <ImageResponse>(Task.FromResult(default(ImageResponse)));
            _searchTokenSource   = new CancellationTokenSource();
        }
Exemplo n.º 19
0
 public virtual void SaveAppSettings(AppSettingsDto settings)
 {
     _user.Value.AppSettings = settings.Serialize();
     _userRepository.UpdateUser(_user.Value);
     _userRepository.Commit();
 }
Exemplo n.º 20
0
        public async Task <IActionResult> PutAppSettings(string app, [FromBody] UpdateAppSettingsDto request)
        {
            var response = await InvokeCommandAsync(request.ToCommand(), x => AppSettingsDto.FromApp(x, Resources));

            return(Ok(response));
        }
Exemplo n.º 21
0
 public RatesClient(IOptions <AppSettingsDto> settings)
 {
     _appSettings = settings.Value;
 }
Exemplo n.º 22
0
 private AppSettingsDto GetResponse(IAppEntity result)
 {
     return(AppSettingsDto.FromDomain(result, Resources));
 }
Exemplo n.º 23
0
        static async Task Main(string[] args)
        {
            setupLogConfig();

            _logger.LogInfoMessage($"App started => args:{args.ToJson()}");

            Terminal.WriteLine("UGCS DroneTracker - PTZ Probe tool", ConsoleColor.Yellow);

            // create a new instance of the class that we want to parse the arguments into
            var options = new Options();

            // if everything went out fine the ParseArguments method will return true
            ArgumentParser.Current.ParseArguments(args, options);
            _logger.LogInfoMessage($"Options parsed => options:\n{options.ToJson()}");

            _transport = options.TransportType == PTZDeviceTransportType.Udp
                ? (IPTZDeviceMessagesTransport) new UdpPTZMessagesTransport(options.PTZUdpHost, options.PTZUdpPort)
                : new SerialPortPTZMessagesTransport(options.PTZSerialPortName, options.PTZSerialPortSpeed);

            logInfo("Initialize transport...");
            try
            {
                // TODO
                // await _transport.Initialize();
                _transport.Initialize();
                logOk("Transport initialized");
            }
            catch (Exception e)
            {
                _logger.LogException(e);
                Terminal.WriteLine("Transport initialize error! Check logs to details.", ConsoleColor.Red);

                Terminal.WriteLine("Press enter to exit...");
                Terminal.ReadLine();

                Environment.Exit(1);
            }

            logInfo("Create PTZ device controller");

            _settingsManager = new ApplicationSettingsManager(null);

            _defaultCoreOptions = _settingsManager.GetAppSettings();

            _requestBuilder  = new PelcoRequestBuilder(_defaultCoreOptions.PelcoCodesMapping);
            _responseDecoder = new PelcoResponseDecoder(_defaultCoreOptions.PelcoCodesMapping);

            _controller = new PelcoDeviceController(_transport, _settingsManager, _requestBuilder, _responseDecoder);

            logInfo("PTZ device controller created");

            await requestCurrentPan(options);

            await requestCurrentTilt(options);

            _transport.MessageSending  += _transport_MessageSending;
            _transport.MessageReceived += _transport_MessageReceived;

            await requestMaxPan(options);

            await requestMaxTilt(options);

            logInfo("Try to set pan by 0x71 opCode");
            if (_maxPan.HasValue)
            {
                await requestSetPan(options, (ushort)(_maxPan.Value / 2));
                await requestSetPan(options, (ushort)(_maxPan.Value));
                await requestSetPan(options, 0);
                await requestSetPan(options, (ushort)(_initialPan * 100));
            }
            else
            {
                await requestSetPan(options, 9000);
                await requestSetPan(options, 18000);
                await requestSetPan(options, 0);
                await requestSetPan(options, (ushort)(_initialPan * 100));
            }

            logInfo("Try to set pan by 0x4B opCode");
            byte pelcoSetPanCode = 0x4b;

            if (_maxPan.HasValue)
            {
                await requestSetPan(options, (ushort)(_maxPan.Value / 2), pelcoSetPanCode);
                await requestSetPan(options, (ushort)(_maxPan.Value), pelcoSetPanCode);
                await requestSetPan(options, 0, pelcoSetPanCode);
                await requestSetPan(options, (ushort)(_initialPan * 100), pelcoSetPanCode);
            }
            else
            {
                await requestSetPan(options, 9000, pelcoSetPanCode);
                await requestSetPan(options, 0, pelcoSetPanCode);
                await requestSetPan(options, (ushort)(_initialPan * 100), pelcoSetPanCode);
            }


            logInfo("Try to set tilt by 0x73 opCode");
            if (_maxTilt.HasValue)
            {
                await requestSetTilt(options, (ushort)(_maxTilt.Value / 2));
                await requestSetTilt(options, (ushort)(_maxTilt.Value));
                await requestSetTilt(options, 0);
                await requestSetTilt(options, (ushort)(_initialTilt * 100));
            }
            else
            {
                await requestSetTilt(options, 4500);
                await requestSetTilt(options, 0);
                await requestSetTilt(options, (ushort)(_initialTilt * 100));
            }

            byte pelcoSetTiltCode = 0x4d;

            logInfo("Try to set tilt by 0x4D opCode");
            if (_maxTilt.HasValue)
            {
                await requestSetTilt(options, (ushort)(_maxTilt.Value / 2), pelcoSetTiltCode);
                await requestSetTilt(options, (ushort)(_maxTilt.Value), pelcoSetTiltCode);
                await requestSetTilt(options, 0, pelcoSetTiltCode);
                await requestSetTilt(options, (ushort)(_initialTilt * 100), pelcoSetTiltCode);
            }
            else
            {
                await requestSetTilt(options, 4500, pelcoSetTiltCode);
                await requestSetTilt(options, 0, pelcoSetTiltCode);
                await requestSetTilt(options, (ushort)(_initialPan * 100), pelcoSetTiltCode);
            }


            _logger.LogInfoMessage($"Done. Waiting user to exit.");

            Terminal.WriteLine();
            Terminal.WriteLine("Done.", ConsoleColor.Yellow);
            Terminal.WriteLine("Press enter to exit...", ConsoleColor.Yellow);

            _transport.Teardown();

            Terminal.ReadLine();
        }
Exemplo n.º 24
0
 public OrderConfiguration(AppSettingsDto appSettings)
 {
     _appSettings = appSettings;
 }
Exemplo n.º 25
0
 public DecimalFloatTailZeroContext(DbContextOptions options,
                                    IConfiguration configuration)
     : base(options)
 {
     _appSettings = configuration.Get <AppSettingsDto>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticationController"/> class.
 /// </summary>
 /// <param name="appSettings">The application settings.</param>
 /// <param name="userService">The user service.</param>
 /// <param name="logger">The logger.</param>
 public AuthenticationController(IOptions <AppSettingsDto> appSettings, IApplicationUserManager userService, ILogger <AuthenticationController> logger)
 {
     _appSettings = appSettings.Value;
     _userService = userService;
     _logger      = logger;
 }
Exemplo n.º 27
0
 protected BaseService(IOptions<AppSettingsDto> settings = null) {
     AppSettings = settings.Value;
 }