protected virtual bool BatchSql(PaFile sqlFile) { bool WasSuccessful = true; InstallerInfo.Log.StartJob(string.Format(SQL_BeginFile, sqlFile.Name)); string strScript = ""; switch (sqlFile.Encoding) { case PaTextEncoding.UTF16LittleEndian: strScript = GetAsciiString(sqlFile.Buffer, Encoding.Unicode); //System.Text.Encoding.Unicode.GetString(sqlFile.Buffer) break; case PaTextEncoding.UTF16BigEndian: strScript = GetAsciiString(sqlFile.Buffer, Encoding.BigEndianUnicode); //System.Text.Encoding.BigEndianUnicode.GetString(sqlFile.Buffer) break; case PaTextEncoding.UTF8: strScript = GetAsciiString(sqlFile.Buffer, Encoding.UTF8); //System.Text.Encoding.UTF8.GetString(sqlFile.Buffer) break; case PaTextEncoding.UTF7: strScript = GetAsciiString(sqlFile.Buffer, Encoding.UTF7); //System.Text.Encoding.UTF7.GetString(sqlFile.Buffer) break; case PaTextEncoding.Unknown: throw (new Exception(string.Format(SQL_UnknownFile, sqlFile.Name))); } //This check needs to be included because the unicode Byte Order mark results in an extra character at the start of the file //The extra character - '?' - causes an error with the database. if (strScript.StartsWith("?")) { strScript = strScript.Substring(1); } // execute SQL installation script //TODO: Transactions are removed temporarily. string strSQLExceptions = PortalSettings.ExecuteScript(strScript, false); if (!String.IsNullOrEmpty(strSQLExceptions)) { InstallerInfo.Log.AddFailure(string.Format(SQL_Exceptions, "\r\n", strSQLExceptions)); WasSuccessful = false; } InstallerInfo.Log.EndJob(string.Format(SQL_EndFile, sqlFile.Name)); return(WasSuccessful); }
/// <summary> /// cmdDelete_Click runs when the Delete Button is clicked /// </summary> /// <history> /// [cnurse] 9/28/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> protected void cmdDelete_Click(object sender, EventArgs e) { try { if (!Null.IsNull(DesktopModuleId)) { string strRoot = Request.MapPath("~/DesktopModules/" + txtFolderName.Text) + "\\"; // process uninstall script string strProviderType = "data"; ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration(strProviderType); string strUninstallScript = "Uninstall." + objProviderConfiguration.DefaultProvider; if (File.Exists(strRoot + strUninstallScript)) { // read uninstall script StreamReader objStreamReader; objStreamReader = File.OpenText(strRoot + strUninstallScript); string strScript = objStreamReader.ReadToEnd(); objStreamReader.Close(); // execute uninstall script PortalSettings.ExecuteScript(strScript); } if (Directory.Exists(strRoot)) { if (chkDelete.Checked) { //runtime so remove files/folders // find dnn manifest file string[] arrFiles = Directory.GetFiles(strRoot, "*.dnn.config"); if (arrFiles.Length == 0) { arrFiles = Directory.GetFiles(strRoot, "*.dnn"); // legacy versions stored the *.dnn files unprotected } if (arrFiles.Length != 0) { if (File.Exists(strRoot + Path.GetFileName(arrFiles[0]))) { XmlDocument xmlDoc = new XmlDocument(); // load the manifest file xmlDoc.Load(strRoot + Path.GetFileName(arrFiles[0])); // check version XmlNode myNodeModule = null; switch (xmlDoc.DocumentElement.LocalName.ToLower()) { case "module": myNodeModule = xmlDoc.SelectSingleNode("//module"); break; case "dotnetnuke": string version = xmlDoc.DocumentElement.Attributes["version"].InnerText; switch (version) { case "2.0": // V2 allows for multiple folders in a single DNN definition - we need to identify the correct node foreach (XmlNode nodeModule in xmlDoc.SelectNodes("//dotnetnuke/folders/folder")) { if (nodeModule.SelectSingleNode("name").InnerText.Trim() == txtFriendlyName.Text) { myNodeModule = nodeModule; break; } } break; case "3.0": // V3 also allows for multiple folders in a single DNN definition - but uses module name foreach (XmlNode nodeModule in xmlDoc.SelectNodes("//dotnetnuke/folders/folder")) { if (nodeModule.SelectSingleNode("name").InnerText.Trim() == txtModuleName.Text) { myNodeModule = nodeModule; break; } } break; } break; } // loop through file nodes foreach (XmlNode nodeFile in myNodeModule.SelectNodes("files/file")) { string strFileName = nodeFile.SelectSingleNode("name").InnerText.Trim(); string strFileExtension = Path.GetExtension(strFileName).Replace(".", ""); if (strFileExtension == "dll") { // remove DLL from /bin strFileName = Request.MapPath("~/bin/") + strFileName; } if (File.Exists(strFileName)) { File.SetAttributes(strFileName, FileAttributes.Normal); File.Delete(strFileName); } } //Recursively Delete any sub Folders DeleteSubFolders(strRoot, true); //Recursively delete AppCode folders string appCode = strRoot.Replace("DesktopModules", "App_Code"); DeleteSubFolders(appCode, true); //Delete the <codeSubDirectory> node in web.config Config.RemoveCodeSubDirectory(txtFolderName.Text); } } } } // delete the desktopmodule database record DesktopModuleController objDesktopModules = new DesktopModuleController(); objDesktopModules.DeleteDesktopModule(DesktopModuleId); } Response.Redirect(Globals.NavigateURL(), true); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }