public FlickrExtender VtCheckAuth() { var checkToken = AuthOAuthCheckToken(); // zkusim null dotazem zda jsem autentifikovan if ((checkToken != null) && (checkToken.User != null)) { Logger.Write(string.Format("Successfully authenticated as ({0}, {1}, {2}) with permissions '{3}'.", checkToken.User.FullName, // v t checkToken.User.UserId, // 12345678@N08 checkToken.User.UserName, // tncjklm checkToken.Permissions)); return(this); } return(null); }
static void Main(string[] args) { try { new FlickrNetExtender.Flup(Logger).Run(); } catch (Exception ex) { Logger.Write(ex); } Logger.Write("Finish."); if (System.Diagnostics.Debugger.IsAttached) { Console.ReadLine(); } }
/// <summary> /// Porovnanim (pres CRC) souboru z lokalniho disku a souboru z Flickeru dohleda nove soubory na lokalu /// /// + kvulu rychlosti rovnou dohledam i seznam souboru, ktere patri k Photo instancim, ktere j*z na Flickru jsou, ale nejsou zarazeny do Photoseto /// (coz obvykle nastane prerusenim prenosu mezi uploadem fotky a zarazeni do setu) /// </summary> /// <param name="sourcePaths">seznam zdrojovych adresaru ze soubory</param> /// <param name="flupFlickrPhotos">seznam FLUP souboru z Flickeru</param> /// <returns></returns> private void FindNewLocalFiles(Dictionary <DirectoryInfo, List <FileInfo> > sourcePaths, List <Photo> flupFlickrPhotos, List <Photo> photosWithoutSet, out List <PathWithFlickrFiles> newLocalFiles, out List <PathWithFlickrFiles> filesWithoutSet) { _logger.Write("Looking for new local files..."); var flupFlickrPhotosCrcSet = GetNumericCRC(flupFlickrPhotos); var photosWithoutSetCrcSet = GetNumericCRC(photosWithoutSet); var startTime = DateTime.Now; var filesTotal = sourcePaths.Sum(p => p.Value.Count); var filesProcessed = 0; var bytesTotal = sourcePaths.Sum(p => p.Value.Sum(f => f.Length)); var bytesProcessed = 0L; newLocalFiles = new List <PathWithFlickrFiles>(); filesWithoutSet = new List <PathWithFlickrFiles>(); foreach (var sourcePath in sourcePaths) { // ze souboru v directory zalozim set File4Flickr se spoctenym CRC - paralelne to je o dost rychlejsi var f4fSet = sourcePath.Value.AsParallel() .Select(fileInfo => new File4Flickr(fileInfo, _ini.SourcePath, _ini.NumberOfBytesForCRC).PrepareCrc()) .ToList(); var newInPath = new List <File4Flickr>(); var withoutSet = new List <File4Flickr>(); foreach (var f4f in f4fSet) { // uz existuje na flickru? (poznam pres tag FLUPCRCxxxxx u fotky) var crcExistsOnFlickr = flupFlickrPhotosCrcSet.Contains(f4f.Crc); if (crcExistsOnFlickr) { var withoutPhotoset = photosWithoutSetCrcSet.Contains(f4f.Crc); if (withoutPhotoset) { withoutSet.Add(f4f); // soubor/photo j*z na flickeru je, neni vsak v zadnem photosetu } } else { newInPath.Add(f4f); // jeste na flickru neexistuje } } // nejake nove soubory v adresari? if (newInPath.Any()) { var directoryWithPhotos = new PathWithFlickrFiles(sourcePath.Key, newInPath); newLocalFiles.Add(directoryWithPhotos); } // nejake soubory/photo bez photosetu? if (withoutSet.Any()) { var unassignedPhotos = new PathWithFlickrFiles(sourcePath.Key, withoutSet); filesWithoutSet.Add(unassignedPhotos); } bytesProcessed += f4fSet.Sum(p => p.Length); filesProcessed += f4fSet.Count; GetNewLocalFilesPrintProgress(startTime, filesTotal, filesProcessed, bytesTotal, bytesProcessed); } GetNewLocalFilesPrintFinalMessage(newLocalFiles); }