20231110 - Correção de erros
This commit is contained in:
parent
4665174aca
commit
97b8b1c3a6
45
Program.cs
45
Program.cs
@ -8,7 +8,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
using Pipefy;
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
@ -65,15 +65,15 @@ class Program
|
||||
}
|
||||
if (hasSucceeded)
|
||||
{
|
||||
string strJson = Newtonsoft.Json.JsonSerializer(allRecords);
|
||||
string strJson = JsonConvert.SerializeObject(allRecords);
|
||||
// Desserialize o JSON em objetos C#
|
||||
var jsonData = JsonConvert.DeserializeObject(allRecords.ToO);
|
||||
var jsonData = JsonConvert.DeserializeObject<Pipefy.RootObject>(strJson);
|
||||
|
||||
// Consulte os dados da tabela no banco de dados Access
|
||||
List<ClasseEmpresas> databaseData = GetDataFromDatabase(ConnSourcePath);
|
||||
|
||||
// Compare os dados e encontre os registros ausentes no JSON
|
||||
List<ClasseEmpresas> recordsMissingInJson = CompareData(databaseData, jsonData?.data?.table_records?.edges);
|
||||
List<ClasseEmpresas> recordsMissingInJson = CompareData(databaseData, jsonData);
|
||||
|
||||
// Faça algo com os registros ausentes
|
||||
foreach (var record in recordsMissingInJson)
|
||||
@ -118,7 +118,7 @@ class Program
|
||||
return data;
|
||||
}
|
||||
|
||||
static List<ClasseEmpresas> CompareData(List<ClasseEmpresas> databaseData, List<Edge> jsonData)
|
||||
static List<ClasseEmpresas> CompareData(List<ClasseEmpresas> databaseData, Pipefy.RootObject jsonData)
|
||||
{
|
||||
if (jsonData == null)
|
||||
{
|
||||
@ -129,43 +129,18 @@ class Program
|
||||
|
||||
foreach (var record in databaseData)
|
||||
{
|
||||
if (!jsonData.Any(item => item.node.c_odigo_smart == record.c_odigo_smart))
|
||||
{
|
||||
recordsMissingInJson.Add(record);
|
||||
}
|
||||
//if (jsonData.node.Any(item => item.recordFields[0].value.ToString() == record.c_odigo_smart.ToString()))
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
recordsMissingInJson.Add(record);
|
||||
}
|
||||
|
||||
return recordsMissingInJson;
|
||||
}
|
||||
}
|
||||
|
||||
class Root
|
||||
{
|
||||
public Data data { get; set; }
|
||||
}
|
||||
|
||||
class Data
|
||||
{
|
||||
public TableRecords table_records { get; set; }
|
||||
}
|
||||
|
||||
class TableRecords
|
||||
{
|
||||
public List<Edge> edges { get; set; }
|
||||
}
|
||||
|
||||
class Edge
|
||||
{
|
||||
public Node node { get; set; }
|
||||
}
|
||||
|
||||
class Node
|
||||
{
|
||||
public int c_odigo_smart { get; set; }
|
||||
public string nome_da_empresa { get; set; }
|
||||
public string modalidade { get; set; }
|
||||
public string gestores { get; set; }
|
||||
}
|
||||
|
||||
class ClasseEmpresas
|
||||
{
|
||||
|
||||
35
data.cs
Normal file
35
data.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pipefy
|
||||
{
|
||||
public class RootObject
|
||||
{
|
||||
public data[] Property1 { get; set; }
|
||||
}
|
||||
|
||||
public class data
|
||||
{
|
||||
public Node node { get; set; }
|
||||
}
|
||||
|
||||
public class Node
|
||||
{
|
||||
public Record_Fields[] record_fields { get; set; }
|
||||
}
|
||||
|
||||
public class Record_Fields
|
||||
{
|
||||
public Field field { get; set; }
|
||||
public string value { get; set; }
|
||||
public string[] array_value { get; set; }
|
||||
}
|
||||
|
||||
public class Field
|
||||
{
|
||||
public string id { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user