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 /Codemerx/Gestor.Model/Model.Validation | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Model/Model.Validation')
| -rw-r--r-- | Codemerx/Gestor.Model/Model.Validation/ControleValidacao.cs | 36 | ||||
| -rw-r--r-- | Codemerx/Gestor.Model/Model.Validation/Funcoes.cs | 167 |
2 files changed, 203 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Model/Model.Validation/ControleValidacao.cs b/Codemerx/Gestor.Model/Model.Validation/ControleValidacao.cs new file mode 100644 index 0000000..2c3af2c --- /dev/null +++ b/Codemerx/Gestor.Model/Model.Validation/ControleValidacao.cs @@ -0,0 +1,36 @@ +using System;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Model.Validation
+{
+ public class ControleValidacao
+ {
+ public string Estilo
+ {
+ get;
+ set;
+ }
+
+ public string Nome
+ {
+ get;
+ set;
+ }
+
+ public string Tag
+ {
+ get;
+ set;
+ }
+
+ public Type Tipo
+ {
+ get;
+ set;
+ }
+
+ public ControleValidacao()
+ {
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Model/Model.Validation/Funcoes.cs b/Codemerx/Gestor.Model/Model.Validation/Funcoes.cs new file mode 100644 index 0000000..a1790a2 --- /dev/null +++ b/Codemerx/Gestor.Model/Model.Validation/Funcoes.cs @@ -0,0 +1,167 @@ +using Gestor.Model.Common;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Model.Validation
+{
+ public static class Funcoes
+ {
+ public static System.Diagnostics.Stopwatch Stopwatch;
+
+ public static DateTime? StartTime;
+
+ public static int GetAge(DateTime birth)
+ {
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ int year = date.Year - birth.Year;
+ if (birth > date.AddYears(-year))
+ {
+ year--;
+ }
+ return year;
+ }
+
+ public static string GetDescription(this Enum genericEnum)
+ {
+ if (genericEnum == null)
+ {
+ return "";
+ }
+ MemberInfo[] member = genericEnum.GetType().GetMember(genericEnum.ToString());
+ if (member.Length == 0)
+ {
+ return genericEnum.ToString();
+ }
+ object[] customAttributes = member[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
+ if (!customAttributes.Any<object>())
+ {
+ return genericEnum.ToString();
+ }
+ return ((DescriptionAttribute)customAttributes.ElementAt<object>(0)).Description;
+ }
+
+ public static DateTime GetNetworkTime()
+ {
+ DateTime value;
+ try
+ {
+ if (!Funcoes.StartTime.HasValue)
+ {
+ byte[] numArray = new byte[48];
+ numArray[0] = 27;
+ IPEndPoint pEndPoint = new IPEndPoint(((IEnumerable<IPAddress>)Dns.GetHostEntry("time.google.com").AddressList).First<IPAddress>((IPAddress a) => a.AddressFamily == AddressFamily.InterNetwork), 123);
+ using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
+ {
+ socket.Connect(pEndPoint);
+ socket.ReceiveTimeout = 3000;
+ socket.Send(numArray);
+ socket.Receive(numArray);
+ socket.Close();
+ }
+ ulong num = (ulong)numArray[40] << 24 | (ulong)numArray[41] << 16 | (ulong)numArray[42] << 8 | (ulong)numArray[43];
+ ulong num1 = (ulong)numArray[44] << 24 | (ulong)numArray[45] << 16 | (ulong)numArray[46] << 8 | (ulong)numArray[47];
+ ulong num2 = num * (long)1000 + num1 * (long)1000 / 4294967296L;
+ DateTime dateTime = new DateTime(1900, 1, 1);
+ dateTime = dateTime.AddMilliseconds((double)num2);
+ Funcoes.StartTime = new DateTime?(dateTime.ToLocalTime());
+ Funcoes.Stopwatch = System.Diagnostics.Stopwatch.StartNew();
+ value = Funcoes.StartTime.Value;
+ }
+ else
+ {
+ value = Funcoes.StartTime.Value;
+ value = value.AddMilliseconds((double)Funcoes.Stopwatch.ElapsedMilliseconds);
+ }
+ }
+ catch (Exception exception)
+ {
+ Funcoes.StartTime = new DateTime?(DateTime.Now);
+ Funcoes.Stopwatch = System.Diagnostics.Stopwatch.StartNew();
+ value = Funcoes.StartTime.Value;
+ }
+ return value;
+ }
+
+ public static ParentescoVinculo? ParentescoInverso(ParentescoVinculo? parentesco)
+ {
+ if (parentesco.HasValue)
+ {
+ switch (parentesco.GetValueOrDefault())
+ {
+ case ParentescoVinculo.MaePai:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Filho);
+ }
+ case ParentescoVinculo.Filho:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.MaePai);
+ }
+ case ParentescoVinculo.Avo:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Neto);
+ }
+ case ParentescoVinculo.Neto:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Avo);
+ }
+ case ParentescoVinculo.Tio:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Sobrinho);
+ }
+ case ParentescoVinculo.Sobrinho:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Tio);
+ }
+ case ParentescoVinculo.Bisavo:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Bisneto);
+ }
+ case ParentescoVinculo.Bisneto:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Bisavo);
+ }
+ case ParentescoVinculo.Sogro:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Genro);
+ }
+ case ParentescoVinculo.Genro:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Sogro);
+ }
+ case ParentescoVinculo.MadrastaPadrasto:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Enteado);
+ }
+ case ParentescoVinculo.Enteado:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.MadrastaPadrasto);
+ }
+ case ParentescoVinculo.Proprietario:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Propriedade);
+ }
+ case ParentescoVinculo.Propriedade:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Proprietario);
+ }
+ case ParentescoVinculo.Contratante:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Funcionario);
+ }
+ case ParentescoVinculo.Funcionario:
+ {
+ return new ParentescoVinculo?(ParentescoVinculo.Contratante);
+ }
+ }
+ }
+ return parentesco;
+ }
+ }
+}
\ No newline at end of file |