/// <summary>
        /// 获取一个操作权限的主键
        /// 若不存在就自动增加一个
        /// </summary>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <param name="permissionItemName">操作权限名称</param>
        /// <returns>主键</returns>
        public string GetIdByAdd(string permissionItemCode, string permissionItemName = null)
        {
            // 判断当前判断的权限是否存在,否则很容易出现前台设置了权限,后台没此项权限
            // 需要自动的能把前台判断过的权限,都记录到后台来

            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();

            parameters.Add(new KeyValuePair <string, object>(BasePermissionItemEntity.FieldCode, permissionItemCode));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionItemEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionItemEntity.FieldDeletionStateCode, 0));

            BasePermissionItemEntity permissionItemEntity = new BasePermissionItemEntity();

            permissionItemEntity = new BasePermissionItemEntity(this.GetDataTable(parameters, BasePermissionItemEntity.FieldId));

            string permissionItemId = string.Empty;

            if (permissionItemEntity != null)
            {
                permissionItemId = permissionItemEntity.Id.ToString();
            }

            // 若是在调试阶段、有没在的权限被判断了,那就自动加入这个权限,不用人工加入权限了,工作效率会提高很多,
            // 哪些权限是否有被调用什么的,还可以进行一些诊断
            #if (DEBUG)
            if (String.IsNullOrEmpty(permissionItemId))
            {
                // 这里需要进行一次加锁,方式并发冲突发生
                lock (PermissionItemLock)
                {
                    permissionItemEntity.Code = permissionItemCode;
                    if (string.IsNullOrEmpty(permissionItemName))
                    {
                        permissionItemEntity.FullName = permissionItemCode;
                    }
                    else
                    {
                        permissionItemEntity.FullName = permissionItemName;
                    }
                    permissionItemEntity.ParentId    = null;
                    permissionItemEntity.IsScope     = 0;
                    permissionItemEntity.AllowDelete = 1;
                    permissionItemEntity.AllowEdit   = 1;
                    permissionItemEntity.Enabled     = 1;
                    // 这里是防止主键重复?
                    // permissionEntity.ID = BaseBusinessLogic.NewGuid();
                    permissionItemId = this.AddEntity(permissionItemEntity);
                }
            }
            else
            {
                // 更新最后一次访问日期,设置为当前服务器日期
                SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);
                sqlBuilder.BeginUpdate(this.CurrentTableName);
                sqlBuilder.SetDBNow(BasePermissionItemEntity.FieldLastCall);
                sqlBuilder.SetWhere(BasePermissionItemEntity.FieldId, permissionItemId);
                sqlBuilder.EndUpdate();
            }
                #endif

            return(permissionItemId);
        }
Ejemplo n.º 2
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseModuleEntity entity);
Ejemplo n.º 3
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(HRCheckInEntity entity)
        {
            string key = string.Empty;

            if (string.IsNullOrEmpty(entity.Id))
            {
                entity.Id = System.Guid.NewGuid().ToString("N");
            }
            key = entity.Id;
            SQLBuilder sqlBuilder = new SQLBuilder(this.DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, this.PrimaryKey);
            if (!string.IsNullOrEmpty(entity.Id))
            {
                // 这里已经是指定了主键了,所以不需要返回主键了
                sqlBuilder.ReturnId = false;
                sqlBuilder.SetValue(this.PrimaryKey, entity.Id);
            }
            else
            {
                if ((DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(this.PrimaryKey, "SEQ_BASE_LOGINLOG.NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(this.PrimaryKey, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    entity.Id = System.Guid.NewGuid().ToString("N");
                    sqlBuilder.SetValue(this.PrimaryKey, entity.Id);
                }
            }
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(HRCheckInEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(HRCheckInEntity.FieldCreateBy, UserInfo.RealName);
                sqlBuilder.SetValue(HRCheckInEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(HRCheckInEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(HRCheckInEntity.FieldCreateOn);
            sqlBuilder.SetDBNow(HRCheckInEntity.FieldModifiedOn);
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                key = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
            {
                return(entity.Id.ToString());
            }
            return(key);
        }
Ejemplo n.º 4
0
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseCommentEntity commentEntity);
Ejemplo n.º 5
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(BaseUserRoleEntity entity)
        {
            string result = string.Empty;

            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseUserRoleEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldId, entity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        // 2015-09-25 吉日嘎拉 用一个序列就可以了,不用那么多序列了
                        // sqlBuilder.SetFormula(BaseUserRoleEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                        sqlBuilder.SetFormula(BaseUserRoleEntity.FieldId, "SEQ_" + BaseRoleEntity.TableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        // sqlBuilder.SetFormula(BaseUserRoleEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                        sqlBuilder.SetFormula(BaseUserRoleEntity.FieldId, "NEXT VALUE FOR SEQ_" + BaseRoleEntity.TableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (entity.Id == null)
                        {
                            if (string.IsNullOrEmpty(result))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                result = sequenceManager.Increment(BaseRoleEntity.TableName);
                            }
                            entity.Id = int.Parse(result);
                        }
                        sqlBuilder.SetValue(BaseUserRoleEntity.FieldId, entity.Id);
                    }
                }
            }
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserRoleEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserRoleEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                result = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }

            return(result);
        }
