public void Build() { var cfgWriter = new BuildConfigurationWriter(_configFileName, _configLocalFileName); _configuration = cfgWriter.Read(); // load options DatabaseOptions dbopt = LoadDatabaseOptions(_configuration); List <string> codeFileNames = GetSortedCodeFileNames(_configuration, dbopt); var first = _configuration.GetFirstPatch(); if (first != null) { PluginManager pm = new PluginManager(); using (var db = pm.LoadDatabasePlugin(_configuration.DatabaseType)) { db.Connect(dbopt); var installedPatches = db.GetInstalledPatches(); //todo: if drop-all-sprocs-then-add-back option, then run drop all script //todo: add log/console output InstallPatch(first, db, installedPatches); // install code files InstallProgrammability(codeFileNames, db); } } }
public void AddPatch(string patchName, PatchOptions Options = null) { if (string.IsNullOrWhiteSpace(patchName)) { throw new ApplicationException("Patch Name required"); } else { var cfgWriter = new BuildConfigurationWriter(_configFileName, _configLocalFileName); var cfg = cfgWriter.Read(); // load options //DatabaseOptions dbopt = LoadDatabaseOptions(cfg); //create unique id prefix to avoid collisions string prefix = $"{DateTime.Now:yyyyMMddHHmm}-{_rand.Next(0, 9999):0000}"; // patch names are limited to 50 char total at present, but this could be a property of the plugin string finalId = $"{prefix}-{patchName.Trim()}"; finalId = finalId.Substring(0, Math.Min(50, finalId.Length)); string patchPath = _io.Path.Combine(cfg.PatchFolder, finalId); if (!_io.Directory.Exists(patchPath)) { _io.Directory.CreateDirectory(patchPath); // when adding a patch, make it dependent on all patches // that don't already have a dependency. // need to guard against circular dependencies var openPatches = cfg.GetOpenPatches(); cfg.patches.Add(new Patch(finalId, openPatches)); cfgWriter.Write(cfg); } else { // create custom exception throw new ApplicationException($"A folder named '{finalId}' already exists"); } } }