예제 #1
0
        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;
        }
예제 #2
0
        private void ReadStream(ReconciliationFile rec)
        {
            var reconciliations = ReadContents(rec);

            if (reconciliations.Count > 0)
            {
                SaveReconcilation(reconciliations.ToArray());
                ReconciliationFile.UpdateSuccessReconciliationFile(rec.Id);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
 public void Reader(ReconciliationFile rec)
 {
     if (rec.FileType == FileType.C.ToString())
     {
         CreditCard(rec);
     }
     else if (rec.FileType == FileType.P.ToString())
     {
         PayInSlip(rec);
     }
 }
예제 #5
0
        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();
            }
        }
예제 #6
0
        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();
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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;
            }
        }
예제 #10
0
 private void PayInSlip(ReconciliationFile rec)
 {
     ReadStream(rec);
 }
예제 #11
0
 private void CreditCard(ReconciliationFile rec)
 {
     throw new NotImplementedException("SCB_CAN_NOT_PAY_CREDIT_CARD");
 }
예제 #12
0
        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&lt;T&gt; property instead.
 /// </summary>
 public void AddToReconciliationFiles(ReconciliationFile reconciliationFile)
 {
     base.AddObject("ReconciliationFiles", reconciliationFile);
 }
예제 #15
0
 private void PayInSlip(ReconciliationFile rec)
 {
     ReadContents(rec);
 }