Esempio n. 1
0
        private static void UnidentifiedReceipts(List <Receipt> allReceipts)
        {
            IEnumerable <Receipt> unidentifiedReceipts = allReceipts.Where(x => x.PersonID == "0").ToList();

            using (var db = new ReceiptDBContext())
            {
                using (var tran = db.Database.BeginTransaction())
                {
                    try
                    {
                        foreach (var receipt in unidentifiedReceipts)
                        {
                            Batch b = db.Batches.FirstOrDefault(x => x.GlobalBatchID == receipt.GlobalBatchID);
                            b.DEStatus = 3;
                        }
                        db.SaveChanges();
                        tran.Commit();
                    }
                    catch
                    {
                        tran.Rollback();
                        throw;
                    }
                }
            }
        }
Esempio n. 2
0
        private static List <Receipt> GetReceiptList()
        {
            using (var db = new ReceiptDBContext())
            {
                db.Database.CommandTimeout = 1800;
                List <Receipt> receiptList = db.Database.SqlQuery <Receipt>("proc_Custom_ReceiptExport").ToList();

                return(receiptList);
            }
        }
Esempio n. 3
0
        private static void ProcessReceipts(List <Receipt> receipts, RecordType01 rec01, RecordType05[] rec05)
        {
            using (var db = new ReceiptDBContext())
            {
                using (var tran = db.Database.BeginTransaction())
                {
                    try
                    {
                        int i = 0;

                        #region Loop Receipts
                        foreach (Receipt receipt in receipts)
                        {
                            rec05[i] = LoadRec05(receipt);

                            if (rec05[i].RecordLine().Length == record05Length)
                            {
                                StubsDataEntry sde = db.StubsDataEntries.FirstOrDefault(x => x.GlobalStubID == receipt.GlobalStubID);

                                if (sde != null)
                                {
                                    sde.ExportedToCHARTSDate      = CurrentDate;
                                    sde.SDUTranID                 = rec05[i].SduTranId;
                                    sde.CHARTSStubPrefix          = rec05[i].SduTranId.Substring(0, 8);
                                    sde.ExportedAsUnidentified    = receipt.ExportedAsUnidentified == 1 ? receipt.ExportedAsUnidentified : (receipt.PersonID.Trim() == "0" ? (byte)1 : (byte)0);
                                    sde.ExportedToCHARTS          = 1;
                                    sde.ComplianceExemptionReason = GetComplianceExemptionReason(receipt);
                                    if (rec05[i].RetransmittalIndicator && rec05[i].PayorID != "AR00000000000")
                                    {
                                        sde.ResolvedDate = CurrentDate;
                                    }
                                }
                                else
                                {
                                    Log.WriteLine("Stub not found, not updated. GlobalStubID: " + receipt.GlobalStubID);
                                }

                                //update vertical and horizontal tables
                                //SqlParameter pGlobalStubID = new SqlParameter("globalStubID", receipt.GlobalStubID);
                                //db.Database.ExecuteSqlCommand("proc_Custom_ReceiptExport_UpdateStubDE @GlobalStubID", pGlobalStubID);

                                rec01.TotalAmount += rec05[i].Amount;

                                if (rec05[i].RetransmittalIndicator)
                                {
                                    rec01.RetransmittalRecordCount++;
                                    rec01.RetransmittalAmount += rec05[i].Amount;
                                }
                                else
                                {
                                    rec01.FirstTimeRecordCount++;
                                    rec01.FirstTimeAmount += rec05[i].Amount;
                                }

                                rec01.RecordCount++;  // records written to file count

                                if ((i != 0) && (i % 200) == 0)
                                {
                                    db.SaveChanges();
                                }
                            }
                            else
                            {
                                LogErrorColumns(rec05[i]);
                                badRecCount++;
                            }

                            i++; // total record count
                        }
                        #endregion

                        db.SaveChanges();

                        totalProcessedRecords = i;
                        RecordTotals(rec01);
                        WriteToReceiptFile(rec01, rec05);
                        tran.Commit();
                    }
                    catch
                    {
                        tran.Rollback();
                        throw;
                    }
                }
            }
        }