Example #1
0
        public string SaveList(string model, string panel, string list, string condition, string pagesize, int index, string enable)
        {
            string colsJson = HttpContext.Current.Server.UrlDecode(list);

            string    conditionJson = HttpContext.Current.Server.UrlDecode(condition);
            ModelInfo modelInfo     = ModelHelper.GetModelInfo(model);

            try
            {
                if (modelInfo.Layout.Panels[panel] == null && panel == "multi")
                {
                    AddMutiPanel(modelInfo, model);
                    modelInfo = ModelHelper.GetModelInfo(model);
                }
                ColumnInfoCollection cols = JavaScriptConvert.DeserializeObject <ColumnInfoCollection>(colsJson);

                We7ControlCollection conditionCtr = JavaScriptConvert.DeserializeObject <We7ControlCollection>(conditionJson);

                ModelUIHandler.DealSystemColumn(cols, modelInfo);

                GetGroupByIndex(index, modelInfo.Layout.Panels[panel].ListInfo.Groups).Columns = cols;
                GetGroupByIndex(index, modelInfo.Layout.Panels[panel].ListInfo.Groups).Enable  = bool.Parse(enable);
                modelInfo.Layout.Panels[panel].Context.PageSize       = Convert.ToInt32(pagesize);
                modelInfo.Layout.Panels[panel].ConditionInfo.Controls = conditionCtr;

                ModelHelper.SaveModelInfo(modelInfo, model);

                //生成数据表
                DataBaseHelperFactory.Create().CreateTable(modelInfo);
            }
            catch (Exception ex)
            {
                //TODO:: resolve exception

                return(ex.Message);
            }

            return("保存完毕");
        }
Example #2
0
        public string SaveEdit(string model, string panel, string editControls, string copy, int index, string next, string enable)
        {
            string    editJson  = HttpContext.Current.Server.UrlDecode(editControls);
            ModelInfo modelInfo = ModelHelper.GetModelInfo(model);

            try
            {
                We7ControlCollection editCtrls = JavaScriptConvert.DeserializeObject <We7ControlCollection>(editJson);
                if (modelInfo.Layout.Panels[panel] == null && panel == "multi")
                {
                    AddMutiPanel(modelInfo, model);
                    modelInfo = ModelHelper.GetModelInfo(model);
                }
                foreach (We7Control editCtrl in editCtrls)
                {
                    if (editCtrl.Type == "RelationSelect")
                    {
                        //添加统计字段
                        AddCount(editCtrl, modelInfo);
                    }
                }

                Group group = GetGroupByIndex(index, modelInfo.Layout.Panels[panel].EditInfo.Groups);
                group.Controls = editCtrls;
                group.Next     = int.Parse(next);
                group.Enable   = bool.Parse(enable);
                if (modelInfo.Type == ModelType.ACCOUNT)
                {
                    List <We7Control> DeleteCtrs = new List <We7Control>();
                    foreach (We7Control ctr in modelInfo.Layout.Panels["fedit"].EditInfo.Controls)
                    {
                        if (ctr.Name == "ID")
                        {
                            continue;
                        }
                        DeleteCtrs.Add(ctr);
                    }
                    foreach (We7Control ctr in DeleteCtrs)
                    {
                        modelInfo.Layout.Panels["fedit"].EditInfo.Controls.Remove(ctr);
                    }
                    foreach (We7Control ctr in modelInfo.Layout.Panels["edit"].EditInfo.Controls)
                    {
                        if (ctr.Name == "ID")
                        {
                            continue;
                        }
                        group.Controls.Add(ctr.Clone() as We7Control);
                    }
                }

                if (copy == "true")
                {
                    if (modelInfo.Type == ModelType.ARTICLE)
                    {
                        if (modelInfo.Layout.Panels["multi"] != null)
                        {
                            modelInfo.Layout.Panels["multi"].EditInfo = modelInfo.Layout.Panels["edit"].EditInfo;
                        }
                    }
                }
                ModelHelper.SaveModelInfo(modelInfo, model);

                //生成数据表
                DataBaseHelperFactory.Create().CreateTable(modelInfo);
            }
            catch (Exception ex)
            {
                //TODO:: resolve exception

                return(ex.Message);
            }

            return("保存完毕");
        }
Example #3
0
        public string SaveList(string model, string panel, string list, string condition, string pagesize, int index, string enable)
        {
            string colsJson = HttpContext.Current.Server.UrlDecode(list);

            string    conditionJson = HttpContext.Current.Server.UrlDecode(condition);
            ModelInfo modelInfo     = ModelHelper.GetModelInfo(model);

            try
            {
                if (modelInfo.Layout.Panels[panel] == null && panel == "multi")
                {
                    AddMutiPanel(modelInfo, model);
                    modelInfo = ModelHelper.GetModelInfo(model);
                }
                ColumnInfoCollection cols = JsonConvert.DeserializeObject <ColumnInfoCollection>(colsJson);

                We7ControlCollection conditionCtr = JsonConvert.DeserializeObject <We7ControlCollection>(conditionJson);

                ModelUIHandler.DealSystemColumn(cols, modelInfo);


                /* begin
                 * ndoe:此段代码的作用是查找编辑配置
                 *      有param["model"]的项(此param作用于关联控件)
                 *      列表查询读取此段param信息可以得到关联表信息。
                 * ps:如果您试图维护此代码,或者有更好的办法。请谨慎为之。
                 * author:丁乐
                 * date:2011/12/19
                 */
                if (modelInfo.Layout.Panels["edit"] != null && modelInfo.Layout.Panels["edit"].EditInfo != null && modelInfo.Layout.Panels["edit"].EditInfo.Controls != null && modelInfo.Layout.Panels["edit"].EditInfo.Controls.Count > 0)
                {
                    foreach (var item in modelInfo.Layout.Panels["edit"].EditInfo.Controls)
                    {
                        if (item.Params != null && item.Params.Count > 0 && !string.IsNullOrEmpty(item.Params["model"]))
                        {
                            if (cols[item.Name] != null && cols[item.Name].Params != null)
                            {
                                cols[item.Name].Params.Add(new Param("model", item.Params["model"]));
                                cols[item.Name].Params.Add(new Param("textfield", item.Params["textfield"]));
                                cols[item.Name].Params.Add(new Param("valuefield", item.Params["valuefield"]));
                            }
                            else if (cols[item.Name] != null && cols[item.Name].Params == null)
                            {
                                cols[item.Name].Params = new ParamCollection {
                                    new Param("model", item.Params["model"]), new Param("textfield", item.Params["textfield"]), new Param("valuefield", item.Params["valuefield"])
                                };
                            }
                        }
                    }
                }
                /*end*/

                GetGroupByIndex(index, modelInfo.Layout.Panels[panel].ListInfo.Groups).Columns = cols;
                GetGroupByIndex(index, modelInfo.Layout.Panels[panel].ListInfo.Groups).Enable  = bool.Parse(enable);
                modelInfo.Layout.Panels[panel].Context.PageSize       = Convert.ToInt32(pagesize);
                modelInfo.Layout.Panels[panel].ConditionInfo.Controls = conditionCtr;

                ModelHelper.SaveModelInfo(modelInfo, model);

                //生成数据表
                DataBaseHelperFactory.Create().CreateTable(modelInfo);
            }
            catch (Exception ex)
            {
                //TODO:: resolve exception

                return(ex.Message);
            }

            return("保存完毕");
        }