Class AppointmentSentry
AppointmentSentry guards Appointment entities and their component rows. Document entities also use the AppointmentSentry - since they are basically appointments with a bit of extra info attached.
The AppointmentSentry applies to the following classes: Appointment, AppointmentRow, TextRow, DocumentRow
Inheritance
Implements
Inherited Members
Namespace: SuperOffice.CRM.Security
Assembly: SoDataBase.dll
Syntax
public class AppointmentSentry : RoleRightsSentry<AppointmentTableInfo>, ICloneable
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
Examples
AppointmentRow a = new AppointmentRow.IdxAppointmentId(1234); TextRow t = new TextRow.IdxTextId( a.TextId, a.Sentries );
Constructors
AppointmentSentry(AppointmentTableInfo)
Create a Appointment sentry.
Declaration
public AppointmentSentry(AppointmentTableInfo appointmentTableInfo)
Parameters
Type | Name | Description |
---|---|---|
AppointmentTableInfo | appointmentTableInfo |
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
AppointmentSentry(AppointmentTableInfo, ISoDataLookup)
Create a Appointment sentry for a particular Appointment row. The row's associate_id will control the user's permissions with respect to this row.
Declaration
public AppointmentSentry(AppointmentTableInfo appointmentTableInfo, ISoDataLookup lookup)
Parameters
Type | Name | Description |
---|---|---|
AppointmentTableInfo | appointmentTableInfo | |
ISoDataLookup | lookup |
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
Properties
AssociateId
Appointment.associate id
Declaration
public override int AssociateId { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
GroupId
returns Appointment.GroupIdx
Declaration
public override int GroupId { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
IsDocument
Does appointment represent a document entity? Checks appointment.type field.
Declaration
public bool IsDocument { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
IsGhostRow
Returns whether the primary key is a ghost field (i.e., we're looking at a nonexistent record, as opposed to just looking at a new one)
Declaration
public override bool IsGhostRow { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
IsNew
Is the row saved to teh database (persisted primary key == 0)
Declaration
public override bool IsNew { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
MainTable
Return Appointment table info.
Declaration
protected AppointmentTableInfo MainTable { get; }
Property Value
Type | Description |
---|---|
AppointmentTableInfo |
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
RegisteredAssociateIdField
The field that holds the associate id of teh user first creating the item.
Declaration
public override FieldInfo RegisteredAssociateIdField { get; }
Property Value
Type | Description |
---|---|
FieldInfo |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
RegisteredField
The field that holds information about when the item was first created.
Declaration
public override FieldInfo RegisteredField { get; }
Property Value
Type | Description |
---|---|
FieldInfo |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
RoleTableRights
Returns Appointment or Document rights depending on the appointment type.
Declaration
protected override ETableRight RoleTableRights { get; }
Property Value
Type | Description |
---|---|
ETableRight |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
RowId
Should return a Appointment.Appointment_id
Declaration
public override int RowId { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
Methods
AddFieldsToLookup(Dictionary<FieldInfo, object>, params FieldInfo[])
Add fieldinfos to a simple lookup dictionary
Declaration
protected void AddFieldsToLookup(Dictionary<FieldInfo, object> lookup, params FieldInfo[] fieldsToAdd)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<FieldInfo, object> | lookup | Dictionary to add to (duplicates are OK) |
FieldInfo[] | fieldsToAdd | Array of fields to add |
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
ComputeDerivedTableRights()
Handles document rights.
Declaration
protected override void ComputeDerivedTableRights()
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
ComputeFieldRights()
Computes the field rights based on the associate and group info in the row. The sub-class will handle its particular special cases here. This function is called from SuperComputeFieldRights() which does the standard calculations first, then allows this function to add any special restrictions afterwards.
This function computes a map of rights to all fields that can be determined, both on the primary table and any dependent tables. Each field has an entry in the map, which contains a bitwise OR of all rights the current user has to that field. If the user has no update rights to a field, the corresponding GUI control should be read-only. If the user has no Read rights to a field, its value should not be shown at all. In the case of write but not read rights, the sanity of the underlying rules should be questioned.
Declaration
protected override void ComputeFieldRights()
Overrides
Remarks
Place the results of the computation in the _fieldRights member.
ComputeTableRights()
Computes table rights for Appointment tables. Deny read rights to private appointments that belong to others. Grant update+insert+delete rights to own appointments.
Declaration
protected override void ComputeTableRights()
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
GetMainRight()
Adds filtering right to ensure appointment start+stop fields are always visible.
Declaration
public override ETableRight GetMainRight()
Returns
Type | Description |
---|---|
ETableRight | appointment table right + filtering right |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
GetRecordOwnershipIndex()
Return the sort of relationship between the current user and the Sentry's user and group.
Declaration
public override EOwnershipIndex GetRecordOwnershipIndex()
Returns
Type | Description |
---|---|
EOwnershipIndex | Relationship to the item. |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
GetRowSentry()
Create a copy of the Sentry holding the right instances of table and field infos.
Declaration
public override Sentry GetRowSentry()
Returns
Type | Description |
---|---|
Sentry | New instance of the Sentry. |
Overrides
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
GetTableInfoFromQuery<TargetTableInfo>()
Get tables of the given type from our query
Declaration
protected List<TargetTableInfo> GetTableInfoFromQuery<TargetTableInfo>() where TargetTableInfo : TableInfo
Returns
Type | Description |
---|---|
List<TargetTableInfo> | List of tableinfos of the given type, from the query |
Type Parameters
Name | Description |
---|---|
TargetTableInfo | Type of table to look for |
Remarks
The Appointment row automatically creates a sentry, because Appointment is also an RDB Entity. The text row does not create a sentry because it does not know which entity it belongs to, so we have to give it a sentry to use. The text row asks the Appointment sentry about its permissions.
SetBookingFieldRights()
Set the field rights for all fields we are responsible for, for the special case of 'Booking' (slave, not master). This method uses the And operator of FieldRight and will never add rights, only subtract.
Declaration
protected void SetBookingFieldRights()
Remarks
You get very few rights to a booking. You can read everything, but can't change most things. The code tries to match the C++ code in RDB/AppointmentSentry.cpp around line 310. What we do here is to construct a list of 'surviving' fields, and then disable the rest in all tables we are responsible for.
The code in SetFilteredFieldRights(string) and SetBookingFieldRights() is similar in structure, but operates on different field sets and sets different rights.SetFilteredFieldRights(string)
Set the field rights for all fields we are responsible for, for the special case of 'Filtered read'. This method uses the And operator of FieldRight and will never add rights, only subtract.
Declaration
protected void SetFilteredFieldRights(string reason)
Parameters
Type | Name | Description |
---|---|---|
string | reason | Reason string to set |
Remarks
You get very few rights to a filtered table - none, except for being able to read some fields. The code tries to match the C++ code in RDB/AppointmentSentry.cpp areound line 280. What we do here is to construct a list of 'surviving' fields, and then cloak the rest in all tables we are responsible for.