protected ActionNode GetActionNodeByNewCompositeWeight(int actionNodeNewCompositeWeight, DBNode dbNode) { var objList = from aNode in dbNode.Cast <ActionNode>() where aNode.CompositeWeightRangeStart <= actionNodeNewCompositeWeight && aNode.CompositeWeightRangeEnd >= actionNodeNewCompositeWeight select aNode; foreach (ActionNode aNode in dbNode) { if (aNode.CompositeWeightRangeStart <= actionNodeNewCompositeWeight && aNode.CompositeWeightRangeEnd >= actionNodeNewCompositeWeight) { ActionNode node = aNode; } } return(objList.FirstOrDefault()); }
protected DBNode SetActionNodesCompositeWeight(CustomDBGroup customDBGroup, string dbNodeName, out int dbNodeTotalCompositeWeight, out IList <ActionNode> readWriteActionNodes, out int dbNodeReadWriteTotalCompositeWeight) { int intReadWriteImpactFactor = customDBGroup.DBNodes.ReadWriteImpactFactor; int intConstReadWrite = customDBGroup.DBNodes.ConstReadWrite; int intConstRead = customDBGroup.DBNodes.ConstRead; DBNode dbNode = GetCurrentDBNode(customDBGroup.GroupTypeEnum, dbNodeName); foreach (ActionNode aNode in dbNode) { switch (aNode.ActionEnum) { case ActionEnum.Read: aNode.CompositeWeight = intReadWriteImpactFactor * intConstRead + aNode.Weight; break; case ActionEnum.ReadWrite: aNode.CompositeWeight = intReadWriteImpactFactor * intConstReadWrite + aNode.Weight; break; } } var objActionList = from a in dbNode.Cast <ActionNode>() orderby a.CompositeWeight ascending select a; foreach (ActionNode aNode in objActionList) { var objListP = from n in objActionList where n.CompositeWeight <= aNode.CompositeWeight select n; int intTotalCompositeWeight = objListP.Sum <ActionNode>(actionNode => actionNode.CompositeWeight); aNode.CompositeWeightRangeEnd = intTotalCompositeWeight; aNode.CompositeWeightRangeStart = intTotalCompositeWeight - aNode.CompositeWeight + 1; } dbNodeTotalCompositeWeight = objActionList.Sum <ActionNode>(actionNode => actionNode.CompositeWeight); var objReadWriteActionNodeList = from aNode in objActionList where aNode.ActionEnum == ActionEnum.ReadWrite select aNode; dbNodeReadWriteTotalCompositeWeight = objReadWriteActionNodeList.Sum <ActionNode>(aNode => aNode.CompositeWeight); List <ActionNode> listReadWriteActionNodes = new List <ActionNode>(); foreach (ActionNode aNode in objReadWriteActionNodeList) { var objListP = from n in objReadWriteActionNodeList where n.CompositeWeight <= aNode.CompositeWeight select n; int intTotalReadWriteCompositeWeight = objListP.Sum <ActionNode>(actionNode => actionNode.CompositeWeight); ActionNode tempNode = new ActionNode(aNode.Name, aNode.ActionEnum, aNode.Weight, aNode.CompositeWeight, intTotalReadWriteCompositeWeight - aNode.CompositeWeight + 1, intTotalReadWriteCompositeWeight, aNode.ConnectionString); listReadWriteActionNodes.Add(tempNode); } readWriteActionNodes = listReadWriteActionNodes; return(dbNode); }
protected ActionNode GetActionNodeByNewCompositeWeight(int actionNodeNewCompositeWeight, DBNode dbNode) { var objList = from aNode in dbNode.Cast<ActionNode>() where aNode.CompositeWeightRangeStart <= actionNodeNewCompositeWeight && aNode.CompositeWeightRangeEnd >= actionNodeNewCompositeWeight select aNode; foreach (ActionNode aNode in dbNode) { if (aNode.CompositeWeightRangeStart <= actionNodeNewCompositeWeight && aNode.CompositeWeightRangeEnd >= actionNodeNewCompositeWeight) { ActionNode node = aNode; } } return objList.FirstOrDefault(); }