//
        // 授予授权范围的实现部分
        //

        #region private string GrantModule(BasePermissionScopeManager permissionScopeManager, string id, string organizeId, string grantModuleId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="permissionScopeManager">权限域读写器</param>
        /// <param name="Id">主键</param>
        /// <param name="organizeId">员工主键</param>
        /// <param name="grantModuleId">权限主键</param>
        /// <returns>主键</returns>
        private string GrantModule(BasePermissionScopeManager permissionScopeManager, string organizeId, string permissionCode, string grantModuleId)
        {
            string result = string.Empty;
            BasePermissionScopeEntity resourcePermissionScopeEntity = new BasePermissionScopeEntity();

            resourcePermissionScopeEntity.PermissionId      = int.Parse(this.GetIdByCode(permissionCode));
            resourcePermissionScopeEntity.ResourceCategory  = BaseOrganizeEntity.TableName;
            resourcePermissionScopeEntity.ResourceId        = organizeId;
            resourcePermissionScopeEntity.TargetCategory    = BaseModuleEntity.TableName;
            resourcePermissionScopeEntity.TargetId          = grantModuleId;
            resourcePermissionScopeEntity.Enabled           = 1;
            resourcePermissionScopeEntity.DeletionStateCode = 0;
            return(permissionScopeManager.Add(resourcePermissionScopeEntity));
        }
        //
        // 授予授权范围的实现部分
        //

        #region private string GrantUser(BasePermissionScopeManager permissionScopeManager, string id, string roleId, string grantUserId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="permissionScopeManager">权限域读写器</param>
        /// <param name="Id">主键</param>
        /// <param name="roleId">员工主键</param>
        /// <param name="grantUserId">权限主键</param>
        /// <returns>主键</returns>
        private string GrantUser(BasePermissionScopeManager permissionScopeManager, string roleId, string permissionItemCode, string grantUserId)
        {
            string returnValue = string.Empty;
            BasePermissionScopeEntity resourcePermissionScopeEntity = new BasePermissionScopeEntity();

            resourcePermissionScopeEntity.PermissionId      = int.Parse(this.GetIdByCode(permissionItemCode));
            resourcePermissionScopeEntity.ResourceCategory  = BaseRoleEntity.TableName;
            resourcePermissionScopeEntity.ResourceId        = roleId;
            resourcePermissionScopeEntity.TargetCategory    = BaseUserEntity.TableName;
            resourcePermissionScopeEntity.TargetId          = grantUserId;
            resourcePermissionScopeEntity.Enabled           = 1;
            resourcePermissionScopeEntity.DeletionStateCode = 0;
            return(permissionScopeManager.Add(resourcePermissionScopeEntity));
        }
 /// <summary>
 /// 添加或更新(主键是否为0)
 /// </summary>
 /// <param name="entity">实体</param>
 /// <param name="identity">自增量方式,表主键是否采用自增的策略</param>
 /// <param name="returnId">返回主键,不返回程序允许速度会快,主要是为了主细表批量插入数据优化用的</param>
 /// <returns>主键</returns>
 public string AddOrUpdate(BasePermissionScopeEntity entity, bool identity = true, bool returnId = true)
 {
     Identity = identity;
     ReturnId = returnId;
     if (entity.Id == 0)
     {
         entity.Id = AddEntity(entity).ToInt();
         return(entity.Id.ToString());
     }
     else
     {
         return(UpdateEntity(entity) > 0 ? entity.Id.ToString() : string.Empty);
     }
 }
Esempio n. 4
0
        //
        // 授予授权范围的实现部分
        //

        #region private string GrantUser(BasePermissionScopeManager manager, string id, string roleId, string grantUserId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="manager">权限域读写器</param>
        /// <param name="roleId">员工主键</param>
        /// <param name="grantUserId">权限主键</param>
        /// <param name="permissionCode">权限编号</param>
        /// <returns>主键</returns>
        private string GrantUser(BasePermissionScopeManager permissionScopeManager, string roleId, string grantUserId, string permissionCode)
        {
            string result        = string.Empty;
            string roleTableName = this.UserInfo.SystemCode + "Role";
            BasePermissionScopeEntity resourcePermissionScopeEntity = new BasePermissionScopeEntity();

            resourcePermissionScopeEntity.PermissionId      = this.GetPermissionIdByCode(permissionCode);
            resourcePermissionScopeEntity.ResourceCategory  = roleTableName;
            resourcePermissionScopeEntity.ResourceId        = roleId;
            resourcePermissionScopeEntity.TargetCategory    = BaseUserEntity.TableName;
            resourcePermissionScopeEntity.TargetId          = grantUserId;
            resourcePermissionScopeEntity.Enabled           = 1;
            resourcePermissionScopeEntity.DeletionStateCode = 0;
            return(permissionScopeManager.Add(resourcePermissionScopeEntity));
        }
