Esempio n. 1
0
        public JsonResult ImportItemFromLayout(string formID)
        {
            var form = entities.Set <S_UI_Form>().SingleOrDefault(c => c.ID == formID);

            if (string.IsNullOrEmpty(form.Layout))
            {
                throw new Exception("布局还没有建立");
            }
            UIFO uiFO = FormulaHelper.CreateFO <UIFO>();

            Regex reg    = new Regex(UIFO.uiRegStr);
            var   matchs = reg.Matches(form.Layout, 0);

            var list = JsonHelper.ToObject <List <FormItem> >(form.Items ?? "[]");

            int index = list.Count;

            foreach (Match match in matchs)
            {
                string name = match.Value.Trim('{', '}');
                if (list.SingleOrDefault(c => c.Name == name) == null)
                {
                    list.Add(new FormItem
                    {
                        ID           = FormulaHelper.CreateGuid(),
                        Code         = uiFO.GetHanZiPinYinString(name),
                        Name         = name,
                        Enabled      = "true",
                        Visible      = "true",
                        DefaultValue = "",
                        ItemType     = "TextBox",
                        FieldType    = "nvarchar(200)"
                    });
                }
            }
            return(Json(list));
        }