public ScriptProjectRunner(string scriptSourcePath, string connectionstring, bool encryptScripts, bool applyDataDirectory) { if (Message != null) Message("Starting Sql sync", Common.CommandLine.Log.SeverityLevel.Message); this.scriptSourcePath = scriptSourcePath; if (Message != null) Message("Path:" + scriptSourcePath, Common.CommandLine.Log.SeverityLevel.Message); this.scriptSource = GetScriptSource(scriptSourcePath); Global.ConnectionString = connectionstring; if (Message != null) Message("ConnectionString: " + connectionstring, Common.CommandLine.Log.SeverityLevel.Message); Global.ToolStarted = Time.Now; this.encryptScripts = encryptScripts; this.applyDataDirectory = applyDataDirectory; }
private static ScriptSource GetScriptSource(string path) { ScriptSource scriptSource; FileInfo fi = new FileInfo(path); if (!fi.Exists) { DirectoryInfo di = new DirectoryInfo(path); if (di.Exists) { FileInfo[] projectFiles = di.GetFiles("*.dbp"); if (projectFiles.Length == 1) { scriptSource = new DatabaseProjectScriptSource(projectFiles[0].FullName); } else { projectFiles = di.GetFiles("*.csproj"); if (projectFiles.Length == 1) { scriptSource = new CSharpProjectScriptSource(projectFiles[0].FullName); } else { scriptSource = new FolderStructureScriptSource(path); } } } else { throw new Exception(String.Format("Path {0} was not found", path)); } }else{ switch (fi.Extension) { case "dbp": scriptSource = new DatabaseProjectScriptSource(path); break; case "csproj": scriptSource = new CSharpProjectScriptSource(path); break; default: throw new Exception(String.Format("Unknown project type '{0}'", fi.Extension)); } } return scriptSource; }