Esempio n. 5
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="baseResourcePermissionScopeEntity">实体</param>
        public int UpdateEntity(BasePermissionScopeEntity baseResourcePermissionScopeEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, baseResourcePermissionScopeEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BasePermissionScopeEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(BasePermissionScopeEntity.FieldId, baseResourcePermissionScopeEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
Esempio n. 6
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="permissionScopeEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BasePermissionScopeEntity permissionScopeEntity)
 {
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldResourceCategory, permissionScopeEntity.ResourceCategory);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldResourceId, permissionScopeEntity.ResourceId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldTargetCategory, permissionScopeEntity.TargetCategory);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldTargetId, permissionScopeEntity.TargetId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldPermissionItemId, permissionScopeEntity.PermissionId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldPermissionConstraint, permissionScopeEntity.PermissionConstraint);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldStartDate, permissionScopeEntity.StartDate);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldEndDate, permissionScopeEntity.EndDate);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldEnabled, permissionScopeEntity.Enabled);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldDeletionStateCode, permissionScopeEntity.DeletionStateCode);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldDescription, permissionScopeEntity.Description);
     SetEntityExpand(sqlBuilder, permissionScopeEntity);
 }
        //
        // 授予授权范围的实现部分
        //

        #region private string GrantPermission(BasePermissionScopeManager manager, string id, string userId, string grantPermissionId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="permissionScopeManager">权限域读写器</param>
        /// <param name="systemCode">系统编码</param>
        /// <param name="userId">用户主键</param>
        /// <param name="grantPermissionId">权限主键</param>
        /// <param name="permissionCode">权限编号</param>
        /// <returns>主键</returns>
        private string GrantPermission(BasePermissionScopeManager permissionScopeManager, string systemCode, string userId, string grantPermissionId, string permissionCode)
        {
            var result = string.Empty;
            var resourcePermissionScopeEntity = new BasePermissionScopeEntity
            {
                PermissionId     = new BaseModuleManager().GetIdByCodeByCache(systemCode, permissionCode).ToInt(),
                ResourceCategory = BaseUserEntity.CurrentTableName,
                ResourceId       = userId.ToInt(),
                TargetCategory   = BaseModuleEntity.CurrentTableName,
                TargetId         = grantPermissionId.ToInt(),
                Enabled          = 1,
                Deleted          = 0
            };

            return(permissionScopeManager.Add(resourcePermissionScopeEntity));
        }
