Example #1
0
        private bool FillRow(Document doc, DataRow r)
        {
            var isInserting = true;

            foreach (var attribute in doc.Attributes)
            {
                var vA = new ValidatedAttribute(attribute);
                if (attribute.ExternalEntity != "DPoW Attributes")
                {
                    continue;
                }

                // check for table columns
                var sName = attribute.Name;
                if (!AttributesGrid.Columns.Contains(sName))
                {
                    isInserting = false;
                    AttributesGrid.Columns.Add(new DataColumn(attribute.Name, typeof(ValidatedAttribute))
                    {
                        Namespace = attribute.PropertySetName
                    });
                }
                if (!isInserting || attribute.Value == null)
                {
                    continue;
                }

                r[sName] = vA;
            }
            if (!AttributesGrid.Columns.Contains("DPoW_Directory"))
            {
                AttributesGrid.Columns.Add(new DataColumn("DPoW_Directory", typeof(VisualValue)));
                AttributesGrid.Columns.Add(new DataColumn("DPoW_File", typeof(VisualValue)));
                return(false);
            }

            var status = doc.ValidationResult() == StatusOptions.Passed
                ? VisualAttentionStyle.Green
                : VisualAttentionStyle.Red;

            var vDir = new VisualValue(doc.Directory)
            {
                AttentionStyle = status
            };
            var vFile = new VisualValue(doc.File)
            {
                AttentionStyle = status
            };

            r["DPoW_Directory"] = vDir;
            r["DPoW_File"]      = vFile;
            return(isInserting);
        }
Example #2
0
        internal DataTable GetReport(string groupingAttributeName)
        {
            if (_documentsToReport == null || !_documentsToReport.Any())
                return null;
            var d = PrepareTable(groupingAttributeName);
            var dic = new Dictionary<string, List<Document>>();
            foreach (var document in _documentsToReport)
            {
                var attV = "";
                var firstAtt = document.Attributes.FirstOrDefault(att => att.Name == groupingAttributeName);
                if (firstAtt != null)
                {
                    var tmpV = firstAtt.Value.GetStringValue();
                    if (!string.IsNullOrEmpty(tmpV))
                        attV = tmpV;
                }
                if (!dic.ContainsKey(attV))
                {
                    dic.Add(attV, new List<Document> { document });
                }
                else
                {
                    dic[attV].Add(document);
                }
            }

            foreach (var key in dic.Keys)
            {
                var newrow = d.NewRow();
                newrow[GroupColName] = key;
                var iTot = 0;
                var iPass = 0;
                foreach (var doc in dic[key])
                {
                    iTot++;
                    if (doc.ValidationResult() == StatusOptions.Passed)
                    {
                        iPass++;
                    }
                }
                newrow[SubmittedColName] = iTot;

                var aStyle = VisualAttentionStyle.Green;
                if (iPass < iTot)
                    aStyle = VisualAttentionStyle.Red;
                if (iTot == 0)
                    aStyle = VisualAttentionStyle.Amber;
                // ReSharper disable once RedundantAssignment (reduces risk for future edits)
                newrow[ValidColName] = new VisualValue(iPass) { AttentionStyle = aStyle };
                d.Rows.Add(newrow);
            }
            return d;
        }
        private bool FillRow(Document doc, DataRow r)
        {
            var isInserting = true;
            foreach (var attribute in doc.Attributes)
            {
                var vA = new ValidatedAttribute(attribute);
                if (attribute.ExternalEntity != "DPoW Attributes")
                    continue;

                // check for table columns
                var sName = attribute.Name;
                if (!AttributesGrid.Columns.Contains(sName))
                {
                    isInserting = false;
                    AttributesGrid.Columns.Add(new DataColumn(attribute.Name, typeof(ValidatedAttribute))
                    {
                        Namespace = attribute.PropertySetName
                    });
                }
                if (!isInserting || attribute.Value == null)
                    continue;

                r[sName] = vA;
            }
            if (!AttributesGrid.Columns.Contains("DPoW_Directory"))
            {
                AttributesGrid.Columns.Add(new DataColumn("DPoW_Directory", typeof(VisualValue)));
                AttributesGrid.Columns.Add(new DataColumn("DPoW_File", typeof(VisualValue)));
                return false;
            }

            var status = doc.ValidationResult() == StatusOptions.Passed
                ? VisualAttentionStyle.Green
                : VisualAttentionStyle.Red;

            var vDir = new VisualValue(doc.Directory) {AttentionStyle = status};
            var vFile = new VisualValue(doc.File) { AttentionStyle = status };

            r["DPoW_Directory"] = vDir;
            r["DPoW_File"] = vFile;
            return isInserting;
        }
