Exemplo n.º 1
0
        protected void EntityDataSource_Selected(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            ClientDataSet.EntityFieldDataTable table = e.ReturnValue as ClientDataSet.EntityFieldDataTable;
            if (table != null)
            {
                if (table.Count > 0)
                {
                    ClientDataSet.EntityFieldRow row = table[0];
                    EntityFieldType fieldType        = (EntityFieldType)row.EntityFieldTypeId;
                    SwitchDataTypeFields(fieldType, (EntityFieldDataType)row.DataTypeId);
                    (EditForm.Fields[4] as TextBoxField).Required = (!row.AllowDBNull);
                    if (fieldType != EntityFieldType.Value)
                    {
                        (EditForm.Fields[5] as CheckBoxField).AutoPostBack = false;
                    }
                    ConfigureRangeValidators((EntityFieldDataType)row.DataTypeId, row.DecimalDigits
                                             , (EditForm.Fields[4] as TextBoxField), (EditForm.Fields[9] as TextBoxField), (EditForm.Fields[10] as TextBoxField));
                }
            }
        }
Exemplo n.º 2
0
 private void SwitchDataTypeFields(EntityFieldType fieldType, EntityFieldDataType dataType)
 {
     EditForm.Fields[4].Visible = (fieldType == EntityFieldType.Value);
     if (dataType == EntityFieldDataType.NotSet)
     {
         EditForm.Fields[7].Visible    = true;
         EditForm.Fields[7].HeaderText = Resources.EntityFieldsControl_EditForm_MaxLengthField_HeaderText;
         EditForm.Fields[8].Visible    = true;
         EditForm.Fields[9].Visible    = true;
         EditForm.Fields[10].Visible   = true;
     }
     else
     {
         EditForm.Fields[7].Visible = ((dataType == EntityFieldDataType.Text) || (dataType == EntityFieldDataType.Numeric));
         if (dataType == EntityFieldDataType.Text)
         {
             EditForm.Fields[7].HeaderText = Resources.EntityFieldsControl_EditForm_MaxLengthField_HeaderText;
         }
         else if (dataType == EntityFieldDataType.Numeric)
         {
             EditForm.Fields[7].HeaderText = Resources.EntityFieldsControl_EditForm_LengthField_HeaderText;
         }
         EditForm.Fields[8].Visible = (dataType == EntityFieldDataType.Numeric);
         EditForm.Fields[9].Visible = EditForm.Fields[10].Visible = ((dataType == EntityFieldDataType.DateTime) || (dataType == EntityFieldDataType.Numeric));
     }
 }
        } = false;                                                         // auxiliary field used for index creation only

        public EntityField
        (
            EntityFieldType fieldType,
            String name,
            int?stringLengthMin              = null,
            int stringLengthMax              = 32,
            String validationRegExp          = null,
            Boolean validationCheckExistance = false,
            String directoryEnumName         = null,
            LinkType linkType                  = LinkType.NoLink,
            String linkedEntityName            = "",
            String linkedFieldName             = "Id",
            int gridColumnWidth                = 100,
            Boolean gridColumnIsSortingAllowed = false,
            Boolean fieldFilterIsRequired      = false,
            Boolean fieldFilterIsMinRequired   = false
        )
        {
            FieldType                  = fieldType;
            Name                       = name;
            StringLengthMin            = stringLengthMin;
            StringLengthMax            = stringLengthMax;
            ValidationRegExp           = validationRegExp;
            ValidationCheckExistance   = validationCheckExistance;
            DirectoryEnumName          = directoryEnumName;
            LinkType                   = linkType;
            LinkedEntityName           = linkedEntityName;
            LinkedFieldName            = linkedFieldName;
            GridColumnWidth            = gridColumnWidth;
            GridColumnIsSortingAllowed = gridColumnIsSortingAllowed;
            FieldFilterIsRequired      = fieldFilterIsRequired;
            FieldFilterIsMinRequired   = fieldFilterIsMinRequired;
        }
Exemplo n.º 4
0
 public EntityField(string name, int instanceID, EntityFieldType fieldType, bool isKey, bool isRequired, bool isUnique,
                    int lookUpID, bool isCore, int entityKey, string value, bool isReadOnly, string defaultValue, int displayOrder,
                    List <string> lookUpArray, string min, string max, int maxLength, string displayName, bool autoIncrement, int incrementfrom,
                    int incrementby, string description, bool enableencription, bool enablelimit)
 {
     Name               = name ?? throw new ArgumentNullException(nameof(name));
     InstanceID         = instanceID;
     FieldType          = fieldType;
     IsKey              = isKey;
     IsRequired         = isRequired;
     IsUnique           = isUnique;
     LookUpID           = lookUpID;
     IsCore             = isCore;
     EntityKey          = entityKey;
     Value              = value ?? throw new ArgumentNullException(nameof(value));
     IsReadOnly         = isReadOnly;
     DefaultValue       = defaultValue ?? throw new ArgumentNullException(nameof(defaultValue));
     DisplayOrder       = displayOrder;
     LookUpArray        = lookUpArray ?? throw new ArgumentNullException(nameof(lookUpArray));
     Min                = min ?? throw new ArgumentNullException(nameof(min));
     Max                = max ?? throw new ArgumentNullException(nameof(max));
     MaxLength          = maxLength;
     DisplayName        = displayName ?? throw new ArgumentNullException(nameof(displayName));
     AutoIncrement      = autoIncrement;
     Incrementfrom      = incrementfrom;
     Incrementby        = incrementby;
     IsShow             = true;
     Description        = description;
     enableContentLimit = enablelimit;
     EnableEncription   = enableencription;
     dataEntity         = new Data.EntitySchema();
 }
Exemplo n.º 5
0
 public uc_Field(EntityFieldType type)
 {
     _type  = type.Type;
     _query = type.Query;
     InitializeComponent();
     SetupControl();
 }
Exemplo n.º 6
0
 public EntityInstance(int pinstanceID)
 {
     InstanceID    = pinstanceID;
     Name          = "";
     InstanceID    = -1;
     FieldType     = EntityFieldType._Text;
     IsKey         = false;
     IsRequired    = false;
     IsUnique      = false;
     LookUpID      = -1;
     IsCore        = false;
     EntityKey     = -1;
     Value         = "";
     IsReadOnly    = false;
     DefaultValue  = "";
     DisplayOrder  = -1;
     LookUpArray   = new List <string>();
     Min           = "0";
     Max           = "0";
     MaxLength     = 0;
     Note          = "";
     AutoIncrement = false;
     Incrementfrom = 0;
     Incrementby   = 0;
 }
Exemplo n.º 7
0
 public EntityInstance(string name, int instanceID, EntityFieldType fieldType, bool isKey, bool isRequired, bool isUnique, int lookUpID, bool isCore, int entityKey, string value, bool isReadOnly, string defaultValue, int displayOrder, List <string> lookUpArray, string min, string max, int maxLength, string note, bool autoIncrement, long incrementfrom, long incrementby)
 {
     Name          = name ?? throw new ArgumentNullException(nameof(name));
     InstanceID    = instanceID;
     FieldType     = fieldType;
     IsKey         = isKey;
     IsRequired    = isRequired;
     IsUnique      = isUnique;
     LookUpID      = lookUpID;
     IsCore        = isCore;
     EntityKey     = entityKey;
     Value         = value ?? throw new ArgumentNullException(nameof(value));
     IsReadOnly    = isReadOnly;
     DefaultValue  = defaultValue ?? throw new ArgumentNullException(nameof(defaultValue));
     DisplayOrder  = displayOrder;
     LookUpArray   = lookUpArray ?? throw new ArgumentNullException(nameof(lookUpArray));
     Min           = min ?? throw new ArgumentNullException(nameof(min));
     Max           = max ?? throw new ArgumentNullException(nameof(max));
     MaxLength     = maxLength;
     Note          = note ?? throw new ArgumentNullException(nameof(note));
     AutoIncrement = autoIncrement;
     Incrementfrom = incrementfrom;
     Incrementby   = incrementby;
     IsShow        = true;
 }
 public RangeFieldTransformer(RangeField field) : base("range", field.Negate)
 {
     FieldType   = field.FieldType;
     Key         = field.Name;
     Left        = field.Left;
     Right       = field.Right;
     LeftClosed  = field.LeftClosed;
     RightClosed = field.RightClosed;
 }
 public RangeField(bool negate, string name, EntityFieldType type, object left, bool leftClosed,
                   object right, bool rightClosed) : base(negate)
 {
     Name        = name;
     FieldType   = type;
     Left        = left;
     Right       = right;
     LeftClosed  = leftClosed;
     RightClosed = rightClosed;
 }
