public void DoWork()
        {
            Db = DbUtil.Create(Host);
            Db.CommandTimeout = 1200;

            var noaddressok = Db.Setting("RequireAddressOnStatement", "true") == "false";
            showCheckNo = Db.Setting("RequireCheckNoOnStatement", "false").ToLower() == "true";
            showNotes = Db.Setting("RequireNotesOnStatement", "false").ToLower() == "true";
            const bool UseMinAmt = true;

            var qc = APIContribution.contributors(Db, fd, td, 0, 0, 0, noaddressok, UseMinAmt, StartsWith, Sort, tagid: TagId, excludeelectronic: ExcludeElectronic);
            var runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
            runningtotals.Count = qc.Count();
            Db.SubmitChanges();
            if (showCheckNo || showNotes)
            {
                var c = new ContributionStatementsExtra
                {
                    FromDate = fd,
                    ToDate = td,
                    typ = 3,
                    ShowCheckNo = showCheckNo,
                    ShowNotes = showNotes
                };
                using (var stream = new FileStream(OutputFile, FileMode.Create))
                    c.Run(stream, Db, qc);
                LastSet = c.LastSet();
                var sets = c.Sets();
                foreach (var set in sets)
                    using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
                        c.Run(stream, Db, qc, set);
                runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                runningtotals.LastSet = LastSet;
                runningtotals.Sets = string.Join(",", sets);
                runningtotals.Completed = DateTime.Now;
                Db.SubmitChanges();
            }
            else
            {
                var c = new ContributionStatements
                {
                    FromDate = fd,
                    ToDate = td,
                    typ = 3
                };
                using (var stream = new FileStream(OutputFile, FileMode.Create))
                    c.Run(stream, Db, qc);
                LastSet = c.LastSet();
                var sets = c.Sets();
                foreach (var set in sets)
                    using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
                        c.Run(stream, Db, qc, set);
                runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                runningtotals.LastSet = LastSet;
                runningtotals.Sets = string.Join(",", sets);
                runningtotals.Completed = DateTime.Now;
                Db.SubmitChanges();
            }
        }
