Feature repricing min max (#10)

amazon settlement import/export improvements
This commit is contained in:
2020-05-01 09:08:23 +01:00
committed by GitHub
parent 56647c7648
commit 43d61c2ef8
118 changed files with 7930 additions and 3021 deletions

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Data
{
public class DatabaseFileStream : IDisposable, IValidatableObject
{
[Required()]
public Guid FileGUID { get; set; }
[Required()]
public MemoryStream FileData { get; set; }
public bool IsSetFileData
{
get { return FileData != null; }
}
[Required(), StringLength(3, MinimumLength = 3)]
public string FileExtention { get; set; }
[Required(), Range(1, 2147483647)]
public int FileSize { get; set; }
[Required(), StringLength(24, MinimumLength = 24)]
public string FileMD5base64 { get; set; }
public string CalculateContentMD5(MemoryStream stream)
{
MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
byte[] hash = provider.ComputeHash(stream);
return Convert.ToBase64String(hash);
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var resultList = new List<ValidationResult>();
if (IsSetFileData && FileData.Length == 0)
{
var validate = new ValidationResult("Stream is empty");
resultList.Add(validate);
}
if (IsSetFileData && FileMD5base64 != new Logic.Utilities.CalculateMD5().Base64(FileData))
{
var validate = new ValidationResult("Calculated file MD5 hash does not match.");
resultList.Add(validate);
}
return resultList;
}
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects).
if (FileData != null)
FileData.Dispose();
}
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
// TODO: set large fields to null.
disposedValue = true;
}
}
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
//~AmazonFeedSubmission()
//{
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
// Dispose(false);
//}
// This code added to correctly implement the disposable pattern.
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
// TODO: uncomment the following line if the finalizer is overridden above.
// GC.SuppressFinalize(this);
}
#endregion
}
}