20231121 - criação dos segredos do código

This commit is contained in:
giuliano 2023-11-21 18:10:38 -03:00
parent 589b09279d
commit b238bbe353
5 changed files with 46 additions and 28 deletions

View File

@ -5,11 +5,14 @@
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>1b2d76eb-7ab5-428f-9f67-13b6bf96375d</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Data.OleDb" Version="7.0.0" />
<PackageReference Include="System.Data.OleDb" Version="8.0.0" />
</ItemGroup>
</Project>

View File

@ -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 = Environment.GetEnvironmentVariable("PIPEFY_API_URL");
string PipefyToken = Environment.GetEnvironmentVariable("PIPEFY_API_TOKEN");
string PipefyTokenTableID = Environment.GetEnvironmentVariable("PIPEFY_TABLE_ID");
string apiUrl = "https://api.pipefy.com/graphql";
string PipefyToken = "eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJQaXBlZnkiLCJpYXQiOjE2OTg4NTYyMjcsImp0aSI6IjM2N2Y4M2NhLWZjODYtNGRhOC04ODEyLTkzODRkZGZkODc0MiIsInN1YiI6MzAyNTM0MzY2LCJ1c2VyIjp7ImlkIjozMDI1MzQzNjYsImVtYWlsIjoiYmFjazVAZW5lcmdpYXNtYXJ0LmNvbS5iciIsImFwcGxpY2F0aW9uIjozMDAyODkyNDgsInNjb3BlcyI6W119LCJpbnRlcmZhY2VfdXVpZCI6bnVsbH0.o13j9c_y3G3HX35qhX4PmkkibGsmlHsk5dL_Bxsr1CKV5Jlgj218kJdEmriS7aHiw0-P7sfs-bu4YcElfuyiqg";
string PipefyTokenTableID = "wzirXS8w";
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;
}

View File

@ -0,0 +1,7 @@
{
"profiles": {
"Pipefy": {
"commandName": "Project"
}
}
}

6
appsetings.json Normal file
View File

@ -0,0 +1,6 @@
{
"MySecretValues": {
"Username": "Abc",
"Password": "Xyz"
}
}

18
data.cs
View File

@ -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; }
}
}