private bool TestPermission() { string str; errorMsgs = new List <string>(); try { Configuration configuration = WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath); if (configuration.ConnectionStrings.ConnectionStrings["Entities"].ConnectionString != "none") { configuration.ConnectionStrings.ConnectionStrings["Entities"].ConnectionString = "none"; } else { configuration.ConnectionStrings.ConnectionStrings["Entities"].ConnectionString = "required"; } configuration.Save(); } catch (Exception exception) { errorMsgs.Add(exception.Message); } if (!InstallerController.TestFolder(base.Request.MapPath(string.Concat(base.Request.ApplicationPath, "/storage/test.txt")), out str)) { errorMsgs.Add(str); } return(errorMsgs.Count == 0); }
private bool ExecuteScriptFile(string pathToScriptFile, out string errorMsg) { StreamReader streamReader = null; DbConnection dbConnection = null; string applicationPath = base.Request.ApplicationPath; StreamReader streamReader1 = new StreamReader(pathToScriptFile); streamReader = streamReader1; using (streamReader1) { SqlConnection mySqlConnection = new SqlConnection(GetConnectionString()); dbConnection = mySqlConnection; using (mySqlConnection) { DbCommand dbCommand = dbConnection.CreateCommand(); dbCommand.Connection = dbConnection; dbCommand.CommandType = CommandType.Text; dbCommand.CommandTimeout = 360; dbConnection.Open(); while (!streamReader.EndOfStream) { try { string str = InstallerController.NextSqlFromStream(streamReader); if (!string.IsNullOrEmpty(str)) { dbCommand.CommandText = str.Replace("$VirsualPath$", applicationPath); dbCommand.ExecuteNonQuery(); } } catch (Exception exception) { throw new Exception(exception.Message); } } dbConnection.Close(); } streamReader.Close(); } errorMsg = null; return(true); }