Example #1
0
        protected override void Create()
        {
            var element = new AxEdtInt64 {
                Name = ElementName,
            };

            MetaService.CreateExtendedDataType(element, Model);
        }
        public AxEdt BuildEdt()
        {
            var edt = _axHelper.MetadataProvider.Edts.Read(EdtText);

            if (edt != null)
            {
                IsEdtExist = true;
            }
            else
            {
                switch (FieldType)
                {
                case FieldType.String:
                    var edtString = new AxEdtString();
                    if (NewStrEdtLen > 0 && ExtendsText == String.Empty)
                    {
                        edtString.StringSize = NewStrEdtLen;
                    }
                    edt = edtString;
                    break;

                case FieldType.Integer:
                    edt = new AxEdtInt();
                    break;

                case FieldType.Real:
                    edt = new AxEdtReal();
                    break;

                case FieldType.DateTime:
                    edt = new AxEdtUtcDateTime();
                    if (ExtendsText == String.Empty)
                    {
                        edt.Extends = "TransDateTime";
                    }
                    break;

                case FieldType.Guid:
                    edt = new AxEdtGuid();
                    break;

                case FieldType.Int64:
                    edt = new AxEdtInt64();
                    break;

                case FieldType.Enum:
                    AxEdtEnum edtEnum = new AxEdtEnum();

                    AxEdtEnum edtLocal =
                        _axHelper.MetadataProvider.Edts.Read(ExtendsText) as AxEdtEnum;

                    if (edtLocal != null)
                    {
                        edtEnum.EnumType = edtLocal.EnumType;
                    }

                    edt = edtEnum;
                    break;

                case FieldType.Time:
                    edt = new AxEdtTime();
                    break;

                case FieldType.Container:
                    edt = new AxEdtContainer();
                    break;

                case FieldType.Memo:
                    edt = new AxEdtString();
                    if (ExtendsText == String.Empty)
                    {
                        edt.Extends = "FreeTxt";
                    }
                    break;

                case FieldType.Date:
                    edt = new AxEdtDate();
                    if (ExtendsText == String.Empty)
                    {
                        edt.Extends = "TransDate";
                    }
                    break;

                default:
                    throw new NotImplementedException(
                              $"Field type {FieldType.ToString()} is not supported");
                }
                edt.Name = EdtText;

                if (ExtendsText != string.Empty)
                {
                    edt.Extends = ExtendsText;
                }
                if (LabelText != String.Empty)
                {
                    edt.Label = LabelText;
                }
                if (HelpTextText != String.Empty)
                {
                    edt.HelpText = HelpTextText;
                }
            }

            return(edt);
        }