Esempio n. 1
0
        public string AddGroup(string model, string name, int index, string panel)
        {
            ModelInfo   modelInfo   = ModelHelper.GetModelInfo(model);
            AjaxMessage ajaxMessage = new AjaxMessage();

            ajaxMessage.Success = false;
            ajaxMessage.Message = "添加错误!";

            if (modelInfo.Layout.Panels[panel] == null || modelInfo.Layout.Panels[panel].EditInfo == null)
            {
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }
            else
            {
                if (HasGroup(name, ref index, modelInfo.Layout.Panels[panel].EditInfo.Groups))
                {
                    ajaxMessage.Message = "已存在该标记!";
                }
                else
                {
                    ajaxMessage.Success = true;
                    ajaxMessage.Message = "添加成功!";
                    Group group = new Group();
                    group.Index = index;
                    group.Name  = name;
                    group.Next  = index;
                    modelInfo.Layout.Panels[panel].EditInfo.Groups.Add(group);
                    ModelHelper.SaveModelInfo(modelInfo);
                    ajaxMessage.Data = modelInfo.Layout.Panels[panel].EditInfo.Groups;
                }
                return(JavaScriptConvert.SerializeObject(ajaxMessage).Replace("null", "\"\""));
            }
        }
Esempio n. 2
0
        public string GetEditControls(string model, string panel, int index)
        {
            ModelInfo   modelInfo   = ModelHelper.GetModelInfo(model);
            AjaxMessage ajaxMessage = new AjaxMessage();

            ajaxMessage.Success = false;
            ajaxMessage.Message = "控件为空!";
            if (modelInfo.Layout.Panels[panel] == null || modelInfo.Layout.Panels[panel].EditInfo == null)
            {
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }
            else
            {
                GroupCollection groups = modelInfo.Layout.Panels[panel].EditInfo.Groups;
                Group           group  = GetGroupByIndex(index, groups);
                if (group != null)
                {
                    ajaxMessage.Data    = group;// editControls;
                    ajaxMessage.Success = true;
                    ajaxMessage.Message = "获取成功!";
                }

                return(JavaScriptConvert.SerializeObject(ajaxMessage).Replace("null", "\"\""));
            }
        }
Esempio n. 3
0
        public string CopyToUserCenter(string model)
        {
            AjaxMessage ajaxMessage = new AjaxMessage();
            bool        success     = false;
            ModelInfo   modelInfo   = ModelHelper.GetModelInfoByName(model);

            if (modelInfo.Type != ModelType.ARTICLE)
            {
                ajaxMessage.Success = success;
                ajaxMessage.Message = "模型类型不是文章类型,没有会员中心!";

                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }

            modelInfo.Layout.Panels["multi"].EditInfo.Groups[0].Controls = modelInfo.Layout.Panels["edit"].EditInfo.Groups[0].Controls;

            success = ModelHelper.SaveModelInfo(modelInfo, model);

            ajaxMessage.Success = success;

            if (success)
            {
                ajaxMessage.Message = "复制成功!";
            }
            else
            {
                ajaxMessage.Message = "复制失败!";
            }
            return(JavaScriptConvert.SerializeObject(ajaxMessage));
        }
Esempio n. 4
0
        public string DelGroup(string model, int index, string panel)
        {
            ModelInfo   modelInfo   = ModelHelper.GetModelInfo(model);
            AjaxMessage ajaxMessage = new AjaxMessage();

            ajaxMessage.Success = false;
            ajaxMessage.Message = "不存在!";
            if (modelInfo.Layout.Panels[panel] == null || modelInfo.Layout.Panels[panel].EditInfo == null ||
                modelInfo.Layout.Panels[panel].EditInfo.Groups == null)
            {
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }
            else
            {
                bool            flag   = false;
                GroupCollection groups = modelInfo.Layout.Panels[panel].EditInfo.Groups;
                foreach (Group group in groups)
                {
                    if (group.Next == index)
                    {
                        group.Next = group.Index;
                    }
                    if (group.Index == index)
                    {
                        modelInfo.Layout.Panels[panel].EditInfo.Groups.Remove(group);
                        flag = true;
                        break;
                    }
                }
                ajaxMessage.Success = flag;
                if (flag)
                {
                    ajaxMessage.Message = "删除成功!";
                    ajaxMessage.Data    = modelInfo.Layout.Panels[panel].EditInfo.Groups;
                    ModelHelper.SaveModelInfo(modelInfo);
                }
                else
                {
                    ajaxMessage.Message = "删除失败!";
                }
                return(JavaScriptConvert.SerializeObject(ajaxMessage).Replace("null", "\"\""));
            }
        }
