コード例 #1
0
        /// <summary>
        /// 获取所有内容模型
        /// </summary>
        /// <returns>所有内容模型集合</returns>
        public ContentModelCollection GetModelCollection()
        {
            ModelType type = (ModelType)Enum.Parse(typeof(ModelType), modelType);
            ContentModelCollection collection = ModelHelper.GetContentModel(type);

            return(collection);
        }
コード例 #2
0
ファイル: Advice_File.ascx.cs プロジェクト: jiaping/JPCMS
        /// <summary>
        ///  界面加载
        /// </summary>
        void InitializePage()
        {
            ContentModelCollection cmc   = new ContentModelCollection();
            ContentModelCollection orcmc = ModelHelper.GetAllContentModel();

            foreach (We7.Model.Core.ContentModel c in orcmc)
            {
                if (c.Type == ModelType.ADVICE)
                {
                    cmc.Add(c);
                }
            }

            ddlAdviceType.DataSource     = cmc;
            ddlAdviceType.DataTextField  = "label";
            ddlAdviceType.DataValueField = "name";
            ddlAdviceType.DataBind();
            ddlAdviceType.Items.Insert(0, new ListItem("请选择", ""));
            adviceType = AdviceTypeHelper.GetAdviceType(AdviceTypeID);
            if (adviceType != null)
            {
                ConfigNameTextBox.Text      = adviceType.Title.ToString();
                ddlAdviceType.SelectedValue = adviceType.ModelName;
            }
        }
コード例 #3
0
        void ResponseModelType()
        {
            ContentModelCollection      cmc  = ModelHelper.GetContentModel(ModelType.ADVICE);
            ContentModelCollection      cmc2 = ModelHelper.GetContentModel(ModelType.ARTICLE);
            Dictionary <string, string> dic  = new Dictionary <string, string>();

            dic.Add("", "请选择");
            foreach (We7.Model.Core.ContentModel c in cmc)
            {
                if (dic.ContainsKey(c.Name))
                {
                    continue;
                }
                dic.Add(c.Name, c.Label);
            }
            foreach (We7.Model.Core.ContentModel c in cmc2)
            {
                if (dic.ContainsKey(c.Name))
                {
                    continue;
                }
                dic.Add(c.Name, c.Label);
            }
            OutPut2(dic);
        }
コード例 #4
0
ファイル: AddMenuUser.aspx.cs プロジェクト: jiaping/JPCMS
        void BindingData()
        {
            ContentModelCollection cmc = ModelHelper.GetContentModel(ModelType.ARTICLE);

            MenuDropDownList.DataSource     = cmc;
            MenuDropDownList.DataTextField  = "Label";
            MenuDropDownList.DataValueField = "Name";
            MenuDropDownList.DataBind();
        }
コード例 #5
0
        /// <summary>
        /// 设置内容模型字典
        /// </summary>
        /// <param name="assistat"></param>
        public static void SetModelDataDic(ObjectAssistant assistat)
        {
            if (assistat == null)
            {
                return;
            }
            ContentModelCollection cmc = ModelHelper.GetAllContentModel();

            foreach (ContentModel item in cmc)
            {
                ModelInfo info = ModelHelper.GetModelInfo(item.Name);
                foreach (var table in info.DataSet.Tables)
                {
                    ObjectManager om = new ObjectManager();
                    EntityObject  eo = new EntityObject();
                    eo.TypeForDT      = typeof(TableInfo);
                    eo.IdentityName   = "ID";
                    eo.IsDataTable    = true;
                    eo.PrimaryKeyName = "ID";
                    eo.TableName      = table.Name;
                    //亲,此处取的是内容模型的描述,不是写错了
                    eo.Description = item.Description;
                    Dictionary <string, Property> diccolumn = new Dictionary <string, Property>(StringComparer.OrdinalIgnoreCase);
                    foreach (var column in table.Columns)
                    {
                        Property pt = new Property();
                        pt.Description = column.Label;
                        pt.Field       = column.Name;
                        pt.Nullable    = column.Nullable;
                        pt.Size        = column.MaxLength;
                        pt.Name        = column.Name;
                        //pt.Type = column.DataType;
                        diccolumn.Add(column.Name, pt);
                    }

                    eo.PropertyDict = diccolumn;
                    om.CurObject    = eo;
                    DataBase db = new DataBase();
                    db.DbDriver         = assistat.GetDatabases()["We7.CMS.Common"].DbDriver;
                    db.Name             = assistat.GetDatabases()["We7.CMS.Common"].Name;
                    db.ConnectionString = assistat.GetDatabases()["We7.CMS.Common"].ConnectionString;
                    om.CurDatabase      = db;
                    om.ObjType          = eo.TypeForDT;
                    if (assistat.DicForTable().ContainsKey(table.Name)) //如果存在此KEY
                    {
                        assistat.DicForTable().Remove(table.Name);      //移除此项
                    }
                    if (!assistat.DicForTable().ContainsKey(table.Name))
                    {
                        assistat.DicForTable().Add(table.Name, om);                          //添加
                    }
                }
            }
        }
コード例 #6
0
ファイル: EditModel.aspx.cs プロジェクト: jiaping/JPCMS
        bool CheckInput()
        {
            if (String.IsNullOrEmpty(ModelLabelTextBox.Text.Trim()))
            {
                Messages.ShowError("模型名称不能为空");
                return(false);
            }
            if (String.IsNullOrEmpty(ModelNameTextBox.Text.Trim()))
            {
                Messages.ShowError("配置文件名不能为空");
                return(false);
            }
            if (!Utils.IsCharAndNumber(ModelNameTextBox.Text.Trim()))
            {
                Messages.ShowError("配置文件名只能为英文字母或字符");
                return(false);
            }


            ContentModelCollection cmc = ModelHelper.GetAllContentModel();

            foreach (We7.Model.Core.ContentModel cm in cmc)
            {
                if (!IsEdit)
                {
                    if (String.Compare(cm.Name, String.Format("{0}.{1}", GroupDropDownList.SelectedValue, ModelNameTextBox.Text.Trim()), true) == 0)
                    {
                        Messages.ShowError("当前模型配置文件名已存在,请改更配置文件名称");
                        return(false);
                    }

                    if (String.Compare(cm.Label, ModelLabelTextBox.Text.Trim(), true) == 0)
                    {
                        Messages.ShowError("当前模型名称已存在,请更改模型名称");
                        return(false);
                    }
                }
                else
                {
                    string    defaultModelName = RequestHelper.Get <string>("modelname");
                    ModelInfo modelInfo        = ModelHelper.GetModelInfoByName(defaultModelName);

                    if (String.Compare(cm.Label, ModelLabelTextBox.Text.Trim(), true) == 0 &&
                        String.Compare(cm.Label, modelInfo.Label, true) != 0)
                    {
                        Messages.ShowError("当前模型名称已存在,请更改模型名称");
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #7
0
ファイル: EditModel.aspx.cs プロジェクト: jiaping/JPCMS
        private void BindRelationModelName()
        {
            //ddlRelationModelName
            ContentModelCollection contentCollection = ModelHelper.GetContentModel(ModelType.ADVICE);

            ddlRelationModelName.DataSource     = contentCollection;
            ddlRelationModelName.DataTextField  = "Label";
            ddlRelationModelName.DataValueField = "Name";
            ddlRelationModelName.DataBind();
            ddlRelationModelName.Items.Insert(0, new ListItem("请选择", ""));
            ddlRelationModelName.Items[0].Selected = true;
        }
コード例 #8
0
        /// <summary>
        /// 创建所有的文章模型表
        /// </summary>
        public void CreateModelTables()
        {
            ModelHelper.ReCreateModelIndex();

            ContentModelCollection collection = ModelHelper.GetAllContentModel();

            foreach (ContentModel cm in collection)
            {
                ModelInfo mi = ModelHelper.GetModelInfo(cm.Name);
                if (mi.Type == ModelType.ARTICLE)
                {
                    CreateTable(mi);
                }
            }
        }
コード例 #9
0
ファイル: TemplateBindTo.aspx.cs プロジェクト: jiaping/JPCMS
        string LoadTemplateDictionary()
        {
            string        itemString = "<a href=\"javascript:addBind('{0}','{1}','{3}','{4}','{5}')\" title=\"指定为 {4} ? \"  >{2}</a> ";
            string        itemTitle  = "<H3>{0}</H3>";
            StringBuilder sb         = new StringBuilder();

            List <TemplateBindConfig> list = TemplateHelper.GetTemplateBindConfigList();
            string title = "";
            List <TemplateBindConfig> modelList = new List <TemplateBindConfig>();

            foreach (TemplateBindConfig tb in list)
            {
                if (tb.Handler == "model")
                {
                    modelList.Add(tb);
                }
                else
                {
                    if (title != tb.HandlerName)
                    {
                        sb.AppendLine(string.Format(itemTitle, tb.HandlerName));
                        title = tb.HandlerName;
                    }
                    sb.AppendLine(string.Format(itemString, tb.Handler, tb.Mode, tb.ModeText, "", tb.Description, FileName));
                }
            }

            ContentModelCollection cmc = ModelHelper.GetContentModel(ModelType.ARTICLE);

            foreach (We7.Model.Core.ContentModel cm in cmc)
            {
                sb.AppendLine(string.Format(itemTitle, cm.Label + "模型"));
                foreach (TemplateBindConfig tb in modelList)
                {
                    sb.AppendLine(string.Format(itemString, tb.Handler, tb.Mode, tb.ModeText, cm.Name, cm.Label + tb.Description, FileName));
                }
            }

            sb.AppendLine("<br>");
            return(sb.ToString());
        }
コード例 #10
0
ファイル: ContentModel.ashx.cs プロジェクト: jiaping/JPCMS
        /// <summary>
        /// 检查模型
        /// </summary>
        /// <param name="groupname">模板组</param>
        /// <param name="file">配置文件名</param>
        /// <param name="modelname">模板名称</param>
        /// <returns></returns>
        public string CheckModelName(bool isEdit, string groupname, string file, string modelname)
        {
            string result = "";

            ContentModelCollection cmc = ModelHelper.GetAllContentModel();

            foreach (We7.Model.Core.ContentModel cm in cmc)
            {
                if (!isEdit)
                {
                    if (String.Compare(cm.Name, String.Format("{0}.{1}", groupname, file), true) == 0)
                    {
                        result = "当前模型配置文件名已存在,请改更配置文件名称";
                        return(result);
                    }

                    if (String.Compare(cm.Label, modelname, true) == 0)
                    {
                        result = "当前模型名称已存在,请更改模型名称";
                        return(result);
                    }
                }
                else
                {
                    string    defaultModelName = RequestHelper.Get <string>("modelname");
                    ModelInfo modelInfo        = ModelHelper.GetModelInfoByName(defaultModelName);

                    if (String.Compare(cm.Label, modelname, true) == 0 &&
                        String.Compare(cm.Label, modelInfo.Label, true) != 0)
                    {
                        result = "当前模型名称已存在,请更改模型名称";
                        return(result);
                    }
                }
            }

            return(result);
        }
コード例 #11
0
 public void AddToCollection(ReadingModelBase model)
 {
     ContentModelCollection.Add(model);
 }
コード例 #12
0
        string LoadTemplateDictionary(string editorUrl)
        {
            string        itemString = "<a href=\"{4}?handler={0}&mode={1}&model={2}\" title=\"新建 {3} 模板? \" target=\"_blank\"  >{3}</a> ";
            string        itemTitle  = "<H3 >{0}</H3>";
            StringBuilder sb         = new StringBuilder();

            sb.AppendLine("<h1>您想创建哪一个对应页面的模板?</h1>");
            SkinInfo data = TemplateHelper.GetSkinInfo(FileName);

            List <TemplateBindConfig> list = TemplateHelper.GetTemplateBindConfigList();
            string title = "";
            List <TemplateBindConfig> modelList = new List <TemplateBindConfig>();

            foreach (TemplateBindConfig tb in list)
            {
                if (tb.Handler == "model")
                {
                    modelList.Add(tb);
                }
                else
                {
                    SkinInfo.SkinItem item = new SkinInfo.SkinItem();
                    item.C_Model  = "";
                    item.Location = tb.Mode;
                    item.Tag      = "";
                    item.Type     = tb.Handler;
                    if (!TemplateHelper.HaveSameItem(item, data))
                    {
                        if (title != tb.HandlerName)
                        {
                            sb.AppendLine(string.Format(itemTitle, tb.HandlerName));
                            title = tb.HandlerName;
                        }
                        sb.AppendLine(string.Format(itemString, tb.Handler, tb.Mode, "", tb.Description, editorUrl));
                        sb.Append(" ┃ ");
                    }
                }
            }

            ContentModelCollection cmc = ModelHelper.GetContentModel(ModelType.ARTICLE);

            foreach (We7.Model.Core.ContentModel cm in cmc)
            {
                sb.AppendLine(string.Format(itemTitle, cm.Label + "模型"));
                foreach (TemplateBindConfig tb in modelList)
                {
                    SkinInfo.SkinItem item = new SkinInfo.SkinItem();
                    item.C_Model  = cm.Name;
                    item.Location = tb.Mode;
                    item.Tag      = "";
                    item.Type     = tb.Handler;
                    if (!TemplateHelper.HaveSameItem(item, data))
                    {
                        sb.AppendLine(string.Format(itemString, tb.Handler, tb.Mode, cm.Name, cm.Label + tb.Description, editorUrl));
                        sb.Append(" ┃ ");
                    }
                }
            }

            sb.AppendLine("<br>");
            sb.AppendLine("<h2>" + string.Format(itemString, "", "", "", "个性化模板(不做默认指定)", editorUrl) + "</h2>");
            sb.AppendLine("<br>");
            return(sb.ToString());
        }