public override string Run(PluginInfo info, PluginAction action) { try { string widgetDownloadPath = Path.Combine(Constants.We7WidgetsFileFolder, "商城下载类"); if (!Directory.Exists(widgetDownloadPath)) { Directory.CreateDirectory(widgetDownloadPath); } BaseControlHelper baseControlHelper = new BaseControlHelper(); string srcWidgetPath = Path.Combine(info.PluginClientPath, "Widget"); if (Directory.Exists(srcWidgetPath)) { CopyDirectory(info, action, srcWidgetPath, widgetDownloadPath); baseControlHelper.CreateWidegetsIndex(); //创建部件索引 } string srcPath = Path.Combine(info.PluginClientPath, "Control"); if (Directory.Exists(srcPath)) { CopyDirectory(info, action, srcPath, "We7Controls"); baseControlHelper.CreateIntegrationIndexConfig(); //创建控件索引 } } catch (Exception ex) { return(new PluginJsonResult(false, ex.Message).ToString()); } return(new PluginJsonResult(true).ToString()); }
/// <summary> /// 重建所有索引 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ReIndexHyperLink_Click(object sender, EventArgs e) { try { //部件,主题索引 BaseControlHelper baseCtrlHelper = new BaseControlHelper(); baseCtrlHelper.CreateThemeIndex(); baseCtrlHelper.CreateWidegetsIndex(); //模板图索引 SiteSettingHelper siteSettingHelper = new SiteSettingHelper(); TemplateHelper TemplateHelper = new TemplateHelper(); string defaultTempGroupFile = siteSettingHelper.Config.DefaultTemplateGroupFileName; if (!string.IsNullOrEmpty(defaultTempGroupFile) && File.Exists(Path.Combine(TemplateHelper.TemplateGroupPath, defaultTempGroupFile))) { SkinInfo data = TemplateHelper.GetSkinInfo(defaultTempGroupFile); TemplateHelper.CreateMapFileFromSkinInfo(data); TemplateHelper.RefreshTemplateDefaultBindText(data); } } catch (Exception ex) { We7.Framework.LogHelper.WriteLog(typeof(content), ex); } }
/// <summary> /// 重建部件索引 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void CreateWidgetIndex_Click(object sender, EventArgs e) { try { BaseControlHelper Helper = new BaseControlHelper(); Helper.CreateWidegetsIndex(); Messages.ShowMessage("重新部件索引成功"); } catch (Exception ex) { Messages.ShowError("重建部件索引失败:" + ex.Message); } }
public string CreateModelWidegetsIndex() { try { BaseControlHelper ctrHelper = new BaseControlHelper(); ctrHelper.CreateIntegrationIndexConfig(); ctrHelper.CreateWidegetsIndex(); } catch (Exception ex) { return("{\"success\":false,\"msg\":\"生成索引失败,错误消息:" + Utils.JsonCharFilter(ex.Message) + "\"}"); } return("{\"success\":true}"); }
protected void btnCreateIndex_Click(object sender, EventArgs e) { try { BaseControlHelper Helper = new BaseControlHelper(); Helper.CreateWidegetsIndex(); //重建部件索引 Helper.CreateIntegrationIndexConfig(); //创建控件、模型、插件的索引 ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('重建索引成功!')", true); BindCategory(); BindData(); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('重建索引失败:" + ex.Message + "')", true); } }
/// <summary> /// 获取系统widgets /// </summary> /// <returns></returns> public WidgetCollection GetSystemWidgetList() { var widgets = new WidgetCollection(); try { //检查WidgetIndex.xml是否存在 if (!File.Exists(WidgetConfigPath)) { BaseControlHelper Helper = new BaseControlHelper(); Helper.CreateWidegetsIndex(); } widgets = SerializationHelper.Load <WidgetCollection>(WidgetConfigPath); } catch (Exception ex) { throw new Exception(ex.Message); } return(widgets); }
/// <summary> /// 删除模型 /// </summary> /// <returns></returns> public string DeleteModel() { string modelName = We7Request.GetQueryString("model"); string msg = ""; bool success = true; //2011-10-10 取消生成控件 //ModelHelper.CreateControls(modelInf); /* * TODO: * 以下这些代码应该集成到ModelHelper.DeleteContentModel中,但是下列代码中需要一些方法是调用We7.CMS.WebControls.Core.BaseControlHelper中的方法,这个类物理文件存储在We7.CMS.UI里面. */ ModelInfo modelInf = ModelHelper.GetModelInfo(modelName); //反馈模型删除前需要解除类型的绑定 if (modelInf.Type.ToString().ToLower().Equals("advice")) { Criteria c = new Criteria(CriteriaType.Equals, "ModelName", modelInf.ModelName); List <AdviceType> adviceList = Assistant.List <AdviceType>(c, null); if (adviceList != null && adviceList.Count > 0) { success = false; msg = "当前模型尚有绑定的反馈类型,请先解除绑定再进行删除!"; return("{\"success\":" + success.ToString().ToLower() + ",\"msg\":\"" + msg + "\"}"); } } //布局控件 string layoutPath = ModelHelper.GetModelLayoutDirectory(modelInf.ModelName); //部件 int widgetCount = 0; string viewPath = ModelHelper.GetWidgetDirectory(modelInf, "View"); string listPath = ModelHelper.GetWidgetDirectory(modelInf, "List"); string pageListPath = ModelHelper.GetWidgetDirectory(modelInf, "PagedList"); try { if (Directory.Exists(layoutPath)) { Directory.Delete(layoutPath, true); } if (Directory.Exists(viewPath)) { Directory.Delete(viewPath, true); widgetCount++; } if (Directory.Exists(listPath)) { Directory.Delete(listPath, true); widgetCount++; } if (Directory.Exists(pageListPath)) { Directory.Delete(pageListPath, true); widgetCount++; } if (widgetCount > 0) { //重建部件索引 BaseControlHelper ctrHelper = new BaseControlHelper(); ctrHelper.CreateIntegrationIndexConfig(); ctrHelper.CreateWidegetsIndex(); } } catch { msg += "部分文件夹删除失败,请手动删除以下文件夹:\r\n"; msg += "1:" + layoutPath + "\r\n"; msg += "2:" + viewPath + "\r\n"; msg += "3:" + listPath + "\r\n"; msg += "4:" + pageListPath + "\r\n"; success = false; } //删除数据库表 try { DataBaseHelperFactory.Create().DeleteTable(modelInf); } catch { } //检查左侧菜单 MenuHelper MenuHelper = HelperFactory.Instance.GetHelper <MenuHelper>(); MenuItem item = MenuHelper.GetMenuItemByTitle(modelInf.Label + "管理"); if (item != null && !string.IsNullOrEmpty(item.ID)) { try { MenuHelper.DeleteMenuItem(item.ID); } catch { success = false; msg += "左侧菜单删除失败,请在【后台菜单管理里手动删除】"; } } //检查是否关联了Channel List <Channel> channelList = HelperFactory.Instance.GetHelper <ChannelHelper>(). GetChannelByModelName(modelInf.ModelName); if (channelList != null && channelList.Count > 0) { try { foreach (Channel c in channelList) { c.ModelName = ""; HelperFactory.Instance.GetHelper <ChannelHelper>().UpdateChannel(c); } } catch (Exception ex) { success = false; msg += "内容模型已关联栏目,取消关联失败,请手动取消栏目和内容模型的绑定关系!错误消息:" + ex.Message; } } //删除XML节点及文件 success = !ModelHelper.DeleteContentModel(modelName, ref msg) ? false : success; string strResult = "{\"success\":" + success.ToString().ToLower() + ",\"msg\":\"" + Utils.JsonCharFilter(msg) + "\"}"; //return JsonConvert.SerializeObject(strResult).Replace("null", "\"\""); ; return(strResult); }