Show / Hide Table of Contents

Class InterestHelper

Base class for contact and person interest helpers. The helpers provide functionality that combines MDO list and 'what is actually selected', i.e., they combine entity subcollections with mdo lists.

Inheritance
Object
MDOProviderBase
InterestHelper
ContactInterestHelper
PersonInterestHelper
Implements
ISoListProvider
ISoList
IEnumerable<ISoListItem>
IEnumerable
Inherited Members
MDOProviderBase._historyIds
MDOProviderBase._searchValue
MDOProviderBase._forceFlatList
MDOProviderBase._rootCollection
MDOProviderBase._historyCollection
MDOProviderBase._headingCollection
MDOProviderBase._declaredListName
MDOProviderBase._tableRows
MDOProviderBase._nodeType
MDOProviderBase._listName
MDOProviderBase._tableName
MDOProviderBase._tableListInfo
MDOProviderBase._listInfo
MDOProviderBase.Construct(String, String, Int32[], Boolean, String, Boolean)
MDOProviderBase.FillList()
MDOProviderBase.GetHistoryCollection()
MDOProviderBase.ReadSimpleList()
MDOProviderBase.GetSimpleListQuery()
MDOProviderBase.AddSimpleListOrderBy(ListTableRows.CustomSearch)
MDOProviderBase.GetItemsAndHeadingsQuery(Boolean, Int32[])
MDOProviderBase.AddGroupLinkJoin(Int32[], ListTableRows.CustomSearch)
MDOProviderBase.GetItemType(ListTableRow)
MDOProviderBase.GetHeadingType(ListTableRow)
MDOProviderBase.GetItemIconHint(ListTableRow)
MDOProviderBase.GetHeadingIconHint(ListTableRow)
MDOProviderBase.GetItemId(ListTableRow)
MDOProviderBase.GetItemName(ListTableRow)
MDOProviderBase.AcceptHistoryRow(ListTableRow)
MDOProviderBase.GetHistoryIconHint(ListTableRow)
MDOProviderBase.GetItemTooltip(ListTableRow)
MDOProviderBase.GetItemRank(ListTableRow)
MDOProviderBase.GetItemDeleted(ListTableRow)
MDOProviderBase.GetItemColor(ListTableRow)
MDOProviderBase.GetItemStyleHint(ListTableRow)
MDOProviderBase.GetItemExtraInfo(ListTableRow)
MDOProviderBase.GetGroupingAllowedForList()
MDOProviderBase.OnAddRootElementToCollection(SoListItem)
MDOProviderBase.OnAddSubItemToCollection(SoListItem, List<ISoListItem>)
MDOProviderBase.OnAddHeadingElementToCollection(SoListHeading)
MDOProviderBase.OnAddHistoryElementToCollection(SoListItem)
MDOProviderBase.GetListLowerLimit()
MDOProviderBase.GetPreferredSortOrder()
MDOProviderBase.ResortFlattenedList()
MDOProviderBase.IEnumerable<ISoListItem>.GetEnumerator()
MDOProviderBase.IEnumerable.GetEnumerator()
MDOProviderBase.HistoryInfo
MDOProviderBase.IncludeDeletedItems
MDOProviderBase.InhibitResortOnFlattening
MDOProviderBase.IsFinalListFlat
MDOProviderBase.HistoryItems
MDOProviderBase.RootItems
MDOProviderBase.HeadingItems
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.Entities
Assembly: SoDataBase.dll
Syntax
public abstract class InterestHelper : MDOProviderBase, ISoListProvider, ISoList, IPlugin, IEnumerable<ISoListItem>, IEnumerable
Remarks

The MDO list is available in two flavours - as the standard list, with Root and Heading items; and as a subset, containing only those rows that have corresponding link rows to the parent entity.

In both cases, the actual items in the lists are of type ISelectableListItem, an interface that inherits from ISoListItem but adds two more properties: A settable bool Selected, and a read-only DateTime LastChanged (which is automatically maintained).

The various SetItemSelection collections will accept a whole ISoList or various sub-objects of it, extract the Selected flags and update the entity data accordingly. Note that items that lose their Selected status cause immediate deletions, while new Selected items are not stored to the database until entity.Save() is called. Interests not in the incoming lists will not be touched.

Note that you cannot add new interest items through this class, only link existing interest items to a particular contact or person. Add new interests is an ordinary list-editing task, to be done through SoAdmin.

Constructors

InterestHelper(TableRowsBase, String, Int32)

Default constructor.

Declaration
protected InterestHelper(TableRowsBase selectedInterests, string tableName, int parentEntityId)
Parameters
Type Name Description
TableRowsBase selectedInterests

List of the currently selected interests. This can either be a class of type ContIntRows or PersIntRows

String tableName

Name of the table holding the definition of the interests

Int32 parentEntityId

Fields

_parentEntityId

Declaration
protected int _parentEntityId
Field Value
Type Description
Int32

_selectedHeadingCollection

Declaration
protected List<ISoListHeading> _selectedHeadingCollection
Field Value
Type Description
List<ISoListHeading>

_selectedInterestIds

Declaration
protected Dictionary<int, TableRowBase> _selectedInterestIds
Field Value
Type Description
Dictionary<Int32, TableRowBase>

_selectedInterests

Declaration
protected TableRowsBase _selectedInterests
Field Value
Type Description
TableRowsBase

_selectedRootCollection

Declaration
protected List<ISoListItem> _selectedRootCollection
Field Value
Type Description
List<ISoListItem>

Properties

SelectedHeadingItems

Get the list of heading items that are currently selected, i.e., have link rows to the parent entity.

Declaration
public List<ISoListHeading> SelectedHeadingItems { get; }
Property Value
Type Description
List<ISoListHeading>

