aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Program.cs
blob: 06c960e13b39c15fcdbc863b5d27fe2caf66a5cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL;
using Tango.BL.Entities;

namespace Tango.CctOptimizer.CLI
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ObservablesContext db = ObservablesContext.CreateDefault())
            {
                var notUsedCcts = db.Ccts.Where(x => x.Rmls.All(y=>y.Cct.FileName != x.FileName)).ToObservableCollection();
                
                foreach ( var cct in notUsedCcts)
                {
                    cct.DeleteCascadeAsync(db);
                }
                
                Dictionary <string, List<Cct>> duplicates = db.Ccts.Where(x => x.Rmls.All(y => y.Cct.FileName == x.FileName)).GroupBy(x => x.FileName).Where(x => x.Count() > 1).ToDictionary(g=>g.Key, g => g.ToList());
                foreach (var value in duplicates.Values)
                {
                    var res = db.Rmls.Where(x => value.All(y => y.Guid == x.CctGuid )).ToList();
                    
                }

                db.SaveChanges();

            }
        }
    }
}