Пример #1
0
        public DualityFolders Clone()
        {
            var clone = new DualityFolders();

            clone.AddRange(this);
            return(clone);
        }
Пример #2
0
        public void UpdateFolders(DualityFolders dualityFolders)
        {
            var folders = dualityFolders.Where(x => x.MachineId.ToUpper() == ForMachine.ToUpper()).ToList();

            if (!folders.Any())
            {
                return;
            }
            DualityFolders.ForEach(x => x.Needed = false);
            var newFolders = new List <DualityFolder>();

            foreach (var folder in folders)
            {
                foreach (var subFolder in folder.TopSubFolders())
                {
                    var existingFolders = DualityFolders.Where(x => x.Folder == folder.Folder + subFolder && x.OtherFolder == folder.OtherFolder + subFolder).ToList();
                    if (existingFolders.Any())
                    {
                        existingFolders.ForEach(x => { x.Needed = true; x.CheckInterval = folder.CheckInterval; });
                    }
                    else
                    {
                        newFolders.Add(new DualityFolder {
                            Folder = folder.Folder + subFolder, OtherFolder = folder.OtherFolder + subFolder, Needed = true, LastCheckedAt = new DateTime(0), CheckInterval = folder.CheckInterval
                        });
                    }
                }
            }
            DualityFolders.Where(x => !x.Needed).ToList().ForEach(x => DualityFolders.Remove(x));
            DualityFolders.AddRange(newFolders);
        }