diff options
Diffstat (limited to 'Gestor.Application/ViewModels/LoginViewModel.cs')
| -rw-r--r-- | Gestor.Application/ViewModels/LoginViewModel.cs | 1495 |
1 files changed, 1495 insertions, 0 deletions
diff --git a/Gestor.Application/ViewModels/LoginViewModel.cs b/Gestor.Application/ViewModels/LoginViewModel.cs new file mode 100644 index 0000000..8981f60 --- /dev/null +++ b/Gestor.Application/ViewModels/LoginViewModel.cs @@ -0,0 +1,1495 @@ +using Agger.Registro;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Command;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Security;
+using Gestor.Common.Validation;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+
+namespace Gestor.Application.ViewModels
+{
+ internal class LoginViewModel : BaseSegurosViewModel
+ {
+ private bool _enableRegistro;
+
+ private bool _enableTrocaSenha;
+
+ private bool _aggerUser;
+
+ private string _imagemLink = "https://calendly.com/treinamentocs";
+
+ private string _imagem = "https://docs.agger.com.br/treinamentoprimeirasemana.png";
+
+ private string _head;
+
+ private string _login;
+
+ private string _novaNovaSenha;
+
+ private string _senha;
+
+ private string _confirmacaoSenha;
+
+ private Gestor.Model.Domain.Seguros.Usuario _usuario;
+
+ private string userJson = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "user.json");
+
+ private LoginImageModel _selectedImage;
+
+ private int _selectedIndex;
+
+ private string _version;
+
+ private string _labelVersion = "";
+
+ private bool _loadingVisibility;
+
+ private bool _fieldsVisibility;
+
+ private string _errorLogin = "DADOS DE ACESSO INVÁLIDOS";
+
+ private Visibility _errorLoginVisibility = Visibility.Hidden;
+
+ private Visibility _acessoVisibility = Visibility.Collapsed;
+
+ private Visibility _trocaSenhaVisibility = Visibility.Collapsed;
+
+ private Visibility _loginVisibility;
+
+ private Visibility _registrarVisibility = Visibility.Collapsed;
+
+ private Visibility _visibilityCancelarRegitro = Visibility.Collapsed;
+
+ private string _chave;
+
+ private string _mensagem;
+
+ private string _centralAtendimento = Address.get_CentralAtendimento().ToString();
+
+ public Visibility AcessoVisibility
+ {
+ get
+ {
+ return this._acessoVisibility;
+ }
+ set
+ {
+ this._acessoVisibility = value;
+ base.OnPropertyChanged("AcessoVisibility");
+ }
+ }
+
+ public bool AggerUser
+ {
+ get
+ {
+ return this._aggerUser;
+ }
+ set
+ {
+ this._aggerUser = value;
+ base.OnPropertyChanged("AggerUser");
+ }
+ }
+
+ public string CentralAtendimento
+ {
+ get
+ {
+ return this._centralAtendimento;
+ }
+ set
+ {
+ this._centralAtendimento = value;
+ base.OnPropertyChanged("CentralAtendimento");
+ }
+ }
+
+ public string Chave
+ {
+ get
+ {
+ return this._chave;
+ }
+ set
+ {
+ this._chave = value;
+ this.EnableRegistro = Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(this.Chave);
+ base.OnPropertyChanged("Chave");
+ }
+ }
+
+ public string ConfirmacaoSenha
+ {
+ get
+ {
+ return this._confirmacaoSenha;
+ }
+ set
+ {
+ this._confirmacaoSenha = value;
+ this.EnableTrocaSenha = (!Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(this.NovaSenha) || !Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(this.ConfirmacaoSenha) ? false : this.NovaSenha.Equals(this.ConfirmacaoSenha));
+ base.OnPropertyChanged("ConfirmacaoSenha");
+ }
+ }
+
+ public bool EnableRegistro
+ {
+ get
+ {
+ return this._enableRegistro;
+ }
+ set
+ {
+ this._enableRegistro = value;
+ base.OnPropertyChanged("EnableRegistro");
+ }
+ }
+
+ public bool EnableTrocaSenha
+ {
+ get
+ {
+ return this._enableTrocaSenha;
+ }
+ set
+ {
+ this._enableTrocaSenha = value;
+ base.OnPropertyChanged("EnableTrocaSenha");
+ }
+ }
+
+ public string ErrorLogin
+ {
+ get
+ {
+ return this._errorLogin;
+ }
+ set
+ {
+ this._errorLogin = value;
+ base.OnPropertyChanged("ErrorLogin");
+ }
+ }
+
+ public Visibility ErrorLoginVisibility
+ {
+ get
+ {
+ return this._errorLoginVisibility;
+ }
+ set
+ {
+ this._errorLoginVisibility = value;
+ base.OnPropertyChanged("ErrorLoginVisibility");
+ }
+ }
+
+ public bool FieldsVisibility
+ {
+ get
+ {
+ return this._fieldsVisibility;
+ }
+ set
+ {
+ this._fieldsVisibility = value;
+ base.OnPropertyChanged("FieldsVisibility");
+ }
+ }
+
+ public string Head
+ {
+ get
+ {
+ return this._head;
+ }
+ set
+ {
+ string upper;
+ if (value != null)
+ {
+ upper = value.ToUpper();
+ }
+ else
+ {
+ upper = null;
+ }
+ this._head = upper;
+ base.OnPropertyChanged("Head");
+ }
+ }
+
+ public ICommand ImageClickCommand
+ {
+ get
+ {
+ return new RelayCommand(() => {
+ bool flag;
+ LoginImageModel selectedImage = this.SelectedImage;
+ flag = (selectedImage != null ? Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(selectedImage.UrlFixa) : false);
+ if (flag)
+ {
+ Process.Start(new ProcessStartInfo()
+ {
+ FileName = this.SelectedImage.UrlFixa,
+ UseShellExecute = true
+ });
+ }
+ });
+ }
+ }
+
+ public string Imagem
+ {
+ get
+ {
+ return this._imagem;
+ }
+ set
+ {
+ this._imagem = value;
+ base.OnPropertyChanged("Imagem");
+ }
+ }
+
+ public string ImagemLink
+ {
+ get
+ {
+ return this._imagemLink;
+ }
+ set
+ {
+ this._imagemLink = value;
+ base.OnPropertyChanged("ImagemLink");
+ }
+ }
+
+ public string LabelVersion
+ {
+ get
+ {
+ return this._labelVersion;
+ }
+ set
+ {
+ this._labelVersion = value;
+ base.OnPropertyChanged("LabelVersion");
+ }
+ }
+
+ public bool LoadingVisibility
+ {
+ get
+ {
+ return this._loadingVisibility;
+ }
+ set
+ {
+ this._loadingVisibility = value;
+ base.OnPropertyChanged("LoadingVisibility");
+ }
+ }
+
+ public string Login
+ {
+ get
+ {
+ return this._login;
+ }
+ set
+ {
+ bool flag;
+ bool flag1;
+ this._login = value;
+ string login = this.Login;
+ if (login != null)
+ {
+ flag = login.ToUpper().StartsWith("AGGER@");
+ }
+ else
+ {
+ flag = false;
+ }
+ if (flag)
+ {
+ flag1 = true;
+ }
+ else
+ {
+ string senha = this.Senha;
+ if (senha != null)
+ {
+ flag1 = senha.ToUpper().StartsWith("AGGER@");
+ }
+ else
+ {
+ flag1 = false;
+ }
+ }
+ this.AggerUser = flag1;
+ base.OnPropertyChanged("Login");
+ }
+ }
+
+ public ObservableCollection<LoginImageModel> LoginImages { get; set; } = new ObservableCollection<LoginImageModel>();
+
+ public Visibility LoginVisibility
+ {
+ get
+ {
+ return this._loginVisibility;
+ }
+ set
+ {
+ this._loginVisibility = value;
+ base.OnPropertyChanged("LoginVisibility");
+ }
+ }
+
+ public string Mensagem
+ {
+ get
+ {
+ return this._mensagem;
+ }
+ set
+ {
+ this._mensagem = value;
+ base.OnPropertyChanged("Mensagem");
+ }
+ }
+
+ public string NovaSenha
+ {
+ get
+ {
+ return this._novaNovaSenha;
+ }
+ set
+ {
+ this._novaNovaSenha = value;
+ this.EnableTrocaSenha = (!Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(this.NovaSenha) || !Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(this.ConfirmacaoSenha) ? false : this.NovaSenha.Equals(this.ConfirmacaoSenha));
+ base.OnPropertyChanged("NovaSenha");
+ }
+ }
+
+ public Visibility RegistrarVisibility
+ {
+ get
+ {
+ return this._registrarVisibility;
+ }
+ set
+ {
+ this._registrarVisibility = value;
+ base.OnPropertyChanged("RegistrarVisibility");
+ }
+ }
+
+ public LoginImageModel SelectedImage
+ {
+ get
+ {
+ return this._selectedImage;
+ }
+ set
+ {
+ this._selectedImage = value;
+ base.OnPropertyChanged("SelectedImage");
+ }
+ }
+
+ public int SelectedIndex
+ {
+ get
+ {
+ return this._selectedIndex;
+ }
+ set
+ {
+ this._selectedIndex = value;
+ this.SelectedImage = this.LoginImages.ElementAtOrDefault<LoginImageModel>(value);
+ base.OnPropertyChanged("SelectedIndex");
+ }
+ }
+
+ public string Senha
+ {
+ get
+ {
+ return this._senha;
+ }
+ set
+ {
+ bool flag;
+ bool flag1;
+ this._senha = value;
+ string login = this.Login;
+ if (login != null)
+ {
+ flag = login.ToUpper().StartsWith("AGGER@");
+ }
+ else
+ {
+ flag = false;
+ }
+ if (flag)
+ {
+ flag1 = true;
+ }
+ else
+ {
+ string senha = this.Senha;
+ if (senha != null)
+ {
+ flag1 = senha.ToUpper().StartsWith("AGGER@");
+ }
+ else
+ {
+ flag1 = false;
+ }
+ }
+ this.AggerUser = flag1;
+ base.OnPropertyChanged("Senha");
+ }
+ }
+
+ public Visibility TrocaSenhaVisibility
+ {
+ get
+ {
+ return this._trocaSenhaVisibility;
+ }
+ set
+ {
+ this._trocaSenhaVisibility = value;
+ base.OnPropertyChanged("TrocaSenhaVisibility");
+ }
+ }
+
+ public Gestor.Model.Domain.Seguros.Usuario Usuario
+ {
+ get
+ {
+ return this._usuario;
+ }
+ set
+ {
+ this._usuario = value;
+ base.OnPropertyChanged("Usuario");
+ }
+ }
+
+ public static string VersaoAtual
+ {
+ get;
+ set;
+ }
+
+ public string Version
+ {
+ get
+ {
+ return this._version;
+ }
+ set
+ {
+ this._version = value;
+ base.OnPropertyChanged("Version");
+ }
+ }
+
+ public Visibility VisibilityCancelarRegitro
+ {
+ get
+ {
+ return this._visibilityCancelarRegitro;
+ }
+ set
+ {
+ this._visibilityCancelarRegitro = value;
+ base.OnPropertyChanged("VisibilityCancelarRegitro");
+ }
+ }
+
+ public LoginViewModel()
+ {
+ string login;
+ base.EnableButtons = true;
+ ApplicationHelper.Versao = Assembly.GetExecutingAssembly().GetName().Version;
+ this.Version = ApplicationHelper.Versao.ToString();
+ this.LabelVersion = string.Concat("Gestor ", this.Version);
+ LoginViewModel.VersaoAtual = this.LabelVersion;
+ if (!File.Exists(this.userJson))
+ {
+ return;
+ }
+ Gestor.Model.Domain.Seguros.Usuario usuario = JsonConvert.DeserializeObject<Gestor.Model.Domain.Seguros.Usuario>(File.ReadAllText(this.userJson));
+ if (usuario != null)
+ {
+ login = usuario.get_Login();
+ }
+ else
+ {
+ login = null;
+ }
+ this.Login = login;
+ }
+
+ public void AbrirRegistro()
+ {
+ this.LoginVisibility = Visibility.Collapsed;
+ this.AcessoVisibility = Visibility.Collapsed;
+ this.RegistrarVisibility = Visibility.Visible;
+ this.VisibilityCancelarRegitro = (ApplicationHelper.IdFornecedor == 0 ? Visibility.Collapsed : Visibility.Visible);
+ this.Chave = string.Empty;
+ }
+
+ public async Task AbrirTrocaSenha()
+ {
+ bool flag;
+ UsuarioServico usuarioServico = new UsuarioServico();
+ flag = (Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(this.Senha) ? true : Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(this.Login));
+ bool flag1 = flag;
+ if (!flag1)
+ {
+ bool flag2 = Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(this.Login);
+ if (flag2)
+ {
+ Gestor.Model.Domain.Seguros.Usuario usuario = await usuarioServico.BuscarLogin(this.Login);
+ Gestor.Model.Domain.Seguros.Usuario usuario1 = usuario;
+ this.Usuario = usuario;
+ flag2 = usuario1 == null;
+ }
+ flag1 = flag2;
+ }
+ if (!flag1)
+ {
+ this.TrocaSenhaVisibility = Visibility.Visible;
+ this.LoginVisibility = Visibility.Collapsed;
+ }
+ else
+ {
+ await base.ShowMessage("NECESSÁRIO INSERIR UM USUÁRIO E SENHA VÁLIDOS PARA REALIZAR A TROCA DE SENHA.", "OK", "", false);
+ }
+ }
+
+ public void AcessoNegado(string message)
+ {
+ this.Mensagem = message;
+ this.RegistrarVisibility = Visibility.Collapsed;
+ this.LoginVisibility = Visibility.Collapsed;
+ this.AcessoVisibility = Visibility.Visible;
+ }
+
+ public void FecharRegistro()
+ {
+ this.RegistrarVisibility = Visibility.Collapsed;
+ this.LoginVisibility = Visibility.Visible;
+ this.Chave = string.Empty;
+ }
+
+ public async Task<bool> GetCfgJson()
+ {
+ bool flag;
+ string str;
+ string str1;
+ string str2;
+ string str3;
+ string str4;
+ string str5;
+ string str6;
+ string str7;
+ string str8;
+ string str9;
+ string str10;
+ string str11;
+ string str12;
+ string str13;
+ string str14;
+ string str15;
+ string str16;
+ object uri;
+ object apiGestorBeta;
+ object assinadorApiOficial;
+ object assinadorApiBeta;
+ object card;
+ object assistance;
+ object apiAD;
+ object apiArquivo;
+ object apiFipe;
+ object apiSso;
+ object apiMonitor;
+ object apiCep;
+ object loginJson;
+ object surveyJson;
+ object promo;
+ object betaPromo;
+ object centralAtendimento;
+ HttpResponseMessage async = null;
+ try
+ {
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ httpClient.set_Timeout(TimeSpan.FromSeconds(30));
+ int num = 0;
+ try
+ {
+ async = await httpClient.GetAsync(Address.get_JsonGestor());
+ async.EnsureSuccessStatusCode();
+ }
+ catch
+ {
+ num = 1;
+ }
+ if (num == 1)
+ {
+ async = await httpClient.GetAsync(Address.get_JsonGestorAzure());
+ }
+ if (!async.get_IsSuccessStatusCode())
+ {
+ async = null;
+ }
+ else
+ {
+ JObject jObject = JObject.Parse(await async.get_Content().ReadAsStringAsync());
+ JToken item = jObject.get_Item("ApiGestor");
+ if (item != null)
+ {
+ str = Extensions.Value<string>(item);
+ }
+ else
+ {
+ str = null;
+ }
+ string str17 = str;
+ JToken jToken = jObject.get_Item("ApiGestorBeta");
+ if (jToken != null)
+ {
+ str1 = Extensions.Value<string>(jToken);
+ }
+ else
+ {
+ str1 = null;
+ }
+ string str18 = str1;
+ JToken item1 = jObject.get_Item("ApiAssinador");
+ if (item1 != null)
+ {
+ str2 = Extensions.Value<string>(item1);
+ }
+ else
+ {
+ str2 = null;
+ }
+ string str19 = str2;
+ JToken jToken1 = jObject.get_Item("ApiAssinadorBeta");
+ if (jToken1 != null)
+ {
+ str3 = Extensions.Value<string>(jToken1);
+ }
+ else
+ {
+ str3 = null;
+ }
+ string str20 = str3;
+ JToken item2 = jObject.get_Item("ApiCard");
+ if (item2 != null)
+ {
+ str4 = Extensions.Value<string>(item2);
+ }
+ else
+ {
+ str4 = null;
+ }
+ string str21 = str4;
+ JToken jToken2 = jObject.get_Item("ApiAssistencia");
+ if (jToken2 != null)
+ {
+ str5 = Extensions.Value<string>(jToken2);
+ }
+ else
+ {
+ str5 = null;
+ }
+ string str22 = str5;
+ JToken item3 = jObject.get_Item("ApiAD");
+ if (item3 != null)
+ {
+ str6 = Extensions.Value<string>(item3);
+ }
+ else
+ {
+ str6 = null;
+ }
+ string str23 = str6;
+ JToken jToken3 = jObject.get_Item("ApiAttachment");
+ if (jToken3 != null)
+ {
+ str7 = Extensions.Value<string>(jToken3);
+ }
+ else
+ {
+ str7 = null;
+ }
+ string str24 = str7;
+ JToken item4 = jObject.get_Item("ApiFipe");
+ if (item4 != null)
+ {
+ str8 = Extensions.Value<string>(item4);
+ }
+ else
+ {
+ str8 = null;
+ }
+ string str25 = str8;
+ JToken jToken4 = jObject.get_Item("ApiSso");
+ if (jToken4 != null)
+ {
+ str9 = Extensions.Value<string>(jToken4);
+ }
+ else
+ {
+ str9 = null;
+ }
+ string str26 = str9;
+ JToken item5 = jObject.get_Item("ApiCep");
+ if (item5 != null)
+ {
+ str10 = Extensions.Value<string>(item5);
+ }
+ else
+ {
+ str10 = null;
+ }
+ string str27 = str10;
+ JToken jToken5 = jObject.get_Item("ApiMonitor");
+ if (jToken5 != null)
+ {
+ str11 = Extensions.Value<string>(jToken5);
+ }
+ else
+ {
+ str11 = null;
+ }
+ string str28 = str11;
+ JToken item6 = jObject.get_Item("LoginJson");
+ if (item6 != null)
+ {
+ str12 = Extensions.Value<string>(item6);
+ }
+ else
+ {
+ str12 = null;
+ }
+ string str29 = str12;
+ JToken jToken6 = jObject.get_Item("PromoJson");
+ if (jToken6 != null)
+ {
+ str13 = Extensions.Value<string>(jToken6);
+ }
+ else
+ {
+ str13 = null;
+ }
+ string str30 = str13;
+ JToken item7 = jObject.get_Item("BetaPromoJson");
+ if (item7 != null)
+ {
+ str14 = Extensions.Value<string>(item7);
+ }
+ else
+ {
+ str14 = null;
+ }
+ string str31 = str14;
+ JToken jToken7 = jObject.get_Item("SurveyJson");
+ if (jToken7 != null)
+ {
+ str15 = Extensions.Value<string>(jToken7);
+ }
+ else
+ {
+ str15 = null;
+ }
+ string str32 = str15;
+ JToken item8 = jObject.get_Item("CentralAtendimento");
+ if (item8 != null)
+ {
+ str16 = Extensions.Value<string>(item8);
+ }
+ else
+ {
+ str16 = null;
+ }
+ string str33 = str16;
+ JToken jToken8 = jObject.get_Item("UsarApis");
+ if (jToken8 != null)
+ {
+ Extensions.Value<string>(jToken8);
+ }
+ else
+ {
+ }
+ if (str17 != null)
+ {
+ uri = str17.ToUri();
+ }
+ else
+ {
+ uri = null;
+ }
+ if (uri == null)
+ {
+ uri = Address.get_ApiGestorOficial();
+ }
+ Address.set_ApiGestorOficial((Uri)uri);
+ if (str18 != null)
+ {
+ apiGestorBeta = str18.ToUri();
+ }
+ else
+ {
+ apiGestorBeta = null;
+ }
+ if (apiGestorBeta == null)
+ {
+ apiGestorBeta = Address.get_ApiGestorBeta();
+ }
+ Address.set_ApiGestorBeta((Uri)apiGestorBeta);
+ if (str19 != null)
+ {
+ assinadorApiOficial = str19.ToUri();
+ }
+ else
+ {
+ assinadorApiOficial = null;
+ }
+ if (assinadorApiOficial == null)
+ {
+ assinadorApiOficial = Address.get_AssinadorApiOficial();
+ }
+ Address.set_AssinadorApiOficial((Uri)assinadorApiOficial);
+ if (str20 != null)
+ {
+ assinadorApiBeta = str20.ToUri();
+ }
+ else
+ {
+ assinadorApiBeta = null;
+ }
+ if (assinadorApiBeta == null)
+ {
+ assinadorApiBeta = Address.get_AssinadorApiBeta();
+ }
+ Address.set_AssinadorApiBeta((Uri)assinadorApiBeta);
+ if (str21 != null)
+ {
+ card = str21.ToUri();
+ }
+ else
+ {
+ card = null;
+ }
+ if (card == null)
+ {
+ card = Address.get_Card();
+ }
+ Address.set_Card((Uri)card);
+ if (str22 != null)
+ {
+ assistance = str22.ToUri();
+ }
+ else
+ {
+ assistance = null;
+ }
+ if (assistance == null)
+ {
+ assistance = Address.get_Assistance();
+ }
+ Address.set_Assistance((Uri)assistance);
+ if (str23 != null)
+ {
+ apiAD = str23.ToUri();
+ }
+ else
+ {
+ apiAD = null;
+ }
+ if (apiAD == null)
+ {
+ apiAD = Address.get_ApiAD();
+ }
+ Address.set_ApiAD((Uri)apiAD);
+ if (str24 != null)
+ {
+ apiArquivo = str24.ToUri();
+ }
+ else
+ {
+ apiArquivo = null;
+ }
+ if (apiArquivo == null)
+ {
+ apiArquivo = Address.get_ApiArquivo();
+ }
+ Address.set_ApiArquivo((Uri)apiArquivo);
+ if (str25 != null)
+ {
+ apiFipe = str25.ToUri();
+ }
+ else
+ {
+ apiFipe = null;
+ }
+ if (apiFipe == null)
+ {
+ apiFipe = Address.get_ApiFipe();
+ }
+ Address.set_ApiFipe((Uri)apiFipe);
+ if (str26 != null)
+ {
+ apiSso = str26.ToUri();
+ }
+ else
+ {
+ apiSso = null;
+ }
+ if (apiSso == null)
+ {
+ apiSso = Address.get_ApiSso();
+ }
+ Address.set_ApiSso((Uri)apiSso);
+ if (str28 != null)
+ {
+ apiMonitor = str28.ToUri();
+ }
+ else
+ {
+ apiMonitor = null;
+ }
+ if (apiMonitor == null)
+ {
+ apiMonitor = Address.get_ApiMonitor();
+ }
+ Address.set_ApiMonitor((Uri)apiMonitor);
+ if (str27 != null)
+ {
+ apiCep = str27.ToUri();
+ }
+ else
+ {
+ apiCep = null;
+ }
+ if (apiCep == null)
+ {
+ apiCep = Address.get_ApiCep();
+ }
+ Address.set_ApiCep((Uri)apiCep);
+ if (str29 != null)
+ {
+ loginJson = str29.ToUri();
+ }
+ else
+ {
+ loginJson = null;
+ }
+ if (loginJson == null)
+ {
+ loginJson = Address.get_LoginJson();
+ }
+ Address.set_LoginJson((Uri)loginJson);
+ if (str32 != null)
+ {
+ surveyJson = str32.ToUri();
+ }
+ else
+ {
+ surveyJson = null;
+ }
+ if (surveyJson == null)
+ {
+ surveyJson = Address.get_SurveyJson();
+ }
+ Address.set_SurveyJson((Uri)surveyJson);
+ if (str30 != null)
+ {
+ promo = str30.ToUri();
+ }
+ else
+ {
+ promo = null;
+ }
+ if (promo == null)
+ {
+ promo = Address.Promo;
+ }
+ Address.Promo = (Uri)promo;
+ if (str31 != null)
+ {
+ betaPromo = str31.ToUri();
+ }
+ else
+ {
+ betaPromo = null;
+ }
+ if (betaPromo == null)
+ {
+ betaPromo = Address.BetaPromo;
+ }
+ Address.BetaPromo = (Uri)betaPromo;
+ if (str33 != null)
+ {
+ centralAtendimento = str33.ToUri();
+ }
+ else
+ {
+ centralAtendimento = null;
+ }
+ if (centralAtendimento == null)
+ {
+ centralAtendimento = Address.get_CentralAtendimento();
+ }
+ Address.set_CentralAtendimento((Uri)centralAtendimento);
+ flag = true;
+ return flag;
+ }
+ }
+ httpClient = null;
+ }
+ catch
+ {
+ }
+ flag = false;
+ return flag;
+ }
+
+ public async Task GetImagesFromJson()
+ {
+ HttpResponseMessage async;
+ string str;
+ string str1;
+ try
+ {
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ httpClient.set_Timeout(TimeSpan.FromSeconds(30));
+ try
+ {
+ async = await httpClient.GetAsync(Address.get_LoginJson());
+ async.EnsureSuccessStatusCode();
+ }
+ catch
+ {
+ return;
+ }
+ if (async.get_IsSuccessStatusCode())
+ {
+ JObject jObject = JObject.Parse(await async.get_Content().ReadAsStringAsync());
+ JToken item = jObject.get_Item("Imagem");
+ if (item != null)
+ {
+ str = Extensions.Value<string>(item);
+ }
+ else
+ {
+ str = null;
+ }
+ string str2 = str;
+ JToken jToken = jObject.get_Item("Url");
+ if (jToken != null)
+ {
+ str1 = Extensions.Value<string>(jToken);
+ }
+ else
+ {
+ str1 = null;
+ }
+ string str3 = str1;
+ if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str2) && Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str3))
+ {
+ this.Imagem = str2;
+ this.ImagemLink = str3;
+ }
+ }
+ }
+ httpClient = null;
+ }
+ catch
+ {
+ }
+ }
+
+ public async Task<bool> Load()
+ {
+ bool flag1 = await Task.Run<bool>(async () => {
+ bool flag;
+ try
+ {
+ flag = await (new BaseServico()).LoadInicialParameters();
+ }
+ catch (Exception exception)
+ {
+ flag = false;
+ }
+ return flag;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> TrocaSenha()
+ {
+ bool flag;
+ long? nullable;
+ bool valueOrDefault;
+ object obj = null;
+ if (string.IsNullOrEmpty(this.Senha))
+ {
+ await base.ShowMessage("NECESSÁRIO PREENCHER A SENHA ANTERIOR PARA REALIZAR A TROCA DE SENHA.", "OK", "", false);
+ flag = false;
+ }
+ else if (!string.IsNullOrEmpty(this.NovaSenha))
+ {
+ Token token = new Token();
+ if (this.Senha == this.NovaSenha)
+ {
+ await base.ShowMessage("A NOVA SENHA NÃO PODE SER IGUAL A SENHA ANTERIOR.", "OK", "", false);
+ flag = false;
+ }
+ else if (this.NovaSenha == this.ConfirmacaoSenha)
+ {
+ if (this.Senha.ToUpper().Contains("AGGER@"))
+ {
+ string senha = this.Senha;
+ string[] strArrays = senha.Split(new char[] { '@' });
+ if ((int)strArrays.Length >= 3)
+ {
+ LoginViewModel.AggerAccess aggerAccess = new LoginViewModel.AggerAccess();
+ LoginViewModel.Client client = new LoginViewModel.Client()
+ {
+ Login = strArrays[1].ToUpper(),
+ Password = (new Token()).AggerEncrypt(strArrays[2])
+ };
+ aggerAccess.Usuario = client;
+ aggerAccess.Acao = string.Format("TrocaSenha - {0}|{1}", this.Usuario.get_Id(), this.Usuario.get_Login());
+ aggerAccess.Log = string.Concat("ANG - ", ApplicationHelper.NumeroSerial);
+ aggerAccess.Serial = ApplicationHelper.NumeroSerial;
+ LoginViewModel.AggerAccess aggerAccess1 = aggerAccess;
+ LoginViewModel.AggerAccess aggerAccess2 = null;
+ int num = 0;
+ try
+ {
+ aggerAccess2 = await Gestor.Application.Helpers.Connection.Post<LoginViewModel.AggerAccess>("Access/AggerLogin", aggerAccess1);
+ }
+ catch (Exception exception)
+ {
+ obj = exception;
+ num = 1;
+ }
+ if (num != 1)
+ {
+ obj = null;
+ LoginViewModel.AggerAccess aggerAccess3 = aggerAccess2;
+ if (aggerAccess3 != null)
+ {
+ LoginViewModel.Client usuario = aggerAccess3.Usuario;
+ if (usuario != null)
+ {
+ nullable = new long?(usuario.Id);
+ }
+ else
+ {
+ nullable = null;
+ }
+ long? nullable1 = nullable;
+ long num1 = (long)0;
+ valueOrDefault = nullable1.GetValueOrDefault() > num1 & nullable1.HasValue;
+ }
+ else
+ {
+ valueOrDefault = false;
+ }
+ if (valueOrDefault)
+ {
+ aggerAccess2 = null;
+ }
+ else
+ {
+ await base.ShowMessage("SENHA ANTERIOR INVÁLIDA.", "OK", "", false);
+ flag = false;
+ return flag;
+ }
+ }
+ else
+ {
+ Exception exception1 = (Exception)obj;
+ await base.ShowMessage("SENHA ANTERIOR INVÁLIDA.", "OK", "", false);
+ flag = false;
+ return flag;
+ }
+ }
+ else
+ {
+ await base.ShowMessage("SENHA ANTERIOR INVÁLIDA.", "OK", "", false);
+ flag = false;
+ return flag;
+ }
+ }
+ else if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(this.Usuario.get_Senha()) && this.Senha != token.AggerDecrypt(this.Usuario.get_Senha()))
+ {
+ await base.ShowMessage("SENHA ANTERIOR INVÁLIDA.", "OK", "", false);
+ flag = false;
+ return flag;
+ }
+ UsuarioServico usuarioServico = new UsuarioServico();
+ this.Usuario.set_SenhaAnterior(token.AggerEncrypt(this.Senha));
+ this.Usuario.set_Senha(token.AggerEncrypt(this.NovaSenha));
+ await usuarioServico.Save(this.Usuario);
+ if (!usuarioServico.Sucesso)
+ {
+ this.Usuario.set_SenhaAnterior(string.Empty);
+ this.Usuario.set_Senha(string.Empty);
+ await base.ShowMessage("VERIFIQUE OS DADOS DIGITADOS E TENTE NOVAMENTE.", "OK", "", false);
+ flag = false;
+ }
+ else
+ {
+ this.Senha = this.NovaSenha;
+ flag = true;
+ }
+ }
+ else
+ {
+ await base.ShowMessage("A SENHA E A CONFIRMAÇÃO DA SENHA DEVEM SER IGUAIS.", "OK", "", false);
+ flag = false;
+ }
+ }
+ else
+ {
+ await base.ShowMessage("NECESSÁRIO PREENCHER A NOVA SENHA PARA REALIZAR A TROCA DE SENHA.", "OK", "", false);
+ flag = false;
+ }
+ return flag;
+ }
+
+ public async Task<bool> Validate(string login, string password)
+ {
+ bool flag;
+ string str;
+ long? nullable;
+ Gestor.Model.Domain.Seguros.Usuario usuario;
+ this.ErrorLoginVisibility = Visibility.Hidden;
+ if (!login.Contains("AGGER@"))
+ {
+ usuario = await (new BaseServico()).BuscarUsuario(login, password);
+ if (usuario != null)
+ {
+ str = await base.VerificarAcesso(usuario.get_Id());
+ }
+ else
+ {
+ str = "DADOS DE ACESSO INVÁLIDOS";
+ }
+ string str1 = str;
+ if (str1 == null)
+ {
+ Recursos.Usuario = usuario;
+ Recursos.Empresa = (new BaseServico()).BuscarEmpresa(Recursos.Usuario.get_IdEmpresa());
+ Recursos.Usuario.set_Senha(string.Empty);
+ File.WriteAllText(this.userJson, JsonConvert.SerializeObject(usuario));
+ flag = true;
+ }
+ else
+ {
+ this.ErrorLogin = str1;
+ this.ErrorLoginVisibility = Visibility.Visible;
+ flag = false;
+ }
+ }
+ else
+ {
+ string[] strArrays = login.Split(new char[] { '@' });
+ LoginViewModel.AggerAccess aggerAccess = new LoginViewModel.AggerAccess();
+ LoginViewModel.Client client = new LoginViewModel.Client()
+ {
+ Login = strArrays[1],
+ Password = (new Token()).AggerEncrypt(password)
+ };
+ aggerAccess.Usuario = client;
+ aggerAccess.Acao = "AggerAccessNovoGestor";
+ aggerAccess.Log = string.Concat("ANG - ", ApplicationHelper.NumeroSerial);
+ aggerAccess.Serial = ApplicationHelper.NumeroSerial;
+ LoginViewModel.AggerAccess aggerAccess1 = await Gestor.Application.Helpers.Connection.Post<LoginViewModel.AggerAccess>("Access/AggerLogin", aggerAccess);
+ if (aggerAccess1 != null)
+ {
+ LoginViewModel.Client usuario1 = aggerAccess1.Usuario;
+ if (usuario1 != null)
+ {
+ nullable = new long?(usuario1.Id);
+ }
+ else
+ {
+ nullable = null;
+ }
+ long? nullable1 = nullable;
+ long num = (long)0;
+ if (nullable1.GetValueOrDefault() > num & nullable1.HasValue)
+ {
+ Gestor.Model.Domain.Seguros.Usuario usuario2 = new Gestor.Model.Domain.Seguros.Usuario();
+ usuario2.set_Nome(string.Concat("ACESSO AGGER - USUÁRIO ", aggerAccess1.Usuario.Name));
+ usuario2.set_Login(aggerAccess1.Usuario.Login);
+ usuario2.set_IdEmpresa((long)1);
+ usuario2.set_PermissaoAggilizador(new long?((long)1));
+ Recursos.Usuario = usuario2;
+ Recursos.Empresa = (new BaseServico()).BuscarEmpresa(Recursos.Usuario.get_IdEmpresa());
+ flag = true;
+ usuario = null;
+ return flag;
+ }
+ }
+ this.ErrorLoginVisibility = Visibility.Visible;
+ flag = false;
+ }
+ usuario = null;
+ return flag;
+ }
+
+ private class AggerAccess
+ {
+ public string Acao
+ {
+ get;
+ set;
+ }
+
+ public DateTime? Data
+ {
+ get;
+ set;
+ }
+
+ public long Id
+ {
+ get;
+ set;
+ }
+
+ public string Ip
+ {
+ get;
+ set;
+ }
+
+ public string Log
+ {
+ get;
+ set;
+ }
+
+ public string Serial
+ {
+ get;
+ set;
+ }
+
+ public LoginViewModel.Client Usuario
+ {
+ get;
+ set;
+ }
+
+ public AggerAccess()
+ {
+ }
+ }
+
+ private class Client
+ {
+ public bool AttendancePrivate
+ {
+ get;
+ set;
+ }
+
+ public DateTime? DateLoginFinal
+ {
+ get;
+ set;
+ }
+
+ public DateTime? DateLoginStart
+ {
+ get;
+ set;
+ }
+
+ public bool Deleted
+ {
+ get;
+ set;
+ }
+
+ public string Email
+ {
+ get;
+ set;
+ }
+
+ public DateTime? ExpirationPassDate
+ {
+ get;
+ set;
+ }
+
+ public long Id
+ {
+ get;
+ set;
+ }
+
+ public string Login
+ {
+ get;
+ set;
+ }
+
+ public string Name
+ {
+ get;
+ set;
+ }
+
+ public string Password
+ {
+ get;
+ set;
+ }
+
+ public Client()
+ {
+ }
+ }
+ }
+}
\ No newline at end of file |