public static IEnumerable <SchemaVersion> GetVersionsOnDisk(Installable app, string tenant) { var versions = new List <SchemaVersion>(); string directory = DatabaseConvention.GetRootDbDirectory(app, tenant); if (string.IsNullOrWhiteSpace(directory) || !Directory.Exists(directory)) { return(versions); } var directories = Directory.GetDirectories(directory, "*.update", SearchOption.TopDirectoryOnly); foreach (string path in directories) { string fileName = Path.GetFileName(path); string candidate = fileName.Or("").Replace(".update", ""); double value; double.TryParse(candidate, out value); if (value > 0) { versions.Add( new SchemaVersion { SchemaName = app.DbSchema, VersionNumber = candidate } ); } } return(versions); }
private static UpdateBase GetUpdater(string tenant, Installable app) { var site = TenantConvention.GetSite(tenant); if (site == null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Not an approved domain."); Console.ForegroundColor = ConsoleColor.White; return(null); } string providerName = site.DbProvider; switch (providerName) { case "Npgsql": return(new PostgresqlUpdater(tenant, app)); case "System.Data.SqlClient": return(new SqlServerUpdater(tenant, app)); default: throw new SchemaUpdaterException("Frapid schema updater does not support provider " + providerName); } }
public AppInstaller(string tenant, string database, bool withoutSample, Installable installable) { this.Tenant = tenant; this.Database = database; this.WithoutSample = withoutSample; this.Installable = installable; }
public UpdateCandidate(Installable app, string tenant) { this.AppInfo = app; this.AllVersions = VersionInvestigator.GetVersionsOnDisk(app, tenant); this.InstalledVersions = VersionManager.GetVersions(tenant, app.DbSchema); this.VersionToUpdate = this.AllVersions.OrderByDescending(x => x.VersionNumber.To <double>()).FirstOrDefault(); this.PathToUpdateFile = VersionPathConvention.GetFilePath(app, tenant, this.VersionToUpdate); }
public void Uninstall() { if (installedObject == null) { Debug.Log("Could not Uninstall() from Tile (" + X + ", " + Y + ") because it has no object installed."); return; } installedObject.OnUninstall(); installedObject = null; }
public static async Task <string> UpdateAsync(string tenant, Installable app) { var updater = GetUpdater(tenant, app); if (updater != null) { return(await updater.UpdateAsync().ConfigureAwait(false)); } return($"Could not install updates for {app.ApplicationName} due to errors."); }
public void Install(Installable installable) { if (installedObject != null) { Debug.Log("Could not install" + installable.name + " because Tile (" + X + ", " + Y + ") already has " + installedObject.name + " installed."); return; } installable.OnInstall(); installable.transform.position = obj.transform.position; installedObject = installable; }
public static string GetFilePath(Installable app, string tenant, SchemaVersion version) { if (version == null) { return(string.Empty); } string directory = DatabaseConvention.GetRootDbDirectory(app, tenant); directory = Path.Combine(directory, version.VersionNumber + ".update"); string updateFile = Directory.GetFiles(directory, "*.update.sql", SearchOption.TopDirectoryOnly).FirstOrDefault(); return(updateFile); }
public static void InstallSystem(bool reset) { var notInstalled = Installable.InstallAll(GetInstallables, reset); if (notInstalled.Count > 0) { var names = from module in notInstalled let type = module.Key.GetType() let errorType = module.Value.GetType() let errorMessage = module.Value.Message select $"\n\t[{type.Name}] {errorType.Name}: {errorMessage}"; var nameList = string.Join("", names); Debug.LogError("Juniper: ERROR: components were not installed correctly." + nameList); } }
public static string GetRootDbDirectory(Installable app, string tenant) { string dbms = DbServerUtility.GetDbmsName(tenant); string dbPath = PathMapper.MapPath(app.BlankDbPath.Or(string.Empty).Replace("{DbServer}", dbms)); try { return(new FileInfo(dbPath).DirectoryName); } catch (DirectoryNotFoundException) { Log.Warning("The app {ApplicationName} does not have {dbms} implementation.", app.ApplicationName, dbms); } return(string.Empty); }
private void CreateResource(Installable app) { Console.WriteLine("Creating resource on " + app.ApplicationName); var approved = new ApprovedDomainSerializer().Get().FirstOrDefault(); if (approved == null) { return; } string tenant = TenantConvention.GetTenant(approved.DomainName); var writer = new ResourceWriter(tenant, app); writer.WriteAsync().GetAwaiter().GetResult(); }
private static UpdateBase GetUpdater(string tenant, Installable app) { var site = TenantConvention.GetSite(tenant); string providerName = site.DbProvider; switch (providerName) { case "Npgsql": return(new PostgresqlUpdater(tenant, app)); case "System.Data.SqlClient": return(new SqlServerUpdater(tenant, app)); default: throw new SchemaUpdaterException("Frapid schema updater does not support provider " + providerName); } }
private void OnAddClick(object sender, RoutedEventArgs e) { _ = MainWindow.GetMainWindow.ChangeCurrentControl(new ServerList()); ComboBox comboBox = Items[0] as ComboBox; string key = comboBox.SelectedValue as string; Installable installable = Initializer.Installables[key]; string path = Path.Combine(GlobalConfig.ServersPath, ServerName.Text); if (Directory.Exists(path)) { return; } _ = Initializer.CreateServer(path, installable.ServerType, installable.InstallAction); }
public ResourceWriter(string tenant, Installable app) { this.Tenant = tenant; this.App = app; }
public async Task <Dictionary <string, string> > GetResourcesAsync(string tenant, Installable app, string path) { var resources = new Dictionary <string, string>(); using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(tenant), tenant).GetDatabase()) { var sql = new Sql("SELECT i18n_key, menu_name FROM core.menus"); sql.Where("app_name=@0", app.ApplicationName); var columns = await db.SelectAsync <dynamic>(sql).ConfigureAwait(false); foreach (var column in columns) { string key = column.I18nKey; string value = column.MenuName; resources.Add(key, value); } } return(resources); }
public static async Task <string> UpdateAsync(string tenant, Installable app) { var updater = GetUpdater(tenant, app); return(await updater.UpdateAsync().ConfigureAwait(false)); }
public async Task <Dictionary <string, string> > GetResourcesAsync(string tenant, Installable app, string path) { var resources = new Dictionary <string, string>(); if (string.IsNullOrWhiteSpace(app.DbSchema)) { return(resources); } using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(tenant), tenant).GetDatabase()) { var sql = new Sql("SELECT DISTINCT column_name FROM information_schema.columns"); sql.Where("table_schema=@0", app.DbSchema); var columns = await db.SelectAsync <dynamic>(sql).ConfigureAwait(false); foreach (var column in columns) { string name = column.ColumnName; string key = name.ToPascalCase(); string value = name.ToSentence().ToTitleCaseSentence(); if (!resources.ContainsKey(key)) { resources.Add(key, value); } } } return(resources); }
public static void UninstallSystem() { Installable.UninstallAll(JuniperSystem.GetInstallables); }
public AppInstaller(string tenant, string database, Installable installable) { this.Tenant = tenant; this.Database = database; this.Installable = installable; }
public AppInstaller(string database, Installable installable) { this.Database = database; this.Installable = installable; }
public SqlServerUpdater(string tenant, Installable app) : base(tenant, app) { }
protected UpdateBase(string tenant, Installable app) { this.Tenant = tenant; this.App = app; this.Candidate = new UpdateCandidate(app, tenant); }
public AppInstaller(string catalog, Installable installable) { this.Catalog = catalog; this.Installable = installable; }
public async Task <Dictionary <string, string> > GetResourcesAsync(string tenant, Installable app, string path) { await Task.Delay(0).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(path)) { return(new Dictionary <string, string>()); } string contents = File.ReadAllText(path, Encoding.UTF8); var deserializer = new Deserializer(); return(deserializer.Deserialize <Dictionary <string, string> >(contents)); }
public static async Task <Dictionary <string, string> > GetResourcesAsync(string tenant, Installable app, string path) { var resources = new Dictionary <string, string>(); var readers = FindReaders(); foreach (var reader in readers) { resources.Merge(await reader.GetResourcesAsync(tenant, app, path).ConfigureAwait(false)); } return(resources); }
public PostgresqlUpdater(string tenant, Installable app) : base(tenant, app) { }