private string ImportControl(string controlSrc) { string ExtensionMessage = string.Empty; if (!string.IsNullOrEmpty(controlSrc)) { DropDownList ddlFirst = ((DropDownList)PackageDetails1.FindControl("ddlFirst")); DropDownList ddlSecond = ((DropDownList)PackageDetails1.FindControl("ddlSecond")); DropDownList ddlLast = ((DropDownList)PackageDetails1.FindControl("ddlLast")); DropDownList ddlIcon = ((DropDownList)ModuleControlsDetails1.FindControl("ddlIcon")); TextBox txtKey = ((TextBox)ModuleControlsDetails1.FindControl("txtKey")); TextBox txtTitle = ((TextBox)ModuleControlsDetails1.FindControl("txtTitle")); TextBox txtHelpURL = ((TextBox)ModuleControlsDetails1.FindControl("txtHelpURL")); TextBox txtDisplayOrder = ((TextBox)ModuleControlsDetails1.FindControl("txtDisplayOrder")); CheckBox chkSupportsPartialRendering = ((CheckBox)ModuleControlsDetails1.FindControl("chkSupportsPartialRendering")); DropDownList ddlType = ((DropDownList)ModuleControlsDetails1.FindControl("ddlType")); ModuleInfo objModule = new ModuleInfo(); Installers install = new Installers(); try { string folder = RemoveTrailingSlash(GetSourceFolder()); string friendlyName = PackageDetails1.PackageName; string name = GetClassName(); string moduleControl = "Modules/" + folder + "/" + controlSrc; //add module and package tables objModule.ModuleName = name; objModule.Name = name; objModule.FriendlyName = friendlyName; objModule.Description = PackageDetails1.Description; objModule.FolderName = folder; objModule.Version = ddlFirst.SelectedValue + "." + ddlSecond.SelectedValue + "." + ddlLast.SelectedValue;//"01.00.00"; //new Version(1, 0, 0); objModule.Owner = PackageDetails1.Owner; objModule.Organization = PackageDetails1.Organization; objModule.URL = PackageDetails1.Url; objModule.Email = PackageDetails1.Email; objModule.ReleaseNotes = PackageDetails1.ReleaseNotes; objModule.License = PackageDetails1.License; objModule.PackageType = "Module"; objModule.isPremium = true; objModule.supportedFeatures = 0; objModule.BusinessControllerClass = ""; objModule.CompatibleVersions = ""; objModule.dependencies = ""; objModule.permissions = ""; ModuleController objController = new ModuleController(); try { int[] outputValue; outputValue = objController.AddModules(objModule, false, 0, true, DateTime.Now, GetPortalID, GetUsername); objModule.ModuleID = outputValue[0]; objModule.ModuleDefID = outputValue[1]; _newModuleID = objModule.ModuleID; _newModuleDefID = objModule.ModuleDefID; } catch (Exception ex) { ProcessException(ex); } try { //insert into ProtalModule table _newPortalmoduleID = objController.AddPortalModules(GetPortalID, _newModuleID, true, DateTime.Now, GetUsername); } catch (Exception ex) { ProcessException(ex); } //install permission for the installed module in ModuleDefPermission table with ModuleDefID and PermissionID try { // get the default module VIEW permissions int _permissionIDView = objController.GetPermissionByCodeAndKey("SYSTEM_VIEW", "VIEW"); objController.AddModulePermission(_newModuleDefID, _permissionIDView, GetPortalID, _newPortalmoduleID, true, GetUsername, true, DateTime.Now, GetUsername); int _permissionIDEdit = objController.GetPermissionByCodeAndKey("SYSTEM_EDIT", "EDIT"); objController.AddModulePermission(_newModuleDefID, _permissionIDEdit, GetPortalID, _newPortalmoduleID, true, GetUsername, true, DateTime.Now, GetUsername); } catch (Exception ex) { Exceptions += ex.Message; } try { //Logic for modulecontrol installation string _moduleControlKey = txtKey.Text; string _moduleControlTitle = txtTitle.Text; string _moduleControlSrc = moduleControl; string _moduleControlHelpUrl = txtHelpURL.Text; bool _moduleSupportsPartialRendering = chkSupportsPartialRendering.Checked; int _controlType = int.Parse(ddlType.SelectedItem.Value); string _iconFile = ""; if (ddlIcon.SelectedIndex != -1) { _iconFile = ddlIcon.SelectedItem.Value; } int _displayOrder = int.Parse(txtDisplayOrder.Text); _moduleControlID = objController.AddModuleCoontrols(_newModuleDefID, _moduleControlKey, _moduleControlTitle, _moduleControlSrc, _iconFile, _controlType, _displayOrder, _moduleControlHelpUrl, _moduleSupportsPartialRendering, true, DateTime.Now, GetPortalID, GetUsername); ExtensionMessage = GetSageMessage("Extensions", "ModuleExtensionIsAddedSuccessfully"); } catch (Exception ex) { Exceptions = ex.Message; } if (Exceptions != string.Empty) { if (objModule.ModuleID > 0 && _newModuleDefID != null && _newModuleDefID > 0) { //Delete Module info from data base install.ModulesRollBack(objModule.ModuleID, GetPortalID); } } } catch { if (objModule.ModuleID > 0 && _newModuleDefID != null && _newModuleDefID > 0) { //Delete Module info from data base install.ModulesRollBack(objModule.ModuleID, GetPortalID); } } } return(ExtensionMessage); }
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); } } }
public void RegisterModule(string moduleName, string moduleFolderPath, string procedure) { ModuleInfo objModule = new ModuleInfo(); int _newModuleID = 0; int _newModuleDefID = 0; int _newPortalmoduleID = 0; string Exceptions = string.Empty; string ExtensionMessage = string.Empty; try { //add module and package tables objModule.ModuleName = moduleName; objModule.Name = moduleName; objModule.FriendlyName = moduleName; objModule.Description = txtModuleDescription.Text; objModule.FolderName = moduleName; objModule.Version = "01.00.00";//ddlFirst.SelectedValue + "." + ddlSecond.SelectedValue + "." + ddlLast.SelectedValue;//"01.00.00"; //new Version(1, 0, 0); objModule.Owner = ""; objModule.Organization = ""; objModule.URL = ""; objModule.Email = ""; objModule.ReleaseNotes = ""; objModule.License = ""; objModule.PackageType = "Module"; objModule.isPremium = true; objModule.supportedFeatures = 0; objModule.BusinessControllerClass = ""; objModule.CompatibleVersions = ""; objModule.dependencies = ""; objModule.permissions = ""; ModuleController objController = new ModuleController(); int[] outputValue; outputValue = objController.AddModules(objModule, false, 0, true, DateTimeHelper.GetUtcTime(DateTime.Now), GetPortalID, GetUsername); objModule.ModuleID = outputValue[0]; objModule.ModuleDefID = outputValue[1]; _newModuleID = objModule.ModuleID; _newModuleDefID = objModule.ModuleDefID; //insert into ProtalModule table _newPortalmoduleID = objController.AddPortalModules(GetPortalID, _newModuleID, true, DateTimeHelper.GetUtcTime(DateTime.Now), GetUsername); //install permission for the installed module in ModuleDefPermission table with ModuleDefID and PermissionID // get the default module VIEW permissions int _permissionIDView = objController.GetPermissionByCodeAndKey("SYSTEM_VIEW", "VIEW"); objController.AddModulePermission(_newModuleDefID, _permissionIDView, GetPortalID, _newPortalmoduleID, true, GetUsername, true, DateTimeHelper.GetUtcTime(DateTime.Now), GetUsername); int _permissionIDEdit = objController.GetPermissionByCodeAndKey("SYSTEM_EDIT", "EDIT"); objController.AddModulePermission(_newModuleDefID, _permissionIDEdit, GetPortalID, _newPortalmoduleID, true, GetUsername, true, DateTimeHelper.GetUtcTime(DateTime.Now), GetUsername); RegisterControl(moduleName, moduleFolderPath + moduleName + "/" + moduleName + ".ascx", 1, _newModuleDefID); if (chkEdit.Checked) { RegisterControl(moduleName, moduleFolderPath + moduleName + "/" + moduleName + "Edit" + ".ascx", 2, _newModuleDefID); } if (chkSetting.Checked) { RegisterControl(moduleName, moduleFolderPath + moduleName + "/" + moduleName + "Setting" + ".ascx", 3, _newModuleDefID); } if (Exceptions != string.Empty) { if (objModule.ModuleID > 0 && _newModuleDefID > 0) { Installers install = new Installers(); //Delete Module info from data base install.ModulesRollBack(objModule.ModuleID, GetPortalID); } } else { SQLHandler sageSQLHandler = new SQLHandler(); sageSQLHandler.ExecuteScript(procedure, true); } } catch (Exception ex) { ShowMessage("", ex.ToString(), "", SageMessageType.Error); ProcessException(ex); } Response.Redirect(Request.Url.AbsoluteUri); }