Ejemplo n.º 6
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseWorkFlowBillTemplateEntity baseWorkFlowBillTemplateEntity);
Ejemplo n.º 7
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseMessageRecentEntity entity);
Ejemplo n.º 8
0
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseHolidaysEntity entity);
Ejemplo n.º 9
0
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseNewsEntity entity);
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="organizeEntity">实体</param>
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseOrganizeEntity organizeEntity)
 {
     sqlBuilder.SetValue(BaseOrganizeEntity.FieldLayer, organizeEntity.Layer);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(BaseHolidaysEntity entity)
        {
            string     sequence   = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseHolidaysEntity.FieldId);
            if (entity.Id != null || !this.Identity)
            {
                // 这里已经是指定了主键了,所以不需要返回主键了
                sqlBuilder.ReturnId = false;
                sqlBuilder.SetValue(BaseHolidaysEntity.FieldId, entity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseHolidaysEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseHolidaysEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (entity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.Increment(this.CurrentTableName);
                            }
                            entity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(BaseHolidaysEntity.FieldId, entity.Id);
                    }
                }
            }
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseHolidaysEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseHolidaysEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseHolidaysEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseHolidaysEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseHolidaysEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseHolidaysEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Ejemplo n.º 12
0
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseFileEntity fileEntity);
Ejemplo n.º 13
0
 // 这个是声明扩展方法
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity);
Ejemplo n.º 14
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseUserIdentityAuditEntity entity);
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseUserRoleEntity userRoleEntity);
Ejemplo n.º 16
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(BaseOrganizeScopeEntity entity)
        {
            string     key        = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, this.PrimaryKey);
            if (!this.Identity)
            {
                // 这里已经是指定了主键了,所以不需要返回主键了
                sqlBuilder.ReturnId = false;
                sqlBuilder.SetValue(this.PrimaryKey, entity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        // 2015-09-25 吉日嘎拉 用一个序列就可以了,不用那么多序列了
                        sqlBuilder.SetFormula(this.PrimaryKey, "SEQ_" + BaseOrganizeScopeEntity.TableName.ToUpper() + ".NEXTVAL ");
                        // sqlBuilder.SetFormula(this.PrimaryKey, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        // sqlBuilder.SetFormula(this.PrimaryKey, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                        sqlBuilder.SetFormula(this.PrimaryKey, "NEXT VALUE FOR SEQ_" + BaseOrganizeScopeEntity.TableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        // BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper);
                        // entity.Id = int.Parse(sequenceManager.Increment(BasePermissionEntity.TableName));
                        // entity.Id = int.Parse(sequenceManager.Increment(this.CurrentTableName));
                        // sqlBuilder.SetValue(this.PrimaryKey, entity.Id);
                        sqlBuilder.SetFormula(this.PrimaryKey, "SEQ_" + BaseOrganizeScopeEntity.TableName.ToUpper() + ".NEXTVAL ");
                    }
                }
            }
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseOrganizeScopeEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseOrganizeScopeEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseOrganizeScopeEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseOrganizeScopeEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseOrganizeScopeEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseOrganizeScopeEntity.FieldModifiedOn);
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                key = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
            {
                return(entity.Id.ToString());
            }
            return(key);
        }