SelectedRootItems

Get the list of root items that are currently selected, i.e., have link rows to the parent entity.

Declaration
public List<ISoListItem> SelectedRootItems { get; }
Property Value
Type Description
List<ISoListItem>

Methods

BuildMdoCollections()

Convert rows object to ISoList collections. Fetching of the MDO list runs in the base class, here we instantiate InterestMDOListItem objects instead of the more generic ones, so that we can add the extra information (selected & date).

Declaration
protected override void BuildMdoCollections()
Overrides
MDOProviderBase.BuildMdoCollections()

CreateInterest(Int32)

Create a new link row for the given interest, using the protected _parentEntityId as the entity id. ALSO: Add to the _selectedInterests collection, since TableRowsBase does not have a public Add operator.

Declaration
protected abstract TableRowBase CreateInterest(int interestId)
Parameters
Type Name Description
Int32 interestId

Interest id to link to

Returns
Type Description
TableRowBase

New row, which has already been added to the entity's link table collections

GetInterestDate(TableRowBase)

Get the interest date from the link row (which must be castable to the correct type)

Declaration
protected abstract DateTime GetInterestDate(TableRowBase row)
Parameters
Type Name Description
TableRowBase row

Row, castable to the type needed by the subclass

Returns
Type Description
DateTime

Last changed date extracted from the row

GetInterestId(TableRowBase)

Get the interest id from the link row (which must be castable to the correct type)

Declaration
protected abstract int GetInterestId(TableRowBase row)
Parameters
Type Name Description
TableRowBase row

Row, castable to the type needed by the subclass

Returns
Type Description
Int32

Interest ID the row links to

GetItemsAndHeadingsQuery()

Create a query for for reading the items and headings of the interest list, including any currently selected items (regardless of filtering; this is implemented in the base class). Searching is not supported.

Declaration
protected override ListTableRows.CustomSearch GetItemsAndHeadingsQuery()
Returns
Type Description
ListTableRows.CustomSearch

Query for reading the items and headdings of a list.

Overrides
MDOProviderBase.GetItemsAndHeadingsQuery()

IsItemSelected(Int32)

Declaration
public bool IsItemSelected(int interestId)
Parameters
Type Name Description
Int32 interestId
Returns
Type Description
Boolean

ReadItemsAndHeadings()

Read all mdo items with heading information

Declaration
protected override void ReadItemsAndHeadings()
Overrides
MDOProviderBase.ReadItemsAndHeadings()

Refresh()

Declaration
public void Refresh()

SetItemSelection(ISelectableListItem)

Extract the 'Selected' property from the elements, and synchronize the entity's link table with the present status. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)

Declaration
public void SetItemSelection(ISelectableListItem item)
Parameters
Type Name Description
ISelectableListItem item

Single MDO list item

SetItemSelection(ISoList)

Extract the 'Selected' property from all elements, and synchronize the entity's link table with the present status. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)

Declaration
public void SetItemSelection(ISoList list)
Parameters
Type Name Description
ISoList list

Complete MDO list, with root, heading and history items. History items are IGNORED!

SetItemSelection(List<ISelectableListItem>)

Extract the 'Selected' property from all elements, and synchronize the entity's link table with the present status. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)

Declaration
public void SetItemSelection(List<ISelectableListItem> items)
Parameters
Type Name Description
List<ISelectableListItem> items

List of MDO list items

SetItemSelection(List<ISoListItem>)

Extract the 'Selected' property from all elements, and synchronize the entity's link table with the present status. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)

Declaration
public void SetItemSelection(List<ISoListItem> selectableItems)
Parameters
Type Name Description
List<ISoListItem> selectableItems

List of MDO list items. Items not of (a subtype of) ISelectableListItem are quietly ignored and do no harm.

SetItemSelection(Int32, Boolean)

Synchronize the entity's link table with the present status for the given interest. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)

Declaration
public void SetItemSelection(int interestId, bool isSelected)
Parameters
Type Name Description
Int32 interestId

ID of interest to add or remove

Boolean isSelected

New status

Events

OnActiveInterestsChanged

Subscribe or unsubscribe to the event raised whenever the number of active interests are changed.

Declaration
public event ActiveInterestsChanged OnActiveInterestsChanged
Event Type
Type Description
ActiveInterestsChanged

Implements

ISoListProvider
ISoList
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

EnumUtil.MapEnums<From, To>(From)
IEnumerableExtensions.ForEach<T>(System.Collections.Generic.IEnumerable<T>, System.Action<T>)
IEnumerableExtensions.ContainsAny<T>(System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IEnumerable<T>)
IEnumerableExtensions.Batch<T>(System.Collections.Generic.IEnumerable<T>, System.Int32)
IEnumerableExtensions.IndexOf<T>(System.Collections.Generic.IEnumerable<T>, T, System.Int32)
IEnumerableExtensions.IndexOf<T>(System.Collections.Generic.IEnumerable<T>, System.Func<T, System.Boolean>, System.Int32)
IEnumerableExtensions.Permute<T>(System.Collections.Generic.IEnumerable<T>, System.Int32)
IEnumerableExtensions.PermissiveToDictionary<T, K, V>(System.Collections.Generic.IEnumerable<T>, System.Func<T, K>, System.Func<T, V>)
IEnumerableExtensions.PermissiveToDictionary<T, K, V>(System.Collections.Generic.IEnumerable<T>, System.Func<T, K>, System.Func<T, V>, System.Collections.Generic.IEqualityComparer<K>)
IEnumerableExtensions.GetDifferentCombinations<T>(System.Collections.Generic.IEnumerable<T>, System.Int32)
CollectionOps.AtLeastOne<T>(IEnumerable<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