Ejemplo n.º 1
0
        public override AnyStatus Save(StackAppContext appContext, EntityModelBase model)
        {
            if (model.IsNew)
            {
                var entityId  = model.GetValue <int>("entityid", 0);
                var length    = model.GetValue <int>("length", 0);
                var type      = model.GetValue <int>("fieldtype", 0);
                var fieldInfo = EntityMetaData.CreateField((FieldType)type);
                var baseType  = fieldInfo.BaseType;
                model.SetTempInfo("basetypecode", baseType);

                if (length == 0)
                {
                    if (baseType == TypeCode.String)
                    {
                        length = GetDefaultVarCharLength((FieldType)type);
                    }
                    else if (baseType == TypeCode.Decimal)
                    {
                        length = 6;
                    }

                    model.SetValue("length", length);
                }

                var fieldName = model.GetValue("fieldname", "");
                var tableName = this.GetEntity(entityId).DBName;
                model.SetValue("tablename", tableName);
                model.SetValue("dbname", fieldName);
            }

            return(base.Save(appContext, model));
        }
Ejemplo n.º 2
0
        private void CreateTableColumn(EntityModelBase model, IDbConnection connection, IDbTransaction transaction)
        {
            var fieldName = model.GetValue("dbname", "");
            //var type = model.GetValue("fieldtype", 0);
            var baseType = model.GetTempInfo("basetypecode", 0);
            var table    = model.GetValue("tablename", "");
            var length   = model.GetValue("length", 0);

            EntityBuilder.CreateEntityColumn(connection, transaction, table, fieldName, (TypeCode)baseType, length);
        }
Ejemplo n.º 3
0
        public override AnyStatus Save(StackAppContext appContext, EntityModelBase model)
        {
            //encrypt pwd if new
            //if edit do not change **
            if (model.IsNew)
            {
                model.SetValue("Password", Encrypt(model.GetValue("Password").ToString()));
            }

            return(base.Save(appContext, model));
        }
Ejemplo n.º 4
0
        public override AnyStatus Save(StackAppContext appContext, EntityModelBase model)
        {
            if (model.IsNew)
            {
                var entityId = model.GetValue <int>("entityid", 0);
                var itemType = this.GetEntity(entityId).DefaultItemTypeId;
                model.SetValue("itemType", itemType);
                model.SetValue("viewType", 0);
            }

            return(base.Save(appContext, model));
        }
Ejemplo n.º 5
0
        private bool GetRightValue(FilterExpField criteria, out object rVal, ref FieldType rFieldType)
        {
            bool isVaild = true;

            if (criteria.ValueType == FilterValueType.EntityField)
            {
                rVal = _DataModel.GetValue(criteria.FieldName);
            }
            else
            {
                rVal = criteria.Value;
            }

            return(isVaild);
        }