Exemplo n.º 10
0
        public static Type GetValueType(this EntityFieldType fieldType)
        {
            switch (fieldType)
            {
            case EntityFieldType.EntityId: return(typeof(EntityId));

            case EntityFieldType.String: return(typeof(string));

            case EntityFieldType.DateTime: return(typeof(DateTime));

            case EntityFieldType.Int16: return(typeof(short));

            case EntityFieldType.UInt16: return(typeof(ushort));

            case EntityFieldType.Int32: return(typeof(int));

            case EntityFieldType.UInt32: return(typeof(uint));

            case EntityFieldType.Int64: return(typeof(long));

            case EntityFieldType.UInt64: return(typeof(ulong));

            case EntityFieldType.Decimal: return(typeof(decimal));

            case EntityFieldType.Float: return(typeof(float));

            case EntityFieldType.Double: return(typeof(double));

            case EntityFieldType.Boolean: return(typeof(bool));

            case EntityFieldType.Guid: return(typeof(Guid));

            case EntityFieldType.Byte: return(typeof(byte));

            case EntityFieldType.Binary: return(typeof(byte[]));

            case EntityFieldType.Enum: return(typeof(int));

            default: return(typeof(object));
            }
        }
        public SingleSearchFieldTransformer(SingleField field) : base("field", field.Negate)
        {
            Key = field.Name;
            if (field.TermValue != null)
            {
                Value    = field.TermValue.Value;
                TermType = field.TermValue.TermType;

                if (field.TermValue.BoostValue != DefaultTermValue.NoBoost)
                {
                    Boost = field.TermValue.BoostValue;
                }
                else
                {
                    Boost = null;
                }
            }
            else
            {
                Value     = field.Value;
                FieldType = FieldUtils.DetectFieldType(field.Value);
            }
        }
Exemplo n.º 12
0
 public SingleField(bool negate, string name, object value) : base(negate)
 {
     Name      = name;
     Value     = value;
     FieldType = FieldUtils.DetectFieldType(value);
 }
