Skip to content

Commit

Permalink
Merge pull request #619 from MarkMpn/repeatedvalidation
Browse files Browse the repository at this point in the history
Reduced calls to Validate while loading
  • Loading branch information
rappen committed Jan 16, 2022
2 parents eadfa83 + 5fa9aa3 commit 4b31c22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 1 addition & 2 deletions FetchXmlBuilder/DockControls/TreeBuilderControl.cs
Expand Up @@ -347,7 +347,6 @@ internal void UpdateCurrentNode()
internal void UpdateChildNode(TreeNode node)
{
TreeNodeHelper.SetNodeText(node, fxb);
node.Nodes.OfType<TreeNode>().ToList().ForEach(n => TreeNodeHelper.SetNodeText(n, fxb));
node.Nodes.OfType<TreeNode>().ToList().ForEach(n => UpdateChildNode(n));
}

Expand Down Expand Up @@ -431,7 +430,7 @@ private void DisplayDefinition(XmlDocument fetchDoc)
{
var entitys = TreeNodeHelper.GetEntitysForFetch(fetchDoc);
entitys = entitys?.Where(e => !string.IsNullOrEmpty(e) && fxb.entities.ContainsKey(e) && fxb.entities[e].Attributes == null)?.ToList();
entitys?.ForEach(e => fxb.LoadEntityDetails(e, null, false));
entitys?.ForEach(e => fxb.LoadEntityDetails(e, null, false, false));
}
XmlNode definitionXmlNode = fetchDoc.DocumentElement;
var selected = tvFetch.SelectedNode;
Expand Down
18 changes: 11 additions & 7 deletions FetchXmlBuilder/FetchXmlBuilder.cs
Expand Up @@ -664,7 +664,7 @@ internal string GetOData(int version)
}
}

internal void LoadEntityDetails(string entityName, Action detailsLoaded, bool async = true)
internal void LoadEntityDetails(string entityName, Action detailsLoaded, bool async = true, bool update = true)
{
if (detailsLoaded != null && !async)
{
Expand All @@ -682,7 +682,7 @@ internal void LoadEntityDetails(string entityName, Action detailsLoaded, bool as
{
PostWorkCallBack = (completedargs) =>
{
LoadEntityDetailsCompleted(entityName, completedargs.Error == null ? completedargs.Result as EntityMetadata : null, completedargs.Error);
LoadEntityDetailsCompleted(entityName, completedargs.Error == null ? completedargs.Result as EntityMetadata : null, completedargs.Error, update);
if (completedargs.Error == null && detailsLoaded != null)
{
detailsLoaded();
Expand All @@ -695,11 +695,11 @@ internal void LoadEntityDetails(string entityName, Action detailsLoaded, bool as
try
{
var resp = MetadataExtensions.LoadEntityDetails(Service, entityName);
LoadEntityDetailsCompleted(entityName, resp, null);
LoadEntityDetailsCompleted(entityName, resp, null, update);
}
catch (Exception e)
{
LoadEntityDetailsCompleted(entityName, null, e);
LoadEntityDetailsCompleted(entityName, null, e, update);
}
}
}
Expand Down Expand Up @@ -1220,7 +1220,7 @@ private void LoadEntities()
});
}

private void LoadEntityDetailsCompleted(string entityName, EntityMetadata Result, Exception Error)
private void LoadEntityDetailsCompleted(string entityName, EntityMetadata Result, Exception Error, bool update)
{
if (Error != null)
{
Expand All @@ -1246,8 +1246,12 @@ private void LoadEntityDetailsCompleted(string entityName, EntityMetadata Result
MessageBox.Show("Metadata not found for entity " + entityName, "Load attribute metadata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
working = false;
dockControlBuilder.UpdateAllNode();
UpdateLiveXML();

if (update)
{
dockControlBuilder.UpdateAllNode();
UpdateLiveXML();
}
}
working = false;
}
Expand Down

0 comments on commit 4b31c22

Please sign in to comment.