public void Select(SemWeb.StatementSink sink) { byte [] data = null; ImageDirectory props = Root.ReadDirectory(Tag.ImageProps); ImageDirectory camera = props.ReadDirectory(Tag.CameraObject); data = props.ReadEntry(Tag.TimeStamp); if (data != null) { MetadataStore.AddLiteral(sink, "xmp:CreateDate", new CaptureTime(data, little).ToString()); } data = props.ReadEntry(Tag.ImageSpec); if (data != null) { ImageSpec spec = new ImageSpec(data, little); MetadataStore.AddLiteral(sink, "tiff:Orientation", ((int)spec.Orientation).ToString()); MetadataStore.AddLiteral(sink, "tiff:ImageWidth", spec.ImageWidth.ToString()); MetadataStore.AddLiteral(sink, "tiff:ImageLength", spec.ImageHeight.ToString()); string comp = spec.ComponentBitDepth.ToString(); if (spec.IsColor) { MetadataStore.Add(sink, "tiff:BitsPerSample", "rdf:Seq", new string [] { comp, comp, comp }); } else { MetadataStore.Add(sink, "tiff:BitsPerSample", "rdf:Seq", new string [] { comp }); } if (!spec.HasSquarePixels) { MetadataStore.AddLiteral(sink, "tiff:XResolution", (1000000 * spec.PixelAspectRatio).ToString()); MetadataStore.AddLiteral(sink, "tiff:YResolution", (1000000 * (1 / spec.PixelAspectRatio)).ToString()); } } data = camera.ReadEntry(Tag.CanonRawMakeModel); if (data != null) { string make_model = System.Text.Encoding.ASCII.GetString(data, 0, data.Length - 1); string [] vals = make_model.Split(new char [] { '\0' }); MetadataStore.AddLiteral(sink, "tiff:Make", vals [0]); MetadataStore.AddLiteral(sink, "tiff:Model", vals [1]); } /* * // FIXME this doesn't appear to be ascii. * data = camera.ReadEntry (Tag.OwnerName); * if (data != null) { * string name = System.Text.Encoding.ASCII.GetString (data, 0, data.Length - 1); * MetadataStore.AddLiteral (sink, "dc:creator", "rdf:Seq", new SemWeb.Literal (name)); * } */ }
public void Select(StatementSink sink) { using (Stream stream = Open()) { Header header = new Header(stream); MetadataStore.AddLiteral(sink, "tiff:ImageWidth", header.Width.ToString()); MetadataStore.AddLiteral(sink, "tiff:ImageLength", header.Height.ToString()); string bits = header.IsDeep ? "16" : "8"; MetadataStore.Add(sink, "tiff:BitsPerSample", "rdf:Seq", new string [] { bits, bits, bits }); } }
public void SynchronizeLocalFileChange(string fullPath, FileChangeType changeType, string oldFullPath) { lock (this) { Logger.LogDebug("SynchronizeLocalFileChange Path={0} ChangeType={1} OldPath={2}", fullPath, changeType, oldFullPath); OnSyncProgress(0, ProgressStatus.Analyzing); try { var syncToRemote = (_configuration.Direction == SyncDirection.LocalToRemote || _configuration.Direction == SyncDirection.Both); var syncToLocal = _configuration.Direction == SyncDirection.RemoteToLocal || _configuration.Direction == SyncDirection.Both; if (!syncToRemote) { OnSyncProgress(100, ProgressStatus.Completed); return; } if (!_configuration.ShouldFileSync(fullPath)) { OnSyncProgress(100, ProgressStatus.Completed); return; } var localExtension = Path.GetExtension(fullPath); if (localExtension == ".spsync") { OnSyncProgress(100, ProgressStatus.Completed); return; } var isDirectory = false; if (changeType != FileChangeType.Deleted) { try { if (File.GetAttributes(fullPath).HasFlag(FileAttributes.Hidden)) { OnSyncProgress(100, ProgressStatus.Completed); return; } if (File.GetAttributes(fullPath).HasFlag(FileAttributes.Directory)) { isDirectory = true; } if (isDirectory) { if (Path.GetDirectoryName(fullPath) == MetadataStore.STOREFOLDER) { OnSyncProgress(100, ProgressStatus.Completed); return; } } else { if (Directory.GetParent(fullPath).Name == MetadataStore.STOREFOLDER) { OnSyncProgress(100, ProgressStatus.Completed); return; } } } catch { OnSyncProgress(100, ProgressStatus.Completed); return; } } MetadataItem item = null; if (string.IsNullOrEmpty(oldFullPath)) { item = _metadataStore.GetByFileName(fullPath); } else { item = _metadataStore.GetByFileName(oldFullPath); if (item == null) { changeType = FileChangeType.Changed; item = _metadataStore.GetByFileName(fullPath); } } if (item == null) { if (changeType != FileChangeType.Deleted) { if (_metadataStore.GetByFileName(fullPath) == null) { _metadataStore.Add(new MetadataItem(fullPath, isDirectory ? ItemType.Folder : ItemType.File)); } } } else { item.UpdateWithLocalInfo(_configuration.ConflictHandling, Guid.NewGuid()); if (item.Status == ItemStatus.Conflict) { item.Status = OnItemConflict(item); } if (changeType == FileChangeType.Renamed) { item.NewNameAfterRename = Path.GetFileName(fullPath); //works for directories as well item.Status = ItemStatus.RenamedLocal; if (isDirectory) { foreach (var itemInFolder in _metadataStore.Items.Where(p => p.LocalFile.Contains(item.LocalFile))) { if (itemInFolder.Id == item.Id) { continue; } itemInFolder.LocalFolder = itemInFolder.LocalFolder.Replace(item.LocalFile, fullPath); } } } } if (changeType == FileChangeType.Deleted && item != null) { item.Status = ItemStatus.DeletedLocal; } _metadataStore.Save(); SyncChanges(); OnSyncProgress(100, ProgressStatus.Completed); } catch (Exception ex) { //todo: if (_configuration.AuthenticationType == AuthenticationType.ADFS) //&& ex is webexception 403 { Adfs.AdfsHelper.InValidateCookie(); } OnSyncProgress(100, ProgressStatus.Error, "An error has occured: " + ex.Message, ex); return; } } }