Skip to content

Commit

Permalink
Atualizações
Browse files Browse the repository at this point in the history
  • Loading branch information
govinda777 committed Jun 7, 2017
1 parent c7fbaf3 commit 3f774b8
Show file tree
Hide file tree
Showing 16 changed files with 619 additions and 17 deletions.
Binary file modified .DS_Store
Binary file not shown.
46 changes: 46 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
]
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<TargetFramework>netstandard1.1</TargetFramework>
<AssemblyName>SyonOnline.ServiceFacade</AssemblyName>
<PackageId>SyonOnline.ServiceFacade</PackageId>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
</PropertyGroup>

</Project>
<ItemGroup>
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0"/>
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0"/>
</ItemGroup>
</Project>
203 changes: 203 additions & 0 deletions ServiceReference/SyonOnline.ServiceFacade/Util.cs
Original file line number Diff line number Diff line change
@@ -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<T>(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>(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<TServiceFacase, TService>(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;
}
*/
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SyonOnline.ServiceFacade.WebReferences.Adquirencia
{

}
Loading

0 comments on commit 3f774b8

Please sign in to comment.