예제 #1
0
        private void MailSend(long siteId, FormMailModel mail, string mailSubject, string mailBody, System.Collections.ArrayList fileList, string recipientIds)
        {
            string                 SitesTitle      = SitesDAO.GetInfo(siteId).Title;//網站名稱
            IEnumerable <long>     recipientIdList = recipientIds.Split(',').Select(id => long.Parse(id));
            IEnumerable <FormItem> formItems       = FormItemDAO.GetItems(recipientIdList);
            string                 rootUrl         = Utility.GetRootUrl() + "/";

            foreach (FormItem item in formItems)
            {
                if (string.IsNullOrWhiteSpace(item.Email))
                {
                    continue;
                }

                FormCheckStatus status  = (FormCheckStatus)item.CheckStatus;
                string          result  = status == FormCheckStatus.正取 ? "報名成功" : status.ToString();
                string          subject = mailSubject.Replace("[RegTime]", item.CreateDate.ToString(WebInfo.DateFmt))
                                          .Replace("[RegName]", item.Name)
                                          .Replace("[RegGender]", item.Sex)
                                          .Replace("[RegResult]", result);

                string receiveUrl = $"{ rootUrl }Form/MailRead/{ mail.ID }?itemId={ item.ID }";
                string body       = mailBody.Replace("[RegTime]", item.CreateDate.ToString(WebInfo.DateFmt))
                                    .Replace("[RegName]", item.Name)
                                    .Replace("[RegGender]", item.Sex)
                                    .Replace("[Receive]", receiveUrl)
                                    .Replace("[RegPhone]", item.Mobile)
                                    .Replace("[RegTel]", item.Phone)
                                    .Replace("[RegEmail]", item.Email)
                                    .Replace("[RegResult]", result);

                emailService.SendMailWithFiles(siteId, item.Email, item.Name, subject, body, fileList, mail.SenderEmail, SitesTitle);
                FormMailDAO.WriteLog(mail.ID, item.ID);
            }
        }
예제 #2
0
        public ActionResult MailLogList(long siteId, long menuId, long id, bool?isEvent)
        {
            IEnumerable <FormMailLogModel> logs = FormMailDAO.GetMailLogs(id);

            ViewBag.FormItems = FormItemDAO.GetItems(logs.Select(log => log.FormItemID));

            ViewBag.SiteID  = siteId;
            ViewBag.IsEvent = isEvent ?? false;
            return(View(logs));
        }
예제 #3
0
        public ActionResult List(long siteId, long menuId, int?index, FormItemSearch search)
        {
            FormModel form = FormDAO.GetItemFromSourceID(menuId);

            if (Request.HttpMethod == "GET")
            {
                if (index == null)
                {
                    Utility.ClearSearchValue();
                }
                else
                {
                    FormItemSearch prevSearch = Utility.GetSearchValue <FormItemSearch>();
                    if (prevSearch != null)
                    {
                        search = prevSearch;
                    }
                }
            }
            else if (Request.HttpMethod == "POST")
            {
                Utility.SetSearchValue(search);
            }
            search.FormID = form.ID;

            ViewBag.Search = search;

            Pagination pagination = new Pagination {
                PageIndex = index ?? 1,
                PageSize  = 20
            };

            int totalRecord;
            IEnumerable <FormItem> items = FormItemDAO.GetItems(search, pagination.PageSize, pagination.PageIndex, out totalRecord);

            pagination.TotalRecord = totalRecord;
            ViewBag.Pagination     = pagination;

            ViewBag.Form   = form;
            ViewBag.Fields = FieldDAO.GetItems(search.FormID).Where(f => f.ShowInList).ToList();

            ViewBag.SiteID    = siteId;
            ViewBag.MenuID    = menuId;
            ViewBag.UploadUrl = Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/') + "/";

            return(View(items));
        }
예제 #4
0
        public void AddFlag(long siteId, long[] formItemIds, string[] flags)
        {
            if (formItemIds == null || formItemIds.Length == 0 || flags == null || flags.Length == 0)
            {
                return;
            }

            IEnumerable <FormItem> formItems = FormItemDAO.GetItems(formItemIds);

            foreach (FormItem item in formItems)
            {
                foreach (string flag in flags)
                {
                    UserFlagDAO.SetItem(siteId, flag, item.Email, item.Mobile, item.Phone, item.IDCard);
                }
            }
        }
예제 #5
0
        public FileResult FormItemExport(long id, bool?privacy, bool?isEvent = false)
        {
            FormItemSearch search = Utility.GetSearchValue <FormItemSearch>();

            if (search == null)
            {
                search = new FormItemSearch();
            }
            search.FormID         = id;
            ViewData["FormItems"] = FormItemDAO.GetItems(search);

            FormModel form = FormDAO.GetItem(id);

            ViewData["Fields"]  = form.GetFields();
            ViewData["Privacy"] = privacy ?? false;
            ViewData["IsEvent"] = isEvent ?? false;

            string html = Utility.GetViewHtml(this, "FormItemExport", null);

            string title = $"{ form.Title }-填寫.xls";

            return(File(System.Text.Encoding.UTF8.GetBytes(html), "application/vnd.ms-excel", title));
        }