Class TreeService
Inheritance
Implements
Namespace: DirectScale.Disco.Extension.Services
Assembly: DirectScale.Disco.Extension.Abstractions.dll
Syntax
public class TreeService : Object, ITreeService
Constructors
TreeService(IApiService)
Declaration
public TreeService(IApiService apiService)
Parameters
Type | Name | Description |
---|---|---|
IApiService | apiService |
Methods
DeleteNode(NodeId, TreeType)
Removes the specified Associate's id
placement from the specified tree
.
Declaration
public Task DeleteNode(NodeId id, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | The associate to remove. |
TreeType | tree | The tree to be removed from. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
DeleteNodeAll(NodeId)
Removes the specified Associate's placement from ALL trees.
Declaration
public Task DeleteNodeAll(NodeId id)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | The associate to remove from all trees. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
GetBottomOfLeg(NodeId, LegName, TreeType)
Declaration
public Task<NodeDetail> GetBottomOfLeg(NodeId id, LegName leg, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | |
LegName | leg | |
TreeType | tree |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeDetail> |
GetDownlineIds(NodeId, TreeType, Int32)
Gets a unordered list of the specifed Id's downline.
Declaration
public Task<NodeDetail[]> GetDownlineIds(NodeId id, TreeType tree, int levels)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | |
TreeType | tree | |
System.Int32 | levels |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeDetail[]> |
GetFirstTreeNodeId(Int32, TreeType)
Gets the NodeId of this associateId
for the first time they appear in tree
.
Declaration
public Task<NodeId> GetFirstTreeNodeId(int associateId, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Associate to find in |
TreeType | tree | The tree to look in. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeId> | The first NodeId found. |
See Also
GetLastTreeNodeId(Int32, TreeType)
Gets the NodeId of this associateId
for the last time they appear in tree
.
Declaration
public Task<NodeId> GetLastTreeNodeId(int associateId, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Associate to find in |
TreeType | tree | The tree to look in. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeId> |
Remarks
In most cases this will be the same result as GetFirstTreeNodeId(Int32, TreeType). Most comp plans only allow an associate to be placed in each tree once. See GetTreeIndexes(Int32, TreeType) if associate is allowed in the tree multipe times and you want to get all of those placements.
See Also
GetLegCount(NodeId, TreeType, LegName)
Gets the number of items in a specifed associateid
's leg
's downline tree in tree
.
Declaration
public Task<int> GetLegCount(NodeId id, TreeType tree, LegName leg)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | Associate with downline. |
TreeType | tree | Tree to use. |
LegName | leg | Associate's leg to size. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | The size of the associate's leg. |
GetLevel(NodeId, NodeId, TreeType)
Find out how many levels away id
is below inDownlineOfId
in tree
.
Declaration
public Task<int> GetLevel(NodeId id, NodeId inDownlineOfId, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | Dowline associate. |
NodeId | inDownlineOfId | Upline associate. |
TreeType | tree | Tree to use. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | Distance between upline and downline associate, or -1 if not in downline. |
GetMatrixDepth()
Gets the maximum allowed depth in a matrix tree. This is set through the advanced setting "MatrixDepthSetting".
Declaration
public Task<int> GetMatrixDepth()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | Max depth of a matrix tree. |
GetNodeDetail(NodeId, TreeType)
Gets the specified associate id
's UplineID and Leg in tree
.
Declaration
public Task<NodeDetail> GetNodeDetail(NodeId id, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | Associate to find upline for. |
TreeType | tree | Tree to find upline in. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeDetail> | Upline and leg details for associate. |
GetTree(NodeId, TreeType, Int32)
Gets levels
of downline Tree for a specified associateid
in tree
.
Declaration
public Task<Node> GetTree(NodeId id, TreeType tree, int levels)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | The associate to get tree for. |
TreeType | tree | The tree to read. |
System.Int32 | levels | The number of levels deep to find associate below specified associate. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Node> | Downline tree that can be traversed by going through the Legs. |
GetTreeIndexes(Int32, TreeType)
Gets all of the times this associateId
is found within tree
. To use these values create a new NodeId for this associate with the TreeIndex set to one of the values in the return array to specify an exact position in the tree
.
Declaration
public Task<int[]> GetTreeIndexes(int associateId, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Associate to find in |
TreeType | tree | The tree to look in. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32[]> | All of the assocaite's placements in this tree. |
Remarks
Since most comp plans only allow an associate to be placed in each tree once, the return value will usually be an array with a single element of value "0".
The reason this doesn't just return a single int representing the number of times an associate is in a tree, is because an associate could be added into the tree multiple times, but then deleted, creating gaps. Example return value: {0, 1, 3, 5}
See Also
GetUnplacedNodes(NodeId, TreeType, TreeType)
Finds all the associates downline of id
's in sourcTreeType
, that have not been placed in tree
. Example: GetUnplacedNodes(2, TreeType.Enrollment, TreeType.Binary); will find the associates that this associate enrolled, but still needs to place in the binary tree.
Declaration
public Task<NodeId[]> GetUnplacedNodes(NodeId id, TreeType sourcTreeType, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | Associate with unplaced people in downline. |
TreeType | sourcTreeType | The tree used to find their downline. |
TreeType | tree | The tree used to determine if they've been placed. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeId[]> | Associates that are under |
GetUplineIds(NodeId, TreeType)
Gets the chain of associate NodeDetails from id
to the top of the tree tree
, in order.
Declaration
public Task<NodeDetail[]> GetUplineIds(NodeId id, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | The associate to find the uplines of. |
TreeType | tree | The tree to walk up. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeDetail[]> | An array of associates, including and starting with the passed in associate |
Remarks
Counterintuitively, the first element returned in the array will be equivalent to calling GetNodeDetail(NodeId, TreeType) for the passed in associate id
, NOT the associate's direct upline. This is because the relationship between the associate and their enroller comes from UplineLeg. Skipping straight to the first upline would loose this information connecting the reqeusted associate to their direct upine.
If only the direct upline's associate id is needed, then using GetNodeDetail(NodeId, TreeType) will be more efficient and UplineId will provide the upline's id.
Example: These should all return the same value if called for the same associate and tree: GetNodeDetail(...).UplineId, GetUplineIds(...)[0].UplineId, GetUplineIds(...)[1].NodeId
GetUplineIdsBulk(NodeId[], TreeType)
Declaration
public Task<NodeDetail[]> GetUplineIdsBulk(NodeId[] ids, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId[] | ids | |
TreeType | tree |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeDetail[]> |
GetUplineIdsPartial(NodeId, NodeId, TreeType)
Gets the chain of associate NodeDetails from beginId
to endId
in tree
, in order.
Declaration
public Task<NodeDetail[]> GetUplineIdsPartial(NodeId beginId, NodeId endId, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId | beginId | The node to begin getting detail from. |
NodeId | endId | The node to stop at when getting detail. |
TreeType | tree | The tree to get detail from. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NodeDetail[]> | Array of upline details starting with |
InDownline(NodeId, NodeId, TreeType)
Returns 'True' if the id
is in the downline of inDownlineOfId
in tree
.
Declaration
public Task<bool> InDownline(NodeId id, NodeId inDownlineOfId, TreeType tree)
Parameters
Type | Name | Description |
---|---|---|
NodeId | id | Associate being searched for. |
NodeId | inDownlineOfId | Associate's downline to search. |
TreeType | tree | Tree to look in. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | Indicates if |
Place(Placement[])
Executes one or more placements or moves.
Declaration
public Task Place(Placement[] changes)
Parameters
Type | Name | Description |
---|---|---|
Placement[] | changes | The array of changes to be made. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Remarks
It is important that you call ValidatePlacements(Placement[]) first!
See Also
ValidatePlacements(Placement[])
Validate changes
before the placements are actually executed.
Declaration
public Task ValidatePlacements(Placement[] changes)
Parameters
Type | Name | Description |
---|---|---|
Placement[] | changes | The array of changes to validate. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |