コード例 #1
0
        /// <summary>
        /// 提交表单信息到数据库
        /// </summary>
        public void SubmitFormToDB()
        {
            DNNGo_PowerForms_Content SubmitContent = new DNNGo_PowerForms_Content();

            //读取需要载入的参数
            List <DNNGo_PowerForms_ContentItem> ContentList = new List <DNNGo_PowerForms_ContentItem>();


            Boolean SubmitValue = false;

            if (FieldList != null && FieldList.Count > 0)
            {
                foreach (DNNGo_PowerForms_Field fieldItem in FieldList)
                {
                    DNNGo_PowerForms_ContentItem ContentItem = new DNNGo_PowerForms_ContentItem();
                    ContentItem.FieldID      = fieldItem.ID;
                    ContentItem.FieldName    = fieldItem.Name;
                    ContentItem.FieldAlias   = fieldItem.Alias;
                    ContentItem.Sort         = fieldItem.Sort;
                    ContentItem.ContentValue = GetWebFormValue(fieldItem);
                    ContentItem.Group        = DNNGo_PowerForms_Group.FindNameByKeyForEdit(fieldItem.GroupID);
                    if (!String.IsNullOrEmpty(ContentItem.ContentValue))
                    {
                        SubmitValue = true;
                    }

                    ContentList.Add(ContentItem);
                }
            }

            //是否添加额外跟踪属性
            if (Settings_ExtraTracking)
            {
                ContentList.AddRange(GetExtraTracking());
            }


            if (SubmitValue)
            {
                //判断是否需要隐藏IP
                String  UserHost = WebHelper.UserHost;
                Boolean HideIp   = Settings["PowerForms_HideIp"] != null?Convert.ToBoolean(Settings["PowerForms_HideIp"]) : false;

                if (HideIp)
                {
                    UserHost = Common.HideIpAddress(UserHost);
                }

                SubmitContent.VerifyString = WebHelper.GetStringParam(Request, hfVerifyString.UniqueID, "");
                SubmitContent.LastIP       = UserHost;
                SubmitContent.LastTime     = xUserTime.LocalTime();
                SubmitContent.LastUser     = UserId;
                SubmitContent.ModuleId     = ModuleId;
                SubmitContent.PortalId     = PortalId;
                SubmitContent.CultureInfo  = System.Globalization.CultureInfo.CurrentCulture.Name;
                SubmitContent.FormVersion  = ViewSettingT <String>("PowerForms_FormVersion", "");


                //默认是当前登录用户的邮箱
                if (UserId > 0 && UserInfo != null && !String.IsNullOrEmpty(UserInfo.Email) && Mail.IsValidEmailAddress(UserInfo.Email, Null.NullInteger))
                {
                    SubmitContent.UserName = UserInfo.Username;
                    SubmitContent.Email    = UserInfo.Email;
                }


                if (!String.IsNullOrEmpty(Settings_SubmitUserEmail))
                {
                    //如果没有填写邮箱时
                    DNNGo_PowerForms_ContentItem EmailItem = ContentList.Find(r1 => r1.FieldName == Settings_SubmitUserEmail);
                    //if (EmailItem != null && !String.IsNullOrEmpty(EmailItem.ContentValue) && Mail.IsValidEmailAddress(EmailItem.ContentValue, Null.NullInteger))
                    if (EmailItem != null && !String.IsNullOrEmpty(EmailItem.ContentValue))
                    {
                        SubmitContent.Email = EmailItem.ContentValue;
                    }
                }


                //如果没有填写姓名时
                DNNGo_PowerForms_Field DisplayNameField = FieldList.Find(r => r.FieldType == (Int32)EnumViewControlType.TextBox_DisplayName);
                if (DisplayNameField != null && DisplayNameField.ID > 0)
                {
                    DNNGo_PowerForms_ContentItem DisplayNameItem = ContentList.Find(r1 => r1.FieldName == DisplayNameField.Name);
                    if (DisplayNameItem != null && !String.IsNullOrEmpty(DisplayNameItem.ContentValue))
                    {
                        SubmitContent.UserName = DisplayNameItem.ContentValue;
                    }
                }



                //序列化收集到的提交值列表
                if (ContentList != null && ContentList.Count > 0)
                {
                    SubmitContent.ContentValue = Common.Serialize <List <DNNGo_PowerForms_ContentItem> >(ContentList);
                }

                SubmitContent.Status = (Int32)EnumStatus.Activation;

                //是否需要保存记录
                Boolean SaveRecords = ViewSettingT <bool>("PowerForms_SaveRecords", true);
                //不保存记录 或 保存记录
                if (!SaveRecords || (SaveRecords && SubmitContent.Insert() > 0))
                {
                    //提交成功发邮件的方法
                    SendMail(SubmitContent, ContentList, FieldList);

                    //推送数据到第三方URL
                    Boolean Push_Enable = Settings["PowerForms_Push_Enable"] != null && !string.IsNullOrEmpty(Settings["PowerForms_Push_Enable"].ToString()) ? Convert.ToBoolean(Settings["PowerForms_Push_Enable"]) : false;
                    if (Push_Enable)
                    {
                        PushForm push = new PushForm(this);
                        push.ContentList   = ContentList;
                        push.SubmitContent = SubmitContent;
                        push.Push();
                    }


                    if (iFrame.IndexOf("iFrame", StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        if (!String.IsNullOrEmpty(Settings_RedirectPage))
                        {
                            Response.Write(String.Format("<script> window.parent.location = '{0}';</script>", RedirectPage(SubmitContent)));
                        }
                        else
                        {
                            //提交成功跳转的页面
                            Response.Redirect(RedirectPage(SubmitContent));
                        }
                    }
                    else
                    {
                        //提交成功跳转的页面
                        Response.Redirect(RedirectPage(SubmitContent));
                    }
                }
                else
                {
                    //新增表单失败
                }
            }
            else
            {
                //提交的内容是空的,没任何信息
            }
        }
コード例 #2
0
        public void ThreadUploadValues(object o)
        {
            PushForm push = o as PushForm;

            push.PushData();
        }