public override SyncEntry CreateSyncEntryForAdapterItem(IAdapterItem item, SyncEntry parentEntry) { AzureStorageAdapterItem adapterItem = (AzureStorageAdapterItem)item; SyncEntry entry = new SyncEntry { Name = item.Name, AdapterEntries = new List <SyncEntryAdapterData>(), CreationDateTimeUtc = adapterItem.CreationTimeUtc, ModifiedDateTimeUtc = adapterItem.ModifiedTimeUtc }; if (parentEntry != null) { entry.ParentEntry = parentEntry; entry.ParentId = parentEntry.Id; } entry.AdapterEntries.Add(new SyncEntryAdapterData() { AdapterId = this.Configuration.Id, SyncEntry = entry, AdapterEntryId = item.UniqueId }); if (adapterItem.ItemType == SyncAdapterItemType.File) { entry.Type = SyncEntryType.File; entry.SetSize(this.Relationship, SyncEntryPropertyLocation.Source, adapterItem.Size); // TODO Set MD5 hash? } else { entry.Type = SyncEntryType.Directory; } if (entry.Type == SyncEntryType.Undefined) { throw new Exception(string.Format("Unknown type for Item {0} ({1})", item.Name, item.UniqueId)); } // TODO: FIX THIS //if (this.Relationship.Configuration.SyncTimestamps) //{ // entry.CreationDateTimeUtc = info.CreationTimeUtc; // entry.ModifiedDateTimeUtc = info.LastWriteTimeUtc; //} entry.EntryLastUpdatedDateTimeUtc = DateTime.UtcNow; return(entry); }
private SyncEntry CreateEntry(FileSystemInfo info, SyncEntry parentEntry) { SyncEntry entry = new SyncEntry { CreationDateTimeUtc = info.CreationTimeUtc, ModifiedDateTimeUtc = info.LastWriteTimeUtc, Name = info.Name, AdapterEntries = new List <SyncEntryAdapterData>() }; if (parentEntry != null) { entry.AdapterEntries.Add( new SyncEntryAdapterData() { AdapterId = this.Configuration.Id, SyncEntry = entry, AdapterEntryId = GetItemId(info) }); entry.ParentEntry = parentEntry; entry.ParentId = parentEntry.Id; } FileInfo fileInfo = info as FileInfo; if (fileInfo != null) { entry.Type = SyncEntryType.File; entry.SetSize(this.Relationship, SyncEntryPropertyLocation.Source, fileInfo.Length); } DirectoryInfo directoryInfo = info as DirectoryInfo; if (directoryInfo != null) { entry.Type = SyncEntryType.Directory; } if (entry.Type == SyncEntryType.Undefined) { throw new Exception("Unknown type for FileSystemInfo " + info.FullName); } entry.EntryLastUpdatedDateTimeUtc = DateTime.UtcNow; return(entry); }
private SyncEntry CreateEntry(Item item, SyncEntry parent) { SyncEntry entry = new SyncEntry { CreationDateTimeUtc = item.CreatedDateTime.ToUniversalTime(), Name = item.Name, AdapterEntries = new List <SyncEntryAdapterData>() }; if (item.LastModifiedDateTime.HasValue) { entry.ModifiedDateTimeUtc = item.LastModifiedDateTime.Value; } if (parent != null) { entry.ParentEntry = parent; entry.ParentId = parent.Id; } entry.AdapterEntries.Add(new SyncEntryAdapterData() { AdapterId = this.Configuration.Id, SyncEntry = entry, AdapterEntryId = item.Id }); if (item.File != null) { entry.Type = SyncEntryType.File; entry.SetSize(this.Relationship, SyncEntryPropertyLocation.Source, item.Size); if (!string.IsNullOrWhiteSpace(item.File.Hashes?.Sha1Hash)) { entry.SetSha1Hash( this.Relationship, SyncEntryPropertyLocation.Source, HexToBytes(item.File.Hashes.Sha1Hash)); } } if (item.Folder != null) { entry.Type = SyncEntryType.Directory; } if (entry.Type == SyncEntryType.Undefined) { throw new Exception(string.Format("Unknown type for Item {0} ({1})", item.Name, item.Id)); } // TODO: FIX THIS //if (this.Relationship.Configuration.SyncTimestamps) //{ // entry.CreationDateTimeUtc = info.CreationTimeUtc; // entry.ModifiedDateTimeUtc = info.LastWriteTimeUtc; //} entry.EntryLastUpdatedDateTimeUtc = DateTime.UtcNow; return(entry); }