Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleStringId"></param>
        /// <returns></returns>
        public static bool UninstallModule(string moduleStringId)
        {
            var moduleInst = AttachedModules.GetModules(AttachedModules.EModuleType.All).FirstOrDefault(
                item =>
                ((IModule)Activator.CreateInstance(item, null)).ModuleStringId.ToLower() == Convert.ToString(moduleStringId).ToLower());

            if (moduleInst != null)
            {
                var module = ((IModule)Activator.CreateInstance(moduleInst, null));
                if (module.UninstallModule())
                {
                    ModulesRepository.UninstallModuleFromDb(module.ModuleStringId);
                }
                else
                {
                    return(false);
                }
            }

            if (Directory.Exists(HttpContext.Current.Server.MapPath("~/App_Code/Advantshop/Modules/" + moduleStringId)))
            {
                Directory.Delete(HttpContext.Current.Server.MapPath("~/App_Code/Advantshop/Modules/" + moduleStringId), true);
            }
            if (Directory.Exists(HttpContext.Current.Server.MapPath("~/Modules/" + moduleStringId)))
            {
                Directory.Delete(HttpContext.Current.Server.MapPath("~/Modules/" + moduleStringId), true);
            }
            return(true);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleStringId"></param>
        /// <returns></returns>
        public static bool UninstallModule(string moduleStringId)
        {
            var moduleInst = AttachedModules.GetModules().FirstOrDefault(
                item =>
                ((IModule)Activator.CreateInstance(item, null)).ModuleStringId.ToLower() == SQLDataHelper.GetString(moduleStringId).ToLower());

            if (moduleInst != null)
            {
                var module = ((IModule)Activator.CreateInstance(moduleInst, null));
                if (module.UninstallModule())
                {
                    ModulesRepository.UninstallModuleFromDb(module.ModuleStringId);
                }
                else
                {
                    return(false);
                }
            }

            FileHelpers.DeleteDirectory(HttpContext.Current.Server.MapPath("~/App_Code/Advantshop/Modules/" + moduleStringId));
            FileHelpers.DeleteDirectory(HttpContext.Current.Server.MapPath("~/Modules/" + moduleStringId));

            return(true);
        }