Codeunit 9043 ABS Helper Library in 26
- App
- System Application
- Namespace
- System.Azure.Storage
Versions171819202122232425262728latest
Source in 26
src/System Application/App/Azure Blob Services API/src/Helper/ABSHelperLibrary.Codeunit.al211 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace System.Azure.Storage;
using System.Reflection;
codeunit 9043 "ABS Helper Library"
{
Access = Internal;
InherentEntitlements = X;
InherentPermissions = X;
Permissions = tabledata Field = r;
// #region Container-specific Helper
procedure ContainerNodeListTotempRecord(NodeList: XmlNodeList; var ABSContainer: Record "ABS Container")
begin
NodeListToTempRecord(NodeList, './/Name', ABSContainer);
end;
procedure CreateContainerNodeListFromResponse(ResponseAsText: Text): XmlNodeList
begin
exit(CreateXPathNodeListFromResponse(ResponseAsText, '/*/Containers/Container'));
end;
// #endregion
procedure PageRangesResultToDictionairy(Document: XmlDocument; var PageRanges: Dictionary of [Integer, Integer])
var
NodeList: XmlNodeList;
Node: XmlNode;
StartRange: Integer;
EndRange: Integer;
begin
NodeList := CreatePageRangesNodeListFromResponse(Document);
if NodeList.Count = 0 then
exit;
foreach Node in NodeList do begin
Evaluate(StartRange, GetValueFromNode(Node, 'Start'));
Evaluate(EndRange, GetValueFromNode(Node, 'End'));
PageRanges.Add(StartRange, EndRange);
end;
end;
procedure CreatePageRangesNodeListFromResponse(Document: XmlDocument): XmlNodeList
begin
exit(CreateXPathNodeListFromResponse(Document, '/*/PageRange'));
end;
procedure BlockListResultToDictionary(Document: XmlDocument; var CommitedBlocks: Dictionary of [Text, Integer]; var UncommitedBlocks: Dictionary of [Text, Integer])
var
NodeList: XmlNodeList;
Node: XmlNode;
NameValue: Text;
SizeValue: Integer;
begin
NodeList := CreateBlockListCommitedNodeListFromResponse(Document);
if NodeList.Count > 0 then
foreach Node in NodeList do begin
Evaluate(NameValue, GetValueFromNode(Node, 'Name'));
Evaluate(SizeValue, GetValueFromNode(Node, 'Size'));
CommitedBlocks.Add(NameValue, SizeValue);
end;
NodeList := CreateBlockListUncommitedNodeListFromResponse(Document);
if NodeList.Count > 0 then
foreach Node in NodeList do begin
Evaluate(NameValue, GetValueFromNode(Node, 'Name'));
Evaluate(SizeValue, GetValueFromNode(Node, 'Size'));
UncommitedBlocks.Add(NameValue, SizeValue);
end;
end;
procedure CreateBlockListCommitedNodeListFromResponse(Document: XmlDocument): XmlNodeList
begin
exit(CreateXPathNodeListFromResponse(Document, '/*/CommittedBlocks/Block'));
end;
procedure CreateBlockListUncommitedNodeListFromResponse(Document: XmlDocument): XmlNodeList
begin
exit(CreateXPathNodeListFromResponse(Document, '/*/UncommittedBlocks/Block'));
end;
// #region Blob-specific Helper
procedure CreateBlobNodeListFromResponse(ResponseAsText: Text; var NextMarker: Text): XmlNodeList
var
XmlDoc: XmlDocument;
Node: XmlNode;
NodeList: XmlNodeList;
begin
Clear(NextMarker);
GetXmlDocumentFromResponse(XmlDoc, ResponseAsText);
if XmlDoc.SelectSingleNode('//NextMarker', Node) then
NextMarker := Node.AsXmlElement().InnerText;
XmlDoc.SelectNodes('//Blobs/Blob', NodeList);
exit(NodeList);
end;
procedure BlobNodeListToTempRecord(NodeList: XmlNodeList)
var
ABSContainerContent: Record "ABS Container Content";
begin
BlobNodeListToTempRecord(NodeList, ABSContainerContent);
end;
procedure BlobNodeListToTempRecord(NodeList: XmlNodeList; var ABSContainerContent: Record "ABS Container Content")
begin
NodeListToTempRecord(NodeList, './/Name', ABSContainerContent);
end;
procedure BlobNodeListToBlobList(NodeList: XmlNodeList; var BlobList: Dictionary of [Text, XmlNode])
var
Name, Node : XmlNode;
begin
foreach Node in NodeList do begin
Node.SelectSingleNode('Name', Name);
BlobList.Add(Name.AsXmlElement().InnerText, Node);
end;
end;
// #endregion
// #region XML Helper
local procedure GetXmlDocumentFromResponse(var Document: XmlDocument; ResponseAsText: Text)
var
ReadingAsXmlErr: Label 'Error reading Response as XML.';
begin
if not XmlDocument.ReadFrom(ResponseAsText, Document) then
Error(ReadingAsXmlErr);
end;
local procedure CreateXPathNodeListFromResponse(ResponseAsText: Text; XPath: Text): XmlNodeList
var
Document: XmlDocument;
RootNode: XmlElement;
NodeList: XmlNodeList;
begin
GetXmlDocumentFromResponse(Document, ResponseAsText);
Document.GetRoot(RootNode);
RootNode.SelectNodes(XPath, NodeList);
exit(NodeList);
end;
local procedure CreateXPathNodeListFromResponse(Document: XmlDocument; XPath: Text): XmlNodeList
var
RootNode: XmlElement;
NodeList: XmlNodeList;
begin
Document.GetRoot(RootNode);
RootNode.SelectNodes(XPath, NodeList);
exit(NodeList);
end;
procedure GetValueFromNode(Node: XmlNode; XPath: Text): Text
var
Node2: XmlNode;
Value: Text;
begin
Node.SelectSingleNode(XPath, Node2);
Value := Node2.AsXmlElement().InnerText();
exit(Value);
end;
local procedure NodeListToTempRecord(NodeList: XmlNodeList; XPathName: Text; var ABSContainerContent: Record "ABS Container Content")
var
ABSContainerContentHelper: Codeunit "ABS Container Content Helper";
Node: XmlNode;
EntryNo: Integer;
begin
ABSContainerContent.Reset();
ABSContainerContent.DeleteAll();
if NodeList.Count = 0 then
exit;
foreach Node in NodeList do
ABSContainerContentHelper.AddNewEntryFromNode(ABSContainerContent, Node, XPathName, EntryNo);
end;
local procedure NodeListToTempRecord(NodeList: XmlNodeList; XPathName: Text; var ABSContainer: Record "ABS Container")
var
ContainerHelper: Codeunit "ABS Container Helper";
Node: XmlNode;
begin
ABSContainer.DeleteAll();
if NodeList.Count = 0 then
exit;
foreach Node in NodeList do
ContainerHelper.AddNewEntryFromNode(ABSContainer, Node, XPathName);
end;
// #endregion
// #region Format Helper
procedure GetFieldByName(TableNo: Integer; FieldCaption: Text; var FieldNo: Integer): Boolean
var
Field: Record Field;
begin
Clear(FieldNo);
Field.Reset();
Field.SetRange(TableNo, TableNo);
Field.SetRange("Field Caption", CopyStr(FieldCaption, 1, MaxStrLen(Field.FieldName)));
if Field.FindFirst() then
FieldNo := Field."No.";
exit(FieldNo <> 0);
end;
// #endregion
}Procedures, 13
| Name | Parameters | Returns | Access | Obsolete |
|---|---|---|---|---|
| ContainerNodeListTotempRecord | (XmlNodeList, var Record ABS Container) | public | - | |
| CreateContainerNodeListFromResponse | (Text) | XmlNodeList | public | - |
| PageRangesResultToDictionairy | (XmlDocument, var Dictionary) | public | - | |
| CreatePageRangesNodeListFromResponse | (XmlDocument) | XmlNodeList | public | - |
| BlockListResultToDictionary | (XmlDocument, var Dictionary, var Dictionary) | public | - | |
| CreateBlockListCommitedNodeListFromResponse | (XmlDocument) | XmlNodeList | public | - |
| CreateBlockListUncommitedNodeListFromResponse | (XmlDocument) | XmlNodeList | public | - |
| BlobNodeListToTempRecord | (XmlNodeList) | public | - | |
| BlobNodeListToTempRecord | (XmlNodeList, var Record ABS Container Content) | public | - | |
| GetValueFromNode | (XmlNode, Text) | Text | public | - |
| GetFieldByName | (Integer, Text, var Integer) | Boolean | public | - |
| CreateBlobNodeListFromResponse | (Text, var Text) | XmlNodeList | public | - |
| BlobNodeListToBlobList | (XmlNodeList, var Dictionary) | public | - |