Ejemplo n.º 17
0
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseFolderEntity folderEntity);
Ejemplo n.º 18
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseOrganizeScopeEntity entity);
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddEntity(BaseContactDetailsEntity entity)
        {
            string sequence = string.Empty;

            sequence = entity.Id;
            if (entity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                sequence        = sequenceManager.Increment(this.CurrentTableName);
                entity.SortCode = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(BaseContactDetailsEntity.TableName, BaseContactDetailsEntity.FieldId);
            if (entity.Id is string)
            {
                this.Identity = false;
            }
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseContactDetailsEntity.FieldId, entity.Id);
            }
            else
            {
                if (!this.ReturnId && DbHelper.CurrentDbType == CurrentDbType.Oracle)
                {
                    sqlBuilder.SetFormula(BaseContactDetailsEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                }
                else
                {
                    if (this.Identity && DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        if (string.IsNullOrEmpty(sequence))
                        {
                            BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                            sequence = sequenceManager.Increment(this.CurrentTableName);
                        }
                        entity.Id = sequence;
                        sqlBuilder.SetValue(BaseContactDetailsEntity.FieldId, entity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseContactDetailsEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseContactDetailsEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseContactDetailsEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseContactDetailsEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseContactDetailsEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseContactDetailsEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseServicesLicenseEntity entity);
Ejemplo n.º 21
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="baseCommentEntity">实体</param>
        public string AddEntity(BaseCommentEntity baseCommentEntity)
        {
            string sequence = string.Empty;

            this.Identity = false;
            if (baseCommentEntity.SortCode == null || baseCommentEntity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                baseCommentEntity.SortCode = int.Parse(sequence);
            }
            if (baseCommentEntity.Id != null)
            {
                sequence = baseCommentEntity.Id.ToString();
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseCommentEntity.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(baseCommentEntity.Id))
                {
                    sequence             = BaseBusinessLogic.NewGuid();
                    baseCommentEntity.Id = sequence;
                }
                sqlBuilder.SetValue(BaseCommentEntity.FieldId, baseCommentEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseCommentEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseCommentEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(baseCommentEntity.Id))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            baseCommentEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(BaseCommentEntity.FieldId, baseCommentEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, baseCommentEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseCommentEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseCommentEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseCommentEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseCommentEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseCommentEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseCommentEntity.FieldModifiedOn);
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(BaseServicesLicenseEntity entity)
        {
            string     result     = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseServicesLicenseEntity.FieldId);
            if (!string.IsNullOrEmpty(entity.Id) || !this.Identity)
            {
                result = entity.Id;
                sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldId, entity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseServicesLicenseEntity.FieldId, "SEQ_" + BaseServicesLicenseEntity.TableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseServicesLicenseEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (entity.Id == null)
                        {
                            if (string.IsNullOrEmpty(result))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                result = sequenceManager.Increment(BaseServicesLicenseEntity.TableName);
                            }
                            entity.Id = result;
                        }
                        sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldId, entity.Id);
                    }
                }
            }
            this.SetObject(sqlBuilder, entity);

            // 创建人信息
            if (!string.IsNullOrEmpty(entity.CreateUserId))
            {
                sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldCreateUserId, entity.CreateUserId);
            }
            else
            {
                if (UserInfo != null)
                {
                    sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldCreateUserId, UserInfo.Id);
                }
            }
            if (!string.IsNullOrEmpty(entity.CreateBy))
            {
                sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldCreateBy, entity.CreateBy);
            }
            else
            {
                if (UserInfo != null)
                {
                    sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldCreateBy, UserInfo.RealName);
                }
            }
            if (entity.CreateOn.HasValue)
            {
                sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldCreateOn, entity.CreateOn);
            }
            else
            {
                sqlBuilder.SetDBNow(BaseServicesLicenseEntity.FieldCreateOn);
            }

            // 修改人信息
            if (!string.IsNullOrEmpty(entity.ModifiedUserId))
            {
                sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldModifiedUserId, entity.ModifiedUserId);
            }
            else
            {
                if (UserInfo != null)
                {
                    sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldModifiedUserId, UserInfo.Id);
                }
            }
            if (!string.IsNullOrEmpty(entity.ModifiedBy))
            {
                sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldModifiedBy, entity.ModifiedBy);
            }
            else
            {
                if (UserInfo != null)
                {
                    sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldModifiedBy, UserInfo.RealName);
                }
            }
            if (entity.ModifiedOn.HasValue)
            {
                sqlBuilder.SetValue(BaseServicesLicenseEntity.FieldModifiedOn, entity.ModifiedOn);
            }
            else
            {
                sqlBuilder.SetDBNow(BaseServicesLicenseEntity.FieldModifiedOn);
            }

            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                result = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(result);
        }
Ejemplo n.º 23
0
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BasePermissionScopeEntity entity);
Ejemplo n.º 24
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="workFlowActivityEntity">实体</param>
        public string AddObject(BaseWorkFlowStepEntity workFlowActivityEntity)
        {
            string sequence = string.Empty;

            if (workFlowActivityEntity.SortCode == null || workFlowActivityEntity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                sequence = sequenceManager.Increment(this.CurrentTableName);
                workFlowActivityEntity.SortCode = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseWorkFlowStepEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldId, workFlowActivityEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseWorkFlowStepEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseWorkFlowStepEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (workFlowActivityEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.Increment(this.CurrentTableName);
                            }
                            workFlowActivityEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldId, workFlowActivityEntity.Id);
                    }
                }
            }
            this.SetObject(sqlBuilder, workFlowActivityEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowStepEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowStepEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(BaseModuleEntity entity)
        {
            string result = string.Empty;

            if (entity.SortCode == null || entity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                result          = sequenceManager.Increment(BaseModuleEntity.TableName);
                entity.SortCode = int.Parse(result);
            }

            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseModuleEntity.FieldId);

            // 若是非空主键,表明已经指定了主键了
            if (!string.IsNullOrEmpty(entity.Id))
            {
                // 这里已经是指定了主键了,所以不需要返回主键了
                sqlBuilder.SetValue(BaseModuleEntity.FieldId, entity.Id);
                result = entity.Id;
            }
            else
            {
                if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                {
                    // 2015-12-23 吉日嘎拉 这里需要兼容一下以前的老的数据结构
                    sqlBuilder.SetFormula(this.PrimaryKey, "SEQ_" + BaseModuleEntity.TableName.ToUpper() + ".NEXTVAL ");
                }
                else
                {
                    entity.Id = Guid.NewGuid().ToString("N");
                    result    = entity.Id;
                    sqlBuilder.SetValue(BaseModuleEntity.FieldId, entity.Id);
                }
            }

            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseModuleEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseModuleEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseModuleEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseModuleEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseModuleEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseModuleEntity.FieldModifiedOn);
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                result = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }

            return(result);
        }
Ejemplo n.º 26
0
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseSequenceEntity sequenceEntity);
Ejemplo n.º 27
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, TAB_EMPLOYEEEntity entity);
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="userRoleEntity">实体</param>
        public string AddEntity(BaseUserRoleEntity userRoleEntity)
        {
            string     sequence   = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseUserRoleEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldId, userRoleEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseUserRoleEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseUserRoleEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (userRoleEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            userRoleEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(BaseUserRoleEntity.FieldId, userRoleEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, userRoleEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserRoleEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserRoleEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserRoleEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Ejemplo n.º 29
0
 partial void SetObjectExpand(SQLBuilder sqlBuilder, HRCheckInEntity entity);
Ejemplo n.º 30
0
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseSequenceEntity entity);