Example #1
0
        /// <summary>
        /// 生成文章类型前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateArticleListControl(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateDirectory(model, "List", "ArticleModelListDataControl", "列表");

            helper.Put("modelDesc", string.IsNullOrEmpty(model.Desc) ? model.Desc : model.ModelName);
            helper.Put("model", model);

            We7DataColumnCollection dcs = null;

            if (model.Layout.UCContrl.DetailFieldArray == null)
            {
                dcs = model.DataSet.Tables[0].Columns;
            }
            else
            {
                dcs = new We7DataColumnCollection();
                foreach (We7DataColumn dc in model.DataSet.Tables[0].Columns)
                {
                    if (Array.Exists(model.Layout.UCContrl.DetailFieldArray, s => s == dc.Name))
                    {
                        dcs.Add(dc);
                    }
                }
            }

            helper.Put("columns", dcs);

            helper.Put("CurrentDate", DateTime.Now.ToString());
            if (ModelConfig.IsCreateArticleUC)
            {
                helper.Save("ArticleList.vm", path);
            }
            helper.Save("DbModelList.vm", CreateNewFilePath(path, "DB"));
        }
Example #2
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (Design)
            {
                //可视化设计时
                StringWriter   output = new StringWriter();
                HtmlTextWriter tw     = new HtmlTextWriter(output);
                base.Render(tw);
                string ControlHtml = output.ToString();
                //格式化代码
                string formatControlHtml = FormatHtml(ControlHtml);

                NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory);

                helper.Put("controlId", this.ID);
                helper.Put("controlContent", formatControlHtml);
                helper.Put("controlData", BuildData());
                var rendHtml = helper.Save("We7LayoutDesign.vm");
                //格式化
                rendHtml = FormatHtml(rendHtml);
                //输出代码
                writer.Write(rendHtml);
            }
            else
            {
                writer.Write("<div id=\"" + this.ID + "\" class=\"sf_cols\">");
                base.Render(writer);
                //writer.Write("<div style= \"clear:both; height:0;\"></div>");
                writer.Write("<div style= \"clear:both;height:0;font-size:1px;\"></div>");
                writer.Write("</div>");
            }
        }
Example #3
0
        /// <summary>
        /// 生成模型布局
        /// </summary>
        /// <param name="model"></param>
        /// <returns>布局存放路径</returns>
        public static string CreateModelLayout(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            //string path = CreateDirectory(model, "Edit", "ArticleModelEditDataControl", "录入");
            //string path2 = CreateModelDirectory(model, "Edit", "ArticleModelEditDataControl", "录入");

            string   path = GetModelLayoutDirectory(model.ModelName) + "GenerateLayout.ascx";
            FileInfo fi   = new FileInfo(path);

            if (!fi.Directory.Exists)
            {
                fi.Directory.Create();
            }

            helper.Put("model", model);
            helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls);
            helper.Put("CurrentDate", DateTime.Now.ToString());

            helper.Save("ArticleEditor.vm", path);

            path = String.Format("{0}/{1}/{2}/{3}", ModelConfig.ModelsDirectory, model.GroupName, model.Name, "GenerateLayout.ascx");
            return(path);

            //helper.Save("ArticleEditor.vm", path);
            //helper.Save("ArticleEditor.vm", path2);
        }
Example #4
0
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (Design)
            {
                //可视化设计时
                StringWriter   output = new StringWriter();
                HtmlTextWriter tw     = new HtmlTextWriter(output);
                base.Render(tw);
                string ControlHtml = output.ToString();
                //格式化代码
                string formatControlHtml = FormatHtml(ControlHtml);

                NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory);

                helper.Put("controlId", this.ID);
                helper.Put("controlContent", formatControlHtml);

                var rendHtml = helper.Save("We7LayoutDesign.vm");
                //格式化
                rendHtml = FormatHtml(rendHtml);
                //输出代码
                writer.Write(rendHtml);
            }
            else
            {
                base.Render(writer);
            }
        }
Example #5
0
 /// <summary>
 /// 创建部件
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="refFilePath"></param>
 /// <param name="tpls"></param>
 static void CreateWidgets(NVelocityHelper helper, string refFilePath, string[] tpls)
 {
     foreach (string tpl in tpls)
     {
         string   file = Path.GetFileName(tpl);
         string[] ss   = file.Split('.');
         string   ext  = ss.Length > 2 ? ss[1] : "Default";
         helper.Save(file, CreateNewWidgetPath(refFilePath, ext));
     }
 }
Example #6
0
        /// <summary>
        /// 生成反馈类型 前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateAdviceEditControl(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateDirectory(model, "Edit", "AdviceModelEditDataControl", "录入");

            helper.Put("model", model);
            helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls);
            helper.Put("CurrentDate", DateTime.Now.ToString());

            helper.Save("Advice.vm", path);
        }
