Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            string result = "";

            context.Response.ContentType = "text/html";
            string          control  = context.Request.QueryString["control"];
            string          filePath = context.Request["filepath"];
            DataControlInfo dc       = new BaseControlHelper().GetIntegrationInfoByPath(filePath);
            string          id       = context.Request.QueryString["id"];

            try
            {
                if (!String.IsNullOrEmpty(control))
                {
                    string tmpfolder = GeneralConfigs.GetConfig().DefaultTemplateGroupFileName;
                    tmpfolder = tmpfolder.Remove(tmpfolder.IndexOf("."));
                    TemplateProcessor tp = new TemplateProcessor(tmpfolder);
                    //result = tp.CreateControlIcon(control, id);
                    string name = "";
                    if (!String.IsNullOrEmpty(dc.Name) && dc.Controls.Count > 0 && !String.IsNullOrEmpty(dc.Controls[0].Name))
                    {
                        name = dc.Name + ":" + dc.Controls[0].Name;
                    }
                    result = tp.CreateDataControlIcon(name, id);
                }
            }
            catch {  }
            context.Response.Write(result);
        }
Example #2
0
        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());
        }
Example #3
0
        protected override void Initialize()
        {
            Response.Expires = -1;

            if (ControlFile != null)
            {
                //DataControlInfo  info = DataControlHelper.GetDataControlInfoByPath(ControlFile);
                //DataControlInfo info=DataControlHelper.GetDataControlInfoByPath(ControlFile);

                BaseControlHelper Helper = new BaseControlHelper();
                DataControlInfo   info   = Helper.GetIntegrationInfoByPath(ControlFile);
                NameLabel.Text    = info.Name;
                SummaryLabel.Text = info.Desc;

                FieldsTextBox.Text = info.ToJson();

                IsFirstTextBox.Text = Request["isFirst"];
                GroupHidden.Value   = Folder.Trim();
                ControlHidden.Value = ControlFile;
                if (ControlFile != null && Template != null)
                {
                    InitializeCssFile();
                }
            }
        }
Example #4
0
 /// <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);
     }
 }
Example #5
0
 /// <summary>
 /// 重建主题索引
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void CreateThemeIndex_Click(object sender, EventArgs e)
 {
     try
     {
         BaseControlHelper Helper = new BaseControlHelper();
         Helper.CreateThemeIndex();
         Messages.ShowMessage("重新主题索引成功");
     }
     catch (Exception ex)
     {
         Messages.ShowError("重建主题索引失败:" + ex.Message);
     }
 }
Example #6
0
 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}");
 }
Example #7
0
 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);
     }
 }
Example #8
0
        void BindData()
        {
            BaseControlHelper      Helper   = new BaseControlHelper();
            List <DataControlInfo> infoList = Helper.GetDataControlsInfos();
            List <DataControlInfo> result   = new List <DataControlInfo>();

            if (result != null)
            {
                if (ddlType.SelectedValue != "ALL")
                {
                    foreach (DataControlInfo dci in infoList)
                    {
                        if (!result.Contains(dci) && dci.Group == ddlType.SelectedValue && (dci.Name.Contains(txtKeyWord.Text.Trim()) || dci.Desc.Contains(txtKeyWord.Text.Trim()) || dci.DefaultControl.Description.Contains(txtKeyWord.Text.Trim())))
                        {
                            result.Add(dci);
                        }
                    }
                }
                else
                {
                    foreach (DataControlInfo dci in infoList)
                    {
                        if (!result.Contains(dci) && (dci.Name.Contains(txtKeyWord.Text.Trim()) || dci.Desc.Contains(txtKeyWord.Text.Trim())))
                        {
                            result.Add(dci);
                        }
                    }
                }
                PagedDataSource pds = new PagedDataSource();
                pds.DataSource       = result;
                pds.PageSize         = Pager.PageSize;
                pds.AllowPaging      = true;
                Pager.RecordCount    = result.Count;
                pds.CurrentPageIndex = Pager.CurrentPageIndex - 1;

                if (pds.CurrentPageIndex < 0)
                {
                    pds.CurrentPageIndex = 0;
                }
                ModeDataList.DataSource = pds;
                ModeDataList.DataBind();
            }
        }
Example #9
0
        /// <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);
        }
Example #10
0
        /// <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);
        }
Example #11
0
        protected bool IsControl()
        {
            BaseControlHelper Helper = new BaseControlHelper();

            return(Helper.IsControl(ControlFile));
        }
