summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
commit225aa1499e37faf9d38257caabbadc68d78b427e (patch)
tree102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs2102
1 files changed, 2102 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs
new file mode 100644
index 0000000..d48c992
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs
@@ -0,0 +1,2102 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+using System.Windows.Threading;
+using Agger.Registro;
+using Gestor.Application.Actions;
+using Gestor.Application.Componentes;
+using Gestor.Application.Drawers;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model;
+using Gestor.Application.Properties;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Common.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Aggilizador;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.MalaDireta;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.License;
+using MaterialDesignThemes.Wpf;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Xceed.Wpf.AvalonDock.Controls;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public abstract class BaseViewModel : INotifyPropertyChanged
+{
+ public ArquivoDigitalServico ArquivoDigitalServico;
+
+ public PermissaoArquivoDigitalServico ServicoPermissArquivoDigital;
+
+ public PermissaoUsuarioServico ServicoPermissUsuario;
+
+ public RestricaoUsuarioServico ServicoRestriUsuario;
+
+ public VendedorUsuarioServico ServicoVendedorUsuario;
+
+ public bool _incluirPermissEnabled;
+
+ public bool _alterarPermissEnabled;
+
+ public bool _excluirPermissEnabled;
+
+ public long LastAccessId;
+
+ public TipoTela LastAccessTela;
+
+ private bool _enableButtons = true;
+
+ private bool _enableIncluir = true;
+
+ private bool _isVisibleEmpresa;
+
+ private bool _enableAlterar;
+
+ private bool _enableExcluir;
+
+ private long? _lastId;
+
+ private bool _incluirParcelaEnabled;
+
+ private bool _alterarParcelaEnabled;
+
+ private bool _excluirParcelaEnabled;
+
+ private bool _permissaoWhatsapp;
+
+ public bool Initialized;
+
+ private bool _enableFields;
+
+ private bool _allowEditParcela;
+
+ private bool _isEnableEdit;
+
+ private bool _isEnabledEditEndosso;
+
+ private bool _enableMenu;
+
+ private bool _enableMainMenu;
+
+ private bool _isEnabled;
+
+ private Visibility _isVisible;
+
+ private object _popupContent;
+
+ public bool EnableButtons
+ {
+ get
+ {
+ return _enableButtons;
+ }
+ set
+ {
+ _enableButtons = value;
+ OnPropertyChanged("EnableButtons");
+ }
+ }
+
+ public bool EnableIncluir
+ {
+ get
+ {
+ return _enableIncluir;
+ }
+ set
+ {
+ _enableIncluir = _incluirPermissEnabled && value;
+ OnPropertyChanged("EnableIncluir");
+ }
+ }
+
+ public bool IsVisibleEmpresa
+ {
+ get
+ {
+ return _isVisibleEmpresa;
+ }
+ set
+ {
+ _isVisibleEmpresa = value;
+ OnPropertyChanged("IsVisibleEmpresa");
+ }
+ }
+
+ public bool EnableAlterar
+ {
+ get
+ {
+ return _enableAlterar;
+ }
+ set
+ {
+ _enableAlterar = _alterarPermissEnabled && value;
+ OnPropertyChanged("EnableAlterar");
+ }
+ }
+
+ public bool EnableExcluir
+ {
+ get
+ {
+ return _enableExcluir;
+ }
+ set
+ {
+ _enableExcluir = _excluirPermissEnabled && value;
+ OnPropertyChanged("EnableExcluir");
+ }
+ }
+
+ public bool IncluirParcelaEnabled
+ {
+ get
+ {
+ return _incluirParcelaEnabled;
+ }
+ set
+ {
+ _incluirParcelaEnabled = value;
+ OnPropertyChanged("IncluirParcelaEnabled");
+ }
+ }
+
+ public bool AlterarParcelaEnabled
+ {
+ get
+ {
+ return _alterarParcelaEnabled;
+ }
+ set
+ {
+ _alterarParcelaEnabled = value;
+ OnPropertyChanged("AlterarParcelaEnabled");
+ }
+ }
+
+ public bool ExcluirParcelaEnabled
+ {
+ get
+ {
+ return _excluirParcelaEnabled;
+ }
+ set
+ {
+ _excluirParcelaEnabled = value;
+ OnPropertyChanged("ExcluirParcelaEnabled");
+ }
+ }
+
+ public bool PermissaoWhatsapp
+ {
+ get
+ {
+ return _permissaoWhatsapp;
+ }
+ set
+ {
+ _permissaoWhatsapp = value;
+ OnPropertyChanged("PermissaoWhatsapp");
+ }
+ }
+
+ public bool EnableFields
+ {
+ get
+ {
+ return _enableFields;
+ }
+ set
+ {
+ _enableFields = value;
+ OnPropertyChanged("EnableFields");
+ }
+ }
+
+ public bool AllowEditParcela
+ {
+ get
+ {
+ return _allowEditParcela;
+ }
+ set
+ {
+ _allowEditParcela = value;
+ OnPropertyChanged("AllowEditParcela");
+ }
+ }
+
+ public bool IsEnabledEdit
+ {
+ get
+ {
+ return _isEnableEdit;
+ }
+ set
+ {
+ _isEnableEdit = value;
+ OnPropertyChanged("IsEnabledEdit");
+ }
+ }
+
+ public bool IsEnabledEditEndosso
+ {
+ get
+ {
+ return _isEnabledEditEndosso;
+ }
+ set
+ {
+ _isEnabledEditEndosso = value;
+ OnPropertyChanged("IsEnabledEditEndosso");
+ }
+ }
+
+ public bool EnableMenu
+ {
+ get
+ {
+ return _enableMenu;
+ }
+ set
+ {
+ _enableMenu = value;
+ OnPropertyChanged("EnableMenu");
+ }
+ }
+
+ public bool EnableMainMenu
+ {
+ get
+ {
+ return _enableMainMenu;
+ }
+ set
+ {
+ _enableMainMenu = value;
+ OnPropertyChanged("EnableMainMenu");
+ }
+ }
+
+ public bool IsEnabled
+ {
+ get
+ {
+ return _isEnabled;
+ }
+ set
+ {
+ _isEnabled = value;
+ OnPropertyChanged("IsEnabled");
+ }
+ }
+
+ public Visibility IsVisible
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisible;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisible = value;
+ OnPropertyChanged("IsVisible");
+ }
+ }
+
+ public string ErroCamposInvalidos { get; }
+
+ public object PopupContent
+ {
+ get
+ {
+ return _popupContent;
+ }
+ set
+ {
+ _popupContent = value;
+ OnPropertyChanged("PopupContent");
+ }
+ }
+
+ public AutoCompleteFilterPredicate<object> CoberturaItemFilter => (string searchText, object obj) => ((CoberturaPadrao)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected BaseViewModel()
+ {
+ //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
+ int isVisibleEmpresa;
+ if (LicenseHelper.Produtos != null && LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 2 && x.Status == 1))
+ {
+ Empresa empresa = Recursos.Empresa;
+ isVisibleEmpresa = ((empresa != null && ((DomainBase)empresa).Id == 1) ? 1 : 0);
+ }
+ else
+ {
+ isVisibleEmpresa = 0;
+ }
+ _isVisibleEmpresa = (byte)isVisibleEmpresa != 0;
+ _enableAlterar = true;
+ _enableExcluir = true;
+ _permissaoWhatsapp = true;
+ _allowEditParcela = true;
+ _isEnableEdit = true;
+ _isEnabledEditEndosso = true;
+ Usuario usuario = Recursos.Usuario;
+ _enableMenu = usuario != null && ((DomainBase)usuario).Id > 0;
+ _enableMainMenu = true;
+ _isEnabled = true;
+ _isVisible = (Visibility)2;
+ ErroCamposInvalidos = "HÁ CAMPOS DESTACADOS QUE DEVEM SER PREENCHIDOS CORRETAMENTE." + Environment.NewLine + "REALIZE A CORREÇÃO E TENTE NOVAMENTE.";
+ base._002Ector();
+ ArquivoDigitalServico = new ArquivoDigitalServico();
+ Gestor.Application.Actions.Actions.EnableMainMenu = (Action<bool>)Delegate.Combine(Gestor.Application.Actions.Actions.EnableMainMenu, new Action<bool>(HabilitarMenu));
+ Gestor.Application.Actions.Actions.EnableMenu = (Action<bool>)Delegate.Combine(Gestor.Application.Actions.Actions.EnableMenu, new Action<bool>(HabilitarMenuSecundario));
+ ServicoPermissArquivoDigital = new PermissaoArquivoDigitalServico();
+ ServicoPermissUsuario = new PermissaoUsuarioServico();
+ ServicoRestriUsuario = new RestricaoUsuarioServico();
+ ServicoVendedorUsuario = new VendedorUsuarioServico();
+ }
+
+ public void VerificarEnables(long? id)
+ {
+ _lastId = id;
+ EnableIncluir = !id.HasValue || id.Value >= 0;
+ EnableAlterar = id.HasValue && id.Value > 0;
+ EnableExcluir = id.HasValue && id.Value > 0;
+ EnableButtons = id.HasValue && id.Value > 0;
+ }
+
+ public async Task<bool> PermissaoConsultar(TipoTela tela)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ return true;
+ }
+ PermissaoUsuario obj = await ServicoPermissUsuario.VerificarPermissao(Recursos.Usuario, tela);
+ return obj == null || obj.Consultar;
+ }
+
+ public async Task PermissaoTela(TipoTela tela)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ EnableIncluir = false;
+ EnableAlterar = false;
+ EnableExcluir = false;
+ if (((DomainBase)Recursos.Usuario).Id != 0L)
+ {
+ PermissaoUsuario val = await ServicoPermissUsuario.VerificarPermissao(Recursos.Usuario, tela);
+ if ((int)tela == 5)
+ {
+ IncluirParcelaEnabled = val == null || val.Incluir;
+ AlterarParcelaEnabled = val == null || val.Alterar;
+ ExcluirParcelaEnabled = val == null || val.Excluir;
+ }
+ else if ((int)tela == 24 || (int)tela == 26 || (int)tela == 29 || (int)tela == 28 || (int)tela == 27)
+ {
+ _incluirPermissEnabled = true;
+ _alterarPermissEnabled = true;
+ _excluirPermissEnabled = true;
+ }
+ else
+ {
+ _incluirPermissEnabled = val == null || val.Incluir;
+ _alterarPermissEnabled = val == null || val.Alterar;
+ _excluirPermissEnabled = val == null || val.Excluir;
+ }
+ }
+ }
+
+ public async Task PermissaoArquivoDigital(TipoArquivoDigital tela)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ EnableIncluir = false;
+ EnableExcluir = false;
+ if (((DomainBase)Recursos.Usuario).Id != 0L)
+ {
+ PermissaoArquivoDigital val = await ServicoPermissArquivoDigital.VerificarPermissao(Recursos.Usuario, tela);
+ _incluirPermissEnabled = val == null || val.Incluir;
+ _excluirPermissEnabled = val == null || val.Excluir;
+ }
+ }
+
+ public async Task VerificarVersao()
+ {
+ bool flag;
+ try
+ {
+ string text = await Connection.Get<string>($"Update/Stable?versao={ApplicationHelper.Versao}");
+ flag = text != null && bool.Parse(text);
+ }
+ catch (Exception e)
+ {
+ new BaseServico().Registrar(e, (TipoErro)287, 3, ApplicationHelper.Versao.ToString(), abrirTela: false);
+ flag = false;
+ }
+ if (!flag)
+ {
+ ApplicationHelper.ChecagemVersao = Funcoes.GetNetworkTime();
+ return;
+ }
+ await ShowMessage("HÁ UMA ATUALIZAÇÃO OBRIGATÓRIA A SER FEITA. O PROCESSO SERÁ CANCELADO PARA A ATUALIZAÇÃO");
+ Application.Current.Shutdown();
+ }
+
+ public async void Alterar(bool alterar)
+ {
+ Gestor.Application.Actions.Actions.EnablePesquisarClientes?.Invoke(!alterar);
+ Gestor.Application.Actions.Actions.EnableMenu?.Invoke(!alterar);
+ Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(!alterar);
+ EnableFields = alterar;
+ EnableMenu = !alterar;
+ if (!alterar)
+ {
+ VerificarEnables(_lastId);
+ }
+ else
+ {
+ EnableIncluir = false;
+ EnableAlterar = false;
+ EnableExcluir = false;
+ EnableButtons = false;
+ }
+ AllowEditParcela = !alterar;
+ IsEnabledEdit = !alterar;
+ IsEnabledEditEndosso = !alterar;
+ if ((Funcoes.GetNetworkTime() - ApplicationHelper.ChecagemVersao).TotalMinutes > 10.0)
+ {
+ await VerificarVersao();
+ }
+ }
+
+ private void HabilitarMenu(bool enable)
+ {
+ EnableMainMenu = enable;
+ }
+
+ private void HabilitarMenuSecundario(bool enable)
+ {
+ EnableMenu = enable;
+ }
+
+ public void OnPropertyChanged([CallerMemberName] string name = "")
+ {
+ this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
+ }
+
+ public void Loading(bool isLoading)
+ {
+ Grid progressRing = App.ProgressRing;
+ if (progressRing == null)
+ {
+ return;
+ }
+ Dispatcher dispatcher = ((DispatcherObject)progressRing).Dispatcher;
+ if (dispatcher != null)
+ {
+ dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate
+ {
+ LoadingThread(isLoading);
+ });
+ }
+ }
+
+ public void LoadingThread(bool isLoading)
+ {
+ IsVisible = (Visibility)(isLoading ? 2 : 0);
+ ((UIElement)App.ProgressRing).Visibility = (Visibility)((!isLoading) ? 2 : 0);
+ IsEnabled = !isLoading;
+ }
+
+ public async Task<EnderecoBase> BuscaCep(string cep)
+ {
+ return await new CepService().SearchDirect(cep);
+ }
+
+ internal void ShowDrawer(object content, int position, bool close = true)
+ {
+ Window? obj = ((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive));
+ DrawerHost val = Extentions.FindVisualChildren<DrawerHost>((DependencyObject)(object)obj).FirstOrDefault();
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)obj).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ if (val == null)
+ {
+ return;
+ }
+ switch (position)
+ {
+ case 1:
+ val.TopDrawerContent = content;
+ val.IsTopDrawerOpen = true;
+ val.TopDrawerCloseOnClickAway = close;
+ return;
+ case 2:
+ val.LeftDrawerContent = content;
+ val.IsLeftDrawerOpen = true;
+ val.LeftDrawerCloseOnClickAway = close;
+ return;
+ case 3:
+ val.BottomDrawerContent = content;
+ val.IsBottomDrawerOpen = true;
+ val.BottomDrawerCloseOnClickAway = close;
+ return;
+ }
+ if (val.IsRightDrawerOpen && (val.RightDrawerContent == null || val.RightDrawerContent.GetType() != content.GetType()))
+ {
+ val.LeftDrawerContent = content;
+ val.IsLeftDrawerOpen = true;
+ val.LeftDrawerCloseOnClickAway = close;
+ }
+ else
+ {
+ val.IsRightDrawerOpen = true;
+ val.RightDrawerContent = content;
+ val.RightDrawerCloseOnClickAway = close;
+ }
+ }
+
+ internal void CloseDrawer()
+ {
+ Window? obj = ((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive));
+ DrawerHost val = Extentions.FindVisualChildren<DrawerHost>((DependencyObject)(object)obj).FirstOrDefault();
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)obj).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)0;
+ });
+ if (val != null)
+ {
+ val.IsBottomDrawerOpen = false;
+ val.IsTopDrawerOpen = false;
+ if (val.IsLeftDrawerOpen)
+ {
+ val.IsLeftDrawerOpen = false;
+ }
+ else
+ {
+ val.IsRightDrawerOpen = false;
+ }
+ }
+ }
+
+ internal DialogHost GetHost()
+ {
+ DialogHost val = Extentions.FindVisualChildren<DialogHost>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).FirstOrDefault();
+ if (val == null)
+ {
+ foreach (Window item in ((IEnumerable)Application.Current.Windows).OfType<Window>())
+ {
+ val = Extentions.FindVisualChildren<DialogHost>((DependencyObject)(object)item).FirstOrDefault();
+ if (val != null && !val.IsOpen)
+ {
+ break;
+ }
+ }
+ }
+ if (val == null || !val.IsOpen)
+ {
+ return val;
+ }
+ return null;
+ }
+
+ internal async Task<bool> ShowMessage(string message, string accept = "OK", string cancel = "", bool root = false)
+ {
+ DialogHost val = null;
+ if (!root)
+ {
+ val = GetHost();
+ if (val == null)
+ {
+ return false;
+ }
+ }
+ DefaultDialog defaultDialog = new DefaultDialog();
+ ((FrameworkElement)defaultDialog).DataContext = new DialogViewModel
+ {
+ AcceptContent = accept,
+ CancelContent = cancel,
+ Message = message
+ };
+ DefaultDialog dialogControl = defaultDialog;
+ return await ExecuteRunExtendedDialog((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task<ConfiguracaoImpressao> ShowDialogPrint(Relatorio relatorio, Type tipo)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogPrint dialogControl = new DialogPrint(relatorio, tipo);
+ return await ExecuteRunExtendedDialogPrint((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<ConfiguracaoImpressao> ExecuteRunExtendedDialogPrint(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ return (ConfiguracaoImpressao)(await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler)));
+ }
+
+ internal async Task<List<ArquivoDigital>> ShowDialogAnexar(List<ArquivoDigital> arquivos, bool root = false)
+ {
+ DialogHost val = null;
+ if (!root)
+ {
+ val = GetHost();
+ if (val != null && val.IsOpen)
+ {
+ return arquivos;
+ }
+ }
+ DialogAnexar dialogControl = new DialogAnexar(arquivos);
+ return await ExecuteRunExtendedDialogAnexar((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<List<ArquivoDigital>> ExecuteRunExtendedDialogAnexar(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ return (List<ArquivoDigital>)(await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandlerArquivo)));
+ }
+
+ internal async Task ShowDialogAdvertising(bool root = false)
+ {
+ _ = 1;
+ try
+ {
+ DialogHost host = null;
+ if (!root)
+ {
+ host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return;
+ }
+ }
+ DialogAdvertising dialogAdvertising = await CreateDialogAdvertising();
+ if (dialogAdvertising != null)
+ {
+ await ExecuteRunExtendedDialogAdvertising((UserControl)(object)dialogAdvertising, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+ }
+ catch
+ {
+ }
+ }
+
+ private async Task<DialogAdvertising> CreateDialogAdvertising()
+ {
+ JObject val = await LoadJsonAdvertising(Address.SurveyJson);
+ if (val == null)
+ {
+ return await LoadDialogAdertisingPromo();
+ }
+ JToken obj = val["Inicio"];
+ DateTime? dateTime = ((obj != null) ? new DateTime?(Extensions.Value<DateTime>((IEnumerable<JToken>)obj)) : null);
+ JToken obj2 = val["Fim"];
+ DateTime? dateTime2 = ((obj2 != null) ? new DateTime?(Extensions.Value<DateTime>((IEnumerable<JToken>)obj2)) : null);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Gestor.Application.Model.Configuracoes configuracoes = LoadConfiguracoes();
+ JToken obj3 = val["UrlPost"];
+ string text = ((obj3 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj3) : null);
+ if (ValidationHelper.IsNullOrEmpty(text))
+ {
+ JToken obj4 = val["UrlFixa"];
+ text = ((obj4 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj4) : null) ?? string.Empty;
+ }
+ if (configuracoes.LinkPromo == text || configuracoes.NaoverPromo)
+ {
+ return null;
+ }
+ return (!(dateTime2 >= networkTime) || !(dateTime <= networkTime)) ? (await LoadDialogAdertisingPromo()) : new DialogAdvertising(val, isPromo: false);
+ }
+
+ private Gestor.Application.Model.Configuracoes LoadConfiguracoes()
+ {
+ CriarConfiguracaoPadrao("config.json");
+ return JsonConvert.DeserializeObject<Gestor.Application.Model.Configuracoes>(File.ReadAllText("config.json"));
+ }
+
+ private async Task<DialogAdvertising> LoadDialogAdertisingPromo()
+ {
+ Gestor.Application.Model.Configuracoes config = LoadConfiguracoes();
+ JObject val = await LoadJsonAdvertising(Address.JsonPromo());
+ if (val == null)
+ {
+ return null;
+ }
+ JToken obj = val["Imagem"];
+ string text = ((obj != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj) : null) ?? string.Empty;
+ if (config.LinkPromo == text || config.NaoverPromo)
+ {
+ return null;
+ }
+ return new DialogAdvertising(val);
+ }
+
+ private async Task<JObject> LoadJsonAdvertising(Uri location)
+ {
+ HttpClient client = new HttpClient();
+ try
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ client.Timeout = TimeSpan.FromSeconds(20.0);
+ HttpResponseMessage val = await client.GetAsync(location);
+ return (!val.IsSuccessStatusCode) ? null : JObject.Parse(await val.Content.ReadAsStringAsync());
+ }
+ finally
+ {
+ ((IDisposable)client)?.Dispose();
+ }
+ }
+
+ private void CriarConfiguracaoPadrao(string configFile)
+ {
+ if (!File.Exists(configFile))
+ {
+ Gestor.Application.Model.Configuracoes configuracoes = new Gestor.Application.Model.Configuracoes
+ {
+ LinkPromo = "",
+ NaoverPromo = false
+ };
+ File.WriteAllText(configFile, JsonConvert.SerializeObject((object)configuracoes, (Formatting)1));
+ }
+ }
+
+ public async Task ExecuteRunExtendedDialogAdvertising(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandlerArquivo));
+ }
+
+ internal async Task<bool> ShowMessage(List<KeyValuePair<string, string>> pairs, string message, string accept, string cancel = "")
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return false;
+ }
+ ErrorDialog errorDialog = new ErrorDialog();
+ ((FrameworkElement)errorDialog).DataContext = new ErrorDialogViewModel
+ {
+ Erros = pairs.Select((KeyValuePair<string, string> pair) => new KeyValuePair<string, string>(pair.Key.Contains("|") ? pair.Key.Substring(pair.Key.IndexOf("|", StringComparison.Ordinal) + 1) : pair.Key, pair.Value)).ToList(),
+ AcceptContent = accept,
+ CancelContent = cancel,
+ Message = message
+ };
+ ErrorDialog dialogControl = errorDialog;
+ return await ExecuteRunExtendedDialog((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task ShowMedalha(int liquido, int comissao, int resultado, int media)
+ {
+ DialogHost host = GetHost();
+ if (host == null || !host.IsOpen)
+ {
+ DialogMedalha dialogControl = new DialogMedalha(liquido, comissao, resultado, media);
+ await ExecuteRunExtendedDialog((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+ }
+
+ internal async Task<bool?> ShowSenha(string mensagem)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return false;
+ }
+ DialogSenhaAdm dialogControl = new DialogSenhaAdm(mensagem);
+ return await ExecuteRunExtendedDialogSenha((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task<Instalacao> ShowInstalacoes(List<Instalacao> instalacoes)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogInstalacoes dialogControl = new DialogInstalacoes(instalacoes);
+ return await ExecuteRunExtendedDialogInstalacoes((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Instalacao> ExecuteRunExtendedDialogInstalacoes(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ object obj2 = obj;
+ if (obj2 == null || (obj2 is bool && !(bool)obj2))
+ {
+ return null;
+ }
+ return (Instalacao)obj;
+ }
+
+ internal async Task<Prospeccao> ShowProspeccaoDialog(Prospeccao prospecao)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ ProspeccaoDialog dialogControl = new ProspeccaoDialog(prospecao);
+ return await ExecuteRunExtendedDialogProspeccao((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Prospeccao> ExecuteRunExtendedDialogProspeccao(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Prospeccao)obj;
+ }
+
+ public async Task<bool> ExecuteRunExtendedDialog(UserControl dialogControl, string hostName)
+ {
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ DialogHost.CloseDialogCommand.Execute((object)null, (IInputElement)null);
+ return obj != null && (bool)obj;
+ }
+
+ public async Task<bool?> ExecuteRunExtendedDialogSenha(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ return (bool?)(await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler)));
+ }
+
+ public void ExtendedOpenedEventHandler(object sender, DialogOpenedEventArgs eventargs)
+ {
+ IsEnabled = false;
+ }
+
+ public void ExtendedClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
+ {
+ IsEnabled = true;
+ Window? obj = ((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive));
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)obj).ToList().ForEach(delegate(WebEditor x)
+ {
+ if (!x.IsReadOnly)
+ {
+ ((UIElement)x).Visibility = (Visibility)0;
+ }
+ });
+ Extentions.FindVisualChildren<DrawerHost>((DependencyObject)(object)obj).Any((DrawerHost x) => x.IsLeftDrawerOpen || x.IsBottomDrawerOpen || x.IsRightDrawerOpen || x.IsTopDrawerOpen);
+ }
+
+ public void ExtendedClosingEventHandlerArquivo(object sender, DialogClosingEventArgs eventArgs)
+ {
+ IsEnabled = true;
+ Extentions.FindVisualChildren<DrawerHost>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).Any((DrawerHost x) => x.IsLeftDrawerOpen || x.IsBottomDrawerOpen || x.IsRightDrawerOpen || x.IsTopDrawerOpen);
+ }
+
+ public void ToggleSnackBar(string message, bool active = true)
+ {
+ Snackbar val = Extentions.FindVisualChildren<Snackbar>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).FirstOrDefault();
+ if (val != null)
+ {
+ ((ContentControl)val.Message).Content = message;
+ val.IsActive = active;
+ if (active)
+ {
+ Task.Factory.StartNew(CloseSlackBar);
+ }
+ }
+ }
+
+ private void CloseSlackBar()
+ {
+ Thread.Sleep(5000);
+ Dispatcher dispatcher = ((DispatcherObject)App.ProgressRing).Dispatcher;
+ if (dispatcher != null)
+ {
+ dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate
+ {
+ ToggleSnackBar("", active: false);
+ });
+ }
+ }
+
+ public async Task<List<string>> ValidateAttachment(List<ArquivoDigital> attachments, List<string> files)
+ {
+ string message = ("Os Arquivos Abaixo não podem ser anexados pois não possuem Formatos válidos, são maiores que o permitido ou já foram anexados!" + Environment.NewLine + Environment.NewLine).ToUpper();
+ List<string> result = new List<string>();
+ bool error = false;
+ foreach (string x in files)
+ {
+ try
+ {
+ if (attachments?.Exists(delegate(ArquivoDigital a)
+ {
+ string text2 = ValidationHelper.RemoveDiacritics(a.Descricao.ToUpper());
+ string? fileNameWithoutExtension = Path.GetFileNameWithoutExtension(x);
+ return text2 == ((fileNameWithoutExtension != null) ? ValidationHelper.RemoveDiacritics(fileNameWithoutExtension.ToUpper()) : null);
+ }) ?? false)
+ {
+ message += Path.GetFileName(x);
+ error = true;
+ continue;
+ }
+ FileInfo fileInfo = new FileInfo(x);
+ if (fileInfo.Length > 1024 && fileInfo.Length / 1024 > ((Recursos.Empresa.MaxFileSize > 0) ? Recursos.Empresa.MaxFileSize : 14336))
+ {
+ message += Path.GetFileName(x);
+ error = true;
+ continue;
+ }
+ string text = Path.GetExtension(x)?.ToLower();
+ if (text != null)
+ {
+ int length = text.Length;
+ if (length != 4)
+ {
+ if (length == 5)
+ {
+ switch (text[2])
+ {
+ case 'o':
+ break;
+ case 'l':
+ goto IL_0341;
+ case 'p':
+ goto IL_0351;
+ case 's':
+ goto IL_0361;
+ default:
+ goto IL_036f;
+ }
+ if (text == ".docx")
+ {
+ goto IL_038d;
+ }
+ }
+ }
+ else
+ {
+ switch (text[1])
+ {
+ case 't':
+ break;
+ case 'd':
+ goto IL_0243;
+ case 'x':
+ goto IL_0259;
+ case 'j':
+ goto IL_026f;
+ case 'p':
+ goto IL_0285;
+ case 'b':
+ goto IL_02ac;
+ case 'z':
+ goto IL_02c2;
+ case 'r':
+ goto IL_02d8;
+ case 'm':
+ goto IL_02ee;
+ case 'e':
+ goto IL_0301;
+ case 'a':
+ goto IL_0311;
+ case 'o':
+ goto IL_0321;
+ default:
+ goto IL_036f;
+ }
+ if (text == ".txt")
+ {
+ goto IL_038d;
+ }
+ }
+ }
+ goto IL_036f;
+ IL_0285:
+ if (!(text == ".png") && !(text == ".pdf"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_026f:
+ if (!(text == ".jpg"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0311:
+ if (!(text == ".amr"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_02d8:
+ if (!(text == ".rar"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0321:
+ if (!(text == ".ogg"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0301:
+ if (!(text == ".eml"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_02ac:
+ if (!(text == ".bmp"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0243:
+ if (!(text == ".doc"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_02ee:
+ if (!(text == ".msg"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0361:
+ if (!(text == ".json"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_038d:
+ result.Add(x);
+ goto end_IL_0080;
+ IL_0341:
+ if (!(text == ".xlsx"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_036f:
+ message += Path.GetFileName(x);
+ goto end_IL_0080;
+ IL_0351:
+ if (!(text == ".jpeg"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0259:
+ if (!(text == ".xls"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_02c2:
+ if (!(text == ".zip"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ end_IL_0080:;
+ }
+ catch (Exception)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL CARREGAR O ARQUIVO " + x + "." + Environment.NewLine + "O ARQUIVO ESTÁ INACESSÍVEL OU SENDO UTILIZADO POR OUTRO PROCESSO.");
+ }
+ }
+ if (error)
+ {
+ await ShowMessage((message + Environment.NewLine + Environment.NewLine + "Favor Corrija antes de tentar novamente.").ToUpper());
+ }
+ return result;
+ }
+
+ public async Task<List<ArquivoDigital>> AddAttachments(List<ArquivoDigital> attachments, List<ArquivoDigital> attacheds)
+ {
+ List<string> list = new List<string>();
+ OpenFileDialog val = new OpenFileDialog();
+ try
+ {
+ val.Multiselect = true;
+ ((FileDialog)val).Filter = "Todos os Arquivos|*.pdf;*.jpg;*.jpeg;*.png;*.bmp;*.doc;*.docx;*.xls;*.xlsx;*.json;*.rar;*.zip;*.msg;*.eml;*.txt|Arquivos PDF|*.pdf|Imagens|*.jpg;*.jpeg;*.png;*.bmp|Documentos|*.doc;*.docx;*.msg|Planilhas|*.xls;*.xlsx|Arquivos do Aggilizador|*.json|Arquivos de Áudio|*.amr;*.ogg";
+ ((FileDialog)val).InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return null;
+ }
+ list.AddRange(((FileDialog)val).FileNames);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ list = await ValidateAttachment(attacheds, await ValidateAttachment(attachments, list));
+ attachments = new List<ArquivoDigital>();
+ foreach (string item2 in list)
+ {
+ try
+ {
+ string extension = Path.GetExtension(item2);
+ using MemoryStream memoryStream = new MemoryStream(File.ReadAllBytes(item2));
+ byte[] array = new byte[memoryStream.Length];
+ memoryStream.Position = 0L;
+ memoryStream.Read(array, 0, array.Length);
+ ArquivoDigital item = new ArquivoDigital
+ {
+ Arquivo = array,
+ Descricao = Path.GetFileNameWithoutExtension(item2),
+ Extensao = extension
+ };
+ attachments.Add(item);
+ }
+ catch (Exception)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL CARREGAR O ARQUIVO " + item2 + "." + Environment.NewLine + "O ARQUIVO ESTÁ INACESSÍVEL OU SENDO UTILIZADO POR OUTRO PROCESSO.");
+ }
+ }
+ return (attachments.Count == 0) ? null : attachments;
+ }
+
+ public async void Download(IndiceArquivoDigital indice, bool open = true)
+ {
+ if (((DomainBase)indice).Id == 0L)
+ {
+ return;
+ }
+ ArquivoDigital arquivo = null;
+ if (indice.Assinado)
+ {
+ ArquivoDigital val = await ArquivoDigitalServico.BuscarPorId(((DomainBase)indice).Id);
+ if (((val != null) ? val.Arquivo : null) != null)
+ {
+ if (!val.Extensao.Contains("."))
+ {
+ val.Extensao = "." + val.Extensao;
+ }
+ arquivo = val;
+ }
+ }
+ if (arquivo == null)
+ {
+ arquivo = await ArquivoDigitalServico.BuscarPorId(indice.IdArquivoDigital, indice.Bd);
+ }
+ ArquivoDigital obj = arquivo;
+ if (((obj != null) ? obj.Arquivo : null) == null || arquivo.Extensao == null)
+ {
+ string text = "DOCUMENTO NÃO POSSUI PDF";
+ if (indice.DataCriacao?.Year <= DateTime.Now.Year - 5)
+ {
+ text += " OU POR SER UM ARQUIVO ANTIGO, TENTE NOVAMENTE EM ALGUNS MINUTOS";
+ }
+ await ShowMessage(text + ".");
+ return;
+ }
+ if (open)
+ {
+ if (Abrir(indice, arquivo))
+ {
+ return;
+ }
+ await ShowMessage("NÃO FOI POSSÍVEL ABRIR O ARQUIVO. ESCOLHA UM LOCAL PARA SALVAR O ARQUIVO.");
+ }
+ SaveFileDialog sfd = new SaveFileDialog();
+ try
+ {
+ ((FileDialog)sfd).Filter = "All Files|*.*";
+ ((FileDialog)sfd).FileName = indice.Descricao;
+ if (1 != (int)((CommonDialog)sfd).ShowDialog())
+ {
+ return;
+ }
+ if (File.Exists(((FileDialog)sfd).FileName + ValidationHelper.GetDefaultExtension(arquivo.Extensao)))
+ {
+ await ShowMessage("JÁ EXISTE UM ARQUIVO COM O NOME DE " + arquivo.Descricao + ValidationHelper.GetDefaultExtension(arquivo.Extensao) + " NA PASTA SELECIONADA. " + Environment.NewLine + "TENTE NOVAMENTE EM OUTRA PASTA.");
+ return;
+ }
+ using BinaryWriter binaryWriter = new BinaryWriter(File.Open(((FileDialog)sfd).FileName + ValidationHelper.GetDefaultExtension(arquivo.Extensao), FileMode.Create));
+ binaryWriter.Write(arquivo.Arquivo);
+ }
+ finally
+ {
+ ((IDisposable)sfd)?.Dispose();
+ }
+ }
+
+ public async Task<string> Salvar(IndiceArquivoDigital indice)
+ {
+ if (((DomainBase)indice).Id == 0L)
+ {
+ return null;
+ }
+ ArquivoDigital val = await ArquivoDigitalServico.BuscarPorId(indice.IdArquivoDigital, indice.Bd);
+ if (((val != null) ? val.Arquivo : null) == null || val.Extensao == null)
+ {
+ return null;
+ }
+ string tempPath = Path.GetTempPath();
+ string text = $"{tempPath}{val.AzureGuid ?? Guid.NewGuid()}{ValidationHelper.GetDefaultExtension(val.Extensao)}";
+ using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(text, FileMode.Create)))
+ {
+ binaryWriter.Write(val.Arquivo);
+ }
+ return text;
+ }
+
+ public bool Abrir(IndiceArquivoDigital indice, ArquivoDigital arquivo)
+ {
+ string tempPath = Path.GetTempPath();
+ string text = $"{tempPath}{arquivo.AzureGuid ?? Guid.NewGuid()}{ValidationHelper.GetDefaultExtension(arquivo.Extensao)}";
+ try
+ {
+ using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(text, FileMode.Create)))
+ {
+ binaryWriter.Write(arquivo.Arquivo);
+ }
+ Process.Start(text);
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public async Task<bool> DownloadAll(List<IndiceArquivoDigital> indices, long id)
+ {
+ FolderBrowserDialog val = new FolderBrowserDialog();
+ string selectedPath;
+ try
+ {
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return false;
+ }
+ selectedPath = $"{val.SelectedPath}\\{id}";
+ Directory.CreateDirectory(selectedPath);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ int count = 1;
+ foreach (IndiceArquivoDigital indice in indices)
+ {
+ ArquivoDigital arquivo = null;
+ if (indice.Assinado)
+ {
+ ArquivoDigital val2 = await ArquivoDigitalServico.BuscarPorId(((DomainBase)indice).Id);
+ if (((val2 != null) ? val2.Arquivo : null) != null)
+ {
+ arquivo = val2;
+ }
+ }
+ if (arquivo == null)
+ {
+ arquivo = await ArquivoDigitalServico.BuscarPorId(indice.IdArquivoDigital, indice.Bd);
+ }
+ ArquivoDigital obj = arquivo;
+ if (((obj != null) ? obj.Arquivo : null) == null || arquivo.Extensao == null)
+ {
+ return false;
+ }
+ if (File.Exists(ValidationHelper.NormalizePath(selectedPath + "\\" + indice.Descricao + ValidationHelper.GetDefaultExtension(arquivo.Extensao))))
+ {
+ indice.Descricao = $"{indice.Descricao}_{count}";
+ count++;
+ }
+ using BinaryWriter binaryWriter = new BinaryWriter(File.Open(ValidationHelper.NormalizePath(selectedPath + "\\" + indice.Descricao + ValidationHelper.GetDefaultExtension(arquivo.Extensao)), FileMode.Create));
+ binaryWriter.Write(arquivo.Arquivo);
+ }
+ Process.Start(selectedPath);
+ return true;
+ }
+
+ public async Task DownloadAll(List<long> ids, TipoArquivoVinculo type)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (ids == null || ids.Count == 0)
+ {
+ return;
+ }
+ string selectedPath = $"{Path.GetTempPath()}{Guid.NewGuid()}";
+ BaseServico baseServico = new BaseServico();
+ ArquivoDigitalServico attachment = new ArquivoDigitalServico();
+ List<ArquivoVinculo> arquivos = await baseServico.ArquivoVinculo(ids, type);
+ int count = 1;
+ if (!Directory.Exists(selectedPath))
+ {
+ Directory.CreateDirectory(selectedPath);
+ }
+ foreach (ArquivoVinculo item in await attachment.BaixarArquivosPendentes(arquivos))
+ {
+ if (((item != null) ? item.Arquivo : null) != null)
+ {
+ string text = Guid.NewGuid().ToString();
+ if (File.Exists(selectedPath + "\\" + text + ".pdf"))
+ {
+ text = $"{text}_{count}";
+ count++;
+ }
+ using BinaryWriter binaryWriter = new BinaryWriter(File.Open(selectedPath + "\\" + text + ".pdf", FileMode.Create));
+ binaryWriter.Write(item.Arquivo);
+ }
+ }
+ Process.Start(selectedPath);
+ }
+
+ internal async Task<List<Banco>> BuscarBanco(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarBanco(value));
+ }
+
+ public bool Restricao(TipoRestricao tipoRestricao)
+ {
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ return false;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, tipoRestricao);
+ if (val != null)
+ {
+ return val.Restricao;
+ }
+ return false;
+ }
+
+ public bool Permissao(TipoTela tipoTela)
+ {
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ return false;
+ }
+ PermissaoUsuario val = ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, tipoTela);
+ if (val != null)
+ {
+ return val.Consultar;
+ }
+ return true;
+ }
+
+ public async Task<List<VendedorUsuario>> VerificaVinculoVendedor(Usuario usuario)
+ {
+ if (usuario == null || ((DomainBase)usuario).Id == 0L)
+ {
+ return new List<VendedorUsuario>();
+ }
+ return await ServicoVendedorUsuario.FindByVinculo(usuario);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> SalvarProspeccao(Prospeccao prospecao)
+ {
+ List<KeyValuePair<string, string>> list = prospecao.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ List<ArquivoDigital> anexos = prospecao.Anexos;
+ if (((DomainBase)prospecao.Tarefa).Id == 0L)
+ {
+ prospecao.Tarefa.Cliente = prospecao.Nome;
+ prospecao.Tarefa.Titulo = "PROSPECÇÃO " + prospecao.VigenciaFinal?.ToString("d");
+ prospecao.Tarefa.Referencia = prospecao.Item;
+ prospecao.Tarefa.Descricao = $"{Recursos.Usuario.Nome} {Funcoes.GetNetworkTime():g} {Environment.NewLine}{prospecao.Observacao}";
+ }
+ Prospeccao prosccaoSalva = await new ProspeccaoServico().Salvar(prospecao);
+ if (anexos != null && anexos.Count > 0)
+ {
+ await SalvarAttachments(anexos, (TipoArquivoDigital)11, ((DomainBase)prosccaoSalva).Id);
+ }
+ if (prosccaoSalva.Tarefa != null && prospecao.AbrirTarefa && prosccaoSalva != null && ((DomainBase)prosccaoSalva).Id > 0)
+ {
+ Tarefa tarefa = prosccaoSalva.Tarefa;
+ ShowDrawer(new TarefaDrawer(tarefa), 0, close: false);
+ }
+ return null;
+ }
+
+ public async Task<bool> VerificarRestricao(TipoRestricao tipoRestricao, bool root = false, bool showmessage = true)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ return true;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, tipoRestricao);
+ if (val == null || !val.Restricao)
+ {
+ return true;
+ }
+ if (showmessage)
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR ESSA TELA. CONTATE O ADMINISTRADOR DO SISTEMA.", "OK", "", root);
+ }
+ return false;
+ }
+
+ public async Task<bool> VerificarPermissao(TipoTela tela, bool root = false)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (await PermissaoConsultar(tela))
+ {
+ return true;
+ }
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR ESSA TELA. CONTATE O ADIMINSTRADOR DO SISTEMA.", "OK", "", root);
+ return false;
+ }
+
+ public async Task<bool> VerificarContrato(Produto produto, bool message = true, bool root = false)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if ((int)produto == 79)
+ {
+ if (LicenseHelper.Produtos.Exists((Licenca x) => (int)x.Produto == 91 && x.AcessoLiberado))
+ {
+ return true;
+ }
+ if (LicenseHelper.Produtos.Exists((Licenca x) => (int)x.Produto == 81 && x.AcessoLiberado))
+ {
+ return true;
+ }
+ if (LicenseHelper.Produtos.Exists((Licenca x) => (int)x.Produto == 77 && x.AcessoLiberado))
+ {
+ return true;
+ }
+ }
+ if (LicenseHelper.Produtos != null && LicenseHelper.Produtos.Exists((Licenca x) => x.Produto == produto && x.AcessoLiberado))
+ {
+ return true;
+ }
+ if (message)
+ {
+ Licenca val = LicenseHelper.Produtos?.FirstOrDefault((Func<Licenca, bool>)((Licenca x) => x.Produto == produto));
+ await ShowMessage((val == null) ? ("VOCÊ NÃO POSSUI O MÓDULO " + EnumHelper.GetDescription<Produto>(produto) + " CONTRATADO") : ("ACESSO AO MÓDULO " + EnumHelper.GetDescription<Produto>(produto) + " INTERROMPIDO"), "OK", "", root);
+ }
+ return false;
+ }
+
+ internal async Task<List<NotaFiscal>> ShowExtratoComissaoDialog(List<Seguradora> seguradoras)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogExtratoComissao dialogControl = new DialogExtratoComissao(seguradoras);
+ return await ExecuteRunExtendedDialogExtratoComissao((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<List<NotaFiscal>> ExecuteRunExtendedDialogExtratoComissao(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (List<NotaFiscal>)obj;
+ }
+
+ internal async Task<Cliente> ShowCopiarCliente()
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogCopiarCliente dialogControl = new DialogCopiarCliente();
+ return await ExecuteRunExtendedDialogCopiarCliente((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Cliente> ExecuteRunExtendedDialogCopiarCliente(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Cliente)obj;
+ }
+
+ internal async Task<Copia> ShowCopiaDialog(Copia copia)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogCopia dialogControl = new DialogCopia(copia);
+ return await ExecuteRunExtendedDialogCopia((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Copia> ExecuteRunExtendedDialogCopia(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Copia)obj;
+ }
+
+ public async void AbrirLog(TipoTela tipoTela, long id)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ ShowDrawer(new LogDrawer(tipoTela, id), 0, close: false);
+ return;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, (TipoRestricao)109);
+ if (val == null || !val.Restricao)
+ {
+ ShowDrawer(new LogDrawer(tipoTela, id), 0, close: false);
+ }
+ else
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR OS LOGS");
+ }
+ }
+
+ public async void AbrirLogParcela(List<long> parcelas, long documento, int numparcela = 0)
+ {
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ ShowDrawer(new LogDrawer((TipoTela)5, documento, parcelas, numparcela), 0, close: false);
+ return;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, (TipoRestricao)109);
+ if (val == null || !val.Restricao)
+ {
+ ShowDrawer(new LogDrawer((TipoTela)5, documento, parcelas, numparcela), 0, close: false);
+ }
+ else
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR OS LOGS");
+ }
+ }
+
+ public async void AbrirLogEmail(TipoTela tela, long id)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ ShowDrawer(new LogEmailDrawer(tela, id), 0, close: false);
+ return;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, (TipoRestricao)109);
+ if (val == null || !val.Restricao)
+ {
+ ShowDrawer(new LogEmailDrawer(tela, id), 0, close: false);
+ }
+ else
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR OS LOGS");
+ }
+ }
+
+ public async Task ImprimirFornecedor(List<Fornecedor> fornecedores)
+ {
+ new ParcelaServico();
+ string text = "<html><head><title>RELATÓRIO DE FORNECEDORES</title></head><body style='font-size: 12px; font-family: Arial, Helvetica, sans-serif; margin-left: 50px; margin-right: 50px; line-height: 30px;' onload='self.print();'>";
+ text += "<div align='center' style='font-size: 20px;'><strong>RELATÓRIO DE FORNECEDORES</strong></div> <br>";
+ text += "<div class='table-responsive'>";
+ text += "<table align='center' class='table table-bordered' border='1px' style='border-collapse:collapse;' style='width:100%;' style='margin:auto;'>";
+ int num = 1;
+ text += "<tr bgcolor=LightBlue>";
+ text += "<td><strong>NOME</strong></td>";
+ text += "<td><strong>CPF/CNPJ</strong></td>";
+ text += "<td><strong>ENDEREÇO</strong></td>";
+ text += "<td><strong>E-MAIL</strong></td>";
+ text += "<td><strong>TIPO PESSOA</strong></td>";
+ text += "</tr>";
+ foreach (Fornecedor fornecedore in fornecedores)
+ {
+ text = text + "<tr> <td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + fornecedore.Nome + "</td>";
+ text = text + "<td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + fornecedore.Documento + "</td>";
+ text = text + "<td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + ((EnderecoBase)fornecedore).Endereco + "</td>";
+ text = text + "<td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + fornecedore.Email + "</td>";
+ string text2 = ((fornecedore.Documento == null) ? "" : ((ValidationHelper.OnlyNumber(fornecedore.Documento).Length > 11) ? "JURÍDICA" : "FÍSICA"));
+ text = text + "<td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + text2 + "</td></tr>";
+ num = ((num != 1) ? (num + 1) : 0);
+ }
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ string nome = Recursos.Usuario.Nome;
+ text += "</table></div>";
+ text += $"Emitido pelo usuário: {nome}, data e hora: {networkTime}.";
+ text += "</body>";
+ string tempPath = Path.GetTempPath();
+ string text3 = $"{tempPath}FORNECEDORES_{networkTime:ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text3, append: true, Encoding.UTF8);
+ streamWriter.Write(text);
+ streamWriter.Close();
+ Process.Start(text3);
+ }
+
+ public async Task EmitirCheckList(List<Documento> documentos)
+ {
+ ParcelaServico parcelaServico = new ParcelaServico();
+ string html5 = "<html><head><title>CHECK LIST DE PROTOCOLOS</title></head><body style='font-size: 12px; font-family: Arial, Helvetica, sans-serif; margin-left: 50px; margin-right: 50px; line-height: 30px;' onload='self.print();'>";
+ html5 += "<div align='center' style='font-size: 20px;'><strong>CHECK LIST DE PROTOCOLOS</strong></div> <br>";
+ html5 += "<div class='table-responsive'>";
+ html5 += "<table align='center' class='table table-bordered' border='1px' style='border-collapse:collapse;' style='width:100%;' style='margin:auto;'>";
+ int color = 1;
+ html5 += "<tr bgcolor=LightBlue>";
+ html5 += "<td><strong>CLIENTE</strong></td>";
+ html5 += "<td><strong>APÓLICE</strong></td>";
+ html5 += "<td><strong>1ª PARCELA</strong></td>";
+ html5 += "<td><strong>2ª PARCELA</strong></td>";
+ html5 += "<td><strong>RECEBIDA POR</strong></td>";
+ html5 += "<td><strong>VENDEDOR</strong></td>";
+ html5 += "</tr>";
+ documentos = documentos.OrderBy((Documento x) => x.Controle.Cliente.Nome).ToList();
+ foreach (Documento doc in documentos)
+ {
+ Documento val = doc;
+ val.Parcelas = await parcelaServico.BuscarParcelasAsync(((DomainBase)doc).Id);
+ html5 = html5 + "<tr> <td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + doc.Controle.Cliente.Nome + "</td>";
+ html5 = html5 + "<td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + doc.Apolice + "</td>";
+ string text = ((doc.Parcelas != null && doc.Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).ToList().Count > 0) ? doc.Parcelas.Where((Parcela x) => x.NumeroParcela == 1).First().Vencimento.Date.ToString("dd/MM/yyyy") : "");
+ html5 = html5 + "<td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + text + "</td>";
+ text = ((doc.Parcelas != null && doc.Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).ToList().Count > 1) ? doc.Parcelas.Where((Parcela x) => x.NumeroParcela == 2).First().Vencimento.Date.ToString("dd/MM/yyyy") : "");
+ html5 = html5 + "<td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + text + "</td>";
+ html5 = html5 + "<td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>____________/____/___</td>";
+ string[] obj = new string[6]
+ {
+ html5,
+ "<td style='padding:10px' bgcolor='",
+ (color % 2 == 0) ? "WhiteSmoke" : "White",
+ "'>",
+ null,
+ null
+ };
+ Vendedor vendedorPrincipal = doc.VendedorPrincipal;
+ obj[4] = ((vendedorPrincipal != null) ? vendedorPrincipal.Nome : null);
+ obj[5] = "</td></tr>";
+ html5 = string.Concat(obj);
+ color = ((color != 1) ? (color + 1) : 0);
+ }
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ string nome = Recursos.Usuario.Nome;
+ html5 += "</table></div>";
+ html5 = html5 + "<div align='center'><strong>TOTAL DE PROTOCOLOS: " + documentos.Count + "</strong></div>";
+ html5 += $"Emitido pelo usuário: {nome}, data e hora: {networkTime}.";
+ html5 += "</body>";
+ string tempPath = Path.GetTempPath();
+ string text2 = $"{tempPath}{(object)(TipoExtrato)0}CheckList_{networkTime:ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text2, append: true, Encoding.UTF8);
+ streamWriter.Write(html5);
+ streamWriter.Close();
+ Process.Start(text2);
+ }
+
+ public async Task EmitirProtocolos(List<Tuple<long, string>> lista, bool doisPorPagina, List<Documento> protocolo)
+ {
+ int multiploDois = 0;
+ DateTime now = Funcoes.GetNetworkTime();
+ int i = 0;
+ StringBuilder pageBuilder = new StringBuilder();
+ StringBuilder protocoloContent = new StringBuilder();
+ foreach (Tuple<long, string> listum in lista)
+ {
+ i++;
+ ApoliceServico apoliceServico = new ApoliceServico();
+ ItemServico itemServico = new ItemServico();
+ ClienteServico cliServico = new ClienteServico();
+ ParcelaServico parcelaServico = new ParcelaServico();
+ Documento apolice = await apoliceServico.BuscarApoliceAsync(listum.Item1);
+ apolice.Controle.Cliente.Telefones = cliServico.BuscarTelefones(((DomainBase)apolice.Controle.Cliente).Id);
+ Cliente cliente = apolice.Controle.Cliente;
+ cliente.Emails = await cliServico.BuscarEmailsAsync(((DomainBase)apolice.Controle.Cliente).Id);
+ cliente = apolice.Controle.Cliente;
+ cliente.Enderecos = await cliServico.BuscarEnderecosAsync(((DomainBase)apolice.Controle.Cliente).Id);
+ if (apolice.VendedorPrincipal == null)
+ {
+ Documento val = apolice;
+ val.VendedorPrincipal = await apoliceServico.BuscarVendedorPrincipal(((DomainBase)apolice.Controle).Id);
+ }
+ ObservableCollection<Item> itens = await itemServico.BuscarItems(((DomainBase)apolice).Id, (StatusItem)2);
+ if (itens == null || itens.Count == 0)
+ {
+ itens = await itemServico.BuscarItens(((DomainBase)apolice.Controle).Id, (StatusItem)3);
+ }
+ ObservableCollection<Parcela> observableCollection = await parcelaServico.BuscarParcelasAsync(((DomainBase)apolice).Id);
+ apolice.ProtocoloEmail = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloEmail;
+ apolice.ProtocoloTelefone = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloTelefone;
+ apolice.ProtocoloParcela = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloParcela;
+ apolice.ProtocoloEndereco = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloEndereco;
+ apolice.ProtocoloVendedor = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloVendedor;
+ ObservableCollection<ClienteTelefone> telefones = apolice.Controle.Cliente.Telefones;
+ string text = "Telefone: <b>" + ((apolice.ProtocoloTelefone && telefones != null && telefones.Where((ClienteTelefone t) => !string.IsNullOrEmpty(((TelefoneBase)t).Numero)).Any()) ? string.Join(" | ", (from t in telefones
+ where !string.IsNullOrEmpty(((TelefoneBase)t).Numero)
+ select ((TelefoneBase)t).Prefixo + " " + ((TelefoneBase)t).Numero).ToList()) : null) + "</b>";
+ ClienteEndereco val2 = apolice.Controle.Cliente.Enderecos?.FirstOrDefault();
+ string newValue = (protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloEndereco ? ((string.IsNullOrWhiteSpace(((EnderecoBase)val2).Endereco) ? "" : ((EnderecoBase)val2).Endereco) + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Numero) ? "" : ((EnderecoBase)val2).Numero) + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Complemento) ? "" : (" - " + ((EnderecoBase)val2).Complemento)) + " - " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Bairro) ? "" : ((EnderecoBase)val2).Bairro) + " - " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Cidade) ? "" : ((EnderecoBase)val2).Cidade) + " - " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Estado) ? "" : ((EnderecoBase)val2).Estado) + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Cep) ? "" : ((EnderecoBase)val2).Cep)) : null);
+ ObservableCollection<ClienteEmail> emails = apolice.Controle.Cliente.Emails;
+ bool flag = apolice.ProtocoloEmail && emails != null && emails.Count > 0 && !string.IsNullOrEmpty(((EmailBase)emails.First()).Email);
+ string newValue2 = " Email: <b>" + (flag ? ((EmailBase)emails.First()).Email : null) + "</b>";
+ string newValue3 = ((telefones == null && val2 == null && emails == null) ? "style='display:none;'" : "");
+ string newValue4 = (string.IsNullOrWhiteSpace(apolice.Endosso) ? ", " : (" e<br>endosso de n° <b>" + apolice.Endosso + "</b>, "));
+ string newValue5 = "iniciado em <b>" + (string.IsNullOrWhiteSpace(apolice.Vigencia1.ToShortDateString()) ? "" : apolice.Vigencia1.ToShortDateString()) + "</b> até <b>" + (string.IsNullOrWhiteSpace(apolice.Vigencia2?.ToShortDateString()) ? "" : apolice.Vigencia2?.ToShortDateString()) + "</b>";
+ string newValue6 = ((itens != null && itens.Count > 0) ? ("<b>" + (string.IsNullOrWhiteSpace(itens[0].Descricao) ? "" : itens[0].Descricao) + "</b>") : "");
+ string text2 = "";
+ Documento? obj = ((IEnumerable<Documento>)protocolo).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id));
+ string text3 = ((obj != null) ? obj.ObsProtocolo : null);
+ string newValue7 = (string.IsNullOrEmpty(text3) ? "" : ("OBSERVAÇÃO: " + text3));
+ if (apolice.ProtocoloParcela && observableCollection != null && observableCollection.Count > 0)
+ {
+ text2 = ((observableCollection.Count != 1) ? (string.Format("{0} parcelas: vencimento 1ª parcela: <strong>{1}</strong>, ", observableCollection.Count, string.IsNullOrWhiteSpace(observableCollection[0].Vencimento.ToShortDateString()) ? "" : observableCollection[0].Vencimento.ToShortDateString()) + "vencimento 2ª parcela: <strong>" + (string.IsNullOrWhiteSpace(observableCollection[1].Vencimento.ToShortDateString()) ? "" : observableCollection[1].Vencimento.ToShortDateString()) + "</strong>, demais parcelas, vide apólice.") : (text2 + "1 parcela: vencimento <strong>" + (string.IsNullOrWhiteSpace(observableCollection[0].Vencimento.ToShortDateString()) ? "" : observableCollection[0].Vencimento.ToShortDateString()) + "</strong> "));
+ }
+ string text4 = (apolice.ProtocoloVendedor ? apolice.Pasta : null);
+ object obj2;
+ if (!apolice.ProtocoloVendedor)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Vendedor vendedorPrincipal = apolice.VendedorPrincipal;
+ obj2 = ((vendedorPrincipal != null) ? vendedorPrincipal.Nome : null);
+ }
+ string text5 = (string)obj2;
+ string newValue8 = ((text4 != null || text5 != null) ? "" : "style = 'display:none;'");
+ protocoloContent.Append(Resources.ProtocoloTemplate.Replace("{Tamanho}", doisPorPagina ? "12.2cm" : "24.4cm").Replace("{Observacao}", newValue7).Replace("{Nome}", apolice.Controle.Cliente.Nome)
+ .Replace("{Email}", newValue2)
+ .Replace("{DisplayTelefones}", newValue3)
+ .Replace("{Telefones}", (telefones != null) ? text : "")
+ .Replace("{Endereço}", newValue)
+ .Replace("{Ramo}", apolice.Controle.Ramo.Nome)
+ .Replace("{Apolice}", apolice.Apolice)
+ .Replace("{Endosso}", newValue4)
+ .Replace("{Seguradora}", apolice.Controle.Seguradora.Nome)
+ .Replace("{Vigencias}", newValue5)
+ .Replace("{Item}", newValue6)
+ .Replace("{Parcelas}", text2)
+ .Replace("{Pasta}", text4)
+ .Replace("{Vendedor}", text5)
+ .Replace("{DisplayVendedor}", newValue8)
+ .Replace("{NomeCorretora}", Recursos.Empresa.Nome)
+ .Replace("{Usuario}", Recursos.Usuario.Nome)
+ .Replace("{Emissao}", $"{now}"));
+ multiploDois++;
+ if (!doisPorPagina || i == 2)
+ {
+ protocoloContent.Append("<div style='page-break-after: always'></div>");
+ i = 0;
+ }
+ }
+ pageBuilder.Append(Resources.ProtocoloPageTemplate.Replace("{Protocolos}", protocoloContent.ToString()));
+ string tempPath = Path.GetTempPath();
+ string text6 = $"{tempPath}{(object)(TipoExtrato)0}_{now:ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text6, append: true, Encoding.UTF8);
+ streamWriter.Write((object?)pageBuilder);
+ streamWriter.Close();
+ Process.Start(text6);
+ RegistrarAcao(string.Format("EMITIU PROTOCOLO DE {0} DOCUMENTO{1}", lista.Count, (lista.Count == 1) ? "" : "S"), 0L, (TipoTela)59, "IDS DOS DOCUMENTOS E SUAS RESPECTIVAS OBSERVAÇÕES:\n" + string.Join("\n", lista.Select((Tuple<long, string> x) => x.Item1 + ": \"" + x.Item2 + "\"")));
+ }
+
+ public async Task<string> VerificarAcesso(long id)
+ {
+ string erro = null;
+ Usuario val = await new UsuarioServico().BuscarUsuarioPorId(id);
+ if (val == null)
+ {
+ return "DADOS DE ACESSO INVÁLIDOS";
+ }
+ List<string> list = new List<string>();
+ List<string> list2 = new List<string> { "SEGUNDAS-FEIRAS", "TERÇAS-FEIRAS", "QUARTAS-FEIRAS", "QUINTAS-FEIRAS", "SEXTAS-FEIRAS", "SÁBADOS", "DOMINGOS" };
+ if (val.Segunda == false)
+ {
+ list.Add("SEGUNDAS-FEIRAS");
+ list2.Remove("SEGUNDAS-FEIRAS");
+ }
+ if (val.Terca == false)
+ {
+ list.Add("TERÇAS-FEIRAS");
+ list2.Remove("TERÇAS-FEIRAS");
+ }
+ if (val.Quarta == false)
+ {
+ list.Add("QUARTAS-FEIRAS");
+ list2.Remove("QUARTAS-FEIRAS");
+ }
+ if (val.Quinta == false)
+ {
+ list.Add("QUINTAS-FEIRAS");
+ list2.Remove("QUINTAS-FEIRAS");
+ }
+ if (val.Sexta == false)
+ {
+ list.Add("SEXTAS-FEIRAS");
+ list2.Remove("SEXTAS-FEIRAS");
+ }
+ if (val.Sabado == false)
+ {
+ list.Add("SÁBADOS");
+ list2.Remove("SÁBADOS");
+ }
+ if (val.Domingo == false)
+ {
+ list.Add("DOMINGOS");
+ list2.Remove("DOMINGOS");
+ }
+ string text;
+ if (list.Count == 7)
+ {
+ text = "RESTRITO TODOS OS DIAS";
+ }
+ else if (list.Count <= 3)
+ {
+ text = "RESTRITO ";
+ for (int i = 0; i < list.Count; i++)
+ {
+ text = ((i >= list.Count - 2) ? ((i != list.Count - 2) ? (text + list[i]) : (text + list[i] + " E ")) : (text + list[i] + ", "));
+ }
+ }
+ else
+ {
+ text = "APENAS PERMITIDO ";
+ for (int j = 0; j < list2.Count; j++)
+ {
+ text = ((j >= list2.Count - 2) ? ((j != list2.Count - 2) ? (text + list2[j]) : (text + list2[j] + " E ")) : (text + list2[j] + ", "));
+ }
+ }
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ switch (networkTime.DayOfWeek)
+ {
+ case DayOfWeek.Monday:
+ if (val.Segunda == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Tuesday:
+ if (val.Terca == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Wednesday:
+ if (val.Quarta == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Thursday:
+ if (val.Quinta == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Friday:
+ if (val.Sexta == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Saturday:
+ if (val.Sabado == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Sunday:
+ if (val.Domingo == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ }
+ if (val.InicioAcesso.HasValue && val.FimAcesso.HasValue && (networkTime.TimeOfDay <= val.InicioAcesso.Value.TimeOfDay || networkTime.TimeOfDay >= val.FimAcesso.Value.TimeOfDay))
+ {
+ erro = "USUÁRIO COM PERMISSÃO DE ACESSO ENTRE " + val.InicioAcesso.Value.ToShortTimeString() + " E " + val.FimAcesso.Value.ToShortTimeString();
+ }
+ return erro;
+ }
+
+ public void RegistrarAcao(string descricao, long entidadeId, TipoTela? tela = null, object obs = null)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0013: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001b: Expected O, but got Unknown
+ RegistroAcao log = new RegistroAcao
+ {
+ Descricao = descricao,
+ EntidadeId = entidadeId,
+ Tela = tela
+ };
+ new ApoliceServico().SalvarAcao(log, obs);
+ }
+
+ public void RegistrarAcao(string descricao, Relatorio? relatorio, object obs = null)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0014: Expected O, but got Unknown
+ RegistroAcao log = new RegistroAcao
+ {
+ Relatorio = relatorio,
+ Descricao = descricao
+ };
+ new ApoliceServico().SalvarAcao(log, obs);
+ }
+
+ public async Task<bool> SalvarAttachments(List<ArquivoDigital> arquivos, TipoArquivoDigital tipoAd, long id)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ if (arquivos == null || arquivos.Count == 0)
+ {
+ return false;
+ }
+ arquivos.ForEach(delegate(ArquivoDigital x)
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0008: Invalid comparison between Unknown and I4
+ //IL_001b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Invalid comparison between Unknown and I4
+ //IL_0034: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Invalid comparison between Unknown and I4
+ //IL_004d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0053: Invalid comparison between Unknown and I4
+ //IL_0066: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006c: Invalid comparison between Unknown and I4
+ //IL_007f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0085: Invalid comparison between Unknown and I4
+ //IL_0098: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009f: Invalid comparison between Unknown and I4
+ //IL_00b2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b8: Invalid comparison between Unknown and I4
+ //IL_00cb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d1: Invalid comparison between Unknown and I4
+ //IL_00e4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00eb: Invalid comparison between Unknown and I4
+ //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0105: Invalid comparison between Unknown and I4
+ //IL_0118: Unknown result type (might be due to invalid IL or missing references)
+ //IL_011f: Invalid comparison between Unknown and I4
+ //IL_0132: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0139: Invalid comparison between Unknown and I4
+ //IL_014c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0153: Invalid comparison between Unknown and I4
+ //IL_0166: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016d: Invalid comparison between Unknown and I4
+ //IL_0180: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0187: Invalid comparison between Unknown and I4
+ x.IdCliente = (((int)tipoAd == 1) ? id : 0);
+ x.IdDocumento = (((int)tipoAd == 2) ? id : 0);
+ x.IdParcela = (((int)tipoAd == 3) ? id : 0);
+ x.IdItem = (((int)tipoAd == 4) ? id : 0);
+ x.IdSinistro = (((int)tipoAd == 5) ? id : 0);
+ x.IdVendedor = (((int)tipoAd == 6) ? id : 0);
+ x.IdUsuario = (((int)tipoAd == 12) ? id : 0);
+ x.IdSeguradora = (((int)tipoAd == 8) ? id : 0);
+ x.IdExtrato = (((int)tipoAd == 7) ? id : 0);
+ x.IdLancamento = (((int)tipoAd == 9) ? id : 0);
+ x.IdFornecedor = (((int)tipoAd == 10) ? id : 0);
+ x.IdProspeccao = (((int)tipoAd == 11) ? id : 0);
+ x.IdSocio = (((int)tipoAd == 14) ? id : 0);
+ x.IdTarefa = (((int)tipoAd == 15) ? id : 0);
+ x.IdNotaFiscal = (((int)tipoAd == 16) ? id : 0);
+ x.IdEstipulante = (((int)tipoAd == 17) ? id : 0);
+ x.IdEmpresa = Recursos.Usuario.IdEmpresa;
+ });
+ TipoArquivoDigital val = tipoAd;
+ switch (val - 1)
+ {
+ default:
+ await ArquivoDigitalServico.Insert(arquivos);
+ if (!ArquivoDigitalServico.Sucesso)
+ {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public double GetWindowHeight()
+ {
+ return ((FrameworkElement)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ActualHeight;
+ }
+}