Skip to content

Commit

Permalink
Added support for long-term retention data
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Jul 29, 2023
1 parent a772747 commit b68d47c
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 4 deletions.
13 changes: 13 additions & 0 deletions FetchXmlBuilder/Builder/Validations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ private static ControlValidationResult ValidateFetch(TreeNode node, FetchXmlBuil
{
return new ControlValidationResult(ControlValidationLevel.Error, "Missing entity under the fetch.");
}
if (!string.IsNullOrWhiteSpace(node.Value("datasource")) && node.Value("datasource") != "archive")
{
return new ControlValidationResult(ControlValidationLevel.Error, "Invalid data source value");
}
if (node.Value("datasource") == "archive" && node.IsFetchAggregate())
{
return new ControlValidationResult(ControlValidationLevel.Error, "Aggregate queries cannot use Long Term Retention data", "https://learn.microsoft.com/en-us/power-apps/maker/data-platform/data-retention-view#limitations-for-retrieval-of-retained-data");
}
return null;
}

Expand All @@ -63,6 +71,11 @@ private static ControlValidationResult ValidateEntity(TreeNode node, FetchXmlBui

private static ControlValidationResult ValidateLinkEntity(TreeNode node, FetchXmlBuilder fxb)
{
if (node.TreeView.Nodes[0].Value("datasource") == "archive")
{
return new ControlValidationResult(ControlValidationLevel.Error, "Link-Entity cannot be used with Long Term Retention data", "https://learn.microsoft.com/en-us/power-apps/maker/data-platform/data-retention-view#limitations-for-retrieval-of-retained-data");
}

var name = node.Value("name");
if (string.IsNullOrWhiteSpace(name) ||
string.IsNullOrWhiteSpace(node.Value("to")) ||
Expand Down
48 changes: 47 additions & 1 deletion FetchXmlBuilder/Controls/fetchControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions FetchXmlBuilder/Controls/fetchControl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Rappen.XTB.FetchXmlBuilder.DockControls;
using Rappen.XTB.XmlEditorUtils;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
Expand All @@ -7,6 +8,28 @@ namespace Rappen.XTB.FetchXmlBuilder.Controls
{
public partial class fetchControl : FetchXmlElementControlBase
{
class DataSourceItem : IComboBoxItem
{
private readonly string _value;
private readonly string _name;

public DataSourceItem(string value, string name)
{
_value = value;
_name = name;
}

public string GetValue()
{
return _value;
}

public override string ToString()
{
return _name;
}
}

public fetchControl() : this(null, null, null)
{
}
Expand All @@ -17,6 +40,14 @@ public fetchControl(Dictionary<string, string> collection, FetchXmlBuilder fetch
InitializeFXB(collection, fetchXmlBuilder, tree, null);
}

protected override void PopulateControls()
{
base.PopulateControls();

dataSourceComboBox.Items.Add(new DataSourceItem("", "Live"));
dataSourceComboBox.Items.Add(new DataSourceItem("archive", "Long Term Retention"));
}

private void textPagingCookie_Leave(object sender, EventArgs e)
{
textPagingCookie.Text = textPagingCookie.Text.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&quot;", "\"");
Expand Down
15 changes: 12 additions & 3 deletions FetchXmlBuilder/Controls/fetchControl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EwAACxMBAJqcGAAAAMNJREFUKFNjcKzZ/l8ucysYT1259/+BAwcYQFgpGyKGjK0rt/9n0Mzf9j+odef/
EAAACxABrSO9dQAAAMNJREFUKFNjcKzZ/l8ucysYT1259/+BAwcYQFgpGyKGjK0rt/9n0Mzf9j+odef/
lgV7/m/Yvh+uoW3hHrAYCDvVAhVGbv4PMgSsoWLmbrhCdFwze/d/tpjN/13qdhDWAFPcPH/P/4Z5e/Br
qEZSDOLj1YCuGIRBbC2gWgwN2BQjYxQNhBSDMFzDnn0H/qvmbgUHIzaFa7ft/z9p+V5UJ+3dfwCnySie
9mrY8b9sxm682L8ZGg/ejTv+axdsIwq71e34DwDIiV/OjEilhQAAAABJRU5ErkJggg==
Expand All @@ -130,7 +130,7 @@
<data name="pictureBox2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EwAACxMBAJqcGAAAAMNJREFUKFNjcKzZ/l8ucysYT1259/+BAwcYQFgpGyKGjK0rt/9n0Mzf9j+odef/
EAAACxABrSO9dQAAAMNJREFUKFNjcKzZ/l8ucysYT1259/+BAwcYQFgpGyKGjK0rt/9n0Mzf9j+odef/
lgV7/m/Yvh+uoW3hHrAYCDvVAhVGbv4PMgSsoWLmbrhCdFwze/d/tpjN/13qdhDWAFPcPH/P/4Z5e/Br
qEZSDOLj1YCuGIRBbC2gWgwN2BQjYxQNhBSDMFzDnn0H/qvmbgUHIzaFa7ft/z9p+V5UJ+3dfwCnySie
9mrY8b9sxm682L8ZGg/ejTv+axdsIwq71e34DwDIiV/OjEilhQAAAABJRU5ErkJggg==
Expand All @@ -139,7 +139,16 @@
<data name="pictureBox3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EwAACxMBAJqcGAAAAMNJREFUKFNjcKzZ/l8ucysYT1259/+BAwcYQFgpGyKGjK0rt/9n0Mzf9j+odef/
EAAACxABrSO9dQAAAMNJREFUKFNjcKzZ/l8ucysYT1259/+BAwcYQFgpGyKGjK0rt/9n0Mzf9j+odef/
lgV7/m/Yvh+uoW3hHrAYCDvVAhVGbv4PMgSsoWLmbrhCdFwze/d/tpjN/13qdhDWAFPcPH/P/4Z5e/Br
qEZSDOLj1YCuGIRBbC2gWgwN2BQjYxQNhBSDMFzDnn0H/qvmbgUHIzaFa7ft/z9p+V5UJ+3dfwCnySie
9mrY8b9sxm682L8ZGg/ejTv+axdsIwq71e34DwDIiV/OjEilhQAAAABJRU5ErkJggg==
</value>
</data>
<data name="pictureBox4.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DwAACw8BkvkDpQAAAMNJREFUKFNjcKzZ/l8ucysYT1259/+BAwcYQFgpGyKGjK0rt/9n0Mzf9j+odef/
lgV7/m/Yvh+uoW3hHrAYCDvVAhVGbv4PMgSsoWLmbrhCdFwze/d/tpjN/13qdhDWAFPcPH/P/4Z5e/Br
qEZSDOLj1YCuGIRBbC2gWgwN2BQjYxQNhBSDMFzDnn0H/qvmbgUHIzaFa7ft/z9p+V5UJ+3dfwCnySie
9mrY8b9sxm682L8ZGg/ejTv+axdsIwq71e34DwDIiV/OjEilhQAAAABJRU5ErkJggg==
Expand Down
1 change: 1 addition & 0 deletions FetchXmlBuilder/DockControls/XmlContentControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ private void InitIntellisense()
_autocomplete.AddMemberDescription<FetchType>(nameof(FetchType.pagingcookie), "Paging Cookie", "The paging cookie returned with the previous page of results. Supplying this value makes it more efficient to retrieve the next page.");
_autocomplete.AddMemberDescription<FetchType>(nameof(FetchType.returntotalrecordcount), "Return Total Record Count", "Indicates if the total number of possible results should be returned along with this page of results.");
_autocomplete.AddMemberDescription<FetchType>(nameof(FetchType.top), "Top Count", "The maximum number of records to return. No further pages of data will be returned.");
_autocomplete.AddMemberDescription<FetchType>(nameof(FetchType.datasource), "Data Source", "Set to 'archive' to access Long Term Retention data, or leave blank to access live data.");

_autocomplete.AddTypeDescription<FetchEntityType>("Main Entity", "Gives the name of the entity type the query will return.");
_autocomplete.AddMemberDescription<FetchEntityType>(nameof(FetchEntityType.enableprefiltering), "Enable Prefiltering", "If this query is being used in an SSRS report, indicates if the report can be pre-filtered by the user selecting the records to run it on.");
Expand Down
1 change: 1 addition & 0 deletions FetchXmlBuilder/FetchXmlBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
<Compile Include="ControlsClasses\EntityNameItem.cs" />
<Compile Include="Extensions\Extensions.cs" />
<Compile Include="Extensions\GroupBoxExpanderExtensions.cs" />
<Compile Include="Resources\FetchExtensions.cs" />
<Compile Include="Settings\FXBConnectionSettings.cs" />
<Compile Include="FXBGui.cs">
<SubType>UserControl</SubType>
Expand Down
14 changes: 14 additions & 0 deletions FetchXmlBuilder/Resources/FetchExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rappen.XTB.FetchXmlBuilder
{
partial class FetchType
{
[System.Xml.Serialization.XmlAttributeAttribute()]
public string datasource;
}
}

0 comments on commit b68d47c

Please sign in to comment.