Example #7
0
        /// <summary>
        /// 生成反馈类型 前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateAdviceQueryListControl(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateDirectory(model, "QueryList", "AdviceQueryListDataControl", "查询列表");

            helper.Put("model", model);
            helper.Put("columns", model.DataSet.Tables[0].Columns);
            helper.Put("CurrentDate", DateTime.Now.ToString());

            helper.Save("AdviceQueryList.vm", path);
        }
Example #8
0
        private static void CreateAdviceDetailsWidget(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateWidgetDirectory(model, "View");

            helper.Put("model", model);
            helper.Put("columns", model.DataSet.Tables[0].Columns);
            helper.Put("CurrentDate", DateTime.Now.ToString());

            helper.Save("WidgetAdviceView.vm", path);
        }
Example #9
0
        /// <summary>
        /// 反馈前台录入(自动布局)
        /// </summary>
        /// <param name="model"></param>
        private static void CreateAdviceEditWidget(ModelInfo model)
        {
            //Criteria c = new Criteria(CriteriaType.Equals, "ModelName", model.ModelName);
            //List<AdviceType> adviceList = Assistant.List<AdviceType>(c, null);

            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateWidgetDirectory(model, "Edit");

            helper.Put("model", model);
            helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls);
            helper.Put("CurrentDate", DateTime.Now.ToString());
            //helper.Put("adviceType", adviceList);

            helper.Save("WidgetAdvice.vm", path);
        }
Example #10
0
        public void Render(RenderChain renders, ref string content, RenderArguments args)
        {
            Design = !string.IsNullOrEmpty(args.Request["state"]);
            if (Design)
            {
                UserControl uc = null;

                Action = !string.IsNullOrEmpty(args.Request["action"]);
                if (Action)
                {
                    WidgetParameter = new Dictionary <string, object>();
                    var param = RequestHelper.Get <string>("params");
                    if (!string.IsNullOrEmpty(param))
                    {
                        param           = Base64Helper.Decode(param);
                        WidgetParameter = JsonConvert.DeserializeObject <Dictionary <string, object> >(param);
                    }
                }
                else
                {
                    uc       = args.Control;
                    FileName = args.Request["file"].ToString();
                }
                //执行
                //格式化代码
                content = FormatHtml(content);


                NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory);
                helper.Put("controlId", args.Control.ID);
                helper.Put("controlName", string.Empty);
                helper.Put("controlContent", content);
                helper.Put("controlData", AttributesJsonData(args.Control));

                var rendHtml = helper.Save("We7ControlDesign.vm");

                //格式化
                content = FormatHtml(rendHtml);
            }
            renders.DoRender(ref content, args);
        }
Example #11
0
        /// <summary>
        /// 重写Render方法
        /// </summary>
        /// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)
        {
            if (VisualDesign)//在可视化设计时生成辅助标签
            {
                //可视化设计时
                StringWriter   output = new StringWriter();
                HtmlTextWriter tw     = new HtmlTextWriter(output);
                try
                {
                    base.Render(tw);
                }
                catch (Exception ex)
                {
                    tw.Write("<div class=\"vdControlError\">");
                    tw.Write(ex.Message);
                    tw.Write("</div>");
                };

                string ControlHtml = output.ToString();
                //格式化代码
                string formatControlHtml = FormatHtml(ControlHtml);

                NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory);

                helper.Put("controlId", this.ID);
                helper.Put("controlName", "");
                helper.Put("controlContent", formatControlHtml);
                helper.Put("controlData", AttributesJsonData());

                var rendHtml = helper.Save("We7ControlDesign.vm");

                //格式化
                rendHtml = FormatHtml(rendHtml);
                //输出代码
                writer.Write(rendHtml);
            }
            else
            {
                if (CreateHtml) //生成静态过程中
                {
                    if (IsHtml) //需要生成静态
                    {
                        StringWriter   strWriter  = new StringWriter();
                        HtmlTextWriter tempWriter = new HtmlTextWriter(strWriter);
                        try
                        {
                            base.Render(tempWriter);
                        }
                        catch (Exception ex)
                        {
                            strWriter.Write("");
                        };
                        string content = strWriter.ToString();
                        //格式化代码
                        string formatControlHtml = FormatHtml(content);
                        //输出html代码
                        writer.Write(formatControlHtml);
                    }
                    else
                    {
                        writer.Write(GetOriginalControl());
                    }
                }
                else
                {
                    base.Render(writer);
                }
            }

            //Response.Write("<br />当前控件执行时间::" + DateTime.Now.Subtract(processStartTime).TotalMilliseconds / 1000);
        }