protected void cmdDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string   Checkbox_Value       = WebHelper.GetStringParam(Request, "Checkbox", "");
                string[] Checkbox_Value_Array = Checkbox_Value.Split(',');
                Int32    IDX = 0;
                for (int i = 0; i < Checkbox_Value_Array.Length; i++)
                {
                    if (Int32.TryParse(Checkbox_Value_Array[i], out IDX))
                    {
                        DNNGo_PowerForms_Content ContentItem = DNNGo_PowerForms_Content.FindByKeyForEdit(IDX);

                        if (ContentItem != null && ContentItem.ID > 0 && !String.IsNullOrEmpty(ContentItem.ContentValue))
                        {
                            foreach (DNNGo_PowerForms_ContentItem item in Common.Deserialize <List <DNNGo_PowerForms_ContentItem> >(ContentItem.ContentValue))
                            {
                                if (!String.IsNullOrEmpty(item.ContentValue))
                                {
                                    List <String> files = WebHelper.GetList(item.ContentValue, "<|>");
                                    if (files != null && files.Count > 0)
                                    {
                                        foreach (var filename in files)
                                        {
                                            if (!String.IsNullOrEmpty(filename) && filename.IndexOf("Url://") >= 0)
                                            {
                                                try
                                                {
                                                    FileInfo formFile = new FileInfo(MapPath(String.Format("~/Portals/{0}/PowerForms/{1}/{2}", PortalId, ModuleId, filename.Replace("Url://", ""))));
                                                    if (formFile.Exists)
                                                    {
                                                        formFile.Delete();
                                                    }
                                                }
                                                catch
                                                { }
                                            }
                                        }
                                    }
                                }
                            }
                        }


                        if (ContentItem.Delete() > 0)
                        {
                            //删除历史记录成功
                            mTips.IsPostBack = true;
                            mTips.LoadMessage("DeleteHistoryRecordsSuccess", EnumTips.Success, this, new String[] { "" });
                        }
                    }
                }

                BindDataToPage();
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        /// <summary>
        /// 清除所有历史记录
        /// </summary>
        protected void cmdCleanup_Click(object sender, EventArgs e)
        {
            try
            {
                Int32      RecordCount = 0;
                QueryParam qp          = new QueryParam();
                qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal));

                List <DNNGo_PowerForms_Content> CleanupList = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount);
                Int32 CleanupCount = 0;
                foreach (var CleanupItem in CleanupList)
                {
                    if (CleanupItem.Delete() > 0)
                    {
                        CleanupCount++;
                    }
                }

                if (CleanupCount > 0)
                {
                    BindDataToPage();
                }



                mTips.IsPostBack = true;
                mTips.LoadMessage("CleanupHistoryRecordsSuccess", EnumTips.Success, this, new String[] { CleanupCount.ToString() });
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        /// <summary>
        /// 执行单个任务
        /// </summary>
        public Int32 ExecutionTask(Hashtable ModuleSettings, ModuleInfo mInfo)
        {
            Int32 ModuleRecordCount = 0;

            int DaysBefore = ModuleSettings["PowerForms_Cleanup_DaysBefore"] != null?Convert.ToInt32(ModuleSettings["PowerForms_Cleanup_DaysBefore"]) : 30;

            int MaxFeedback = ModuleSettings["PowerForms_Cleanup_MaxFeedback"] != null?Convert.ToInt32(ModuleSettings["PowerForms_Cleanup_MaxFeedback"]) : 1000;

            Int32      RecordCount = 0;
            QueryParam qp          = new QueryParam();

            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.LastTime, DateTime.Now.AddDays(-DaysBefore), SearchType.Lt));
            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.ModuleId, mInfo.ModuleID, SearchType.Equal));
            qp.Orderfld  = DNNGo_PowerForms_Content._.ID;
            qp.OrderType = 0;

            List <DNNGo_PowerForms_Content> DeleteList = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount);

            for (int i = 0; i < DeleteList.Count && i < MaxFeedback; i++)
            {
                if (DeleteList[i].Delete() > 0)
                {
                    ModuleRecordCount++;
                }
            }
            this.ScheduleHistoryItem.AddLogNote(String.Format("It cleared {1} history records. time:{2} .Module:{0}<br />", mInfo.ModuleID, ModuleRecordCount, DateTime.Now.ToString()));


            return(ModuleRecordCount);
        }
        protected void repeaterContent_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                DNNGo_PowerForms_Content ContentItem = e.Item.DataItem as DNNGo_PowerForms_Content;


                Label lblUserName    = e.Item.FindControl("lblUserName") as Label;
                Label lblEmail       = e.Item.FindControl("lblEmail") as Label;
                Label lblFormVersion = e.Item.FindControl("lblFormVersion") as Label;


                lblUserName.Text    = String.IsNullOrEmpty(ContentItem.UserName) ? Localization.GetString("Anonymous", this.LocalResourceFile) : ContentItem.UserName;
                lblEmail.Text       = String.IsNullOrEmpty(ContentItem.Email) ? Localization.GetString("Anonymous", this.LocalResourceFile) : ContentItem.Email;
                lblFormVersion.Text = ContentItem.FormVersion;


                GridView gvItemList = e.Item.FindControl("gvItemList") as GridView;
                //读取存储的表单内容
                gvItemList.DataSource = Common.Deserialize <List <DNNGo_PowerForms_ContentItem> >(ContentItem.ContentValue);
                gvItemList.DataBind();
                gvItemList.Columns[3].Visible = Setting_EffectDB.Group;
                BindGridViewEmpty <DNNGo_PowerForms_ContentItem>(gvItemList);
            }
        }
        /// <summary>
        /// 绑定数据项到前台
        /// </summary>
        public void BindDataItem(EffectDB EffectDB)
        {
            Hashtable      Puts = new Hashtable();
            TemplateFormat xf   = new TemplateFormat(this);


            //读取需要载入的参数
            Puts.Add("EffectName", Settings_ResultName);
            Puts.Add("ThemeName", Settings_ResultThemeName);

            //读取当前Form的结果
            DNNGo_PowerForms_Content DataItem = DNNGo_PowerForms_Content.FindByKeyForEdit(FormID);

            Puts.Add("DataItem", DataItem);


            if (DataItem != null && DataItem.ID > 0 && !String.IsNullOrEmpty(DataItem.ContentValue))
            {
                List <DNNGo_PowerForms_ContentItem> ContentList = Common.Deserialize <List <DNNGo_PowerForms_ContentItem> >(DataItem.ContentValue);
                Puts.Add("ContentList", ContentList);
            }

            //查看是否是结果列表页
            if (!EffectDB.IsDetail)
            {
                Int32      RecordCount = 0;
                QueryParam qp          = new QueryParam();
                qp.Orderfld  = DNNGo_PowerForms_Content._.ID;
                qp.OrderType = 1;
                qp.PageSize  = 10;
                qp.PageIndex = PageIndex;
                qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal));
                List <DNNGo_PowerForms_Content> Results = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount);
                Puts.Add("ResultList", Results);

                if (RecordCount > qp.PageSize)
                {
                    Puts.Add("Pager", new Pager(qp.PageIndex, qp.PageSize, ModuleId, RecordCount, EnumPageType.DnnURL, false).CreateHtml());//分页
                }
                else
                {
                    Puts.Add("Pager", "");
                }
            }



            liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "Effect.html", Puts, xf, "Result"));
        }
        protected void cmdExport_Click(object sender, EventArgs e)
        {
            try
            {
                string   Checkbox_Value       = WebHelper.GetStringParam(Request, "Checkbox", "");
                string[] Checkbox_Value_Array = Checkbox_Value.Split(',');
                Int32    IDX = 0;

                List <DNNGo_PowerForms_Content> DataList = new List <DNNGo_PowerForms_Content>();
                for (int i = 0; i < Checkbox_Value_Array.Length; i++)
                {
                    if (Int32.TryParse(Checkbox_Value_Array[i], out IDX))
                    {
                        DNNGo_PowerForms_Content ContentItem = DNNGo_PowerForms_Content.FindByKeyForEdit(IDX);

                        if (ContentItem != null && ContentItem.ID > 0 && !String.IsNullOrEmpty(ContentItem.ContentValue))
                        {
                            //DataList.Add(  Common.Deserialize<List<DNNGo_PowerForms_ContentItem>>(ContentItem.ContentValue));
                            DataList.Add(ContentItem);
                        }
                    }
                }
                if (DataList.Count > 0)
                {
                    try
                    {
                        String FullName = String.Empty;
                        if (CsvHelper.SaveAsToFile(FieldList, DataList, out FullName, this))
                        {
                            FileSystemUtils.DownloadFile(FullName, Path.GetFileName(FullName));
                            //Response.Write(FullName);
                        }
                        else
                        {
                            mTips.LoadMessage("SaveExportRecordsError", EnumTips.Error, this, new String[] { FullName });
                        }
                    }
                    catch (Exception ex)
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
예제 #7
0
        /// <summary>
        /// 提交成功跳转页面
        /// </summary>
        /// <param name="SubmitContent"></param>
        /// <returns></returns>
        public String RedirectPage(DNNGo_PowerForms_Content SubmitContent)
        {
            //默认跳转到结果页
            String UrlValue = Globals.NavigateURL("", String.Format("Token=Result{0}", ModuleId), "FormID=" + SubmitContent.ID.ToString());

            //这里判断跳转的类型(指定页面)
            if (!String.IsNullOrEmpty(Settings_RedirectPage))
            {
                if (Settings_RedirectPage.IndexOf("TabID=", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    UrlValue = Globals.NavigateURL(Convert.ToInt32(Settings_RedirectPage.Replace("TabID=", "")), "", String.Format("FormID{0}={1}", ModuleId, SubmitContent.ID));
                }
                else if (Settings_RedirectPage.IndexOf("sFileID=", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    var fi = DotNetNuke.Services.FileSystem.FileManager.Instance.GetFile(Convert.ToInt32(Settings_RedirectPage.Replace("sFileID=", "")));
                    if (fi != null && fi.FileId > 0)
                    {
                        String filepath = MapPath(string.Format("{0}{1}{2}", PortalSettings.HomeDirectory, fi.Folder, Server.UrlPathEncode(fi.FileName)));
                        FileSystemUtils.DownloadFile(filepath, fi.FileName);
                    }
                }
                else
                {
                    UrlValue = Settings_RedirectPage;
                }
            }
            else
            {
                if (iFrame.IndexOf("iFrame", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    String language = WebHelper.GetStringParam(Request, "language", PortalSettings.DefaultLanguage);
                    UrlValue = String.Format("{0}View_iFrame.aspx?PortalId={1}&TabId={2}&ModuleId={3}&language={4}&Token=Result{3}&FormID={5}&iFrame=iFrame", ModulePath, PortalId, TabId, ModuleId, language, SubmitContent.ID);
                }
            }

            String RedirectPageAnchorLink = ViewSettingT <String>("PowerForms_RedirectPageAnchorLink", "");

            if (!String.IsNullOrEmpty(RedirectPageAnchorLink))
            {
                UrlValue = String.Format("{0}#{1}", UrlValue, RedirectPageAnchorLink);
            }

            return(UrlValue);
        }
        protected void cmdExportAll_Click(object sender, EventArgs e)
        {
            try
            {
                QueryParam qp = new QueryParam();
                qp.OrderType = 1;
                qp.Orderfld  = DNNGo_PowerForms_Content._.ID;
                qp.PageSize  = int.MaxValue;
                qp.Where     = BindSearch();
                Int32 RecordCount = 0;
                List <DNNGo_PowerForms_Content> DataList = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount);


                if (DataList != null && DataList.Count > 0)
                {
                    try
                    {
                        String FullName = String.Empty;
                        if (CsvHelper.SaveAsToFile(FieldList, DataList, out FullName, this))
                        {
                            FileSystemUtils.DownloadFile(FullName, Path.GetFileName(FullName));

                            //Response.Write(FullName);
                        }
                        else
                        {
                            //导出记录失败
                            mTips.IsPostBack = true;
                            mTips.LoadMessage("SaveExportRecordsError", EnumTips.Error, this, new String[] { FullName });
                        }
                    }
                    catch (Exception ex)
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
예제 #9
0
        /// <summary>
        /// 显示表单信息
        /// </summary>
        /// <returns></returns>
        public Boolean DisplayForm()
        {
            Boolean _DisplayForm = true;


            Boolean LoginUserDisplay = ViewSettingT <Boolean>("PowerForms_LoginUserDisplay", false);

            if (LoginUserDisplay)
            {
                if (UserId > 0)
                {
                    String FormVersion = ViewSettingT <String>("PowerForms_FormVersion", "");
                    if (!String.IsNullOrEmpty(FormVersion))
                    {
                        //根据条件判断该用户是否提交过了。
                        QueryParam qp = new QueryParam();
                        qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.ModuleId, ModuleId, SearchType.Equal));
                        qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.FormVersion, FormVersion, SearchType.Equal));
                        qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.LastUser, UserId, SearchType.Equal));

                        if (DNNGo_PowerForms_Content.FindCount(qp) > 0)
                        {
                            _DisplayForm = false;//如果已经提交过表单,则不显示
                        }
                    }
                }
                else
                {
                    _DisplayForm = false;//需要登陆且没有登陆时不显示表单
                }
            }



            //检查是否需要登陆用户可见



            return(_DisplayForm);
        }
예제 #10
0
        /// <summary>
        /// 导出表格
        /// </summary>
        /// <param name="SchedulerItem"></param>
        /// <returns></returns>
        public String ExportExcel(DNNGo_PowerForms_Scheduler SchedulerItem, Int32 index)
        {
            String Attachment = String.Empty;
            List <DNNGo_PowerForms_Content> DataList  = DNNGo_PowerForms_Content.FindAllByModuleId(SchedulerItem.ModuleId);
            List <DNNGo_PowerForms_Field>   FieldList = DNNGo_PowerForms_Field.FindAllByModuleId(SchedulerItem.ModuleId);

            if (DataList != null && DataList.Count > 0)
            {
                if (FieldList != null && FieldList.Count > 0)
                {
                    String FileName = SchedulerItem.ExcelName;
                    FileName = Common.ReplaceNoCase(FileName, "{yyyy}", DateTime.Now.ToString("yyyy"));
                    FileName = Common.ReplaceNoCase(FileName, "{mm}", DateTime.Now.ToString("MM"));
                    FileName = Common.ReplaceNoCase(FileName, "{dd}", DateTime.Now.ToString("dd"));
                    FileName = Common.ReplaceNoCase(FileName, "{time}", DateTime.Now.ToString("HHmmss"));
                    FileName = Common.ReplaceNoCase(FileName, "{ModuleID}", SchedulerItem.ModuleId.ToString());

                    Attachment = String.Format("{0}temp\\PowerForms\\{1}.xls", HttpRuntime.AppDomainAppPath, FileName);

                    try
                    {
                        CsvHelper.SaveAsToFile(FieldList, DataList, Attachment, false);
                    }
                    catch (Exception exc)
                    {
                        this.ScheduleHistoryItem.AddLogNote(exc.Source);
                    }
                }
                else
                {
                    this.ScheduleHistoryItem.AddLogNote(String.Format("task {0},field list is empty,Has ignored. time:{1}<br />", index, DateTime.Now.ToString()));
                }
            }
            else
            {
                this.ScheduleHistoryItem.AddLogNote(String.Format("task {0},History records is empty,Has ignored. time:{1}<br />", index, DateTime.Now.ToString()));
            }
            return(Attachment);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindDataToPage()
        {
            //tdControl.Visible = IsAdministrator;
            cmdDelete.Visible = IsAdministrator;
            cmdCleanup.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("CleanupConfirm", "") + "');");

            QueryParam qp = new QueryParam();

            qp.OrderType = OrderType;
            if (!String.IsNullOrEmpty(Orderfld))
            {
                qp.Orderfld = Orderfld;
            }
            else
            {
                qp.Orderfld = DNNGo_PowerForms_Content._.ID;
            }

            #region "分页的一系列代码"


            int RecordCount = 0;
            int pagesize    = qp.PageSize = Settings_PageSize;
            qp.PageIndex = PageIndex;



            #endregion

            //查询的方法
            qp.Where = BindSearch();

            List <DNNGo_PowerForms_Content> Articles = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount);
            qp.RecordCount = RecordCount;
            RecordPages    = qp.Pages;

            repeaterContent.DataSource = Articles;
            repeaterContent.DataBind();
        }
예제 #12
0
        /// <summary>
        /// 验证隐藏域
        /// </summary>
        /// <returns></returns>
        public Boolean VerificationHiddenfields(ref Boolean RepeatSubmitted)
        {
            Boolean HiddenfieldsVerify = true;
            String  VerifyEncrypt      = WebHelper.GetStringParam(Request, hfVerifyEncrypt.UniqueID, "", false);
            String  VerifyString       = WebHelper.GetStringParam(Request, hfVerifyString.UniqueID, "", false);

            if (!String.IsNullOrEmpty(VerifyEncrypt) && !String.IsNullOrEmpty(VerifyString))
            {
                try
                {
                    String DecryptString = CryptionHelper.DecryptString1(VerifyEncrypt, Settings_Hiddenfields_EncryptionKey);//CryptionHelper.DecryptString(VerifyEncrypt, Settings_Hiddenfields_EncryptionKey);
                    if (!String.IsNullOrEmpty(DecryptString) && VerifyString == DecryptString)
                    {
                        //查询该信息是否为重复提交的
                        QueryParam qp = new QueryParam();
                        qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.VerifyString, VerifyString, SearchType.Equal));
                        qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.LastTime, xUserTime.UtcTime().AddMinutes(-Settings_Hiddenfields_VerifyIntervalTime), SearchType.GtEqual));
                        if (DNNGo_PowerForms_Content.FindCount(qp) > 0)
                        {
                            RepeatSubmitted = false;
                        }
                    }
                    else
                    {
                        HiddenfieldsVerify = false;
                    }
                }
                catch
                {
                    HiddenfieldsVerify = false;
                }
            }
            else
            {
                HiddenfieldsVerify = false;
            }
            return(HiddenfieldsVerify);
        }