示例#2
0
        public override void ExecuteResult(ControllerContext context)
        {
            var response = context.HttpContext.Response;

            response.ContentType = "application/pdf";
            var filename = $"Statement-{ToDate:d}".SlugifyString("-", false);

            response.AddHeader("content-disposition", $"filename={filename}.pdf");
            var cs = ContributionStatements.GetStatementSpecification(CurrentDatabase, statementType ?? "all");

            if (showCheckNo || showNotes)
            {
                var c = new ContributionStatementsExtra
                {
                    FamilyId    = FamilyId,
                    FromDate    = FromDate,
                    PeopleId    = PeopleId,
                    SpouseId    = SpouseId,
                    ToDate      = ToDate,
                    typ         = typ,
                    ShowCheckNo = showCheckNo,
                    ShowNotes   = showNotes
                };

                IEnumerable <ContributorInfo> q = null;
                switch (typ)
                {
                case 1:
                    q = APIContribution.Contributors(CurrentDatabase, FromDate, ToDate, PeopleId, SpouseId, 0, cs.Funds, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;

                case 2:
                    FamilyId = CurrentDatabase.People.Single(p => p.PeopleId == PeopleId).FamilyId;
                    q        = APIContribution.Contributors(CurrentDatabase, FromDate, ToDate, 0, 0, FamilyId, cs.Funds, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;

                case 3:
                    q = APIContribution.Contributors(CurrentDatabase, FromDate, ToDate, 0, 0, 0, cs.Funds, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;
                }
                c.Run(response.OutputStream, CurrentDatabase, q, cs);
            }
            else
            {
                var c = new ContributionStatements
                {
                    FamilyId = FamilyId,
                    FromDate = FromDate,
                    PeopleId = PeopleId,
                    SpouseId = SpouseId,
                    ToDate   = ToDate,
                    typ      = typ
                };

                IEnumerable <ContributorInfo> q = null;
                switch (typ)
                {
                case 1:
                    q = APIContribution.Contributors(CurrentDatabase, FromDate, ToDate, PeopleId, SpouseId, 0, cs.Funds, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;

                case 2:
                    FamilyId = CurrentDatabase.People.Single(p => p.PeopleId == PeopleId).FamilyId;
                    q        = APIContribution.Contributors(CurrentDatabase, FromDate, ToDate, 0, 0, FamilyId, cs.Funds, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;

                case 3:
                    q = APIContribution.Contributors(CurrentDatabase, FromDate, ToDate, 0, 0, 0, cs.Funds, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;
                }
                c.Run(response.OutputStream, CurrentDatabase, q, cs);
            }
        }
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            if (showCheckNo || showNotes)
            {
                var c = new ContributionStatementsExtra
                {
                    FamilyId    = FamilyId,
                    FromDate    = FromDate,
                    PeopleId    = PeopleId,
                    SpouseId    = SpouseId,
                    ToDate      = ToDate,
                    typ         = typ,
                    ShowCheckNo = showCheckNo,
                    ShowNotes   = showNotes
                };

                IEnumerable <ContributorInfo> q = null;
                switch (typ)
                {
                case 1:
                    q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, PeopleId, SpouseId, 0, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;

                case 2:
                    FamilyId = DbUtil.Db.People.Single(p => p.PeopleId == PeopleId).FamilyId;
                    q        = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, 0, 0, FamilyId, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;

                case 3:
                    q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, 0, 0, 0, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;
                }
                c.Run(Response.OutputStream, DbUtil.Db, q);
            }
            else
            {
                var c = new ContributionStatements
                {
                    FamilyId = FamilyId,
                    FromDate = FromDate,
                    PeopleId = PeopleId,
                    SpouseId = SpouseId,
                    ToDate   = ToDate,
                    typ      = typ
                };

                IEnumerable <ContributorInfo> q = null;
                switch (typ)
                {
                case 1:
                    q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, PeopleId, SpouseId, 0, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;

                case 2:
                    FamilyId = DbUtil.Db.People.Single(p => p.PeopleId == PeopleId).FamilyId;
                    q        = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, 0, 0, FamilyId, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;

                case 3:
                    q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, 0, 0, 0, noaddressok, useMinAmt, singleStatement: singleStatement);
                    break;
                }
                c.Run(Response.OutputStream, DbUtil.Db, q);
            }
        }
        public void DoWork()
        {
            Db = new CMSDataContext(Util.GetConnectionString(Host));
            Db.Host = Host;
            Db.CommandTimeout = 1200;

            var noaddressok = Db.Setting("RequireAddressOnStatement", "true") == "false";
            showCheckNo = Db.Setting("RequireCheckNoOnStatement", "false").ToLower() == "true";
            showNotes = Db.Setting("RequireNotesOnStatement", "false").ToLower() == "true";

            var qc = APIContribution.contributors(Db, fd, td, 0, 0, 0, noaddressok, useMinAmt: true, startswith: StartsWith, sort: Sort);
            var runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
            runningtotals.Count = qc.Count();
            Db.SubmitChanges();
            if (PDF)
            {
                if (showCheckNo || showNotes)
                {
                    var c = new ContributionStatementsExtra
                    {
                        FromDate = fd,
                        ToDate = td,
                        typ = 3,
                        ShowCheckNo = showCheckNo,
                        ShowNotes = showNotes
                    };
                    using (var stream = new FileStream(OutputFile, FileMode.Create))
                        c.Run(stream, Db, qc);
                    LastSet = c.LastSet();
                    var sets = c.Sets();
                    foreach (var set in sets)
                        using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
                            c.Run(stream, Db, qc, set);
                    runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                    runningtotals.LastSet = LastSet;
                    runningtotals.Sets = string.Join(",", sets);
                    runningtotals.Completed = DateTime.Now;
                    Db.SubmitChanges();
                }
                else
                {
                    var c = new ContributionStatements
                    {
                        FromDate = fd,
                        ToDate = td,
                        typ = 3
                    };
                    using (var stream = new FileStream(OutputFile, FileMode.Create))
                        c.Run(stream, Db, qc);
                    LastSet = c.LastSet();
                    var sets = c.Sets();
                    foreach (var set in sets)
                        using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
                            c.Run(stream, Db, qc, set);
                    runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                    runningtotals.LastSet = LastSet;
                    runningtotals.Sets = string.Join(",", sets);
                    runningtotals.Completed = DateTime.Now;
                    Db.SubmitChanges();
                }
            }
            else
            {
                textStream = new StreamWriter(OutputFile);
                foreach (var c in qc)
                {
                    pageStatement = 1;
                    writeHeader(c);
                    writeContributions(c);
                    string hdrGift = "   Date        Fund Name          Description of Gift-in-Kind Given as of {0:d}\n\n".Fmt(td);
                    rWrite(hdrGift);
                    writeSummary(c);
                    runningtotals.Processed += 1;
                    Db.SubmitChanges();
                }
                textStream.Close();
                runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                runningtotals.Completed = DateTime.Now;
                Db.SubmitChanges();
            }
        }
        public void DoWork(ContributionStatements.StatementSpecification cs)
        {
            Db = DbUtil.Create(Host);
            DbUtil.Db.CommandTimeout = 1200;

            var noaddressok = !DbUtil.Db.Setting("RequireAddressOnStatement", true);

            showCheckNo = DbUtil.Db.Setting("RequireCheckNoOnStatement");
            showNotes   = DbUtil.Db.Setting("RequireNotesOnStatement");
            const bool UseMinAmt = true;

            var qc            = APIContribution.Contributors(DbUtil.Db, fd, td, 0, 0, 0, cs.Funds, noaddressok, UseMinAmt, StartsWith, Sort, tagid: TagId, excludeelectronic: ExcludeElectronic);
            var runningtotals = DbUtil.Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();

            runningtotals.Count = qc.Count();
            DbUtil.Db.SubmitChanges();
            if (showCheckNo || showNotes)
            {
                var c = new ContributionStatementsExtra
                {
                    FromDate    = fd,
                    ToDate      = td,
                    typ         = 3,
                    ShowCheckNo = showCheckNo,
                    ShowNotes   = showNotes
                };
                using (var stream = new FileStream(OutputFile, FileMode.Create))
                {
                    c.Run(stream, Db, qc, cs);
                }

                LastSet = c.LastSet();
                var sets = c.Sets();
                foreach (var set in sets)
                {
                    using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
                    {
                        c.Run(stream, Db, qc, cs, set);
                    }
                }

                runningtotals           = DbUtil.Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                runningtotals.LastSet   = LastSet;
                runningtotals.Sets      = string.Join(",", sets);
                runningtotals.Completed = DateTime.Now;
                DbUtil.Db.SubmitChanges();
            }
            else
            {
                var c = new ContributionStatements
                {
                    FromDate = fd,
                    ToDate   = td,
                    typ      = 3
                };
                using (var stream = new FileStream(OutputFile, FileMode.Create))
                {
                    c.Run(stream, Db, qc, cs);
                }

                LastSet = c.LastSet();
                var sets = c.Sets();
                foreach (var set in sets)
                {
                    using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
                    {
                        c.Run(stream, Db, qc, cs, set);
                    }
                }

                runningtotals           = DbUtil.Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                runningtotals.LastSet   = LastSet;
                runningtotals.Sets      = string.Join(",", sets);
                runningtotals.Completed = DateTime.Now;
                DbUtil.Db.SubmitChanges();
            }
        }
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            if (showCheckNo || showNotes)
            {
                var c = new ContributionStatementsExtra
                {
                    FamilyId = FamilyId,
                    FromDate = FromDate,
                    PeopleId = PeopleId,
                    SpouseId = SpouseId,
                    ToDate = ToDate,
                    typ = typ,
                    ShowCheckNo = showCheckNo,
                    ShowNotes = showNotes
                };

                IEnumerable<ContributorInfo> q = null;
                switch (typ)
                {
                    case 1:
                        q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, PeopleId, SpouseId, 0, noaddressok, useMinAmt, singleStatement: singleStatement);
                        break;
                    case 2:
                        FamilyId = DbUtil.Db.People.Single(p => p.PeopleId == PeopleId).FamilyId;
                        q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, 0, 0, FamilyId, noaddressok, useMinAmt, singleStatement: singleStatement);
                        break;
                    case 3:
                        q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, 0, 0, 0, noaddressok, useMinAmt, singleStatement: singleStatement);
                        break;
                }
                c.Run(Response.OutputStream, DbUtil.Db, q);
            }
            else
            {
                var c = new ContributionStatements
                {
                    FamilyId = FamilyId,
                    FromDate = FromDate,
                    PeopleId = PeopleId,
                    SpouseId = SpouseId,
                    ToDate = ToDate,
                    typ = typ
                };

                IEnumerable<ContributorInfo> q = null;
                switch (typ)
                {
                    case 1:
                        q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, PeopleId, SpouseId, 0, noaddressok, useMinAmt, singleStatement: singleStatement);
                        break;
                    case 2:
                        FamilyId = DbUtil.Db.People.Single(p => p.PeopleId == PeopleId).FamilyId;
                        q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, 0, 0, FamilyId, noaddressok, useMinAmt, singleStatement: singleStatement);
                        break;
                    case 3:
                        q = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, 0, 0, 0, noaddressok, useMinAmt, singleStatement: singleStatement);
                        break;
                }
                c.Run(Response.OutputStream, DbUtil.Db, q);
            }
        }
