示例#1
0
 public PickingTypesService(ICommonDataService dataService, IUserProvider userProvider, ITriggersService triggersService,
                            IValidationService validationService, IFieldDispatcherService fieldDispatcherService,
                            IFieldSetterFactory fieldSetterFactory, IAppConfigurationService configurationService)
     : base(dataService, userProvider, triggersService, validationService, fieldDispatcherService, fieldSetterFactory, configurationService
            )
 {
 }
示例#2
0
 public TariffsService(ICommonDataService dataService, IUserProvider userProvider, ITriggersService triggersService,
                       IValidationService validationService, IFieldDispatcherService fieldDispatcherService,
                       IFieldSetterFactory fieldSetterFactory, IAppConfigurationService configurationService)
     : base(dataService, userProvider, triggersService, validationService, fieldDispatcherService, fieldSetterFactory, configurationService)
 {
     _mapper = ConfigureMapper().CreateMapper();
 }
        public AppStateInfoViewModel(
            IApplicationCommands applicationCommands,
            IEventAggregator eventAggregator,
            IAppConfigurationService appConfigurationService,
            IKeyHookService keyHookService,
            IStorageService storageService)
        {
            KeyHookService          = keyHookService;
            ApplicationCommands     = applicationCommands;
            EventAggregator         = eventAggregator;
            AppConfigurationService = appConfigurationService;
            StorageService          = storageService;

            tokenKeyHandlerHome = KeyHookService.Add(System.Windows.Forms.Keys.Home, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));
            tokenKeyHandlerEnd  = KeyHookService.Add(System.Windows.Forms.Keys.End, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));

            //handle "unload" event from view to cleanup VM resources
            EventAggregator.GetEvent <ViewDestroyedEvent>()
            .Subscribe(
                HandleUnload,
                ThreadOption.UIThread,
                false,
                view => view.DataContext == this     //if view has this context then handle operation
                );
        }
示例#4
0
 public P3dbController(
     INsModelsService modelsService,
     IAppConfigurationService configurationService
     )
 {
     this.modelsService        = modelsService;
     this.configurationService = configurationService;
 }
示例#5
0
 public ArticlesService(ICommonDataService dataService, IUserProvider userProvider, ITriggersService triggersService, IValidationService validationService,
                        IHistoryService historyService, IFieldDispatcherService fieldDispatcherService, IFieldSetterFactory fieldSetterFactory,
                        IChangeTrackerFactory changeTrackerFactory, IAppConfigurationService configurationService)
     : base(dataService, userProvider, triggersService, validationService, fieldDispatcherService, fieldSetterFactory, configurationService)
 {
     _mapper               = ConfigureMapper().CreateMapper();
     _historyService       = historyService;
     _changeTrackerFactory = changeTrackerFactory;
 }
        public static void InjectCachedQueriesData(IAppConfigurationService testingAppConfigurationService)
        {
            const string fileName = "cachedQueries.json";

            var from = Path.Combine(queryCacheDataDirectory, fileName);
            var to   = Path.Combine(testingAppConfigurationService.StorageDirectory, fileName);

            File.Copy(from, to);
        }
 public MatchProcessingService(ILogService logService, IStorageService storageService, IQueryCacheService queryCacheService, IDataService userRankProcessingService, IAppConfigurationService appConfigurationService)
 {
     #region Assign services
     AppConfigurationService = appConfigurationService;
     LogService                = logService;
     StorageService            = storageService;
     QueryCacheService         = queryCacheService;
     UserRankProcessingService = userRankProcessingService;
     #endregion
 }
        public LogService(IAppConfigurationService appConfigurationService)
        {
            var config = new NLog.Config.LoggingConfiguration();

            var logFileName = "log_" + DateTime.Now.ToString("d_MMM_yyyy-h_mm_ss", DateTimeFormatInfo.InvariantInfo);

            //.Replace(":", "-");

#if DEBUG
            //keep only single log file for each app session
            //var logFilePath = Path.Combine(appConfigurationService.StorageDirectory, "logs");
            var logFilePath = Path.Combine(appConfigurationService.StorageDirectory, "logs", $"_debug_log.txt");

            if (File.Exists(logFilePath))
            {
                //supress
                //    try
                //    {
                File.Delete(logFilePath);
                //    }
                //    catch(Exception e)
                //    {
                //        if (
                //            e is StackOverflowException ||
                //            e is ThreadAbortException ||
                //            e is AccessViolationException
                //            )
                //        {
                //            throw e;
                //        }
                //    }
                //}
            }
#else //RELEASE
            var logFilePath = Path.Combine(appConfigurationService.StorageDirectory, "logs", $"{logFileName}.txt");
#endif
            // Targets where to log to: File and Console
            var logFile = new NLog.Targets.FileTarget("logfile")
            {
                FileName   = logFilePath,
                Layout     = "[${level:uppercase=true}] ${longdate} Thread: ${threadid}: ${exception:format=toString} ${message}",
                CreateDirs = true
            };

//#if DEBUG
//            config.AddRule(LogLevel.Debug, LogLevel.Fatal, logFile);
//#else //RELEASE

//#endif

            config.AddRule(LogLevel.Trace, LogLevel.Fatal, logFile);

            LogManager.Configuration = config;
            logger = LogManager.GetCurrentClassLogger();
        }
示例#9
0
        private void initConfiguration()
        {
            var service = AppController.Instance.GetService <IAppConfigurationService, AppConfigurationService>();

            if (service == null || !typeof(IAppConfigurationService).IsAssignableFrom(service.GetType()))
            {
                throw new AppServiceException(typeof(IAppConfigurationService));
            }

            configuration = (IAppConfigurationService)service;
            configuration.Init();
        }
示例#10
0
 protected DictionaryServiceBase(ICommonDataService dataService, IUserProvider userProvider,
                                 ITriggersService triggersService,
                                 IValidationService validationService, IFieldDispatcherService fieldDispatcherService,
                                 IFieldSetterFactory fieldSetterFactory, IAppConfigurationService configurationService)
 {
     _dataService            = dataService;
     _userProvider           = userProvider;
     _triggersService        = triggersService;
     _validationService      = validationService;
     _fieldDispatcherService = fieldDispatcherService;
     _fieldSetterFactory     = fieldSetterFactory;
     _configurationService   = configurationService;
 }
        static internal void PreapareTestingDirectory(IAppConfigurationService testingAppConfigurationService)
        {
            if (!Directory.Exists(testingAppConfigurationService.StorageDirectory))
            {
                Directory.CreateDirectory(testingAppConfigurationService.StorageDirectory);
            }

            var testingStorageDirectory = new DirectoryInfo(testingAppConfigurationService.StorageDirectory);

            foreach (var file in testingStorageDirectory.GetFiles())
            {
                file.Delete();
            }
        }
示例#12
0
 public WorkflowService(IFileRepository fileRepository,
                        IWFFileStateRepository wfFileStateRepository,
                        IWorkflowRepository workflowRepository,
                        IWFStateRepository wfStateRepository,
                        IWFTransitionRepository wfTransitionRepository,
                        IAppConfigurationService appConfigurationService,
                        ICustomerRepository customerRepository
                        )
 {
     this.appConfigurationService = appConfigurationService;
     this.fileRepository          = fileRepository;
     this.wfFileStateRepository   = wfFileStateRepository;
     this.workflowRepository      = workflowRepository;
     this.wfStateRepository       = wfStateRepository;
     this.wfTransitionRepository  = wfTransitionRepository;
     this.customerRepository      = customerRepository;
 }
        public TeamsPanelViewModel(
            IApplicationCommands applicationCommands,
            IAppConfigurationService appConfigurationService,
            IEventAggregator eventAggregator,
            IDataService userRankService,
            IKeyHookService keyHookService,
            ILogService logService,
            IStorageService storageService)
        {
            ApplicationCommands     = applicationCommands;
            AppConfigurationService = appConfigurationService;
            EventAggregator         = eventAggregator;
            UserRankService         = userRankService;
            KeyHookService          = keyHookService;
            LogService     = logService;
            StorageService = storageService;

            //ApplicationCommands.ShowWindow.Execute(null);

            updateTimer = new System.Timers.Timer(AppConfigurationService.TeamPanelUpdateTick)
            {
                AutoReset = true
            };
            updateTimer.Elapsed += UpdateTimer_Elapsed;
            updateTimer.Start();

            //assign home/end keys with window visibility toggle
            keyHandlerTokenHome = KeyHookService.Add(System.Windows.Forms.Keys.Home, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));
            keyHandlerTokenEnd  = KeyHookService.Add(System.Windows.Forms.Keys.End, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));

            EventAggregator.GetEvent <ViewDestroyedEvent>()
            .Subscribe(
                HandleUnload,
                ThreadOption.UIThread,
                false,
                view => view.DataContext == this     //if view has this context then handle operation
                );
        }
