diff --git a/App_LocalResources/ExportCSV.ascx.resx b/App_LocalResources/ExportCSV.ascx.resx index 1987fa4..bbaf134 100644 --- a/App_LocalResources/ExportCSV.ascx.resx +++ b/App_LocalResources/ExportCSV.ascx.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Folder @@ -165,4 +165,28 @@ Semicolon ";" + + Include Created by, Created at, Changed by and Changed at Fields + + + Include System Fields + + + Select final date to export records, if blank all records will be exported + + + Final date + + + Select initial date to export records, if blank all records will be exported + + + Initial date + + + You must select both or no dates + + + Initial date must be earlier than final date + \ No newline at end of file diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs index 9a1a6e9..74bc049 100644 --- a/AssemblyInfo.cs +++ b/AssemblyInfo.cs @@ -3,13 +3,13 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("DotNetNuke.Modules.UserDefinedTable")] [assembly: AssemblyDescription("DNN Form and List ")] -[assembly: AssemblyCompany("DNN Corp")] -[assembly: AssemblyCopyright("DotNetNuke® is copyright 2002-2016 by DNN Corp. All Rights Reserved.")] -[assembly: AssemblyTrademark("DotNetNuke")] +[assembly: AssemblyCompany("DNN Community")] +[assembly: AssemblyCopyright("2021 DNN Community")] +[assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("06.05.05.00")] +[assembly: AssemblyVersion("06.05.08.00")] [assembly: CLSCompliant(true)] -[assembly: AssemblyFileVersion("06.05.05.00")] +[assembly: AssemblyFileVersion("06.05.08.00")] diff --git a/Components/DataProvider.cs b/Components/DataProvider.cs index 670c8cb..d826df4 100644 --- a/Components/DataProvider.cs +++ b/Components/DataProvider.cs @@ -71,6 +71,9 @@ public abstract int AddField(int ModuleID, string FieldTitle, int before, string public abstract IDataReader GetRow(int UserDefinedRowId, int ModuleId); public abstract IDataReader GetRows(int ModuleId); + + public abstract IDataReader GetRowsWithDates(int ModuleId, DateTime initialDate, DateTime finalDate); + public abstract IDataReader GetFieldSettings(int moduleId); public abstract void UpdateFieldSetting(int fieldid, string key, string value); diff --git a/Components/UserDefinedTableController.cs b/Components/UserDefinedTableController.cs index 29b3b80..fccc13a 100644 --- a/Components/UserDefinedTableController.cs +++ b/Components/UserDefinedTableController.cs @@ -253,6 +253,34 @@ public DataSet GetDataSet(bool withPreRenderedValues) return ds; } + /// ----------------------------------------------------------------------------- + /// + /// Gets all Data values of an UDT table (module) from the Database as DataSet + /// + /// specifies, whether links, dates etc. shall be prerendered for XML output + /// All field values as DataSet + /// ----------------------------------------------------------------------------- + public DataSet GetDataSetWithDates(bool withPreRenderedValues, DateTime initialDate, DateTime finalDate) + { + var fieldsTable = FieldController.GetFieldsTable(ModuleId, addNewColumn: false, addAuditColumns: false); + DataSet ds; + using (var dr = DataProvider.Instance().GetRowsWithDates(ModuleId,initialDate,finalDate)) + { + ds = BuildMainDataSet(fieldsTable, dr, !withPreRenderedValues); + } + var fieldSettingsTable = FieldSettingsController.GetFieldSettingsTable(ModuleId); + ds.Tables.Add(fieldSettingsTable); + + SetEditLinksAndVisibilityBasedOnPermissions(ds); + + if (withPreRenderedValues) + { + RenderValuesToHtmlInsideDataSet(ds); + } + ds.Namespace = "DotNetNuke/UserDefinedTable"; + return ds; + } + public DataSet GetSchemaDataset() { var ds = GetRow(-1); diff --git a/DotNetNuke.Modules.UserDefinedTable.xml b/DotNetNuke.Modules.UserDefinedTable.xml index ad4df0c..fb9d09b 100644 --- a/DotNetNuke.Modules.UserDefinedTable.xml +++ b/DotNetNuke.Modules.UserDefinedTable.xml @@ -986,6 +986,87 @@ To modify move field declaration from designer file to code-behind file. + + + plSystemFields control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + + + + cbSystemFields control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + + + + plInitialDate control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + + + + txtInitialDate control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + + + + plFinalDate control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + + + + txtFinalDate control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + + + + plDatesValidator control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + + + + compareValidatorDates control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + + + + CustomValidatorDates control. + + + Auto-generated field. + To modify move field declaration from designer file to code-behind file. + + cmdExport control. @@ -3122,6 +3203,15 @@ All field values as DataSet ----------------------------------------------------------------------------- + + ----------------------------------------------------------------------------- + + Gets all Data values of an UDT table (module) from the Database as DataSet + + specifies, whether links, dates etc. shall be prerendered for XML output + All field values as DataSet + ----------------------------------------------------------------------------- + ----------------------------------------------------------------------------- diff --git a/ExportCSV.ascx b/ExportCSV.ascx index f1674d0..cc08bcf 100644 --- a/ExportCSV.ascx +++ b/ExportCSV.ascx @@ -1,30 +1,110 @@ <%@ Control Language="C#" CodeBehind="ExportCSV.ascx.cs" Inherits="DotNetNuke.Modules.UserDefinedTable.ExportCsv" AutoEventWireup="false" %> <%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> +<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %> + + + +
-
- - -
-
- - -
-
- - - - - +
+ + +
+
+ + +
+
+ + + + + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + + + +
+
    +
  • +
  • +
  • +
  • +
+
-
    -
  • -
  • -
  • -
  • -
- -
\ No newline at end of file + + diff --git a/ExportCSV.ascx.cs b/ExportCSV.ascx.cs index 4e5e1dd..58e51b3 100644 --- a/ExportCSV.ascx.cs +++ b/ExportCSV.ascx.cs @@ -14,7 +14,8 @@ using DotNetNuke.Services.FileSystem; using DotNetNuke.Services.Localization; using DotNetNuke.UI.Skins.Controls; - +using System.Globalization; +using DotNetNuke.Entities.Portals; namespace DotNetNuke.Modules.UserDefinedTable { @@ -22,18 +23,18 @@ public partial class ExportCsv : PortalModuleBase { #region Private Members - int _moduleId = Convert.ToInt32(- 1); + int _moduleId = Convert.ToInt32(-1); #endregion #region Event Handlers - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - cmdCancel.Click += cmdCancel_Click; - cmdExport.Click += cmdExport_Click; - Load += Page_Load; - } + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + cmdCancel.Click += cmdCancel_Click; + cmdExport.Click += cmdExport_Click; + Load += Page_Load; + } void Page_Load(object sender, EventArgs e) { try @@ -43,7 +44,7 @@ void Page_Load(object sender, EventArgs e) _moduleId = int.Parse(Request.QueryString["moduleid"]); } - if (! Page.IsPostBack) + if (!Page.IsPostBack) { cboFolders.Items.Insert(0, new ListItem( @@ -52,15 +53,18 @@ void Page_Load(object sender, EventArgs e) foreach (FolderInfo folder in folders) { var folderItem = new ListItem - { - Text = folder.FolderPath == Null.NullString + { + Text = folder.FolderPath == Null.NullString ? Localization.GetString("Root", LocalResourceFile) : folder.FolderPath, - Value = folder.FolderPath - }; + Value = folder.FolderPath + }; cboFolders.Items.Add(folderItem); } + txtInitialDate.Attributes.Add("readonly", "readonly"); + txtFinalDate.Attributes.Add("readonly", "readonly"); + var moduleController = new ModuleController(); var objModule = moduleController.GetModule(_moduleId, TabId, false); if (objModule != null) @@ -95,7 +99,7 @@ void cmdExport_Click(object sender, EventArgs e) { var strFile = CleanName(string.Format("{0}.csv", txtFile.Text)); var strMessage = ExportModule(_moduleId, strFile, cboFolders.SelectedItem.Value, - rblDelimiter.SelectedValue); + rblDelimiter.SelectedValue, txtInitialDate.Text, txtFinalDate.Text); if (strMessage == "") { Response.Redirect(Globals.NavigateURL(), true); @@ -121,7 +125,7 @@ void cmdExport_Click(object sender, EventArgs e) #region Private Methods - string ExportModule(int moduleId, string fileName, string folder, string delimiter) + string ExportModule(int moduleId, string fileName, string folder, string delimiter, string initialDate, string finalDate) { var strMessage = ""; @@ -130,11 +134,11 @@ string ExportModule(int moduleId, string fileName, string folder, string delimit var extension = Path.GetExtension(fileName); if (extension != null && (extension.ToUpper() == ".CSV" && moduleInfo != null)) { - + try { - ExportData(folder, fileName , delimiter); + ExportData(folder, fileName, delimiter, initialDate, finalDate); } catch (Exception ex) { @@ -154,16 +158,40 @@ static string CleanName(string name) return badChars.Aggregate(strName, (current, badChar) => current.Replace(badChar.ToString(), "")); } - void ExportData(string folder, string strFileName, string delimiter) + void ExportData(string folder, string strFileName, string delimiter, string initialDate, string finalDate) { - var ds = new UserDefinedTableController(_moduleId, TabId, UserInfo).GetDataSet(true); + DataSet ds; + + if(!string.IsNullOrEmpty(initialDate) && !string.IsNullOrEmpty(finalDate)) + { + CultureInfo provider = CultureInfo.InvariantCulture; + string format = "yyyy/MM/dd"; + + var serverTimeZone = PortalController.Instance.GetCurrentPortalSettings().TimeZone; + var timeZone = serverTimeZone; + + DateTime startDate = DateTime.ParseExact(initialDate, format, provider); + startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0); + startDate = TimeZoneInfo.ConvertTimeToUtc(startDate, timeZone); + + DateTime endDate = DateTime.ParseExact(finalDate, format, provider); + endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59); + endDate = TimeZoneInfo.ConvertTimeToUtc(endDate, timeZone); + + ds = new UserDefinedTableController(_moduleId, TabId, UserInfo).GetDataSetWithDates(true,startDate, endDate); + } + else + { + ds = new UserDefinedTableController(_moduleId, TabId, UserInfo).GetDataSet(true); + } + var data = ds.Tables[0]; var fields = ds.Tables[1]; WriteData(data, fields, folder, strFileName, delimiter); } - void WriteData(DataTable data, DataTable fields, string folder, string fileName, string delimiter) + void WriteData(DataTable data, DataTable fields, string folder, string fileName, string delimiter) { using (var sw = new StringWriter()) @@ -174,7 +202,7 @@ void WriteData(DataTable data, DataTable fields, string folder, string fileName, { var typeName = (row[FieldsTableColumn.Type].ToString()); //ignore system fields - if (DataType.ByName(typeName).IsUserDefinedField) + if (DataType.ByName(typeName).IsUserDefinedField || cbSystemFields.Checked) { columns.Add(row[FieldsTableColumn.Title].ToString()); } @@ -194,6 +222,11 @@ void WriteData(DataTable data, DataTable fields, string folder, string fileName, ? fieldTitle + DataTableColumn.Appendix_Original : fieldTitle); var value = row[valueName].AsString(); + if (fieldTitle == "Created at" || fieldTitle == "Changed at") + { + DateTime valueDate = DateTime.Parse(value); + value = valueDate.ToString("yyyy-MM-ddTHH:mm:ssZ"); + } values.Add(value); } CSVWriter.WriteCSV(values.ToArray(), sw, delimiter); @@ -216,4 +249,4 @@ void WriteFile(string folder, string fileName, StringWriter sw) #endregion } -} \ No newline at end of file +} diff --git a/ExportCSV.ascx.designer.cs b/ExportCSV.ascx.designer.cs index 23b2bc0..3c04d59 100644 --- a/ExportCSV.ascx.designer.cs +++ b/ExportCSV.ascx.designer.cs @@ -7,11 +7,13 @@ // //------------------------------------------------------------------------------ -namespace DotNetNuke.Modules.UserDefinedTable { - - - public partial class ExportCsv { - +namespace DotNetNuke.Modules.UserDefinedTable +{ + + + public partial class ExportCsv + { + /// /// plFolder control. /// @@ -20,7 +22,7 @@ public partial class ExportCsv { /// To modify move field declaration from designer file to code-behind file. /// protected global::DotNetNuke.UI.UserControls.LabelControl plFolder; - + /// /// cboFolders control. /// @@ -29,7 +31,7 @@ public partial class ExportCsv { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.DropDownList cboFolders; - + /// /// plFile control. /// @@ -38,7 +40,7 @@ public partial class ExportCsv { /// To modify move field declaration from designer file to code-behind file. /// protected global::DotNetNuke.UI.UserControls.LabelControl plFile; - + /// /// txtFile control. /// @@ -47,7 +49,7 @@ public partial class ExportCsv { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.TextBox txtFile; - + /// /// plDelimiter control. /// @@ -56,7 +58,7 @@ public partial class ExportCsv { /// To modify move field declaration from designer file to code-behind file. /// protected global::DotNetNuke.UI.UserControls.LabelControl plDelimiter; - + /// /// rblDelimiter control. /// @@ -65,7 +67,88 @@ public partial class ExportCsv { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.RadioButtonList rblDelimiter; - + + /// + /// plSystemFields control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plSystemFields; + + /// + /// cbSystemFields control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox cbSystemFields; + + /// + /// plInitialDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plInitialDate; + + /// + /// txtInitialDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtInitialDate; + + /// + /// plFinalDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plFinalDate; + + /// + /// txtFinalDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtFinalDate; + + /// + /// plDatesValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plDatesValidator; + + /// + /// compareValidatorDates control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CompareValidator compareValidatorDates; + + /// + /// CustomValidatorDates control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CustomValidator CustomValidatorDates; + /// /// cmdExport control. /// @@ -74,7 +157,7 @@ public partial class ExportCsv { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.LinkButton cmdExport; - + /// /// cmdCancel control. /// diff --git a/FormAndList.csproj b/FormAndList.csproj index 1f59551..fdfc40f 100644 --- a/FormAndList.csproj +++ b/FormAndList.csproj @@ -364,6 +364,8 @@ + + diff --git a/FormAndList.dnn b/FormAndList.dnn index 12f6664..e2df7d5 100644 --- a/FormAndList.dnn +++ b/FormAndList.dnn @@ -1,14 +1,14 @@  - + Form and List Create a simple form or a view of repetitive and simple data. desktopmodules/userdefinedtable/icon_fnl_32px.gif - DNNCorp - DNNCorp - http://www.dnnsoftware.com - support@dnnsoftware.com + DNN Community + DNN Community + https://dnncommunity.org + @@ -120,6 +120,16 @@ 06.00.06.sqldataprovider 06.00.06 + +