Skip to content

Commit

Permalink
Updated from master
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Jan 6, 2024
1 parent 2b774bd commit 7230318
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 178 deletions.
24 changes: 12 additions & 12 deletions BulkDataUpdater.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
<iconUrl>https://raw.githubusercontent.com/rappen/BulkDataUpdater/master/images/BDU-150-tsp.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
Work with any number of rows in Microsoft Dataverse! Update Column values / Assign / Set State / Delete.
Empower yourself to achieve more.
This tool is useful to trigger workflows or plugins, as well as bulk updating any number of records with fixed values.
It can also delete, assign, and set state of records by the filter specified.
Updating values can also be calculated - using "XRM Tokens" (just Bing it!) and even more - using the Microsoft Power Fx!
Work with any number of rows in Microsoft Dataverse! Update Column values / Assign / Set State / Delete.
Empower yourself to achieve more.
This tool is useful to trigger workflows or plugins, as well as bulk updating any number of records with fixed values.
It can also delete, assign, and set state of records by the filter specified.
Updating values can also be calculated - using "XRM Tokens" (just Bing it!) and even more - using the Microsoft Power Fx!

Read more: https://jonasr.app/BDU and https://jonasr.app/xrm-tokens/
Read more: https://jonasr.app/BDU and https://jonasr.app/xrm-tokens/
</description>
<summary>Work with any number of rows in Microsoft Dataverse! Update Column values / Assign / Set State / Delete. Empower yourself to achieve more.</summary>
<releaseNotes>
!STOP THE PRESSES!
Bulk Data Updater supports Microsoft Power Fx calculations!
Now works well with newest version of XrmToolBox!
See https://jonasr.app/missing-xrmtoolbox-pluginsstore/

See latest release notes, and all history:
https://jonasr.app/bdu/releases/#$versionnumber$
See latest release notes, and all history:
https://jonasr.app/bdu/releases/#$versionnumber$
</releaseNotes>
<copyright>Copyright 2016-2022 Jonas Rapp</copyright>
<copyright>Copyright 2016-2023 Jonas Rapp</copyright>
<tags>XrmToolBox Plugins BulkDataUpdater</tags>
<dependencies>
<dependency id="XrmToolBox" version="1.2022.11.59" />
<dependency id="XrmToolBox" version="1.2023.10.67" />
</dependencies>
</metadata>
<files>
Expand Down
13 changes: 4 additions & 9 deletions BulkDataUpdater/AppCode/BDUAssign.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Cinteros.XTB.BulkDataUpdater.AppCode;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using Rappen.XRM.Helpers.Extensions;
using System;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.Windows.Forms;
using XrmToolBox.Extensibility;

Expand Down Expand Up @@ -102,15 +102,10 @@ private void AssignRecords()
if (batch.Requests.Count == executeoptions.BatchSize || current == total)
{
bgworker.ReportProgress(pct, $"Assigning records {current - batch.Requests.Count + 1}-{current} of {total}");
var response = (ExecuteMultipleResponse)Service.Execute(batch);
if (response.IsFaulted && !executeoptions.IgnoreErrors)
var response = Service.Execute(batch) as ExecuteMultipleResponse;
if (!executeoptions.IgnoreErrors && response?.IsFaulted == true)
{
var firsterror = response.Responses.First(r => r.Fault != null);
if (firsterror != null)
{
throw new Exception(firsterror.Fault.Message);
}
throw new Exception("Unknown exception during assignment");
throw new FaultException<OrganizationServiceFault>(response.Responses.FirstOrDefault(r => r.Fault != null).Fault);
}
assigned += response.Responses.Count;
batch.Requests.Clear();
Expand Down
12 changes: 4 additions & 8 deletions BulkDataUpdater/AppCode/BDUDelete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.Windows.Forms;
using XrmToolBox.Extensibility;

Expand Down Expand Up @@ -76,15 +77,10 @@ private void DeleteRecords()
if (batch.Requests.Count == executeoptions.BatchSize || current == total)
{
bgworker.ReportProgress(pct, $"Deleting records {current - batch.Requests.Count + 1}-{current} of {total}");
var response = (ExecuteMultipleResponse)Service.Execute(batch);
if (response.IsFaulted && !executeoptions.IgnoreErrors)
var response = Service.Execute(batch) as ExecuteMultipleResponse;
if (!executeoptions.IgnoreErrors && response?.IsFaulted == true)
{
var firsterror = response.Responses.First(r => r.Fault != null);
if (firsterror != null)
{
throw new Exception(firsterror.Fault.Message);
}
throw new Exception("Unknown exception during delete");
throw new FaultException<OrganizationServiceFault>(response.Responses.FirstOrDefault(r => r.Fault != null).Fault);
}
deleted += batch.Requests.Count - response.Responses.Count(r => r.Fault != null);
batch.Requests.Clear();
Expand Down
13 changes: 11 additions & 2 deletions BulkDataUpdater/AppCode/BDUGeneral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,17 @@ private void RetrieveRecords()
}
else if (!completedargs.Cancelled && completedargs.Result is EntityCollection result)
{
records = result;
fetchResulCount = records.Entities.Count;
if (result.Entities.Any(e => e.Id.Equals(Guid.Empty)))
{
MessageBox.Show("There are records without an ID, and those records cannot be updated.\r\n\r\nThis is probably because of two things:\r\nRetrieved with a distinct flag, and the ID attribute is not included.\r\n\r\nPlease fix either issue.", "Missing Id", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
records = null;
crmGridView1.DataSource = null;
}
else
{
records = result;
fetchResulCount = records.Entities.Count;
}
}
RetrieveRecordsReady();
},
Expand Down
12 changes: 4 additions & 8 deletions BulkDataUpdater/AppCode/BDUSetState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.Windows.Forms;
using XrmToolBox.Extensibility;

Expand Down Expand Up @@ -86,15 +87,10 @@ private void SetStateRecords()
if (batch.Requests.Count == executeoptions.BatchSize || current == total)
{
bgworker.ReportProgress(pct, $"Setting status for records {current - batch.Requests.Count + 1}-{current} of {total}");
var response = (ExecuteMultipleResponse)Service.Execute(batch);
if (response.IsFaulted && !executeoptions.IgnoreErrors)
var response = Service.Execute(batch) as ExecuteMultipleResponse;
if (!executeoptions.IgnoreErrors && response?.IsFaulted == true)
{
var firsterror = response.Responses.First(r => r.Fault != null);
if (firsterror != null)
{
throw new Exception(firsterror.Fault.Message);
}
throw new Exception("Unknown exception during assignment");
throw new FaultException<OrganizationServiceFault>(response.Responses.FirstOrDefault(r => r.Fault != null).Fault);
}
updated += response.Responses.Count;
batch.Requests.Clear();
Expand Down
3 changes: 2 additions & 1 deletion BulkDataUpdater/AppCode/BDUUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.Windows.Forms;
using XrmToolBox.Extensibility;

Expand Down Expand Up @@ -150,7 +151,7 @@ private void UpdateRecords()
catch (Exception ex)
{
failed++;
if (!chkIgnoreErrors.Checked)
if (!executeoptions.IgnoreErrors)
{
throw ex;
}
Expand Down
Loading

0 comments on commit 7230318

Please sign in to comment.