diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Application/ViewModels/Generic/DialogAdvertisingViewModel.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Gestor.Application/ViewModels/Generic/DialogAdvertisingViewModel.cs')
| -rw-r--r-- | Gestor.Application/ViewModels/Generic/DialogAdvertisingViewModel.cs | 292 |
1 files changed, 0 insertions, 292 deletions
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<bool>(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<string>(item);
- }
- else
- {
- str = null;
- }
- this.Titulo = str;
- JToken jToken = json.get_Item("Url");
- if (jToken != null)
- {
- str1 = Extensions.Value<string>(jToken);
- }
- else
- {
- str1 = null;
- }
- this.Url = str1;
- JToken item1 = json.get_Item("Imagem");
- if (item1 != null)
- {
- str2 = Extensions.Value<string>(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<string>(item);
- }
- else
- {
- str = null;
- }
- this.Titulo = str;
- JToken jToken = json.get_Item("Imagem");
- if (jToken != null)
- {
- str1 = Extensions.Value<string>(jToken);
- }
- else
- {
- str1 = null;
- }
- this.Imagem = str1;
- JToken item1 = json.get_Item("UrlPost");
- if (item1 != null)
- {
- str2 = Extensions.Value<string>(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<string>(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<string, string, string, string, long>[] { 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<string>(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<Gestor.Application.Model.Configuracoes>(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 |