示例#14
0
 /// <summary>
 /// Create an instance of the TestResultItemApiController.
 /// </summary>
 /// <param name="appConfigurationService"></param>
 /// <param name="reviewService"></param>
 public TestResultItemApiController(IAppConfigurationService appConfigurationService, ReviewService reviewService)
 {
     this.ReviewService           = reviewService;
     this.AppConfigurationService = appConfigurationService;
 }
 public PanoramsController(INsPanoramsService panoramsService, IAppConfigurationService appConfigurationService)
 {
     this.panoramsService         = panoramsService;
     this.appConfigurationService = appConfigurationService;
 }
示例#16
0
 public StorageService(IAppConfigurationService appConfigurationService, ILogService logService)
 {
     AppConfigurationService = appConfigurationService;
     LogService = logService;
 }
示例#17
0
 public AppConfigurationController(IAppConfigurationService appConfigurationService)
 {
     this.appConfigurationService = appConfigurationService;
 }
示例#18
0
 public IdentityService(IAppConfigurationService appConfigurationService, UserManager <UserProfileModel> userManager,
                        SignInManager <UserProfileModel> signInManager, RoleManager <IdentityRole> roleManager)
     : base(((QAFood.BLL.Services.AppConfigurationService)appConfigurationService).AppConfiguration, userManager, signInManager, roleManager)
 {
 }
示例#19
0
 public SettingsController(IAppConfigurationService configurationService)
 {
     this.configurationService = configurationService ?? throw new System.ArgumentNullException(nameof(configurationService));
 }
示例#20
0
 public AgentService(IAppConfigurationService config)
 {
     this._config = config;
 }
示例#21
0
 public FirstViewModel(IAppConfigurationService appConfigurationService)
 {
     this.appConfigurationService = appConfigurationService;
 }
 public NodesController(IAppConfigurationService config, IAgentService agent)
 {
     this._config = config;
     this._agent  = agent;
 }
示例#23
0
 public CredentialsService(IAppConfigurationService appConfiguration, ILogger <CredentialsService> logger)
 {
     _appConfiguration = appConfiguration;
     _logger           = logger;
 }
 public SettingsViewModel(
     ILoggerFacade logger,
     IRegionManager regionManager,
     IEventAggregator eventAggregator,
     ISnackbarMessageQueue snackbarMessageQueue,
     IAppConfigurationService appConfigurationService)
 {
     _logger                       = logger ?? throw new ArgumentNullException(nameof(logger));
     _regionManager                = regionManager ?? throw new ArgumentNullException(nameof(regionManager));
     _eventAggregator              = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator));
     _messageQueue                 = snackbarMessageQueue ?? throw new ArgumentNullException(nameof(snackbarMessageQueue));
     _appConfigurationService      = appConfigurationService ?? throw new ArgumentNullException(nameof(appConfigurationService));
     NavigateToMainView            = new DelegateCommand(NavigateToMain);
     ResetToDefaultSettingsCommand = new DelegateCommand(ResetToDefaultSettings);
     OpenLogDirectoryCommand       = new DelegateCommand(OpenLogDirectory);
     LogLevels                     = new ObservableCollection <LogLevel>
     {
         new LogLevel
         {
             Level = 0,
             Name  = "Verbose"
         },
         new LogLevel
         {
             Level = 1,
             Name  = "Debug"
         },
         new LogLevel
         {
             Level = 2,
             Name  = "Information"
         },
         new LogLevel
         {
             Level = 3,
             Name  = "Warning"
         },
         new LogLevel
         {
             Level = 4,
             Name  = "Error"
         },
         new LogLevel
         {
             Level = 5,
             Name  = "Fatal"
         },
     };
     _appConfiguration = _appConfigurationService.Configuration;
     if (_appConfiguration != null)
     {
         if (_appConfiguration.LogLevel > _logLevels.Count - 1)
         {
             _currentLogLevel = _logLevels[(int)Global.DefaultLogEventLevel];
         }
         else
         {
             _currentLogLevel = _logLevels[_appConfiguration.LogLevel];
         }
     }
 }
 internal RequestTestingService(IAppConfigurationService appConfigurationService) : base(appConfigurationService)
 {
 }
