Ejemplo n.º 1
0
        /// <summary>
        /// 生成属性
        /// </summary>
        public static Dictionary <string, MetaDataProperty> RegisterPropertys(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            Dictionary <string, MetaDataProperty> PropertyData = new Dictionary <string, MetaDataProperty>();
            var items = screenDef.Children.Where(a => a.MemberType == EMemberType.Property).ToList();

            foreach (var item in items)
            {
                MetaDataProperty propertyMember = GetPropertyContent(item);
                PropertyData.Add(item.Name, propertyMember);
            }
            return(PropertyData);
        }
Ejemplo n.º 2
0
        private static MetaDataProperty GetDataMemberContent(MemberBase mb)
        {
            var    item = mb as DataMember;
            var    typeContent = item.Content as CommonDataType;
            string defaultValue = string.Empty, maxValue = string.Empty, minValue = string.Empty, maxLength = string.Empty, minLength = string.Empty;

            BuildCommonMethod.GetDataTypeValue(typeContent, ref defaultValue, ref maxValue, ref minValue, ref maxLength, ref minLength);
            var propertyMember = new MetaDataProperty()
            {
                Name         = item.Name,
                Title        = item.Title,
                IsRequired   = item.IsRequired,
                IsCollection = false,
                DefaultValue = defaultValue,
                MaxValue     = maxValue,
                MinValue     = minValue,
                MaxLength    = maxLength,
                MinLength    = minLength,
                DataType     = BuildCommonMethod.GetTypeNameByIon(typeContent.BaseType)
            };

            return(propertyMember);
        }
Ejemplo n.º 3
0
        private static MetaDataDataSet BuildMetaDataDataSet(string entityName, MemberBase memberBase)
        {
            string        optionStr = string.Empty, dataSetType = string.Empty;
            StringBuilder options = new StringBuilder();

            dynamic dats = memberBase as DataSet;

            if (memberBase.MemberType == EMemberType.DataSet)
            {
                dats = memberBase as DataSet;
                if (dats.EntityId > 0)
                {
                    if (dats.IsCollection)
                    {
                        dataSetType = "RemoteDataSet";
                    }
                    else
                    {
                        dataSetType = "RemoteDataObject";
                    }
                }
                else
                {
                    if (dats.IsCollection)
                    {
                        dataSetType = "LocalDataSet";
                    }
                    else
                    {
                        dataSetType = "LocalDataObject";
                    }
                }
                options.AppendLine("refreshOnLoaded:true,");
            }
            else
            {
                dats = memberBase as Objects;
                if (dats.EntityId > 0)
                {
                    if (dats.IsCollection)
                    {
                        dataSetType = "RemoteDataSet";
                    }
                    else
                    {
                        dataSetType = "RemoteDataObject";
                    }
                }
                else
                {
                    if (dats.IsCollection)
                    {
                        dataSetType = "LocalDataSet";
                    }
                    else
                    {
                        dataSetType = "LocalDataObject";
                    }
                }
            }

            #region 过滤条件
            string filters = GetFilterContent(dats);
            if (!string.IsNullOrEmpty(filters))
            {
                options.AppendLine($"where:{filters},");
            }
            #endregion
            #region 数据集中的属性,方法,事件,选中项中的数据成员/方法/展开成员
            StringBuilder           expand                 = new StringBuilder();
            List <MetaDataProperty> listProperty           = new List <MetaDataProperty>();
            List <MetaDataMethod>   listMethod             = new List <MetaDataMethod>();
            List <MetaDataMethod>   listEvent              = new List <MetaDataMethod>();
            List <MetaDataProperty> listSelectedItemMember = new List <MetaDataProperty>();
            List <MetaDataMethod>   listSelectedItemMethod = new List <MetaDataMethod>();
            foreach (var child in dats.Children)
            {
                if (child.MemberType == EMemberType.Property)
                {
                    MetaDataProperty propertyMember = GetPropertyContent(child);
                    listProperty.Add(propertyMember);
                }
                else if (child.MemberType == EMemberType.Method)
                {
                    MetaDataMethod methodMember = GetMethodContent(child);
                    listMethod.Add(methodMember);
                }
                else if (child.MemberType == EMemberType.Events)
                {
                    foreach (var evt in child.Children)
                    {
                        MetaDataMethod eventMember = GetEventContent(evt);
                        if (eventMember != null)
                        {
                            listEvent.Add(eventMember);
                        }
                    }
                }
                else if (child.MemberType == EMemberType.SelectedItem)
                {
                    foreach (var item in child.Children)
                    {
                        if (item.MemberType == EMemberType.DataMember)
                        {
                            MetaDataProperty propertyMember = GetDataMemberContent(item);
                            listSelectedItemMember.Add(propertyMember);
                        }
                        else if (item.MemberType == EMemberType.Method)
                        {
                            MetaDataMethod methodMember = GetMethodContent(item);
                            listSelectedItemMethod.Add(methodMember);
                        }
                        else if (item.MemberType == EMemberType.NavigateMember)
                        {
                            GetExpandContent(item, expand, "");
                        }
                    }
                }

                else if (child.MemberType == EMemberType.QueryParameters)
                {
                    StringBuilder queryParas = new StringBuilder();
                    string        parasStr   = GetParameterContent(child);
                    if (!string.IsNullOrEmpty(parasStr))
                    {
                        parasStr = parasStr.Substring(0, parasStr.Length - 3);
                    }
                    queryParas.AppendLine("parameters:{");
                    queryParas.AppendLine(parasStr);
                    queryParas.AppendLine("},");
                    options.Append(queryParas);
                }
            }
            if (!string.IsNullOrEmpty(expand.ToString()))
            {
                string expandStr = expand.ToString().Substring(0, expand.ToString().Length - 1);
                options.AppendLine($"orderBy:[{expandStr.ToString()}],");
            }
            #endregion
            #region 排序
            StringBuilder orderByStr = new StringBuilder();
            foreach (var sort in dats.Sorts)
            {
                string sortStr = string.Format("{0} {1}", sort.Name, sort.Direction == 0 ? "asc" : "desc");
                if (orderByStr.ToString().Length == 0)
                {
                    orderByStr.Append("\"" + sortStr + "\"");
                }
                else
                {
                    orderByStr.Append(",\"" + sortStr + "\"");
                }
            }
            if (!string.IsNullOrEmpty(orderByStr.ToString()))
            {
                options.AppendLine($"expand:[{orderByStr.ToString()}],");
            }
            #endregion
            if (!string.IsNullOrEmpty(options.ToString()))
            {
                optionStr = options.ToString().Substring(0, options.ToString().Length - 3);
            }
            var DataSetMember = new MetaDataDataSet
            {
                Type                = dataSetType,
                Name                = dats.Name,
                Title               = dats.Title,
                EntityName          = entityName,
                Options             = optionStr,
                DataPropertys       = listProperty,
                DataMethods         = listMethod,
                DataEvents          = listEvent,
                SelectedItemMembers = listSelectedItemMember,
                SelectedItemMethods = listSelectedItemMethod
            };
            return(DataSetMember);
        }