Exemplo n.º 13
0
        internal void Read(BinSerializer bs)
        {
            Id         = bs.ReadUInt16();
            MemberType = (EntityMemberType)bs.ReadByte();
            ValueType  = (EntityFieldType)bs.ReadByte();
            Flag.Data  = bs.ReadByte();

            switch (MemberType)
            {
            case EntityMemberType.DataField:
                switch (ValueType)
                {
                case EntityFieldType.Boolean: BooleanValue = bs.ReadBoolean(); break;

                case EntityFieldType.Byte: ByteValue = bs.ReadByte(); break;

                case EntityFieldType.Float: FloatValue = bs.ReadFloat(); break;

                case EntityFieldType.Double: DoubleValue = bs.ReadDouble(); break;

                case EntityFieldType.Enum: Int32Value = bs.ReadInt32(); break;

                case EntityFieldType.Int16: Int16Value = bs.ReadInt16(); break;

                case EntityFieldType.UInt16: UInt16Value = bs.ReadUInt16(); break;

                case EntityFieldType.Int32: Int32Value = bs.ReadInt32(); break;

                case EntityFieldType.UInt32: UInt32Value = bs.ReadUInt32(); break;

                case EntityFieldType.Int64: Int64Value = bs.ReadInt64(); break;

                case EntityFieldType.UInt64: UInt64Value = bs.ReadUInt64(); break;

                case EntityFieldType.DateTime: DateTimeValue = bs.ReadDateTime(); break;

                case EntityFieldType.Guid: GuidValue = bs.ReadGuid(); break;

                case EntityFieldType.Decimal: DecimalValue = bs.ReadDecimal(); break;

                case EntityFieldType.String: ObjectValue = bs.ReadString(); break;

                case EntityFieldType.Binary: ObjectValue = bs.ReadByteArray(); break;

                default: throw new NotSupportedException();
                }
                break;

            case EntityMemberType.EntityRef:
            case EntityMemberType.EntitySet: ObjectValue = bs.Deserialize(); break;

            //case EntityMemberType.ImageRef: this.ObjectValue = bs.Deserialize(); break;
            //case EntityMemberType.FieldSet:
            //switch (this.ValueType)
            //{
            //    case EntityFieldType.String:
            //        {
            //            var array = bs.ReadStringArray();
            //            this.ObjectValue = array == null ? null : new HashSet<string>(array);
            //        }
            //        break;
            //    case EntityFieldType.Integer:
            //        {
            //            var array = bs.ReadInt32Array();
            //            this.ObjectValue = array == null ? null : new HashSet<int>(array);
            //        }
            //        break;
            //    case EntityFieldType.Guid:
            //        {
            //            var array = bs.ReadGuidArray();
            //            this.ObjectValue = array == null ? null : new HashSet<Guid>(array);
            //        }
            //        break;
            //    case EntityFieldType.Float:
            //        {
            //            var array = bs.ReadFloatArray();
            //            this.ObjectValue = array == null ? null : new HashSet<float>(array);
            //        }
            //        break;
            //    case EntityFieldType.Double:
            //        {
            //            var array = bs.ReadDoubleArray();
            //            this.ObjectValue = array == null ? null : new HashSet<double>(array);
            //        }
            //        break;
            //    case EntityFieldType.Decimal:
            //        {
            //            var array = bs.ReadDecimalArray();
            //            this.ObjectValue = array == null ? null : new HashSet<Decimal>(array);
            //        }
            //        break;
            //    case EntityFieldType.DateTime:
            //        {
            //            var array = bs.ReadDateTimeArray();
            //            this.ObjectValue = array == null ? null : new HashSet<DateTime>(array);
            //        }
            //        break;
            //    case EntityFieldType.Byte:
            //        {
            //            var array = bs.ReadByteArray();
            //            this.ObjectValue = array == null ? null : new HashSet<byte>(array);
            //        }
            //        break;
            //    default: throw new NotSupportedException($"不支持二进制反序列化FieldSet: {ValueType}");
            //}
            //break;
            default:
                GuidValue   = bs.ReadGuid();
                ObjectValue = bs.Deserialize();
                break;
            }
        }
Exemplo n.º 14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eft"></param>
 /// <returns></returns>
 internal protected TechSharpy.Data.FieldType getDataType(EntityFieldType eft)
 {
     if (eft == EntityFieldType._Number)
     {
         return(FieldType._Number);
     }
     else if (eft == EntityFieldType._Text)
     {
         return(FieldType._String);
     }
     else if (eft == EntityFieldType._LongText)
     {
         return(FieldType._Text);
     }
     else if (eft == EntityFieldType._Auto)
     {
         return(FieldType._String);
     }
     else if (eft == EntityFieldType._Bool)
     {
         return(FieldType._Question);
     }
     else if (eft == EntityFieldType._Date)
     {
         return(FieldType._Date);
     }
     else if (eft == EntityFieldType._DateTime)
     {
         return(FieldType._DateTime);
     }
     else if (eft == EntityFieldType._File)
     {
         return(FieldType._Text);
     }
     else if (eft == EntityFieldType._Picture)
     {
         return(FieldType._Text);
     }
     else if (eft == EntityFieldType._Time)
     {
         return(FieldType._DateTime);
     }
     else if (eft == EntityFieldType._Float)
     {
         return(FieldType._Decimal);
     }
     else if (eft == EntityFieldType._LongText)
     {
         return(FieldType._Text);
     }
     else if (eft == EntityFieldType._Lookup)
     {
         return(FieldType._Number);
     }
     else if (eft == EntityFieldType._MultiLookup)
     {
         return(FieldType._Text);
     }
     else if (eft == EntityFieldType._Entity)
     {
         return(FieldType._Number);
     }
     else
     {
         return(FieldType._String);
     }
 }
