diff options
Diffstat (limited to 'Gestor.Model/Model.Domain.Ferramentas/Credencial.cs')
| -rw-r--r-- | Gestor.Model/Model.Domain.Ferramentas/Credencial.cs | 278 |
1 files changed, 278 insertions, 0 deletions
diff --git a/Gestor.Model/Model.Domain.Ferramentas/Credencial.cs b/Gestor.Model/Model.Domain.Ferramentas/Credencial.cs new file mode 100644 index 0000000..a6e7464 --- /dev/null +++ b/Gestor.Model/Model.Domain.Ferramentas/Credencial.cs @@ -0,0 +1,278 @@ +using Gestor.Model.Attributes;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+using Gestor.Model.Resources;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Text.RegularExpressions;
+
+namespace Gestor.Model.Domain.Ferramentas
+{
+ public class Credencial : DomainBase, IDomain
+ {
+ private string _descricao;
+
+ private string _assinatura;
+
+ private string _header;
+
+ private string _cabecalho;
+
+ [Description("ASSINATURA")]
+ [Log(true)]
+ public string Assinatura
+ {
+ get
+ {
+ return this._assinatura;
+ }
+ set
+ {
+ this._assinatura = value ?? "";
+ }
+ }
+
+ public string Cabecalho
+ {
+ get
+ {
+ return this._cabecalho;
+ }
+ set
+ {
+ this._cabecalho = value ?? "";
+ }
+ }
+
+ [Description("DESCRIÇÃO")]
+ [Log(true)]
+ public string Descricao
+ {
+ get
+ {
+ string str = this._descricao;
+ if (str != null)
+ {
+ return str.ToUpper();
+ }
+ return null;
+ }
+ set
+ {
+ this._descricao = value;
+ }
+ }
+
+ [Description("DOMÍNIO")]
+ [Log(true)]
+ public string Dominio
+ {
+ get;
+ set;
+ }
+
+ [Description("E-MAIL")]
+ [Log(true)]
+ public string Email
+ {
+ get;
+ set;
+ }
+
+ public bool Excluido
+ {
+ get;
+ set;
+ }
+
+ [Log(true)]
+ public string Header
+ {
+ get
+ {
+ return this._header;
+ }
+ set
+ {
+ this._header = value;
+ }
+ }
+
+ public long IdEmpresa
+ {
+ get;
+ set;
+ }
+
+ public long IdUsuario
+ {
+ get;
+ set;
+ }
+
+ [Description("PORTA")]
+ [Log(true)]
+ public int? Porta
+ {
+ get;
+ set;
+ }
+
+ public string Replyto
+ {
+ get;
+ set;
+ }
+
+ [Description("SEGURO")]
+ [Log(true)]
+ public bool Seguro
+ {
+ get;
+ set;
+ }
+
+ [Description("SENHA")]
+ [Log(true)]
+ public string Senha
+ {
+ get;
+ set;
+ }
+
+ [Log(true)]
+ public TipoEmail Tipo
+ {
+ get;
+ set;
+ }
+
+ [Description("USUÁRIO")]
+ [Log(true)]
+ public string Usuario
+ {
+ get;
+ set;
+ }
+
+ [JsonIgnore]
+ public Func<List<KeyValuePair<string, string>>> ValidationEvent
+ {
+ get
+ {
+ Credencial credencial = this;
+ return new Func<List<KeyValuePair<string, string>>>(credencial.Validate);
+ }
+ }
+
+ public Credencial()
+ {
+ }
+
+ public List<TupleList> Log()
+ {
+ string str;
+ List<TupleList> tupleLists = new List<TupleList>();
+ this.Assinatura = (new Regex("<title>.*<\\/title>")).Replace(this.Assinatura, "").Trim();
+ this.Assinatura = (new Regex("(<[^>]*>)|(p\\s?{[^}]*})|(\\r)|(\\n)")).Replace(this.Assinatura, "").Trim();
+ TupleList tupleList = new TupleList();
+ ObservableCollection<Tuple<string, string, string>> observableCollection = new ObservableCollection<Tuple<string, string, string>>()
+ {
+ new Tuple<string, string, string>("DESCRIÇÃO", (string.IsNullOrWhiteSpace(this.Descricao) ? "" : this.Descricao), "")
+ };
+ int? porta = this.Porta;
+ if (!porta.HasValue)
+ {
+ str = "";
+ }
+ else
+ {
+ porta = this.Porta;
+ if (porta.HasValue)
+ {
+ str = porta.GetValueOrDefault().ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ observableCollection.Add(new Tuple<string, string, string>("PORTA", str, ""));
+ observableCollection.Add(new Tuple<string, string, string>("DOMÍNIO", (string.IsNullOrWhiteSpace(this.Dominio) ? "" : this.Dominio), ""));
+ observableCollection.Add(new Tuple<string, string, string>("E-MAIL", (string.IsNullOrWhiteSpace(this.Email) ? "" : this.Email), ""));
+ observableCollection.Add(new Tuple<string, string, string>("LOGIN", (string.IsNullOrWhiteSpace(this.Usuario) ? "" : this.Usuario), ""));
+ observableCollection.Add(new Tuple<string, string, string>("CERTIFICADO DE SEGURANÇA", (this.Seguro ? "SIM" : "NÃO"), ""));
+ observableCollection.Add(new Tuple<string, string, string>("ASSINATURA", (string.IsNullOrWhiteSpace(this.Assinatura) ? "" : this.Assinatura), ""));
+ tupleList.Tuples = observableCollection;
+ tupleLists.Add(tupleList);
+ return tupleLists;
+ }
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
+ if (string.IsNullOrEmpty(this.Descricao))
+ {
+ keyValuePairs.AddValue<string, string>("Descricao|DESCRIÇÃO", Messages.Obrigatorio, true);
+ }
+ else if (this.Descricao.Length > 50)
+ {
+ keyValuePairs.AddValue<string, string>("Descricao|DESCRIÇÃO", string.Format(Messages.MaiorQueLimite, 50), true);
+ }
+ if (this.Tipo == TipoEmail.Outros)
+ {
+ if (!this.Porta.HasValue)
+ {
+ keyValuePairs.AddValue<string, string>("Porta", Messages.Invalido, true);
+ }
+ if (string.IsNullOrWhiteSpace(this.Dominio))
+ {
+ keyValuePairs.AddValue<string, string>("Dominio|DOMÍNIO", Messages.Obrigatorio, true);
+ }
+ else if (this.Dominio.Length > 80)
+ {
+ keyValuePairs.AddValue<string, string>("Dominio|DOMÍNIO", string.Format(Messages.MaiorQueLimite, 80), true);
+ }
+ if (string.IsNullOrEmpty(this.Usuario))
+ {
+ keyValuePairs.AddValue<string, string>("Usuario|USUÁRIO", Messages.Obrigatorio, true);
+ }
+ else if (this.Usuario.Length > 50)
+ {
+ keyValuePairs.AddValue<string, string>("Usuario|USUÁRIO", string.Format(Messages.MaiorQueLimite, 50), true);
+ }
+ if (string.IsNullOrEmpty(this.Senha))
+ {
+ keyValuePairs.AddValue<string, string>("Senha", Messages.Obrigatorio, true);
+ }
+ else if (this.Senha.Length > 50)
+ {
+ keyValuePairs.AddValue<string, string>("Senha", string.Format(Messages.MaiorQueLimite, 50), true);
+ }
+ }
+ if (string.IsNullOrWhiteSpace(this.Email))
+ {
+ keyValuePairs.AddValue<string, string>("Email|E-MAIL", Messages.Obrigatorio, true);
+ }
+ else if (this.Email.Length > 80)
+ {
+ keyValuePairs.AddValue<string, string>("Email|E-MAIL", string.Format(Messages.MaiorQueLimite, 80), true);
+ }
+ else if (!this.Email.ValidacaoEmail())
+ {
+ keyValuePairs.AddValue<string, string>("Email|E-MAIL", Messages.Invalido, true);
+ }
+ if (!string.IsNullOrWhiteSpace(this.Replyto) && !this.Replyto.ValidacaoEmail())
+ {
+ keyValuePairs.AddValue<string, string>("Replyto|RESPONDER PARA", Messages.Obrigatorio, true);
+ }
+ return keyValuePairs;
+ }
+ }
+}
\ No newline at end of file |