-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/crisfervil/XrmCommandBox
- Loading branch information
Showing
18 changed files
with
430 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="CommandLineParser" version="2.1.1-beta" targetFramework="net46" /> | ||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net46" /> | ||
<package id="CommandLineParser" version="2.3.0" targetFramework="net46" /> | ||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net46" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.CrmSdk.CoreAssemblies" version="8.2.0.2" targetFramework="net461" /> | ||
<package id="Microsoft.IdentityModel" version="6.1.7600.16394" targetFramework="net461" /> | ||
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.CoreAssemblies" version="9.0.2.4" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.Deployment" version="9.0.2.4" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.Workflow" version="9.0.2.4" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.XrmTooling.CoreAssembly" version="9.0.2.5" targetFramework="net461" /> | ||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.22.302111727" targetFramework="net461" /> | ||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<packages> | ||
<package id="FakeItEasy" version="3.2.0" targetFramework="net461" /> | ||
<package id="FakeXrmEasy.365" version="1.36.1" targetFramework="net461" /> | ||
<package id="FakeXrmEasy.9" version="1.47.0" targetFramework="net461" /> | ||
<package id="log4net" version="2.0.8" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.CoreAssemblies" version="8.2.0.2" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.Deployment" version="8.2.0.2" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.Workflow" version="8.2.0.2" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.XrmTooling.CoreAssembly" version="8.2.0.4" targetFramework="net461" /> | ||
<package id="Microsoft.IdentityModel" version="6.1.7600.16394" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.CoreAssemblies" version="9.0.2.4" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.Deployment" version="9.0.2.4" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.Workflow" version="9.0.2.4" targetFramework="net461" /> | ||
<package id="Microsoft.CrmSdk.XrmTooling.CoreAssembly" version="9.0.2.5" targetFramework="net461" /> | ||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.22.302111727" targetFramework="net461" /> | ||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace XrmCommandBox.Data | ||
{ | ||
class DataSetSerializer | ||
{ | ||
public DataSet Deserialize(string file) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using Microsoft.Xrm.Sdk; | ||
using Microsoft.Xrm.Sdk.Metadata; | ||
using Microsoft.Xrm.Sdk.Query; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace XrmCommandBox.Tools.Common | ||
{ | ||
public static class Utilities | ||
{ | ||
internal static Guid? GetExistingRecordId(IOrganizationService service, string entityName, Entity entityRecord, IList<string> matchAttributes, EntityMetadata entityMetadata) | ||
{ | ||
Guid? recordGuid = null; | ||
|
||
var qry = GetMatchQuery(entityName, entityRecord, matchAttributes, entityMetadata); | ||
|
||
var foundRecords = service.RetrieveMultiple(qry); | ||
|
||
if (foundRecords.Entities.Count > 0) | ||
{ | ||
if (foundRecords.Entities.Count > 1) | ||
throw new Exception("Too many records found"); | ||
|
||
recordGuid = foundRecords.Entities[0].Id; | ||
} | ||
|
||
return recordGuid; | ||
} | ||
|
||
private static QueryBase GetMatchQuery(string entityName, Entity entityRecord, IList<string> matchAttributes, EntityMetadata entityMetadata) | ||
{ | ||
if (matchAttributes == null || matchAttributes.Count == 0) | ||
{ | ||
// set the id attribute as match attribute | ||
var attrId = entityMetadata.PrimaryIdAttribute; | ||
|
||
matchAttributes = new[] { attrId }; | ||
} | ||
|
||
var qry = new QueryByAttribute | ||
{ | ||
EntityName = entityName, | ||
ColumnSet = new ColumnSet(entityMetadata.PrimaryIdAttribute) | ||
}; | ||
|
||
qry.Attributes.AddRange(matchAttributes); | ||
|
||
foreach (var attrName in matchAttributes) | ||
{ | ||
var filterAttrValue = entityRecord.Contains(attrName) ? GetFilterValue(entityRecord[attrName]) : null; | ||
qry.Values.Add(filterAttrValue); | ||
} | ||
|
||
return qry; | ||
} | ||
|
||
private static object GetFilterValue(object attributeValue) | ||
{ | ||
var filterValue = attributeValue; | ||
|
||
if (attributeValue is EntityReference) | ||
{ | ||
var attrValueReference = (EntityReference)attributeValue; | ||
filterValue = attrValueReference.Id; | ||
} | ||
else if (attributeValue is OptionSetValue) | ||
{ | ||
var attrValueOptionset = (OptionSetValue)attributeValue; | ||
filterValue = attrValueOptionset.Value; | ||
} | ||
|
||
return filterValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace XrmCommandBox.Tools.DataLoader | ||
{ | ||
public class ColumnMappingOptions | ||
{ | ||
} | ||
} |
Oops, something went wrong.