private static List <Image> AssignLocalPathName(List <Image> listAll, string imageDownloadFolder, string imageScaleFolder, HashSet <string> folderFiles) { List <Image> listNew = new List <Image>(); string hashValue; string ext; string localFileName; foreach (Image myImage in listAll) { hashValue = HttpUrlHash.GetHashValueString(myImage.SourceUrl); ext = myImage.GetExtFromUrl(); localFileName = string.Format("{0}.jpg", hashValue); myImage.LocalImageName = string.Format("{0}\\{1}", imageScaleFolder, localFileName); localFileName = string.Format("{0}{1}", hashValue, ext); myImage.DownloadImageName = string.Format("{0}\\{1}", imageDownloadFolder, localFileName); if (!folderFiles.Contains(localFileName)) { listNew.Add(myImage); } } return(listNew); }
private Tuple <string, int, int> IngestImage(Tuple <List <Image>, int> tuple) { List <Image> list = tuple.Item1; int index = tuple.Item2; int partIngestedCount = 0; string tmpFile = string.Format("{0}.part{1}", workingFile, index); using (StreamWriter sw = new StreamWriter(tmpFile, true)) { string feed = string.Empty; List <IDataLoadResult> results = null; try { using (DataLoader loader = new DataLoader(OSContext.Instance.Configuration)) { for (int i = 0; i < list.Count; ++i) { Image myImage = list[i]; byte[] data = ScaledImageToBinary(myImage); string hashValue = HttpUrlHash.GetHashValueString(myImage.SourceUrl); results = ImageIngester.Ingest(hashValue, data, myImage, loader); partIngestedCount += LogIngestResults(results, sw); } loader.Flush(); results = loader.Receive(true); partIngestedCount += LogIngestResults(results, sw); } } catch (Exception ex) { ImageLogger.LogMessage(this.log, EventType.Error, "[ImageIngest][{0}][T{1}]: {2}", feed, index, ex.Message); ImageLogger.LogMessage(this.log, EventType.Error, ex.StackTrace); } } return(new Tuple <string, int, int>(tmpFile, partIngestedCount, index)); }