Skip to content

Commit

Permalink
Renamn it på XRMTokensRun
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Jul 13, 2021
1 parent 3e3543f commit 21e314a
Show file tree
Hide file tree
Showing 12 changed files with 1,063 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Rappen.XTB.Helper"]
path = Rappen.XTB.Helper
url = https://github.com/rappen/Rappen.XTB.Helper
1 change: 1 addition & 0 deletions Rappen.XTB.Helper
Submodule Rappen.XTB.Helper added at c6365f
30 changes: 30 additions & 0 deletions XRMTokensRun.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31129.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XRMTokensRun", "XRMTokensRun\XRMTokensRun.csproj", "{731361BE-5619-4E95-A472-9C6F9B6ECB73}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Rappen.XTB.Helpers", "Rappen.XTB.Helper\Rappen.XTB.Helpers.shproj", "{0B88B381-EE9D-41E8-A62C-90152C42DE90}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Rappen.XTB.Helper\Rappen.XTB.Helpers.projitems*{0b88b381-ee9d-41e8-a62c-90152c42de90}*SharedItemsImports = 13
Rappen.XTB.Helper\Rappen.XTB.Helpers.projitems*{731361be-5619-4e95-a472-9c6f9b6ecb73}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{731361BE-5619-4E95-A472-9C6F9B6ECB73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{731361BE-5619-4E95-A472-9C6F9B6ECB73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{731361BE-5619-4E95-A472-9C6F9B6ECB73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{731361BE-5619-4E95-A472-9C6F9B6ECB73}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7F79F08B-8027-4C05-840D-812701497308}
EndGlobalSection
EndGlobal
36 changes: 36 additions & 0 deletions XRMTokensRun/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("XRM Tokens Run")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("XRMTokensRun")]
[assembly: AssemblyCopyright("Copyright © Jonas Rapp 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("731361be-5619-4e95-a472-9c6f9b6ecb73")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
19 changes: 19 additions & 0 deletions XRMTokensRun/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XRMTokensRun
{
/// <summary>
/// This class can help you to store settings for your plugin
/// </summary>
/// <remarks>
/// This class must be XML serializable
/// </remarks>
public class Settings
{
public string LastUsedOrganizationWebappUrl { get; set; }
}
}
128 changes: 128 additions & 0 deletions XRMTokensRun/XRMTR.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using McTools.Xrm.Connection;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Rappen.XTB.Helpers;
using Rappen.XTB.Helpers.Controls;
using Rappen.XTB.Helpers.Extensions;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using XrmToolBox.Extensibility;

namespace XRMTokensRun
{
public partial class XRMTR : PluginControlBase
{
private Settings mySettings;

public XRMTR()
{
InitializeComponent();

btnGetRecord.BackColor = Color.White;
}

private void MyPluginControl_Load(object sender, EventArgs e)
{
if (!SettingsManager.Instance.TryLoad(GetType(), out mySettings))
{
mySettings = new Settings();
}
}

/// <summary>
/// This event occurs when the plugin is closed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MyPluginControl_OnCloseTool(object sender, EventArgs e)
{
// Before leaving, save the settings
SettingsManager.Instance.Save(GetType(), mySettings);
}

/// <summary>
/// This event occurs when the connection has been updated in XrmToolBox
/// </summary>
public override void UpdateConnection(IOrganizationService newService, ConnectionDetail detail, string actionName, object parameter)
{
base.UpdateConnection(newService, detail, actionName, parameter);

if (mySettings != null && detail != null)
{
mySettings.LastUsedOrganizationWebappUrl = detail.WebApplicationUrl;
LogInfo("Connection has changed to: {0}", detail.WebApplicationUrl);
}

if (newService == null)
{
tableselect.DataSource = null;
}
else
{
tableselect.DataSource = newService.LoadEntities().EntityMetadata;
}
record.Service = newService;
}

private void tableselect_SelectedIndexChanged(object sender, EventArgs e)
{
var entity = tableselect.SelectedEntity;
btnGetRecord.Enabled = entity != null;
}

private void button1_Click(object sender, EventArgs e)
{
var look = new XRMLookupDialog
{
Service = Service,
LogicalName = tableselect.SelectedEntity.LogicalName
};
if (look.ShowDialog() == DialogResult.OK)
{
record.Record = look.Record;
ShowColumns();
}
}

private void btnResult_Click(object sender, EventArgs e)
{
txtTokensOut.Text = record.Record.Substitute(Service, txtTokensIn.Text);
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://jonasr.app/xrm-tokens/");
}

private void toolStripLabel1_Click(object sender, EventArgs e)
{
Process.Start("https://jonasr.app/xrm-tokens/");
}

private void btnReload_Click(object sender, EventArgs e)
{
var rec = Service.Retrieve(record.Record.LogicalName, record.Record.Id, new ColumnSet(true));
record.Record = null;
record.Record = rec;
ShowColumns();
}

private void ShowColumns()
{
lstRecord.Items.Clear();
lstRecord.Items.AddRange(record.Record.Attributes.Keys.Select(k => new ListViewItem(k)).ToArray());
}

private void lstRecord_DoubleClick(object sender, EventArgs e)
{
if (lstRecord.SelectedItems == null)
{
return;
}
txtTokensIn.Text += "{" + lstRecord.SelectedItems[0].Text + "}";
}
}
}
Loading

0 comments on commit 21e314a

Please sign in to comment.