/// <summary> /// 导出数据到XML /// </summary> protected void cmdExportToXml_Click(object sender, EventArgs e) { ImportExportHelper ieHelper = new ImportExportHelper(); ieHelper.ModuleID = ModuleId; //查询字段的数据,填充待导出的XML实体 QueryParam qp = new QueryParam(); Int32 RecordCount = 0; qp.Orderfld = DNNGo_PowerForms_Field._.Sort; qp.OrderType = 0; qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal)); List <DNNGo_PowerForms_Field> fieldList = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount); List <FieldEntity> xmlFieldList = new List <FieldEntity>(); List <GallerySettingsEntity> xmlSettingList = new List <GallerySettingsEntity>(); foreach (DNNGo_PowerForms_Field fieldItem in fieldList) { xmlFieldList.Add(ieHelper.EntityToXml(fieldItem)); } //查询出所有的配置项 List <SettingEntity> EffectSettingDB = ieHelper.Setting_EffectSettingDB; if (EffectSettingDB != null && EffectSettingDB.Count > 0) { foreach (SettingEntity SettingItem in EffectSettingDB) { String SettingValue = ieHelper.ViewXmlSetting(SettingItem.Name, SettingItem.DefaultValue).ToString(); xmlSettingList.Add(new GallerySettingsEntity(ieHelper.EffectSettingsFormat(ieHelper.Settings_EffectName, SettingItem.Name), SettingValue)); } foreach (String key in ieHelper.PowerForms_Settings.Keys) { if (!xmlSettingList.Exists(r1 => r1.SettingName == key) && key.IndexOf("Gallery") != 0) { xmlSettingList.Add(new GallerySettingsEntity(key, Convert.ToString(ieHelper.PowerForms_Settings[key]))); } } } XmlFormat xf = new XmlFormat(MapPath(String.Format("{0}Resource/xml/FieldEntity.xml", ModulePath))); //将字段列表转换成XML的实体 String XmlContent = xf.ToXml <FieldEntity>(xmlFieldList, xmlSettingList); String XmlFilePath = FileSystemUtils.SaveXmlToFile(String.Format("FieldListEntity_{0}_{1}.xml", ModuleId, xUserTime.UtcTime().ToString("yyyyMMddHHmmssffff")), XmlContent, this); FileSystemUtils.DownloadFile(XmlFilePath, "FieldListEntity.xml"); }
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); } }
/// <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); } }
/// <summary> /// 下载表单文件 /// </summary> public void DownLoadFormFile() { bool LoginUserDownload = ViewSettingT <bool>("PowerForms_LoginUserDownload", false); if ((LoginUserDownload && UserInfo.UserID > 0) || !LoginUserDownload) { String filepath = WebHelper.GetStringParam(Request, "file", ""); if (!String.IsNullOrEmpty(filepath)) { try { filepath = CryptionHelper.DecryptString(CryptionHelper.Base64Decode(filepath)); if (!String.IsNullOrEmpty(filepath)) { String FileUrl = MapPath(String.Format("~/Portals/{0}/PowerForms/{1}/{2}", PortalId, ModuleId, filepath)); if (File.Exists(FileUrl)) { Response.Write(" <script>window.opener=null;window.close(); </script>"); FileSystemUtils.DownloadFile(FileUrl, Path.GetFileName(FileUrl)); } } } catch { } } } else { String file = WebHelper.GetStringParam(Request, "file", ""); String RedirectFile = String.Format("{0}Resource_Service.aspx?Token=downloadformfile&PortalId={1}&ModuleId={2}&file={3}", ModulePath, PortalId, ModuleId, Server.UrlEncode(file)); Response.Redirect(Globals.NavigateURL(PortalSettings.LoginTabId, "Login", "returnurl=" + Server.UrlEncode(RedirectFile)), false); //String file = WebHelper.GetStringParam(Request, "file", ""); //String RedirectFile = Globals.NavigateURL("", "a=b","Token=abc","bb=cc", "PortalId="+ PortalId.ToString(), "TabId="+ TabId.ToString(), "ModuleId="+ ModuleId.ToString(), "file="+ Server.UrlEncode(file));// String.Format("{0}Resource_Service.aspx?Token=RedirectFormFile&PortalId={1}&ModuleId={2}&file={3}", ModulePath, PortalId, ModuleId, Server.UrlEncode(file)); //Response.Redirect(Globals.NavigateURL(PortalSettings.LoginTabId, "Login", "returnurl=" + Server.UrlEncode(RedirectFile)),false); } }