public bool GetBranchAccumMinutes(long lGroup, ref long m_lRealAccMinutes) { trace.Write(TraceLevel.Debug, "CM1GroupsTree::GetBranchAccumMinutes"); bool fnResult = true; try { CM1Group group = GetGroupFromGrpId(lGroup); if (group == null) { throw new InvalidOperationException("Could not obtain group of current operation"); } long lGrpAccMinutes = 0; m_lRealAccMinutes = 0; while (group != null) { lGrpAccMinutes = group.GetAccMinutes(); m_lRealAccMinutes = Math.Max(lGrpAccMinutes, m_lRealAccMinutes); group = GetGroupParent(group.GetGrpId()); } trace.Write(TraceLevel.Info, $"Minutes accumulate for branch of group {lGroup}: {m_lRealAccMinutes}"); } catch (Exception error) { trace.Write(TraceLevel.Error, error.ToLogString()); fnResult = false; } return(fnResult); }
// OPERATIONS /// <summary> /// Returns the maximum minutes that a user can spend in a branch without overflowing the maximum money constraint in any group /// </summary> /// <param name="groupId"></param> /// <param name="minutes"></param> /// <returns>bool</returns> public bool GetBranchMaxAvailableMinutes(long groupId, ref long minutes, bool isComputeEx1 = false) { trace?.Write(TraceLevel.Debug, "CM1GroupTree::GetBranchMaxAvailableMoney"); bool fnResult = true; try { CM1Group treeGroup = GetGroupFromGrpId(groupId); if (treeGroup == null) { throw new ArgumentNullException(nameof(groupId), "Could not obtain group of current operation"); } long lGrpAccMinutes = 0; long lGrpMaxMinutes = 0; minutes = 999999999; while (treeGroup != null) { if (isComputeEx1) { lGrpAccMinutes = treeGroup.GetRealAccMinutes(); } else { lGrpAccMinutes = treeGroup.GetAccMinutes(); } lGrpMaxMinutes = treeGroup.GetMaxMinutes(); if (lGrpMaxMinutes != GlobalDefs.DEF_UNDEFINED_VALUE) { minutes = Math.Min(lGrpMaxMinutes - lGrpAccMinutes, minutes); } treeGroup = GetGroupParent(treeGroup.GetGrpId()); } trace?.Write(TraceLevel.Info, $"Minutes left for branch of group {groupId}: {minutes}"); } catch (Exception error) { trace?.Write(TraceLevel.Error, error.ToLogString()); fnResult = false; } return(fnResult); }
public void TraceBranchM1ComputeEx1(long lGrpId) { trace.Write(TraceLevel.Debug, "CM1GroupsTree::TraceBranchM1ComputeEx1"); try { trace.Write(TraceLevel.Debug, $"Tracing branch of group: {lGrpId}"); trace.Write(TraceLevel.Debug, $"[ Group | Type | NumChilds | NumConstraits | PruneFase | Money | Minutes ]"); CM1Group pGrp = GetGroupFromGrpId(lGrpId); while (pGrp != null) { // For each group have to be a node CM1Node pNode = GetFirstNodeFromIds(pGrp.GetGrpId()); if (pNode != null) { trace.Write(TraceLevel.Debug, $"[ {pGrp.GetGrpId(),-7} | {pGrp.GetGrpTypeId(),-4} | {pNode.ChildsNum,9} | {pNode.CnstrNum,-13} | {pNode.PruneFase,-9} | {pGrp.GetAccMoney(),-5} | {pGrp.GetAccMinutes(),-7} ]"); } pGrp = GetGroupParent(pGrp.GetGrpId()); } } catch (Exception error) { trace.Write(TraceLevel.Error, error.ToLogString()); } }