Example #1
0
        public async Task <Stream> GetDocumentVersionAsync(DocumentVersionEntity verEntity)
        {
            var stor     = _config.Stors.First(s => s.ShortName == verEntity.StorName).GetStorFromConfig();
            var fileName = verEntity.GetServerFileName();
            var stream   = await stor.GetFileAsync(fileName);

            return(stream);
        }
Example #2
0
        public async Task MoveDocumentVersion(DocumentVersionEntity verEntity, string newStorProvider)
        {
            try
            {
                IStor origStor = _config.Stors.First(s => s.ShortName == verEntity.StorName).GetStorFromConfig();
                IStor newStor  = _config.Stors.First(s => s.ShortName == newStorProvider).GetStorFromConfig();
                if (String.IsNullOrWhiteSpace(origStor.ShortName))
                {
                    throw new Exception("Unable to find old stor within config");
                }
                if (String.IsNullOrWhiteSpace(newStor.ShortName))
                {
                    throw new Exception("Unable to find new stor within config");
                }
                var    fileName = verEntity.GetServerFileName();
                string hash;
                using (var origStream = await origStor.GetFileAsync(fileName))
                {
                    await newStor.SetFileAsync(fileName, origStream);

                    hash = await newStor.GetFileHashAsync(fileName);

                    if (hash != verEntity.MD5Hash)
                    {
                        await newStor.RemoveFileAsync(fileName);

                        throw new Exception("File transfer failed MD5 hash is not equal");
                    }
                }
                await origStor.RemoveFileAsync(fileName);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to move document see inner exception", ex);
            }
        }
Example #3
0
 public async Task DeleteDocumentVersionAsync(DocumentVersionEntity verEntity)
 {
     IStor stor     = _config.Stors.First(s => s.ShortName == verEntity.StorName).GetStorFromConfig();
     var   fileName = verEntity.GetServerFileName();
     await stor.RemoveFileAsync(fileName);
 }