Exemplo n.º 15
0
        public frm_SynapseObjectEdit(object SynapseObject)
        {
            InitializeComponent();
            _SynapseObject = SynapseObject;
            bags           = new Hashtable();
            languages      = SynapseLanguage.Load();
            IList <PropertyInfo> properties      = SynapseObject.GetType().GetProperties();
            IList <FieldInfo>    fields          = SynapseObject.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
            List <Control>       labelBagControl = new List <Control>();

            foreach (FieldInfo fi in fields)
            {
                if (fi.Name == "_IDproperty")
                {
                    _IDproperty = fi.GetValue(SynapseObject).ToString();
                }
                if (fi.Name == "_EcludeForSave")
                {
                    _EcludeForSave = fi.GetValue(SynapseObject).ToString();
                }
                if (fi.Name == "_tableName")
                {
                    _tableName = fi.GetValue(SynapseObject).ToString().Trim(new char[] { '[', ']' });
                }
            }
            foreach (PropertyInfo pi in from x in properties where x.PropertyType.ToString() == "SynapseCore.Database.LabelBag" select x)
            {
                uc_LabelBag bag   = new uc_LabelBag();
                object      value = pi.GetValue(SynapseObject, null);
                LabelBag    lbl   = (LabelBag)value;
                Int64       lblid = lbl.GetLabelID();
                if (lblid == 0)
                {
                    lblid = SynapseLabel.GetNextID();
                }

                LabelId[] ids = (LabelId[])pi.GetCustomAttributes(typeof(LabelId), true);
                foreach (LabelId id in ids)
                {
                    PropertyInfo field = SynapseObject.GetType().GetProperty(id.IDField);
                    field.SetValue(SynapseObject, lblid, null);
                    bags.Add(id.IDField, id);
                }

                if (lbl.Labels.Count < languages.Count)
                {
                    foreach (SynapseLanguage lang in languages)
                    {
                        if (lbl.GetLabel(lang.CODE) == null)
                        {
                            SynapseLabel newlabel = new SynapseLabel();

                            newlabel.LABELID = lblid;

                            newlabel.LANGUAGE = lang.CODE;
                            newlabel.TEXT     = "";
                            newlabel.save();
                            lbl.Labels.Add(newlabel);
                        }
                    }
                    _NewLabels = true;
                }

                bag.FieldName = pi.Name;
                bag.LblBag    = lbl;
                labelBagControl.Add(bag);
                //flowLayoutPanel1.Controls.Add(bag);
            }

            foreach (PropertyInfo pi in from x in properties where x.PropertyType.ToString() != "SynapseCore.Database.LabelBag" select x)
            {
                if (!bags.ContainsKey(pi.Name))
                {
                    EntityFieldType FieldType = ((EntityFieldType[])pi.GetCustomAttributes(typeof(EntityFieldType), true)).SingleOrDefault();

                    uc_Field field;
                    if (FieldType != null)
                    {
                        field = new uc_Field(FieldType);
                    }
                    else
                    {
                        field = new uc_Field();
                    }
                    field.FieldName   = pi.Name;
                    field.DisplayName = SynapseForm.GetLabel(_tableName.ToUpperInvariant() + "." + pi.Name.ToUpperInvariant());
                    object value = pi.GetValue(SynapseObject, null);
                    if (value != null)
                    {
                        field.FieldValue = value;
                    }
                    if (pi.Name == _IDproperty)
                    {
                        field.Enabled = false;
                    }
                    flowLayoutPanel1.Controls.Add(field);
                }
            }
            flowLayoutPanel1.Controls.AddRange(labelBagControl.ToArray());
            if (_NewLabels)
            {
                SynapseObject.GetType().InvokeMember("save", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, SynapseObject, null);
            }
        }
