Exemple #1
0
        /// <summary>
        /// 创建单个扩展信息
        /// </summary>
        /// <param name="FieldName"></param>
        /// <param name="FieldAlias"></param>
        /// <param name="ContentValue"></param>
        /// <param name="Sort"></param>
        /// <returns></returns>
        public DNNGo_PowerForms_ContentItem GetExtraTrackingItem(String FieldName, String FieldAlias, String ContentValue, Int32 Sort)
        {
            DNNGo_PowerForms_ContentItem ContentItem = new DNNGo_PowerForms_ContentItem();

            ContentItem.Group        = "Tracking";
            ContentItem.FieldID      = 0;
            ContentItem.FieldName    = FieldName;
            ContentItem.FieldAlias   = FieldAlias;
            ContentItem.Sort         = Sort;
            ContentItem.ContentValue = ContentValue;
            ContentItem.Extra        = true;
            return(ContentItem);
        }
        protected void gvItemList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DNNGo_PowerForms_ContentItem ContentItem = e.Row.DataItem as DNNGo_PowerForms_ContentItem;

                if (ContentItem.Extra && !Settings_ExtraTracking)
                {
                    e.Row.Visible = false; //如果是关闭了追踪,就停止显示
                }
                else
                {
                    Literal LiContentValue = e.Row.FindControl("LiContentValue") as Literal;

                    TemplateFormat xf = new TemplateFormat(this);
                    xf.FieldList        = FieldList;
                    LiContentValue.Text = xf.ViewContentValue(ContentItem);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 提交成功发送邮件
        /// 1.构造管理员邮件并发送
        /// 2.构造提交者的邮件并发送
        /// </summary>
        /// <param name="SubmitContent"></param>
        public void SendMail(DNNGo_PowerForms_Content SubmitContent, List <DNNGo_PowerForms_ContentItem> ContentList, List <DNNGo_PowerForms_Field> FieldList)
        {
            DNNGo_PowerForms_Template Template = Settings_EmailTemplate;

            //if (String.IsNullOrEmpty(SubmitContent.Email) || SubmitContent.Email.IndexOf("Anonymous e-mail", StringComparison.CurrentCultureIgnoreCase) >= 0)
            //{

            //    DNNGo_PowerForms_ContentItem ContentItem = ContentList.Find(r1 => r1.FieldName.IndexOf(Settings_SubmitUserEmail, StringComparison.CurrentCultureIgnoreCase) >= 0);

            //    if (ContentItem != null && !String.IsNullOrEmpty(ContentItem.ContentValue))
            //    {
            //        SubmitContent.Email = ContentItem.ContentValue;
            //    }
            //}

            EmailInfo Email = new EmailInfo();

            Email.Settings = Settings;
            Email.PushSettings(this);

            //1.构造管理员邮件并发送
            if (Settings_SendToAdmin && !String.IsNullOrEmpty(Settings_AdminEmail))//发邮件||管理员邮箱不为空
            {
                List <String> SendMailAddress = new List <string>();

                //Boolean ReplaceSender = Settings["PowerForms_ReplaceSender"] != null && !string.IsNullOrEmpty(Settings["PowerForms_ReplaceSender"].ToString()) ? Convert.ToBoolean(Settings["PowerForms_ReplaceSender"]) : false;
                //if (ReplaceSender && !String.IsNullOrEmpty(SubmitContent.Email) && Mail.IsValidEmailAddress(SubmitContent.Email, Null.NullInteger))
                //{
                //    Email.ReplyTo = SubmitContent.Email;//替换发件人地址为提交用户
                //}

                /** 因为要加入ReplyTo,这个需要记录下,屏蔽掉之前的代码  2015.12.21 **/
                String  EmailReplyTo = String.Empty;
                Boolean ReplyTo      = Settings["PowerForms_ReplyTo"] != null?Convert.ToBoolean(Settings["PowerForms_ReplyTo"]) : true;

                if (ReplyTo && !String.IsNullOrEmpty(SubmitContent.Email) && Mail.IsValidEmailAddress(SubmitContent.Email, Null.NullInteger))
                {
                    EmailReplyTo = SubmitContent.Email;//替换发件人地址为提交用户
                }

                //添加管理员邮件到代发列表
                if (!String.IsNullOrEmpty(Settings_AdminEmail))
                {
                    if (Settings_AdminEmail.IndexOf(";") >= 0)
                    {
                        List <String> adminMailTos = WebHelper.GetList(Settings_AdminEmail, ";");
                        foreach (var adminMailTo in adminMailTos)
                        {
                            if (!String.IsNullOrEmpty(adminMailTo) && Mail.IsValidEmailAddress(adminMailTo, Null.NullInteger))
                            {
                                SendMailAddress.Add(adminMailTo);
                            }
                        }
                    }
                    else
                    {
                        SendMailAddress.Add(Settings_AdminEmail);
                    }
                }



                //检索勾选的待发送角色
                String AdminEmailRoles = Settings["PowerForms_AdminEmailRoles"] != null?Convert.ToString(Settings["PowerForms_AdminEmailRoles"]) : "";

                if (!String.IsNullOrEmpty(AdminEmailRoles))
                {
                    List <String> RoleNames = Common.GetList(AdminEmailRoles);
                    if (RoleNames != null && RoleNames.Count > 0)
                    {
                        foreach (var RoleName in RoleNames)
                        {
                            if (!String.IsNullOrEmpty(RoleName))
                            {
                                //找出角色相关的用户信息
                                DotNetNuke.Security.Roles.RoleController roleController = new DotNetNuke.Security.Roles.RoleController();
                                ArrayList users = roleController.GetUsersByRoleName(PortalId, RoleName);
                                if (users != null && users.Count > 0)
                                {
                                    foreach (UserInfo user in users)
                                    {
                                        //判断邮件地址是否符合
                                        if (!String.IsNullOrEmpty(user.Email) && Mail.IsValidEmailAddress(user.Email, Null.NullInteger) && !(SendMailAddress.IndexOf(user.Email) >= 0))
                                        {
                                            SendMailAddress.Add(user.Email);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }



                //发送给所有的管理用户
                foreach (var SendMail in SendMailAddress)
                {
                    Email          = new EmailInfo();
                    Email.Settings = Settings;
                    Email.PushSettings(this);

                    if (!String.IsNullOrEmpty(EmailReplyTo))
                    {
                        Email.ReplyTo = EmailReplyTo;
                    }

                    //构造邮件的主题和内容
                    Email.Subject = FormatContent(SubmitContent, Template.ReceiversSubject, ContentList);
                    Email.Content = FormatContent(SubmitContent, Template.ReceiversTemplate, ContentList);

                    Email.MailTo = SendMail;
                    MailScheduler.AssignMessage(Email);//加到待发队列
                }
            }

            //2.构造提交者的邮件并发送
            if (Settings_SendToSubmitUser)
            {
                if (!String.IsNullOrEmpty(SubmitContent.Email) && SubmitContent.Email.IndexOf("Anonymous e-mail", StringComparison.CurrentCultureIgnoreCase) < 0)
                {
                    Email          = new EmailInfo();
                    Email.Settings = Settings;
                    Email.PushSettings(this);
                    Email.MailTo = SubmitContent.Email;

                    //构造邮件的主题和内容
                    Email.Subject = FormatContent(SubmitContent, Template.ReplySubject, ContentList);
                    Email.Content = FormatContent(SubmitContent, Template.ReplyTemplate, ContentList);

                    MailScheduler.AssignMessage(Email);//加到待发队列
                    //NetHelper.SendMail(Email);
                }
            }

            //3.检查有无下拉列表发邮件的字段
            foreach (DNNGo_PowerForms_Field fieldItem in FieldList)
            {
                if (fieldItem.FieldType == (Int32)EnumViewControlType.DropDownList_SendEmail)
                {
                    DNNGo_PowerForms_ContentItem contentItem = ContentList.Find(r1 => r1.FieldName == fieldItem.Name);
                    if (contentItem != null && !String.IsNullOrEmpty(contentItem.FieldName))
                    {
                        Email          = new EmailInfo();
                        Email.Settings = Settings;
                        Email.PushSettings(this);
                        Email.MailTo = contentItem.ContentValue;

                        //构造邮件的主题和内容
                        Email.Subject = FormatContent(SubmitContent, Template.ReceiversSubject, ContentList);
                        Email.Content = FormatContent(SubmitContent, Template.ReceiversTemplate, ContentList);

                        MailScheduler.AssignMessage(Email);//加到待发队列
                        //NetHelper.SendMail(Email);
                    }
                }
            }
        }
Exemple #4
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
            {
                //提交的内容是空的,没任何信息
            }
        }
Exemple #5
0
        /// <summary>
        /// 显示内容值
        /// </summary>
        /// <param name="ContentItem"></param>
        /// <returns></returns>
        public static String ViewContentValue(List <DNNGo_PowerForms_Field> fieldList, DNNGo_PowerForms_ContentItem ItemInfo, DNNGo_PowerForms_Content ContentItem)
        {
            if (!String.IsNullOrEmpty(ItemInfo.ContentValue))
            {
                String LiContentValue = ItemInfo.ContentValue;

                DNNGo_PowerForms_Field fielditem = fieldList.Find(r => r.ID == ItemInfo.FieldID);

                if (fielditem != null && fielditem.ID > 0 && fielditem.FieldType == (Int32)EnumViewControlType.TextBox)
                {
                    LiContentValue = HttpUtility.HtmlEncode(ItemInfo.ContentValue);
                }
                else if (ItemInfo.ContentValue.IndexOf("Url://") >= 0)
                {
                    LiContentValue = String.Format("/Portals/{0}/PowerForms/{1}/{2}", ContentItem.PortalId, ContentItem.ModuleId, ItemInfo.ContentValue.Replace("Url://", ""));

                    //看看是否需要加http
                    if (LiContentValue.ToLower().IndexOf("http://") < 0 && LiContentValue.ToLower().IndexOf("https://") < 0)
                    {
                        LiContentValue = string.Format("http://{0}{1}", WebHelper.GetHomeUrl(), LiContentValue);
                    }
                }
                else
                {
                    LiContentValue = ItemInfo.ContentValue;
                }
                return(LiContentValue);
            }
            return(String.Empty);
        }
Exemple #6
0
        public static DataTable ConvertDataTable(DataTable dt, List <DNNGo_PowerForms_Field> fieldList, List <DNNGo_PowerForms_Content> DataList, bool ExtraTracking)
        {
            for (int i = 0; i < fieldList.Count; i++)
            {
                dt.Columns.Add(fieldList[i].Name);
            }

            if (!dt.Columns.Contains("UserName"))
            {
                dt.Columns.Add("UserName");
            }
            if (!dt.Columns.Contains("Time"))
            {
                dt.Columns.Add("Time");
            }
            if (!dt.Columns.Contains("IP"))
            {
                dt.Columns.Add("IP");
            }

            if (ExtraTracking)
            {
                if (!dt.Columns.Contains("Tracking_PageURL"))
                {
                    dt.Columns.Add("Tracking_PageURL");
                }
                if (!dt.Columns.Contains("Tracking_OriginalReferrer"))
                {
                    dt.Columns.Add("Tracking_OriginalReferrer");
                }
                if (!dt.Columns.Contains("Tracking_LandingPage"))
                {
                    dt.Columns.Add("Tracking_LandingPage");
                }
                if (!dt.Columns.Contains("Tracking_UserIP"))
                {
                    dt.Columns.Add("Tracking_UserIP");
                }
                if (!dt.Columns.Contains("Tracking_UserAgent"))
                {
                    dt.Columns.Add("Tracking_UserAgent");
                }
            }

            if (DataList != null && DataList.Count > 0)
            {
                string strModel = string.Empty;

                for (int i = 0; i < DataList.Count; i++)
                {
                    DNNGo_PowerForms_Content ContentItem = DataList[i];

                    if (ContentItem != null && !String.IsNullOrEmpty(ContentItem.ContentValue))
                    {
                        List <DNNGo_PowerForms_ContentItem> DataItem = Common.Deserialize <List <DNNGo_PowerForms_ContentItem> >(ContentItem.ContentValue);

                        if (DataItem != null && DataItem.Count > 0)
                        {
                            DataRow dr = dt.NewRow();



                            for (int j = 0; j < dt.Columns.Count; j++)
                            {
                                string PropertyName = dt.Columns[j].ColumnName;
                                DNNGo_PowerForms_ContentItem ItemInfo = DataItem.Find(r1 => r1.FieldName == PropertyName);
                                if (ItemInfo != null)
                                {
                                    dr[PropertyName] = ViewContentValue(fieldList, ItemInfo, ContentItem);
                                }
                                else
                                {
                                    if (PropertyName == "UserName")
                                    {
                                        dr["UserName"] = ContentItem.UserName;
                                    }
                                    else if (PropertyName == "Time")
                                    {
                                        dr["Time"] = ContentItem.LastTime.ToString();
                                    }
                                    else if (PropertyName == "IP")
                                    {
                                        dr["IP"] = ContentItem.LastIP;
                                    }
                                }
                            }

                            dt.Rows.Add(dr);
                        }
                    }
                }
            }
            return(dt);
        }