コード例 #1
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");
            var c = new ContributionStatements
            {
                FamilyId = FamilyId,
                FromDate = FromDate,
                PeopleId = PeopleId,
                SpouseId = SpouseId,
                ToDate   = ToDate,
                typ      = typ
            };
            IEnumerable <ContributorInfo> q = null;

            switch (typ)
            {
            case 1:
                SpouseId = DbUtil.Db.People.Single(p => p.PeopleId == PeopleId).SpouseId.ToInt();
                q        = APIContribution.contributors(DbUtil.Db, FromDate, ToDate, PeopleId, SpouseId, 0, noaddressok, useMinAmt);
                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);
                break;

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

            var noaddressok   = Db.Setting("RequireAddressOnStatement", "true") == "false";
            var qc            = APIContribution.contributors(Db, fd, td, 0, 0, 0, noaddressok, useMinAmt: true, startswith: StartsWith);
            var runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();

            runningtotals.Count = qc.Count();
            Db.SubmitChanges();
            if (PDF)
            {
                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();
            }
        }
コード例 #3
0
        public ActionResult ContributionStatements(DateTime?fromDate, DateTime?endDate, string startswith, string sort, int?tagid, bool excludeelectronic, bool exportcontributors = false)
        {
            if (!fromDate.HasValue || !endDate.HasValue)
            {
                return(Content("<h3>Must have a Startdate and Enddate</h3>"));
            }
            var runningtotals = new ContributionsRun
            {
                Started   = DateTime.Now,
                Count     = 0,
                Processed = 0
            };

            if (!startswith.HasValue())
            {
                startswith = null;
            }
            if (exportcontributors)
            {
                var        db          = DbUtil.Db;
                var        noaddressok = !db.Setting("RequireAddressOnStatement", true);
                const bool useMinAmt   = true;
                if (tagid == 0)
                {
                    tagid = null;
                }
                var qc = APIContribution.contributors(db, fromDate.Value, endDate.Value, 0, 0, 0, noaddressok, useMinAmt, startswith, sort, tagid: tagid, excludeelectronic: excludeelectronic);
                return(ExcelExportModel.ToDataTable(qc.ToList()).ToExcel("Contributors.xlsx"));
            }
            DbUtil.Db.ContributionsRuns.InsertOnSubmit(runningtotals);
            DbUtil.Db.SubmitChanges();
            var cul  = DbUtil.Db.Setting("Culture", "en-US");
            var host = Util.Host;

            var output = Output();

            if (tagid == 0)
            {
                tagid = null;
            }

            HostingEnvironment.QueueBackgroundWorkItem(ct =>
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);
                var m = new ContributionStatementsExtract(host, fromDate.Value, endDate.Value, output, startswith, sort, tagid, excludeelectronic);
                m.DoWork();
            });
            return(Redirect("/Statements/Progress"));
        }
コード例 #4
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";
            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();
            }
        }