Example #12
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json; charset=utf-8";

            AjaxResponse ajaxMessage = new AjaxResponse();

            try
            {
                //参数
                var    action = context.Request["action"];
                string file   = context.Request["file"];
                string folder = context.Request["folder"];


                //删除操作
                #region  除操作
                if (string.Compare("delete", action, true) == 0)
                {
                    //获取操作
                    string widgetId = context.Request["id"];

                    VisualDesignFile vd = new VisualDesignFile(folder, file);
                    vd.Delete(widgetId);
                    vd.SaveDraft(true);
                    ajaxMessage.Success = true;
                }
                #endregion
                //移动操作
                #region 移动操作
                else if (string.Compare("move", action, true) == 0)
                {
                    //获取参数
                    var target = context.Request["target"];
                    var id     = context.Request["id"];
                    var nextId = context.Request["nextid"];

                    VisualDesignFile vd = new VisualDesignFile(folder, file);
                    vd.Move(target, id, nextId);
                    vd.SaveDraft();
                }
                #endregion
                #region 编辑背景
                else if (string.Compare("editbg", action, true) == 0)
                {
                    VisualDesignFile vd = new VisualDesignFile(folder, file);
                    var bodyAttr        = Base64Helper.Decode(context.Request["bodyattr"]);
                    var containerAttr   = Base64Helper.Decode(context.Request["ccattr"]);
                    vd.ReplaceDomAttr(vd.Body, bodyAttr);
                    if (vd.PageContainer != null)
                    {
                        vd.ReplaceDomAttr(vd.PageContainer, containerAttr);
                    }
                    vd.SaveDraft();
                }
                #endregion
                //发布模板
                #region 发布模板
                else if (string.Compare("publish", action, true) == 0)
                {
                    VisualDesignFile vd = new VisualDesignFile(folder, file);
                    vd.Publish();

                    //样式整合
                    vd.CombineStyle();
                }
                #endregion
                //编辑布局
                #region 编辑布局
                else if (string.Compare("editlayout", action, true) == 0)
                {
                    var temp = context.Request["params"];

                    if (string.IsNullOrEmpty(temp))
                    {
                        throw new ArgumentNullException("params为空!");
                    }

                    temp = Base64Helper.Decode(temp);

                    var layoutParams = JsonConvert.DeserializeObject <WidgetDesign>(temp);

                    VisualDesignFile vdFile = new VisualDesignFile(folder, file);

                    for (int i = 0; i < layoutParams.Columns.Count; i++)
                    {
                        var col = layoutParams.Columns[i];

                        var node = vdFile.GetElementById(col["id"].ToString());
                        if (node.Attributes.Contains("style"))
                        {
                            node.Attributes["style"].Value = col["style"].ToString();
                        }
                        else
                        {
                            node.Attributes.Add("style", col["style"].ToString());
                        }
                        if (node.Attributes.Contains("width"))
                        {
                            node.Attributes["width"].Value = col["width"].ToString();
                        }
                        else
                        {
                            node.Attributes.Add("width", col["width"].ToString());
                        }
                        if (node.Attributes.Contains("cssclass"))
                        {
                            node.Attributes["cssclass"].Value = col["cssclass"].ToString();
                        }
                        else
                        {
                            node.Attributes.Add("cssclass", col["cssclass"].ToString());
                        }
                        if (node.Attributes.Contains("widthunit"))
                        {
                            node.Attributes["widthunit"].Value = col["widthunit"].ToString();
                        }
                        else
                        {
                            node.Attributes.Add("widthunit", col["widthunit"].ToString());
                        }
                    }
                    vdFile.SaveDraft();
                }
                #endregion
                //更换主题
                #region 更换主题
                else if (string.Compare("changetheme", action, true) == 0)
                {
                    var theme = context.Request["theme"].Trim();

                    if (string.IsNullOrEmpty(theme))
                    {
                        throw new ArgumentNullException("主题不能为空!");
                    }
                    VisualDesignFile vdFile = new VisualDesignFile(folder, file);

                    vdFile.AddOrUpdateThemeFile(theme);

                    vdFile.SaveDraft();
                }
                #endregion
                //复制
                #region  制
                else if (string.Compare("copy", action, true) == 0)
                {
                    var id       = context.Request["id"];
                    var fileName = context.Request["fileName"];

                    VisualDesignFile vdFile = new VisualDesignFile(folder, file);
                    var node = vdFile.GetElementById(id);

                    Dictionary <string, object> WidgetParameter = new Dictionary <string, object>();

                    BaseControlHelper DcHelper = new BaseControlHelper();
                    DCInfo            infoList = DcHelper.PickUp(fileName);
                    foreach (DCPartInfo partInfo in infoList.Parts)
                    {
                        List <DataControlParameter> parsList = partInfo.Params;
                        foreach (DataControlParameter par in parsList)
                        {
                            object supportCopy = par.SupportCopy;
                            if (node.Attributes.Contains(par.Name) && supportCopy.ToString() == Boolean.TrueString)
                            {
                                WidgetParameter.Add(par.Name.ToLower(), node.Attributes[par.Name].Value);
                            }
                        }
                    }
                    if (!WidgetParameter.ContainsKey("filename"))
                    {
                        WidgetParameter.Add("filename", fileName);
                    }
                    //WidgetParameter.Add("id", node.Attributes["id"].Value);
                    if (infoList.Parts.Count == 0)
                    {
                        ajaxMessage.Success = false;
                        ajaxMessage.Message = "该控件没有没有可复制的属性!";
                    }
                    else
                    {
                        ajaxMessage.Success = true;
                        ajaxMessage.Message = JsonConvert.SerializeObject(WidgetParameter);
                    }
                }
                #endregion
                #region 检查模板是否存在
                else if (String.Compare("checktempexist", action, true) == 0)
                {
                    string templateGroupName =
                        GeneralConfigs.GetConfig().DefaultTemplateGroupFileName.ToLower().Replace(".xml", "");
                    string fileName = HttpContext.Current.Server.MapPath(
                        string.Format("/_skins/~{0}/{1}.ascx", templateGroupName, file));
                    if (File.Exists(fileName))
                    {
                        ajaxMessage.Success = false;
                        ajaxMessage.Message = "已经存在此模板";
                    }
                    else
                    {
                        ajaxMessage.Success = false;
                        ajaxMessage.Message = "";
                    }
                }
                #endregion
                else
                {
                    ajaxMessage.Success = false;
                    ajaxMessage.Message = "不存在该操作!";
                }
            }
            catch (Exception ex)
            {
                ajaxMessage.Success = false;
                ajaxMessage.Message = ex.Message;
            }
            context.Response.Write(ajaxMessage.ToJson());
        }