Esempio n. 8
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="entity">实体</param>
 private void SetObject(SQLBuilder sqlBuilder, BasePermissionScopeEntity entity)
 {
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldResourceCategory, entity.ResourceCategory);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldResourceId, entity.ResourceId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldTargetCategory, entity.TargetCategory);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldTargetId, entity.TargetId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldPermissionId, entity.PermissionId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldContainChild, entity.ContainChild);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldPermissionConstraint, entity.PermissionConstraint);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldStartDate, entity.StartDate);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldEndDate, entity.EndDate);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldEnabled, entity.Enabled);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldDeletionStateCode, entity.DeletionStateCode);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldDescription, entity.Description);
     SetObjectExpand(sqlBuilder, entity);
 }
        /// <summary>
        /// 设置约束条件
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="resourceCategory">资源类别</param>
        /// <param name="resourceId">资源主键</param>
        /// <param name="tableName">表名</param>
        /// <param name="constraint">约束</param>
        /// <param name="enabled">有效</param>
        /// <param name="permissionCode">操作权限项</param>
        /// <returns>主键</returns>
        public string SetConstraint(string resourceCategory, string resourceId, string tableName, string permissionCode, string constraint, bool enabled = true)
        {
            string returnValue = string.Empty;

            string permissionId = string.Empty;
            BasePermissionItemManager permissionItemManager = new BasePermissionItemManager(this.UserInfo);

            permissionId = permissionItemManager.GetIdByAdd(permissionCode);

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

            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, resourceCategory));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, resourceId));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, "Table"));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetId, tableName));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionItemId, permissionId));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldDeletionStateCode, 0));

            BasePermissionScopeManager manager = new BasePermissionScopeManager(this.DbHelper, this.UserInfo);

            // 1:先获取是否有这样的主键,若有进行更新操作。
            // 2:若没有进行添加操作。
            returnValue = manager.GetId(parameters);
            if (!string.IsNullOrEmpty(returnValue))
            {
                parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionConstraint, constraint));
                parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldEnabled, enabled ? 1 : 0));
                manager.SetProperty(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldId, returnValue), parameters);
            }
            else
            {
                BasePermissionScopeEntity entity = new BasePermissionScopeEntity();
                entity.ResourceCategory     = resourceCategory;
                entity.ResourceId           = resourceId;
                entity.TargetCategory       = "Table";
                entity.TargetId             = tableName;
                entity.PermissionConstraint = constraint;
                entity.PermissionId         = int.Parse(permissionId);
                entity.DeletionStateCode    = 0;
                entity.Enabled = enabled ? 1: 0;
                returnValue    = manager.Add(entity);
            }
            return(returnValue);
        }
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="sqlBuilder">Sql语句生成器</param>
 /// <param name="entity">实体</param>
 private void SetEntity(SqlBuilder sqlBuilder, BasePermissionScopeEntity entity)
 {
     SetEntityExtend(sqlBuilder, entity);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldSystemCode, entity.SystemCode);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldResourceCategory, entity.ResourceCategory);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldResourceId, entity.ResourceId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldTargetCategory, entity.TargetCategory);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldTargetId, entity.TargetId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldPermissionId, entity.PermissionId);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldContainChild, entity.ContainChild);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldPermissionConstraint, entity.PermissionConstraint);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldStartTime, entity.StartTime);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldEndTime, entity.EndTime);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldDescription, entity.Description);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldSortCode, entity.SortCode);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldDeleted, entity.Deleted);
     sqlBuilder.SetValue(BasePermissionScopeEntity.FieldEnabled, entity.Enabled);
 }
Esempio n. 11
0
        //
        // 授予授权范围的实现部分
        //

        #region private string GrantRole(BasePermissionScopeManager manager, string id, string roleId, string grantRoleId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="systemCode">系统编码</param>
        /// <param name="permissionScopeManager">权限域读写器</param>
        /// <param name="roleId">员工主键</param>
        /// <param name="grantRoleId">权限主键</param>
        /// <param name="permissionCode">权限编号</param>
        /// <returns>主键</returns>
        private string GrantRole(string systemCode, BasePermissionScopeManager permissionScopeManager, string roleId, string grantRoleId, string permissionCode)
        {
            var roleTableName = systemCode + "Role";

            var result = string.Empty;
            var entity = new BasePermissionScopeEntity
            {
                PermissionId     = new BaseModuleManager().GetIdByCodeByCache(systemCode, permissionCode).ToInt(),
                ResourceCategory = roleTableName,
                ResourceId       = roleId.ToInt(),
                TargetCategory   = roleTableName,
                TargetId         = grantRoleId.ToInt(),
                Enabled          = 1,
                Deleted          = 0
            };

            return(permissionScopeManager.Add(entity, true, false));
        }
Esempio n. 12
0
        //
        // 授予授权范围的实现部分
        //

        #region private string GrantModule(BasePermissionScopeManager manager, string id, string userId, string grantModuleId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="manager">权限域读写器</param>
        /// <param name="userId">用户主键</param>
        /// <param name="grantModuleId">权限主键</param>
        /// <param name="permissionCode">权限编号</param>
        /// <returns>主键</returns>
        private string GrantModule(BasePermissionScopeManager permissionScopeManager, string systemCode, string userId, string grantModuleId, string permissionCode)
        {
            string result = string.Empty;
            BasePermissionScopeEntity resourcePermissionScopeEntity = new BasePermissionScopeEntity();
            string permissionId = BaseModuleManager.GetIdByCodeByCache(systemCode, permissionCode);

            if (string.IsNullOrEmpty(permissionId))
            {
                return(string.Empty);
            }
            resourcePermissionScopeEntity.PermissionId      = permissionId;
            resourcePermissionScopeEntity.ResourceCategory  = BaseUserEntity.TableName;
            resourcePermissionScopeEntity.ResourceId        = userId;
            resourcePermissionScopeEntity.TargetCategory    = BaseModuleEntity.TableName;
            resourcePermissionScopeEntity.TargetId          = grantModuleId;
            resourcePermissionScopeEntity.Enabled           = 1;
            resourcePermissionScopeEntity.DeletionStateCode = 0;
            return(permissionScopeManager.Add(resourcePermissionScopeEntity));
        }
