Пример #1
0
        public void Save(object entity)
        {
            IEntitySchema     es  = IEntitySchemaHelper.Get(entity.GetType());
            IOperationManager opm = new DefaultOperationManager(this._context, this._currentUser);

            if (Convert.ToInt32(es.GetKeyValue(entity)) <= 0)
            {
                int nextIdentity = this.GetNextIdentity();
                entity.SetPropertyValue(es.KeyName, nextIdentity, null);
            }
            if (es.RequiredLevel() != RequireLevelEnum.PlatForm)
            {
                entity.SetPropertyValue("CreateTime", DateTime.Now, null);
                entity.SetPropertyValue("CreateUserId", opm.CurrentUser.User_ID, null);
                object obj2 = entity.GetPropertyValue("OwnerId", null);
                if ((obj2 == null) || (Convert.ToInt32(obj2) <= 0))
                {
                    entity.SetPropertyValue("OwnerId", opm.CurrentUser.User_ID, null);
                }
                object obj3 = entity.GetPropertyValue("State", null);
                if ((obj3 == null) || (Convert.ToInt32(obj3) <= 0))
                {
                    entity.SetPropertyValue("State", 0, null);
                }
                entity.SetPropertyValue("StateDetail", 0, null);
            }
            this.SetDefaultValues(es, entity);
            opm.AUD_OperationCheck(es, entity, EntityOperationEnum.Add);
            if (es.EntityName == T_AttachmentTable)
            {
                this._attachHandler.SaveAttachment(entity as T_Attachment);
            }
            else
            {
                this.SaveActionUniqueKeyCheck(es, entity);
                this.AutoSaveSystemLevelCode(es, entity);
                this.UpdateTableVersion(es, entity);
                this._context.Insert(entity);
                this.SaveAttachmentOwner(es, entity);
            }
        }