From b238bbe353a78b5947affe7604ab54bd7ecb204b Mon Sep 17 00:00:00 2001 From: giuliano Date: Tue, 21 Nov 2023 18:10:38 -0300 Subject: [PATCH] =?UTF-8?q?20231121=20-=20cria=C3=A7=C3=A3o=20dos=20segred?= =?UTF-8?q?os=20do=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pipefy.csproj | 5 ++++- Program.cs | 38 ++++++++++++++++++---------------- Properties/launchSettings.json | 7 +++++++ appsetings.json | 6 ++++++ data.cs | 18 ++++++++-------- 5 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 Properties/launchSettings.json create mode 100644 appsetings.json diff --git a/Pipefy.csproj b/Pipefy.csproj index 8ee7526..8e417aa 100644 --- a/Pipefy.csproj +++ b/Pipefy.csproj @@ -5,11 +5,14 @@ net7.0-windows enable enable + 1b2d76eb-7ab5-428f-9f67-13b6bf96375d + + - + diff --git a/Program.cs b/Program.cs index 8e67cdd..9b04171 100644 --- a/Program.cs +++ b/Program.cs @@ -4,27 +4,30 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Text.Json; using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System.Collections.Generic; using System.Reflection.Metadata; using Pipefy; using Microsoft.VisualBasic; using System.Net.Quic; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration.UserSecrets; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; class Program { static async Task Main(string[] args) { + Console.Clear(); // URL da API que vocĂȘ deseja chamar string ConnSourcePath = @"C:\Users\contratos\Documents\Giuliano\Pipefy.accdb"; - - string apiUrl = "https://api.pipefy.com/graphql"; - string PipefyToken = "eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJQaXBlZnkiLCJpYXQiOjE2OTg4NTYyMjcsImp0aSI6IjM2N2Y4M2NhLWZjODYtNGRhOC04ODEyLTkzODRkZGZkODc0MiIsInN1YiI6MzAyNTM0MzY2LCJ1c2VyIjp7ImlkIjozMDI1MzQzNjYsImVtYWlsIjoiYmFjazVAZW5lcmdpYXNtYXJ0LmNvbS5iciIsImFwcGxpY2F0aW9uIjozMDAyODkyNDgsInNjb3BlcyI6W119LCJpbnRlcmZhY2VfdXVpZCI6bnVsbH0.o13j9c_y3G3HX35qhX4PmkkibGsmlHsk5dL_Bxsr1CKV5Jlgj218kJdEmriS7aHiw0-P7sfs-bu4YcElfuyiqg"; - string PipefyTokenTableID = "wzirXS8w"; + string apiUrl = Environment.GetEnvironmentVariable("PIPEFY_API_URL"); + string PipefyToken = Environment.GetEnvironmentVariable("PIPEFY_API_TOKEN"); + string PipefyTokenTableID = Environment.GetEnvironmentVariable("PIPEFY_TABLE_ID"); + JArray allRecords = await GetPipefyDataAsync(apiUrl,PipefyToken,PipefyTokenTableID); - JArray allGestores = await GetPipefyDataAsync(apiUrl, PipefyToken, "nuyW2tji"); + JArray allGestores = await GetPipefyDataAsync(apiUrl, PipefyToken, "mGCNlqoB"); Console.Clear(); @@ -64,9 +67,9 @@ class Program bool success = await CreatePipefyDataAsync(apiUrl, PipefyToken, PipefyTokenTableID, strQuery); - if (!success) { - int test2 = 10; - } + //if (!success) { + // int test2 = 10; + //} } } @@ -113,12 +116,11 @@ class Program { JArray allRecords = new JArray(); - string? cursor = "null"; + string cursor = "null"; string query = $"{{\"query\":\"query GetRecords($cursor: String){{ table_records(table_id: \\\"{PipefyTokenTableID}\\\",first:50,after:$cursor){{ pageInfo{{ hasNextPage endCursor }} edges{{ node{{ id record_fields{{ field {{ id }} value array_value }} }} }} }}}}\",\"variables\":{{\"cursor\":{cursor}}}}}"; bool hasNextPage = true; - bool hasSucceeded = true; while (hasNextPage) { @@ -275,7 +277,7 @@ class Program //Console.WriteLine(jsonList[j].c_digo_smart.ToString().Replace(".0", "") + " - " + record.c_digo_smart.ToString() + " - " + (jsonList[j].c_digo_smart.ToString().Replace(".0", "") == record.c_digo_smart.ToString())); - if (jsonList[j].c_digo_smart?.ToString().Replace(".0", "") == record.c_digo_smart.ToString()) + if (jsonList[j].c_digo_smart.ToString().Replace(".0", "") == record.c_digo_smart.ToString()) { exists = true; break; @@ -292,10 +294,10 @@ class Program { recordsMissingInJson.Add(record); } - else - { - int test = 10; - } + //else + //{ + // int test = 10; + //} } } @@ -305,7 +307,7 @@ class Program { for (var i = 0; i < jsonListGestores.Count; i++) { - if (sCodigo == jsonListGestores[i].gestores?.ToString()) + if (sCodigo == jsonListGestores[i].gestores.ToString()) { return jsonListGestores[i].id; } diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..f16b6c1 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "Pipefy": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/appsetings.json b/appsetings.json new file mode 100644 index 0000000..56a81a0 --- /dev/null +++ b/appsetings.json @@ -0,0 +1,6 @@ +{ + "MySecretValues": { + "Username": "Abc", + "Password": "Xyz" + } +} \ No newline at end of file diff --git a/data.cs b/data.cs index 1a60b25..7425c7e 100644 --- a/data.cs +++ b/data.cs @@ -26,34 +26,34 @@ namespace Pipefy } public class NodeGestor { - public string id { get; set; } + public string ?id { get; set; } public Record_Fields[] record_fields { get; set; } } public class Record_Fields { public Field field { get; set; } - public string value { get; set; } + public string ?value { get; set; } public string[] array_value { get; set; } } public class Field { - public string id { get; set; } + public string ?id { get; set; } } public class ClasseEmpresas { - public string c_digo_smart { get; set; } - public string nome_da_empresa { get; set; } - public string modalidade { get; set; } - public string gestores { get; set; } + public string ?c_digo_smart { get; set; } + public string ?nome_da_empresa { get; set; } + public string ?modalidade { get; set; } + public string ?gestores { get; set; } } public class ClasseGestores { - public string id { get; set; } - public string gestores { get; set; } + public string ?id { get; set; } + public string ?gestores { get; set; } } }