Skip to content

Commit

Permalink
Here and there fixes... 🙄
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed May 14, 2024
1 parent 41f714a commit e52387e
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 161 deletions.
83 changes: 2 additions & 81 deletions BulkDataUpdater/BDU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,6 @@ public override void ClosingPlugin(PluginCloseInfo info)
LogUse("Close", ai2: true);
}

public string GetFullWebApplicationUrl()
{
var url = ConnectionDetail.WebApplicationUrl;
if (string.IsNullOrEmpty(url))
{
url = ConnectionDetail.ServerName;
}
if (!url.ToLower().StartsWith("http"))
{
url = string.Concat("http://", url);
}
var uri = new Uri(url);
if (!uri.Host.EndsWith(".dynamics.com"))
{
if (string.IsNullOrEmpty(uri.AbsolutePath.Trim('/')))
{
uri = new Uri(uri, ConnectionDetail.Organization);
}
}
return uri.ToString();
}

#endregion Public Methods

#region Internal Methods
Expand Down Expand Up @@ -437,7 +415,7 @@ private void LoadGlobalSetting()
// Reset some settings when new version is deployed
globalsettings.CurrentVersion = version;
SettingsManager.Instance.Save(typeof(BulkDataUpdater), globalsettings, "[Global]");
UrlUtils.OpenUrl($"https://jonasr.app/BDU/releases/#{version}");
Process.Start($"https://jonasr.app/BDU/releases/#{version}");
}
}

Expand Down Expand Up @@ -547,56 +525,6 @@ private void UpdateIncludeCount()
txtDeleteWarning.Text = deleteWarningText.Replace("[nn]", rbIncludeSelected.Checked ? count.ToString() : "ALL");
}

private string GetEntityUrl(Entity entity)
{
var entref = entity.ToEntityReference();
switch (entref.LogicalName)
{
case "activitypointer":
if (!entity.Contains("activitytypecode"))
{
MessageBox.Show("To open records of type activitypointer, attribute 'activitytypecode' must be included in the query.", "Open Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
entref.LogicalName = string.Empty;
}
else
{
entref.LogicalName = entity["activitytypecode"].ToString();
}
break;

case "activityparty":
if (!entity.Contains("partyid"))
{
MessageBox.Show("To open records of type activityparty, attribute 'partyid' must be included in the query.", "Open Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
entref.LogicalName = string.Empty;
}
else
{
var party = (EntityReference)entity["partyid"];
entref.LogicalName = party.LogicalName;
entref.Id = party.Id;
}
break;
}
return GetEntityReferenceUrl(entref);
}

private string GetEntityReferenceUrl(EntityReference entref)
{
if (!string.IsNullOrEmpty(entref.LogicalName) && !entref.Id.Equals(Guid.Empty))
{
var url = GetFullWebApplicationUrl();
url = string.Concat(url,
url.EndsWith("/") ? "" : "/",
"main.aspx?etn=",
entref.LogicalName,
"&pagetype=entityrecord&id=",
entref.Id.ToString());
return url;
}
return string.Empty;
}

private void AfterEntitiesLoaded(IEnumerable<EntityMetadata> metadatas, bool forcereload)
{
entities = metadatas?.ToList();
Expand Down Expand Up @@ -754,14 +682,7 @@ private void tsbFriendly_Click(object sender, EventArgs e)

private void crmGridView1_RecordDoubleClick(object sender, Rappen.XTB.Helpers.Controls.XRMRecordEventArgs e)
{
if (e.Entity != null)
{
string url = GetEntityUrl(e.Entity);
if (!string.IsNullOrEmpty(url))
{
ConnectionDetail.OpenUrlWithBrowserProfile(new Uri(url));
}
}
UrlUtils.OpenUrl(e, ConnectionDetail);
}

private void btnAssignSelect_Click(object sender, EventArgs e)
Expand Down
86 changes: 38 additions & 48 deletions BulkDataUpdater/Forms/Execute.Designer.cs

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

Loading

0 comments on commit e52387e

Please sign in to comment.