public void SetUserStatus(string userName, UserStatus status) { // Internally we implement this by adding the user to the #locked group. var table = QueryContext.GetMutableTable(SystemSchema.UserGroupTableName); var c1 = table.GetResolvedColumnName(0); var c2 = table.GetResolvedColumnName(1); // All 'user_group' where UserName = %username% var t = table.SimpleSelect(QueryContext, c1, SqlExpressionType.Equal, SqlExpression.Constant(userName)); // All from this set where PrivGroupName = %group% t = t.SimpleSelect(QueryContext, c2, SqlExpressionType.Equal, SqlExpression.Constant(SystemGroups.LockGroup)); bool userBelongsToLockGroup = t.RowCount > 0; if (status == UserStatus.Locked && !userBelongsToLockGroup) { // Lock the user by adding the user to the Lock group // Add this user to the locked group. var rdat = new Row(table); rdat.SetValue(0, userName); rdat.SetValue(1, SystemGroups.LockGroup); table.AddRow(rdat); } else if (status == UserStatus.Unlocked && userBelongsToLockGroup) { // Unlock the user by removing the user from the Lock group // Remove this user from the locked group. table.Delete(t); } }
public ITable GetTable(int offset) { var tableInfo = GetTableInfo(offset); var table = new TriggeredOldNew(transaction.Context, tableInfo); if (HasOldTable) { if (offset == 0) { // Copy data from the table to the new table var dtable = transaction.GetTable(Handler.TableState.TableSource); var oldRow = new Row(table); int rowIndex = Handler.TableState.OldRowIndex; for (int i = 0; i < tableInfo.ColumnCount; ++i) { oldRow.SetValue(i, dtable.GetValue(rowIndex, i)); } // All OLD tables are immutable table.SetReadOnly(true); table.SetData(oldRow); return table; } } table.SetReadOnly(!Handler.TableState.IsNewMutable); table.SetData(Handler.TableState.NewDataRow); return table; }