private static int? BatchProcessOakbrookChurch(CsvReader csv, DateTime date, int? fundid) { var cols = csv.GetFieldHeaders(); BundleHeader bh = null; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; while (csv.ReadNextRecord()) { if (csv[16] == "Credit") { if (bh != null) BatchImportContributions.FinishBundle(bh); bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now); continue; } if (bh == null) bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now); var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; string ck, rt, ac; rt = csv[11]; ac = csv[13]; ck = csv[14]; bd.Contribution.ContributionAmount = csv[15].GetAmount(); bd.Contribution.CheckNo = ck; var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } BatchImportContributions.FinishBundle(bh); return bh.BundleHeaderId; }
private static int? BatchProcessDiscoverCrosspoint(string text, DateTime date, int? fundid) { var prevdt = DateTime.MinValue; BundleHeader bh = null; var sr = new StringReader(text); for (; ; ) { var line = sr.ReadLine(); if (line == null) break; var csv = line.Split(','); var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; var dt = csv[2].ToDate().Value; if (dt != prevdt) { if (bh != null) BatchImportContributions.FinishBundle(bh); bh = BatchImportContributions.GetBundleHeader(dt, DateTime.Now); prevdt = dt; } bd.Contribution.ContributionAmount = csv[1].ToDecimal(); var ck = csv[3]; var rt = csv[4]; var ac = csv[0]; bd.Contribution.CheckNo = ck; var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } BatchImportContributions.FinishBundle(bh); return bh.BundleHeaderId; }
private static BundleDetail CreateContribution(DateTime date, int fundid) { var bd = new CmsData.BundleDetail { CreatedBy = Util.UserId, CreatedDate = Util.Now, }; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = Util.Now, ContributionDate = date, FundId = fundid, ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; return(bd); }
public static BundleDetail NewBundleDetail(CMSDataContext db, DateTime date, int fundid, string amount) { var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now }; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid, ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, ContributionAmount = amount.GetAmount() }; return(bd); }
public static BundleDetail NewBundleDetail(CMSDataContext db, DateTime date, int fundid, string amount, int?contributionTypeId) { var bd = new BundleDetail { CreatedBy = db.UserId, CreatedDate = DateTime.Now }; var value = amount.GetAmount(); bd.Contribution = new Contribution { CreatedBy = db.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid, ContributionStatusId = 0, ContributionTypeId = contributionTypeId.GetValueOrDefault(value > 0 ? ContributionTypeCode.CheckCash : ContributionTypeCode.Reversed), ContributionAmount = value }; return(bd); }
public static int? BatchProcessFbcStark(string text, DateTime date, int? fundid) { var prevdt = DateTime.MinValue; BundleHeader bh = null; var sr = new StringReader(text); for (; ; ) { var line = sr.ReadLine(); if (line == null) break; var csv = line.Split(','); var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; var dtint = csv[3].ToLong(); var y = (int)(dtint % 10000); var m = (int)(dtint / 1000000); var d = (int)(dtint / 10000) % 100; var dt = new DateTime(y, m, d); if (dt != prevdt) { if (bh != null) FinishBundle(bh); bh = GetBundleHeader(dt, DateTime.Now); prevdt = dt; } bd.Contribution.ContributionAmount = csv[5].GetAmount() / 100; string ck, rt, ac; ck = csv[4]; rt = csv[6]; ac = csv[7]; bd.Contribution.CheckNo = ck; var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } FinishBundle(bh); return bh.BundleHeaderId; }
private static int? BatchProcessRegions(CsvReader csv, DateTime date, int? fundid) { var prevbundle = -1; var curbundle = 0; var bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now); Regex re = new Regex( @"(?<g1>d(?<rt>.*?)d\sc(?<ac>.*?)(?:c|\s)(?<ck>.*?))$ |(?<g2>d(?<rt>.*?)d(?<ck>.*?)(?:c|\s)(?<ac>.*?)c[\s!]*)$ |(?<g3>d(?<rt>.*?)d(?<ac>.*?)c(?<ck>.*?$)) |(?<g4>c(?<ck>.*?)c\s*d(?<rt>.*?)d(?<ac>.*?)c\s*$) ", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); int fieldCount = csv.FieldCount; var cols = csv.GetFieldHeaders(); while (csv.ReadNextRecord()) { if (!csv[12].Contains("Check")) continue; var bd = new CmsData.BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; string ac = null, rt = null; for (var c = 1; c < fieldCount; c++) { switch (cols[c].ToLower()) { case "deposit number": curbundle = csv[c].ToInt(); if (curbundle != prevbundle) { if (curbundle == 3143) { foreach (var i in bh.BundleDetails) { Debug.WriteLine(i.Contribution.ContributionDesc); Debug.WriteLine(i.Contribution.BankAccount); } } BatchImportContributions.FinishBundle(bh); bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now); prevbundle = curbundle; } break; case "post amount": bd.Contribution.ContributionAmount = csv[c].GetAmount(); break; // break; case "micr": var m = re.Match(csv[c]); rt = m.Groups["rt"].Value; ac = m.Groups["ac"].Value; bd.Contribution.CheckNo = m.Groups["ck"].Value.Truncate(20); break; } } var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } BatchImportContributions.FinishBundle(bh); return bh.BundleHeaderId; }
public object PostContribution(PostBundleController ctl) { try { var bd = new BundleDetail { BundleHeaderId = id, CreatedBy = Util.UserId, CreatedDate = DateTime.Now }; int type; switch (PLNT) { case "PL": type = ContributionTypeCode.Pledge; break; case "NT": type = ContributionTypeCode.NonTaxDed; break; case "GK": type = ContributionTypeCode.GiftInKind; break; case "SK": type = ContributionTypeCode.Stock; break; default: type = ContributionTypeCode.CheckCash; break; } decimal? othersplitamt = null; if (splitfrom > 0) { var q = from c in DbUtil.Db.Contributions where c.ContributionId == splitfrom select new { c, bd = c.BundleDetails.First() }; var i = q.Single(); othersplitamt = i.c.ContributionAmount - amt; i.c.ContributionAmount = othersplitamt; DbUtil.Db.SubmitChanges(); bd.BundleSort1 = i.bd.BundleDetailId; } bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = bd.CreatedDate, FundId = fund, PeopleId = pid.ToInt2(), ContributionDate = contributiondate ?? bundle.ContributionDate, ContributionAmount = amt, ContributionStatusId = 0, ContributionTypeId = type, ContributionDesc = notes, CheckNo = (checkno ?? "").Trim().Truncate(20) }; bundle.BundleDetails.Add(bd); DbUtil.Db.SubmitChanges(); return ContributionRowData(ctl, bd.ContributionId, othersplitamt); } catch (Exception ex) { return new {error = ex.Message}; } }
public object PostContribution(PostBundleController ctl) { try { var bd = new CmsData.BundleDetail { BundleHeaderId = id, CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; int type; switch (PLNT) { case "PL": type = ContributionTypeCode.Pledge; break; case "NT": type = ContributionTypeCode.NonTaxDed; break; case "GK": type = ContributionTypeCode.GiftInKind; break; case "SK": type = ContributionTypeCode.Stock; break; default: type = ContributionTypeCode.CheckCash; break; } decimal?othersplitamt = null; if (splitfrom > 0) { var q = from c in DbUtil.Db.Contributions where c.ContributionId == splitfrom select new { c, bd = c.BundleDetails.First(), }; var i = q.Single(); othersplitamt = i.c.ContributionAmount - amt; i.c.ContributionAmount = othersplitamt; DbUtil.Db.SubmitChanges(); bd.BundleSort1 = i.bd.BundleDetailId; } bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = bd.CreatedDate, FundId = fund, PeopleId = pid.ToInt2(), ContributionDate = contributiondate ?? bundle.ContributionDate, ContributionAmount = amt, ContributionStatusId = 0, ContributionTypeId = type, ContributionDesc = notes, CheckNo = checkno }; bundle.BundleDetails.Add(bd); DbUtil.Db.SubmitChanges(); return(ContributionRowData(ctl, bd.ContributionId, othersplitamt)); } catch (Exception ex) { return(new { error = ex.Message }); } }
private static BundleDetail CreateContribution(DateTime date, int fundid) { var bd = new CmsData.BundleDetail { CreatedBy = Util.UserId, CreatedDate = Util.Now, }; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = Util.Now, ContributionDate = date, FundId = fundid, ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; return bd; }
public Contribution PostUnattendedContribution(CMSDataContext Db, decimal Amt, int? Fund, string Description, bool pledge = false, int? typecode = null, int? tranid = null) { if (!typecode.HasValue) { typecode = BundleTypeCode.Online; if (pledge) typecode = BundleTypeCode.OnlinePledge; } var now = Util.Now; var d = now.Date; BundleHeader bundle = null; var spec = Db.Setting("OnlineContributionBundleDayTime", ""); if (Util.HasValue(spec)) { var a = spec.SplitStr(" ", 2); try { var next = DateTime.Parse(now.ToShortDateString() + " " + a[1]); var dow = Enum.Parse(typeof(DayOfWeek), a[0], ignoreCase: true); next = next.Sunday().Add(next.TimeOfDay).AddDays(dow.ToInt()); if(now > next) next = next.AddDays(7); var prev = next.AddDays(-7); var bid = BundleTypeCode.MissionTrip == typecode ? Db.GetCurrentMissionTripBundle(next, prev) : Db.GetCurrentOnlineBundle(next, prev); bundle = Db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid); } catch (Exception) { spec = ""; } } if(!Util.HasValue(spec)) { var nextd = d.AddDays(1); var bid = BundleTypeCode.MissionTrip == typecode ? Db.GetCurrentMissionTripBundle(nextd, d) : Db.GetCurrentOnlineBundle(nextd, d); bundle = Db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid); } if (bundle == null) { bundle = new BundleHeader { BundleHeaderTypeId = typecode.Value, BundleStatusId = BundleStatusCode.Open, CreatedBy = Util.UserId1, ContributionDate = d, CreatedDate = now, FundId = Db.Setting("DefaultFundId", "1").ToInt(), RecordStatus = false, TotalCash = 0, TotalChecks = 0, TotalEnvelopes = 0, BundleTotal = 0 }; Db.BundleHeaders.InsertOnSubmit(bundle); } if (!Fund.HasValue) Fund = Db.Setting("DefaultFundId", "1").ToInt(); var fundtouse = (from f in Db.ContributionFunds where f.FundId == Fund select f).SingleOrDefault(); //failsafe if fund is not found if(fundtouse == null) Fund = (from f in Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId).First(); var FinanceManagerId = Db.Setting("FinanceManagerId", "").ToInt2(); if (!FinanceManagerId.HasValue) { var qu = from u in Db.Users where u.UserRoles.Any(ur => ur.Role.RoleName == "Finance") orderby u.Person.LastName select u.UserId; FinanceManagerId = qu.FirstOrDefault(); if (!FinanceManagerId.HasValue) FinanceManagerId = 1; } var bd = new BundleDetail { BundleHeaderId = bundle.BundleHeaderId, CreatedBy = FinanceManagerId.Value, CreatedDate = now, }; var typid = ContributionTypeCode.CheckCash; if (pledge) typid = ContributionTypeCode.Pledge; bd.Contribution = new Contribution { CreatedBy = FinanceManagerId.Value, CreatedDate = bd.CreatedDate, FundId = Fund.Value, PeopleId = PeopleId, ContributionDate = bd.CreatedDate, ContributionAmount = Amt, ContributionStatusId = 0, ContributionTypeId = typid, ContributionDesc = Description, TranId = tranid, Source = Util2.FromMobile.HasValue() ? 1 : (int?)null }; bundle.BundleDetails.Add(bd); Db.SubmitChanges(); if(fundtouse == null) Db.LogActivity($"FundNotFound Used fund #{Fund} on contribution #{bd.ContributionId}"); return bd.Contribution; }
private static BundleDetail AddContributionDetail(DateTime date, int fundid, string amount, string checkno, string routing, string account) { var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid, ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; bd.Contribution.ContributionAmount = amount.GetAmount(); bd.Contribution.CheckNo = checkno; var eac = Util.Encrypt(routing + "|" + account); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; return bd; }
private void detach_BundleDetails(BundleDetail entity) { this.SendPropertyChanging(); entity.Contribution = null; }
private static int? BatchProcessMagTek(string lines, DateTime date) { var now = DateTime.Now; var bh = new BundleHeader { BundleHeaderTypeId = BundleTypeCode.ChecksAndCash, BundleStatusId = BundleStatusCode.Open, ContributionDate = date, CreatedBy = Util.UserId, CreatedDate = now, FundId = DbUtil.Db.Setting("DefaultFundId", "1").ToInt() }; DbUtil.Db.BundleHeaders.InsertOnSubmit(bh); var re = new Regex( @"(T(?<rt>[\d?]+)T(?<ac>[\d ?]*)U\s*(?<ck>[\d?]+))| (CT(?<rt>[\d?]+)A(?<ac>[\d ?]*)C(?<ck>[\d?]+)M)", RegexOptions.IgnoreCase); var m = re.Match(lines); while (m.Success) { var rt = m.Groups["rt"].Value; var ac = m.Groups["ac"].Value; var ck = m.Groups["ck"].Value; var bd = new CmsData.BundleDetail { CreatedBy = Util.UserId, CreatedDate = now, }; bh.BundleDetails.Add(bd); var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = now, ContributionDate = date, FundId = qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; bd.Contribution.ContributionDesc = ck; var eac = Util.Encrypt(rt + "," + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bd.Contribution.ContributionDesc = ck; m = m.NextMatch(); } bh.TotalChecks = 0; bh.TotalCash = 0; bh.TotalEnvelopes = 0; DbUtil.Db.SubmitChanges(); return bh.BundleHeaderId; }
private void detach_BundleDetails(BundleDetail entity) { this.SendPropertyChanging(); entity.BundleHeader = null; }
private static int?BatchProcessMagTek(string lines, DateTime date) { var now = DateTime.Now; var bh = new BundleHeader { BundleHeaderTypeId = BundleTypeCode.ChecksAndCash, BundleStatusId = BundleStatusCode.Open, ContributionDate = date, CreatedBy = Util.UserId, CreatedDate = now, FundId = DbUtil.Db.Setting("DefaultFundId", "1").ToInt() }; DbUtil.Db.BundleHeaders.InsertOnSubmit(bh); var re = new Regex( @"(T(?<rt>[\d?]+)T(?<ac>[\d ?]*)U\s*(?<ck>[\d?]+))| (CT(?<rt>[\d?]+)A(?<ac>[\d ?]*)C(?<ck>[\d?]+)M)", RegexOptions.IgnoreCase); var m = re.Match(lines); while (m.Success) { var rt = m.Groups["rt"].Value; var ac = m.Groups["ac"].Value; var ck = m.Groups["ck"].Value; var bd = new CmsData.BundleDetail { CreatedBy = Util.UserId, CreatedDate = now, }; bh.BundleDetails.Add(bd); var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = now, ContributionDate = date, FundId = qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; bd.Contribution.ContributionDesc = ck; var eac = Util.Encrypt(rt + "," + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) { bd.Contribution.PeopleId = pid; } bd.Contribution.BankAccount = eac; bd.Contribution.ContributionDesc = ck; m = m.NextMatch(); } bh.TotalChecks = 0; bh.TotalCash = 0; bh.TotalEnvelopes = 0; DbUtil.Db.SubmitChanges(); return(bh.BundleHeaderId); }
public static int?BatchProcessSunTrust(CsvReader csv, DateTime date, int?fundid) { var prevbundle = -1; var curbundle = 0; var bh = GetBundleHeader(date, DateTime.Now); int fieldCount = csv.FieldCount; var cols = csv.GetFieldHeaders(); while (csv.ReadNextRecord()) { var bd = new CmsData.BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; string ac = null, rt = null, ck = null, sn = null; for (var c = 1; c < fieldCount; c++) { switch (cols[c].ToLower()) { case "deposit_id": curbundle = csv[c].ToInt(); if (curbundle != prevbundle) { if (curbundle == 3143) { foreach (var i in bh.BundleDetails) { Debug.WriteLine(i.Contribution.ContributionDesc); Debug.WriteLine(i.Contribution.BankAccount); } } FinishBundle(bh); bh = GetBundleHeader(date, DateTime.Now); prevbundle = curbundle; } break; case "amount": bd.Contribution.ContributionAmount = csv[c].GetAmount(); break; case "tran_code": ck = csv[c]; break; case "serial_number": sn = csv[c]; break; case "routing_transit": rt = csv[c]; break; case "account_number": ac = csv[c]; break; } } if (!ck.HasValue()) { if (ac.Contains(' ')) { var a = ac.SplitStr(" ", 2); ck = a[0]; ac = a[1]; } } bd.Contribution.ContributionDesc = string.Join(" ", sn, ck); var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) { bd.Contribution.PeopleId = pid; } bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } FinishBundle(bh); return(bh.BundleHeaderId); }
private static int?BatchProcessRegions(CsvReader csv, DateTime date, int?fundid) { var db = DbUtil.Db; var userId = db.UserId; var prevbundle = -1; var curbundle = 0; var bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now); Regex re = new Regex( @"(?<g1>d(?<rt>.*?)d\sc(?<ac>.*?)(?:c|\s)(?<ck>.*?))$ |(?<g2>d(?<rt>.*?)d(?<ck>.*?)(?:c|\s)(?<ac>.*?)c[\s!]*)$ |(?<g3>d(?<rt>.*?)d(?<ac>.*?)c(?<ck>.*?$)) |(?<g4>c(?<ck>.*?)c\s*d(?<rt>.*?)d(?<ac>.*?)c\s*$) " , RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); int fieldCount = csv.FieldCount; var cols = csv.GetFieldHeaders(); while (csv.ReadNextRecord()) { if (!csv[12].Contains("Check")) { continue; } var bd = new CmsData.BundleDetail { CreatedBy = userId, CreatedDate = DateTime.Now, }; var qf = from f in db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = userId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; string ac = null, rt = null; for (var c = 1; c < fieldCount; c++) { switch (cols[c].ToLower()) { case "deposit number": curbundle = csv[c].ToInt(); if (prevbundle == -1) { prevbundle = curbundle; } if (curbundle != prevbundle) { if (curbundle == 3143) { foreach (var i in bh.BundleDetails) { Debug.WriteLine(i.Contribution.ContributionDesc); Debug.WriteLine(i.Contribution.BankAccount); } } BatchImportContributions.FinishBundle(bh); bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now); prevbundle = curbundle; } break; case "post amount": bd.Contribution.ContributionAmount = csv[c].GetAmount(); break; case "micr": var m = re.Match(csv[c]); rt = m.Groups["rt"].Value; ac = m.Groups["ac"].Value; bd.Contribution.CheckNo = m.Groups["ck"].Value.Truncate(20); break; } } var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) { bd.Contribution.PeopleId = pid; } bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } BatchImportContributions.FinishBundle(bh); return(bh.BundleHeaderId); }
public static int? BatchProcessFbcStark2(string text, DateTime date, int? fundid) { var prevdt = DateTime.MinValue; BundleHeader bh = null; var sr = new StringReader(text); string line = ""; do { line = sr.ReadLine(); if (line == null) return null; } while (!line.StartsWith("Batch ID")); var sep = ','; if (line.StartsWith("Batch ID\t")) sep = '\t'; for (; ; ) { line = sr.ReadLine(); if (line == null) break; var csv = line.Split(sep); var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; var s = csv[3]; var m = s.Substring(0, 2).ToInt(); var d = s.Substring(2, 2).ToInt(); var y = s.Substring(4, 2).ToInt() + 2000; var dt = new DateTime(y, m, d); if (dt != prevdt) { if (bh != null) FinishBundle(bh); bh = GetBundleHeader(dt, DateTime.Now); prevdt = dt; } string ck, rt, ac; rt = csv[7]; ac = csv[8]; ck = csv[9]; bd.Contribution.ContributionAmount = csv[10].GetAmount(); bd.Contribution.CheckNo = ck; var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } FinishBundle(bh); return bh.BundleHeaderId; }
public static int? RunImport(CsvReader csv, DateTime date, int? fundid) { var prevbundle = -1; var curbundle = 0; BundleHeader bh = null; var fieldCount = csv.FieldCount; var cols = csv.GetFieldHeaders(); while (csv.ReadNextRecord()) { var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now }; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash }; string ac = null, rt = null, ck = null; for (var c = 1; c < fieldCount; c++) { switch (cols[c]) { case "DEPOSIT NUMBER": curbundle = csv[c].ToInt(); if (curbundle != prevbundle) { if(bh != null) BatchImportContributions.FinishBundle(bh); bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now); prevbundle = curbundle; } break; case "AMOUNT": bd.Contribution.ContributionAmount = csv[c].GetAmount(); break; case "CHECK NUMBER": ck = csv[c]; break; case "ROUTING NUMBER": rt = csv[c]; break; case "ACCOUNT NUMBER": ac = csv[c]; break; } } if (!ck.HasValue()) { if (ac.Contains(' ')) { var a = ac.SplitStr(" ", 2); ck = a[0]; ac = a[1]; } } var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bd.Contribution.CheckNo = ck; bh.BundleDetails.Add(bd); } BatchImportContributions.FinishBundle(bh); return bh.BundleHeaderId; }
public static int? BatchProcessSunTrust(CsvReader csv, DateTime date, int? fundid) { var prevbundle = -1; var curbundle = 0; var bh = GetBundleHeader(date, DateTime.Now); int fieldCount = csv.FieldCount; var cols = csv.GetFieldHeaders(); while (csv.ReadNextRecord()) { var bd = new CmsData.BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; string ac = null, rt = null, ck = null, sn = null; for (var c = 1; c < fieldCount; c++) { switch (cols[c].ToLower()) { case "deposit_id": curbundle = csv[c].ToInt(); if (curbundle != prevbundle) { if (curbundle == 3143) { foreach (var i in bh.BundleDetails) { Debug.WriteLine(i.Contribution.ContributionDesc); Debug.WriteLine(i.Contribution.BankAccount); } } FinishBundle(bh); bh = GetBundleHeader(date, DateTime.Now); prevbundle = curbundle; } break; case "amount": bd.Contribution.ContributionAmount = csv[c].GetAmount(); break; case "tran_code": ck = csv[c]; break; case "serial_number": sn = csv[c]; break; case "routing_transit": rt = csv[c]; break; case "account_number": ac = csv[c]; break; } } if (!ck.HasValue()) if (ac.Contains(' ')) { var a = ac.SplitStr(" ", 2); ck = a[0]; ac = a[1]; } bd.Contribution.ContributionDesc = string.Join(" ", sn, ck); var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } FinishBundle(bh); return bh.BundleHeaderId; }
private static BundleDetail AddContributionDetail(DateTime date, int fundid, string amount, string checkno, string routing, int peopleid) { var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid, ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; bd.Contribution.ContributionAmount = amount.GetAmount(); bd.Contribution.CheckNo = checkno; bd.Contribution.PeopleId = peopleid; return bd; }
private static int? BatchProcessBankOfNorthGeorgia(string text, DateTime date, int? fundid) { BundleHeader bh = null; var sr = new StringReader(text); var line = ""; do { line = sr.ReadLine(); if (line == null) return null; } while (!line.Contains("Item ID")); var sep = ','; if (line.Contains("Item ID\t")) sep = '\t'; for (; ; ) { line = sr.ReadLine(); if (line == null) break; line = line.TrimStart(); var csv = line.Split(sep); if (!csv[6].HasValue()) continue; if (csv[21] == "VDP") { if (bh != null) BatchImportContributions.FinishBundle(bh); bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now); continue; } var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, }; var qf = from f in DbUtil.Db.ContributionFunds where f.FundStatusId == 1 orderby f.FundId select f.FundId; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid ?? qf.First(), ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, }; var rt = csv[14]; var ac = csv[20]; var ck = csv[17]; bd.Contribution.ContributionAmount = csv[9].GetAmount(); bd.Contribution.CheckNo = ck; var eac = Util.Encrypt(rt + "|" + ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); if (pid != null) bd.Contribution.PeopleId = pid; bd.Contribution.BankAccount = eac; bh.BundleDetails.Add(bd); } BatchImportContributions.FinishBundle(bh); return bh.BundleHeaderId; }
internal static BundleDetail NewBundleDetail(DateTime date, int fundid, string amount) { var bd = new BundleDetail { CreatedBy = Util.UserId, CreatedDate = DateTime.Now }; bd.Contribution = new Contribution { CreatedBy = Util.UserId, CreatedDate = DateTime.Now, ContributionDate = date, FundId = fundid, ContributionStatusId = 0, ContributionTypeId = ContributionTypeCode.CheckCash, ContributionAmount = amount.GetAmount() }; return bd; }
public static int?BatchProcessServiceU(CsvReader csv, DateTime date) { var cols = csv.GetFieldHeaders(); var now = DateTime.Now; var bh = GetBundleHeader(date, now); while (csv.ReadNextRecord()) { string ac = null, oth = null, first = null, last = null, addr = null, name = null, email = null; var dt = date; for (var c = 1; c < csv.FieldCount; c++) { var col = cols[c].Trim(); switch (col) { case "Date Entered": dt = csv[c].ToDate() ?? date; break; case "ProfileID": ac = csv[c]; break; case "First Name": first = csv[c]; break; case "Last Name": last = csv[c]; break; case "Full Name": name = csv[c]; break; case "Address": addr = csv[c]; break; case "Email Address": email = csv[c]; break; case "Designation for "Other"": oth = csv[c]; break; } } if (ac.ToInt() == 0) { ac = email; } var eac = Util.Encrypt(ac); var q = from kc in DbUtil.Db.CardIdentifiers where kc.Id == eac select kc.PeopleId; var pid = q.SingleOrDefault(); string bankac = null; ExtraDatum ed = null; if (pid == null) { bankac = eac; string person; if (last.HasValue()) { person = "{1}, {0}; {2}".Fmt(first, last, addr); } else { person = "{0}; {1}".Fmt(name, addr); } ed = new ExtraDatum { Data = person, Stamp = Util.Now }; } CmsData.BundleDetail bd = null; var defaultfundid = DbUtil.Db.Setting("DefaultFundId", "1").ToInt(); for (var c = 0; c < csv.FieldCount; c++) { var col = cols[c].Trim(); if (col != "Amount" && !col.Contains("Comment") && csv[c].StartsWith("$") && csv[c].GetAmount() > 0) { var fundid = FindFund(col); bd = CreateContribution(date, fundid ?? defaultfundid); bd.Contribution.ContributionAmount = csv[c].GetAmount(); if (col == "Other") { col = oth; } if (!fundid.HasValue) { bd.Contribution.ContributionDesc = col; } if (ac.HasValue()) { bd.Contribution.BankAccount = bankac; } bd.Contribution.PeopleId = pid; bh.BundleDetails.Add(bd); if (ed != null) { bd.Contribution.ExtraDatum = ed; } } } } FinishBundle(bh); return(bh.BundleHeaderId); }