Esempio n. 13
0
        /// <summary>
        /// 获取约束条件
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="resourceCategory">资源类别</param>
        /// <param name="resourceId">资源主键</param>
        /// <param name="tableName">表名</param>
        /// <returns>约束条件</returns>
        public BasePermissionScopeEntity GetConstraintEntity(BaseUserInfo userInfo, string resourceCategory, string resourceId, string tableName, string permissionCode = "Resource.AccessPermission")
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            BasePermissionScopeEntity returnValue = null;

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseTableColumnsManager manager = new BaseTableColumnsManager(dbHelper, userInfo);
                    returnValue = manager.GetConstraintEntity(resourceCategory, resourceId, tableName, permissionCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.TableColumnsService_SetConstraint, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return(returnValue);
        }
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="manager">权限域读写器</param>
        /// <param name="systemCode">系统编码</param>
        /// <param name="userId">用户主键</param>
        /// <param name="grantOrganizationId">权组织机构限主键</param>
        /// <param name="permissionCode">权限编号</param>
        /// <param name="containChild"></param>
        /// <returns>主键</returns>
        private string GrantOrganization(BasePermissionScopeManager manager, string systemCode, string userId, string grantOrganizationId, string permissionCode = "Resource.AccessPermission", bool containChild = false)
        {
            var result       = string.Empty;
            var permissionId = new BaseModuleManager().GetIdByCodeByCache(systemCode, permissionCode);

            if (!string.IsNullOrEmpty(permissionId))
            {
                var parameters = new List <KeyValuePair <string, object> >
                {
                    new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.CurrentTableName),
                    new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId),
                    new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizationEntity.CurrentTableName),
                    new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetId, grantOrganizationId),
                    new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, permissionId)
                };
                // Nick Deng 优化数据权限设置,没有权限和其他任意一种权限互斥
                // 即当没有权限时,该用户对应该数据权限的其他权限都应删除
                // 当该用户拥有对应该数据权限的其他权限时,删除该用户的没有权限的权限
                result = manager.GetId(parameters);
                if (!string.IsNullOrEmpty(result))
                {
                    manager.SetProperty(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldId, result), new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldContainChild, containChild ? 1 : 0));
                }
                else
                {
                    var entity = new BasePermissionScopeEntity
                    {
                        PermissionId     = permissionId.ToInt(),
                        ResourceCategory = BaseUserEntity.CurrentTableName,
                        ResourceId       = userId.ToInt(),
                        TargetCategory   = BaseOrganizationEntity.CurrentTableName,
                        TargetId         = grantOrganizationId.ToInt(),
                        ContainChild     = containChild ? 1 : 0,
                        Enabled          = 1,
                        Deleted          = 0
                    };
                    result = manager.Add(entity);
                }
            }
            return(result);
        }
