diff --git a/Intacct.SDK.Tests/Intacct.SDK.Tests.csproj b/Intacct.SDK.Tests/Intacct.SDK.Tests.csproj index ba422f68..d0b0c116 100644 --- a/Intacct.SDK.Tests/Intacct.SDK.Tests.csproj +++ b/Intacct.SDK.Tests/Intacct.SDK.Tests.csproj @@ -1,11 +1,11 @@  - net4.6.1;netcoreapp2.1;netcoreapp3.1 + net5.0;net4.6.1;netcoreapp2.1;netcoreapp3.1 false - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Intacct.SDK/Intacct.SDK.csproj b/Intacct.SDK/Intacct.SDK.csproj index 1c9fa37d..f585ba69 100644 --- a/Intacct.SDK/Intacct.SDK.csproj +++ b/Intacct.SDK/Intacct.SDK.csproj @@ -1,8 +1,8 @@  - netstandard2.0 + netstandard2.0;net5.0 Intacct.SDK - 3.0.0 + 3.0.1 intacct Sage Intacct SDK Sage Intacct SDK for .NET @@ -15,11 +15,11 @@ - - - - - + + + + + diff --git a/Intacct.SDK/Xml/IaXmlWriter.cs b/Intacct.SDK/Xml/IaXmlWriter.cs index 5778e6bb..fdf915f3 100644 --- a/Intacct.SDK/Xml/IaXmlWriter.cs +++ b/Intacct.SDK/Xml/IaXmlWriter.cs @@ -1,29 +1,27 @@ /* * Copyright 2020 Sage Intacct, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not - * use this file except in compliance with the License. You may obtain a copy + * use this file except in compliance with the License. You may obtain a copy * of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * or in the "LICENSE" file accompanying this file. This file is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing + * + * or in the "LICENSE" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using System; using System.Collections.Generic; using System.IO; -using System.Text; using System.Xml; namespace Intacct.SDK.Xml { public class IaXmlWriter : XmlWriter { - public const string IntacctDateFormat = "MM/dd/yyyy"; public const string IntacctDateTimeFormat = "MM/dd/yyyy HH:mm:ss"; @@ -31,78 +29,56 @@ public class IaXmlWriter : XmlWriter public const string IntacctMultiSelectGlue = "#~#"; private readonly XmlWriter _writer; - - public override WriteState WriteState => _writer.WriteState; public IaXmlWriter(Stream output, XmlWriterSettings settings) { _writer = Create(output, settings); } + public override WriteState WriteState => _writer.WriteState; - public override void WriteStartDocument() - { - _writer.WriteStartDocument(); - } - - public override void WriteStartDocument(bool standalone) - { - _writer.WriteStartDocument(standalone); - } - - public override void WriteEndDocument() - { - _writer.WriteEndDocument(); - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - _writer.WriteDocType(name, pubid, sysid, subset); - } - - public new void WriteStartElement(string localName) - { - _writer.WriteStartElement(localName); - } - - public new void WriteStartElement(string localName, string ns) - { - _writer.WriteStartElement(localName, ns); - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - _writer.WriteStartElement(prefix, localName, ns); - } - - public override void WriteEndElement() + public override void Flush() { - _writer.WriteEndElement(); + _writer.Flush(); } - public override void WriteFullEndElement() + public override string LookupPrefix(string ns) { - _writer.WriteFullEndElement(); + return _writer.LookupPrefix(ns); } - public new void WriteStartAttribute(string localName) + public void WriteAttribute(string localName, string value, bool writeNull = false) { - _writer.WriteStartAttribute(localName); + if (!string.IsNullOrEmpty(value) || writeNull == true) + { + _writer.WriteAttributeString(localName, value); + } } - public new void WriteStartAttribute(string localName, string ns) + public void WriteAttribute(string localName, int? value, bool writeNull = false) { - _writer.WriteStartAttribute(localName, ns); + if (value == null) + { + if (writeNull == true) + { + _writer.WriteAttributeString(localName, ""); + } + } + else + { + _writer.WriteAttributeString(localName, value.ToString()); + } } - public override void WriteStartAttribute(string prefix, string localName, string ns) + public void WriteAttribute(string localName, bool value) { - _writer.WriteStartAttribute(prefix, localName, ns); + string val = (value == true) ? "true" : "false"; + _writer.WriteAttributeString(localName, val); } - public override void WriteEndAttribute() + public override void WriteBase64(byte[] buffer, int index, int count) { - _writer.WriteEndAttribute(); + _writer.WriteBase64(buffer, index, count); } public override void WriteCData(string text) @@ -110,73 +86,75 @@ public override void WriteCData(string text) _writer.WriteCData(text); } - public override void WriteComment(string text) - { - _writer.WriteComment(text); - } - - public override void WriteProcessingInstruction(string name, string text) - { - _writer.WriteProcessingInstruction(name, text); - } - - public override void WriteEntityRef(string name) - { - _writer.WriteEntityRef(name); - } - public override void WriteCharEntity(char ch) { _writer.WriteCharEntity(ch); } - public override void WriteWhitespace(string ws) + public override void WriteChars(char[] buffer, int index, int count) { - _writer.WriteWhitespace(ws); + _writer.WriteChars(buffer, index, count); } - public override void WriteString(string text) + public override void WriteComment(string text) { - _writer.WriteString(text); + _writer.WriteComment(text); } - public override void WriteSurrogateCharEntity(char lowChar, char highChar) + public void WriteCustomFieldsExplicit(Dictionary customFields) { - _writer.WriteSurrogateCharEntity(lowChar, highChar); - } + if (customFields.Count > 0) + { + WriteStartElement("customfields"); + foreach (KeyValuePair customField in customFields) + { + WriteStartElement("customfield"); + WriteElement("customfieldname", customField.Key, true); - public override void WriteChars(char[] buffer, int index, int count) - { - _writer.WriteChars(buffer, index, count); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - _writer.WriteRaw(buffer, index, count); + if (customField.Value == null) + { + WriteEmptyElement("customfieldvalue"); + } + else + { + WriteElement("customfieldvalue", customField.Value, true); + } + WriteEndElement(); //customfield + } + WriteEndElement(); //customfields + } } - public override void WriteRaw(string data) + public void WriteCustomFieldsImplicit(Dictionary customFields) { - _writer.WriteRaw(data); + if (customFields.Count > 0) + { + foreach (KeyValuePair customField in customFields) + { + if (customField.Value == null) + { + WriteEmptyElement(customField.Key); + } + else + { + WriteElement(customField.Key, customField.Value, true); + } + } + } } - public override void WriteBase64(byte[] buffer, int index, int count) - { - _writer.WriteBase64(buffer, index, count); - } - - public override void Flush() + public void WriteDateSplitElements(DateTime date, bool writeNull = true) { - _writer.Flush(); + WriteElement("year", date.ToString("yyyy"), writeNull); + WriteElement("month", date.ToString("MM"), writeNull); + WriteElement("day", date.ToString("dd"), writeNull); } - public override string LookupPrefix(string ns) + public override void WriteDocType(string name, string pubid, string sysid, string subset) { - return _writer.LookupPrefix(ns); + _writer.WriteDocType(name, pubid, sysid, subset); } - // XML Helper Functions - public void WriteElement(string localName, string value, bool writeNull = false) { if (value == null) @@ -193,6 +171,7 @@ public void WriteElement(string localName, string value, bool writeNull = false) } } + // XML Helper Functions public void WriteElement(string localName, int value) { _writer.WriteElementString(localName, value.ToString()); @@ -257,7 +236,7 @@ public void WriteElement(string localName, bool? value, bool writeNull = false) } } } - + public void WriteElement(string localName, DateTime value, string format = IntacctDateTimeFormat) { _writer.WriteElementString(localName, value == default(DateTime) ? "" : value.ToString(format)); @@ -283,85 +262,100 @@ public void WriteEmptyElement(string localName) _writer.WriteStartElement(localName); _writer.WriteEndElement(); } - - public void WriteAttribute(string localName, string value, bool writeNull = false) + + public override void WriteEndAttribute() { - if (!string.IsNullOrEmpty(value) || writeNull == true) - { + _writer.WriteEndAttribute(); + } - _writer.WriteAttributeString(localName, value); - } + public override void WriteEndDocument() + { + _writer.WriteEndDocument(); } - public void WriteAttribute(string localName, int? value, bool writeNull = false) + public override void WriteEndElement() { - if (value == null) - { - if (writeNull == true) - { - _writer.WriteAttributeString(localName, ""); - } - } - else - { - _writer.WriteAttributeString(localName, value.ToString()); - } + _writer.WriteEndElement(); } - public void WriteAttribute(string localName, bool value) + public override void WriteEntityRef(string name) { - string val = (value == true) ? "true" : "false"; - _writer.WriteAttributeString(localName, val); + _writer.WriteEntityRef(name); } - public void WriteDateSplitElements(DateTime date, bool writeNull = true) + public override void WriteFullEndElement() { - WriteElement("year", date.ToString("yyyy"), writeNull); - WriteElement("month", date.ToString("MM"), writeNull); - WriteElement("day", date.ToString("dd"), writeNull); + _writer.WriteFullEndElement(); } - public void WriteCustomFieldsExplicit(Dictionary customFields) + public override void WriteProcessingInstruction(string name, string text) { - if (customFields.Count > 0) - { - WriteStartElement("customfields"); - foreach (KeyValuePair customField in customFields) - { - WriteStartElement("customfield"); - WriteElement("customfieldname", customField.Key, true); - - if (customField.Value == null) - { - WriteEmptyElement("customfieldvalue"); - } - else - { - WriteElement("customfieldvalue", customField.Value, true); - } - WriteEndElement(); //customfield - } - WriteEndElement(); //customfields - } + _writer.WriteProcessingInstruction(name, text); } - public void WriteCustomFieldsImplicit(Dictionary customFields) + public override void WriteRaw(char[] buffer, int index, int count) { - if (customFields.Count > 0) - { - foreach (KeyValuePair customField in customFields) - { - if (customField.Value == null) - { - WriteEmptyElement(customField.Key); - } - else - { - WriteElement(customField.Key, customField.Value, true); - } - } - } + _writer.WriteRaw(buffer, index, count); + } + + public override void WriteRaw(string data) + { + _writer.WriteRaw(data); + } + + public new void WriteStartAttribute(string localName) + { + _writer.WriteStartAttribute(localName); + } + + public new void WriteStartAttribute(string localName, string ns) + { + _writer.WriteStartAttribute(localName, ns); + } + + public override void WriteStartAttribute(string prefix, string localName, string ns) + { + _writer.WriteStartAttribute(prefix, localName, ns); + } + + public override void WriteStartDocument() + { + _writer.WriteStartDocument(); + } + + public override void WriteStartDocument(bool standalone) + { + _writer.WriteStartDocument(standalone); } + public new void WriteStartElement(string localName) + { + _writer.WriteStartElement(localName); + } + + public new void WriteStartElement(string localName, string ns) + { + _writer.WriteStartElement(localName, ns); + } + + public override void WriteStartElement(string prefix, string localName, string ns) + { + _writer.WriteStartElement(prefix, localName, ns); + } + + public override void WriteString(string text) + { + _writer.WriteString(text); + } + + public override void WriteSurrogateCharEntity(char lowChar, char highChar) + { + _writer.WriteSurrogateCharEntity(lowChar, highChar); + } + + public override void WriteWhitespace(string ws) + { + _writer.WriteWhitespace(ws); + } } } \ No newline at end of file diff --git a/Intacct.SDK/Xml/LoggingHandler.cs b/Intacct.SDK/Xml/LoggingHandler.cs index 0fc85900..8f5e9762 100644 --- a/Intacct.SDK/Xml/LoggingHandler.cs +++ b/Intacct.SDK/Xml/LoggingHandler.cs @@ -1,34 +1,33 @@ /* * Copyright 2020 Sage Intacct, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not - * use this file except in compliance with the License. You may obtain a copy + * use this file except in compliance with the License. You may obtain a copy * of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * or in the "LICENSE" file accompanying this file. This file is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing + * + * or in the "LICENSE" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ +using Intacct.SDK.Logging; +using Microsoft.Extensions.Logging; using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using Intacct.SDK.Logging; -using Microsoft.Extensions.Logging; namespace Intacct.SDK.Xml { public class LoggingHandler : DelegatingHandler { private ILogger _logger; - - private MessageFormatter _logMessageFormatter; - + private LogLevel _logLevel; + private MessageFormatter _logMessageFormatter; public LoggingHandler(HttpMessageHandler innerHandler, ILogger logger, MessageFormatter logMessageFormat, LogLevel logLevel) : base(innerHandler) { @@ -49,11 +48,10 @@ protected override async Task SendAsync(HttpRequestMessage catch (Exception ex) { _logger.Log(_logLevel, ex, _logMessageFormatter.Format(request, response)); - throw ex; + throw; } return response; } - } } \ No newline at end of file