Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Edit-In Excel] Improve metadata handling #1721

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace System.Integration.Excel;

using System;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using System.Environment;

using System.Integration;

/// <summary>
Expand All @@ -14,6 +15,42 @@
{
Access = Public;

procedure CreateMetadataWebRequest()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats with this procedure?
Does nothing? Init local variable and one declared variable not used.

var
EnvironmentInfo: Codeunit "Environment Information";

Check failure on line 20 in src/System Application/App/Edit in Excel/src/EditInExcel.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application (Clean) / System Application (Clean)

AL0185 Codeunit 'Environment Information' is missing

Check failure on line 20 in src/System Application/App/Edit in Excel/src/EditInExcel.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application (Translated) / System Application (Translated)

AL0185 Codeunit 'Environment Information' is missing

Check failure on line 20 in src/System Application/App/Edit in Excel/src/EditInExcel.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application (Default) / System Application (Default)

AL0185 Codeunit 'Environment Information' is missing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be name space using System.Environment;

Token: Text;
begin
Token := 'herpderp';


end;

procedure IsMetadataGeneratedForWebService(): Boolean
var
HttpClient: HttpClient;
HttpResponseMessage: HttpResponseMessage;
MetadataUrl: Text;
EntitySetXml: Text;
Document: DotNet XmlDocument;
NodeList: DotNet XmlNodeList;
NameSpaceManager: DotNet XmlNamespaceManager;
EntitySetName: Text;
begin
MetadataUrl := 'https://metadatastoragexyz.blob.core.windows.net/metadata/metadata.xml?sp=r&st=2024-08-02T09:38:22Z&se=2024-08-02T17:38:22Z&spr=https&sv=2022-11-02&sr=b&sig=eP4pvx1m1OiiGVhYVD4haMIYvSgOAWIUysk3mD7h8Ds%3D';
EntitySetName := 'Company';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this necessary as variable, could be hardcoded with //edm:EntitySet[@name="

if HttpClient.Get(MetadataUrl, HttpResponseMessage) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need any authentication?
image

if HttpResponseMessage.IsSuccessStatusCode then begin
HttpResponseMessage.Content().ReadAs(EntitySetXml);
Document := Document.XmlDocument();
Document.LoadXml(EntitySetXml);
NameSpaceManager := NameSpaceManager.XmlNamespaceManager(Document.NameTable());
NameSpaceManager.AddNamespace('edm', 'http://docs.oasis-open.org/odata/ns/edm');
NodeList := Document.SelectNodes('//edm:EntitySet[@Name="' + EntitySetName + '"]', NameSpaceManager);
exit(NodeList.Count() > 0);
end;
exit(false);
end;

#if not CLEAN22
/// <summary>
/// Creates web service for the specified page, and uses the web service to prepare and download an Excel file for the Edit in Excel functionality.
Expand Down
Loading