Esempio n. 15
0
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="manager">权限域读写器</param>
        /// <param name="userId">用户主键</param>
        /// <param name="grantOrganizeId">权组织机构限主键</param>
        /// <param name="permissionCode">权限编号</param>
        /// <returns>主键</returns>
        private string GrantOrganize(BasePermissionScopeManager manager, string systemCode, string userId, string grantOrganizeId, string permissionCode = "Resource.AccessPermission", bool containChild = false)
        {
            string result       = string.Empty;
            string permissionId = BaseModuleManager.GetIdByCodeByCache(systemCode, permissionCode);

            if (!string.IsNullOrEmpty(permissionId))
            {
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.TableName));
                parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId));
                parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizeEntity.TableName));
                parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetId, grantOrganizeId));
                parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, permissionId));
                // Nick Deng 优化数据权限设置,没有权限和其他任意一种权限互斥
                // 即当没有权限时,该用户对应该数据权限的其他权限都应删除
                // 当该用户拥有对应该数据权限的其他权限时,删除该用户的没有权限的权限
                result = manager.GetId(parameters);
                if (!string.IsNullOrEmpty(result))
                {
                    manager.SetProperty(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldId, result), new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldContainChild, containChild ? 1 : 0));
                }
                else
                {
                    BasePermissionScopeEntity entity = new BasePermissionScopeEntity();
                    entity.PermissionId      = permissionId;
                    entity.ResourceCategory  = BaseUserEntity.TableName;
                    entity.ResourceId        = userId;
                    entity.TargetCategory    = BaseOrganizeEntity.TableName;
                    entity.TargetId          = grantOrganizeId;
                    entity.ContainChild      = containChild ? 1 : 0;
                    entity.Enabled           = 1;
                    entity.DeletionStateCode = 0;
                    result = manager.Add(entity);
                }
            }
            return(result);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">实体</param>
        public int UpdateEntity(BasePermissionScopeEntity entity)
        {
            var sqlBuilder = new SqlBuilder(DbHelper);

            sqlBuilder.BeginUpdate(CurrentTableName);
            SetEntity(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldUpdateUserId, UserInfo.UserId);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldUpdateUserName, UserInfo.UserName);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldUpdateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDbNow(BasePermissionScopeEntity.FieldUpdateTime);
            sqlBuilder.SetValue(BasePermissionScopeEntity.FieldUpdateIp, Utils.GetIp());
            sqlBuilder.SetWhere(PrimaryKey, entity.Id);
            //return sqlBuilder.EndUpdate();
            var result = sqlBuilder.EndUpdate();

            if (result > 0)
            {
                RemoveCache(entity.Id);
            }
            return(result);
        }
Esempio n. 17
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">实体</param>
 public int Update(BasePermissionScopeEntity entity)
 {
     return(this.UpdateObject(entity));
 }
Esempio n. 18
0
        //
        // 授予授权范围的实现部分
        //

        #region private string GrantOrganize(BasePermissionScopeManager permissionScopeManager, string id, string userId, string grantOrganizeId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="permissionScopeManager">权限域读写器</param>
        /// <param name="Id">主键</param>
        /// <param name="userId">员工主键</param>
        /// <param name="grantOrganizeId">权限主键</param>
        /// <returns>主键</returns>
        private string GrantOrganize(BasePermissionScopeManager permissionScopeManager, string userId, string permissionItemCode, string grantOrganizeId)
        {
            string returnValue = string.Empty;

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

            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.TableName));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizeEntity.TableName));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetId, grantOrganizeId));
            parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionItemId, this.GetIdByCode(permissionItemCode)));
            // Nick Deng 优化数据权限设置,没有权限和其他任意一种权限互斥
            // 即当没有权限时,该用户对应该数据权限的其他权限都应删除
            // 当该用户拥有对应该数据权限的其他权限时,删除该用户的没有权限的权限
            BasePermissionScopeEntity resourcePermissionScopeEntity = new BasePermissionScopeEntity();
            DataTable dt = new DataTable();

            if (!this.Exists(parameters))
            {
                resourcePermissionScopeEntity.PermissionId      = int.Parse(this.GetIdByCode(permissionItemCode));
                resourcePermissionScopeEntity.ResourceCategory  = BaseUserEntity.TableName;
                resourcePermissionScopeEntity.ResourceId        = userId;
                resourcePermissionScopeEntity.TargetCategory    = BaseOrganizeEntity.TableName;
                resourcePermissionScopeEntity.TargetId          = grantOrganizeId;
                resourcePermissionScopeEntity.Enabled           = 1;
                resourcePermissionScopeEntity.DeletionStateCode = 0;
                returnValue = permissionScopeManager.Add(resourcePermissionScopeEntity);
                if (grantOrganizeId != ((int)PermissionScope.None).ToString())
                {
                    parameters = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.TableName));
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId));
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizeEntity.TableName));
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetId, ((int)PermissionScope.None).ToString()));
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionItemId, this.GetIdByCode(permissionItemCode)));
                    if (this.Exists(parameters))
                    {
                        dt = permissionScopeManager.GetDataTable(parameters);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            permissionScopeManager.DeleteEntity(dt.Rows[0]["Id"].ToString());
                        }
                    }
                }
                else
                {
                    parameters = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.TableName));
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId));
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizeEntity.TableName));
                    parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionItemId, this.GetIdByCode(permissionItemCode)));

                    dt = permissionScopeManager.GetDataTable(parameters);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["TargetId"].ToString() != ((int)PermissionScope.None).ToString())
                        {
                            permissionScopeManager.DeleteEntity(dt.Rows[0]["Id"].ToString());
                        }
                    }
                }
            }
            return(returnValue);
        }