示例#26
0
 public RequestService(IAppConfigurationService appConfigurationService)
 {
     AppConfigurationService = appConfigurationService;
     HttpClient = new HttpClient();
 }
        public MainWindowViewModel(
            ILoggerFacade logger,
            IRegionManager regionManager,
            IEventAggregator eventAggregator,
            ISnackbarMessageQueue snackbarMessageQueue,
            IAppConfigurationService appConfigurationService)
        {
            _logger                  = logger ?? throw new ArgumentNullException(nameof(logger));
            _eventAggregator         = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator));
            _regionManager           = regionManager ?? throw new ArgumentNullException(nameof(regionManager));
            _messageQueue            = snackbarMessageQueue ?? throw new ArgumentNullException(nameof(snackbarMessageQueue));
            _appConfigurationService = appConfigurationService ?? throw new ArgumentNullException(nameof(appConfigurationService));
            try
            {
                _appConfiguration = _appConfigurationService.Configuration;
                _eventAggregator.GetEvent <StampAddedEvent>().Subscribe(CustomStampAdded);
                NavigateToAboutViewCommand    = new DelegateCommand(NavigateToAboutView);
                NavigateToStampViewCommand    = new DelegateCommand(NavigateToStampView);
                NavigateToSettingsViewCommand = new DelegateCommand(NavigateToSettingsView);
                OpenWebCommand         = new DelegateCommand <string>(OpenUrl);
                CheckForUpdatesCommand = new DelegateCommand(CheckForUpdates);

                HandleCustomFilter = new DelegateCommand(HandleCustomStamp);
                HandleFamilyFilter = new DelegateCommand(async() => await HandleDnsCrypt(Global.DefaultFamilyFilterKey));
                HandleAdultFilter  = new DelegateCommand(async() => await HandleDnsCrypt(Global.DefaultAdultFilterKey));

                IsWorking             = true;
                IsCustomFilterEnabled = false;
                IsFamilyFilterEnabled = false;
                IsAdultFilterEnabled  = false;

                var year = Global.CopyrightYear.ToString();
                if (DateTime.UtcNow.Year != Global.CopyrightYear)
                {
                    year = $"{Global.CopyrightYear} - {DateTime.UtcNow.Year}";
                }
                Footer = $"Copyright © {year} {Global.CompanyName}. {VersionHelper.PublishVersion} {VersionHelper.PublishBuild}";
                ((App)Application.Current).LoggingLevelSwitch.MinimumLevel = (Serilog.Events.LogEventLevel)_appConfiguration.LogLevel;
                _logger.Log($"LogLevel: {_appConfiguration.LogLevel}", Category.Debug, Priority.Low);
                _logger.Log($"{Global.ApplicationName} {VersionHelper.PublishVersion} {VersionHelper.PublishBuild} started", Category.Info, Priority.Medium);
                // check application configuration
                _logger.Log($"checking {Global.AppConfigurationFile}", Category.Info, Priority.Medium);

                var resetApplicationConfig = false;
                if (_appConfiguration != null)
                {
                    if (_appConfiguration.Proxies != null)
                    {
                        foreach (var proxy in _appConfiguration.Proxies)
                        {
                            var decodedStamp = StampTools.Decode(proxy.Stamp);
                            if (decodedStamp != null)
                            {
                                if (decodedStamp.Protocol == DnsCrypt.Models.StampProtocol.DnsCrypt)
                                {
                                    //simple check if the stamp is a valid cleanbrowsing stamp
                                    if (!decodedStamp.ProviderName.Equals(Global.ValidCleanBrowsingDnsCryptStamp))
                                    {
                                        resetApplicationConfig = true;
                                    }
                                }
                                else if (decodedStamp.Protocol == DnsCrypt.Models.StampProtocol.DoH)
                                {
                                    //simple check if the stamp is a valid cleanbrowsing stamp
                                    if (!decodedStamp.Hostname.Equals(Global.ValidCleanBrowsingDohStamp))
                                    {
                                        resetApplicationConfig = true;
                                    }
                                }
                                else
                                {
                                    //unsupported stamp
                                    resetApplicationConfig = true;
                                }
                            }
                            else
                            {
                                resetApplicationConfig = true;
                            }
                            _logger.Log($"{proxy.Name} loaded", Category.Info, Priority.Medium);
                        }
                        _logger.Log($"{Global.AppConfigurationFile} loaded", Category.Info, Priority.Medium);
                    }
                    else
                    {
                        resetApplicationConfig = true;
                    }
                }
                else
                {
                    resetApplicationConfig = true;
                    _logger.Log($"failed to load {Global.AppConfigurationFile}", Category.Warn, Priority.Medium);
                }

                if (resetApplicationConfig)
                {
                    _logger.Log($"reset {Global.AppConfigurationFile} to default", Category.Warn, Priority.Medium);
                    _appConfigurationService.Reset();
                    _appConfiguration = _appConfigurationService.Configuration;
                    if (_appConfiguration == null)
                    {
                        _logger.Log($"failed to reset {Global.AppConfigurationFile}", Category.Exception, Priority.High);
                        Environment.Exit(-1);
                    }
                    else
                    {
                        //no validation this time, just go on
                    }
                }

                _logger.Log($"checking {Global.DnsCryptProxyFolder} folder", Category.Info, Priority.Medium);
                foreach (var proxyFile in Global.DnsCryptProxyFiles)
                {
                    var proxyFilePath = Path.Combine(Directory.GetCurrentDirectory(), Global.DnsCryptProxyFolder, proxyFile);
                    if (!File.Exists(proxyFilePath))
                    {
                        _logger.Log($"missing {proxyFile}", Category.Warn, Priority.Medium);
                    }
                    else
                    {
                        _logger.Log($"found {proxyFile}", Category.Info, Priority.Low);
                    }
                }

                var isValidConfiguration = false;
                _logger.Log($"checking {Global.DnsCryptConfigurationFile}", Category.Info, Priority.Medium);

                var configurationCheck = DnsCryptProxyManager.IsConfigurationFileValid();
                if (configurationCheck.Success)
                {
                    isValidConfiguration = true;
                    _logger.Log($"{Global.DnsCryptConfigurationFile} is valid", Category.Info, Priority.Medium);
                }
                else
                {
                    if (configurationCheck.StandardError.Contains("[FATAL] No servers configured"))
                    {
                        isValidConfiguration = true;
                        _logger.Log($"{Global.DnsCryptConfigurationFile} is valid (but no servers)", Category.Info, Priority.Medium);
                    }
                }

                if (isValidConfiguration)
                {
                    var version = DnsCryptProxyManager.GetVersion();
                    if (!string.IsNullOrEmpty(version))
                    {
                        Title = $"{Global.ApplicationName} (dnscrypt-proxy {version})";
                        _logger.Log($"dnscrypt-proxy version: {version}", Category.Info, Priority.Medium);
                    }
                    else
                    {
                        Title = $"{Global.ApplicationName} (dnscrypt-proxy unknown)";
                        _logger.Log("dnscrypt-proxy version: unknown", Category.Warn, Priority.Medium);
                    }
                    _logger.Log($"loading {Global.DnsCryptConfigurationFile}", Category.Info, Priority.Medium);
                    if (DnscryptProxyConfigurationManager.LoadConfiguration())
                    {
                        _logger.Log($"{Global.DnsCryptConfigurationFile} loaded", Category.Info, Priority.Medium);
                        _dnscryptProxyConfiguration = DnscryptProxyConfigurationManager.DnscryptProxyConfiguration;
                        if (_dnscryptProxyConfiguration.Static != null && _dnscryptProxyConfiguration.Static.Count > 0)
                        {
                            if (_dnscryptProxyConfiguration.Static.ContainsKey(Global.DefaultCustomFilterKey))
                            {
                                _logger.Log($"found {Global.DefaultCustomFilterKey} filter", Category.Info, Priority.Medium);
                                IsCustomFilterEnabled = true;
                            }
                            else if (_dnscryptProxyConfiguration.Static.ContainsKey(Global.DefaultAdultFilterKey))
                            {
                                _logger.Log($"found {Global.DefaultAdultFilterKey} filter", Category.Info, Priority.Medium);
                                IsAdultFilterEnabled = true;
                            }
                            else if (_dnscryptProxyConfiguration.Static.ContainsKey(Global.DefaultFamilyFilterKey))
                            {
                                _logger.Log($"found {Global.DefaultFamilyFilterKey} filter", Category.Info, Priority.Medium);
                                IsFamilyFilterEnabled = true;
                            }
                        }
                        else
                        {
                            _logger.Log("no static filter configured", Category.Info, Priority.Medium);
                        }

                        if (IsCustomFilterEnabled || IsFamilyFilterEnabled || IsAdultFilterEnabled)
                        {
                            if (!DnsCryptProxyManager.IsDnsCryptProxyInstalled())
                            {
                                _logger.Log($"dnscrypt-proxy service is not installed, try install", Category.Info, Priority.High);
                                //install
                                Task.Run(() => { DnsCryptProxyManager.Install(); }).ConfigureAwait(false);
                                Task.Delay(Global.ServiceInstallTime).ConfigureAwait(false);
                            }
                            else
                            {
                                _logger.Log($"dnscrypt-proxy service is already installed", Category.Info, Priority.Medium);
                            }

                            if (!DnsCryptProxyManager.IsDnsCryptProxyRunning())
                            {
                                _logger.Log($"dnscrypt-proxy service is not running, try start", Category.Info, Priority.High);
                                Task.Run(() => { DnsCryptProxyManager.Start(); }).ConfigureAwait(false);
                                Task.Delay(Global.ServiceStartTime).ConfigureAwait(false);
                            }
                            else
                            {
                                _logger.Log($"dnscrypt-proxy service is already running", Category.Info, Priority.Medium);
                            }

                            if (DnsCryptProxyManager.IsDnsCryptProxyRunning())
                            {
                                _logger.Log($"checking dns servers on network interfaces", Category.Info, Priority.High);
                                if (!HandleNetworkInterfaces(true))
                                {
                                    _logger.Log($"could not update dns servers on network interfaces", Category.Warn, Priority.High);
                                }
                            }
                            else
                            {
                                _logger.Log($"could not start dnscrypt-proxy", Category.Warn, Priority.High);
                            }
                        }
                    }
                    else
                    {
                        _logger.Log($"could not load configuration: {Global.DnsCryptConfigurationFile}", Category.Warn, Priority.High);
                        Environment.Exit(-1);
                    }
                }
                else
                {
                    _logger.Log($"invalid {Global.DnsCryptConfigurationFile}", Category.Warn, Priority.High);
                    Environment.Exit(-1);
                }
            }
            catch (Exception ex)
            {
                _logger.Log(ex.Message, Category.Exception, Priority.High);
                Environment.Exit(-1);
            }
            MessageQueue.Enqueue("🐞 You are using a preview version! May contain bugs! 🐞");
            IsWorking = false;
        }