private static Metric ConvertToParsedMetric(GOPGMET.Metric metric, GENESTRT strt) { if (metric is GOPGMET.StringMetric str) { StringMetric parsed = new StringMetric(); parsed.Name = strt.Strings[str.NameIndex]; foreach (ushort index in str.ValueIndices) { parsed.Values.Add(strt.Strings[index]); } return(parsed); } else if (metric is GOPGMET.ReferenceMetric reference) { ReferenceMetric parsed = new ReferenceMetric(); parsed.Name = strt.Strings[reference.NameIndex]; foreach (GOPGMET.Metric referenced in reference.ReferencedMetrics) { parsed.ReferencedMetrics.Add(ConvertToParsedMetric(referenced, strt)); } return(parsed); } else { throw new Exception("Unknown raw metric type \"" + metric.GetType() + "\"."); } }
public ComparisionOutput CompareColumnValues(DataTable DataTable1, DataTable DataTable2, string RequestType = "immediate") { IStringMetric stringMetricObj = new StringMetric(); ComparisionOutput finalOutput = new ComparisionOutput(); List <DataTable> DataTableList = new List <DataTable>(); var TuppledOutput = DataTableRowEqualizer.EqualizeDatable(DataTable1, DataTable2); DataTable1 = TuppledOutput.Item1; DataTable2 = TuppledOutput.Item2; int IteratrionLength = DataTable1.Columns.Count > DataTable2.Columns.Count ? DataTable2.Columns.Count : DataTable1.Columns.Count; for (int i = 0; i < IteratrionLength; i++) { DataTable ColumnValue1 = new DataTable(); DataTable ColumnValue2 = new DataTable(); string Col1 = DataTable1.Columns[i].ColumnName.ToString(); string Col2 = DataTable2.Columns[i].ColumnName.ToString(); if (Col1 == Col2) { Col2 = Col2 + "_1"; } ColumnValue1.Columns.Add(Col1); ColumnValue2.Columns.Add(Col2); for (int j = 0; j < DataTable1.Rows.Count; j++) { ColumnValue1.Rows.Add(DataTable1.Rows[j][i].ToString()); ColumnValue2.Rows.Add(DataTable2.Rows[j][i].ToString()); } DataTable dataTableOutput = stringMetricObj.StringComparisonResult(ColumnValue1, ColumnValue2, "db", Col1, Col2, i + 1); if (i == 0) { finalOutput.RowSet = dataTableOutput.Copy(); } else { finalOutput.RowSet = MergeDataTable.MergeDataTables(finalOutput.RowSet, dataTableOutput); } } finalOutput.ColumnSet = finalOutput.RowSet.Columns.Cast <DataColumn>().Select(col => Convert.ToString(col)).ToList(); // if (RequestType == "immediate") // { // IntermediateCache<DataTable>.Current.Set("ComparisionOutputGrid", finalOutput.RowSet); // } return(finalOutput); }
private static Metric ReadMetric(Stream stream) { BinaryReader reader = new BinaryReader(stream); ushort nameIndex = reader.ReadUInt16(); ushort length = reader.ReadUInt16(); ushort knownType = 0; Metric metric = null; for (ushort i = 0; i < length; i++) { ushort type = reader.ReadUInt16(); ushort value = reader.ReadUInt16(); if (metric == null) { knownType = type; switch (type) { case 0: metric = new StringMetric(); break; case 1: metric = new ReferenceMetric(); break; default: throw new Exception("Unknown metric type " + type + "."); } metric.NameIndex = nameIndex; } else if (knownType != type) { throw new Exception("Encountered metric with mixed data types."); } switch (type) { case 0: ((StringMetric)metric).ValueIndices.Add(value); break; case 1: long pos = stream.Position; stream.Seek(value, SeekOrigin.Begin); Metric m = ReadMetric(stream); ((ReferenceMetric)metric).ReferencedMetrics.Add(m); stream.Seek(pos, SeekOrigin.Begin); break; default: throw new Exception("Unknown datum type \"" + type + "\"."); } } return(metric); }