public async Task Run(XConsole xc) { try { using (var scope = xc.WebHost.Services.CreateScope()) { var settings = scope.ServiceProvider.GetService <IDbSettingsReader>(); xc.WriteInfo(this, "Retriving version information.."); var versions = new Versions() { AppVersion = settings.GetAppVersion(), DataSeederFrameworkVersion = settings.GetDataSeederFrameworkVersion(), FrameWorkVersion = AppSettingsAccessor.GetFrameWorkBuildNumber(true) }; xc.WriteSuccess(this, "Done."); var table = xc.CreateTable(new string[] { "Item", "Value" }); table.AddRow("Application Version", versions.AppVersion); table.AddRow("Data Seeder Framework Version", versions.DataSeederFrameworkVersion); table.AddRow("Framework Version", versions.FrameWorkVersion); var parts = versions.NugetVersion.Split('.'); table.AddRow("Nuget Version", parts.Length <= 3 ? versions.NugetVersion : string.Join('.', parts.Take(3))); xc.WriteTable(table); } } catch (Exception ex) { xc.WriteException(this, ex); } }
public CollectionWithLogsTests() { _log = new DeviceLog { DateStamp = DateTime.Now, PluginName = "SamsungDPlugin" }; var options = Options .Create(new ServerSettings { DataStoragePlugin = new ServerSettingViewModel { Name = "DataStoragePlugin", Value = "MSSQLDSPlugin", DisplayName = "Data storage plugin", IsEditable = false }, CapacityOfCollectionToInsert = new ServerSettingViewModel { Name = "BulkInsertCapacity", DisplayName = "Bulk insert capacity", Value = 100.ToString(), IsEditable = true }, IntervalForWritingIntoDb = new ServerSettingViewModel { Name = "BulkInsertInterval", DisplayName = "Bulk insert interval", Value = 100.ToString(), IsEditable = true } }); _appSettingsModifier = new AppSettingsAccessor(options); _helperCollection = new CollectionOfLogs(_appSettingsModifier); }
public DataStoragesHelperType(IEnumerable <IDataStoragePlugin> dataStoragePluginsCollection , AppSettingsAccessor appSettingsModifier ) { _serverSettings = appSettingsModifier.GetServerSettings(); _appSettingsModifier = appSettingsModifier; _dataStoragePlugins = dataStoragePluginsCollection; appSettingsModifier.NotifyDependentEntetiesEvent += HandleUserSettingsUpdate; }
public DeviceController( CollectionOfLogs collectionOfLogs , IDevicesLogsService devicesLogsService , AppSettingsAccessor appSettingsModifier ) { _collectionOfLogs = collectionOfLogs; _devicesLogsService = devicesLogsService; _appSettingsModifier = appSettingsModifier; }
public LogsStorageWriter(CollectionOfLogs collectionOfLogs , IDevicesLogsRepository logsRepository , AppSettingsAccessor appSettingsModifier ) { _collectionOfLogs = collectionOfLogs; _logsRepository = logsRepository; _appSettingsModifier = appSettingsModifier; appSettingsModifier.NotifyDependentEntetiesEvent += HandleUserSettingsUpdate; _serverSettings = appSettingsModifier.GetServerSettings(); _autoResetEvent = new AutoResetEvent(false); }
public CollectionOfLogs(AppSettingsAccessor appSettingsModifier) { _serverSettings = appSettingsModifier.GetServerSettings(); resetEvent = new ManualResetEvent(false); _appSettingsModifier = appSettingsModifier; appSettingsModifier.NotifyDependentEntetiesEvent += HandleUserSettingsUpdate; List <DeviceLog> initialLogs = new List <DeviceLog>(_serverSettings.CapacityOfCollectionToInsert.Value.ConvertToInt()); _allCollections = new List <List <DeviceLog> >() { initialLogs }; _helperQueue = new Queue <List <DeviceLog> >(); }
public ABaseController(IConfiguration config, IDbSettingsReader settings, ILogger logger) : base() { this.Settings = settings; this.Config = config; this.Views = new ViewNames(); this.Logger = logger; this.Controllers = new ControllerNames { DashboardController = Settings.GetAppDashboardControllerName(), MyProfileController = Settings.GetAppMyProfileControllerName(), AccountController = Settings.GetAccountControllerName(), UninstallController = Settings.GetAppUninstallControllerName() }; this.VersionInfo = new Versions() { AppVersion = settings.GetAppVersion(), FrameWorkVersion = AppSettingsAccessor.GetFrameWorkBuildNumber(), DataSeederFrameworkVersion = Settings.GetDataSeederFrameworkVersion() }; }
/// <summary> /// Adds all aspnet core services (AddMemoryCache(),AddSession() etc) required for the framework /// as well as registers all ExioSopifyFramework services. /// </summary> /// <param name="services"></param> /// <param name="Configuration"></param> /// <param name="mvcBuilder"></param> public static void AddExicoShopifyRequiredServices(this IServiceCollection services, IConfiguration Configuration, IMvcBuilder mvcBuilder) { #region DB context services.AddDbContext <ExicoIdentityDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString(AppSettingsAccessor.DB_CON_STRING_NAME))); services.AddIdentity <AspNetUser, IdentityRole>(options => { options.Password.RequireNonAlphanumeric = false; options.Password.RequireLowercase = false; options.Password.RequireUppercase = false; }) .AddEntityFrameworkStores <ExicoIdentityDbContext>() .AddDefaultTokenProviders(); services.ConfigureApplicationCookie(options => { options.Cookie.Name = AppSettingsAccessor.IDENTITY_CORE_AUTH_COOKIE_NAME; }); services.AddDbContext <ExicoShopifyDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString(AppSettingsAccessor.DB_CON_STRING_NAME))); #endregion #region Db services services.AddTransient <ExicoShopifyDbUnitOfWork, ExicoShopifyDbUnitOfWork>(); services.AddTransient <ExicoShopifyDbRepository <Plan>, ExicoShopifyDbRepository <Plan> >(); services.AddTransient <IDbService <Plan>, ExicoShopifyDbService <Plan> >(); services.AddTransient <ExicoShopifyDbRepository <AspNetUser>, ExicoShopifyDbRepository <AspNetUser> >(); services.AddTransient <IDbService <AspNetUser>, ExicoShopifyDbService <AspNetUser> >(); services.AddTransient <ExicoShopifyDbRepository <SystemSetting>, ExicoShopifyDbRepository <SystemSetting> >(); services.AddTransient <IDbService <SystemSetting>, ExicoShopifyDbService <SystemSetting> >(); #endregion #region Filters services.AddScoped <AdminPasswordVerification>(); services.AddScoped <IPAddressVerification>(); services.AddScoped <RequiresPlan>(); services.AddScoped <RequireSubscription>(); #endregion #region Scoped services services.AddScoped <IPlansReader, PlansReader>(); services.AddScoped <IDbSettingsReader, DbSettingsReader>(); services.AddScoped <IUserCaching, UserCaching>(); services.AddScoped <IWebMsgConfig, DefaultWebMsgConfig>(); #endregion #region Scoped Services services.AddScoped <IGenerateUserPassword, DefaultPasswordGenerator>(); services.AddScoped <IShopifyApi, ShopifyApi>(); services.AddScoped <IWebMessenger, DefaultWebMessenger>(); services.AddScoped <IAppSettingsAccessor, AppSettingsAccessor>(); #endregion #region Transient Services services.AddTransient <IEmailer, SendGridEmailer>(); services.AddTransient <IShopifyEventsEmailer, ShopifyEventsEmailer>(); #endregion services.AddMemoryCache(); var scopeFactory = services.BuildServiceProvider().GetRequiredService <IServiceScopeFactory>(); using (var scope = scopeFactory.CreateScope()) { var logger = scope.ServiceProvider.GetService <ILogger <Startup> >(); var isEmbeded = AppSettingsAccessor.IsUsingEmbededSdk(Configuration); logger.LogInformation($"Embeded app sdk usage is set to '{isEmbeded}'."); if (isEmbeded) { logger.LogInformation("Setting up cookie provider for temp data."); mvcBuilder.AddCookieTempDataProvider(x => x.Cookie.SameSite = SameSiteMode.None); logger.LogInformation("Done setting up temp data cookie provider."); logger.LogInformation("Setting up site cookie policy to 'SameSiteMode.None'."); services.ConfigureApplicationCookie(options => { options.Cookie.SameSite = SameSiteMode.None; }); logger.LogInformation("Done setting up cookie policy."); logger.LogInformation("Setting up anti forgery SuppressXFrameOptionsHeader = true."); services.AddAntiforgery(x => x.SuppressXFrameOptionsHeader = true); logger.LogInformation("Done setting up anti forgery."); } } }
private static void SeedSettingsData(ExicoShopifyDbContext exicoDbContext, IConfiguration config, ILogger logger) { if (!exicoDbContext.SystemSettings.Any()) { SettingsSeederAppModel settSeed = new SettingsSeederAppModel(); config.Bind("SettingsSeed", settSeed); logger.LogInformation("Seeding settings data {@data}.", settSeed); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "Account", Description = "Default account controller name without the controller part.", DisplayName = "Account controller", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.ACCOUNT_CONTOLLER.ToString(), Value = settSeed.ACCOUNT_CONTOLLER ?? "Account" }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "Dashboard", Description = "Default dashboard controller name without the controller part.", DisplayName = "Dashboard controller", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.DASHBOARD_CONTOLLER.ToString(), Value = settSeed.DASHBOARD_CONTOLLER ?? "Dashboard" }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "MyProfile", Description = "Default my profile controller name without the controller part.", DisplayName = "My profile controller", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.MY_PROFILE_CONTOLLER.ToString(), Value = settSeed.MY_PROFILE_CONTOLLER ?? "MyProfile", }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "Shopify", Description = "Default my Shopify controller name without the controller part.", DisplayName = "Shopify controller", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.SHOPIFY_CONTROLLER.ToString(), Value = settSeed.SHOPIFY_CONTROLLER ?? "Shopify", }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "AppUninstall", Description = "Default my app uninstall controller name without the controller part.", DisplayName = "App uninstall controller", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.UNINSTALL_CONTROLLER.ToString(), Value = settSeed.UNINSTALL_CONTROLLER ?? "Uninstall", }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "127.0.0.1", Description = "List of privileged ip addresses.Use comma for multiples.", DisplayName = "Privileged IPs", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.PRIVILEGED_IPS.ToString(), Value = settSeed.PRIVILEGED_IPS ?? "127.0.0.1", }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "Welcome to the app!", Description = "A welcome message template for new users.It can contain HTML.", DisplayName = "Welcome Message", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.WELCOME_EMAIL_TEMPLATE.ToString(), Value = settSeed.WELCOME_EMAIL_TEMPLATE ?? "Welcome to the app!", }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "*****@*****.**", Description = "App support email address.", DisplayName = "Support Email", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.APP_SUPPORT_EMAIL_ADDRESS.ToString(), Value = settSeed.APP_SUPPORT_EMAIL_ADDRESS ?? "" }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "shopiyfy ap key", Description = "API key of your shopify app.", DisplayName = "API Key", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.API_KEY.ToString(), Value = settSeed.API_KEY ?? "" }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "exicoShopifyFramework", Description = "App name same as shopify app store.", DisplayName = "App Name", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.APP_NAME.ToString(), Value = settSeed.APP_NAME ?? "" }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "https://*****:*****@myapp.com", Description = "Email address that will be used as from address.", DisplayName = "From Email", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.SHOPIFY_EMAILS_FROM_ADDRESS.ToString(), Value = settSeed.SHOPIFY_EMAILS_FROM_ADDRESS ?? "" }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "*****@*****.**", Description = "Emaile address that will receive any emails generated by the app/framework.Use comma for multiples.", DisplayName = "Subscribers", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.SHOPIFY_EVENT_EMAIL_SUBSCRIBERS.ToString(), Value = settSeed.SHOPIFY_EVENT_EMAIL_SUBSCRIBERS ?? "" }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "1.0.0", Description = "Version of your app", DisplayName = "Version", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.APP_VERSION.ToString(), Value = settSeed.APP_VERSION ?? "1.0.0" }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "0.0.0", Description = "Version of the Exico Shopify Framework that created this database", DisplayName = "Seeder Framework Version", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.SEEDER_FRAMEWORK_VERSION.ToString(), Value = AppSettingsAccessor.GetFrameWorkBuildNumber(true) }); exicoDbContext.SystemSettings.Add(new SystemSetting() { DefaultValue = "", Description = "Default auser password salt", DisplayName = "User Password Salt", GroupName = "CORE", SettingName = CORE_SYSTEM_SETTING_NAMES.PASSWORD_SALT.ToString(), Value = Guid.NewGuid().ToString() }); var total = exicoDbContext.SaveChanges(); logger.LogInformation($"Finished seeding settings data. Total {total} records."); } else { logger.LogInformation("Settings data alraedy exists.Skipping seeding for settings data."); } }