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.Common.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.Common.RegisterModule.Common.ModuleFolder + '\\' + module.FolderName;
                                    module.InstalledFolderPath = moduleInstalledPath;
                                }
                                else
                                {
                                    ShowMessage(SageMessageTitle.Exception.ToString(), GetSageMessage("Extensions", "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", "ModuleExtensionIsUninstallError"), "", SageMessageType.Alert);
                            }
                            else
                            {
                                string ExtensionMessage = GetSageMessage("Extensions", "ModuleExtensionIsUninstalledSuccessfully");
                                ProcessCancelRequestBase(Request.RawUrl, true, ExtensionMessage);
                            }
                        }
                        else
                        {
                            ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ThisPackageIsNotValid"), "", SageMessageType.Alert);
                        }
                    }
                    else
                    {
                        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ThisPackageDoesNotAppearToHaveManifestFile"), "", SageMessageType.Alert);
                    }
                }
                else
                {
                    ShowMessage(SageMessageTitle.Exception.ToString(), GetSageMessage("Extensions", "ModuleFolderDoesnotExist"), "", SageMessageType.Error);
                }
            }
        }
        private void UninstallModule(ModuleInfo moduleInfo, bool deleteModuleFolder)
        {
            Installers installerClass = new Installers();
            string path = HttpContext.Current.Server.MapPath("~/");

            //checked if directory exist for current module foldername
            string moduleFolderPath = path +"modules\\"+ moduleInfo.FolderName;
            if (!string.IsNullOrEmpty(moduleFolderPath))
            {
                if (Directory.Exists(moduleFolderPath))
                {
                    //check for valid .sfe file exist or not
                    string fileName = installerClass.checkFormanifestFile(moduleFolderPath, moduleInfo);
                    if (fileName != "")
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.Load(moduleFolderPath + '\\' + fileName);
                        XmlElement root = doc.DocumentElement;
                        if (installerClass.checkValidManifestFile(root, moduleInfo))
                        {
                            XmlNodeList xnList = doc.SelectNodes("sageframe/folders/folder");
                            foreach (XmlNode xn in xnList)
                            {
                                moduleInfo.ModuleName = xn["modulename"].InnerXml.ToString();
                                moduleInfo.FolderName = xn["foldername"].InnerXml.ToString();

                                
                            }
                            try
                            {
                                if (moduleInfo.ModuleID > 0)
                                {
                                    //Run script  
                                    ReadUninstallScriptAndDLLFiles(doc, moduleFolderPath, installerClass);
                                   
                                    if (deleteModuleFolder == true)
                                    {
                                        //Delete Module's Folder
                                        //installerClass.DeleteTempDirectory(moduleInfo.InstalledFolderPath);
                                        Directory.Delete(moduleFolderPath, true);
                                       
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Exceptions = ex.Message;
                            }

                            if (Exceptions != string.Empty)
                            {
                                ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ModuleExtensionIsUninstallError"), "", SageMessageType.Alert);
                            }
                            else
                            {
                                string ExtensionMessage = GetSageMessage("Extensions", "ModuleExtensionIsUninstalledSuccessfully");
                                //UninstallProcessCancelRequestBase(Request.RawUrl, true, ExtensionMessage);
                            }
                        }
                        else
                        {
                            ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ThisPackageIsNotValid"), "", SageMessageType.Alert);
                            if (Directory.Exists(moduleFolderPath))
                            {
                                Directory.Delete(moduleFolderPath, true);
                            }
                        }
                    }
                    else
                    {
                        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ThisPackageDoesNotAppearToBeValid"), "", SageMessageType.Alert);
                        if (Directory.Exists(moduleFolderPath))
                        {
                            Directory.Delete(moduleFolderPath, true);
                        }
                    }
                }
                else
                {
                    if (Directory.Exists(moduleFolderPath))
                    {
                        Directory.Delete(moduleFolderPath, true);
                    }
                    ShowMessage(SageMessageTitle.Exception.ToString(), GetSageMessage("Extensions", "ModuleFolderDoesnotExist"), "", SageMessageType.Error);
                }
            }
        }