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");
        }
示例#2
0
        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");
        }