Removendo métodos assincronos
This commit is contained in:
parent
b65d42e0de
commit
a7b176ae12
@ -12,7 +12,7 @@ public class Program
|
||||
|
||||
private static HttpClient httpClient = new HttpClient();
|
||||
|
||||
public static async Task Main()
|
||||
public static void Main()
|
||||
{
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
@ -21,15 +21,15 @@ public class Program
|
||||
DirectoryInfo pasta = new DirectoryInfo(@"X:\Middle\Carteira " + i + @"\Carteira " + i + "." + j + @"\Faturas fourdocs\1 - INDIVIDUAIS");
|
||||
DirectoryInfo pasta_agrupadas = new DirectoryInfo(@"X:\Middle\Carteira " + i + @"\Carteira " + i + "." + j + @"\Faturas fourdocs\2 - AGRUPADAS");
|
||||
|
||||
if (LerPasta(pasta, agrupada: false).Result)
|
||||
if (LerPasta(pasta, agrupada: false))
|
||||
{
|
||||
await LerPasta(pasta_agrupadas, agrupada: true);
|
||||
LerPasta(pasta_agrupadas, agrupada: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> LerPasta(DirectoryInfo pasta, bool agrupada)
|
||||
public static bool LerPasta(DirectoryInfo pasta, bool agrupada)
|
||||
{
|
||||
if (pasta.Exists)
|
||||
{
|
||||
@ -43,8 +43,8 @@ public class Program
|
||||
{
|
||||
if (!IsFileLocked(fatura))
|
||||
{
|
||||
HttpResponseMessage response = await SendFatura(token, fatura.FullName, agrupada);
|
||||
if ((int)response.StatusCode == 202)
|
||||
HttpResponseMessage response = SendFatura(token, fatura.FullName, agrupada);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var iD = JsonDocument.Parse(response.Content.ReadAsStringAsync().Result).RootElement.GetProperty("requestId");
|
||||
fatura.MoveTo(fatura.Directory?.Parent?.FullName + $@"\3 - PROCESSANDO\{iD} - " + fatura.Name);
|
||||
@ -65,7 +65,7 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<string?> ReqToken()
|
||||
public static string? ReqToken()
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.4docs.cloud/v2/oauth2/token");
|
||||
|
||||
@ -75,12 +75,12 @@ public class Program
|
||||
request.Content = new StringContent("grant_type=client_credentials");
|
||||
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/x-www-form-urlencoded");
|
||||
|
||||
var response = await httpClient.SendAsync(request);
|
||||
var response = httpClient.Send(request);
|
||||
|
||||
return JsonDocument.Parse(response.Content.ReadAsStringAsync().Result).RootElement.GetProperty("access_token").GetString();
|
||||
}
|
||||
|
||||
public static async Task<HttpResponseMessage> SendFatura(string token, string fatura, bool agrupada)
|
||||
public static HttpResponseMessage SendFatura(string token, string fatura, bool agrupada)
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.4docs.cloud/v2/parse");
|
||||
|
||||
@ -96,7 +96,7 @@ public class Program
|
||||
|
||||
request.Content = multipartContent;
|
||||
|
||||
return await httpClient.SendAsync(request);
|
||||
return httpClient.Send(request);
|
||||
}
|
||||
|
||||
public static bool IsFileLocked(FileInfo file)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user