private static List<Reconciliation> ReadContents(ReconciliationFile rec) { var reconciliations = new List<Reconciliation>(); using (var stream = new StreamReader(new MemoryStream(rec.Contents), Encoding.Default)) { var str = stream.ReadLine(); while (str != null) { var flag = str.AsRecordType(); if (flag.ToUpper().Equals("D")) //Detail { var recDto = new Reconciliation { ReconciliationFileId = rec.Id, PaymentMethod = rec.FileType, PaymentCode = str.AsCustomerNoRef1(), PaymentDate = str.AsPaymentDateTime(), PaymentBy = str.AsCustomerName(), Amount = str.AsAmount() }; reconciliations.Add(recDto); } str = stream.ReadLine(); } } return reconciliations; }
private void ReadStream(ReconciliationFile rec) { var reconciliations = ReadContents(rec); if (reconciliations.Count > 0) { SaveReconcilation(reconciliations.ToArray()); ReconciliationFile.UpdateSuccessReconciliationFile(rec.Id); } }
private void CreditCard(ReconciliationFile rec) { var content = new StreamReader(new MemoryStream(rec.Contents)); DataSet ds = TextToDataSet.Convert(content); var recons = MapperReconciliation.CreateCreditCardToBBL(ds.Tables[0], rec.FileType, rec.Id); SaveReconcilation(recons); ReconciliationFile.UpdateSuccessReconciliationFile(rec.Id); }
public void Reader(ReconciliationFile rec) { if (rec.FileType == FileType.C.ToString()) { CreditCard(rec); } else if (rec.FileType == FileType.P.ToString()) { PayInSlip(rec); } }
public static void UpdateFailReconciliationFile(ReconciliationFile recon) { using (var container = new TransactionModelContainer()) { var val = container.ReconciliationFiles.FirstOrDefault(x => x.Id == recon.Id); val.IsValid = false; val.IsRead = true; val.FileType = TransactionModel.Utils.FileType.E.ToString(); val.BackupPath = recon.BackupPath; container.SaveChanges(); } }
private void UpdateFailReconciliationFile(ReconciliationFile rec) { var sourceFile = rec.BackupPath; var destinationFile = sourceFile.Replace("Success", "Err"); var parentPath = new DirectoryInfo(destinationFile).Parent.FullName; CreateDirectory(parentPath); File.Move(sourceFile, destinationFile); rec.BackupPath = destinationFile; ReconciliationFile.UpdateFailReconciliationFile(rec); }
private void BankType(ReconciliationFile rec) { var bankName = GetBank(rec.BackupPath); if (bankName == TransactionBanks.BBL.ToString()) { var bbl = new BBLProcessor(); bbl.Reader(rec); } else if (bankName == TransactionBanks.KBANK.ToString()) { var kbank = new KBankProcessor(); kbank.Reader(rec); } else if (bankName == TransactionBanks.SCB.ToString()) { var scb = new SCBProcessor(); scb.Reader(rec); } }
private void ReadContents(ReconciliationFile rec) { try { List<Reconciliation> reconciliations = new List<Reconciliation>(); string sourceFileName = rec.BackupPath; using (var stream = new StreamReader(new MemoryStream(rec.Contents), Encoding.Default)) { string str = stream.ReadLine(); while (str != null) { str = str.Substring(19); string flag = str.Substring(0, 1).ToUpper(); if (flag == "D") { //Line Item var value = MapperReconciliation.CreatePayInSlip(str, rec.Id); reconciliations.Add(value); } str = stream.ReadLine(); } if (reconciliations.Count() <= 0) { string msg = string.Format("Invalid PayInSlip Pattern - Id:{0} FullPath:{1}", rec.Id, rec.BackupPath); throw new Exception(msg); } SaveReconcilation(reconciliations.ToArray()); ReconciliationFile.UpdateSuccessReconciliationFile(rec.Id); } } catch (Exception ex) { throw ex; } }
private void PayInSlip(ReconciliationFile rec) { ReadStream(rec); }
private void CreditCard(ReconciliationFile rec) { throw new NotImplementedException("SCB_CAN_NOT_PAY_CREDIT_CARD"); }
public void TestCreateReconciliation() { using (var context = new TransactionModelContainer()) { ReconciliationFile reconcil = new ReconciliationFile("test", new byte[] { 1, 2 }, DateTime.Now, "system",null,true,null,false); context.ReconciliationFiles.AddObject(reconcil); context.SaveChanges(); } }
/// <summary> /// Create a new ReconciliationFile object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="fileName">Initial value of the FileName property.</param> /// <param name="contents">Initial value of the Contents property.</param> /// <param name="isValid">Initial value of the IsValid property.</param> /// <param name="version">Initial value of the Version property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> /// <param name="createBy">Initial value of the CreateBy property.</param> /// <param name="isRead">Initial value of the IsRead property.</param> /// <param name="fileType">Initial value of the FileType property.</param> public static ReconciliationFile CreateReconciliationFile(global::System.Int64 id, global::System.String fileName, global::System.Byte[] contents, global::System.Boolean isValid, global::System.Byte[] version, global::System.DateTime createDate, global::System.String createBy, global::System.Boolean isRead, global::System.String fileType) { ReconciliationFile reconciliationFile = new ReconciliationFile(); reconciliationFile.Id = id; reconciliationFile.FileName = fileName; reconciliationFile.Contents = contents; reconciliationFile.IsValid = isValid; reconciliationFile.Version = version; reconciliationFile.CreateDate = createDate; reconciliationFile.CreateBy = createBy; reconciliationFile.IsRead = isRead; reconciliationFile.FileType = fileType; return reconciliationFile; }
/// <summary> /// Deprecated Method for adding a new object to the ReconciliationFiles EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToReconciliationFiles(ReconciliationFile reconciliationFile) { base.AddObject("ReconciliationFiles", reconciliationFile); }
private void PayInSlip(ReconciliationFile rec) { ReadContents(rec); }