예제 #1
0
        public static void ExportComparison(FHXCompareResultList results, string file)
        {
            using (var pkg = new ExcelPackage())
            {
                var wbk = pkg.Workbook;
                var sht = wbk.Worksheets.Add("Parameters");

                sht.Cells[1, 1].Value = "Key";
                sht.Cells[1, 2].Value = "Parent";
                sht.Cells[1, 3].Value = "Type";
                sht.Cells[1, 4].Value = "OldValue";
                sht.Cells[1, 5].Value = "NewValue";

                int i = 2;

                foreach (var k in results.Results.Keys)
                {
                    var r = results.Results[k];
                    sht.Cells[i, 1].Value = k;
                    sht.Cells[i, 2].Value = r.Parent;
                    sht.Cells[i, 3].Value = r.Type;
                    sht.Cells[i, 4].Value = r.OldValue;
                    sht.Cells[i, 5].Value = r.NewValue;
                    i++;
                }

                pkg.SaveAs(new FileInfo(file));
            }
        }
예제 #2
0
        public static FHXCompareResultList CompareObjects(FHXObject a, FHXObject b)
        {
            FHXCompareResultList res = new FHXCompareResultList();

            List <FHXParameter> psa = a.GetAllParameters();
            List <FHXParameter> psb = b.GetAllParameters();

            foreach (var pa in psa)
            {
                string rpath = pa.RelativePath(a);
                //Check if b contains the parameter
                if (psb.Any(i => i.RelativePath(b) == rpath))
                {
                    //If it contains it
                    //FHXParameter pb = psb.Single(i => i.RelativePath(b) == rpath);
                    FHXParameter pb = psb.Where(i => i.RelativePath(b) == rpath).ToArray()[0];
                    if (pa.Value != pb.Value)
                    {
                        res.Add(a, pa, FHXCompareType.DIFFERENT);
                        res.Add(b, pb, FHXCompareType.DIFFERENT);
                    }
                }
                else
                {
                    //If not
                    res.Add(a, pa, FHXCompareType.IN);
                }
            }

            foreach (var pb in psb)
            {
                string rpath = pb.RelativePath(b);
                //Check if b contains the parameter
                if (!psb.Any(i => i.RelativePath(b) == rpath))
                {
                    //If not
                    res.Add(b, pb, FHXCompareType.IN);
                }
            }

            return(res);
        }