Advertisement
nopcodex90

ApplyPaymentsLog

Dec 28th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.95 KB | None | 0 0
  1.  internal sealed class ApplyPayments : IDisposable
  2.     {
  3.         private ILogLib _lib = new ILogLib();
  4.         private readonly IList<IApplyPaymentsLog> _logs = new List<IApplyPaymentsLog>();
  5.  
  6.         private DateTime ProcessedDate { get; set; }
  7.  
  8.         private Guid PaymentBatchGuid { get; set; }
  9.  
  10.         private string ProcessedUser { get; set; }
  11.  
  12.         /// <summary>
  13.         /// Initializes a new instance of the <see cref="ApplyPayments"/> class.
  14.         /// </summary>
  15.         public ApplyPayments()
  16.         {
  17.            ProcessedDate = DateTime.Today;
  18.         }
  19.  
  20.         public ApplyPayments(Guid paymentBatchGuid, string processedUser)
  21.             : this()
  22.         {
  23.             PaymentBatchGuid = paymentBatchGuid;
  24.             ProcessedUser = processedUser;
  25.         }
  26.  
  27.         /// <summary>
  28.         /// Adds the log entry.
  29.         /// </summary>
  30.         /// <param name="paymentGuid">The payment unique identifier.</param>
  31.         /// <param name="policyGuid">The policy unique identifier.</param>
  32.         /// <param name="columnName">Name of the column.</param>
  33.         /// <param name="oldValue">The old value.</param>
  34.         /// <param name="newValue">The new value.</param>
  35.         /// <param name="valueType">Type of the value.</param>
  36.         public void AddLogEntry(Guid paymentGuid, Guid policyGuid, string columnName, string oldValue, string newValue, string
  37.             valueType)
  38.         {
  39.             _logs.Add(new ApplyPaymentsLog()
  40.             {
  41.                 GUID = Guid.NewGuid(),
  42.                 Batch_GUID = PaymentBatchGuid,
  43.                 Policy_GUID = policyGuid,
  44.                 ColumnName = columnName,
  45.                 OldValue = oldValue,
  46.                 NewValue = newValue,
  47.                 ValueType = valueType,
  48.                 ProcessedUser = ProcessedUser,
  49.                 ProcessedDate = ProcessedDate,
  50.                 Payment_GUID = paymentGuid
  51.             });
  52.         }
  53.  
  54.         /// <summary>
  55.         /// Adds the log entry.
  56.         /// </summary>
  57.         /// <param name="paymentGuid">The payment unique identifier.</param>
  58.         /// <param name="policyGuid">The policy unique identifier.</param>
  59.         /// <param name="columnName">Name of the column.</param>
  60.         /// <param name="oldValue">The old value.</param>
  61.         /// <param name="newValue">The new value.</param>
  62.         public void AddLogEntry(Guid paymentGuid, Guid policyGuid, string columnName, dynamic oldValue, dynamic newValue)
  63.         {
  64.             AddLogEntry(paymentGuid, policyGuid, columnName, oldValue.ToString(), newValue.ToString(CultureInfo.CurrentCulture),
  65.             oldValue.GetType().ToString());
  66.         }
  67.  
  68.         public void Sumbit()
  69.         {
  70.             _lib.BulkInsert(_logs);
  71.             _logs.Clear();
  72.         }
  73.  
  74.         public void Dispose()
  75.         {
  76.             if (_logs.Count <= 0)
  77.                 Sumbit();  
  78.             if (_lib != null)
  79.                 _lib.Dispose();
  80.         }
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement