public static string RepositoryFilename(this IAttachment Attachment, DiscoDataContext Database)
{
switch (Attachment.AttachmentType)
{
case AttachmentTypes.Device:
return Path.Combine(DataStore.CreateLocation(Database, "DeviceAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_file", Attachment.Reference, Attachment.Id));
case AttachmentTypes.Job:
return Path.Combine(DataStore.CreateLocation(Database, "JobAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_file", Attachment.Reference, Attachment.Id));
case AttachmentTypes.User:
return Path.Combine(DataStore.CreateLocation(Database, "UserAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_file", ((string)Attachment.Reference).Replace('\\', '_'), Attachment.Id));
default:
throw new ArgumentException("Unknown Attachment Type", nameof(Attachment));
}
}