Esempio n. 1
0
        internal void ProcessRefField(RegNameList <Tk5FieldInfoEx> fields)
        {
            if (Decoder == null)
            {
                return;
            }

            SimpleFieldDecoder decoder = Decoder as SimpleFieldDecoder;

            if (decoder == null || decoder.RefFields == null)
            {
                return;
            }

            foreach (var refField in decoder.RefFields)
            {
                Tk5FieldInfoEx refFieldInfo = fields[refField.RefField];
                if (refFieldInfo != null)
                {
                    refField.CtrlType = refFieldInfo.InternalControl.Control;
                }
                else
                {
                    TkDebug.ThrowToolkitException(string.Format(ObjectUtil.SysCulture,
                                                                "没有查找到{0}字段的定义,请确认", refField.RefField), this);
                }
            }
        }
        public static Tk5FieldInfoEx CreateDataXmlField(ITableSchemeEx scheme,
                                                        IFieldInfoEx field, IInputData input, BaseSingleMetaDataConfig config)
        {
            Tk5FieldInfoEx fieldInfo = new Tk5FieldInfoEx(field, input.Style);

            return(fieldInfo);
        }
Esempio n. 3
0
        public Tk5TableScheme(ITableSchemeEx scheme, IInputData input, ISingleMetaData config,
                              Func <ITableSchemeEx, IFieldInfoEx, IInputData, ISingleMetaData, Tk5FieldInfoEx> createFunc)
            : this()
        {
            TkDebug.AssertArgumentNull(scheme, "scheme", null);
            TkDebug.AssertArgumentNull(input, "input", null);
            TkDebug.AssertArgumentNull(config, "config", null);
            TkDebug.AssertArgumentNull(createFunc, "createFunc", null);

            SetFileDependency(scheme);
            TableName = scheme.TableName;
            TableDesc = scheme.TableDesc;
            NameField = scheme.NameField;

            PageStyle pageStyle = input.Style.Style;
            var       list      = from item in scheme.Fields
                                  where (item.Control.DefaultShow & pageStyle) == pageStyle
                                  select item;

            foreach (var item in list)
            {
                Tk5FieldInfoEx fieldInfo = createFunc(scheme, item, input, config);
                fList.Add(fieldInfo);
            }

            ProcessRefField();
        }
Esempio n. 4
0
 private void AddFields(IInputData input, List <AddFieldConfig> addFields)
 {
     if (addFields != null)
     {
         foreach (var field in addFields)
         {
             Tk5FieldInfoEx fieldInfo = new Tk5FieldInfoEx(field, input.Style);
             fieldInfo.SetControl(input.Style);
             fList.Add(fieldInfo);
         }
     }
 }
Esempio n. 5
0
        private void CopyFromTk5FieldInfo(Tk5FieldInfoEx field, string newNickName, IPageStyle style)
        {
            if (!string.IsNullOrEmpty(newNickName))
            {
                NickName = newNickName;
            }
            PlaceHolder  = field.PlaceHolder;
            Hint         = field.Hint;
            HintPosition = field.HintPosition;

            ListDetail      = field.ListDetail;
            Edit            = field.Edit;
            Extension       = field.Extension;
            Upload          = field.Upload;
            Constraints     = field.Constraints;
            InternalControl = field.InternalControl;
        }
Esempio n. 6
0
        internal Tk5TableScheme(ITableSchemeEx scheme, IInputData input, BaseSingleMetaDataConfig config,
                                Func <ITableSchemeEx, IFieldInfoEx, IInputData, BaseSingleMetaDataConfig, Tk5FieldInfoEx> createFunc)
            : this()
        {
            SetFileDependency(scheme);
            if (!string.IsNullOrEmpty(config.TableName))
            {
                TableName = config.TableName;
            }
            else
            {
                TableName = scheme.TableName;
            }
            if (config.TableDesc != null)
            {
                TableDesc = config.TableDesc.ToString();
            }
            else
            {
                TableDesc = scheme.TableDesc;
            }
            NameField = scheme.NameField;

            PageStyle pageStyle = input.Style.Style;
            var       list      = from item in scheme.Fields
                                  where IsShow(item, pageStyle, config.OverrideFields)
                                  select item;

            foreach (var item in list)
            {
                Tk5FieldInfoEx fieldInfo = createFunc(scheme, item, input, config);
                fList.Add(fieldInfo);
            }

            // 删除主Schema中的字段
            DelFields(config.DelFields);
            // 重载主Schema中的字段
            OverrideFields(input, config.OverrideFields);
            // 添加虚拟字段到主Schema中
            AddFields(input, config.AddFields);

            ProcessRefField();
        }
Esempio n. 7
0
        internal Tk5FieldInfoEx(Tk5FieldInfoEx field, string newNickName, IPageStyle style)
        {
            CopyFieldInfo(field);

            CopyFromTk5FieldInfo(field, newNickName, style);
        }
Esempio n. 8
0
 public JsonField(Tk5FieldInfoEx field)
 {
     Name = field.NickName;
     Type = field.JsControlName;
 }
Esempio n. 9
0
 public JsonField(string nickName, Tk5FieldInfoEx field)
 {
     Name = nickName;
     Type = field.JsControlName;
 }
Esempio n. 10
0
 private static bool IsShowField(Tk5FieldInfoEx item)
 {
     return(item.InternalControl.SrcControl != ControlType.Hidden &&
            item.InternalControl.SrcControl != ControlType.None);
 }