Example #4
0
        public DataTable GetReport(string mainClassification)
        {
            if (_validatedAssetTypes == null || !_validatedAssetTypes.Any())
            {
                return(null);
            }
            if (mainClassification == @"")
            {
                var firstRequirement = _validatedAssetTypes.FirstOrDefault();
                if (firstRequirement == null)
                {
                    return(null);
                }

                var firstClassification = firstRequirement.Categories.FirstOrDefault();
                if (firstClassification == null)
                {
                    return(null);
                }
                mainClassification = firstClassification.Classification;
            }

            var retTable = PrepareTable(mainClassification, _title);

            // the progressive variable allows grouping by Maincategory and MatchingCategory values
            //
            var progressive = new Dictionary <Tuple <string, string, bool>, ValidationSummary>();

            foreach (var reportingAsset in _validatedAssetTypes)
            {
                var mainCatCode = "";
                var mainCat     =
                    reportingAsset.GetRequirementCategories().FirstOrDefault(c => c.Classification == mainClassification);
                if (mainCat != null)
                {
                    mainCatCode = mainCat.Code;
                }

                var thisQuantities = new ValidationSummary
                {
                    Passes             = reportingAsset.GetValidChildrenCount(),
                    Total              = reportingAsset.GetSubmittedChildrenCount(),
                    MainCatDescription = mainCat != null
                        ? mainCat.Description
                        : ""
                };

                var matchingCat = reportingAsset.GetMatchingCategories().FirstOrDefault();
                // var sClass = (matchingCat != null) ? matchingCat.Classification : "";
                var matchCatValue = (matchingCat != null) ? matchingCat.Code : "";
                var passState     = false;
                if (reportingAsset.Categories != null)
                {
                    var vPassValue = reportingAsset.Categories.FirstOrDefault(c => c.Classification == "DPoW");
                    if (vPassValue != null && vPassValue.Code == "Passed")
                    {
                        passState = true;
                    }
                }


                var thiItem = new Tuple <string, string, bool>(mainCatCode, matchCatValue, passState);

                if (!progressive.ContainsKey(thiItem))
                {
                    progressive.Add(thiItem, thisQuantities);
                }
                else
                {
                    progressive[thiItem].Add(thisQuantities);
                }
            }

            var sortedKeys = progressive.Keys.ToList();

            sortedKeys.Sort(Comparison);

            // now populates the datatable.
            foreach (var sortedKey in sortedKeys)
            {
                var value   = progressive[sortedKey];
                int i       = 1;
                var thisRow = retTable.NewRow();

                thisRow[i++] = sortedKey.Item1;          // main classification
                thisRow[i++] = value.MainCatDescription; // main classification
                thisRow[i++] = sortedKey.Item2;
                thisRow[i++] = value.Total;

                bool pass = sortedKey.Item3;

                var aStyle = VisualAttentionStyle.Green;
                if (value.Passes < value.Total)
                {
                    aStyle = VisualAttentionStyle.Red;
                }
                if (value.Total == 0)
                {
                    // aStyle = VisualAttentionStyle.Amber;
                    if (!pass) // it's green by default.
                    {
                        aStyle = VisualAttentionStyle.Red;
                    }
                }

                // ReSharper disable once RedundantAssignment (reduces risk for future edits)
                thisRow[i++] = new VisualValue(value.Passes)
                {
                    AttentionStyle = aStyle
                };
                retTable.Rows.Add(thisRow);
            }
            return(retTable);
        }
Example #5
0
        internal DataTable GetReport(string groupingAttributeName)
        {
            if (_documentsToReport == null || !_documentsToReport.Any())
            {
                return(null);
            }
            var d   = PrepareTable(groupingAttributeName);
            var dic = new Dictionary <string, List <Document> >();

            foreach (var document in _documentsToReport)
            {
                var attV     = "";
                var firstAtt = document.Attributes.FirstOrDefault(att => att.Name == groupingAttributeName);
                if (firstAtt != null)
                {
                    var tmpV = firstAtt.Value.GetStringValue();
                    if (!string.IsNullOrEmpty(tmpV))
                    {
                        attV = tmpV;
                    }
                }
                if (!dic.ContainsKey(attV))
                {
                    dic.Add(attV, new List <Document> {
                        document
                    });
                }
                else
                {
                    dic[attV].Add(document);
                }
            }

            foreach (var key in dic.Keys)
            {
                var newrow = d.NewRow();
                newrow[GroupColName] = key;
                var iTot  = 0;
                var iPass = 0;
                foreach (var doc in dic[key])
                {
                    iTot++;
                    if (doc.ValidationResult() == StatusOptions.Passed)
                    {
                        iPass++;
                    }
                }
                newrow[SubmittedColName] = iTot;

                var aStyle = VisualAttentionStyle.Green;
                if (iPass < iTot)
                {
                    aStyle = VisualAttentionStyle.Red;
                }
                if (iTot == 0)
                {
                    aStyle = VisualAttentionStyle.Amber;
                }
                // ReSharper disable once RedundantAssignment (reduces risk for future edits)
                newrow[ValidColName] = new VisualValue(iPass)
                {
                    AttentionStyle = aStyle
                };
                d.Rows.Add(newrow);
            }
            return(d);
        }