private void ChangeHandler(object sender, FileSystemEventArgs e) { string relativePath = e.Name; //RAW Scans\20150705\C0001\006\090.jpg string fileName = Path.GetFileName(relativePath); string directoryPath = Path.GetDirectoryName(e.FullPath); //D:\Programs\Github\PhotoOrganizer\TestFolder\RAW Scans\20150705\C0001\006 //check if both front and back picture exist if (!((fileName == settings.FrontPictureName && File.Exists(directoryPath + "\\" + settings.BackPictureName)) || (fileName == settings.BackPictureName && File.Exists(directoryPath + "\\" + settings.FrontPictureName)))) { return; } string msg = string.Format("Locate new picture {0} and {1} in {2}", settings.BackPictureName, settings.FrontPictureName, directoryPath); log.LogInfo(msg); msgDispatcher.PopulateMessage(msg); //if folder hierarchy level string[] folderNames = Path.GetDirectoryName(relativePath).Split(new char[] { '\\', '/' }); if (folderNames.Length != visitors.Count) { return; } //check folder name against rules VisitorItem item = new VisitorItem(); item.CurrentDir = new DirectoryInfo(directoryPath); for (int i = 0; i < visitors.Count; i++) { if (!visitors[i].ValidateFolderName(folderNames[i])) { log.LogInfo(string.Format("Picture path {0} did not match rules, skipped", directoryPath)); return; } item.Info.Add(visitors[i].VisitorKey, folderNames[i]); } PhotoGroup group = CreatePhotoGroup(item); if (NewPhotoGoupHandler != null) { NewPhotoGoupHandler.Invoke(group); } }
private IList <PhotoGroup> FindNewPhotoGroups() { IList <PhotoGroup> photoGroups = new List <PhotoGroup>(); if (visitors.Count < 1) { return(photoGroups); } Queue <VisitorItem> children = new Queue <VisitorItem>(); VisitorItem start = new VisitorItem() { CurrentDir = new DirectoryInfo(settings.ScanBasePath), ActionVisitorLevel = 0 }; children.Enqueue(start); VisitorItem next; do { VisitorItem currentInfo = children.Dequeue(); IList <VisitorItem> dirs = visitors[currentInfo.ActionVisitorLevel].CollectValidDirectories(currentInfo); foreach (VisitorItem d in dirs) { children.Enqueue(d); } next = children.Peek(); } while (next != null && next.ActionVisitorLevel < visitors.Count && children.Count > 0); //todo move this code out of scanner foreach (VisitorItem picFolder in children) { PhotoGroup pg = CreatePhotoGroup(picFolder); if (pg != null) { photoGroups.Add(pg); } } return(photoGroups); }
public override void Initialize() { base.Initialize(); var list = new List <PhotoItem>(); for (var i = 5; i < 15; i++) { list.Add(new PhotoItem { PhotoUrl = $"https://kamusoft.jp/openimage/nativecell/{i + 1}.jpg", Title = $"Title {i + 1}", Category = "DDD", }); } _additionalGroup = new PhotoGroup(list) { Head = "SectionD" }; }
public void SetsTimestampsOnInsertTest() { var auditPropertyManager = new AuditPropertyManager(); // can use any EntityWithId var photoGroup = new PhotoGroup(); _dbContext.Add(photoGroup); var before = DateTimeOffset.Now; // TODO: see todo on interface IAuditPropertManager auditPropertyManager.SetTimestamps(_dbContext); var after = DateTimeOffset.Now; Assert.InRange(_dbContext.Entry(photoGroup).Property <DateTimeOffset>(Constants.InsertTimestampPropertyName).CurrentValue, before, after); Assert.InRange(_dbContext.Entry(photoGroup).Property <DateTimeOffset>(Constants.UpdateTimestampPropertyName).CurrentValue, before, after); Assert.Equal( _dbContext.Entry(photoGroup).Property <DateTimeOffset>(Constants.InsertTimestampPropertyName).CurrentValue, _dbContext.Entry(photoGroup).Property <DateTimeOffset>(Constants.UpdateTimestampPropertyName).CurrentValue); }