예제 #13
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);
        }
예제 #14
0
        /// <summary>
        /// 格式化内容模版
        /// </summary>
        /// <param name="SubmitContent">提交的内容实体</param>
        /// <param name="Template">模版</param>
        /// <returns></returns>
        public String FormatContent(DNNGo_PowerForms_Content SubmitContent, String Template, List <DNNGo_PowerForms_ContentItem> ContentList)
        {
            TemplateFormat xf = new TemplateFormat(this);

            xf.FieldList = FieldList;

            if (!String.IsNullOrEmpty(Template))
            {
                //为了节约效率,需要先判断模版内有无需要替换的标签
                if (Template.IndexOf("[UserName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    Template = Common.ReplaceNoCase(Template, "[UserName]", SubmitContent.UserName);
                }

                if (Template.IndexOf("[CultureInfo]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    Template = Common.ReplaceNoCase(Template, "[CultureInfo]", SubmitContent.CultureInfo);
                }

                if (Template.IndexOf("[SubmitTime]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    Template = Common.ReplaceNoCase(Template, "[SubmitTime]", SubmitContent.LastTime.ToString());
                }

                if (Template.IndexOf("[SubmitIP]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    Template = Common.ReplaceNoCase(Template, "[SubmitIP]", SubmitContent.LastIP);
                }

                if (Template.IndexOf("[Email]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    Template = Common.ReplaceNoCase(Template, "[Email]", SubmitContent.Email);
                }

                //if (Template.IndexOf("[]", StringComparison.CurrentCultureIgnoreCase) >= 0) Template = Common.ReplaceNoCase(Template, "[]", "");

                //2014.4.30 新增更多用户的Token,但需要是用户登陆时提交的才行.
                if (SubmitContent.LastUser > 0)
                {
                    DotNetNuke.Entities.Users.UserInfo uInfo = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, SubmitContent.LastUser);
                    if (uInfo != null && uInfo.UserID > 0)
                    {
                        if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            Template = Common.ReplaceNoCase(Template, "[DisplayName]", uInfo.DisplayName);
                        }
                        if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            Template = Common.ReplaceNoCase(Template, "[LastName]", uInfo.LastName);
                        }
                        if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            Template = Common.ReplaceNoCase(Template, "[FirstName]", uInfo.FirstName);
                        }
                        if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            Template = Common.ReplaceNoCase(Template, "[UserRole]", Common.GetStringByList(uInfo.Roles));
                        }
                    }
                    else
                    {
                        if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            Template = Common.ReplaceNoCase(Template, "[DisplayName]", "Anonymous users");
                        }
                        if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            Template = Common.ReplaceNoCase(Template, "[LastName]", "--");
                        }
                        if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            Template = Common.ReplaceNoCase(Template, "[FirstName]", "--");
                        }
                        if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            Template = Common.ReplaceNoCase(Template, "[UserRole]", "--");
                        }
                    }
                }
                else
                {
                    if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        Template = Common.ReplaceNoCase(Template, "[DisplayName]", "Anonymous users");
                    }
                    if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        Template = Common.ReplaceNoCase(Template, "[LastName]", "--");
                    }
                    if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        Template = Common.ReplaceNoCase(Template, "[FirstName]", "--");
                    }
                    if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        Template = Common.ReplaceNoCase(Template, "[UserRole]", "--");
                    }
                }


                //循环打印所有的字段值
                foreach (DNNGo_PowerForms_ContentItem item in ContentList)
                {
                    String item_key = String.Format("[{0}]", item.FieldName);
                    if (Template.IndexOf(item_key, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        Template = Common.ReplaceNoCase(Template, item_key, xf.ViewContentValue(item));
                    }
                }


                if (Template.IndexOf("[Content]", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    EffectDB EffectDB = Setting_EffectDB;

                    Hashtable Puts = new Hashtable();

                    String FormUrl = Globals.NavigateURL(TabId);
                    if (FormUrl.ToLower().IndexOf("http://") < 0 && FormUrl.ToLower().IndexOf("https://") < 0)
                    {
                        FormUrl = string.Format("{2}://{0}{1}", WebHelper.GetHomeUrl(), FormUrl, PortalSettings.SSLEnabled ? "https" : "http");
                    }

                    Puts.Add("ContentList", ContentList);
                    Puts.Add("FieldList", FieldList);
                    Puts.Add("EffectName", Settings_EffectName);
                    Puts.Add("ThemeName", Settings_EffectThemeName);
                    Puts.Add("Group", EffectDB.Group);//有分组的时候才会显示分组
                    Puts.Add("FormUrl", FormUrl);
                    Puts.Add("FormTitle", ModuleConfiguration.ModuleTitle);
                    Puts.Add("ExtraTracking", Settings_ExtraTracking);//是否启用跟踪

                    Template = Common.ReplaceNoCase(Template, "[Content]", ViewTemplate(EffectDB, "EmailTable.html", Puts, xf));
                }
            }
            return(Template);
        }
예제 #15
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);
                    }
                }
            }
        }
예제 #16
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
            {
                //提交的内容是空的,没任何信息
            }
        }
예제 #17
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);
        }