Import inicial: migração de arquivos da rede
This commit is contained in:
commit
31c2a222d7
4
.editorconfig
Normal file
4
.editorconfig
Normal file
@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# IDE1006: Estilos de Nomenclatura
|
||||
dotnet_diagnostic.IDE1006.severity = none
|
||||
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
363
.gitignore
vendored
Normal file
363
.gitignore
vendored
Normal file
@ -0,0 +1,363 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Oo]ut/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
7
App.xaml
Normal file
7
App.xaml
Normal file
@ -0,0 +1,7 @@
|
||||
<Application x:Class="PipefyProspUpdate.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
59
App.xaml.cs
Normal file
59
App.xaml.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using PipefyProspUpdate.Services;
|
||||
|
||||
namespace PipefyProspUpdate
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
private List<Models.Users>? _users;
|
||||
private readonly HttpClient _httpClient = new();
|
||||
private PipefyApiService? _pipefyApiService;
|
||||
public static IConfiguration config { get; private set; } = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
|
||||
private class Settings
|
||||
{
|
||||
public string? Url { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
protected async override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
if (config.AsEnumerable().Where(c => c.Value == "").ToList().Any()) { throw new Exception("Falha ao acessar o arquivo de configuração"); }
|
||||
_pipefyApiService = new PipefyApiService(_httpClient);
|
||||
base.OnStartup(e);
|
||||
|
||||
LoadUsersData();
|
||||
await LoadSuggestions();
|
||||
|
||||
AppState.Instance.selectedUF = "Paraná (PR)";
|
||||
AppState.Instance.MesoChangeBoxItems.Clear();
|
||||
AppState.Instance.CityChangeBoxItems.Clear();
|
||||
AppState.Instance.Prospectante.Clear();
|
||||
AppState.Instance.Others.Clear();
|
||||
AppState.Instance.KeepProsp = false;
|
||||
AppState.Instance.KeepResp = false;
|
||||
AppState.Instance.filterFlag = true;
|
||||
AppState.Instance.LastUpdated = DateTime.Now;
|
||||
AppState.Instance.Save();
|
||||
}
|
||||
public async void LoadUsersData()
|
||||
{
|
||||
_users ??= await _pipefyApiService!.GetUsersAsync();
|
||||
AppState.Instance.Users = _users.OrderBy(p => p.name).Distinct().ToList();
|
||||
}
|
||||
public static async Task LoadSuggestions()
|
||||
{
|
||||
List<Models.Suggestion>? _sugs = await IBGEService.GetBrazilDataAsync();
|
||||
AppState.Instance.Suggestions = _sugs.OrderBy(x => x.City).OrderBy(x => x.Meso).OrderBy(x => x.UF).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
53
AppState.cs
Normal file
53
AppState.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace PipefyProspUpdate
|
||||
{
|
||||
public class AppState
|
||||
{
|
||||
private static readonly List<Models.Suggestion> suggestions = new();
|
||||
public DateTime LastUpdated { get; set; }
|
||||
public List<Models.Suggestion>? Suggestions { get; set; } = suggestions;
|
||||
public List<Models.Suggestion> MesoChangeBoxItems { get; set; } = new();
|
||||
public List<Models.Suggestion> CityChangeBoxItems { get; set; } = new();
|
||||
public List<Models.Users> Users { get; set; } = new();
|
||||
public List<Models.Users> Prospectante { get; set; } = new();
|
||||
public List<Models.Users> Others { get; set; } = new();
|
||||
public List<Models.Node> ProspeccaoFilteredCards { get; set; } = new();
|
||||
public List<Models.Node> recentMutations { get; set; } = new();
|
||||
public bool filterFlag { get; set; }
|
||||
public int currentItems { get; set; }
|
||||
public string? selectedUF { get; set; }
|
||||
public bool KeepProsp { get; set; }
|
||||
public bool KeepResp { get; set; }
|
||||
private static AppState? _instance;
|
||||
private static readonly string FilePath = SetPath();
|
||||
|
||||
public static AppState Instance => _instance ??= Load();
|
||||
|
||||
private AppState() { }
|
||||
|
||||
public static string SetPath()
|
||||
{
|
||||
return $"{System.IO.Path.GetTempPath()}appstate.json";
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
File.WriteAllText(FilePath, json);
|
||||
}
|
||||
|
||||
private static AppState Load()
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
{
|
||||
var json = File.ReadAllText(FilePath);
|
||||
return JsonConvert.DeserializeObject<AppState>(json) ?? new AppState();
|
||||
}
|
||||
return new AppState();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
AssemblyInfo.cs
Normal file
10
AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
69
Home.xaml
Normal file
69
Home.xaml
Normal file
@ -0,0 +1,69 @@
|
||||
<Page x:Class="PipefyProspUpdate.Home"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:PipefyProspUpdate"
|
||||
mc:Ignorable="d"
|
||||
Title="Home">
|
||||
|
||||
<Grid x:Name="grid">
|
||||
|
||||
<ProgressBar x:Name="ProgressBar" HorizontalAlignment="Stretch" Height="15" VerticalAlignment="Top" IsIndeterminate="False"/>
|
||||
<Label Content="Selecione a UF:" HorizontalAlignment="Left" Margin="19,22,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="UFComboBox" AllowDrop="False" HorizontalAlignment="Left" Margin="19,48,0,0" VerticalAlignment="Top" Width="226" Height="30"/>
|
||||
|
||||
<Label Content="Pesquisar Mesorregião:" HorizontalAlignment="Left" Margin="19,86,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<TextBox x:Name="MesoSearchBox" AllowDrop="False" Width="226" Height="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,112,0,0"/>
|
||||
<ListBox x:Name="MesoSuggestionsList" Width="226" Height="295" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,146,0,0"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True"
|
||||
SelectionMode="Multiple"
|
||||
ItemsSource="{Binding Models.Suggestion}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path= Meso, StringFormat={}{0}}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<Label Content="Pesquisar Cidade:" HorizontalAlignment="Left" Margin="19,446,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<TextBox x:Name="CitySearchBox" AllowDrop="False" Width="226" Height="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,472,0,0"/>
|
||||
<ListBox x:Name="CitySuggestionsList" Width="226" Height="350" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,506,0,0"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True"
|
||||
SelectionMode="Multiple"
|
||||
ItemsSource="{Binding Models.Suggestion}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path= City, StringFormat={}{0}}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Label Content="Mesorregiões selecionadas:" HorizontalAlignment="Left" Margin="333,86,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<ListBox x:Name="MesoChangeBox" HorizontalAlignment="Left" Margin="333,112,0,0" VerticalAlignment="Top" Width="226" Height="329"
|
||||
SelectionMode="Multiple"
|
||||
PreviewKeyDown="ChangeBox_PreviewKeyDown"
|
||||
ItemsSource="{Binding Models.Suggestion}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path= Meso, StringFormat={}{0}}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Label Content="Cidades selecionadas:" HorizontalAlignment="Left" Margin="333,446,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<ListBox x:Name="CityChangeBox" HorizontalAlignment="Left" Margin="333,472,0,0" VerticalAlignment="Top" Width="226" Height="384"
|
||||
SelectionMode="Multiple"
|
||||
PreviewKeyDown="ChangeBox_PreviewKeyDown"
|
||||
ItemsSource="{Binding Models.Suggestion}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path= City, StringFormat={}{0}}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Button x:Name="MesoAdd" Content="Adicionar >>" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="250,262,0,0" Height="15" FontSize="7" VerticalAlignment="Top" HorizontalAlignment="Left" Width="78" RenderTransformOrigin="1.22,0.533" FontFamily="Cascadia Mono" Click="MesoAdd_Click"/>
|
||||
<Button x:Name="MesoRemove" Content="<< Remover" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="250,282,0,0" Height="15" FontSize="7" VerticalAlignment="Top" HorizontalAlignment="Left" Width="78" RenderTransformOrigin="1.22,0.533" FontFamily="Cascadia Mono" Click="MesoRemove_Click"/>
|
||||
<Button x:Name="CityAdd" Content="Adicionar >>" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="250,661,0,0" Height="16" FontSize="7" VerticalAlignment="Top" HorizontalAlignment="Left" Width="78" RenderTransformOrigin="1.22,0.533" FontFamily="Cascadia Mono" Click="CityAdd_Click"/>
|
||||
<Button x:Name="CityRemove" Content="<< Remover" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="250,681,0,0" Height="16" FontSize="7" VerticalAlignment="Top" HorizontalAlignment="Left" Width="78" RenderTransformOrigin="1.22,0.533" FontFamily="Cascadia Mono" Click="CityRemove_Click"/>
|
||||
<Button x:Name="Filter" Content="Selecionar responsáveis" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="333,870,0,0" Height="30" FontSize="14" VerticalAlignment="Top" HorizontalAlignment="Left" Width="226" Click="Filter_Click" RenderTransformOrigin="1.22,0.533"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
366
Home.xaml.cs
Normal file
366
Home.xaml.cs
Normal file
@ -0,0 +1,366 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace PipefyProspUpdate
|
||||
{
|
||||
public partial class Home : Page
|
||||
{
|
||||
public Home()
|
||||
{
|
||||
InitializeComponent();
|
||||
ProgressBar.Value = 100;
|
||||
Loaded += Page_Loaded;
|
||||
}
|
||||
|
||||
private async void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await LoadSuggestions();
|
||||
}
|
||||
|
||||
private async Task LoadSuggestions()
|
||||
{
|
||||
if (AppState.Instance.Suggestions!.Count == 0)
|
||||
{
|
||||
await App.LoadSuggestions();
|
||||
}
|
||||
string _uf = AppState.Instance.selectedUF ?? "Paraná (PR)";
|
||||
|
||||
UFComboBox.ItemsSource = AppState.Instance.Suggestions!.AsEnumerable()
|
||||
.Select(x => x.UF!.ToString())
|
||||
.Distinct()
|
||||
.ToList();
|
||||
UFComboBox.SelectedItem = _uf;
|
||||
|
||||
UpdateSuggestionsLists();
|
||||
|
||||
UFComboBox.SelectionChanged += ComboBox_TextChanged;
|
||||
MesoSearchBox.TextChanged += SearchBox_TextChanged;
|
||||
CitySearchBox.TextChanged += SearchBox_TextChanged;
|
||||
|
||||
MesoChangeBox.ItemsSource = AppState.Instance.MesoChangeBoxItems;
|
||||
CityChangeBox.ItemsSource = AppState.Instance.CityChangeBoxItems;
|
||||
|
||||
}
|
||||
private void ComboBox_TextChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
UpdateSuggestionsLists();
|
||||
AppState.Instance.selectedUF = UFComboBox.SelectedItem.ToString() ?? "Paraná (PR)";
|
||||
AppState.Instance.Save();
|
||||
}
|
||||
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
UpdateSuggestionsLists();
|
||||
}
|
||||
static string RemoveDiacritics(string text)
|
||||
{
|
||||
var normalizedString = text.Normalize(NormalizationForm.FormD);
|
||||
var stringBuilder = new StringBuilder(capacity: normalizedString.Length);
|
||||
|
||||
for (int i = 0; i < normalizedString.Length; i++)
|
||||
{
|
||||
char c = normalizedString[i];
|
||||
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
|
||||
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
|
||||
{
|
||||
stringBuilder.Append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return stringBuilder
|
||||
.ToString()
|
||||
.Normalize(NormalizationForm.FormC);
|
||||
}
|
||||
private void UpdateSuggestionsLists()
|
||||
{
|
||||
var filteredSuggestions = AppState.Instance.Suggestions ?? Enumerable.Empty<Models.Suggestion>();
|
||||
|
||||
var list = filteredSuggestions.Where(
|
||||
x =>
|
||||
(RemoveDiacritics(x.City!.ToString())!.ToLower()!.Contains(CitySearchBox.Text.ToLower())) &&
|
||||
(RemoveDiacritics(x.Meso!.ToString())!.ToLower()!.Contains(MesoSearchBox.Text.ToLower())) &&
|
||||
(x.UF!.ToString()!.ToLower()!.Contains((UFComboBox.SelectedItem.ToString() ?? string.Empty).ToLower())));
|
||||
|
||||
MesoSuggestionsList.ItemsSource = list.Select(
|
||||
x =>
|
||||
x.UF + "****" + x.Meso
|
||||
).Distinct().Select(
|
||||
y =>
|
||||
new Models.Suggestion {
|
||||
UF = y.Split("****")[0],
|
||||
Meso = y.Split("****")[1]
|
||||
}
|
||||
).Distinct();
|
||||
CitySuggestionsList.ItemsSource = list.Select(
|
||||
x =>
|
||||
x.ID + "****" + x.UF + "****" + x.Meso + "****" + x.City
|
||||
).Distinct().Select(
|
||||
y =>
|
||||
new Models.Suggestion
|
||||
{
|
||||
ID = y.Split("****")[0],
|
||||
UF = y.Split("****")[1],
|
||||
Meso = y.Split("****")[2],
|
||||
City = y.Split("****")[3],
|
||||
}
|
||||
).Distinct();
|
||||
}
|
||||
private void ListBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var clickedItem = e.OriginalSource as FrameworkElement;
|
||||
|
||||
while (clickedItem != null && clickedItem is not ListBoxItem)
|
||||
{
|
||||
clickedItem = VisualTreeHelper.GetParent(clickedItem) as FrameworkElement;
|
||||
}
|
||||
|
||||
if (sender is ListBox listBox && clickedItem is ListBoxItem listBoxItem)
|
||||
{
|
||||
listBox.SelectedItem = listBoxItem.Content;
|
||||
Models.Suggestion selectedItem = (Models.Suggestion)listBoxItem.Content;
|
||||
|
||||
if (selectedItem != null)
|
||||
{
|
||||
DragDrop.DoDragDrop(listBox, selectedItem, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ListBox_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effects = DragDropEffects.Move;
|
||||
e.Handled = true;
|
||||
}
|
||||
private void HandleDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
Models.Suggestion? droppedData = (Models.Suggestion?)e.Data.GetData(typeof(Models.Suggestion));
|
||||
|
||||
if (droppedData != null && sender is ListBox origin)
|
||||
{
|
||||
switch (origin.Name)
|
||||
{
|
||||
case ("CityChangeBox"):
|
||||
|
||||
var meso = droppedData.Meso;
|
||||
if (!AppState.Instance.CityChangeBoxItems!.Where(x => x.City == droppedData.City).Any() &&
|
||||
AppState.Instance.Suggestions!.Select(x => x.City).Contains(droppedData.City) &&
|
||||
!AppState.Instance.MesoChangeBoxItems!.Where(x => x.Meso == meso).Any()
|
||||
)
|
||||
{
|
||||
AppState.Instance.CityChangeBoxItems.Add(droppedData);
|
||||
}
|
||||
break;
|
||||
|
||||
case ("MesoChangeBox"):
|
||||
|
||||
List<Models.Suggestion>? cities = null;
|
||||
|
||||
if (!AppState.Instance.MesoChangeBoxItems!.Where(x => x.Meso == droppedData.Meso).Any() &&
|
||||
AppState.Instance.Suggestions!.Select(x => x.Meso).Contains(droppedData.Meso) && droppedData.City == null)
|
||||
{
|
||||
AppState.Instance.MesoChangeBoxItems.Add(droppedData);
|
||||
cities = AppState.Instance.Suggestions!.Where(x => x.Meso == droppedData.Meso).ToList();
|
||||
}
|
||||
|
||||
List<Models.Suggestion> mylist = AppState.Instance.CityChangeBoxItems.ToList();
|
||||
|
||||
if (cities != null)
|
||||
{
|
||||
foreach (Models.Suggestion city in mylist)
|
||||
{
|
||||
if (cities.Where(x => x.ID == city.ID).Any())
|
||||
{
|
||||
AppState.Instance.CityChangeBoxItems.Remove(city);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
AppState.Instance.filterFlag = true;
|
||||
|
||||
AppState.Instance.Save();
|
||||
CityChangeBox.ItemsSource = null;
|
||||
CityChangeBox.ItemsSource = AppState.Instance.CityChangeBoxItems;
|
||||
MesoChangeBox.ItemsSource = null;
|
||||
MesoChangeBox.ItemsSource = AppState.Instance.MesoChangeBoxItems;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (sender is ListBox origin)
|
||||
{
|
||||
int index = origin.SelectedIndex;
|
||||
if (index > -1)
|
||||
{
|
||||
Models.Suggestion selectedItem = (Models.Suggestion)origin.Items[index];
|
||||
if (sender != null && (e.Key == Key.Delete || e.Key == Key.Back))
|
||||
{
|
||||
switch (origin!.Name)
|
||||
{
|
||||
case ("CityChangeBox"):
|
||||
|
||||
Models.Suggestion city = AppState.Instance.CityChangeBoxItems.Where(x => x.City == selectedItem.City).First();
|
||||
AppState.Instance.CityChangeBoxItems.Remove(selectedItem);
|
||||
|
||||
CityChangeBox.ItemsSource = null;
|
||||
CityChangeBox.ItemsSource = AppState.Instance.CityChangeBoxItems;
|
||||
CityChangeBox.SelectedIndex = 0;
|
||||
|
||||
break;
|
||||
case ("MesoChangeBox"):
|
||||
|
||||
Models.Suggestion meso = AppState.Instance.MesoChangeBoxItems.Where(x => x.Meso == selectedItem.Meso).First();
|
||||
AppState.Instance.MesoChangeBoxItems.Remove(meso);
|
||||
|
||||
MesoChangeBox.ItemsSource = null;
|
||||
MesoChangeBox.ItemsSource = AppState.Instance.MesoChangeBoxItems;
|
||||
MesoChangeBox.SelectedIndex = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
AppState.Instance.filterFlag = true;
|
||||
|
||||
AppState.Instance.Save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Filter_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(MesoChangeBox.Items.Count > 0 | CityChangeBox.Items.Count > 0)
|
||||
{
|
||||
AppState.Instance.Save();
|
||||
NavigationService?.Navigate(new Users());
|
||||
}
|
||||
}
|
||||
|
||||
private void MesoAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedItems = MesoSuggestionsList.SelectedItems.OfType<Models.Suggestion>().ToList();
|
||||
|
||||
if (selectedItems.Count > 0 && selectedItems != null)
|
||||
{
|
||||
foreach (var item in selectedItems)
|
||||
{
|
||||
List<Models.Suggestion>? cities = null;
|
||||
|
||||
if (!AppState.Instance.MesoChangeBoxItems!.Where(x => x.UF == item.UF && x.Meso == item.Meso && x.ID == null && x.City == null).Any() &&
|
||||
AppState.Instance.Suggestions!.Select(x => x.Meso).Contains(item.Meso) && item.City == null && item.ID == null)
|
||||
{
|
||||
AppState.Instance.MesoChangeBoxItems.Add(item);
|
||||
cities = AppState.Instance.Suggestions!.Where(x => x.UF == item.UF && x.Meso == item.Meso).ToList();
|
||||
}
|
||||
|
||||
List<Models.Suggestion> mylist = AppState.Instance.CityChangeBoxItems.ToList();
|
||||
|
||||
if (cities != null && mylist.Count > 0)
|
||||
{
|
||||
foreach (Models.Suggestion city in mylist)
|
||||
{
|
||||
if (cities.Where(x => x.ID == city.ID).Any())
|
||||
{
|
||||
AppState.Instance.CityChangeBoxItems.Remove(city);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MesoSuggestionsList.SelectedIndex = -1;
|
||||
AppState.Instance.filterFlag = true;
|
||||
|
||||
AppState.Instance.Save();
|
||||
CityChangeBox.ItemsSource = null;
|
||||
CityChangeBox.ItemsSource = AppState.Instance.CityChangeBoxItems;
|
||||
MesoChangeBox.ItemsSource = null;
|
||||
MesoChangeBox.ItemsSource = AppState.Instance.MesoChangeBoxItems;
|
||||
}
|
||||
}
|
||||
|
||||
private void MesoRemove_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedItems = MesoChangeBox.SelectedItems.OfType<Models.Suggestion>().ToList();
|
||||
|
||||
if (selectedItems.Count > 0 && selectedItems != null)
|
||||
{
|
||||
foreach (var item in selectedItems)
|
||||
{
|
||||
if (item != null && AppState.Instance.MesoChangeBoxItems.Count != 0)
|
||||
{
|
||||
var select = AppState.Instance.MesoChangeBoxItems.Where(x => x.UF == item.UF && x.Meso == item.Meso && x.ID == null && x.City == null).First();
|
||||
AppState.Instance.MesoChangeBoxItems.Remove(select);
|
||||
}
|
||||
}
|
||||
AppState.Instance.filterFlag = true;
|
||||
|
||||
AppState.Instance.Save();
|
||||
MesoChangeBox.ItemsSource = null;
|
||||
MesoChangeBox.ItemsSource = AppState.Instance.MesoChangeBoxItems;
|
||||
MesoChangeBox.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void CityAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedItems = CitySuggestionsList.SelectedItems.OfType<Models.Suggestion>().ToList();
|
||||
|
||||
if (selectedItems.Count > 0 && selectedItems != null)
|
||||
{
|
||||
foreach (var item in selectedItems)
|
||||
{
|
||||
var meso = item.Meso;
|
||||
if (!AppState.Instance.CityChangeBoxItems!.Where(x => x.City == item.City).Any() &&
|
||||
AppState.Instance.Suggestions!.Select(x => x.City).Contains(item.City) &&
|
||||
!AppState.Instance.MesoChangeBoxItems!.Where(x => x.Meso == meso).Any()
|
||||
)
|
||||
{
|
||||
AppState.Instance.CityChangeBoxItems.Add(item);
|
||||
}
|
||||
}
|
||||
CitySuggestionsList.SelectedIndex = -1;
|
||||
AppState.Instance.filterFlag = true;
|
||||
|
||||
AppState.Instance.Save();
|
||||
CityChangeBox.ItemsSource = null;
|
||||
CityChangeBox.ItemsSource = AppState.Instance.CityChangeBoxItems;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CityRemove_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedItems = CityChangeBox.SelectedItems.OfType<Models.Suggestion>().ToList();
|
||||
|
||||
if (selectedItems.Count > 0 && selectedItems != null)
|
||||
{
|
||||
foreach (var item in selectedItems)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
var select = AppState.Instance.CityChangeBoxItems.Where(x => x.ID == item.ID).First();
|
||||
AppState.Instance.CityChangeBoxItems.Remove(select);
|
||||
}
|
||||
}
|
||||
AppState.Instance.filterFlag = true;
|
||||
|
||||
AppState.Instance.Save();
|
||||
CityChangeBox.ItemsSource = null;
|
||||
CityChangeBox.ItemsSource = AppState.Instance.CityChangeBoxItems;
|
||||
CityChangeBox.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
MainWindow.xaml
Normal file
8
MainWindow.xaml
Normal file
@ -0,0 +1,8 @@
|
||||
<Window x:Class="PipefyProspUpdate.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Pipefy - Edição de Prospectantes" MinHeight="950" MinWidth="850" Height="950" Width="850" WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Frame x:Name="MainFrame" NavigationUIVisibility="Hidden"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
13
MainWindow.xaml.cs
Normal file
13
MainWindow.xaml.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace PipefyProspUpdate
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
MainFrame.Navigate(new Home());
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Models/GraphQLResponse.cs
Normal file
87
Models/GraphQLResponse.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PipefyProspUpdate.Models
|
||||
{
|
||||
public class GraphQLResponse
|
||||
{
|
||||
public Data? data { get; set; }
|
||||
}
|
||||
|
||||
public class Data
|
||||
{
|
||||
public Table_Records? table_records { get; set; }
|
||||
public Pipe? pipe { get; set; }
|
||||
public FindCards? findCards { get; set; }
|
||||
}
|
||||
public class FindCards
|
||||
{
|
||||
public Pageinfo? pageinfo { get; set; }
|
||||
public int totalCount { get; set; }
|
||||
public Node[]? nodes { get; set; }
|
||||
}
|
||||
public class Pipe
|
||||
{
|
||||
public List<Users>? users { get; set; }
|
||||
public string? name { get; set; }
|
||||
}
|
||||
public class Users
|
||||
{
|
||||
public string? id { get; set; }
|
||||
public string? name { get; set; }
|
||||
public string? email { get; set; }
|
||||
}
|
||||
public class Table_Records
|
||||
{
|
||||
public int matchCount { get; set; }
|
||||
public int totalCount { get; set; }
|
||||
public Pageinfo? pageInfo { get; set; }
|
||||
public Node[]? nodes { get; set; }
|
||||
}
|
||||
|
||||
public class Pageinfo
|
||||
{
|
||||
public bool hasNextPage { get; set; }
|
||||
public string? endCursor { get; set; }
|
||||
}
|
||||
|
||||
public class Node
|
||||
{
|
||||
public string? id { get; set; }
|
||||
public string? title { get; set; }
|
||||
public Pipe? pipe { get; set; }
|
||||
public string Url { get { return @$"https://app.pipefy.com/open-cards/{id}"; } }
|
||||
public bool success { get; set; }
|
||||
public Record_Fields[]? record_fields { get; set; }
|
||||
public Record_Fields[]? fields { get; set; }
|
||||
public Current_phase? current_phase { get; set; }
|
||||
public Field? field { get; set; }
|
||||
public List<Models.Users>? assignees { get; set; }
|
||||
public List<string?> prosp { get { return this.fields!.Where(x => x.field?.id == "respons_vel").SelectMany(x => x.array_value ?? new string[] { "" }).ToList()!; } }
|
||||
public List<string?> others { get { return this.fields!.Where(x => x.field?.id == "demais_envolvidos").SelectMany(x => x.array_value ?? new string[] { "" }).ToList()!; } }
|
||||
}
|
||||
public class Current_phase
|
||||
{
|
||||
public string? id { get; set; }
|
||||
public string? name { 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; }
|
||||
public string? label { get; set; }
|
||||
public string[]? value { get; set; }
|
||||
}
|
||||
public class Fields
|
||||
{
|
||||
public string? id { get; set; }
|
||||
public string[]? value { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
12
Models/IbgeResponse.cs
Normal file
12
Models/IbgeResponse.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PipefyProspUpdate.Models
|
||||
{
|
||||
public class Suggestion
|
||||
{
|
||||
public string? ID { get; set; }
|
||||
public string? UF { get; set; }
|
||||
public string? Meso { get; set; }
|
||||
public string? City { get; set; }
|
||||
}
|
||||
}
|
||||
30
PipefyProspUpdate.sln
Normal file
30
PipefyProspUpdate.sln
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34221.43
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PipefyProspUpdateApp", "PipefyProspUpdateApp.csproj", "{EF339076-C58E-4C93-845B-504A59160795}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DA264C7F-ED79-4C86-A8FD-D2A104073EFA}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EF339076-C58E-4C93-845B-504A59160795}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EF339076-C58E-4C93-845B-504A59160795}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EF339076-C58E-4C93-845B-504A59160795}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EF339076-C58E-4C93-845B-504A59160795}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8823FC75-7DC9-4B55-AF67-58488BEA053B}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
43
PipefyProspUpdateApp.csproj
Normal file
43
PipefyProspUpdateApp.csproj
Normal file
@ -0,0 +1,43 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ApplicationIcon>logo.ico</ApplicationIcon>
|
||||
<UserSecretsId>bafe1bf8-2883-4167-b003-56e21cde583d</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<COMReference Include="Microsoft.Office.Interop.Excel">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>9</VersionMinor>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<Guid>00020813-0000-0000-c000-000000000046</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="logo.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
59
Services/IBGEService.cs
Normal file
59
Services/IBGEService.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PipefyProspUpdate.Services;
|
||||
|
||||
public class IBGEService
|
||||
{
|
||||
|
||||
public static async Task<List<Models.Suggestion>> GetBrazilDataAsync()
|
||||
{
|
||||
string? apiUrl = App.config["IBGE_URL"];
|
||||
List<Models.Suggestion> sugs = new();
|
||||
|
||||
using (HttpClient client = new())
|
||||
{
|
||||
HttpResponseMessage response = await client.GetAsync(apiUrl);
|
||||
response.EnsureSuccessStatusCode();
|
||||
string responseBody = await response.Content.ReadAsStringAsync();
|
||||
JArray data = JArray.Parse(responseBody);
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
try
|
||||
{
|
||||
string UF;
|
||||
string Meso;
|
||||
if (item["microrregiao"]!.Type == JTokenType.Null)
|
||||
{
|
||||
UF = (string)item["regiao-imediata"]!["regiao-intermediaria"]!["UF"]!["nome"]! + " (" + (string)item["regiao-imediata"]!["regiao-intermediaria"]!["UF"]!["sigla"]! + ")";
|
||||
Meso = (string)item["regiao-imediata"]!["regiao-intermediaria"]!["nome"]!;
|
||||
if ((string)item["nome"]! == "Boa Esperança do Norte") { Meso = "Norte Mato-grossense"; }
|
||||
}
|
||||
else
|
||||
{
|
||||
UF = (string)item["microrregiao"]!["mesorregiao"]!["UF"]!["nome"]! + " (" + (string)item["microrregiao"]!["mesorregiao"]!["UF"]!["sigla"]! + ")";
|
||||
Meso = (string)item["microrregiao"]!["mesorregiao"]!["nome"]!;
|
||||
}
|
||||
|
||||
sugs.Add(new()
|
||||
{
|
||||
ID = (string)item["id"]!,
|
||||
UF = UF,
|
||||
Meso = Meso,
|
||||
City = (string)item["nome"]!
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show($"Erro ao carregar {item} do IBGE. Verifique a conexão com a internet ou o arquivo de configuração.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sugs;
|
||||
}
|
||||
}
|
||||
319
Services/PipefyApiService.cs
Normal file
319
Services/PipefyApiService.cs
Normal file
@ -0,0 +1,319 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PipefyProspUpdate.Models;
|
||||
using System.Windows.Controls;
|
||||
using System.Web;
|
||||
|
||||
namespace PipefyProspUpdate.Services;
|
||||
|
||||
public class PipefyApiService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly string GraphQLUrl = App.config["Pipefy_URL"]!;
|
||||
private readonly string BearerToken = App.config["Pipefy_API_Key"]!;
|
||||
|
||||
public PipefyApiService(HttpClient httpClient)
|
||||
{
|
||||
|
||||
_httpClient = httpClient;
|
||||
_httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", BearerToken);
|
||||
}
|
||||
public async Task<List<Models.Users>> GetUsersAsync()
|
||||
{
|
||||
var allUsers = new List<Models.Users>();
|
||||
var query = new
|
||||
{
|
||||
query = @"query GetProspectantes{
|
||||
pipe(id: 303017662){
|
||||
users{
|
||||
id
|
||||
name
|
||||
email
|
||||
}
|
||||
}
|
||||
}"
|
||||
};
|
||||
|
||||
var requestContent = new StringContent(JsonConvert.SerializeObject(query), Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await _httpClient.PostAsync(GraphQLUrl, requestContent);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
var graphQLResponse = JsonConvert.DeserializeObject<GraphQLResponse>(responseString);
|
||||
|
||||
if (graphQLResponse?.data!.pipe?.users != null)
|
||||
{
|
||||
allUsers.AddRange(graphQLResponse.data.pipe.users);
|
||||
}
|
||||
|
||||
return allUsers;
|
||||
}
|
||||
public async Task<List<Node>> GetCardsAsync(string pipeId, string fieldId, Models.Suggestion sug, IProgress<int>? progress = null, int totalCities = 1)
|
||||
{
|
||||
var allCards = new List<Node>();
|
||||
bool hasNextPage = true;
|
||||
string? endCursor = null;
|
||||
|
||||
while (hasNextPage)
|
||||
{
|
||||
var query = new
|
||||
{
|
||||
query = @"query GetCards_ProspUpdate($pipeId: ID!, $fieldId: String!, $fieldValue: String!, $cursor: String){
|
||||
findCards(
|
||||
pipeId: $pipeId,
|
||||
first: 50,
|
||||
search: {
|
||||
fieldId: $fieldId,
|
||||
fieldValue: $fieldValue
|
||||
},
|
||||
after: $cursor
|
||||
)
|
||||
{
|
||||
pageInfo{
|
||||
hasNextPage
|
||||
endCursor
|
||||
}
|
||||
totalCount
|
||||
nodes{
|
||||
id
|
||||
title
|
||||
assignees
|
||||
{
|
||||
id
|
||||
name
|
||||
email
|
||||
}
|
||||
pipe{
|
||||
name
|
||||
}
|
||||
current_phase{
|
||||
id
|
||||
name
|
||||
}
|
||||
fields{
|
||||
field{
|
||||
id
|
||||
}
|
||||
value
|
||||
array_value
|
||||
}
|
||||
}
|
||||
}
|
||||
}",
|
||||
variables = new
|
||||
{
|
||||
pipeId,
|
||||
fieldId,
|
||||
fieldValue = sug.City,
|
||||
cursor = endCursor,
|
||||
}
|
||||
};
|
||||
|
||||
var requestContent = new StringContent(JsonConvert.SerializeObject(query), Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await _httpClient.PostAsync(GraphQLUrl, requestContent);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
var graphQLResponse = JsonConvert.DeserializeObject<GraphQLResponse>(responseString);
|
||||
|
||||
if (graphQLResponse?.data!.findCards?.nodes != null)
|
||||
{
|
||||
allCards.AddRange(graphQLResponse.data.findCards.nodes);
|
||||
}
|
||||
|
||||
endCursor = graphQLResponse!.data!.findCards!.pageinfo!.endCursor ?? (string?)null;
|
||||
hasNextPage = (bool)(graphQLResponse!.data!.findCards?.pageinfo.hasNextPage)!;
|
||||
|
||||
}
|
||||
string UF = sug.UF!;
|
||||
|
||||
allCards = allCards
|
||||
.Where(x =>
|
||||
x.fields!.Where(x => x.field!.id == "estado_importa_o" | x.field.id == "sele_o_de_lista").Select(x => x.value).First()!.ToString() == UF
|
||||
).ToList();
|
||||
|
||||
if (AppState.Instance.currentItems < totalCities) { AppState.Instance.currentItems++; }
|
||||
var progressPercentage = (int)((double)AppState.Instance.currentItems / totalCities * 100);
|
||||
progress?.Report(progressPercentage);
|
||||
|
||||
return allCards;
|
||||
}
|
||||
public async Task<List<Models.Node>> MutateCardsAsync(List<Models.Node> cards, List<Models.Users> prosp, List<Models.Users> others, bool KeepProsp, bool KeepOthers, IProgress<int>? progress = null, int totalCards = 1)
|
||||
{
|
||||
List<Models.Node> allCards = new();
|
||||
|
||||
List<Models.Node> clearCards = new();
|
||||
|
||||
List<string> id_match = Enumerable.Range(0, cards.Count).Select(x => "").ToList();
|
||||
|
||||
List<string?> newListOfProsp = prosp.Select(x => x.id).ToList();
|
||||
List<string?> newListOfOthers = others.Select(x => x.id).ToList();
|
||||
|
||||
string mutationQuery = "mutation{";
|
||||
string clearQuery = "mutation{";
|
||||
|
||||
int i = 1;
|
||||
|
||||
foreach (Models.Node card in cards)
|
||||
{
|
||||
if (AppState.Instance.currentItems < totalCards) { AppState.Instance.currentItems++; }
|
||||
int progressPercentage = (int)((double)AppState.Instance.currentItems / totalCards * 100);
|
||||
progress?.Report(progressPercentage);
|
||||
|
||||
List<string?> assignees = (card.assignees ?? new List<Models.Users> {}).Select(x => x.id).ToList();
|
||||
|
||||
List<string?> both = card.others.Intersect(card.prosp).Distinct().ToList();
|
||||
List<string?> all = card.others.Concat(card.prosp).ToList();
|
||||
List<string?> neither = all.Except(assignees).Distinct().ToList();
|
||||
|
||||
bool valProsp = (!KeepProsp && newListOfProsp.Any()) || (KeepProsp && card.prosp.Any() && !newListOfProsp.Any());
|
||||
|
||||
if (!valProsp) { continue; }
|
||||
|
||||
List<string?> ProspOfCard = new();
|
||||
List<string?> OthersOfCard = new();
|
||||
|
||||
if (KeepProsp && card.prosp.Any()) { ProspOfCard.Add(card.prosp.First()); }
|
||||
if (KeepOthers && card.others.Any()) { OthersOfCard.AddRange(card.others); }
|
||||
|
||||
if (card.prosp.Count > 1) {
|
||||
OthersOfCard.AddRange(card.prosp);
|
||||
}
|
||||
|
||||
if (newListOfProsp.Any() && !KeepProsp) { ProspOfCard.AddRange(newListOfProsp); }
|
||||
if (newListOfOthers.Any()) { OthersOfCard.AddRange(newListOfOthers); }
|
||||
|
||||
ProspOfCard = new List<string?> { ProspOfCard.Distinct().ToList().First() };
|
||||
OthersOfCard = OthersOfCard.Distinct().ToList().Except(ProspOfCard).ToList();
|
||||
|
||||
if ((ProspOfCard.SequenceEqual(card.prosp)) && (OthersOfCard.SequenceEqual(card.others) && !neither.Any())) { continue; }
|
||||
|
||||
string sProspOfCard = "";
|
||||
string sOthersOfCard = "";
|
||||
|
||||
if (ProspOfCard.Any())
|
||||
{
|
||||
sProspOfCard = $@"{{
|
||||
fieldId:""respons_vel""
|
||||
value: [{string.Join(", ", ProspOfCard)}]
|
||||
}}";
|
||||
}
|
||||
sOthersOfCard = $@",
|
||||
{{
|
||||
fieldId:""demais_envolvidos""
|
||||
value: [{string.Join(", ", OthersOfCard)}]
|
||||
}}";
|
||||
|
||||
id_match[i-1] = card.id ?? "";
|
||||
|
||||
mutationQuery += $@"
|
||||
N{i-1}: updateFieldsValues(
|
||||
input: {{
|
||||
nodeId: {card.id}
|
||||
values: [
|
||||
{sProspOfCard}{sOthersOfCard}
|
||||
]
|
||||
}}
|
||||
)
|
||||
{{
|
||||
success
|
||||
}}";
|
||||
|
||||
clearCards.Add(card);
|
||||
|
||||
string sAssignees = "";
|
||||
|
||||
if (ProspOfCard.Concat(OthersOfCard).Any())
|
||||
{
|
||||
sAssignees = $@"{string.Join(", ", ProspOfCard.Concat(OthersOfCard).Distinct())}";
|
||||
}
|
||||
|
||||
if (card.pipe?.name != "Funil de Vendas")
|
||||
{
|
||||
clearQuery += $@"
|
||||
N{i-1}: updateCard(
|
||||
input: {{
|
||||
id: {card.id}
|
||||
assignee_ids: [
|
||||
{sAssignees}
|
||||
]
|
||||
}}
|
||||
)
|
||||
{{
|
||||
card{{
|
||||
assignees{{
|
||||
name
|
||||
}}
|
||||
}}
|
||||
}}";
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
mutationQuery += "\n}";
|
||||
clearQuery += "\n}";
|
||||
|
||||
if (mutationQuery.Contains("updateFieldsValues"))
|
||||
{
|
||||
|
||||
var query = new
|
||||
{
|
||||
query = mutationQuery,
|
||||
};
|
||||
|
||||
var requestContent = new StringContent(JsonConvert.SerializeObject(query), Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await _httpClient.PostAsync(GraphQLUrl, requestContent);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
|
||||
allCards.AddRange(ProcessJson(responseString, id_match));
|
||||
}
|
||||
|
||||
if (clearQuery.Contains("updateCard"))
|
||||
{
|
||||
var clearQueryVar = new
|
||||
{
|
||||
query = clearQuery,
|
||||
};
|
||||
|
||||
var requestClearContent = new StringContent(JsonConvert.SerializeObject(clearQueryVar), Encoding.UTF8, "application/json");
|
||||
|
||||
var responseClear = await _httpClient.PostAsync(GraphQLUrl, requestClearContent);
|
||||
responseClear.EnsureSuccessStatusCode();
|
||||
var responseStringClear = await responseClear.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
return allCards;
|
||||
}
|
||||
public static List<Models.Node> ProcessJson(string jsonString, List<string> id_match)
|
||||
{
|
||||
var jsonObject = JObject.Parse(jsonString);
|
||||
var data = jsonObject["data"] as JObject;
|
||||
|
||||
var nodes = new List<Models.Node>();
|
||||
|
||||
foreach (var property in data!.Properties())
|
||||
{
|
||||
if (property.Value is JObject innerObject)
|
||||
{
|
||||
foreach (var innerProperty in innerObject.Properties())
|
||||
{
|
||||
bool isSuccess = bool.Parse(innerProperty.Value.ToString().ToLower());
|
||||
string index = id_match[Int32.Parse(property.Name.Replace("N",""))];
|
||||
|
||||
AppState.Instance.ProspeccaoFilteredCards.Where(x => x.id == index).First().success = isSuccess;
|
||||
nodes.Add(AppState.Instance.ProspeccaoFilteredCards.Where(x => x.id == index).First());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
91
Users.xaml
Normal file
91
Users.xaml
Normal file
@ -0,0 +1,91 @@
|
||||
<Page x:Class="PipefyProspUpdate.Users"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:PipefyProspUpdate"
|
||||
mc:Ignorable="d"
|
||||
Title="Users">
|
||||
|
||||
<Grid x:Name="grid">
|
||||
|
||||
<ProgressBar x:Name="ProgressBar" HorizontalAlignment="Stretch" Height="15" VerticalAlignment="Top" IsIndeterminate="False"/>
|
||||
<Button x:Name="BackButton" Content="Voltar" Width="100" Height="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,24,0,0" Click="BackButton_Click" FontSize="14"/>
|
||||
<Button x:Name="ReloadButton" Content="Recarregar Cards" Width="144" Height="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="145,23,0,0" Click="ReloadButton_Click" FontSize="14"/>
|
||||
|
||||
<Label Content="Pesquisar Responsáveis:" HorizontalAlignment="Left" Margin="19,95,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<TextBox x:Name="UsersSearchBox" AllowDrop="False" Width="226" Height="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,121,0,0"/>
|
||||
<ListBox x:Name="UsersSuggestionsList" Width="226" HorizontalAlignment="Left" Margin="19,156,0,10"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True"
|
||||
SelectionMode="Multiple"
|
||||
ItemsSource="{Binding Models.Users}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<TextBlock.Text >
|
||||
<MultiBinding StringFormat="{}{0} ({1}) ">
|
||||
<Binding Path="name" />
|
||||
<Binding Path="email" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<CheckBox x:Name="KeepProsp" Content="Manter Prospectante dos cards" HorizontalAlignment="Left" Margin="333,121,0,0" VerticalAlignment="Top" Width="224" Unchecked="CheckBox_Changed" Checked="CheckBox_Changed"/>
|
||||
<Label x:Name="labelProsp" Content="Prospectante:" HorizontalAlignment="Left" Margin="333,136,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<ListBox x:Name="ProspectanteChangeBox" Margin="333,160,0,0" HorizontalAlignment="Left" Width="224" Height="35" VerticalAlignment="Top"
|
||||
SelectionMode="Multiple"
|
||||
PreviewKeyDown="ChangeBox_PreviewKeyDown"
|
||||
ItemsSource="{Binding Models.Users}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path= name, StringFormat={}{0}}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<CheckBox x:Name="KeepResp" Content="Manter Responsáveis dos cards" HorizontalAlignment="Left" Margin="333,205,0,0" VerticalAlignment="Top" Width="224" Unchecked="CheckBox_Changed" Checked="CheckBox_Changed"/>
|
||||
<Label Content="Demais envolvidos:" HorizontalAlignment="Left" Margin="333,220,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<ListBox x:Name="ResponsavelChangeBox" Margin="333,246,0,10" HorizontalAlignment="Left" Width="224"
|
||||
SelectionMode="Multiple"
|
||||
PreviewKeyDown="ChangeBox_PreviewKeyDown"
|
||||
ItemsSource="{Binding Models.Users}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path= name, StringFormat={}{0}}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<ListBox x:Name="CardsChangeBox" Margin="579,126,10,10"
|
||||
AllowDrop="False"
|
||||
IsEnabled="True"
|
||||
ItemsSource="{Binding Models.Node}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Hyperlink NavigateUri= "{Binding Url}" RequestNavigate="Hyperlink_RequestNavigate">
|
||||
<TextBlock>
|
||||
<TextBlock.Text >
|
||||
<MultiBinding StringFormat="[{0}] {1} - {2} ">
|
||||
<Binding Path="pipe.name[0]" />
|
||||
<Binding Path="id" />
|
||||
<Binding Path="title" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Label Content="{Binding LabelContent}" HorizontalAlignment="Left" Margin="19,59,0,0" VerticalAlignment="Top" Width="140" Height="36"/>
|
||||
<Label Content="ID dos cards a serem alterados:" HorizontalAlignment="Left" Margin="579,95,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
<Button x:Name="ProspAdd" Content="Adicionar >>" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="250,160,0,0" Height="15" FontSize="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="78" RenderTransformOrigin="1.22,0.533" Click="ProspAdd_Click"/>
|
||||
<Button x:Name="ProspRemove" Content="<< Remover" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="250,180,0,0" Height="15" FontSize="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="78" RenderTransformOrigin="1.22,0.533" Click="ProspRemove_Click"/>
|
||||
<Button x:Name="OtherAdd" Content="Adicionar >>" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="250,487,0,0" Height="16" FontSize="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="78" RenderTransformOrigin="1.22,0.533" Click="OtherAdd_Click"/>
|
||||
<Button x:Name="OtherRemove" Content="<< Remover" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="250,507,0,0" Height="16" FontSize="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="78" RenderTransformOrigin="1.22,0.533" Click="OtherRemove_Click"/>
|
||||
<Button x:Name="RunMutations" Content="Atualizar Prospectantes" HorizontalAlignment="Left" Margin="664,24,0,0" VerticalAlignment="Top" Height="30" Width="139" Click="RunMutations_Click"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
546
Users.xaml.cs
Normal file
546
Users.xaml.cs
Normal file
@ -0,0 +1,546 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using PipefyProspUpdate.Services;
|
||||
using PipefyProspUpdate.Models;
|
||||
using System.Net.Http;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Windows.Media;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Navigation;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace PipefyProspUpdate
|
||||
{
|
||||
public partial class Users : Page
|
||||
{
|
||||
public class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private string _labelContent = "Cards filtrados: 0";
|
||||
public string LabelContent
|
||||
{
|
||||
get { return _labelContent; }
|
||||
set
|
||||
{
|
||||
if (_labelContent != value)
|
||||
{
|
||||
_labelContent = value;
|
||||
OnPropertyChanged(nameof(LabelContent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
private List<Models.Users> _users = AppState.Instance.Users;
|
||||
private readonly HttpClient _httpClient = new();
|
||||
private readonly PipefyApiService? _apiService;
|
||||
private readonly List<Models.Suggestion> _meso = AppState.Instance.MesoChangeBoxItems.ToList();
|
||||
private readonly List<Models.Suggestion> _city = AppState.Instance.CityChangeBoxItems.ToList();
|
||||
|
||||
public Users()
|
||||
{
|
||||
var progress = new Progress<int>(percent =>
|
||||
{
|
||||
ProgressBar.Value = percent;
|
||||
ProgressBar.IsIndeterminate = percent == 0;
|
||||
});
|
||||
|
||||
InitializeComponent();
|
||||
_apiService = new PipefyApiService(_httpClient);
|
||||
DataContext = new ViewModel
|
||||
{
|
||||
LabelContent = "Cards filtrados: 0"
|
||||
};
|
||||
|
||||
LoadUsers();
|
||||
FilterCards(progress);
|
||||
}
|
||||
|
||||
public static void startProgress(IProgress<int> progress)
|
||||
{
|
||||
progress.Report(0);
|
||||
}
|
||||
public static void endProgress(IProgress<int> progress)
|
||||
{
|
||||
progress.Report(100);
|
||||
}
|
||||
private async void FilterCards(Progress<int> progress)
|
||||
{
|
||||
var viewModel = (ViewModel)DataContext;
|
||||
|
||||
if (AppState.Instance.filterFlag)
|
||||
{
|
||||
viewModel.LabelContent = "Cards filtrados: 0";
|
||||
CardsChangeBox.ItemsSource = null;
|
||||
RunMutations.IsEnabled = false;
|
||||
startProgress(progress);
|
||||
AppState.Instance.ProspeccaoFilteredCards = new List<Models.Node>();
|
||||
AppState.Instance.currentItems = 0;
|
||||
|
||||
List<Task<List<Node>>> listOfTasks_Prosp = new();
|
||||
|
||||
foreach (var meso in _meso)
|
||||
{
|
||||
_city.AddRange(AppState.Instance.Suggestions!.Where(x => x.Meso == meso.Meso).Select(x => new Models.Suggestion { ID = x.ID, UF = x.UF, Meso = x.Meso, City = x.City }));
|
||||
}
|
||||
foreach (var city in _city)
|
||||
{
|
||||
listOfTasks_Prosp.Add((_apiService ?? new PipefyApiService(_httpClient)).GetCardsAsync("303017662", "cidade_importa_o", city, progress, _city.Count * 2));
|
||||
listOfTasks_Prosp.Add((_apiService ?? new PipefyApiService(_httpClient)).GetCardsAsync("303017678", "cidade", city, progress, _city.Count * 2));
|
||||
}
|
||||
|
||||
var allResults_Prosp = await Task.WhenAll(listOfTasks_Prosp);
|
||||
|
||||
List<Node> allResults = new();
|
||||
foreach (var result in allResults_Prosp)
|
||||
{
|
||||
allResults.AddRange(result);
|
||||
}
|
||||
|
||||
AppState.Instance.ProspeccaoFilteredCards.AddRange(allResults.OrderByDescending(x => (x.pipe ?? new Models.Pipe { name = "_" }).name));
|
||||
AppState.Instance.filterFlag = false;
|
||||
RunMutations.IsEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
endProgress(progress);
|
||||
}
|
||||
|
||||
AppState.Instance.ProspeccaoFilteredCards = AppState.Instance.ProspeccaoFilteredCards.Distinct().ToList();
|
||||
|
||||
AppState.Instance.Save();
|
||||
|
||||
CardsChangeBox.ItemsSource = AppState.Instance.ProspeccaoFilteredCards;
|
||||
|
||||
viewModel.LabelContent = "Cards filtrados: " + (AppState.Instance.ProspeccaoFilteredCards.Count);
|
||||
|
||||
}
|
||||
private void LoadUsers()
|
||||
{
|
||||
_users ??= AppState.Instance.Users;
|
||||
|
||||
UsersSuggestionsList.ItemsSource = null;
|
||||
UsersSuggestionsList.ItemsSource = _users;
|
||||
|
||||
UsersSearchBox.TextChanged += SearchBox_TextChanged;
|
||||
|
||||
UsersSuggestionsList.PreviewMouseLeftButtonDown += ListBox_MouseLeftButtonDown;
|
||||
|
||||
KeepProsp.IsChecked = AppState.Instance.KeepProsp;
|
||||
KeepResp.IsChecked = AppState.Instance.KeepResp;
|
||||
ProspectanteChangeBox.ItemsSource = null;
|
||||
ResponsavelChangeBox.ItemsSource = null;
|
||||
ProspectanteChangeBox.ItemsSource = AppState.Instance.Prospectante;
|
||||
ResponsavelChangeBox.ItemsSource = AppState.Instance.Others;
|
||||
|
||||
}
|
||||
private void ListBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is ListBox listBox)
|
||||
{
|
||||
var clickedItem = e.OriginalSource as FrameworkElement;
|
||||
|
||||
while (clickedItem != null && clickedItem is not ListBoxItem)
|
||||
{
|
||||
clickedItem = VisualTreeHelper.GetParent(clickedItem) as FrameworkElement;
|
||||
}
|
||||
|
||||
if (clickedItem is ListBoxItem)
|
||||
{
|
||||
var selectedItems = listBox.SelectedItems.OfType<Models.Users>().ToList();
|
||||
|
||||
if (selectedItems.Count > 0)
|
||||
{
|
||||
DragDrop.DoDragDrop(listBox, selectedItems, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ListBox_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effects = DragDropEffects.Move;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void HandleDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetData(typeof(List<Models.Users>)) is List<Models.Users> droppedData && sender is ListBox origin)
|
||||
{
|
||||
switch (origin.Name)
|
||||
{
|
||||
case "ProspectanteChangeBox":
|
||||
AppState.Instance.Prospectante.Clear();
|
||||
AppState.Instance.Prospectante.Add(droppedData[0]);
|
||||
|
||||
if (AppState.Instance.Others.Any(x => x.id == droppedData[0].id))
|
||||
{
|
||||
var existingItem = AppState.Instance.Others.First(x => x.id == droppedData[0].id);
|
||||
AppState.Instance.Others.Remove(existingItem);
|
||||
}
|
||||
break;
|
||||
|
||||
case "ResponsavelChangeBox":
|
||||
foreach (var item in droppedData)
|
||||
{
|
||||
if (!AppState.Instance.Others.Contains(item))
|
||||
{
|
||||
AppState.Instance.Others.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
AppState.Instance.Prospectante.RemoveAll(x => droppedData.Any(d => d.id == x.id));
|
||||
break;
|
||||
}
|
||||
|
||||
AppState.Instance.Save();
|
||||
ProspectanteChangeBox.ItemsSource = null;
|
||||
ProspectanteChangeBox.ItemsSource = AppState.Instance.Prospectante;
|
||||
ResponsavelChangeBox.ItemsSource = null;
|
||||
ResponsavelChangeBox.ItemsSource = AppState.Instance.Others;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
ListBox? origin = sender as ListBox;
|
||||
Models.Users? selectedItem = origin!.SelectedItem as Models.Users;
|
||||
|
||||
if (sender != null && (e.Key == Key.Delete || e.Key == Key.Back))
|
||||
{
|
||||
switch (origin!.Name)
|
||||
{
|
||||
case ("ProspectanteChangeBox"):
|
||||
|
||||
AppState.Instance.Prospectante.Remove(selectedItem!);
|
||||
|
||||
ProspectanteChangeBox.ItemsSource = null;
|
||||
ProspectanteChangeBox.ItemsSource = AppState.Instance.Prospectante;
|
||||
ProspectanteChangeBox.SelectedIndex = 0;
|
||||
|
||||
break;
|
||||
case ("ResponsavelChangeBox"):
|
||||
|
||||
AppState.Instance.Others.Remove(selectedItem!);
|
||||
|
||||
ResponsavelChangeBox.ItemsSource = null;
|
||||
ResponsavelChangeBox.ItemsSource = AppState.Instance.Others;
|
||||
ResponsavelChangeBox.SelectedIndex = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
AppState.Instance.Save();
|
||||
|
||||
}
|
||||
}
|
||||
static string RemoveDiacritics(string text)
|
||||
{
|
||||
var normalizedString = text.Normalize(NormalizationForm.FormD);
|
||||
var stringBuilder = new StringBuilder(capacity: normalizedString.Length);
|
||||
|
||||
for (int i = 0; i < normalizedString.Length; i++)
|
||||
{
|
||||
char c = normalizedString[i];
|
||||
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
|
||||
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
|
||||
{
|
||||
stringBuilder.Append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return stringBuilder
|
||||
.ToString()
|
||||
.Normalize(NormalizationForm.FormC);
|
||||
}
|
||||
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var filteredSuggestions = _users?.AsEnumerable() ?? Enumerable.Empty<Models.Users>();
|
||||
|
||||
List<Models.Users> list = filteredSuggestions.Where(
|
||||
x => RemoveDiacritics(x.email!.ToLower())?.Replace("@energiasmart.com.br", "").Replace("@smartenergia.com.br", "").Contains(RemoveDiacritics(UsersSearchBox.Text.ToLower())) ?? false).ToList();
|
||||
list.AddRange(filteredSuggestions.Where(
|
||||
x => RemoveDiacritics(x.name!.ToLower())?.Contains(RemoveDiacritics(UsersSearchBox.Text.ToLower())) ?? false));
|
||||
|
||||
|
||||
|
||||
UsersSuggestionsList.ItemsSource = null;
|
||||
UsersSuggestionsList.ItemsSource = list.Distinct();
|
||||
}
|
||||
|
||||
private void BackButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppState.Instance.Save();
|
||||
NavigationService?.Navigate(new Home());
|
||||
}
|
||||
private void ReloadButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var progress = new Progress<int>(percent =>
|
||||
{
|
||||
ProgressBar.Value = percent;
|
||||
ProgressBar.IsIndeterminate = percent == 0;
|
||||
});
|
||||
AppState.Instance.filterFlag = true;
|
||||
AppState.Instance.Save();
|
||||
FilterCards(progress);
|
||||
}
|
||||
|
||||
private void CheckBox_Changed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox? checkBox = sender as CheckBox;
|
||||
|
||||
Type type = AppState.Instance.GetType();
|
||||
|
||||
PropertyInfo propertyInfo = type.GetProperty(checkBox!.Name)!;
|
||||
|
||||
if (propertyInfo != null)
|
||||
{
|
||||
propertyInfo.SetValue(AppState.Instance, (bool)checkBox.IsChecked!);
|
||||
|
||||
if (checkBox.Name == "KeepProsp")
|
||||
{
|
||||
|
||||
labelProsp.IsEnabled = !((bool)checkBox.IsChecked);
|
||||
ProspectanteChangeBox.IsEnabled = !((bool)checkBox.IsChecked!);
|
||||
ProspAdd.IsEnabled = !((bool)checkBox.IsChecked!);
|
||||
ProspRemove.IsEnabled = !((bool)checkBox.IsChecked!);
|
||||
if ((bool)checkBox.IsChecked) { AppState.Instance.Prospectante.Clear(); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ProspectanteChangeBox.ItemsSource = null;
|
||||
ResponsavelChangeBox.ItemsSource = null;
|
||||
|
||||
ProspectanteChangeBox.ItemsSource = AppState.Instance.Prospectante;
|
||||
ResponsavelChangeBox.ItemsSource = AppState.Instance.Others;
|
||||
|
||||
AppState.Instance.Save();
|
||||
}
|
||||
|
||||
private void ProspAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedItems = UsersSuggestionsList.SelectedItems.OfType<Models.Users>().ToList();
|
||||
|
||||
if (selectedItems.Count > 0 && selectedItems is not null && !AppState.Instance.KeepProsp)
|
||||
{
|
||||
AppState.Instance.Prospectante.Clear();
|
||||
AppState.Instance.Prospectante.Add(selectedItems[0]);
|
||||
|
||||
if (AppState.Instance.Others.Any(x => x.id == selectedItems[0].id))
|
||||
{
|
||||
var existingItem = AppState.Instance.Others.First(x => x.id == selectedItems[0].id);
|
||||
AppState.Instance.Others.Remove(existingItem);
|
||||
}
|
||||
|
||||
UsersSuggestionsList.SelectedIndex = -1;
|
||||
|
||||
AppState.Instance.Save();
|
||||
ProspectanteChangeBox.ItemsSource = null;
|
||||
ProspectanteChangeBox.ItemsSource = AppState.Instance.Prospectante;
|
||||
ResponsavelChangeBox.ItemsSource = null;
|
||||
ResponsavelChangeBox.ItemsSource = AppState.Instance.Others;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProspRemove_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
AppState.Instance.Prospectante.Clear();
|
||||
|
||||
ProspectanteChangeBox.ItemsSource = null;
|
||||
ProspectanteChangeBox.ItemsSource = AppState.Instance.Prospectante;
|
||||
ProspectanteChangeBox.SelectedIndex = -1;
|
||||
|
||||
AppState.Instance.Save();
|
||||
|
||||
}
|
||||
|
||||
private void OtherAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedItems = UsersSuggestionsList.SelectedItems.OfType<Models.Users>().ToList();
|
||||
|
||||
if (selectedItems.Count > 0 && selectedItems is not null)
|
||||
{
|
||||
foreach (var item in selectedItems)
|
||||
{
|
||||
if (!AppState.Instance.Others.Contains(item))
|
||||
{
|
||||
AppState.Instance.Others.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
AppState.Instance.Prospectante.RemoveAll(x => selectedItems.Any(d => d.id == x.id));
|
||||
}
|
||||
|
||||
UsersSuggestionsList.SelectedIndex = -1;
|
||||
|
||||
AppState.Instance.Save();
|
||||
ProspectanteChangeBox.ItemsSource = null;
|
||||
ProspectanteChangeBox.ItemsSource = AppState.Instance.Prospectante;
|
||||
ResponsavelChangeBox.ItemsSource = null;
|
||||
ResponsavelChangeBox.ItemsSource = AppState.Instance.Others;
|
||||
|
||||
}
|
||||
|
||||
private void OtherRemove_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedItems = ResponsavelChangeBox.SelectedItems.OfType<Models.Users>().ToList();
|
||||
|
||||
if (selectedItems.Count > 0 && selectedItems != null)
|
||||
{
|
||||
foreach (var item in selectedItems)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
var select = AppState.Instance.Others.Where(x => x.id == item.id).First();
|
||||
AppState.Instance.Others.Remove(select);
|
||||
}
|
||||
}
|
||||
|
||||
AppState.Instance.Save();
|
||||
ProspectanteChangeBox.ItemsSource = null;
|
||||
ProspectanteChangeBox.ItemsSource = AppState.Instance.Prospectante;
|
||||
ResponsavelChangeBox.ItemsSource = null;
|
||||
ResponsavelChangeBox.ItemsSource = AppState.Instance.Others;
|
||||
|
||||
ResponsavelChangeBox.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private async void RunMutations_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool val = (
|
||||
!AppState.Instance.KeepProsp && AppState.Instance.Prospectante.Any()
|
||||
)
|
||||
||
|
||||
(
|
||||
AppState.Instance.KeepProsp && !AppState.Instance.KeepResp && !AppState.Instance.Prospectante.Any()
|
||||
)
|
||||
||
|
||||
(
|
||||
AppState.Instance.KeepProsp && !AppState.Instance.Prospectante.Any() && AppState.Instance.Others.Any()
|
||||
);
|
||||
|
||||
if (val && AppState.Instance.ProspeccaoFilteredCards.Any())
|
||||
{
|
||||
string Prosp = "Manter";
|
||||
string Resp = "Manter";
|
||||
|
||||
int first = 3;
|
||||
int count = AppState.Instance.Others.Count;
|
||||
|
||||
if (!AppState.Instance.KeepProsp && AppState.Instance.Prospectante.Any())
|
||||
{
|
||||
Prosp = AppState.Instance.Prospectante.Select(x => x.name).First() ?? "Erro";
|
||||
}
|
||||
|
||||
switch (AppState.Instance.KeepResp, AppState.Instance.Others.Any())
|
||||
{
|
||||
case (false, false):
|
||||
|
||||
Resp = "Limpar Demais Envolvidos";
|
||||
break;
|
||||
|
||||
case (false, true):
|
||||
|
||||
Resp = "Substituir todos por ";
|
||||
break;
|
||||
|
||||
case (true, true):
|
||||
|
||||
Resp = "Adicionar ";
|
||||
break;
|
||||
}
|
||||
|
||||
Resp += string.Join(", ", AppState.Instance.Others.Select(x => x.name).ToList().Take(first));
|
||||
|
||||
string plural = (count - first) > 1 ? "s" : "";
|
||||
|
||||
if (count > first) { Resp += $" e {count - first} outro{plural}."; }
|
||||
|
||||
string message = @$"Você está prestes a realizar as seguintes modificações em {AppState.Instance.ProspeccaoFilteredCards.Count} cards:
|
||||
|
||||
Prospectante:
|
||||
{Prosp}
|
||||
|
||||
Demais envolvidos:
|
||||
{Resp}
|
||||
|
||||
Deseja continuar?
|
||||
";
|
||||
|
||||
MessageBoxResult answer = MessageBox.Show(message, "Pipefy", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
if (answer.ToString() != "Yes") { return; }
|
||||
AppState.Instance.currentItems = 0;
|
||||
|
||||
var progress = new Progress<int>(percent =>
|
||||
{
|
||||
ProgressBar.Value = percent;
|
||||
ProgressBar.IsIndeterminate = percent == 0;
|
||||
});
|
||||
startProgress(progress);
|
||||
|
||||
List<Task<List<Node>>> listOfTasks = new();
|
||||
|
||||
List<Models.Node> currentCards = new();
|
||||
|
||||
List<Models.Node> allCards = new();
|
||||
|
||||
allCards.AddRange(AppState.Instance.ProspeccaoFilteredCards);
|
||||
|
||||
for (int i = 0; i < allCards.Count; i += 250)
|
||||
{
|
||||
currentCards.AddRange(allCards.Skip(i).Take(250));
|
||||
|
||||
listOfTasks.Add(
|
||||
(_apiService ?? new PipefyApiService(_httpClient)).
|
||||
MutateCardsAsync(
|
||||
currentCards,
|
||||
AppState.Instance.Prospectante,
|
||||
AppState.Instance.Others,
|
||||
AppState.Instance.KeepProsp,
|
||||
AppState.Instance.KeepResp,
|
||||
progress,
|
||||
AppState.Instance.ProspeccaoFilteredCards.Count
|
||||
)
|
||||
);
|
||||
|
||||
currentCards.Clear();
|
||||
|
||||
}
|
||||
|
||||
var allResults = await Task.WhenAll(listOfTasks);
|
||||
|
||||
AppState.Instance.recentMutations.Clear();
|
||||
|
||||
foreach (var result in allResults)
|
||||
{
|
||||
AppState.Instance.recentMutations.AddRange(result);
|
||||
}
|
||||
AppState.Instance.Save();
|
||||
|
||||
MessageBox.Show("Atualização concluída!", "Informação", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri) { UseShellExecute = true });
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
5
appsettings.json
Normal file
5
appsettings.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"IBGE_URL": "https://servicodados.ibge.gov.br/api/v1/localidades/municipios",
|
||||
"Pipefy_API_Key": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ1c2VyIjp7ImlkIjozMDIyODQxMDMsImVtYWlsIjoiYmFjazNAZW5lcmdpYXNtYXJ0LmNvbS5iciIsImFwcGxpY2F0aW9uIjozMDAyMzY4MDh9fQ.CXRzlEROM0fTCoOobH5FyHWnt6dcu0PvASi_gjpBqWSMynV7-6FsaC98JWLFpvW0p-jDgLzno7TDLuej2OD17A",
|
||||
"Pipefy_URL": "https://app.pipefy.com/queries"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user