Пример #1
0
        public void ModifyFlag(long siteId, long formItemId, string[] flags)
        {
            FormItem             formItem = FormItemDAO.GetItem(formItemId);
            IEnumerable <string> oldFlags = UserFlagDAO.GetFlags(siteId, formItem.Email, formItem.Mobile, formItem.Phone, formItem.IDCard);

            if (flags == null)
            {
                flags = new string[] { }
            }
            ;
            if (oldFlags == null)
            {
                oldFlags = new string[] { }
            }
            ;

            IEnumerable <string> addFlags = flags.Except(oldFlags);

            foreach (string flag in addFlags)
            {
                UserFlagDAO.SetItem(siteId, flag, formItem.Email, formItem.Mobile, formItem.Phone, formItem.IDCard);
            }

            IEnumerable <string> delFlags = oldFlags.Except(flags);

            foreach (string flag in delFlags)
            {
                UserFlagDAO.Delete(siteId, flag, formItem.Email, formItem.Mobile, formItem.Phone, formItem.IDCard);
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        public ActionResult FormItemView(long siteId, long menuId, long id, bool?isEvent)
        {
            FormItem item = FormItemDAO.GetItem(id);

            ViewBag.IsEvent   = isEvent ?? false;
            ViewBag.SiteID    = siteId;
            ViewBag.MenuID    = menuId;
            ViewBag.UploadUrl = Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/');
            return(View(item));
        }
Пример #4
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));
        }
Пример #5
0
        public ActionResult ModifyFlag(long siteId, long formItemId)
        {
            FormItem             formItem = FormItemDAO.GetItem(formItemId);
            IEnumerable <string> flags    = UserFlagDAO.GetFlags(siteId, formItem.Email, formItem.Mobile, formItem.Phone, formItem.IDCard);

            ViewBag.SiteID     = siteId;
            ViewBag.FormItemID = formItemId;
            ViewBag.AllFlags   = UserFlagDAO.GetFlags(siteId);
            return(View(flags));
        }
Пример #6
0
        public ActionResult FormItemView(long siteId, long menuId, long id, byte checkStatus, string remark, bool?isEvent)
        {
            FormItem item = FormItemDAO.GetItem(id);

            item.CheckStatus = checkStatus;
            item.Remark      = remark;
            FormItemDAO.SetItem(item);

            ViewBag.IsEvent   = isEvent ?? false;
            ViewBag.SiteID    = siteId;
            ViewBag.MenuID    = menuId;
            ViewBag.UploadUrl = Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/');

            ViewBag.Exit = true;
            return(View(item));
        }
Пример #7
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));
        }
Пример #8
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);
                }
            }
        }
Пример #9
0
        public ActionResult FormItemEdit(long siteId, long menuId, long formId, long?id, bool?isEvent)
        {
            FormItem item = null;

            if (id != null)
            {
                item = FormItemDAO.GetItem((long)id);
            }

            if (item == null)
            {
                item = new FormItem {
                    ID = WorkLib.GetItem.NewSN(), FormID = formId, IsBack = true
                }
            }
            ;

            ViewBag.IsEvent   = isEvent ?? false;
            ViewBag.SiteID    = siteId;
            ViewBag.MenuID    = menuId;
            ViewBag.UploadUrl = Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/');
            return(View(item));
        }
Пример #10
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));
        }
Пример #11
0
        private FormItem FormItemSave(FormModel form)
        {
            FormItem formItem = new FormItem {
                FormID = form.ID, ID = WorkLib.GetItem.NewSN(), IsTemp = false
            };
            IEnumerable <FieldModel> fields = form.GetFields();

            foreach (FieldModel field in fields)
            {
                string val = Request.Form[field.ID.ToString()] ?? string.Empty;
                if (field.TypeID == "address")
                {
                    string regions    = Request.Form["Regions_" + field.ID] ?? string.Empty;
                    int[]  regionList = null;
                    if (regions != string.Empty)
                    {
                        regionList = JsonConvert.DeserializeObject <int[]>(regions);
                    }

                    string address = Request.Form["Address_" + field.ID] ?? string.Empty;
                    val = JsonConvert.SerializeObject(new FieldAddress {
                        Regions = regionList, Address = address
                    });
                }

                FieldValueDAO.SetItem(new FieldValue
                {
                    FormItemID = formItem.ID,
                    FieldID    = field.ID,
                    Value      = val
                });

                if (field.DefaultType != null)
                {
                    switch ((FieldDefaultType)(byte)field.DefaultType)
                    {
                    case FieldDefaultType.Email:
                        formItem.Email = val;
                        break;

                    case FieldDefaultType.姓名:
                        formItem.Name = val;
                        break;

                    case FieldDefaultType.性別:
                        formItem.Sex = val;
                        break;

                    case FieldDefaultType.身份證字號:
                        formItem.IDCard = val;
                        break;

                    case FieldDefaultType.手機:
                        formItem.Mobile = val;
                        break;

                    case FieldDefaultType.電話:
                        formItem.Phone = val;
                        break;
                    }
                }
            }

            FormItemDAO.SetItem(formItem);
            return(formItem);
        }
Пример #12
0
 public void FormItemDel(long siteId, long menuId, IEnumerable <long> ids)
 {
     FormItemDAO.Delete(ids);
 }