Show / Hide Table of Contents

Class PersonRankHelper

Helper class to handle issues around the Rank field of the Person row

Inheritance
Object
PersonRankHelper
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.Rows
Assembly: SoDataBase.dll
Syntax
public sealed class PersonRankHelper
Remarks

Persons that belong to one contact should have a monotonically increasing set of rank values, starting with 1. In order to move a person to a lower (earlier) rank, it is swapped with its neighbour; or if the move takes it further, all intervening persons also get their ranks changed.

This class contains methods to shift a person one step up or down; set a given rank value; and normalize (clean up) the ranks for a given contact, in case they have become inconsistent.

The person with rank 1 (and there should only be one!) has a special function and is used in many cases, such as when 'add first person' in selection is used.

Constructors

PersonRankHelper()

Declaration
public PersonRankHelper()

Methods

ChangePersonRank(Int32, Boolean)

Move one person up or down in the ranking in the Person Archive, if possible.

The person record that has rank = 1 is the primary contact for a company, and is the one used in situations where no person has been explicitly chosen (such as in selections).

This method corresponds to the move up/move down functions in the person archive in the contact panel.

This method always affects two records.

Declaration
public int ChangePersonRank(int personId, bool moveUp)
Parameters
Type Name Description
Int32 personId

Primary key of person record to move up or down. You must have write access both to this record AND to whatever record is adjacent in the direction you want to move.

Boolean moveUp

If true, the given person is moved to an earlier rank (lower numeric rank value, down to a limit of 1; up in the GUI if sorted by ascending rank). If false, movement is to later priority (higher numeric rank value).

Returns
Type Description
Int32

If movement occurred, the return value will be the ID of the OTHER person that got moved. A GUI should switch the positions of the original person ID and this return value.

If no movement occurred, for any reason, 0 is returned.

NormalizeRanks(Int32)

Nomralize the ranks for all persons that belong to a contact. This means that the persons will be sorted according to their current rank values, and the ranks will be made monotonically increasing from 1.

Declaration
public bool NormalizeRanks(int contactId)
Parameters
Type Name Description
Int32 contactId

Id of contact whose persons are to be rank normalized

Returns
Type Description
Boolean

The reutrn value is true if the operation suceeded, either because all persons were already normalized, or because normalization was done. It is false if Sentry blocks any required changes.

SetPersonRank(Int32, Int16)

Directly set the rank field of a person record, adjusting all other person records under the same contact as needed.

This call may affect multiple records, potentially all person records belonging to one contact.

You must have write access for to affected records for this method to succeed.

Declaration
public bool SetPersonRank(int personId, short desiredRank)
Parameters
Type Name Description
Int32 personId

Id of person to change

Int16 desiredRank

Desired rank to set, legal values are from 1 to the number of person records on this contact. Out of range values will be moved to the closest valid value and processed.

Returns
Type Description
Boolean

If movement occurred, or the person already had exactly the desired rank value, then the return value will be true. If movement did not occur, for any other reason, the return value is false.

Extension Methods

EnumUtil.MapEnums<From, To>(From)
ObjectExtensions.AssignByReflection<T>(T, T)
ObjectExtensions.GraphCopy<T>(T)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top