示例#7
0
        public void DoWork()
        {
            Db                = new CMSDataContext(Util.GetConnectionString(Host));
            Db.Host           = Host;
            Db.CommandTimeout = 1200;

            var noaddressok = Db.Setting("RequireAddressOnStatement", "true") == "false";

            showCheckNo = Db.Setting("RequireCheckNoOnStatement", "false").ToLower() == "true";
            showNotes   = Db.Setting("RequireNotesOnStatement", "false").ToLower() == "true";

            var qc            = APIContribution.contributors(Db, fd, td, 0, 0, 0, noaddressok, useMinAmt: true, startswith: StartsWith, sort: Sort, tagid: TagId);
            var runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();

            runningtotals.Count = qc.Count();
            Db.SubmitChanges();
            if (PDF)
            {
                if (showCheckNo || showNotes)
                {
                    var c = new ContributionStatementsExtra
                    {
                        FromDate    = fd,
                        ToDate      = td,
                        typ         = 3,
                        ShowCheckNo = showCheckNo,
                        ShowNotes   = showNotes
                    };
                    using (var stream = new FileStream(OutputFile, FileMode.Create))
                        c.Run(stream, Db, qc);
                    LastSet = c.LastSet();
                    var sets = c.Sets();
                    foreach (var set in sets)
                    {
                        using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
                            c.Run(stream, Db, qc, set);
                    }
                    runningtotals           = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                    runningtotals.LastSet   = LastSet;
                    runningtotals.Sets      = string.Join(",", sets);
                    runningtotals.Completed = DateTime.Now;
                    Db.SubmitChanges();
                }
                else
                {
                    var c = new ContributionStatements
                    {
                        FromDate = fd,
                        ToDate   = td,
                        typ      = 3
                    };
                    using (var stream = new FileStream(OutputFile, FileMode.Create))
                        c.Run(stream, Db, qc);
                    LastSet = c.LastSet();
                    var sets = c.Sets();
                    foreach (var set in sets)
                    {
                        using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
                            c.Run(stream, Db, qc, set);
                    }
                    runningtotals           = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                    runningtotals.LastSet   = LastSet;
                    runningtotals.Sets      = string.Join(",", sets);
                    runningtotals.Completed = DateTime.Now;
                    Db.SubmitChanges();
                }
            }
            else
            {
                textStream = new StreamWriter(OutputFile);
                foreach (var c in qc)
                {
                    pageStatement = 1;
                    writeHeader(c);
                    writeContributions(c);
                    string hdrGift = "   Date        Fund Name          Description of Gift-in-Kind Given as of {0:d}\n\n".Fmt(td);
                    rWrite(hdrGift);
                    writeSummary(c);
                    runningtotals.Processed += 1;
                    Db.SubmitChanges();
                }
                textStream.Close();
                runningtotals           = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
                runningtotals.Completed = DateTime.Now;
                Db.SubmitChanges();
            }
        }