Skip to content

Commit

Permalink
Refresh UI for Flow, updated features. Fixed #844 #843 #842
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Jan 27, 2023
1 parent 407c754 commit c9734a6
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 159 deletions.
20 changes: 18 additions & 2 deletions FetchXmlBuilder/Converters/ODataCodeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Microsoft.Xrm.Sdk.Metadata;
using MarkMpn.FetchXmlToWebAPI;
using McTools.Xrm.Connection;
using Microsoft.Xrm.Sdk.Metadata;
using Rappen.XTB.FetchXmlBuilder.AppCode;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -8,12 +11,25 @@ namespace Rappen.XTB.FetchXmlBuilder.Converters
{
public class ODataCodeGenerator
{
public static string GetODataQuery(FetchType fetch, string organizationServiceUrl, FetchXmlBuilder sender)
public static string ConvertToOData4(string fetchxml, FetchXmlBuilder fxb)
{
// Find correct WebAPI base url
var baseUrl = fxb.ConnectionDetail.WebApplicationUrl;
if (!baseUrl.EndsWith("/"))
baseUrl += "/";
var url = new Uri(new Uri(baseUrl), $"api/data/v{fxb.ConnectionDetail.OrganizationMajorVersion}.{fxb.ConnectionDetail.OrganizationMinorVersion}");
var converter = new FetchXmlToWebAPIConverter(new WebAPIMetadataProvider(fxb), url.ToString());
var odata4 = converter.ConvertFetchXmlToWebAPI(fetchxml);
return odata4;
}

public static string ConvertToOData2(FetchType fetch, FetchXmlBuilder sender)
{
if (sender.Service == null)
{
throw new Exception("Must have an active connection to CRM to compose OData query.");
}
var organizationServiceUrl = sender.ConnectionDetail.OrganizationDataServiceUrl;
var url = organizationServiceUrl;
var entity = fetch.Items.Where(i => i is FetchEntityType).FirstOrDefault() as FetchEntityType;
if (entity == null)
Expand Down
Loading

0 comments on commit c9734a6

Please sign in to comment.