Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal sealed class ApplyPayments : IDisposable
- {
- private ILogLib _lib = new ILogLib();
- private readonly IList<IApplyPaymentsLog> _logs = new List<IApplyPaymentsLog>();
- private DateTime ProcessedDate { get; set; }
- private Guid PaymentBatchGuid { get; set; }
- private string ProcessedUser { get; set; }
- /// <summary>
- /// Initializes a new instance of the <see cref="ApplyPayments"/> class.
- /// </summary>
- public ApplyPayments()
- {
- ProcessedDate = DateTime.Today;
- }
- public ApplyPayments(Guid paymentBatchGuid, string processedUser)
- : this()
- {
- PaymentBatchGuid = paymentBatchGuid;
- ProcessedUser = processedUser;
- }
- /// <summary>
- /// Adds the log entry.
- /// </summary>
- /// <param name="paymentGuid">The payment unique identifier.</param>
- /// <param name="policyGuid">The policy unique identifier.</param>
- /// <param name="columnName">Name of the column.</param>
- /// <param name="oldValue">The old value.</param>
- /// <param name="newValue">The new value.</param>
- /// <param name="valueType">Type of the value.</param>
- public void AddLogEntry(Guid paymentGuid, Guid policyGuid, string columnName, string oldValue, string newValue, string
- valueType)
- {
- _logs.Add(new ApplyPaymentsLog()
- {
- GUID = Guid.NewGuid(),
- Batch_GUID = PaymentBatchGuid,
- Policy_GUID = policyGuid,
- ColumnName = columnName,
- OldValue = oldValue,
- NewValue = newValue,
- ValueType = valueType,
- ProcessedUser = ProcessedUser,
- ProcessedDate = ProcessedDate,
- Payment_GUID = paymentGuid
- });
- }
- /// <summary>
- /// Adds the log entry.
- /// </summary>
- /// <param name="paymentGuid">The payment unique identifier.</param>
- /// <param name="policyGuid">The policy unique identifier.</param>
- /// <param name="columnName">Name of the column.</param>
- /// <param name="oldValue">The old value.</param>
- /// <param name="newValue">The new value.</param>
- public void AddLogEntry(Guid paymentGuid, Guid policyGuid, string columnName, dynamic oldValue, dynamic newValue)
- {
- AddLogEntry(paymentGuid, policyGuid, columnName, oldValue.ToString(), newValue.ToString(CultureInfo.CurrentCulture),
- oldValue.GetType().ToString());
- }
- public void Sumbit()
- {
- _lib.BulkInsert(_logs);
- _logs.Clear();
- }
- public void Dispose()
- {
- if (_logs.Count <= 0)
- Sumbit();
- if (_lib != null)
- _lib.Dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement