private int RunScenario(string scenarioPath, InstallationInfo inst, bool throwExceptions) { // load XML document XmlDocument docScenario = new XmlDocument(); docScenario.Load(scenarioPath); // go through "check" section XmlNode nodeCheck = docScenario.SelectSingleNode("//check"); if (nodeCheck != null) { foreach (XmlNode nodeStep in nodeCheck.ChildNodes) { if (nodeStep.Name == "fileExists") { /* * // check if the specified file exists * string fileName = nodeStep.Attributes["path"].Value; * fileName = ExpandVariables(fileName, inst); * if (fileName.StartsWith("\\")) * { * fileName = fileName.Substring(1); * } * //get full path to instal folder * PackageInfo package = PackageController.GetPackage(inst.PackageId); * string fullPath = Path.Combine(GetFullPathToInstallFolder(package.UserId), fileName); * if (os.FileExists(fullPath)) * return BusinessErrorCodes.ERROR_WEB_INSTALLER_TARGET_WEBSITE_UNSUITABLE; */ } else if (nodeStep.Name == "sql") { string cmdText = nodeStep.InnerText; cmdText = ExpandVariables(cmdText, inst); DataSet dsResults = sql.ExecuteSqlQuery(inst.DatabaseName, cmdText); if (dsResults.Tables[0].Rows.Count > 0) { return(BusinessErrorCodes.ERROR_WEB_INSTALLER_TARGET_DATABASE_UNSUITABLE); } } } } // go through "commands" section XmlNode nodeCommands = docScenario.SelectSingleNode("//commands"); if (nodeCommands != null) { foreach (XmlNode nodeCommand in nodeCommands.ChildNodes) { if (nodeCommand.Name == "processFile") { // process remote file string fileName = nodeCommand.Attributes["path"].Value; fileName = ExpandVariables(fileName, inst); byte[] fileBinaryContent = FilesController.GetFileBinaryContent(inst.PackageId, fileName); if (fileBinaryContent == null) { throw new Exception("Could not process scenario file: " + fileName); } string fileContent = Encoding.UTF8.GetString(fileBinaryContent); fileContent = ExpandVariables(fileContent, inst); FilesController.UpdateFileBinaryContent(inst.PackageId, fileName, Encoding.UTF8.GetBytes(fileContent)); } else if (nodeCommand.Name == "runSql") { string cmdText = nodeCommand.InnerText; if (nodeCommand.Attributes["path"] != null) { // load SQL from file string sqlPath = Path.Combine(app.Folder, nodeCommand.Attributes["path"].Value); if (!File.Exists(sqlPath)) { continue; } StreamReader reader = new StreamReader(sqlPath); cmdText = reader.ReadToEnd(); reader.Close(); } bool run = true; if (nodeCommand.Attributes["dependsOnProperty"] != null) { string[] propNames = nodeCommand.Attributes["dependsOnProperty"].Value.Split(','); foreach (string propName in propNames) { if (inst[propName.Trim()] == null) { run = false; break; } } } if (run) { try { cmdText = ExpandVariables(cmdText, inst); sql.ExecuteSqlNonQuerySafe(inst.DatabaseName, inst.Username, inst.Password, cmdText); } catch (Exception ex) { if (throwExceptions) { throw ex; } } } } } } return(0); }