/// <inheritdoc />
 public LogsReadOnlyController(
     IOptions <CurrentAppSettings> appSettings,
     IUnitOfWork <ApplicationDbContext> unitOfWork,
     IMapper mapper)
     : base(unitOfWork, mapper)
 {
     _appSettings = appSettings.Value;
 }
 /// <inheritdoc />
 public LogsWritableController(
     IOptions <CurrentAppSettings> appSettings,
     IEntityManager <LogViewModel, Log, LogCreateViewModel, LogUpdateViewModel> entityManager,
     IUnitOfWork <ApplicationDbContext, ApplicationUser, ApplicationRole> unitOfWork)
     : base(entityManager, unitOfWork)
 {
     _appSettings = appSettings.Value;
 }
 /// <inheritdoc />
 public LogsWritableController(
     IOptions <CurrentAppSettings> appSettings,
     IEntityManagerFactory entityManagerFactory,
     IUnitOfWork <ApplicationDbContext> unitOfWork,
     IMapper mapper)
     : base(entityManagerFactory, unitOfWork, mapper)
 {
     _appSettings = appSettings.Value;
 }
Example #4
0
    /// <summary>
    /// Creates/initializes common infrastructure objects [Configuration, Logging, AppSetting] that are not previously added to <see cref="IServiceCollection" />.
    /// <remarks>
    /// Note: the objects [Configuration, Logging, AppSetting] will only be created/initialized if not added in:
    ///   - ConfigureCoreServices
    ///   - CoreServices
    ///   - ConfigureServices
    /// </remarks>
    /// </summary>
    /// <param name="serviceProvider">The <see cref="IServiceProvider"/> for application services.</param>
    /// <exception cref="Exception"></exception>
    public virtual void Initialize(IServiceProvider serviceProvider)
    {
        if (!_servicesConfigured || !_coreServicesConfigured || !_resolversConfigured || !_defaultHandlersConfigured)
        {
            throw new Exception("Services must be configured before application is initialized.");
        }

        #region Configuration

        var config = serviceProvider.GetService <IChromelyConfiguration>();
        if (config is null)
        {
            config = DefaultConfiguration.CreateForRuntimePlatform();
        }

        ChromelyApp.InitConfiguration(config);

        #endregion Configuration

        #region Application/User Settings

        var appSettings = serviceProvider.GetService <IChromelyAppSettings>();
        if (appSettings is null)
        {
            appSettings = new DefaultAppSettings();
        }

        var currentAppSettings = new CurrentAppSettings
        {
            Properties = appSettings
        };

        ChromelyAppUser.App = currentAppSettings;
        ChromelyAppUser.App.Properties.Read(config);

        #endregion

        #region Logger

        var logger = GetCurrentLogger(serviceProvider);
        if (logger is null)
        {
            logger = new SimpleLogger();
        }

        var defaultLogger = new DefaultLogger
        {
            Log = logger
        };
        Logger.Instance = defaultLogger;

        #endregion

        EnsureExpectedWorkingDirectory();

        _servicesInitialized = true;
    }
Example #5
0
 public ActionResult Settings(CurrentAppSettings model)
 {
     if (ModelState.IsValid)
     {
         _configService.SaveChanges(model);
         TempData["Reloaded"] = "Настройки успешно сохранены. Некоторые параметры начнут использоваться через несколько минут. Это связано с кэшировнием на страницах сайта и особенностями некоторых браузеров.";
         return(RedirectToAction("settings"));
     }
     return(View(model));
 }
 private void closingAppSequence()
 {
     if (CurrentAppSettings.RememberUser)
     {
         CurrentAppSettings.SaveToFile();
     }
     else
     {
         CurrentAppSettings = AppSettings.GetDefaultSettings();
         CurrentAppSettings.SaveToFile();
         getAndAdaptLoginResultAndThenPopulateCache(null);
     }
 }
Example #7
0
 /// <inheritdoc />
 public AccountService(
     IUnitOfWork <ApplicationUser, ApplicationRole> unitOfWork,
     ILogger <AccountService> logger,
     IOptions <CurrentAppSettings> options,
     ApplicationClaimsPrincipalFactory claimsFactory,
     IHttpContextAccessor httpContext,
     IMapper mapper)
 {
     _appSettings   = options.Value;
     _unitOfWork    = unitOfWork;
     _logger        = logger;
     _claimsFactory = claimsFactory;
     _httpContext   = httpContext;
     _mapper        = mapper;
 }
 public static void Register(HttpConfiguration config)
 {
     // Web API configuration and services
     if (CurrentAppSettings.Instance().Get <bool>("IsCorsEnabled"))
     {
         config.EnableCors();
     }
     // Web API routes
     config.MapHttpAttributeRoutes();
     config.Routes.MapHttpRoute(
         name: "DefaultApi",
         routeTemplate: "api/{controller}/{id}",
         defaults: new { id = RouteParameter.Optional }
         );
 }
