diff --git a/Pipefy.csproj b/Pipefy.csproj new file mode 100644 index 0000000..0854537 --- /dev/null +++ b/Pipefy.csproj @@ -0,0 +1,14 @@ + + + + Exe + net7.0-windows + enable + enable + + + + + + + diff --git a/Pipefy.sln b/Pipefy.sln new file mode 100644 index 0000000..1972409 --- /dev/null +++ b/Pipefy.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34221.43 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pipefy", "Pipefy.csproj", "{23715724-86C9-4C02-8A4A-E3A348A1135E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {23715724-86C9-4C02-8A4A-E3A348A1135E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23715724-86C9-4C02-8A4A-E3A348A1135E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23715724-86C9-4C02-8A4A-E3A348A1135E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23715724-86C9-4C02-8A4A-E3A348A1135E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E7708A1F-F545-4539-979D-AC1EBCFFB1F2} + EndGlobalSection +EndGlobal diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..3dfd0a3 --- /dev/null +++ b/Program.cs @@ -0,0 +1,79 @@ +using System; +using System.Data.OleDb; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading.Tasks; + +class Program +{ + static async Task Main(string[] args) + { + // URL da API que você deseja chamar + string apiUrl = "https://api.pipefy.com/graphql"; + + // Crie uma instância HttpClient + using (HttpClient httpClient = new HttpClient()) + { + // Defina os headers da requisição (opcional) + httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); + httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJQaXBlZnkiLCJpYXQiOjE2OTg4NTYyMjcsImp0aSI6IjM2N2Y4M2NhLWZjODYtNGRhOC04ODEyLTkzODRkZGZkODc0MiIsInN1YiI6MzAyNTM0MzY2LCJ1c2VyIjp7ImlkIjozMDI1MzQzNjYsImVtYWlsIjoiYmFjazVAZW5lcmdpYXNtYXJ0LmNvbS5iciIsImFwcGxpY2F0aW9uIjozMDAyODkyNDgsInNjb3BlcyI6W119LCJpbnRlcmZhY2VfdXVpZCI6bnVsbH0.o13j9c_y3G3HX35qhX4PmkkibGsmlHsk5dL_Bxsr1CKV5Jlgj218kJdEmriS7aHiw0-P7sfs-bu4YcElfuyiqg"); + + // Crie a consulta GraphQL + string query = /*lang=json,strict*/ @" + { + ""query"":""{\r\n table_records(table_id: \""b9t-7uD5\"") {\r\n edges {\r\n node {\r\n id\r\n record_fields{\r\n value\r\n }\r\n }\r\n }\r\n }\r\n}"",""variables"":{} + }"; + + // Defina o conteúdo do corpo da requisição + var content = new StringContent(query, System.Text.Encoding.UTF8, "application/json"); + + // Envie a requisição POST com a consulta GraphQL + var response = await httpClient.PostAsync(apiUrl, content); + + if (response.IsSuccessStatusCode) + { + string responseBody = await response.Content.ReadAsStringAsync(); + Console.WriteLine("Resposta bem-sucedida:"); + Console.WriteLine(responseBody); + + // Agora você pode comparar a resposta JSON com a tabela no banco de dados Access + CompareResponseWithDatabase(responseBody); + } + else + { + Console.WriteLine($"Erro na requisição: {response.StatusCode}"); + } + } + } + static void CompareResponseWithDatabase(string jsonResponse) + { + // Defina a string de conexão para o banco de dados Access + string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\contratos\Documents\Giuliano\Pipefy.accdb"; + + using (OleDbConnection connection = new OleDbConnection(connectionString)) + { + connection.Open(); + + // Execute uma consulta SQL para recuperar dados da tabela no banco de dados Access + string sqlQuery = "SELECT * FROM tblEmpresas"; + using (OleDbCommand command = new OleDbCommand(sqlQuery, connection)) + { + using (OleDbDataReader reader = command.ExecuteReader()) + { + while (reader.Read()) + { + // Compare os dados da resposta JSON com os dados da tabela + // Você pode usar a biblioteca Newtonsoft.Json para desserializar o JSON + // e comparar os valores desejados com os valores do banco de dados + // Por exemplo: + // string valueFromDatabase = reader["NomeDaColuna"].ToString(); + // string valueFromJSON = JsonConvert.DeserializeObject(jsonResponse).YourProperty; + + // Realize as comparações aqui e tome as ações necessárias + } + } + } + } + } +}