From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Generic/DialogAdvertisingViewModel.cs | 292 --------------------- 1 file changed, 292 deletions(-) delete mode 100644 Gestor.Application/ViewModels/Generic/DialogAdvertisingViewModel.cs (limited to 'Gestor.Application/ViewModels/Generic/DialogAdvertisingViewModel.cs') diff --git a/Gestor.Application/ViewModels/Generic/DialogAdvertisingViewModel.cs b/Gestor.Application/ViewModels/Generic/DialogAdvertisingViewModel.cs deleted file mode 100644 index abd3dde..0000000 --- a/Gestor.Application/ViewModels/Generic/DialogAdvertisingViewModel.cs +++ /dev/null @@ -1,292 +0,0 @@ -using Gestor.Application.Helpers; -using Gestor.Application.Model; -using Gestor.Common.Validation; -using Gestor.Model.Domain.Common; -using Gestor.Model.Domain.Generic; -using Gestor.Model.Domain.Seguros; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using System.Windows; - -namespace Gestor.Application.ViewModels.Generic -{ - public class DialogAdvertisingViewModel : BaseViewModel - { - private readonly bool _isPromo; - - private string _urlPesquisa; - - private Visibility _visualizarNaoExibirNovamente = Visibility.Hidden; - - private string _titulo = ""; - - private string _imagem = ""; - - public string Url = ""; - - private bool _naoQuero; - - public string Imagem - { - get - { - return this._imagem; - } - set - { - this._imagem = value; - base.OnPropertyChanged("Imagem"); - } - } - - public bool NaoVer - { - get - { - return this._naoQuero; - } - set - { - this._naoQuero = value; - base.OnPropertyChanged("NaoVer"); - } - } - - public string Titulo - { - get - { - return this._titulo; - } - set - { - this._titulo = value; - base.OnPropertyChanged("Titulo"); - } - } - - public Visibility VisualizarNaoExibirNovamente - { - get - { - return this._visualizarNaoExibirNovamente; - } - set - { - this._visualizarNaoExibirNovamente = value; - base.OnPropertyChanged("VisualizarNaoExibirNovamente"); - } - } - - public DialogAdvertisingViewModel(JObject jsonAd, bool isPromo) - { - bool flag; - bool flag1 = false; - this._isPromo = isPromo; - if (this._isPromo) - { - this.CarregaImagem(jsonAd); - JToken item = jsonAd.get_Item("NaoExibirNovamente"); - if (item != null) - { - flag = Extensions.Value(item); - } - else - { - flag = true; - } - flag1 = flag; - } - else - { - this.CarregaPesquisa(jsonAd); - } - this.VisualizarNaoExibirNovamente = (flag1 ? Visibility.Visible : Visibility.Hidden); - } - - private void CarregaImagem(JObject json) - { - string str; - string str1; - string str2; - if (json == null) - { - return; - } - JToken item = json.get_Item("Titulo"); - if (item != null) - { - str = Extensions.Value(item); - } - else - { - str = null; - } - this.Titulo = str; - JToken jToken = json.get_Item("Url"); - if (jToken != null) - { - str1 = Extensions.Value(jToken); - } - else - { - str1 = null; - } - this.Url = str1; - JToken item1 = json.get_Item("Imagem"); - if (item1 != null) - { - str2 = Extensions.Value(item1); - } - else - { - str2 = null; - } - this.Imagem = str2; - } - - private void CarregaPesquisa(JObject json) - { - string str; - string str1; - string str2; - string str3; - if (json == null) - { - return; - } - JToken item = json.get_Item("Titulo"); - if (item != null) - { - str = Extensions.Value(item); - } - else - { - str = null; - } - this.Titulo = str; - JToken jToken = json.get_Item("Imagem"); - if (jToken != null) - { - str1 = Extensions.Value(jToken); - } - else - { - str1 = null; - } - this.Imagem = str1; - JToken item1 = json.get_Item("UrlPost"); - if (item1 != null) - { - str2 = Extensions.Value(item1); - } - else - { - str2 = null; - } - this._urlPesquisa = str2; - if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(this._urlPesquisa)) - { - return; - } - JToken jToken1 = json.get_Item("UrlFixa"); - if (jToken1 != null) - { - str3 = Extensions.Value(jToken1); - } - else - { - str3 = null; - } - this._urlPesquisa = str3; - this.Url = this._urlPesquisa; - } - - public void CriarConfiguracaoPadrao(string configFile) - { - File.WriteAllText(configFile, JsonConvert.SerializeObject(new Gestor.Application.Model.Configuracoes() - { - LinkPromo = "", - NaoverPromo = this.NaoVer - }, 1)); - } - - public void EnviarPesquisa() - { - string str; - try - { - using (HttpClient httpClient = new HttpClient()) - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - httpClient.set_Timeout(TimeSpan.FromSeconds(15)); - httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("company-key", "$2b$10$arV/viDP6N.5KX9sRt/.MOo8Gv5FFvHIx0P6HZyuky51P3ItWBV0u"); - var variable = new { customers = new u003cu003ef__AnonymousType49[] { new { nome = Recursos.Usuario.get_Nome(), email = (Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(Recursos.Usuario.get_Email()) ? string.Format("{0}-{1}@sememail.com", Recursos.Usuario.get_Id(), ApplicationHelper.IdFornecedor) : Recursos.Usuario.get_Email()), corretora = Recursos.Empresa.get_NomeSocial(), produto = "Gestor", idfornecedor = ApplicationHelper.IdFornecedor } } }; - HttpResponseMessage result = httpClient.PostAsync(this._urlPesquisa, variable.ToHttpContent(null, "application/json")).Result; - if (result.get_IsSuccessStatusCode()) - { - JToken item = JObject.Parse(result.get_Content().ReadAsStringAsync().Result).get_Item("customers"); - if (item != null) - { - JToken jToken = item.get_Item(0); - if (jToken != null) - { - JToken item1 = jToken.get_Item("shortUrl"); - if (item1 != null) - { - str = Extensions.Value(item1); - } - else - { - str = null; - } - } - else - { - str = null; - } - } - else - { - str = null; - } - string str1 = str; - if (!Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(str1)) - { - this.Url = str1; - } - else - { - return; - } - } - else - { - return; - } - } - } - catch (Exception exception) - { - } - } - - public void SalvaEditarArquivoConfig(bool visto = false) - { - if (!File.Exists("config.json")) - { - this.CriarConfiguracaoPadrao("config.json"); - } - Gestor.Application.Model.Configuracoes naoVer = JsonConvert.DeserializeObject(File.ReadAllText("config.json")); - naoVer.LinkPromo = (this._isPromo ? this.Imagem : this._urlPesquisa); - naoVer.NaoverPromo = this.NaoVer; - File.WriteAllText("config.json", JsonConvert.SerializeObject(naoVer, 1)); - } - } -} \ No newline at end of file -- cgit v1.2.3