Unable to load solution content in Visual Studio 2022
Windows 10
After updating Visual Studio you are no longer able to load source files in your solution
The update has messed up you path settings as you have both 64bit and 32bit version of dotnet running
In the environment settings / system variables move the <drive>\program files\dotnet 64bit path above the <drive>\program files (x86)\dotnet 32bit path
Save and you are ready to use VS 2022 after having updated the platform to latest version
Open Control panel -> System and the Advanced System Settings

Choose Environment Variables

In System Variables edit the Path settings

Move the 64 bit dotnet path above the 32bit path

When done click Ok and restart VS 2022

C# .NET Core 6: Get rootname, namespace or DTD using xmlreader
using (var stream = new MemoryStream())
{
FormFile?.CopyTo(stream);
stream.Seek(0, SeekOrigin.Begin);
var settings = new XmlReaderSettings()
{
// Parse file but do not reolve
DtdProcessing = DtdProcessing.Parse,
XmlResolver = null
};
using (var reader = XmlReader.Create(stream, settings))
{
var done = false;
while (reader.Read() && !done)
{
// something weird happened, bail out
//if (reader.EOF)
// return;
switch (reader.NodeType)
{
// Assume cXML
case XmlNodeType.DocumentType:
DocumentType = reader.GetAttribute("SYSTEM") + "";
break;
case XmlNodeType.Element:
switch (reader.LocalName)
{
// Assume an UBL dpcument of some kind
case "CustomizationID":
reader.Read();
SetCustomization(reader.Value);
break;
// Only OIOUBL, done and exit
case "UBLlVersionID":
reader.Read();
UblVersion = reader.Value;
done = true;
break;
// Only OIOXML, done and exit
case "TypeCode":
reader.Read();
TypeCode = reader.Value;
done = true;
break;
default:
if (string.IsNullOrEmpty(RootName))
{
RootName = reader.Name;
SetNamespace(reader.NamespaceURI);
}
break;
}
break;
}
}
reader.Close();
}
}
Validate EDI (XML, Edifact and Ansi X12)
Functionality
- Multiupload
- No data is stored on the server
- MIME type is detected based on file content
- It is possible to upload without file extensiom
- All other files than text (edifact / ansi x12) or xml are skipped / not supported
- Validate structure (eg schema validation)
- Validate business logic (eg schematron validation)
- XSLT Styling, readable document in HTML
- Calculate content and compare with values in eg an invoice
Milestones
- Multiupload based on Dropzone JS: https://www.dropzone.dev/
- Implemented Mime-Detective in class factory: https://github.com/MediatedCommunications/Mime-Detective
- Prepared and created concept to post files several times from Dropzone JS queue
- Upload to local client (browser)
- Send file content to server to either
- Check and validate content
- Check business logic
- Style document
- Calculate prices and compare with document values
- Use RaspConfiguration (Converted to JSON)
- Detect document type to prepare for XSD (logic) and Schematron (business) validation
- LINQ lookup to get correct DocumentTypeConfig
- Schema validation with PSVI
Current task
- Cookie consent
- AntiforgeyTokens
- To scope the project only a few XML and EDIFACT versions will be implemented
- OIOUBL (danish adaption of the UBL standard)
- Peppol BIS
- Standard eg EDIFACT D96 are considere in a limited version as a start as a proof of concept
- cXML and xCBL are a possibility
- Store messages in memory cache from validation methods and display in popup
- XSLT transformations uses SaxonHE
- All stylesheet versions are suported
- Included stylesheets or XML documents are supported
Release
- WIP
- June 23: Only local test / development atm, date for a first beta release not estimated
To do list for project:
Antiforgery: https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/preventing-cross-site-request-forgery-csrf-attacks
Use local postman for testing?
Unit test
Check for vulnerability
GDPR
Information or questions: Please contact plykkegaard at gmail dot com
An utility to retrieve current year
This is a procedure to use in Seeburger BIC Mapping Designer
/* -----------------------------
Peter Lykkegaard, 25 apr 2023
-----------------------------
procedure getCurrentYear
Parameters:
None
Output
Numeric
Adapted from a question on the stackoverflow
https://stackoverflow.com/questions/9243578/java-util-date-and-getyear
----------------------------- */
#importJavaStart
import static java.time.Year.now;
#importJavaEnd
local output%;
#javaStart
Integer output = now().getValue();
_NumVar_OUTPUT.setNum(output);
#javaEnd
exitProc(output%);
An utility to decode or unescape HTML characters in XML (EDI) documents
This is a procedure to use in Seeburger BIC Mapping Designer
It will extend your library for string handling
/* -----------------------------
Peter Lykkegaard, 25 apr 2023
-----------------------------
procedure unescapeHTML
Parameters:
Source / String, alphanumeric
Output
String, alphanumericString
Adapted from How to Unescape HTML in Java using Plain Java
https://howtodoinjava.com/java/string/unescape-html-to-string/
----------------------------- */
local lvOutput$;
#importJavaStart
import java.util.HashMap;
#importJavaEnd
// Save source in case changes are not needed
copy pSource$ to lvOutput$;
// Check for any ampersand / & character
if (containsSubstring(pSource$, "&") != 0)
if (containsSubstring(pSource$, "&") != 0)
// HTML decode ampersand / &
copy replaceAll(pSource$, "&", "&") to pSource$;
endif
#javastart
int i, j;
boolean continueLoop;
int skip = 0;
HashMap<String, String> htmlEntities = new HashMap<String, String>();
htmlEntities.put("<", "<");
htmlEntities.put(">", ">");
htmlEntities.put("&", "&");
htmlEntities.put(""", "\"");
htmlEntities.put(" ", " ");
htmlEntities.put("©", "\u00a9");
htmlEntities.put("®", "\u00ae");
htmlEntities.put("€", "\u20a0");
htmlEntities.put("Å", "Å");
htmlEntities.put("Æ", "Æ");
htmlEntities.put("Ø", "Ø");
htmlEntities.put("å", "å");
htmlEntities.put("æ", "æ");
htmlEntities.put("ø", "ø");
String source = _StrVar_PSOURCE.getString();
do {
continueLoop = false;
i = source.indexOf("&", skip);
if (i > -1) {
j = source.indexOf(";", i);
if (j > i) {
String entityToLookFor = source.substring(i, j + 1);
String value = (String) htmlEntities.get(entityToLookFor);
if (value != null) {
source = source.substring(0, i) + value + source.substring(j + 1);
continueLoop = true;
} else if (value == null) {
skip = i + 1;
continueLoop = true;
}
}
}
} while (continueLoop);
_StrVar_LVOUTPUT.setString(source);
#javaend
endif
exitProc(lvOutput$);