Esempio n. 19
0
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BasePermissionScopeEntity entity);
Esempio n. 20
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseResourcePermissionScopeEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BasePermissionScopeEntity baseResourcePermissionScopeEntity)
 {
     return(this.AddEntity(baseResourcePermissionScopeEntity));
 }
        //
        // 授予授权范围的实现部分
        //

        #region private string GrantOrganization(BasePermissionScopeManager manager, string id, string roleId, string grantOrganizationId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="systemCode">系统编码</param>
        /// <param name="permissionScopeManager">权限域读写器</param>
        /// <param name="roleId">员工主键</param>
        /// <param name="grantOrganizationId">权限主键</param>
        /// <param name="permissionCode">权限编号</param>
        /// <returns>主键</returns>
        private string GrantOrganization(string systemCode, BasePermissionScopeManager permissionScopeManager, string roleId, string grantOrganizationId, string permissionCode)
        {
            var result = string.Empty;

            var roleTableName = systemCode + "Role";

            var parameters = new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, roleTableName),
                new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, roleId),
                new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizationEntity.CurrentTableName),
                new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetId, grantOrganizationId),
                new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, new BaseModuleManager().GetIdByCodeByCache(systemCode, permissionCode))
            };

            // Nick Deng 优化数据权限设置,没有权限和其他任意一种权限互斥
            // 即当没有权限时,该角色对应该数据权限的其他权限都应删除
            // 当该角色拥有对应该数据权限的其他权限时,删除该角色的没有权限的权限
            var resourcePermissionScopeEntity = new BasePermissionScopeEntity();
            var dt = new DataTable();

            if (!Exists(parameters))
            {
                resourcePermissionScopeEntity.PermissionId     = new BaseModuleManager().GetIdByCodeByCache(systemCode, permissionCode).ToInt();
                resourcePermissionScopeEntity.ResourceCategory = roleTableName;
                resourcePermissionScopeEntity.ResourceId       = roleId.ToInt();
                resourcePermissionScopeEntity.TargetCategory   = BaseOrganizationEntity.CurrentTableName;
                resourcePermissionScopeEntity.TargetId         = grantOrganizationId.ToInt();
                resourcePermissionScopeEntity.Enabled          = 1;
                resourcePermissionScopeEntity.Deleted          = 0;
                result = permissionScopeManager.Add(resourcePermissionScopeEntity, true, false);
                if (grantOrganizationId != ((int)PermissionOrganizationScope.NotAllowed).ToString())
                {
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, roleTableName),
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, roleId),
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizationEntity.CurrentTableName),
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetId, ((int)PermissionOrganizationScope.NotAllowed).ToString()),
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, new BaseModuleManager().GetIdByCodeByCache(systemCode, permissionCode))
                    };

                    if (Exists(parameters))
                    {
                        dt = permissionScopeManager.GetDataTable(parameters);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            permissionScopeManager.DeleteEntity(dt.Rows[0][BasePermissionScopeEntity.FieldId].ToString());
                        }
                    }
                }
                else
                {
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, roleTableName),
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, roleId),
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizationEntity.CurrentTableName),
                        new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, new BaseModuleManager().GetIdByCodeByCache(systemCode, permissionCode))
                    };

                    dt = permissionScopeManager.GetDataTable(parameters);
                    for (var i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["TargetId"].ToString() != ((int)PermissionOrganizationScope.NotAllowed).ToString())
                        {
                            permissionScopeManager.DeleteEntity(dt.Rows[0][BasePermissionScopeEntity.FieldId].ToString());
                        }
                    }
                }
            }

            return(result);
        }
Esempio n. 22
0
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BasePermissionScopeEntity permissionScopeEntity);
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">实体</param>
 public int Update(BasePermissionScopeEntity entity)
 {
     return(UpdateEntity(entity));
 }