Esempio n. 5
0
        public string GetGroups(string model, string panel)
        {
            ModelInfo modelInfo = ModelHelper.GetModelInfo(model);

            if (modelInfo.Layout.Panels[panel] == null || modelInfo.Layout.Panels[panel].EditInfo == null ||
                modelInfo.Layout.Panels[panel].EditInfo.Groups == null)
            {
                AjaxMessage ajaxMessage = new AjaxMessage();
                ajaxMessage.Success = false;
                ajaxMessage.Message = "控件为空!";
                return(JsonConvert.SerializeObject(ajaxMessage));
            }
            else
            {
                AjaxMessage ajaxMessage = new AjaxMessage();
                ajaxMessage.Success = true;
                ajaxMessage.Message = "获取成功!";
                GroupCollection groups = modelInfo.Layout.Panels[panel].EditInfo.Groups;
                ajaxMessage.Data = groups;// editControls;
                return(JsonConvert.SerializeObject(ajaxMessage).Replace("null", "\"\""));
            }
        }
Esempio n. 6
0
        public string AddSingleDataColumn(string model, string label, string name, string title, string search, string dataType, int maxLength)
        {
            //获取对应的modelinfo
            ModelInfo modelInfo = ModelHelper.GetModelInfoByName(model);

            bool success = false;

            AjaxMessage ajaxMessage = new AjaxMessage();

            ajaxMessage.Success = success;

            if (modelInfo == null)
            {
                ajaxMessage.Message = "模型对象为空!";
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }

            if (CheckRepetColumn(modelInfo, delegate(We7DataColumn dc)
            {
                return(dc.Label == label);
            }))
            {
                ajaxMessage.Message = "当前中文名称已存在";
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }

            if (CheckRepetColumn(modelInfo, delegate(We7DataColumn dc)
            {
                return(String.Compare(dc.Name, name, true) == 0);
            }))
            {
                ajaxMessage.Message = "当前英文名已存在";
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }


            We7DataColumn column = new We7DataColumn();

            column.DataType = (TypeCode)Enum.Parse(typeof(TypeCode), dataType, true);
            if (column.DataType == TypeCode.String)
            {
                column.MaxLength = maxLength;
            }
            ParameterDirection direction = ParameterDirection.Input;
            string             mapping   = string.Empty;

            if (title == "true")
            {
                direction = ParameterDirection.Output;
                if (hasTitle(modelInfo))
                {
                    ajaxMessage.Message = "已经拥有标题项!";
                    return(JavaScriptConvert.SerializeObject(ajaxMessage));
                }
                mapping = "Title";
            }
            if (title != "true" && search == "true")
            {
                int count = 0;
                direction = ParameterDirection.Output;
                mapping   = GetMapping(modelInfo, out count);

                if (string.IsNullOrEmpty(mapping))
                {
                    ajaxMessage.Message = "已经拥有最大查询项:" + count.ToString();
                    return(JavaScriptConvert.SerializeObject(ajaxMessage));
                }
            }
            column.Direction = direction;
            column.Label     = label;
            column.Name      = name;
            //column.Require = true;
            column.Mapping = mapping;


            //TODO::tedyding 是否存在Tables 以及多个表
            if (modelInfo.DataSet.Tables == null)
            {
                We7.Model.Core.We7DataTable table = new We7DataTable();
                modelInfo.DataSet.Tables.Add(table);
            }

            modelInfo.DataSet.Tables[0].Columns.AddOrUpdate(column);


            success = ModelHelper.SaveModelInfo(modelInfo, model);
            if (success)
            {
                ajaxMessage.Success = success;
                ajaxMessage.Message = "添加成功!";
            }
            else
            {
                ajaxMessage.Message = "添加失败!";
            }
            return(JavaScriptConvert.SerializeObject(ajaxMessage));
        }