diff --git a/.DS_Store b/.DS_Store index 309e92a..4b38849 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..46b8601 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceRoot}/WebApi/SyonOnline.WebApi/bin/Debug/netcoreapp1.1/SyonOnline.WebApi.dll", + "args": [], + "cwd": "${workspaceRoot}/WebApi/SyonOnline.WebApi", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart", + "launchBrowser": { + "enabled": true, + "args": "${auto-detect-url}", + "windows": { + "command": "cmd.exe", + "args": "/C start ${auto-detect-url}" + }, + "osx": { + "command": "open" + }, + "linux": { + "command": "xdg-open" + } + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceRoot}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..f678aa5 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "0.1.0", + "command": "dotnet", + "isShellCommand": true, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ + "${workspaceRoot}/WebApi/SyonOnline.WebApi/SyonOnline.WebApi.csproj" + ], + "isBuildCommand": true, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/ServiceReference/SyonOnline.ServiceFacade/Class1.cs b/ServiceReference/SyonOnline.ServiceFacade/Interface/IServiceFacade.cs similarity index 52% rename from ServiceReference/SyonOnline.ServiceFacade/Class1.cs rename to ServiceReference/SyonOnline.ServiceFacade/Interface/IServiceFacade.cs index 78716a8..6708010 100644 --- a/ServiceReference/SyonOnline.ServiceFacade/Class1.cs +++ b/ServiceReference/SyonOnline.ServiceFacade/Interface/IServiceFacade.cs @@ -3,12 +3,9 @@ using System.Linq; using System.Threading.Tasks; -namespace SyonOnline.ServiceFacade +namespace SyonOnline.ServiceFacade.Interface { - public class Class1 + public interface IServiceFacade { - public Class1() - { - } } } diff --git a/ServiceReference/SyonOnline.ServiceFacade/SyonOnline.ServiceFacade.csproj b/ServiceReference/SyonOnline.ServiceFacade/SyonOnline.ServiceFacade.csproj index b77376f..952e369 100755 --- a/ServiceReference/SyonOnline.ServiceFacade/SyonOnline.ServiceFacade.csproj +++ b/ServiceReference/SyonOnline.ServiceFacade/SyonOnline.ServiceFacade.csproj @@ -1,11 +1,13 @@ - - + + - netstandard1.6 + netstandard1.1 SyonOnline.ServiceFacade SyonOnline.ServiceFacade - 1.6.0 $(PackageTargetFallback);dnxcore50 - - + + + + + \ No newline at end of file diff --git a/ServiceReference/SyonOnline.ServiceFacade/Util.cs b/ServiceReference/SyonOnline.ServiceFacade/Util.cs new file mode 100644 index 0000000..bd83eb1 --- /dev/null +++ b/ServiceReference/SyonOnline.ServiceFacade/Util.cs @@ -0,0 +1,203 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Text; +using System.Runtime.Serialization; +using System.IO; +using System.Xml; +using System.Net; +using System.Xml.Serialization; +using SyonOnline.ServiceFacade.Interface; +using System.Net.Http; + +//using System.Web.Services.Protocols; + +namespace SyonOnline.ServiceFacade +{ + public class Util + { + /* + private static readonly string testarNaUrl2 = ConfigurationManager.AppSettings["testarNaUrl2"]; + + private static readonly string urlAdquirencia = ConfigurationManager.AppSettings["urlAdquirencia"]; + private static readonly string urlAdquirenciaV2 = ConfigurationManager.AppSettings["urlAdquirenciaV2"]; + private static readonly string urlDatacash = ConfigurationManager.AppSettings["urlDatacash"]; + private static readonly string urlKomerci = ConfigurationManager.AppSettings["urlKomerci"]; + + private static readonly string url2Adquirencia = ConfigurationManager.AppSettings["url2Adquirencia"]; + private static readonly string url2AdquirenciaV2 = ConfigurationManager.AppSettings["url2AdquirenciaV2"]; + private static readonly string url2Datacash = ConfigurationManager.AppSettings["url2Datacash"]; + private static readonly string url2Komerci = ConfigurationManager.AppSettings["url2Komerci"]; + + public static string GetUrlAdquirencia() + { + if (testarNaUrl2 == "0") + { + return urlAdquirencia; + } + + return url2Adquirencia; + } + + public static string GetUrlAdquirenciaV2() + { + if (testarNaUrl2 == "0") + { + return urlAdquirenciaV2; + } + + return url2AdquirenciaV2; + } + + public static string GetUrlDatacash() + { + if (testarNaUrl2 == "0") + { + return urlDatacash; + } + + return url2Datacash; + } + + public static string GetUrlKomerci() + { + if (testarNaUrl2 == "0") + { + return urlKomerci; + } + + return url2Komerci; + } + */ + public static T Deserialize(string xml) + { + XmlSerializer serializer = new XmlSerializer(typeof(T)); + T result; + using (TextReader reader = new StringReader(xml)) + { + result = (T)serializer.Deserialize(reader); + } + + return result; + } + + public static string Serialize(T request) + { + XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces(); + xmlSerializerNamespaces.Add("", ""); + + XmlSerializer xsSubmit = new XmlSerializer(typeof(T)); + var subReq = request; + var xml = ""; + + using (var sww = new StringWriter()) + { + using (XmlWriter writer = XmlWriter.Create(sww, new XmlWriterSettings { OmitXmlDeclaration = true })) + { + xsSubmit.Serialize(writer, subReq, xmlSerializerNamespaces); + xml = sww.ToString(); // Your XML + } + } + + return xml; + } + + /* public static string PostXMLData(string destinationUrl, string requestXml, IServiceFacade service) + { + var horaInicial = DateTime.Now; + + new HttpClient().PostAsync(destinationUrl, ); + + WebRequest request = (WebRequest)WebRequest.Create(destinationUrl); + byte[] bytes; + bytes = Encoding.ASCII.GetBytes(requestXml); + request.ContentType = "text/xml; encoding='utf-8'"; + request.ContentLength = bytes.Length; + request.Method = "POST"; + Stream requestStream = request.GetRequestStream(); + requestStream.Write(bytes, 0, bytes.Length); + requestStream.Close(); + HttpWebResponse response; + + Util.SaveXmlRequest(requestXml, service.GetTestId(), service.GetMethodName()); + + response = (HttpWebResponse)request.GetResponse(); + + if (response.StatusCode == HttpStatusCode.OK) + { + Stream responseStream = response.GetResponseStream(); + string responseStr = new StreamReader(responseStream).ReadToEnd(); + + Util.SaveXmlResponse(responseStr, horaInicial, service.GetTestId(), service.GetMethodName()); + + return responseStr; + } + + return null; + } + + public static void SaveXmlResponse(string xml, DateTime horaInicial, string testId, string methodName) + { + Warning.SecondsExecution = (DateTime.Now - horaInicial).TotalSeconds; + + Console.WriteLine(string.Format("Tempo : {0}", Warning.SecondsExecution)); + + SaveXml(xml, "Response", testId, methodName); + } + + public static void SaveXmlRequest(string xml, string testId, string methodName) + { + SaveXml(xml, "Request", testId, methodName); + } + + private static void SaveXml(string xml, string type, string testId, string methodName) + { + var baseDirectory = System.AppDomain.CurrentDomain.BaseDirectory; + + var testResults = Path.Combine(baseDirectory, "Test Results"); + + Directory.CreateDirectory(testResults); + + var fullName = GetNextFileName(Path.Combine(testResults, string.Concat(testId, "-", type, "-", methodName, ".xml"))); + + File.WriteAllText(fullName, xml); + } + + private static string GetNextFileName(string fileName) + { + string extension = Path.GetExtension(fileName); + + int i = 0; + while (File.Exists(fileName)) + { + if (i == 0) + fileName = fileName.Replace(extension, "(" + ++i + ")" + extension); + else + fileName = fileName.Replace("(" + i + ")" + extension, "(" + ++i + ")" + extension); + } + + return fileName; + } + + public static string GetUrlService(object type, object service) where TServiceFacase : IServiceFacade + { + var url = string.Empty; + + url = ((IServiceFacade)type).GetUrl(); + + if (string.IsNullOrEmpty(url) && service != null) + { + url = ((SoapHttpClientProtocol)service).Url; + } + + Console.WriteLine(string.Format("Data Hora : {0}", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"))); + + Console.WriteLine(string.Format("URL Serviço : {0}", url)); + + return url; + } + */ + } + +} diff --git a/ServiceReference/SyonOnline.ServiceFacade/WebReferences/Adquirencia/References.cs b/ServiceReference/SyonOnline.ServiceFacade/WebReferences/Adquirencia/References.cs new file mode 100644 index 0000000..26b34bf --- /dev/null +++ b/ServiceReference/SyonOnline.ServiceFacade/WebReferences/Adquirencia/References.cs @@ -0,0 +1,9 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SyonOnline.ServiceFacade.WebReferences.Adquirencia +{ + +} diff --git a/Test/SyonOnline.Test/.gitignore b/Test/SyonOnline.Test/.gitignore new file mode 100644 index 0000000..1b86e7e --- /dev/null +++ b/Test/SyonOnline.Test/.gitignore @@ -0,0 +1,268 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/ diff --git a/Test/SyonOnline.Test/SyonOnline.ServiceFacade/Util.cs b/Test/SyonOnline.Test/SyonOnline.ServiceFacade/Util.cs new file mode 100644 index 0000000..fb2e321 --- /dev/null +++ b/Test/SyonOnline.Test/SyonOnline.ServiceFacade/Util.cs @@ -0,0 +1,30 @@ +using Xunit; + +namespace SyonOnline.Test.SyonOnline.ServiceFacade +{ + public class Util + { + [Fact] + public void Deserialize_XmlVariable_Class() + { + //Arrange + + //Act + + //Assert + + } + + [Fact] + public void Serialize_ClassVariable_Xml() + { + //Arrange + + //Act + + //Assert + + } + + } +} diff --git a/Test/SyonOnline.Test/SyonOnline.Test.csproj b/Test/SyonOnline.Test/SyonOnline.Test.csproj new file mode 100755 index 0000000..d23e21f --- /dev/null +++ b/Test/SyonOnline.Test/SyonOnline.Test.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp1.0 + SyonOnline.Test + SyonOnline.Test + true + 1.1.1 + + + + + PreserveNewest + + + + + + + + + + + diff --git a/Test/SyonOnline.Test/xunit.runner.json b/Test/SyonOnline.Test/xunit.runner.json new file mode 100644 index 0000000..6b3f1f8 --- /dev/null +++ b/Test/SyonOnline.Test/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "diagnosticMessages": false, + "methodDisplay": "classAndMethod", + "parallelizeTestCollections": true +} diff --git a/WebApi/SyonOnline.WebApi/.vscode/launch.json b/WebApi/SyonOnline.WebApi/.vscode/launch.json index 430e39d..a068ea8 100644 --- a/WebApi/SyonOnline.WebApi/.vscode/launch.json +++ b/WebApi/SyonOnline.WebApi/.vscode/launch.json @@ -6,7 +6,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/SyonOnline.dll", + "program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/SyonOnline.WebApi.dll", "args": [], "cwd": "${workspaceRoot}", "stopAtEntry": false, diff --git a/WebApi/SyonOnline.WebApi/Controllers/ValuesController.cs b/WebApi/SyonOnline.WebApi/Controllers/ValuesController.cs index e710718..daa3e19 100644 --- a/WebApi/SyonOnline.WebApi/Controllers/ValuesController.cs +++ b/WebApi/SyonOnline.WebApi/Controllers/ValuesController.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -namespace SyonOnline.Controllers +namespace SyonOnline.WebApi.Controllers { [Route("api/[controller]")] public class ValuesController : Controller @@ -13,6 +13,8 @@ public class ValuesController : Controller [HttpGet] public IEnumerable Get() { + var t = System.Net.HttpWebRequest.Create(""); + return new string[] { "value1", "value2" }; } diff --git a/WebApi/SyonOnline.WebApi/Program.cs b/WebApi/SyonOnline.WebApi/Program.cs index 61f9f18..e9ab34f 100644 --- a/WebApi/SyonOnline.WebApi/Program.cs +++ b/WebApi/SyonOnline.WebApi/Program.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; -namespace SyonOnline +namespace SyonOnline.WebApi { public class Program { diff --git a/WebApi/SyonOnline.WebApi/Startup.cs b/WebApi/SyonOnline.WebApi/Startup.cs index 3a3d63d..7a7c7a9 100644 --- a/WebApi/SyonOnline.WebApi/Startup.cs +++ b/WebApi/SyonOnline.WebApi/Startup.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace SyonOnline +namespace SyonOnline.WebApi { public class Startup { diff --git a/WebApi/SyonOnline.WebApi/WebApi.csproj b/WebApi/SyonOnline.WebApi/SyonOnline.WebApi.csproj similarity index 94% rename from WebApi/SyonOnline.WebApi/WebApi.csproj rename to WebApi/SyonOnline.WebApi/SyonOnline.WebApi.csproj index a8d1625..04509f7 100644 --- a/WebApi/SyonOnline.WebApi/WebApi.csproj +++ b/WebApi/SyonOnline.WebApi/SyonOnline.WebApi.csproj @@ -3,9 +3,9 @@ netcoreapp1.1 true - SyonOnline + SyonOnline.WebApi Exe - SyonOnline + SyonOnline.WebApi 1.1.1 $(PackageTargetFallback);dotnet5.6;portable-net45+win8