Ejemplo n.º 1
0
        ItemUpdate GetItemUpdate(string directory, Item item, int index, int requestNumber)
        {
            try
            {
                if (Interlocked.CompareExchange(ref this.requestNumber, requestNumber, requestNumber) != requestNumber)
                {
                    return(null);
                }
                string version    = null;
                var    fullName   = Path.Combine(directory, item.Name);
                var    updateTime = default(DateTime);
                if (item.Extension.ToLower() == ".jpg")
                {
                    using (var er = new ExifReader(fullName))
                    {
                        DateTime exifTime;
                        if (er.GetTagValue <DateTime>(ExifReader.ExifTags.DateTimeOriginal, out exifTime))
                        {
                            updateTime = exifTime;
                        }
                    }
                }
                else
                {
                    version = FileVersion.Get(fullName);
                }

                if (!string.IsNullOrEmpty(version) || updateTime != default(DateTime))
                {
                    return(new ItemUpdate(index, version, updateTime));
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }