private void UninstallModule() { ModuleInfo module = new ModuleInfo(); Installers installerClass = new Installers(); string path = HttpContext.Current.Server.MapPath("~/"); //checked if directory exist for current module foldername if (!string.IsNullOrEmpty(txtFolderName.Text)) { string moduleFolderPath = path + SageFrame.Core.RegisterModule.Common.ModuleFolder + '\\' + txtFolderName.Text; if (Directory.Exists(moduleFolderPath)) { //check for valid .sfe file exist or not if (installerClass.checkFormanifestFile(moduleFolderPath, module) != "") { XmlDocument doc = new XmlDocument(); doc.Load(moduleFolderPath + '\\' + module.ManifestFile); XmlElement root = doc.DocumentElement; if (installerClass.checkValidManifestFile(root, module)) { XmlNodeList xnList = doc.SelectNodes("sageframe/folders/folder"); foreach (XmlNode xn in xnList) { module.ModuleName = xn["modulename"].InnerXml.ToString(); module.FolderName = xn["foldername"].InnerXml.ToString(); if (!String.IsNullOrEmpty(module.ModuleName) && !String.IsNullOrEmpty(module.FolderName) && hdnModuleName.Value == module.ModuleName && txtFolderName.Text == module.FolderName && installerClass.IsModuleExist(module.ModuleName.ToLower(), module)) { string moduleInstalledPath = path + SageFrame.Core.RegisterModule.Common.ModuleFolder + '\\' + module.FolderName; module.InstalledFolderPath = moduleInstalledPath; } else { ShowMessage(SageMessageTitle.Exception.ToString(), GetSageMessage("Extensions_Editors", "ThisModuleSeemsToBeCorrupted"), "", SageMessageType.Error); } } try { if (module.ModuleID > 0) { //Run script ReadUninstallScriptAndDLLFiles(doc, module.InstalledFolderPath, installerClass); //Rollback moduleid installerClass.ModulesRollBack(module.ModuleID, GetPortalID); //Delete Module's Folder installerClass.DeleteTempDirectory(module.InstalledFolderPath); } } catch (Exception ex) { Exceptions = ex.Message; } if (Exceptions != string.Empty) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions_Editors", "ModuleExtensionIsUninstallError"), "", SageMessageType.Alert); } else { string ExtensionMessage = GetSageMessage("Extensions_Editors", "ModuleExtensionIsUninstalledSuccessfully"); ProcessCancelRequestBase(Request.RawUrl, true, ExtensionMessage); } } else { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions_Editors", "ThisPackageIsNotValid"), "", SageMessageType.Alert); } } else { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions_Editors", "ThisPackageDoesNotAppearToHaveManifestFile"), "", SageMessageType.Alert); } } else { ShowMessage(SageMessageTitle.Exception.ToString(), GetSageMessage("Extensions_Editors", "ModuleFolderDoesnotExist"), "", SageMessageType.Error); } } }
protected void wizInstall_NextButtonClick(object sender, WizardNavigationEventArgs e) { int activeIndex = 0; if (!IsModuleExist(Path.GetFileNameWithoutExtension(hdnFileName.Value))) { try { switch (e.CurrentStepIndex) { case 0: //Upload Page string filename = hdnFileName.Value; ArrayList arrColl = installhelp.Step0CheckLogic(filename); int ReturnValue; if (arrColl != null && arrColl.Count > 0) { if ((bool)arrColl[2]) { compositeModule = (CompositeModule)arrColl[1]; compositeModule = installhelp.fillCompositeModuleInfo(compositeModule); ViewState["CompositeModule"] = compositeModule; } else { module = (ModuleInfo)arrColl[1]; ViewState["ModuleInfo"] = module; } ReturnValue = (int)arrColl[0]; if (ReturnValue == 1) { BindPackage(); activeIndex = 2; break; } else if (ReturnValue == 2) { activeIndex = 1; BindPackage(); break; } else if (ReturnValue == 3) { lblLoadMessage.Text = GetSageMessage("Extensions", "ThisPackageIsNotValid"); lblLoadMessage.Visible = true; e.Cancel = true; activeIndex = 0; break; } else if (ReturnValue == 4) { lblLoadMessage.Text = GetSageMessage("Extensions", "ThisPackageDoesNotAppearToBeValid"); lblLoadMessage.Visible = true; e.Cancel = true; activeIndex = 0; break; } else { lblLoadMessage.Text = GetSageMessage("Extensions", "ThereIsErrorWhileInstallingThisModule"); lblLoadMessage.Visible = true; e.Cancel = true; activeIndex = 0; break; } } break; case 1: //Warning Page if (chkRepairInstall.Checked) { if (ViewState["CompositeModule"] != null) { CompositeModule tmpcompositeModule = (CompositeModule)ViewState["CompositeModule"]; this.lblLicense.Text = tmpcompositeModule.License; this.lblReleaseNotes.Text = tmpcompositeModule.ReleaseNotes; foreach (Component component in tmpcompositeModule.Components) { if (component.IsChecked) { bool isexist = installhelp.IsModuleExist(component.Name); if (isexist) { ModuleInfo objModule = installhelp.GetModuleByName(component.Name); if ((objModule != null)) { string path = HttpContext.Current.Server.MapPath("~/"); string targetPath = path + SageFrame.Common.RegisterModule.Common.ModuleFolder + '\\' + objModule.FolderName; objModule.InstalledFolderPath = targetPath; UninstallModule(objModule, true); } } } } } else { module = (ModuleInfo)ViewState["ModuleInfo"]; UninstallModule(module, true); } activeIndex = 2; } else { UninstallModule(module, false); activeIndex = 1; } if (ViewState["CompositeModule"] != null) { compositeModule = (CompositeModule)ViewState["CompositeModule"]; activeIndex = 3; } else { module = (ModuleInfo)ViewState["ModuleInfo"]; } break; case 2: Panel pnl = (Panel)this.Step2.FindControl("pnlPackage"); GridView grd = (GridView)pnl.FindControl("gdvModule"); string existingModules = string.Empty; bool IsErrorFlag = false; foreach (GridViewRow row in grd.Rows) { CheckBox cbInstall = (CheckBox)row.FindControl("cbInstall"); if (cbInstall.Checked == true) { Label lbl = (Label)row.FindControl("lblname"); if (ViewState["CompositeModule"] != null) { CompositeModule tmpcompositeModule = (CompositeModule)ViewState["CompositeModule"]; this.lblLicense.Text = tmpcompositeModule.License; this.lblReleaseNotes.Text = tmpcompositeModule.ReleaseNotes; foreach (Component component in tmpcompositeModule.Components) { if (component.Name.Equals(lbl.Text)) { component.IsChecked = true; bool isexist = installhelp.IsModuleExist(component.Name.ToLower()); if (isexist) { IsErrorFlag = true; existingModules += component.Name + ", "; } break; } } ViewState["CompositeModule"] = tmpcompositeModule; } } else { Label lbl = (Label)row.FindControl("lblname"); if (ViewState["CompositeModule"] != null) { CompositeModule compositeModule = (CompositeModule)ViewState["CompositeModule"]; foreach (Component component in compositeModule.Components) { if (component.Name.Equals(lbl.Text)) { if (!installhelp.IsModuleExist(component.Name.ToLower())) { installhelp.AddAvailableModules(compositeModule.TempFolderPath, component); break; } } } } } } if (IsErrorFlag) { string existingModuleName = existingModules.Substring(0, existingModules.LastIndexOf(",")); ShowMessage("Modules " + existingModuleName + " already exists", "Modules " + existingModuleName + " already exists", "Modules " + existingModuleName + " already exists", SageMessageType.Error); activeIndex = 1; BindPackage(); IsErrorFlag = false; break; } activeIndex = 3; break; case 3: activeIndex = 4; break; case 4: //Accept Terms if (chkAcceptLicense.Checked) { if (ViewState["CompositeModule"] != null) { ModuleInfo moduleInfo = null; compositeModule = (CompositeModule)ViewState["CompositeModule"]; bool confirmationFlag = true; foreach (Component component in compositeModule.Components) { if (component.IsChecked) { ArrayList list = installhelp.Step0CheckLogic(component.ZipFile, compositeModule.TempFolderPath); moduleInfo = (ModuleInfo)list[1]; installhelp.fillModuleInfo(moduleInfo); installhelp.InstallPackage(moduleInfo); if (moduleInfo.ModuleID < 0) { confirmationFlag = false; InstallConfirmation(moduleInfo, ref activeIndex); } } } if (confirmationFlag && moduleInfo != null) { InstallConfirmation(moduleInfo, ref activeIndex); } } else if ((ModuleInfo)ViewState["ModuleInfo"] != null) { module = (ModuleInfo)ViewState["ModuleInfo"]; installhelp.InstallPackage(module); InstallConfirmation(module, ref activeIndex); } activeIndex = 5; } else { lblAcceptMessage.Text = GetSageMessage("Extensions", "AcceptThePackageLicenseAgreementFirst"); e.Cancel = true; activeIndex = 4; } break; } wizInstall.ActiveStepIndex = activeIndex; } catch (Exception ex) { ProcessException(ex); } } else { lblLoadMessage.Text = GetSageMessage("Extensions", "ModuleAlreadyInstall"); lblLoadMessage.Visible = true; e.Cancel = true; activeIndex = 0; string downloadpath = Server.MapPath(string.Format("~/Install/Temp/{0}", hdnFileName.Value)); if (File.Exists(downloadpath)) { File.Delete(downloadpath); } } }