Esempio n. 24
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="baseResourcePermissionScopeEntity">实体</param>
        public string AddEntity(BasePermissionScopeEntity baseResourcePermissionScopeEntity)
        {
            string     sequence   = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BasePermissionScopeEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldId, baseResourcePermissionScopeEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BasePermissionScopeEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BasePermissionScopeEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (baseResourcePermissionScopeEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            baseResourcePermissionScopeEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(BasePermissionScopeEntity.FieldId, baseResourcePermissionScopeEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, baseResourcePermissionScopeEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BasePermissionScopeEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BasePermissionScopeEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Esempio n. 25
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">主键</param>
        public BasePermissionScopeEntity GetEntity(int id)
        {
            BasePermissionScopeEntity baseResourcePermissionScopeEntity = new BasePermissionScopeEntity(this.GetDataTable(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldId, id)));

            return(baseResourcePermissionScopeEntity);
        }
Esempio n. 26
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="baseResourcePermissionScopeEntity">实体</param>
 public int Update(BasePermissionScopeEntity baseResourcePermissionScopeEntity)
 {
     return(this.UpdateEntity(baseResourcePermissionScopeEntity));
 }
Esempio n. 27
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseResourcePermissionScopeEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主鍵</param>
 /// <returns>主键</returns>
 public string Add(BasePermissionScopeEntity baseResourcePermissionScopeEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(baseResourcePermissionScopeEntity));
 }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddEntity(BasePermissionScopeEntity entity)
        {
            var key = string.Empty;

            if (entity.SortCode == 0)
            {
                var managerSequence = new BaseSequenceManager(DbHelper, Identity);
                if (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.Db2)
                {
                    key = managerSequence.Increment($"SC_{CurrentTableName}_SEQ");
                }
                else
                {
                    key = managerSequence.Increment(CurrentTableName);
                }
                entity.SortCode = key.ToInt();
            }
            var sqlBuilder = new SqlBuilder(DbHelper, Identity, ReturnId);

            sqlBuilder.BeginInsert(CurrentTableName, PrimaryKey);
            if (!Identity)
            {
                // 这里已经是指定了主键了,所以不需要返回主键了
                sqlBuilder.ReturnId = false;
                sqlBuilder.SetValue(PrimaryKey, entity.Id);
            }
            else
            {
                if (!ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.Db2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(PrimaryKey, $"{CurrentTableName}_SEQ.NEXTVAL");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.Db2)
                    {
                        sqlBuilder.SetFormula(PrimaryKey, $"NEXT VALUE FOR {CurrentTableName}_SEQ");
                    }
                }
                else
                {
                    if (Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.Db2))
                    {
                        var managerSequence = new BaseSequenceManager(DbHelper);
                        entity.Id = managerSequence.Increment($"{CurrentTableName}_SEQ").ToInt();
                        sqlBuilder.SetValue(PrimaryKey, entity.Id);
                    }
                }
            }
            SetEntity(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateUserId, UserInfo.UserId);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateUserName, UserInfo.UserName);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateBy, UserInfo.RealName);
            }
            else
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateBy, entity.CreateBy);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateUserName, entity.CreateUserName);
            }
            sqlBuilder.SetDbNow(BasePermissionScopeEntity.FieldCreateTime);
            sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateIp, Utils.GetIp());
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldUpdateUserId, UserInfo.UserId);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldUpdateUserName, UserInfo.UserName);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldUpdateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDbNow(BasePermissionScopeEntity.FieldUpdateTime);
            sqlBuilder.SetValue(BasePermissionScopeEntity.FieldUpdateIp, Utils.GetIp());
            if (Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                key = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            if (Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.Db2))
            {
                key = entity.Id.ToString();
            }
            if (!string.IsNullOrWhiteSpace(key))
            {
                RemoveCache();
            }
            return(key);
        }
 // 这个是声明扩展方法
 partial void SetEntityExtend(SqlBuilder sqlBuilder, BasePermissionScopeEntity entity);
Esempio n. 30
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(BasePermissionScopeEntity entity)
        {
            string     sequence   = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BasePermissionScopeEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.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(BasePermissionScopeEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                        sqlBuilder.SetFormula(BasePermissionScopeEntity.FieldId, "SEQ_" + BaseOrganizeScopeEntity.TableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        // sqlBuilder.SetFormula(BasePermissionScopeEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                        sqlBuilder.SetFormula(BasePermissionScopeEntity.FieldId, "NEXT VALUE FOR SEQ_" + BaseOrganizeScopeEntity.TableName.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(BasePermissionScopeEntity.FieldId, entity.Id);
                    }
                }
            }
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BasePermissionScopeEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BasePermissionScopeEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BasePermissionScopeEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }