Exemple #1
0
        public ActionResult Csv(Guid id, string format, bool? sortzip, bool? titles, bool? useMailFlags)
        {
            var ctl = new MailingController {UseTitles = titles ?? false, UseMailFlags = useMailFlags ?? false};

            var sort = "Name";
            if (sortzip ?? false)
                sort = "Zip";

            switch (format)
            {
                case "Individual":
                case "GroupAddress":
                    return new CsvResult(ctl.FetchIndividualList(sort, id));
                case "FamilyMembers":
                    return new CsvResult(ctl.FetchFamilyMembers(sort, id));
                case "Family":
                    return new CsvResult(ctl.FetchFamilyList(sort, id));
                case "ParentsOf":
                    return new CsvResult(ctl.FetchParentsOfList(sort, id));
                case "CouplesEither":
                    return new CsvResult(ctl.FetchCouplesEitherList(sort, id), couples: true);
                case "CouplesBoth":
                    return new CsvResult(ctl.FetchCouplesBothList(sort, id), couples: true);
            }
            return Content("no format");
        }
        public ActionResult Csv(Guid id, string format, bool?sortzip, bool?titles, bool?useMailFlags)
        {
            var ctl = new MailingController(RequestManager)
            {
                UseTitles = titles ?? false, UseMailFlags = useMailFlags ?? false
            };

            var sort = "Name";

            if (sortzip ?? false)
            {
                sort = "Zip";
            }

            switch (format)
            {
            case "Individual":
            case "GroupAddress":
                return(new CsvResult(ctl.FetchIndividualList(sort, id)));

            case "FamilyMembers":
                return(new CsvResult(ctl.FetchFamilyMembers(sort, id)));

            case "Family":
                return(new CsvResult(ctl.FetchFamilyList(sort, id)));

            case "ParentsOf":
                return(new CsvResult(ctl.FetchParentsOfList(sort, id)));

            case "CouplesEither":
                return(new CsvResult(ctl.FetchCouplesEitherList(sort, id), couples: true));

            case "CouplesBoth":
                return(new CsvResult(ctl.FetchCouplesBothList(sort, id), couples: true));
            }
            return(Content("no format"));
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var context         = HttpContext.Current;
            int?qid             = context.Request.QueryString["id"].ToInt2();
            var labelNameFormat = context.Request.QueryString["format"];
            var ctl             = new MailingController();
            var sortZip         = context.Request.QueryString["sortZip"];
            var sort            = "Name";
            var useTitles       = context.Request.QueryString["titles"];

            ctl.UseTitles = useTitles == "true";
            if (sortZip == "true")
            {
                sort = "Zip";
            }
            IEnumerable <MailingController.MailingInfo> q = null;

            switch (labelNameFormat)
            {
            case "Individual":
                q = ctl.FetchIndividualList(sort, qid.Value);
                break;

            case "FamilyMembers":
                q = ctl.FetchFamilyMembers(sort, qid.Value);
                break;

            case "Family":
                q = ctl.FetchFamilyList(sort, qid.Value);
                break;

            case "ParentsOf":
                q = ctl.FetchParentsOfList(sort, qid.Value);
                break;

            case "CouplesEither":
                q = ctl.FetchCouplesEitherList(sort, qid.Value);
                break;

            case "CouplesBoth":
                q = ctl.FetchCouplesBothList(sort, qid.Value);
                break;
            }
            var r = context.Response;

            if (q == null)
            {
                r.Write("no format");
                return;
            }

            r.Clear();
            r.ContentType = "text/plain";
            r.AddHeader("Content-Disposition", "attachment;filename=CMSPeople.csv");
            r.Charset = "";
            if (!qid.HasValue)
            {
                r.Write("no queryid");
                r.Flush();
                r.End();
            }
            foreach (var mi in q)
            {
                r.Write(string.Format("{0},{1},{2},{3},{4},{5},{6}\r\n",
                                      mi.LabelName, mi.Address, mi.Address2, mi.City, mi.State, mi.Zip.FmtZip(), mi.PeopleId));
            }
        }