Example #9
0
        public ActionResult Settings()
        {
            if (TempData["Reloaded"] != null)
            {
                ViewBag.Reloaded = TempData["Reloaded"];
            }
            var model = new CurrentAppSettings {
                IsLogging        = _configService.Config.IsLogging,
                AdminEmail       = _configService.Config.AdminEmail,
                DefaultPagerSize = _configService.Config.DefaultPagerSize,
                DomainUrl        = _configService.Config.DomainUrl,
                IsHtmlForEmailMessagesEnabled = _configService.Config.IsHtmlForEmailMessagesEnabled,
                RobotEmail    = _configService.Config.RobotEmail,
                SmtpClient    = _configService.Config.SmtpClient,
                EntityColumns = _configService.Config.EntityColumns
            };

            return(View(model));
        }
 /// <inheritdoc />
 public EmailService(IOptions <CurrentAppSettings> options, ILogger <EmailService> logger)
 {
     _logger      = logger;
     _appSettings = options.Value;
 }
        public virtual void Initialize(IChromelyContainer container, IChromelyAppSettings appSettings, IChromelyConfiguration config, IChromelyLogger chromelyLogger)
        {
            EnsureExpectedWorkingDirectory();

            #region Container

            _container = container;
            if (_container == null)
            {
                _container = new SimpleContainer();
            }

            #endregion

            #region Configuration

            if (config == null)
            {
                var configurator = new ConfigurationHandler();
                config = configurator.Parse <DefaultConfiguration>();
            }

            if (config == null)
            {
                config = DefaultConfiguration.CreateForRuntimePlatform();
            }

            InitConfiguration(config);
            config.Platform = ChromelyRuntime.Platform;

            #endregion

            #region Application/User Settings

            if (appSettings == null)
            {
                appSettings = new DefaultAppSettings(config.AppName);
            }

            var currentAppSettings = new CurrentAppSettings();
            currentAppSettings.Properties = appSettings;
            ChromelyAppUser.App           = currentAppSettings;
            ChromelyAppUser.App.Properties.Read(config);

            #endregion

            #region Logger

            if (chromelyLogger == null)
            {
                chromelyLogger = new SimpleLogger();
            }

            var defaultLogger = new DefaultLogger();
            defaultLogger.Log = chromelyLogger;
            Logger.Instance   = defaultLogger;

            #endregion

            // Register all primary objects
            _container.RegisterInstance(typeof(IChromelyContainer), typeof(IChromelyContainer).Name, _container);
            _container.RegisterInstance(typeof(IChromelyAppSettings), typeof(IChromelyAppSettings).Name, appSettings);
            _container.RegisterInstance(typeof(IChromelyConfiguration), typeof(IChromelyConfiguration).Name, config);
            _container.RegisterInstance(typeof(IChromelyLogger), typeof(IChromelyLogger).Name, chromelyLogger);
        }
Example #12
0
        public virtual void Initialize(IServiceCollection container, IChromelyAppSettings appSettings, IChromelyConfiguration config, IChromelyLogger chromelyLogger)
        {
            EnsureExpectedWorkingDirectory();

            #region Container

            _container = container;
            if (_container == null)
            {
                _container = new ServiceCollection();
            }

            #endregion

            #region Configuration

            if (config == null)
            {
                var configurator = new ConfigurationHandler();
                config = configurator.Parse <DefaultConfiguration>();
            }

            if (config == null)
            {
                config = DefaultConfiguration.CreateForRuntimePlatform();
            }

            InitConfiguration(config);
            config.Platform = ChromelyRuntime.Platform;

            #endregion

            #region Application/User Settings

            if (appSettings == null)
            {
                appSettings = new DefaultAppSettings(config.AppName);
            }

            var currentAppSettings = new CurrentAppSettings();
            currentAppSettings.Properties = appSettings;
            ChromelyAppUser.App           = currentAppSettings;
            ChromelyAppUser.App.Properties.Read(config);

            #endregion

            #region Logger

            if (chromelyLogger == null)
            {
                chromelyLogger = new SimpleLogger();
            }

            var defaultLogger = new DefaultLogger();
            defaultLogger.Log = chromelyLogger;
            Logger.Instance   = defaultLogger;

            #endregion

            // Register all primary objects
            _container.AddSingleton <IChromelyContainer>(new ChromelyServiceCollectionContainer(_container));
            _container.AddSingleton(_container);
            _container.AddSingleton(appSettings);
            _container.AddSingleton(config);
            _container.AddSingleton(chromelyLogger);
            _container.AddSingleton(NativeHostFactory.GetNativeHost(config));
            _container.AddChromelyMvcWithDefaultRoutes();
        }
Example #13
0
 public EmailService(AppSettings options)
 {
     _appSettings = options.Config;
 }
Example #14
0
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     base.OnFormClosing(e);
     CurrentAppSettings.SaveToFile();
 }