コード例 #1
0
ファイル: StatementsController.cs プロジェクト: vs06/bvcms
        public ActionResult ContributionStatements(bool? pdf, DateTime? fromDate, DateTime? endDate, string startswith, string sort, int? tagid)
        {
            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;
            DbUtil.Db.ContributionsRuns.InsertOnSubmit(runningtotals);
            DbUtil.Db.SubmitChanges();
            var cul = DbUtil.Db.Setting("Culture", "en-US");
            var host = Util.Host;

            var output = Output(pdf);
            if (tagid == 0)
                tagid = null;

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.Lowest;
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);
                var m = new ContributionStatementsExtract(host, fromDate.Value, endDate.Value, pdf ?? false, output, startswith, sort, tagid);
                m.DoWork();
            });
            return Redirect("/Statements/Progress");
        }
コード例 #2
0
        public ActionResult ContributionStatements(DateTime? fromDate, DateTime? endDate, string startswith, string sort, int? tagid, bool excludeelectronic)
        {
            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;
            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");
        }
コード例 #3
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 = ContributionStatementsExtract.GetStatementSpecification(CurrentDatabase, statementType ?? "all");

            var c = new ContributionStatements
            {
                FamilyId = FamilyId,
                FromDate = FromDate,
                PeopleId = PeopleId,
                SpouseId = SpouseId,
                ToDate   = ToDate,
                typ      = typ,
                //TODO: once we switch to entirely html-based statement templates we won't need to check for these options
                NumberOfColumns = showCheckNo || showNotes ? 1 : 2,
                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);
        }