Exemplo n.º 16
0
 public SingleField(bool negate, string name, ITermValue term) : base(negate)
 {
     Name      = name;
     TermValue = term;
     FieldType = FieldUtils.DetectFieldType(term.Value);
 }
Exemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pClientID"></param>
        /// <param name="pEntityFieldID"></param>
        /// <param name="pEntityID"></param>
        /// <param name="pFieldName"></param>
        /// <param name="pFieldDescription"></param>
        /// <param name="pFieldType"></param>
        /// <param name="LookUpID"></param>
        /// <param name="pIsRequired"></param>
        /// <param name="pIsUnique"></param>
        /// <param name="pIsKeyField"></param>
        /// <param name="pEnableContentLimit"></param>
        /// <param name="pContentLimit"></param>
        /// <param name="pMin"></param>
        /// <param name="pMax"></param>
        /// <param name="pFileExtension"></param>
        /// <param name="pIsCore"></param>
        /// <param name="pIsEditable"></param>
        /// <param name="pEnableEncription"></param>
        /// <param name="pAcceptNull"></param>
        /// <param name="pDisplayName"></param>
        /// <param name="value"></param>
        /// <param name="isReadonly"></param>
        /// <param name="defaultValue"></param>
        /// <param name="displayorder"></param>
        /// <param name="pmaxLength"></param>
        /// <param name="displayName"></param>
        /// <param name="autoIncrement"></param>
        /// <param name="incrementfrom"></param>
        /// <param name="incrementby"></param>
        /// <returns></returns>
        internal protected bool AddField(int pClientID, int pEntityFieldID, Int32 pEntityID, string pFieldName, string pFieldDescription, EntityFieldType pFieldType,
                                         int LookUpID, bool pIsRequired, bool pIsUnique, bool pIsKeyField,
                                         bool pEnableContentLimit, string pMin, string pMax, string pFileExtension,
                                         bool pIsCore, bool pIsEditable, bool pEnableEncription, bool pAcceptNull, string pDisplayName, string value, bool isReadonly,
                                         string defaultValue, int displayorder, int pmaxLength, string displayName, bool autoIncrement,
                                         int incrementfrom, int incrementby)
        {
            TQueryBuilder tq;
            EntityField   fd = new EntityField(pFieldName, pEntityFieldID, pFieldType, pIsKeyField, pIsRequired, pIsUnique, LookUpID, pIsCore, pEntityID, value, isReadonly,
                                               defaultValue, displayorder, new List <string>(), pMin, pMax, pmaxLength, displayName, autoIncrement, incrementfrom, incrementby,
                                               Description, pEnableEncription, pEnableContentLimit);

            fd.InstanceID = pEntityFieldID;
            if (pEntityFieldID <= 0)
            {
                tq = new TQueryBuilder(TQueryType._AlterTable);
                tq.TableName(this.TableName.Replace(" ", ""));
                if (fd.SaveField())
                {
                    if (fd.InstanceID > 0)
                    {
                        tq.AddField(fd.Name, fd.IsKey, fd.IsUnique, getDataType(fd.FieldType), true, "");
                        dataEntity.ExecuteNonQuery(tq);
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
 public RangeField(bool negate, string name, EntityFieldType type, object left, object right)
     : this(negate, name, type, left, false, right, false)
 {
 }
Exemplo n.º 19
0
 public override void ReadObject(BinSerializer reader)
 {
     FieldId   = reader.ReadUInt16();
     FieldType = (EntityFieldType)reader.ReadByte();
 }
Exemplo n.º 20
0
 public OutputParam(string value, string key, EntityFieldType fieldType)
 {
     this.Value     = value;
     Key            = key;
     this.FieldType = fieldType;
 }
Exemplo n.º 21
0
 public KVFieldExpression(ushort id, EntityFieldType type)
 {
     FieldId   = id;
     FieldType = type;
 }
Exemplo n.º 22
0
 public SingleField(bool negate, string name, string value) : base(negate)
 {
     Name      = name;
     Value     = value;
     FieldType = EntityFieldType.String;
 }