using System; using Ksat.Logging; using Ksat.Supplyment.Library.Uploader; using Ksat.Supplyment.Library.Model.Uploader; using S3Demo.Model.Uploader; namespace S3Demo.Uploader { public class S3UploadOperator : IUploaderOperator { //Log private ILogger sLog = LoggerFactory.ForContext(); public string ConvertCacheToRequest(string cache) { return cache; } public string ConvertRequestToCachel(string requestData) { return requestData; } public bool ShouldRetryRequest(UploadModel requestModel, out string cancelReason) { if (DateTime.Now.Subtract(requestModel.CreateAt).TotalSeconds > 600) { cancelReason = "exceed 600s"; return false; } if (requestModel.RetryCount > 5) { cancelReason = "exceed 5"; return false; } cancelReason = null; return true; } public bool ShouldStartRequest(UploadModel requestModel, out string cancelReason) { if (DateTime.Now.Subtract(requestModel.CreateAt).TotalSeconds > 600) { cancelReason = "exceed 600s"; return false; } if (requestModel.RetryCount > 5) { cancelReason = "exceed 5"; return false; } cancelReason = null; return true; } public IUploaderRequest UploadData(string data) { return new S3UploadRequest() { RequestData = data }; } } }