Esempio n. 11
0
        private void OverrideFields(IInputData input, RegNameList <OverrideFieldConfig> overrideFields)
        {
            if (overrideFields != null)
            {
                foreach (var field in overrideFields)
                {
                    Tk5FieldInfoEx item = fList[field.NickName];
                    if (item != null)
                    {
                        if (field.IsEmpty.HasValue)
                        {
                            item.IsEmpty = field.IsEmpty.Value;
                        }
                        if (field.PlaceHolder.HasValue)
                        {
                            item.PlaceHolder = field.PlaceHolder.Value;
                        }
                        if (field.Length.HasValue)
                        {
                            item.Length = field.Length.Value;
                        }

                        if (field.Order.HasValue)
                        {
                            item.InternalControl.Order = field.Order.Value;
                        }
                        if (field.Control.HasValue)
                        {
                            item.InternalControl.SrcControl = field.Control.Value;
                            item.SetControl(input.Style);
                        }
                        if (field.DisplayName != null)
                        {
                            item.DisplayName = field.DisplayName.ToString();
                        }
                        if (field.Hint != null)
                        {
                            item.Hint         = field.Hint.ToString();
                            item.HintPosition = field.Hint.Position;
                        }
                        if (field.CodeTable != null)
                        {
                            item.Decoder = new SimpleFieldDecoder(field.CodeTable, DecoderType.CodeTable);
                        }
                        else if (field.EasySearch != null)
                        {
                            item.Decoder = new SimpleFieldDecoder(field.EasySearch, DecoderType.EasySearch);
                        }

                        if (field.Layout != null)
                        {
                            ((SimpleFieldLayout)item.Layout).Override(field.Layout);
                        }
                        switch (input.Style.Style)
                        {
                        case PageStyle.Insert:
                        case PageStyle.Update:
                            OverrideEditConfig ovEdit = field.Edit;
                            if (ovEdit != null)
                            {
                                if (item.Edit == null)
                                {
                                    item.Edit = new Tk5EditConfig();
                                }
                                item.Edit.Override(ovEdit);
                            }
                            break;

                        case PageStyle.Detail:
                        case PageStyle.List:
                            var ovLD = field.ListDetail;
                            if (ovLD != null)
                            {
                                if (item.ListDetail == null)
                                {
                                    item.ListDetail = new Tk5ListDetailConfig();
                                }
                                item.ListDetail.Override(ovLD);
                            }
                            break;
                        }
                        var ovExt = field.Extension;
                        if (ovExt != null)
                        {
                            if (item.Extension == null)
                            {
                                item.Extension = new Tk5ExtensionConfig();
                            }
                            item.Extension.Override(item, ovExt);
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        public static Tk5FieldInfoEx CreateDataXmlField(ITableSchemeEx scheme,
                                                        IFieldInfoEx field, IInputData input, BaseSingleMetaDataConfig config)
        {
            Tk5FieldInfoEx fieldInfo = new Tk5FieldInfoEx(field, input.Style);
            //Tk5DataXml dataXml = scheme.Convert<Tk5DataXml>();
            IDisplayObject display = scheme as IDisplayObject;

            if (display != null && input.Style.Style == PageStyle.List)
            {
                bool isNameField = display.SupportDisplay && field.FieldName == display.Name.FieldName;
                if (!config.DisableAutoDetailLink)
                {
                    if (!isNameField && fieldInfo.ListDetail != null)
                    {
                        IConfigCreator <IDisplay> iConfigCreator = fieldInfo.ListDetail.ListDisplay;
                        IHrefDisplay hrefDisplay = iConfigCreator as IHrefDisplay;
                        if (hrefDisplay != null)
                        {
                            if (string.IsNullOrEmpty(hrefDisplay.Content))
                            {
                                hrefDisplay.Content = CreateContent(input, display);
                            }
                        }
                    }
                    if (isNameField)
                    {
                        if (fieldInfo.ListDetail == null)
                        {
                            fieldInfo.ListDetail = new Tk5ListDetailConfig();
                        }
                        string content = CreateContent(input, display);
                        if (fieldInfo.ListDetail.Link == null)
                        {
                            fieldInfo.ListDetail.Link = new Tk5LinkConfig(content);
                        }
                        IHrefDisplay hrefDisplay = fieldInfo.ListDetail.ListDisplay as IHrefDisplay;
                        if (hrefDisplay == null)
                        {
                            string displayXml = string.Format(ObjectUtil.SysCulture,
                                                              "<tk:ListRefDisplay><tk:NormalDisplay/></tk:ListRefDisplay>", content);
                            var listRefDisplay = Tk5FieldInfoEx.GetDisplay(displayXml);
                            if (fieldInfo.ListDetail.ListDisplay != null)
                            {
                                var displayContainer = listRefDisplay as IDisplayContainer;
                                if (displayContainer != null)
                                {
                                    displayContainer.SetInternalDisplay(fieldInfo.ListDetail.ListDisplay);
                                }
                            }
                            fieldInfo.ListDetail.ListDisplay = listRefDisplay;
                            hrefDisplay = listRefDisplay.Convert <IHrefDisplay>();
                        }
                        if (string.IsNullOrEmpty(hrefDisplay.Content))
                        {
                            hrefDisplay.Content = content;
                        }
                    }
                }
            }
            return(fieldInfo);
        }