////just a flat list of all axis and members... //private Dictionary<string, bool> BuildDimensionElementsUsed( // List<MarkupProperty> validMarkups ) //{ // Dictionary<string, bool> ret = new Dictionary<string, bool>(); // foreach (MarkupProperty mp in validMarkups) // { // if (mp.contextRef == null) continue; // if (mp.contextRef.Segments != null && mp.contextRef.Segments.Count > 0) // { // List<string> eleDimMembers = new List<string>(); // StringBuilder dimVals = new StringBuilder(); // foreach (Segment seg in mp.contextRef.Segments) // { // if (seg.DimensionInfo == null) continue; // ret[seg.DimensionInfo.Id] = true; // ret[seg.DimensionInfo.dimensionId] = true; // } // } // } // return ret; //} private void RecursivelyCheckUniquenessOfParentChildArc(Node parent, Dictionary<string, bool> markedupElements, ref Dictionary<string, List<Node>> parentChildArcToRoleInfo, ref List<ValidationErrorInfo> secValidationErrors) { if (parent.IsProhibited) return; if (parent.children != null && parent.children.Count > 0) { foreach (Node child in parent.children) { if (child.IsProhibited) continue; if (markedupElements.ContainsKey(parent.Id) && markedupElements.ContainsKey(child.Id)) { string key = parent.Id + child.Id; List<Node> otherParentNodes; bool addParentNode = true; if (parentChildArcToRoleInfo.TryGetValue(key, out otherParentNodes)) { foreach (Node opn in otherParentNodes) { if (opn.GetPresentationLink().Role == parent.GetPresentationLink().Role) { //current parent already checked.... addParentNode = false; break; } Node GoodParent, badParent; if (IsInCompleteCalculation(opn, parent, markedupElements, out GoodParent, out badParent)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Calculation relationship between '{0}' and '{1}' is defined in report '{2}' and report '{3}'. Please remove this relationship from one of the reports to correct this problem.", parent.Label, child.Label, parent.GetPresentationLink().Title, opn.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Arc Error", ValidationErrorInfo.SequenceEnum.DUPLICATE_CALCULATION_ARC_ERROR); secValidationErrors.Add(info); } } } else { otherParentNodes = new List<Node>(); parentChildArcToRoleInfo[key] = otherParentNodes; } if (addParentNode) { otherParentNodes.Add(parent); } } RecursivelyCheckUniquenessOfParentChildArc(child, markedupElements, ref parentChildArcToRoleInfo, ref secValidationErrors); } } }
private void RecursivelyCheckPeriodTypeMismatch( Node currentNode, ref List<ValidationErrorInfo> secValidationErrors) { if (currentNode.IsProhibited) return; if (currentNode.children != null) { foreach (Node child in currentNode.children) { if (child.IsProhibited) continue; if (currentNode.PeriodType != child.PeriodType) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Calculation relationship between '{0}' and '{1}' in report {2} is not allowed as their period types are not the same.", currentNode.Label, child.Label, child.GetPresentationLink().Title, currentNode.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Arc Error", ValidationErrorInfo.SequenceEnum.CALCULATION_PERIOD_ERROR); secValidationErrors.Add(info); } else { RecursivelyCheckPeriodTypeMismatch(child, ref secValidationErrors); } } } }
private void RecursivelyCheckPeriodTypeOnParentChild(Node parent, ref List<ValidationErrorInfo> secValidationErrors) { if (parent.IsProhibited) return; if (parent.children != null) { List<string> childIds = new List<string>(); foreach (Node child in parent.children) { if (child.IsProhibited) continue; if (childIds.Contains(child.Id)) { //we cannot have the same child twice for a single parent ValidationErrorInfo info = new ValidationErrorInfo( string.Format("In the Calculation view of the Report '{0}' Element '{1}' appears more than once as the child of the element '{2}'. Please remove all duplicate occurances of the same child element.", parent.GetPresentationLink().Title, child.Label, parent.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Error", ValidationErrorInfo.SequenceEnum.DUPLICATE_IN_CALCULATION); secValidationErrors.Add(info); } else { childIds.Add(child.Id); } if (child.MyElement.PerType != parent.MyElement.PerType) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("In the Calculation view of the Report '{0}' period type of parent element '{1}' does not match the period type of child element '{2}'. Please correct this as the source and target of all calculation relationships must have the same period type.", parent.GetPresentationLink().Title, parent.Label, child.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Error", ValidationErrorInfo.SequenceEnum.CALCULATION_PARENT_CHILD_PERIOD_TYPE_MISMATCH); secValidationErrors.Add(info); } else { RecursivelyCheckPeriodTypeOnParentChild(child, ref secValidationErrors); } } } }
private void RecursivelyBuildChildrenForParent(Node parent, ref List<string> cns , ref List<ValidationErrorInfo> secValidationErrors) { if (parent.children == null) return; if (parent.IsProhibited) return; foreach (Node c in parent.children) { if (c.IsProhibited) continue; if (cns.Contains(c.MyElement.GetNameWithNamespacePrefix())) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("In Report '{0}' element '{1}' with Label '{2} is used multiple times in calculating a parent value. This might result in incorrect calculated values for the parent element.", parent.GetPresentationLink().Title, c.MyElement.GetNameWithNamespacePrefix(), c.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationWarning, "Calculation Warning", ValidationErrorInfo.SequenceEnum.CALCULATION_WARNING_POSSIBLE_APPALACHIAN_TREE); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } else { cns.Add(c.MyElement.GetNameWithNamespacePrefix()); RecursivelyBuildChildrenForParent(c, ref cns, ref secValidationErrors); } } }