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 --- .../ApolicePendenteConverter.cs | 33 + .../ArquivoDigitalToolTipConverter.cs | 38 + .../AtivoConverterColor.cs | 35 + .../AtivoVisibilityConverter.cs | 38 + .../Gestor.Common.Converters/BoolToEyeConverter.cs | 37 + .../BoolToYesNoConverter.cs | 33 + .../ComissaoColorConverter.cs | 39 + .../Gestor.Common.Converters/ComissaoConverter.cs | 43 + .../ComissaoConverterMulti.cs | 74 ++ .../ComparativoColorConverter.cs | 71 ++ .../ComparativoConverter.cs | 55 ++ .../ComparativoPercentualToolTipConverter.cs | 33 + .../ComparativoToolTipConverter.cs | 24 + .../EnumDescriptionConverter.cs | 34 + .../ExpanderHeaderConverter.cs | 33 + .../IdToVisibilityConverter.cs | 30 + .../InativoVisibilityConverter.cs | 38 + .../InvertedBooleanConverter.cs | 29 + .../InvertedBooleanToVisibilityConverter.cs | 30 + .../InvertedVisibilityConverter.cs | 30 + .../IsInsertedBoolConverter.cs | 29 + .../IsNotNullBoolConverter.cs | 29 + .../Gestor.Common.Converters/MesConverter.cs | 39 + .../MultiBoolAndConverter.cs | 35 + .../NegativoColorConverter.cs | 38 + .../NullVisibilityConverter.cs | 30 + .../NullVisibilityInvertedConverter.cs | 30 + .../ObjectToStringConverter.cs | 56 ++ .../ObjectVisibilityConverter.cs | 31 + ...agamentoVendedorCorretoraVisibilityConverter.cs | 28 + .../ParcelaVisibilityConverter.cs | 31 + .../Gestor.Common.Converters/PendenciaConverter.cs | 35 + .../PendenciaVisibilityConverter.cs | 35 + .../RamoAutoVisibilityConverter.cs | 50 ++ .../RecebidoColorConverter.cs | 32 + .../SaldoWeightConverter.cs | 30 + .../SinalColorConverter.cs | 35 + .../StatusExtratoColorConverter.cs | 65 ++ .../StatusParcelaVisibilityConverter.cs | 42 + .../StatusTarefaVisibilityConverter.cs | 43 + .../StringNullOrEmptyToVisibilityConverter.cs | 30 + .../TarefaBackgroundColorConverter.cs | 54 ++ .../TemTarefaVisibilityConverter.cs | 32 + .../TipoCriticaConverter.cs | 40 + .../TipoSinistroConverter.cs | 43 + .../TipoTelefoneVisibilityConverter.cs | 39 + .../TotalizacaoExpanderConverter.cs | 33 + .../Gestor.Common.Converters/ValorTipoConverter.cs | 47 + .../ZeroToEmptyConverter.cs | 41 + .../ZeroToVisibilityConverter.cs | 30 + .../ZeroToVisibilityInvertedConverter.cs | 30 + .../ZeroToVisibilityValorConverter.cs | 31 + .../Gestor.Common.Exceptions/AbortException.cs | 11 + .../Gestor.Common.Exceptions/BaseException.cs | 15 + .../Gestor.Common.Exceptions/ForbiddenException.cs | 15 + .../Gestor.Common.Exceptions/MailingException.cs | 15 + .../PermissionException.cs | 15 + .../UnauthorizedException.cs | 15 + .../ValidationException.cs | 15 + .../Gestor.Common.Helpers/DataBaseParameters.cs | 14 + .../Gestor.Common.Helpers/DefaultAttribute.cs | 19 + .../Gestor.Common.Helpers/EncryptionHelper.cs | 106 +++ .../EnumBindingSourceExtension.cs | 59 ++ .../Gestor.Common.Helpers/EnumHelper.cs | 166 ++++ .../Gestor.Common.Helpers/FindVisualChild.cs | 32 + .../Gestor.Common.Helpers/FindVisualChildren.cs | 38 + .../Gestor.Common.Helpers/Functions.cs | 110 +++ .../Gestor.Common.Helpers/HiddenAttribute.cs | 12 + .../Gestor.Common.Helpers/HttpHelper.cs | 25 + .../Gestor.Common.Helpers/OrderAttribute.cs | 20 + .../ScrollAnimationBehavior.cs | 124 +++ .../Gestor.Common/Gestor.Common.Security/Token.cs | 148 +++ .../Gestor.Common.Validation/SemValicao.cs | 18 + .../Gestor.Common.Validation/ValidacaoAno.cs | 27 + .../ValidacaoAnoObrigatorio.cs | 31 + .../ValidacaoCeiObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoCep.cs | 27 + .../ValidacaoCepObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoChassi.cs | 27 + .../ValidacaoChassiObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoData.cs | 27 + .../ValidacaoDataFutura.cs | 27 + .../Gestor.Common.Validation/ValidacaoDataMaior.cs | 38 + .../ValidacaoDataObrigatoria.cs | 31 + .../ValidacaoDataPassada.cs | 27 + .../ValidacaoDataPassadaObrigatoria.cs | 31 + .../Gestor.Common.Validation/ValidacaoDocumento.cs | 27 + .../ValidacaoDocumentoObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoDouble.cs | 27 + .../Gestor.Common.Validation/ValidacaoEmail.cs | 27 + .../ValidacaoEmailObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoEstado.cs | 27 + .../ValidacaoEstadoObrigatorio.cs | 31 + .../ValidacaoFipeObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoInt.cs | 27 + .../ValidacaoIntObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoLong.cs | 27 + .../ValidacaoLongObrigatorio.cs | 31 + .../ValidacaoObrigatorio.cs | 27 + .../Gestor.Common.Validation/ValidacaoOrgao.cs | 27 + .../Gestor.Common.Validation/ValidacaoPlaca.cs | 27 + .../ValidacaoPlacaObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoPrefixo.cs | 27 + .../ValidacaoPrefixoObrigatorio.cs | 31 + .../ValidacaoRneObrigatorio.cs | 31 + .../Gestor.Common.Validation/ValidacaoTelefone.cs | 27 + .../ValidacaoTelefoneObrigatorio.cs | 31 + .../ValidacaoValorDiferenteZero.cs | 31 + .../ValidacaoValorMaiorQueZero.cs | 31 + .../Gestor.Common.Validation/ValidationHelper.cs | 992 +++++++++++++++++++++ Codemerx/Gestor.Common/Gestor.Common.csproj | 490 ++++++++++ Codemerx/Gestor.Common/Gestor.Common.sln | 21 + .../Gestor.CommonReferences/Gestor.Model.dll | Bin 0 -> 833808 bytes Codemerx/Gestor.Common/Properties/AssemblyInfo.cs | 20 + 114 files changed, 5540 insertions(+) create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ApolicePendenteConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ArquivoDigitalToolTipConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/AtivoConverterColor.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/AtivoVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/BoolToYesNoConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoColorConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoConverterMulti.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoColorConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoPercentualToolTipConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoToolTipConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/EnumDescriptionConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ExpanderHeaderConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/InativoVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedBooleanConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedBooleanToVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/IsInsertedBoolConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/IsNotNullBoolConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/MesConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/MultiBoolAndConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/NegativoColorConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/NullVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/NullVisibilityInvertedConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ObjectToStringConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ObjectVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/PagamentoVendedorCorretoraVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ParcelaVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/PendenciaConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/PendenciaVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/RamoAutoVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/RecebidoColorConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/SaldoWeightConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/SinalColorConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/StatusExtratoColorConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/StatusParcelaVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/StatusTarefaVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/StringNullOrEmptyToVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/TarefaBackgroundColorConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/TemTarefaVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/TipoCriticaConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/TipoSinistroConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/TipoTelefoneVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/TotalizacaoExpanderConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ValorTipoConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToEmptyConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityInvertedConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityValorConverter.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Exceptions/AbortException.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Exceptions/BaseException.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Exceptions/ForbiddenException.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Exceptions/MailingException.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Exceptions/PermissionException.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Exceptions/UnauthorizedException.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Exceptions/ValidationException.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/DataBaseParameters.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/DefaultAttribute.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/EncryptionHelper.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/EnumBindingSourceExtension.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/EnumHelper.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/FindVisualChild.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/Functions.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/HiddenAttribute.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/HttpHelper.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/OrderAttribute.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Helpers/ScrollAnimationBehavior.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Security/Token.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/SemValicao.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoAno.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoAnoObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCeiObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCep.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCepObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoChassi.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoChassiObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoData.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataFutura.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataMaior.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataObrigatoria.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataPassada.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataPassadaObrigatoria.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDocumento.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDocumentoObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDouble.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEmail.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEmailObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEstado.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEstadoObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoFipeObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoInt.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoIntObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoLong.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoLongObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoOrgao.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPlaca.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPlacaObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPrefixo.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPrefixoObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoRneObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoTelefone.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoTelefoneObrigatorio.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoValorDiferenteZero.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoValorMaiorQueZero.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.Validation/ValidationHelper.cs create mode 100644 Codemerx/Gestor.Common/Gestor.Common.csproj create mode 100644 Codemerx/Gestor.Common/Gestor.Common.sln create mode 100644 Codemerx/Gestor.Common/Gestor.CommonReferences/Gestor.Model.dll create mode 100644 Codemerx/Gestor.Common/Properties/AssemblyInfo.cs (limited to 'Codemerx/Gestor.Common') diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ApolicePendenteConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ApolicePendenteConverter.cs new file mode 100644 index 0000000..ae3003e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ApolicePendenteConverter.cs @@ -0,0 +1,33 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ApolicePendenteConverter : MarkupExtension, IValueConverter + { + public ApolicePendenteConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && !string.IsNullOrEmpty((string)value)) + { + return value; + } + return "PENDENTE DE EMISSÃO"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ArquivoDigitalToolTipConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ArquivoDigitalToolTipConverter.cs new file mode 100644 index 0000000..3c9e6dc --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ArquivoDigitalToolTipConverter.cs @@ -0,0 +1,38 @@ +using Gestor.Model.Domain.Common; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Runtime.CompilerServices; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ArquivoDigitalToolTipConverter : MarkupExtension, IValueConverter + { + public ArquivoDigitalToolTipConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null || ((List)value).Count == 0) + { + return ""; + } + return string.Join(Environment.NewLine, + from v in (List)value + select v.Descricao); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/AtivoConverterColor.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/AtivoConverterColor.cs new file mode 100644 index 0000000..cc99edf --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/AtivoConverterColor.cs @@ -0,0 +1,35 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Common.Converters +{ + public class AtivoConverterColor : MarkupExtension, IValueConverter + { + public AtivoConverterColor() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null || !(bool)value) + { + return new SolidColorBrush(Colors.Red); + } + return new SolidColorBrush((Color)Application.Current.Resources["AggerBlue"]); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/AtivoVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/AtivoVisibilityConverter.cs new file mode 100644 index 0000000..d8ffe3f --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/AtivoVisibilityConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class AtivoVisibilityConverter : IMultiValueConverter + { + public AtivoVisibilityConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object obj = values[0]; + if (obj is bool && (bool)obj) + { + return Visibility.Collapsed; + } + if (values[1] == null) + { + return Visibility.Visible; + } + obj = values[1]; + if (obj is long && (long)obj > (long)0) + { + return Visibility.Collapsed; + } + return Visibility.Visible; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs new file mode 100644 index 0000000..062b96b --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs @@ -0,0 +1,37 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class BoolToEyeConverter : MarkupExtension, IValueConverter + { + public BoolToEyeConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return "Eye"; + } + if (!(bool)value) + { + return "Eye"; + } + return "EyeOff"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString())); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/BoolToYesNoConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/BoolToYesNoConverter.cs new file mode 100644 index 0000000..529a9e7 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/BoolToYesNoConverter.cs @@ -0,0 +1,33 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class BoolToYesNoConverter : MarkupExtension, IValueConverter + { + public BoolToYesNoConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && (bool)value) + { + return "SIM"; + } + return "NÃO"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoColorConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoColorConverter.cs new file mode 100644 index 0000000..88df822 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoColorConverter.cs @@ -0,0 +1,39 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Common.Converters +{ + public class ComissaoColorConverter : MarkupExtension, IValueConverter + { + public ComissaoColorConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return new SolidColorBrush(Colors.Red); + } + if ((int)Math.Round(double.Parse(value.ToString())) >= 0 && (int)Math.Round(double.Parse(value.ToString())) != 0) + { + return new SolidColorBrush(Colors.Red); + } + return new SolidColorBrush((Color)Application.Current.Resources["AggerBlue"]); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString())); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoConverter.cs new file mode 100644 index 0000000..d66a902 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoConverter.cs @@ -0,0 +1,43 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ComissaoConverter : MarkupExtension, IValueConverter + { + public ComissaoConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + decimal? nullable; + decimal? nullable1; + decimal? nullable2 = (decimal?)value; + decimal num = 100; + if (nullable2.HasValue) + { + nullable1 = new decimal?(nullable2.GetValueOrDefault() / num); + } + else + { + nullable = null; + nullable1 = nullable; + } + nullable = nullable1; + return nullable.GetValueOrDefault(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoConverterMulti.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoConverterMulti.cs new file mode 100644 index 0000000..5797387 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComissaoConverterMulti.cs @@ -0,0 +1,74 @@ +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class ComissaoConverterMulti : IMultiValueConverter + { + public ComissaoConverterMulti() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + decimal? nullable; + decimal? nullable1; + if (values[0] == DependencyProperty.UnsetValue && values[1] == DependencyProperty.UnsetValue) + { + return null; + } + if (values[1] == DependencyProperty.UnsetValue) + { + return values[0]; + } + object obj = values[0]; + TipoRepasse tipoRepasse = (TipoRepasse)values[1]; + string lower = parameter.ToString().ToLower(); + if (lower == "tipovendedorcolumn") + { + if (tipoRepasse == TipoRepasse.CoCorretagem) + { + return "CO-CORRETAGEM"; + } + return obj; + } + if (lower == "formapagamentocolumn" || lower == "incidenciacolumn") + { + if (tipoRepasse == TipoRepasse.CoCorretagem) + { + return "--"; + } + return obj; + } + if (lower == "pagamentosvalorrepassecolumn" || lower == "repassevendedor") + { + return obj; + } + if (tipoRepasse == TipoRepasse.ValorFixo) + { + return "--"; + } + decimal? nullable2 = (decimal?)obj; + decimal num = 100; + if (nullable2.HasValue) + { + nullable1 = new decimal?(nullable2.GetValueOrDefault() / num); + } + else + { + nullable = null; + nullable1 = nullable; + } + nullable = nullable1; + return nullable.GetValueOrDefault(); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoColorConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoColorConverter.cs new file mode 100644 index 0000000..700be13 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoColorConverter.cs @@ -0,0 +1,71 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media; + +namespace Gestor.Common.Converters +{ + public class ComparativoColorConverter : IMultiValueConverter + { + public ComparativoColorConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + decimal num; + decimal num1; + object darkGoldenrod; + try + { + if (values[0] == null) + { + darkGoldenrod = 0; + } + else if (values[1] != null) + { + num = (!(values[0] is int) ? ((decimal?)values[0]).GetValueOrDefault() : (int)values[0]); + num1 = (!(values[1] is int) ? ((decimal?)values[1]).GetValueOrDefault() : (int)values[1]); + if (num == decimal.Zero && num1 == decimal.Zero) + { + darkGoldenrod = Brushes.DarkGoldenrod; + } + else if (num == decimal.Zero && num1 > decimal.Zero) + { + darkGoldenrod = Brushes.Red; + } + else if (num1 == decimal.Zero && num > decimal.Zero) + { + darkGoldenrod = Brushes.Green; + } + else if (num == decimal.Zero && num1 < decimal.Zero) + { + darkGoldenrod = Brushes.Green; + } + else if (!(num1 == decimal.Zero) || !(num < decimal.Zero)) + { + darkGoldenrod = (((num / num1) - decimal.One) > decimal.Zero ? Brushes.Green : Brushes.Red); + } + else + { + darkGoldenrod = Brushes.Red; + } + } + else + { + darkGoldenrod = 0; + } + } + catch (Exception exception) + { + darkGoldenrod = Brushes.Black; + } + return darkGoldenrod; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoConverter.cs new file mode 100644 index 0000000..fb7ee01 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoConverter.cs @@ -0,0 +1,55 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class ComparativoConverter : IMultiValueConverter + { + public ComparativoConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + decimal num; + decimal num1; + if (values[0] == null) + { + return 0; + } + if (values[1] == null) + { + return 0; + } + num = (!(values[0] is int) ? ((decimal?)values[0]).GetValueOrDefault() : (int)values[0]); + num1 = (!(values[1] is int) ? ((decimal?)values[1]).GetValueOrDefault() : (int)values[1]); + if (num == decimal.Zero && num1 == decimal.Zero) + { + return 0; + } + if (num == decimal.Zero && num1 > decimal.Zero) + { + return -1; + } + if (num1 == decimal.Zero && num > decimal.Zero) + { + return 1; + } + if (num == decimal.Zero && num1 < decimal.Zero) + { + return 1; + } + if (num1 == decimal.Zero && num < decimal.Zero) + { + return -1; + } + return (num - num1) / (num1 > decimal.Zero ? num1 : -num1); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoPercentualToolTipConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoPercentualToolTipConverter.cs new file mode 100644 index 0000000..a978ec0 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoPercentualToolTipConverter.cs @@ -0,0 +1,33 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class ComparativoPercentualToolTipConverter : IMultiValueConverter + { + public ComparativoPercentualToolTipConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object obj; + try + { + decimal num = (decimal)values[1] * new decimal(100); + obj = string.Format("VALOR EM {0}: {1}%", values[0], num); + } + catch (Exception exception) + { + obj = ""; + } + return obj; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoToolTipConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoToolTipConverter.cs new file mode 100644 index 0000000..c10c19a --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ComparativoToolTipConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class ComparativoToolTipConverter : IMultiValueConverter + { + public ComparativoToolTipConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + string str = (!(values[0] is int) ? "R$" : ""); + return string.Format("VALOR EM {0}: {1} {2}", values[0], str, values[1]); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/EnumDescriptionConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/EnumDescriptionConverter.cs new file mode 100644 index 0000000..64de689 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/EnumDescriptionConverter.cs @@ -0,0 +1,34 @@ +using Gestor.Common.Validation; +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class EnumDescriptionConverter : MarkupExtension, IValueConverter + { + public EnumDescriptionConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (!(value is Enum)) + { + return ""; + } + return ((Enum)value).GetDescription(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ExpanderHeaderConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ExpanderHeaderConverter.cs new file mode 100644 index 0000000..8e65056 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ExpanderHeaderConverter.cs @@ -0,0 +1,33 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ExpanderHeaderConverter : MarkupExtension, IValueConverter + { + public ExpanderHeaderConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && (bool)value) + { + return "MENOS INFORMAÇÕES"; + } + return "MAIS INFORMAÇÕES"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs new file mode 100644 index 0000000..ff9f6a3 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class IdToVisibilityConverter : MarkupExtension, IValueConverter + { + public IdToVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || (int)Math.Round(double.Parse(value.ToString())) == 0 ? Visibility.Visible : Visibility.Collapsed); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString())); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/InativoVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/InativoVisibilityConverter.cs new file mode 100644 index 0000000..4969d70 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/InativoVisibilityConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class InativoVisibilityConverter : IMultiValueConverter + { + public InativoVisibilityConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object obj = values[0]; + if (obj is bool && (bool)obj) + { + return Visibility.Visible; + } + if (values[1] == null) + { + return Visibility.Collapsed; + } + obj = values[1]; + if (obj is long && (long)obj > (long)0) + { + return Visibility.Visible; + } + return Visibility.Collapsed; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedBooleanConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedBooleanConverter.cs new file mode 100644 index 0000000..a0c0284 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedBooleanConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class InvertedBooleanConverter : MarkupExtension, IValueConverter + { + public InvertedBooleanConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null ? false : !(bool)value); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedBooleanToVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedBooleanToVisibilityConverter.cs new file mode 100644 index 0000000..9170c1e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedBooleanToVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class InvertedBooleanToVisibilityConverter : MarkupExtension, IValueConverter + { + public InvertedBooleanToVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || !(bool)value ? Visibility.Visible : Visibility.Collapsed); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedVisibilityConverter.cs new file mode 100644 index 0000000..34067d0 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/InvertedVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class InvertedVisibilityConverter : MarkupExtension, IValueConverter + { + public InvertedVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || (Visibility)value != Visibility.Visible ? Visibility.Visible : Visibility.Collapsed); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/IsInsertedBoolConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/IsInsertedBoolConverter.cs new file mode 100644 index 0000000..341ff5e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/IsInsertedBoolConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class IsInsertedBoolConverter : MarkupExtension, IValueConverter + { + public IsInsertedBoolConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null ? false : (long)value != (long)0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/IsNotNullBoolConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/IsNotNullBoolConverter.cs new file mode 100644 index 0000000..afd3293 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/IsNotNullBoolConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class IsNotNullBoolConverter : MarkupExtension, IValueConverter + { + public IsNotNullBoolConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value != null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/MesConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/MesConverter.cs new file mode 100644 index 0000000..825d4b9 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/MesConverter.cs @@ -0,0 +1,39 @@ +using Gestor.Common.Validation; +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class MesConverter : MarkupExtension, IValueConverter + { + public MesConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return ""; + } + if (!(value is Mes)) + { + return ""; + } + return (Mes)value.GetDescription(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/MultiBoolAndConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/MultiBoolAndConverter.cs new file mode 100644 index 0000000..e59ded6 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/MultiBoolAndConverter.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class MultiBoolAndConverter : IMultiValueConverter + { + public MultiBoolAndConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object obj; + try + { + obj = ((IEnumerable)values).All((object value) => (bool)value); + } + catch + { + obj = false; + } + return obj; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/NegativoColorConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/NegativoColorConverter.cs new file mode 100644 index 0000000..4d0ca3a --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/NegativoColorConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Common.Converters +{ + public class NegativoColorConverter : MarkupExtension, IValueConverter + { + public NegativoColorConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null || string.IsNullOrEmpty(value.ToString())) + { + return new SolidColorBrush(Colors.Black); + } + if (!value.ToString().Contains("-")) + { + return new SolidColorBrush(Colors.Black); + } + return new SolidColorBrush(Colors.Red); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/NullVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/NullVisibilityConverter.cs new file mode 100644 index 0000000..25b4679 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/NullVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class NullVisibilityConverter : MarkupExtension, IValueConverter + { + public NullVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null ? Visibility.Visible : Visibility.Collapsed); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/NullVisibilityInvertedConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/NullVisibilityInvertedConverter.cs new file mode 100644 index 0000000..5e26f34 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/NullVisibilityInvertedConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class NullVisibilityInvertedConverter : MarkupExtension, IValueConverter + { + public NullVisibilityInvertedConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null ? Visibility.Collapsed : Visibility.Visible); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ObjectToStringConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ObjectToStringConverter.cs new file mode 100644 index 0000000..5d36295 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ObjectToStringConverter.cs @@ -0,0 +1,56 @@ +using System; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class ObjectToStringConverter : IValueConverter + { + public readonly static ObjectToStringConverter Instance; + + static ObjectToStringConverter() + { + ObjectToStringConverter.Instance = new ObjectToStringConverter(); + } + + public ObjectToStringConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Enum @enum = value as Enum; + if (@enum == null) + { + if (value is DateTime) + { + return ((DateTime)value).ToShortDateString(); + } + if (value == null) + { + return null; + } + return value.ToString(); + } + MemberInfo[] member = @enum.GetType().GetMember(@enum.ToString()); + if (member.Length == 0) + { + return @enum.ToString(); + } + object[] customAttributes = member[0].GetCustomAttributes(typeof(DescriptionAttribute), false); + if (!customAttributes.Any()) + { + return @enum.ToString().Trim(); + } + return ((DescriptionAttribute)customAttributes.ElementAt(0)).Description.Trim(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ObjectVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ObjectVisibilityConverter.cs new file mode 100644 index 0000000..c17787e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ObjectVisibilityConverter.cs @@ -0,0 +1,31 @@ +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ObjectVisibilityConverter : MarkupExtension, IValueConverter + { + public ObjectVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || (TipoTelefone)value != TipoTelefone.Gratuita && (TipoTelefone)value != TipoTelefone.TarifaUnica ? Visibility.Visible : Visibility.Collapsed); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/PagamentoVendedorCorretoraVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/PagamentoVendedorCorretoraVisibilityConverter.cs new file mode 100644 index 0000000..421b4e7 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/PagamentoVendedorCorretoraVisibilityConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class PagamentoVendedorCorretoraVisibilityConverter : IMultiValueConverter + { + public PagamentoVendedorCorretoraVisibilityConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values[1] is bool && values[0] == null && (bool)values[1]) + { + return Visibility.Collapsed; + } + return Visibility.Visible; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ParcelaVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ParcelaVisibilityConverter.cs new file mode 100644 index 0000000..7bbfdaa --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ParcelaVisibilityConverter.cs @@ -0,0 +1,31 @@ +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ParcelaVisibilityConverter : MarkupExtension, IValueConverter + { + public ParcelaVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || (TipoRecebimento)value != TipoRecebimento.Fatura ? Visibility.Visible : Visibility.Collapsed); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/PendenciaConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/PendenciaConverter.cs new file mode 100644 index 0000000..b2ab4e6 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/PendenciaConverter.cs @@ -0,0 +1,35 @@ +using Gestor.Common.Helpers; +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class PendenciaConverter : MarkupExtension, IValueConverter + { + public PendenciaConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return ""; + } + TimeSpan date = Functions.GetNetworkTime().Date - ((DateTime)value).Date; + return string.Format("{0:N0} DIAS", date.TotalDays); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/PendenciaVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/PendenciaVisibilityConverter.cs new file mode 100644 index 0000000..c05b93f --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/PendenciaVisibilityConverter.cs @@ -0,0 +1,35 @@ +using Gestor.Common.Helpers; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class PendenciaVisibilityConverter : MarkupExtension, IValueConverter + { + public PendenciaVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return ""; + } + return (Functions.GetNetworkTime().Date < (DateTime)value ? Visibility.Collapsed : Visibility.Visible); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/RamoAutoVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/RamoAutoVisibilityConverter.cs new file mode 100644 index 0000000..353da3c --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/RamoAutoVisibilityConverter.cs @@ -0,0 +1,50 @@ +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class RamoAutoVisibilityConverter : MarkupExtension, IValueConverter + { + public RamoAutoVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + bool ramo; + Documento documento = (Documento)value; + if (documento != null) + { + Controle controle = documento.Controle; + if (controle != null) + { + ramo = controle.Ramo; + } + else + { + ramo = false; + } + } + else + { + ramo = false; + } + return (!ramo || ((Documento)value).Controle.Ramo.Id != (long)5 && ((Documento)value).Controle.Ramo.Id != (long)2 ? Visibility.Collapsed : Visibility.Visible); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/RecebidoColorConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/RecebidoColorConverter.cs new file mode 100644 index 0000000..e068a77 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/RecebidoColorConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media; + +namespace Gestor.Common.Converters +{ + public class RecebidoColorConverter : IMultiValueConverter + { + public RecebidoColorConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values[1] != null) + { + return new SolidColorBrush(Colors.Green); + } + if ((DateTime)values[0] >= DateTime.Today) + { + return new SolidColorBrush(Colors.Black); + } + return new SolidColorBrush(Colors.Red); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/SaldoWeightConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/SaldoWeightConverter.cs new file mode 100644 index 0000000..78482d3 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/SaldoWeightConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class SaldoWeightConverter : MarkupExtension, IValueConverter + { + public SaldoWeightConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || (bool)value ? FontWeights.Bold : FontWeights.Regular); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/SinalColorConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/SinalColorConverter.cs new file mode 100644 index 0000000..895a11e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/SinalColorConverter.cs @@ -0,0 +1,35 @@ +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Common.Converters +{ + public class SinalColorConverter : MarkupExtension, IValueConverter + { + public SinalColorConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && (Sinal)value == Sinal.Debito) + { + return new SolidColorBrush(Colors.Red); + } + return new SolidColorBrush(Colors.Black); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusExtratoColorConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusExtratoColorConverter.cs new file mode 100644 index 0000000..d6e2fba --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusExtratoColorConverter.cs @@ -0,0 +1,65 @@ +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Common.Converters +{ + public class StatusExtratoColorConverter : MarkupExtension, IValueConverter + { + public StatusExtratoColorConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return new SolidColorBrush(Colors.Black); + } + switch ((StatusParcela)value) + { + case StatusParcela.Baixada: + case StatusParcela.BaixadaAnteriormente: + case StatusParcela.BaixadaDiferencaPercentual: + case StatusParcela.BaixadaManualmente: + case StatusParcela.ParcelaEspecialBaixadaAnteriormente: + { + return new SolidColorBrush(Colors.Green); + } + case StatusParcela.DocumentoNaoEncontrado: + case StatusParcela.ParcelaNaoEncontrada: + case StatusParcela.DesconsideradaUsuario: + case StatusParcela.ParcelaAnteriorNaoBaixada: + { + return new SolidColorBrush(Colors.Red); + } + case StatusParcela.DesconsideradaSistema: + { + return new SolidColorBrush(Colors.Gray); + } + case StatusParcela.ApoliceDuplicada: + { + return new SolidColorBrush((Color)Application.Current.Resources["AggerYellow100"]); + } + default: + { + return new SolidColorBrush(Colors.Black); + } + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString())); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusParcelaVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusParcelaVisibilityConverter.cs new file mode 100644 index 0000000..41efabb --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusParcelaVisibilityConverter.cs @@ -0,0 +1,42 @@ +using Gestor.Model.Common; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class StatusParcelaVisibilityConverter : MarkupExtension, IValueConverter + { + public StatusParcelaVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return Visibility.Collapsed; + } + return ((new List() + { + StatusParcela.Baixada, + StatusParcela.BaixadaDiferencaPercentual, + StatusParcela.BaixadaManualmente, + StatusParcela.BaixadaCritica + }).Contains((StatusParcela)value) ? Visibility.Visible : Visibility.Collapsed); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusTarefaVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusTarefaVisibilityConverter.cs new file mode 100644 index 0000000..4a6184c --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusTarefaVisibilityConverter.cs @@ -0,0 +1,43 @@ +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class StatusTarefaVisibilityConverter : MarkupExtension, IValueConverter + { + public StatusTarefaVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + bool flag = false; + Visibility visibility; + bool flag1 = (parameter == null ? false : bool.TryParse(parameter.ToString(), out flag)) & flag; + Visibility visibility1 = (value == null || (StatusTarefa)value == StatusTarefa.Realizado ? Visibility.Visible : Visibility.Collapsed); + if (flag1) + { + visibility = (visibility1 == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible); + } + else + { + visibility = visibility1; + } + return visibility; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/StringNullOrEmptyToVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/StringNullOrEmptyToVisibilityConverter.cs new file mode 100644 index 0000000..8903884 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/StringNullOrEmptyToVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class StringNullOrEmptyToVisibilityConverter : MarkupExtension, IValueConverter + { + public StringNullOrEmptyToVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/TarefaBackgroundColorConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/TarefaBackgroundColorConverter.cs new file mode 100644 index 0000000..afe3120 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/TarefaBackgroundColorConverter.cs @@ -0,0 +1,54 @@ +using Gestor.Common.Helpers; +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Common.Converters +{ + public class TarefaBackgroundColorConverter : MarkupExtension, IValueConverter + { + public TarefaBackgroundColorConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && !((DateTime)value < Functions.GetNetworkTime())) + { + return new SolidColorBrush(Colors.Black); + } + return new SolidColorBrush(this.ConvertStringToColor("#fc636b")); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public Color ConvertStringToColor(string hex) + { + hex = hex.Replace("#", ""); + byte num = 255; + byte num1 = 255; + byte num2 = 255; + byte num3 = 255; + int num4 = 0; + if (hex.Length == 8) + { + num = byte.Parse(hex.Substring(0, 2), NumberStyles.HexNumber); + num4 = 2; + } + num1 = byte.Parse(hex.Substring(num4, 2), NumberStyles.HexNumber); + num2 = byte.Parse(hex.Substring(num4 + 2, 2), NumberStyles.HexNumber); + num3 = byte.Parse(hex.Substring(num4 + 4, 2), NumberStyles.HexNumber); + return Color.FromArgb(num, num1, num2, num3); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/TemTarefaVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/TemTarefaVisibilityConverter.cs new file mode 100644 index 0000000..9b565f3 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/TemTarefaVisibilityConverter.cs @@ -0,0 +1,32 @@ +using Gestor.Model.Domain.Ferramentas; +using System; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class TemTarefaVisibilityConverter : MarkupExtension, IValueConverter + { + public TemTarefaVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || ((ObservableCollection)value).Count == 0 ? Visibility.Collapsed : Visibility.Visible); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoCriticaConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoCriticaConverter.cs new file mode 100644 index 0000000..c88e9c7 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoCriticaConverter.cs @@ -0,0 +1,40 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class TipoCriticaConverter : IMultiValueConverter + { + public TipoCriticaConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object obj; + try + { + string str = (string)values[0]; + if (str == "0") + { + obj = (string)values[1]; + } + else + { + obj = (str == "1" ? (string)values[2] : ""); + } + } + catch (Exception exception) + { + obj = ""; + } + return obj; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoSinistroConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoSinistroConverter.cs new file mode 100644 index 0000000..4455982 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoSinistroConverter.cs @@ -0,0 +1,43 @@ +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class TipoSinistroConverter : IMultiValueConverter + { + public TipoSinistroConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object obj = values[0]; + if (obj as TipoSinistro == TipoSinistro.Cliente) + { + return ""; + } + if ((TipoSinistro)obj == TipoSinistro.Cliente) + { + return "CLIENTE"; + } + obj = values[1]; + if (obj == null) + { + return "TERCEIRO"; + } + string str = obj as string; + if (str == null) + { + return ""; + } + return string.Concat("TERCEIRO Nº ", str); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoTelefoneVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoTelefoneVisibilityConverter.cs new file mode 100644 index 0000000..37a212e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/TipoTelefoneVisibilityConverter.cs @@ -0,0 +1,39 @@ +using Gestor.Model.Common; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Gestor.Common.Converters +{ + public class TipoTelefoneVisibilityConverter : IMultiValueConverter + { + public TipoTelefoneVisibilityConverter() + { + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values[0] == null) + { + return Visibility.Collapsed; + } + object obj = values[0]; + if (obj is TipoTelefone && (TipoTelefone)obj != TipoTelefone.Celular) + { + return Visibility.Collapsed; + } + obj = values[1]; + if (obj is bool && (bool)obj) + { + return Visibility.Collapsed; + } + return Visibility.Visible; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/TotalizacaoExpanderConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/TotalizacaoExpanderConverter.cs new file mode 100644 index 0000000..701e944 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/TotalizacaoExpanderConverter.cs @@ -0,0 +1,33 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class TotalizacaoExpanderConverter : MarkupExtension, IValueConverter + { + public TotalizacaoExpanderConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && (bool)value) + { + return "ESCONDER TOTALIZAÇÃO"; + } + return "MOSTRAR TOTALIZAÇÃO"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ValorTipoConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ValorTipoConverter.cs new file mode 100644 index 0000000..1e100a0 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ValorTipoConverter.cs @@ -0,0 +1,47 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ValorTipoConverter : MarkupExtension, IMultiValueConverter + { + public ValorTipoConverter() + { + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + + object System.Windows.Data.IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values == null || values[1] == null || values[0] == DependencyProperty.UnsetValue) + { + return null; + } + if (values[0] == null) + { + return values[1].ToString(); + } + string str = values[0].ToString(); + if (str == "VALOR") + { + return ((decimal)values[1]).ToString("c2"); + } + if (str != "PERCENTUAL") + { + return values[1].ToString(); + } + return ((decimal)values[1]).ToString("p2"); + } + + object[] System.Windows.Data.IMultiValueConverter.ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToEmptyConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToEmptyConverter.cs new file mode 100644 index 0000000..bcedd65 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToEmptyConverter.cs @@ -0,0 +1,41 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ZeroToEmptyConverter : MarkupExtension, IValueConverter + { + public ZeroToEmptyConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return ""; + } + if (value is string) + { + return value; + } + if (Math.Abs(Convert.ToDouble(value)) < 0.01) + { + return ""; + } + return value.ToString(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString())); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityConverter.cs new file mode 100644 index 0000000..6422f0b --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ZeroToVisibilityConverter : MarkupExtension, IValueConverter + { + public ZeroToVisibilityConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || (int)Math.Round(double.Parse(value.ToString())) == 0 ? Visibility.Collapsed : Visibility.Visible); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString())); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityInvertedConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityInvertedConverter.cs new file mode 100644 index 0000000..356332b --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityInvertedConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ZeroToVisibilityInvertedConverter : MarkupExtension, IValueConverter + { + public ZeroToVisibilityInvertedConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || (int)Math.Round(double.Parse(value.ToString())) == 0 ? Visibility.Visible : Visibility.Collapsed); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString())); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityValorConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityValorConverter.cs new file mode 100644 index 0000000..ac8afa4 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityValorConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters +{ + public class ZeroToVisibilityValorConverter : MarkupExtension, IValueConverter + { + public ZeroToVisibilityValorConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + decimal num; + return (value == null || !decimal.TryParse(value.ToString(), out num) && decimal.Parse(value.ToString()) <= decimal.Zero ? Visibility.Collapsed : Visibility.Visible); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString())); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Exceptions/AbortException.cs b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/AbortException.cs new file mode 100644 index 0000000..6fc2511 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/AbortException.cs @@ -0,0 +1,11 @@ +using System; + +namespace Gestor.Common.Exceptions +{ + public class AbortException : Exception + { + public AbortException() : base(string.Empty) + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Exceptions/BaseException.cs b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/BaseException.cs new file mode 100644 index 0000000..6078b23 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/BaseException.cs @@ -0,0 +1,15 @@ +using System; + +namespace Gestor.Common.Exceptions +{ + public class BaseException : Exception + { + public BaseException(string message) : base(message) + { + } + + public BaseException() : base(string.Empty) + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Exceptions/ForbiddenException.cs b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/ForbiddenException.cs new file mode 100644 index 0000000..a608b24 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/ForbiddenException.cs @@ -0,0 +1,15 @@ +using System; + +namespace Gestor.Common.Exceptions +{ + public class ForbiddenException : Exception + { + public ForbiddenException(string message) : base(message) + { + } + + public ForbiddenException() : base(string.Empty) + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Exceptions/MailingException.cs b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/MailingException.cs new file mode 100644 index 0000000..9fd65a5 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/MailingException.cs @@ -0,0 +1,15 @@ +using System; + +namespace Gestor.Common.Exceptions +{ + public class MailingException : BaseException + { + public MailingException(string message) : base(message) + { + } + + public MailingException() : base(string.Empty) + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Exceptions/PermissionException.cs b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/PermissionException.cs new file mode 100644 index 0000000..f80f0dc --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/PermissionException.cs @@ -0,0 +1,15 @@ +using System; + +namespace Gestor.Common.Exceptions +{ + public class PermissionException : Exception + { + public PermissionException() + { + } + + public PermissionException(string message) : base(message) + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Exceptions/UnauthorizedException.cs b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/UnauthorizedException.cs new file mode 100644 index 0000000..7e95254 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/UnauthorizedException.cs @@ -0,0 +1,15 @@ +using System; + +namespace Gestor.Common.Exceptions +{ + public class UnauthorizedException : Exception + { + public UnauthorizedException(string message) : base(message) + { + } + + public UnauthorizedException() : base(string.Empty) + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Exceptions/ValidationException.cs b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/ValidationException.cs new file mode 100644 index 0000000..b2a3bca --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Exceptions/ValidationException.cs @@ -0,0 +1,15 @@ +using System; + +namespace Gestor.Common.Exceptions +{ + public class ValidationException : Exception + { + public ValidationException(string message) : base(message) + { + } + + public ValidationException() : base(string.Empty) + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/DataBaseParameters.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/DataBaseParameters.cs new file mode 100644 index 0000000..03ccc65 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/DataBaseParameters.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.CompilerServices; + +namespace Gestor.Common.Helpers +{ + public static class DataBaseParameters + { + public static bool NovoGestor + { + get; + set; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/DefaultAttribute.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/DefaultAttribute.cs new file mode 100644 index 0000000..b79d623 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/DefaultAttribute.cs @@ -0,0 +1,19 @@ +using System; +using System.Runtime.CompilerServices; + +namespace Gestor.Common.Helpers +{ + public class DefaultAttribute : Attribute + { + public bool DefaultProperty + { + get; + private set; + } + + public DefaultAttribute(bool defaultProperty) + { + this.DefaultProperty = defaultProperty; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/EncryptionHelper.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/EncryptionHelper.cs new file mode 100644 index 0000000..b2102d2 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/EncryptionHelper.cs @@ -0,0 +1,106 @@ +using System; +using System.IO; +using System.Runtime.CompilerServices; +using System.Security.Cryptography; +using System.Text; + +namespace Gestor.Common.Helpers +{ + public static class EncryptionHelper + { + private readonly static byte[] Salt; + + private readonly static string EncryptionKey; + + static EncryptionHelper() + { + EncryptionHelper.Salt = new byte[] { 38, 220, 255, 0, 173, 237, 122, 238, 197, 254, 7, 175, 77, 8, 34, 60 }; + EncryptionHelper.EncryptionKey = string.Format("aGG3r{0}#w3BDz$", 1012); + } + + public static string Decrypt(this string cipher) + { + string str; + if (string.IsNullOrEmpty(cipher)) + { + return null; + } + try + { + byte[] numArray = Convert.FromBase64String(cipher); + if ((int)numArray.Length >= 16) + { + byte[] numArray1 = numArray.DecryptBytes(); + str = (numArray1 == null ? cipher : Encoding.UTF8.GetString(numArray1)); + } + else + { + str = cipher; + } + } + catch (Exception exception) + { + str = cipher; + } + return str; + } + + public static byte[] DecryptBytes(this byte[] plainTextBytes) + { + byte[] array; + try + { + using (Rfc2898DeriveBytes rfc2898DeriveByte = new Rfc2898DeriveBytes(EncryptionHelper.EncryptionKey, EncryptionHelper.Salt)) + { + using (Rijndael bytes = Rijndael.Create()) + { + bytes.Key = rfc2898DeriveByte.GetBytes(32); + bytes.IV = rfc2898DeriveByte.GetBytes(16); + using (MemoryStream memoryStream = new MemoryStream()) + { + using (CryptoStream cryptoStream = new CryptoStream(memoryStream, bytes.CreateDecryptor(), CryptoStreamMode.Write)) + { + cryptoStream.Write(plainTextBytes, 0, (int)plainTextBytes.Length); + cryptoStream.FlushFinalBlock(); + array = memoryStream.ToArray(); + } + } + } + } + } + catch (Exception exception) + { + array = null; + } + return array; + } + + public static string Encrypt(this string plain) + { + return Convert.ToBase64String(Encoding.UTF8.GetBytes(plain).EncryptBytes()); + } + + public static byte[] EncryptBytes(this byte[] plainTextBytes) + { + byte[] array; + using (Rfc2898DeriveBytes rfc2898DeriveByte = new Rfc2898DeriveBytes(EncryptionHelper.EncryptionKey, EncryptionHelper.Salt)) + { + using (Rijndael bytes = Rijndael.Create()) + { + bytes.Key = rfc2898DeriveByte.GetBytes(32); + bytes.IV = rfc2898DeriveByte.GetBytes(16); + using (MemoryStream memoryStream = new MemoryStream()) + { + using (CryptoStream cryptoStream = new CryptoStream(memoryStream, bytes.CreateEncryptor(), CryptoStreamMode.Write)) + { + cryptoStream.Write(plainTextBytes, 0, (int)plainTextBytes.Length); + cryptoStream.FlushFinalBlock(); + array = memoryStream.ToArray(); + } + } + } + } + return array; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/EnumBindingSourceExtension.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/EnumBindingSourceExtension.cs new file mode 100644 index 0000000..7ce699e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/EnumBindingSourceExtension.cs @@ -0,0 +1,59 @@ +using System; +using System.Windows.Markup; + +namespace Gestor.Common.Helpers +{ + public class EnumBindingSourceExtension : MarkupExtension + { + private Type _enumType; + + public Type EnumType + { + get + { + return this._enumType; + } + set + { + if (value == this._enumType) + { + return; + } + if (null != value) + { + if (!(Nullable.GetUnderlyingType(value) ?? value).IsEnum) + { + throw new ArgumentException("Type must be for an Enum."); + } + } + this._enumType = value; + } + } + + public EnumBindingSourceExtension() + { + } + + public EnumBindingSourceExtension(Type enumType) + { + this.EnumType = enumType; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + if (null == this._enumType) + { + throw new InvalidOperationException("The EnumType must be specified."); + } + Type underlyingType = Nullable.GetUnderlyingType(this._enumType) ?? this._enumType; + Array values = Enum.GetValues(underlyingType); + if (underlyingType == this._enumType) + { + return values; + } + Array arrays = Array.CreateInstance(underlyingType, values.Length + 1); + values.CopyTo(arrays, 1); + return arrays; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/EnumHelper.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/EnumHelper.cs new file mode 100644 index 0000000..33529b8 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/EnumHelper.cs @@ -0,0 +1,166 @@ +using Gestor.Model.Attributes; +using System; +using System.ComponentModel; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace Gestor.Common.Helpers +{ + public static class EnumHelper + { + public static T2 GetAttribute(this T enumValue) + where T2 : class + { + T2 customAttribute; + string name = Enum.GetName(enumValue.GetType(), enumValue); + try + { + customAttribute = (T2)(Attribute.GetCustomAttribute(enumValue.GetType().GetField(name), typeof(T2)) as T2); + } + catch (Exception exception) + { + customAttribute = default(T2); + } + return customAttribute; + } + + public static bool? GetDefault(this T enumValue) + { + object customAttribute; + string name = Enum.GetName(enumValue.GetType(), enumValue); + FieldInfo field = enumValue.GetType().GetField(name); + if (field == null) + { + customAttribute = null; + } + else + { + customAttribute = Attribute.GetCustomAttribute(field, typeof(DefaultAttribute)) as DefaultAttribute; + } + if (customAttribute != null) + { + return new bool?(((DefaultAttribute)customAttribute).DefaultProperty); + } + return null; + } + + public static string GetDescription(this T enumValue) + { + object customAttribute; + string name = Enum.GetName(enumValue.GetType(), enumValue); + if (name == null) + { + return null; + } + FieldInfo field = enumValue.GetType().GetField(name); + if (field == null) + { + customAttribute = null; + } + else + { + customAttribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; + } + if (customAttribute != null) + { + return ((DescriptionAttribute)customAttribute).Description; + } + return null; + } + + public static bool GetHidden(this T enumValue) + { + object customAttribute; + string name = Enum.GetName(enumValue.GetType(), enumValue); + FieldInfo field = enumValue.GetType().GetField(name); + if (field == null) + { + customAttribute = null; + } + else + { + customAttribute = Attribute.GetCustomAttribute(field, typeof(HiddenAttribute)) as HiddenAttribute; + } + return customAttribute != null; + } + + public static string GetOldValue(this T enumValue) + { + OldValueAttribute attribute = enumValue.GetAttribute(); + if (attribute != null) + { + return attribute.OldValue; + } + return null; + } + + public static string GetOldValue2(this T enumValue) + { + OldValue2Attribute attribute = enumValue.GetAttribute(); + if (attribute != null) + { + return attribute.OldValue2; + } + return null; + } + + public static int? GetOrder(this T enumValue) + { + object customAttribute; + string name = Enum.GetName(enumValue.GetType(), enumValue); + FieldInfo field = enumValue.GetType().GetField(name); + if (field == null) + { + customAttribute = null; + } + else + { + customAttribute = Attribute.GetCustomAttribute(field, typeof(OrderAttribute)) as OrderAttribute; + } + if (customAttribute != null) + { + return new int?(((OrderAttribute)customAttribute).OrderProperty); + } + return null; + } + + public static T ToEnumByOldValue(this string oldValue) + { + Type type = typeof(T); + Type type1 = typeof(OldValueAttribute); + FieldInfo[] fields = type.GetFields(); + for (int i = 0; i < (int)fields.Length; i++) + { + FieldInfo fieldInfo = fields[i]; + OldValueAttribute customAttribute = Attribute.GetCustomAttribute(fieldInfo, type1) as OldValueAttribute; + if (customAttribute != null && customAttribute.OldValue == oldValue) + { + return (T)fieldInfo.GetValue(null); + } + } + return default(T); + } + + public static T ToEnumByOldValue2(this string oldValue) + { + Type type = typeof(T); + Type type1 = typeof(OldValue2Attribute); + FieldInfo[] fields = type.GetFields(); + for (int i = 0; i < (int)fields.Length; i++) + { + FieldInfo fieldInfo = fields[i]; + OldValue2Attribute customAttribute = Attribute.GetCustomAttribute(fieldInfo, type1) as OldValue2Attribute; + if (customAttribute != null && customAttribute.OldValue2 == oldValue) + { + return (T)fieldInfo.GetValue(null); + } + } + return default(T); + } + + public static string Value(this T enumValue) + { + return Convert.ToInt32(enumValue).ToString(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/FindVisualChild.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/FindVisualChild.cs new file mode 100644 index 0000000..4cabf7c --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/FindVisualChild.cs @@ -0,0 +1,32 @@ +using System; +using System.Windows; +using System.Windows.Media; + +namespace Gestor.Common.Helpers +{ + public class FindVisualChild + { + public FindVisualChild() + { + } + + public static childItem Find(DependencyObject obj) + where childItem : DependencyObject + { + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) + { + DependencyObject child = VisualTreeHelper.GetChild(obj, i); + if (child != null && child is childItem) + { + return (childItem)child; + } + childItem _childItem = FindVisualChild.Find(child); + if (_childItem != null) + { + return _childItem; + } + } + return default(childItem); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs new file mode 100644 index 0000000..9b7f11d --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Windows; +using System.Windows.Media; + +namespace Gestor.Common.Helpers +{ + public class FindVisualChildren + { + public FindVisualChildren() + { + } + + public static IEnumerable Find(DependencyObject depObj) + where T : DependencyObject + { + if (depObj != null) + { + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) + { + DependencyObject dependencyObject = VisualTreeHelper.GetChild(depObj, i); + if (dependencyObject != null && dependencyObject is T) + { + yield return (T)dependencyObject; + } + foreach (T t in FindVisualChildren.Find(dependencyObject)) + { + yield return t; + } + dependencyObject = null; + } + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/Functions.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/Functions.cs new file mode 100644 index 0000000..25ffadf --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/Functions.cs @@ -0,0 +1,110 @@ +using Gestor.Common.Validation; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; + +namespace Gestor.Common.Helpers +{ + public class Functions + { + public static System.Diagnostics.Stopwatch Stopwatch; + + public static DateTime? StartTime; + + public Functions() + { + } + + public static int Compare(string original, string modified) + { + if (original == null) + { + original = ""; + } + if (modified == null) + { + modified = ""; + } + string str = original.ToLongNullable().ToString(); + if (!string.IsNullOrWhiteSpace(str)) + { + original = str; + } + str = modified.ToLongNullable().ToString(); + if (!string.IsNullOrWhiteSpace(str)) + { + modified = str; + } + int length = original.Length; + int num = modified.Length; + int[,] numArray = new int[length + 1, num + 1]; + for (int i = 0; i <= length; i++) + { + numArray[i, 0] = i; + } + for (int j = 0; j <= num; j++) + { + numArray[0, j] = j; + } + for (int k = 1; k <= length; k++) + { + for (int l = 1; l <= num; l++) + { + int num1 = modified[l - 1] != original[k - 1]; + numArray[k, l] = (new int[] { numArray[k - 1, l] + 1, numArray[k, l - 1] + 1, numArray[k - 1, l - 1] + num1 }).Min(); + if (k > 1 && l > 1 && original[k - 1] == modified[l - 2] && original[k - 2] == modified[l - 1]) + { + numArray[k, l] = Math.Min(numArray[k, l], numArray[k - 2, l - 2] + num1); + } + } + } + return numArray[length, num]; + } + + public static DateTime GetNetworkTime() + { + DateTime value; + try + { + if (!Functions.StartTime.HasValue) + { + byte[] numArray = new byte[48]; + numArray[0] = 27; + IPEndPoint pEndPoint = new IPEndPoint(((IEnumerable)Dns.GetHostEntry("time.google.com").AddressList).First((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); + Functions.StartTime = new DateTime?(dateTime.ToLocalTime()); + Functions.Stopwatch = System.Diagnostics.Stopwatch.StartNew(); + value = Functions.StartTime.Value; + } + else + { + value = Functions.StartTime.Value; + value = value.AddMilliseconds((double)Functions.Stopwatch.ElapsedMilliseconds); + } + } + catch (Exception exception) + { + Functions.StartTime = new DateTime?(DateTime.Now); + Functions.Stopwatch = System.Diagnostics.Stopwatch.StartNew(); + value = Functions.StartTime.Value; + } + return value; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/HiddenAttribute.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/HiddenAttribute.cs new file mode 100644 index 0000000..236be6f --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/HiddenAttribute.cs @@ -0,0 +1,12 @@ +using System; + +namespace Gestor.Common.Helpers +{ + [AttributeUsage(AttributeTargets.All)] + public class HiddenAttribute : Attribute + { + public HiddenAttribute() + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/HttpHelper.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/HttpHelper.cs new file mode 100644 index 0000000..26b53e3 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/HttpHelper.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Runtime.CompilerServices; + +namespace Gestor.Common.Helpers +{ + public static class HttpHelper + { + public static HttpRequestMessage CreateRequest(this Uri requestUri, HttpMethod httpMethod, Version httpVersion = null) + { + HttpRequestMessage httpRequestMessage = new HttpRequestMessage(); + httpRequestMessage.set_Version(httpVersion ?? HttpVersion.Version11); + httpRequestMessage.set_RequestUri(requestUri); + httpRequestMessage.set_Method(httpMethod); + return httpRequestMessage; + } + + public static FormUrlEncodedContent Encode(this List> keyValuePairs) + { + return new FormUrlEncodedContent(keyValuePairs); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/OrderAttribute.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/OrderAttribute.cs new file mode 100644 index 0000000..58dba77 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/OrderAttribute.cs @@ -0,0 +1,20 @@ +using System; +using System.Runtime.CompilerServices; + +namespace Gestor.Common.Helpers +{ + [AttributeUsage(AttributeTargets.All)] + public class OrderAttribute : Attribute + { + public int OrderProperty + { + get; + private set; + } + + public OrderAttribute(int orderProperty) + { + this.OrderProperty = orderProperty; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Helpers/ScrollAnimationBehavior.cs b/Codemerx/Gestor.Common/Gestor.Common.Helpers/ScrollAnimationBehavior.cs new file mode 100644 index 0000000..6332e15 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Helpers/ScrollAnimationBehavior.cs @@ -0,0 +1,124 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media.Animation; + +namespace Gestor.Common.Helpers +{ + public static class ScrollAnimationBehavior + { + public static DependencyProperty VerticalOffsetProperty; + + public static DependencyProperty TimeDurationProperty; + + public static DependencyProperty PointsToScrollProperty; + + public static DependencyProperty IsEnabledProperty; + + private static double _currentToValue; + + private static Storyboard _storyboard; + + static ScrollAnimationBehavior() + { + ScrollAnimationBehavior.VerticalOffsetProperty = DependencyProperty.RegisterAttached("VerticalOffset", typeof(double), typeof(ScrollAnimationBehavior), new UIPropertyMetadata((object)0, new PropertyChangedCallback(ScrollAnimationBehavior.OnVerticalOffsetChanged))); + ScrollAnimationBehavior.TimeDurationProperty = DependencyProperty.RegisterAttached("TimeDuration", typeof(TimeSpan), typeof(ScrollAnimationBehavior), new PropertyMetadata((object)(new TimeSpan(0, 0, 0, 0, 0)))); + ScrollAnimationBehavior.PointsToScrollProperty = DependencyProperty.RegisterAttached("PointsToScroll", typeof(double), typeof(ScrollAnimationBehavior), new PropertyMetadata((object)0)); + ScrollAnimationBehavior.IsEnabledProperty = DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(ScrollAnimationBehavior), new UIPropertyMetadata(false, new PropertyChangedCallback(ScrollAnimationBehavior.OnIsEnabledChanged))); + } + + private static void AnimateScroll(ScrollViewer scrollViewer) + { + DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrame = new DoubleAnimationUsingKeyFrames() + { + Duration = new Duration(ScrollAnimationBehavior.GetTimeDuration(scrollViewer)) + }; + doubleAnimationUsingKeyFrame.KeyFrames.Add(new EasingDoubleKeyFrame(scrollViewer.VerticalOffset, KeyTime.FromPercent(0))); + doubleAnimationUsingKeyFrame.KeyFrames.Add(new EasingDoubleKeyFrame(ScrollAnimationBehavior._currentToValue, KeyTime.FromPercent(1), new SineEase() + { + EasingMode = EasingMode.EaseOut + })); + ScrollAnimationBehavior._storyboard = new Storyboard(); + ScrollAnimationBehavior._storyboard.Children.Add(doubleAnimationUsingKeyFrame); + Storyboard.SetTarget(doubleAnimationUsingKeyFrame, scrollViewer); + Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrame, new PropertyPath(ScrollAnimationBehavior.VerticalOffsetProperty)); + ScrollAnimationBehavior._storyboard.Begin(); + } + + public static TimeSpan GetTimeDuration(FrameworkElement target) + { + return (TimeSpan)target.GetValue(ScrollAnimationBehavior.TimeDurationProperty); + } + + private static void OnIsEnabledChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) + { + ScrollViewer scrollViewer = sender as ScrollViewer; + if (scrollViewer != null) + { + scrollViewer.Loaded += new RoutedEventHandler(ScrollAnimationBehavior.ScrollerLoaded); + } + } + + private static void OnVerticalOffsetChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) + { + ScrollViewer scrollViewer = target as ScrollViewer; + if (scrollViewer != null) + { + scrollViewer.ScrollToVerticalOffset((double)e.NewValue); + } + } + + private static void ScrollerLoaded(object sender, RoutedEventArgs e) + { + ScrollAnimationBehavior.SetEventHandlersForScrollViewer(sender as ScrollViewer); + } + + private static void ScrollViewerPreviewMouseWheel(object sender, MouseWheelEventArgs e) + { + double num; + double num1 = ScrollAnimationBehavior._currentToValue; + double delta = (double)e.Delta; + ScrollViewer scrollViewer = (ScrollViewer)sender; + double num2 = delta * 2 / 3; + if (ScrollAnimationBehavior._storyboard == null || ScrollAnimationBehavior._storyboard.GetCurrentState() == ClockState.Filling) + { + ScrollAnimationBehavior._currentToValue = scrollViewer.VerticalOffset; + } + if (num2 > ScrollAnimationBehavior._currentToValue) + { + num = 0; + } + else + { + num = (ScrollAnimationBehavior._currentToValue - num2 > scrollViewer.ScrollableHeight ? scrollViewer.ScrollableHeight : ScrollAnimationBehavior._currentToValue - num2); + } + ScrollAnimationBehavior._currentToValue = num; + if (ScrollAnimationBehavior._currentToValue != scrollViewer.VerticalOffset && ScrollAnimationBehavior._currentToValue != num1) + { + ScrollAnimationBehavior.AnimateScroll(scrollViewer); + } + e.Handled = true; + } + + private static void SetEventHandlersForScrollViewer(ScrollViewer scroller) + { + scroller.PreviewMouseWheel += new MouseWheelEventHandler(ScrollAnimationBehavior.ScrollViewerPreviewMouseWheel); + } + + public static void SetIsEnabled(FrameworkElement target, bool value) + { + target.SetValue(ScrollAnimationBehavior.IsEnabledProperty, value); + } + + public static void SetPointsToScroll(FrameworkElement target, double value) + { + target.SetValue(ScrollAnimationBehavior.PointsToScrollProperty, value); + } + + public static void SetTimeDuration(FrameworkElement target, TimeSpan value) + { + target.SetValue(ScrollAnimationBehavior.TimeDurationProperty, value); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Security/Token.cs b/Codemerx/Gestor.Common/Gestor.Common.Security/Token.cs new file mode 100644 index 0000000..c2d76b1 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Security/Token.cs @@ -0,0 +1,148 @@ +using Gestor.Common.Helpers; +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace Gestor.Common.Security +{ + public class Token + { + private readonly byte[] _key = new byte[] { 45, 103, 73, 146, 210, 184, 220, 224, 94, 3, 114, 60, 211, 119, 21, 100, 18, 201, 230, 195, 119, 252, 73, 208, 209, 39, 222, 48, 47, 142, 94, 24 }; + + private readonly byte[] _initializationVector = new byte[] { 95, 17, 151, 243, 209, 243, 119, 80, 63, 252, 13, 180, 162, 13, 23, 218 }; + + private readonly static byte[] Salt; + + static Token() + { + Token.Salt = new byte[] { 38, 220, 255, 0, 173, 237, 122, 238, 197, 254, 7, 175, 77, 8, 34, 60 }; + } + + public Token() + { + } + + public string AggerDecrypt(string cipher) + { + string str = string.Concat("aGG3r", Convert.ToString(1012), "#w3BDz$"); + byte[] numArray = Convert.FromBase64String(cipher); + Rijndael bytes = Rijndael.Create(); + Rfc2898DeriveBytes rfc2898DeriveByte = new Rfc2898DeriveBytes(str, Token.Salt); + bytes.Key = rfc2898DeriveByte.GetBytes(32); + bytes.IV = rfc2898DeriveByte.GetBytes(16); + MemoryStream memoryStream = new MemoryStream(); + CryptoStream cryptoStream = new CryptoStream(memoryStream, bytes.CreateDecryptor(), CryptoStreamMode.Write); + cryptoStream.Write(numArray, 0, (int)numArray.Length); + cryptoStream.Close(); + byte[] array = memoryStream.ToArray(); + return Encoding.UTF8.GetString(array); + } + + public string AggerEncrypt(string plain) + { + string str = string.Concat("aGG3r", Convert.ToString(1012), "#w3BDz$"); + byte[] bytes = Encoding.UTF8.GetBytes(plain); + Rijndael rijndael = Rijndael.Create(); + Rfc2898DeriveBytes rfc2898DeriveByte = new Rfc2898DeriveBytes(str, Token.Salt); + rijndael.Key = rfc2898DeriveByte.GetBytes(32); + rijndael.IV = rfc2898DeriveByte.GetBytes(16); + MemoryStream memoryStream = new MemoryStream(); + CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndael.CreateEncryptor(), CryptoStreamMode.Write); + cryptoStream.Write(bytes, 0, (int)bytes.Length); + cryptoStream.Close(); + return Convert.ToBase64String(memoryStream.ToArray()); + } + + public string Decrypt(string plainText) + { + string end; + string str; + try + { + byte[] numArray = Convert.FromBase64String(plainText); + using (AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider()) + { + ICryptoTransform cryptoTransform = aesCryptoServiceProvider.CreateDecryptor(this._key, this._initializationVector); + using (MemoryStream memoryStream = new MemoryStream(numArray)) + { + using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Read)) + { + using (StreamReader streamReader = new StreamReader(cryptoStream)) + { + end = streamReader.ReadToEnd(); + } + } + } + } + str = end; + } + catch (Exception exception) + { + str = null; + } + return str; + } + + public bool DefaultDecryption(string ecryptedText) + { + return this.DefaultVerification(this.Decrypt(ecryptedText).Split(new char[] { ':' })); + } + + public string DefaultEncryption(long clientId, long providerId) + { + object obj = providerId; + DateTime universalTime = Functions.GetNetworkTime().ToUniversalTime(); + string str = string.Format("{0}:{1}", obj, universalTime.Ticks); + return this.Encrypt(str); + } + + public bool DefaultVerification(string[] textDecrypted) + { + if ((int)textDecrypted.Length < 2) + { + return false; + } + DateTime dateTime = new DateTime(long.Parse(textDecrypted[1]), DateTimeKind.Utc); + dateTime = dateTime.Date; + DateTime dateTime1 = dateTime.AddHours(5); + dateTime = Functions.GetNetworkTime().ToUniversalTime(); + return dateTime1 >= dateTime.Date; + } + + public string Encrypt(string plainText) + { + byte[] array; + using (AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider()) + { + ICryptoTransform cryptoTransform = aesCryptoServiceProvider.CreateEncryptor(this._key, this._initializationVector); + using (MemoryStream memoryStream = new MemoryStream()) + { + using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write)) + { + using (StreamWriter streamWriter = new StreamWriter(cryptoStream)) + { + streamWriter.Write(plainText); + } + array = memoryStream.ToArray(); + } + } + } + return Convert.ToBase64String(array); + } + + public bool VerifyToken(string authHeader) + { + bool flag; + try + { + flag = (authHeader.Contains("Token") ? this.DefaultDecryption(authHeader.Replace("Token ", "")) : false); + } + catch (Exception exception) + { + flag = false; + } + return flag; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/SemValicao.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/SemValicao.cs new file mode 100644 index 0000000..7c6fde3 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/SemValicao.cs @@ -0,0 +1,18 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class SemValicao : ValidationRule + { + public SemValicao() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + return ValidationResult.ValidResult; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoAno.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoAno.cs new file mode 100644 index 0000000..ccdc82b --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoAno.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoAno : ValidationRule + { + public ValidacaoAno() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateAno()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Ano Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoAnoObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoAnoObrigatorio.cs new file mode 100644 index 0000000..5b6c947 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoAnoObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoAnoObrigatorio : ValidationRule + { + public ValidacaoAnoObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateAno()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Ano Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCeiObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCeiObrigatorio.cs new file mode 100644 index 0000000..c2598d5 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCeiObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoCeiObrigatorio : ValidationRule + { + public ValidacaoCeiObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateCei()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "CEI Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCep.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCep.cs new file mode 100644 index 0000000..1ef2a5e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCep.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoCep : ValidationRule + { + public ValidacaoCep() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidatePostCode()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "CEP Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCepObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCepObrigatorio.cs new file mode 100644 index 0000000..7f801fc --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoCepObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoCepObrigatorio : ValidationRule + { + public ValidacaoCepObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidatePostCode()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "CEP Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoChassi.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoChassi.cs new file mode 100644 index 0000000..5ec78c0 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoChassi.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoChassi : ValidationRule + { + public ValidacaoChassi() + { + } + + public override ValidationResult Validate(object chassiNumber, CultureInfo cultureInfo) + { + object obj = chassiNumber; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || chassiNumber.ToString().ValidateChassi()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Chassi Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoChassiObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoChassiObrigatorio.cs new file mode 100644 index 0000000..a2e81ab --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoChassiObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoChassiObrigatorio : ValidationRule + { + public ValidacaoChassiObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateChassi()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Chassi Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoData.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoData.cs new file mode 100644 index 0000000..98b507a --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoData.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoData : ValidationRule + { + public ValidacaoData() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateDate()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Data Inválida"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataFutura.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataFutura.cs new file mode 100644 index 0000000..4180751 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataFutura.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoDataFutura : ValidationRule + { + public ValidacaoDataFutura() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateFutureDate()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Data Inválida"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataMaior.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataMaior.cs new file mode 100644 index 0000000..4345958 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataMaior.cs @@ -0,0 +1,38 @@ +using System; +using System.Globalization; +using System.Runtime.CompilerServices; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoDataMaior : ValidationRule + { + public DateTime BaseDate + { + get; + set; + } + + public ValidacaoDataMaior() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if ((DateTime)value >= this.BaseDate) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Data Inválida"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataObrigatoria.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataObrigatoria.cs new file mode 100644 index 0000000..6a498dc --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataObrigatoria.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoDataObrigatoria : ValidationRule + { + public ValidacaoDataObrigatoria() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateDate()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Data Inválida"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataPassada.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataPassada.cs new file mode 100644 index 0000000..cb22fb4 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataPassada.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoDataPassada : ValidationRule + { + public ValidacaoDataPassada() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidatePastDate()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Data Inválida"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataPassadaObrigatoria.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataPassadaObrigatoria.cs new file mode 100644 index 0000000..f5fd4c8 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDataPassadaObrigatoria.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoDataPassadaObrigatoria : ValidationRule + { + public ValidacaoDataPassadaObrigatoria() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidatePastDate()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Data Inválida"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDocumento.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDocumento.cs new file mode 100644 index 0000000..2f1a886 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDocumento.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoDocumento : ValidationRule + { + public ValidacaoDocumento() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateDocument()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Documento Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDocumentoObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDocumentoObrigatorio.cs new file mode 100644 index 0000000..787942f --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDocumentoObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoDocumentoObrigatorio : ValidationRule + { + public ValidacaoDocumentoObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateDocument()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Documento Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDouble.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDouble.cs new file mode 100644 index 0000000..ce33724 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoDouble.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoDouble : ValidationRule + { + public ValidacaoDouble() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateDouble()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Valor Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEmail.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEmail.cs new file mode 100644 index 0000000..504fd63 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEmail.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoEmail : ValidationRule + { + public ValidacaoEmail() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateMail()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "E-mail Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEmailObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEmailObrigatorio.cs new file mode 100644 index 0000000..ab1a6ad --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEmailObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoEmailObrigatorio : ValidationRule + { + public ValidacaoEmailObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateMail()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "E-mail Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEstado.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEstado.cs new file mode 100644 index 0000000..de54bc8 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEstado.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoEstado : ValidationRule + { + public ValidacaoEstado() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateState()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Estado Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEstadoObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEstadoObrigatorio.cs new file mode 100644 index 0000000..526327e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoEstadoObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoEstadoObrigatorio : ValidationRule + { + public ValidacaoEstadoObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateState()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Estado Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoFipeObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoFipeObrigatorio.cs new file mode 100644 index 0000000..a3547da --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoFipeObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoFipeObrigatorio : ValidationRule + { + public ValidacaoFipeObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateFipe()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "FIPE Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoInt.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoInt.cs new file mode 100644 index 0000000..551a95e --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoInt.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoInt : ValidationRule + { + public ValidacaoInt() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateInt()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Número Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoIntObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoIntObrigatorio.cs new file mode 100644 index 0000000..c62cf85 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoIntObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoIntObrigatorio : ValidationRule + { + public ValidacaoIntObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateInt()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Número Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoLong.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoLong.cs new file mode 100644 index 0000000..042454d --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoLong.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoLong : ValidationRule + { + public ValidacaoLong() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateLong()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Número Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoLongObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoLongObrigatorio.cs new file mode 100644 index 0000000..fd4773b --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoLongObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoLongObrigatorio : ValidationRule + { + public ValidacaoLongObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateLong()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Número Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoObrigatorio.cs new file mode 100644 index 0000000..23eb517 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoObrigatorio.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoObrigatorio : ValidationRule + { + public ValidacaoObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (!string.IsNullOrWhiteSpace(obj.ToString())) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "OBRIGATÓRIO"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoOrgao.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoOrgao.cs new file mode 100644 index 0000000..d2f3dd1 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoOrgao.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoOrgao : ValidationRule + { + public ValidacaoOrgao() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidateOrgao()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Orgão Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPlaca.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPlaca.cs new file mode 100644 index 0000000..b1825e1 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPlaca.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoPlaca : ValidationRule + { + public ValidacaoPlaca() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidatePlate()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Placa Inválida"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPlacaObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPlacaObrigatorio.cs new file mode 100644 index 0000000..cd56924 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPlacaObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoPlacaObrigatorio : ValidationRule + { + public ValidacaoPlacaObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidatePlate()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Placa Inválida"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPrefixo.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPrefixo.cs new file mode 100644 index 0000000..8b4197b --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPrefixo.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoPrefixo : ValidationRule + { + public ValidacaoPrefixo() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidatePrefix()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "DDD Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPrefixoObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPrefixoObrigatorio.cs new file mode 100644 index 0000000..36f2157 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoPrefixoObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoPrefixoObrigatorio : ValidationRule + { + public ValidacaoPrefixoObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidatePrefix()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "DDD Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoRneObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoRneObrigatorio.cs new file mode 100644 index 0000000..5314ac6 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoRneObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoRneObrigatorio : ValidationRule + { + public ValidacaoRneObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateRne()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "RNE Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoTelefone.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoTelefone.cs new file mode 100644 index 0000000..1723d56 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoTelefone.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoTelefone : ValidationRule + { + public ValidacaoTelefone() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString()) || value.ToString().ValidatePhone()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Telefone Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoTelefoneObrigatorio.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoTelefoneObrigatorio.cs new file mode 100644 index 0000000..37f33c6 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoTelefoneObrigatorio.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoTelefoneObrigatorio : ValidationRule + { + public ValidacaoTelefoneObrigatorio() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidatePhone()) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Telefone Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoValorDiferenteZero.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoValorDiferenteZero.cs new file mode 100644 index 0000000..f7f7aa3 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoValorDiferenteZero.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoValorDiferenteZero : ValidationRule + { + public ValidacaoValorDiferenteZero() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateDouble() && !((decimal)value == decimal.Zero)) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Valor Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoValorMaiorQueZero.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoValorMaiorQueZero.cs new file mode 100644 index 0000000..5ab3a4f --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidacaoValorMaiorQueZero.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Controls; + +namespace Gestor.Common.Validation +{ + public class ValidacaoValorMaiorQueZero : ValidationRule + { + public ValidacaoValorMaiorQueZero() + { + } + + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + object obj = value; + if (obj == null) + { + obj = ""; + } + if (string.IsNullOrWhiteSpace(obj.ToString())) + { + return new ValidationResult(false, "Obrigatório"); + } + if (value.ToString().ValidateDouble() && !((decimal)value < new decimal(1, 0, 0, false, 2))) + { + return ValidationResult.ValidResult; + } + return new ValidationResult(false, "Valor Inválido"); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidationHelper.cs b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidationHelper.cs new file mode 100644 index 0000000..585565c --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Validation/ValidationHelper.cs @@ -0,0 +1,992 @@ +using Gestor.Common.Helpers; +using Gestor.Model.Attributes; +using Gestor.Model.Helper; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; + +namespace Gestor.Common.Validation +{ + public static class ValidationHelper + { + public static void AddSorted(this ObservableCollection list, T item, IComparer comparer = null) + { + if (comparer == null) + { + comparer = Comparer.Default; + } + int num = 0; + while (num < list.Count && comparer.Compare(list[num], item) < 0) + { + num++; + } + list.Insert(num, item); + } + + public static int Age(this DateTime birthDate) + { + DateTime date = Functions.GetNetworkTime().Date; + int year = date.Year - birthDate.Year; + if (birthDate > date.AddYears(-year)) + { + year--; + } + return year; + } + + public static string Alphanumeric(this string stringToClean, string replaceWith = "") + { + return Regex.Replace(stringToClean, "[^a-zA-Z0-9]", replaceWith); + } + + public static string AlphanumericAndSpace(this string stringToClean) + { + return Regex.Replace(stringToClean, "[^a-zA-Z0-9 ]", string.Empty); + } + + public static string Captalize(this string text) + { + return (new CultureInfo("pt-Br", false)).TextInfo.ToTitleCase(text.ToLower()); + } + + public static string Clear(this string stringToClean) + { + if (stringToClean == null) + { + return null; + } + return Regex.Replace(stringToClean, "[^\\d]", string.Empty); + } + + public static string ClearCurrency(this string stringToClean) + { + if (string.IsNullOrEmpty(stringToClean)) + { + return string.Empty; + } + return Regex.Replace(stringToClean, "[^\\d\\,\\.]", string.Empty); + } + + public static bool ContainsAny(this string stringToCheck, params string[] stringArray) + { + return stringArray.Any(new Func(stringToCheck.Contains)); + } + + public static bool ContainsEquals(this T @this, params T[] possibles) + { + return possibles.Contains(@this); + } + + public static string DescriptionAttribute(this PropertyInfo pi) + { + object obj = pi.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(); + if (obj == null) + { + return ""; + } + return ((DescriptionAttribute)obj).Description; + } + + public static string FormatarTelefone(this string number) + { + string str; + int? nullable; + if (number != null) + { + str = number.OnlyNumber(); + } + else + { + str = null; + } + number = str; + if (number != null) + { + nullable = new int?(number.Length); + } + else + { + nullable = null; + } + int? nullable1 = nullable; + if (nullable1.HasValue) + { + switch (nullable1.GetValueOrDefault()) + { + case 8: + { + return Convert.ToUInt64(number).ToString("0000\\-0000"); + } + case 9: + { + return Convert.ToUInt64(number).ToString("00000\\-0000"); + } + case 11: + { + return Convert.ToUInt64(number).ToString("0000 000 0000"); + } + } + } + return number.Clear(); + } + + public static string FormatCi(this string value) + { + long num; + string str = value.OnlyNumber().Trim(); + if (string.IsNullOrEmpty(str)) + { + return string.Empty; + } + if (!long.TryParse(str, out num)) + { + return str; + } + return Convert.ToUInt64(str).ToString("00\\.000\\.000\\.000\\.000"); + } + + public static string FormatCompetencia(this string date) + { + if (string.IsNullOrEmpty(date)) + { + return ""; + } + date = date.OnlyNumber(); + switch (date.Length) + { + case 2: + { + int year = Functions.GetNetworkTime().Date.Year; + date = string.Concat(date, year.ToString()); + return Convert.ToUInt64(date).ToString("00\\/0000"); + } + case 3: + case 5: + { + return date; + } + case 4: + { + return Convert.ToUInt64(date).ToString("00\\/00"); + } + case 6: + { + return Convert.ToUInt64(date).ToString("00\\/0000"); + } + default: + { + return date; + } + } + } + + public static string FormatCurrency(this string value) + { + if (string.IsNullOrEmpty(value)) + { + return ""; + } + return value.ToCurrency("pt-BR").ToString("c"); + } + + public static string FormatDate(this string date) + { + if (string.IsNullOrEmpty(date)) + { + return ""; + } + date = date.OnlyNumber(); + switch (date.Length) + { + case 4: + { + int year = Functions.GetNetworkTime().Date.Year; + date = string.Concat(date, year.ToString()); + return Convert.ToUInt64(date).ToString("00\\/00\\/0000"); + } + case 5: + case 7: + { + return date; + } + case 6: + { + return Convert.ToUInt64(date).ToString("00\\/00\\/00"); + } + case 8: + { + return Convert.ToUInt64(date).ToString("00\\/00\\/0000"); + } + default: + { + return date; + } + } + } + + public static string FormatDocument(this string number) + { + number = number.OnlyNumber(); + int length = number.Length; + if (length == 11) + { + return Convert.ToUInt64(number).ToString("000\\.000\\.000\\-00"); + } + if (length != 14) + { + return number; + } + return Convert.ToUInt64(number).ToString("00\\.000\\.000\\/0000\\-00"); + } + + public static string FormatFipe(this string value) + { + if (string.IsNullOrEmpty(value)) + { + return ""; + } + ulong num = Convert.ToUInt64(value.OnlyNumber()); + return num.ToString("000000\\-0"); + } + + public static string FormatPostCode(this string postCode) + { + if (string.IsNullOrEmpty(postCode)) + { + return ""; + } + return postCode.FormataCep(); + } + + public static string FormatRegiao(this string str) + { + if (Regex.Match(str, "[^0-9-.]").Success) + { + return str; + } + if (string.IsNullOrEmpty(str)) + { + return ""; + } + ulong num = Convert.ToUInt64(str.OnlyNumber()); + return num.ToString("00\\.000\\-000"); + } + + public static string FormatRenavam(this string value) + { + long num; + if (string.IsNullOrEmpty(value)) + { + return string.Empty; + } + if (!long.TryParse(value.OnlyNumber(), out num)) + { + return string.Empty; + } + return num.ToString("00\\.000\\.000\\.000"); + } + + public static string FormatTime(this string time) + { + if (string.IsNullOrEmpty(time)) + { + return null; + } + time = time.OnlyNumber(); + int length = time.Length; + if (length == 3) + { + return Convert.ToUInt64(time).ToString("00:00"); + } + if (length != 4) + { + return null; + } + return Convert.ToUInt64(time).ToString("00:00"); + } + + public static string GetCategory(this Enum genericEnum) + { + MemberInfo[] member = genericEnum.GetType().GetMember(genericEnum.ToString()); + if (member.Length == 0) + { + return genericEnum.ToString(); + } + object[] customAttributes = member[0].GetCustomAttributes(typeof(CategoryAttribute), false); + if (!customAttributes.Any()) + { + return genericEnum.ToString(); + } + return ((CategoryAttribute)customAttributes.ElementAt(0)).Category; + } + + public static string GetDefaultExtension(this string mimeType) + { + object value; + RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(string.Concat("MIME\\Database\\Content Type\\", mimeType), false); + if (registryKey != null) + { + value = registryKey.GetValue("Extension", null); + } + else + { + value = null; + } + object obj = value; + if (obj != null) + { + return obj.ToString(); + } + return string.Join(string.Empty, mimeType.Split(Path.GetInvalidPathChars())).Replace("/", "."); + } + + 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()) + { + return genericEnum.ToString().Trim(); + } + return ((DescriptionAttribute)customAttributes.ElementAt(0)).Description.Trim(); + } + + public static string GetEntity(this Enum genericEnum) + { + MemberInfo[] member = genericEnum.GetType().GetMember(genericEnum.ToString()); + if (member.Length == 0) + { + return genericEnum.ToString(); + } + object[] customAttributes = member[0].GetCustomAttributes(typeof(EntityAttribute), false); + if (!customAttributes.Any()) + { + return genericEnum.ToString(); + } + return ((EntityAttribute)customAttributes.ElementAt(0)).Description; + } + + public static T GetEnumFromDescription(string description) + { + Type type = typeof(T); + if (!type.IsEnum) + { + throw new InvalidOperationException(); + } + FieldInfo[] fields = type.GetFields(); + for (int i = 0; i < (int)fields.Length; i++) + { + FieldInfo fieldInfo = fields[i]; + DescriptionAttribute customAttribute = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute)) as DescriptionAttribute; + if (customAttribute != null) + { + if (customAttribute.Description == description) + { + return (T)fieldInfo.GetValue(null); + } + } + else if (fieldInfo.Name == description) + { + return (T)fieldInfo.GetValue(null); + } + } + throw new ArgumentException("Not found.", "description"); + } + + public static T GetEnumFromEntity(this string entityName) + { + T t; + Type type = typeof(T); + if (!type.IsEnum) + { + t = default(T); + return t; + } + FieldInfo[] fields = type.GetFields(); + for (int i = 0; i < (int)fields.Length; i++) + { + FieldInfo fieldInfo = fields[i]; + EntityAttribute customAttribute = Attribute.GetCustomAttribute(fieldInfo, typeof(EntityAttribute)) as EntityAttribute; + if (customAttribute != null) + { + if (customAttribute.Description == entityName) + { + return (T)fieldInfo.GetValue(null); + } + } + else if (fieldInfo.Name == entityName) + { + return (T)fieldInfo.GetValue(null); + } + } + t = default(T); + return t; + } + + public static string GetHelp(this Enum genericEnum) + { + MemberInfo[] member = genericEnum.GetType().GetMember(genericEnum.ToString()); + if (member.Length == 0) + { + return genericEnum.ToString(); + } + object[] customAttributes = member[0].GetCustomAttributes(typeof(HelpAttribute), false); + if (!customAttributes.Any()) + { + return genericEnum.ToString(); + } + return ((HelpAttribute)customAttributes.ElementAt(0)).Description; + } + + public static string GetTipo(this Enum genericEnum) + { + MemberInfo[] member = genericEnum.GetType().GetMember(genericEnum.ToString()); + if (member.Length == 0) + { + return genericEnum.ToString(); + } + object[] customAttributes = member[0].GetCustomAttributes(typeof(TipoAttribute), false); + if (!customAttributes.Any()) + { + return genericEnum.ToString(); + } + return ((TipoAttribute)customAttributes.ElementAt(0)).Description; + } + + public static bool IsNotNullOrEmpty(this string stringToVerify) + { + return !string.IsNullOrEmpty(stringToVerify); + } + + public static bool IsNullOrEmpty(this string stringToVerify) + { + return string.IsNullOrEmpty(stringToVerify); + } + + public static string Join(this IEnumerable stringValues, string separator) + { + return string.Join(separator, stringValues); + } + + public static string Length(this string stringValue, int maxLength) + { + if (stringValue.Length <= maxLength) + { + return stringValue; + } + return stringValue.Substring(0, maxLength); + } + + public static string Mask(this string value, string mask) + { + int num = mask.Count((char x) => x == '#'); + if (string.IsNullOrEmpty(value) || num != value.Length) + { + return string.Empty; + } + string empty = string.Empty; + int num1 = 0; + int num2 = 0; + for (int i = 0; i < mask.Length; i++) + { + if (mask[i] != '#') + { + empty = string.Concat(empty, string.Format("{0}{1}", value.Substring(num1, i - num1 - num2), mask[i])); + num1 = i - num2; + num2++; + } + } + empty = string.Concat(empty, value.Substring(num1, mask.Length - num1 - num2)); + return empty; + } + + public static string Normalized(this string word) + { + if (string.IsNullOrEmpty(word)) + { + return string.Empty; + } + return Encoding.ASCII.GetString(Encoding.GetEncoding("Cyrillic").GetBytes(word)).ToUpper().Trim(); + } + + public static string NormalizePath(this string fullFilename) + { + int i; + char[] invalidPathChars = Path.GetInvalidPathChars(); + char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); + fullFilename = fullFilename.Replace("/", string.Empty); + string fileName = Path.GetFileName(fullFilename); + string directoryName = Path.GetDirectoryName(fullFilename); + char[] chrArray = invalidPathChars; + for (i = 0; i < (int)chrArray.Length; i++) + { + char chr = chrArray[i]; + directoryName = directoryName.Replace(chr.ToString(), string.Empty); + } + chrArray = invalidFileNameChars; + for (i = 0; i < (int)chrArray.Length; i++) + { + char chr1 = chrArray[i]; + fileName = fileName.Replace(chr1.ToString(), string.Empty); + } + return string.Concat(directoryName, "\\", fileName); + } + + public static bool NotEquals(this string obj, string value) + { + return !obj.Equals(value); + } + + public static string OnlyNumber(this string sentence) + { + if (sentence == null) + { + return null; + } + return (new Regex("[^\\d]")).Replace(sentence, ""); + } + + public static string RemoveDiacritics(this string stringWithAccents) + { + if (stringWithAccents == null) + { + return ""; + } + return Encoding.ASCII.GetString(Encoding.GetEncoding("Cyrillic").GetBytes(stringWithAccents)); + } + + public static string RemoverAcentos(this string text) + { + if (string.IsNullOrEmpty(text)) + { + return string.Empty; + } + return new string(( + from c in text.Normalize(NormalizationForm.FormD) + where char.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark + select c).ToArray()); + } + + public static string RemoveTag(this string stringWithTag) + { + return Regex.Replace(stringWithTag, "<(.|\\n)*?>", string.Empty); + } + + public static string StringValue(this decimal decimalValue) + { + return decimalValue.ToString("F", new CultureInfo("en-US")); + } + + public static string ToCurrency(this T currencyDecimal, string currentCulture = "pt-BR") + { + return string.Format(new CultureInfo(currentCulture), "{0:N2}", currencyDecimal); + } + + public static decimal ToCurrency(this string currencyString, string currentCulture = "pt-BR") + { + decimal num; + decimal.TryParse(currencyString.ClearCurrency(), NumberStyles.Any, new CultureInfo(currentCulture), out num); + return num; + } + + public static string ToCurrencyWithSymbol(this T currencyDecimal, string currentCulture = "pt-BR") + { + return string.Format(new CultureInfo(currentCulture), "R$ {0:N2}", currencyDecimal); + } + + public static DateTime ToDateTime(this string dateString) + { + DateTime dateTime; + DateTime.TryParse(dateString.Trim(), out dateTime); + return dateTime; + } + + public static DateTime? ToDateTimeNullable(this string dateString) + { + DateTime dateTime; + DateTime? nullable; + if (dateString == null) + { + nullable = null; + return nullable; + } + DateTime.TryParse(dateString.Trim(), out dateTime); + if (dateTime != DateTime.MinValue) + { + return new DateTime?(dateTime); + } + nullable = null; + return nullable; + } + + public static string ToFloating(this T currencyDecimal, string currentCulture = "pt-BR") + { + return string.Format(new CultureInfo(currentCulture), "{0:F}", currencyDecimal); + } + + public static int ToInt(this string stringValue) + { + int num; + int.TryParse(stringValue, out num); + return num; + } + + public static int? ToIntNullable(this string stringValue) + { + int num; + if (int.TryParse(stringValue, out num)) + { + return new int?(num); + } + return null; + } + + public static long ToLong(this string stringValue) + { + long num; + long.TryParse(stringValue, out num); + return num; + } + + public static long? ToLongNullable(this string stringValue) + { + long num; + if (long.TryParse(stringValue, out num)) + { + return new long?(num); + } + return null; + } + + public static string ToTitleCase(this string stringValue) + { + return Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(stringValue.ToLower()); + } + + public static string ToToken(this string postCode) + { + return Functions.GetNetworkTime().ToFileTime().ToString(); + } + + public static bool ValidaCep(this string cep) + { + if (!string.IsNullOrWhiteSpace(cep)) + { + return false; + } + return Regex.IsMatch(cep, "^\\d{5}-?\\d{3}$"); + } + + public static bool ValidateAno(this string ano) + { + int num; + if (!int.TryParse(ano, out num)) + { + return false; + } + return ano.Length == 4; + } + + public static bool ValidateAttendanceNumber(this string number) + { + if (number == null) + { + return false; + } + return Regex.Match(number, "^[0-9]").Success; + } + + public static bool ValidateCaepf(this string caepf) + { + return !string.IsNullOrEmpty(caepf); + } + + public static bool ValidateCei(this string cei) + { + if (string.IsNullOrEmpty(cei)) + { + return false; + } + cei = cei.Trim(); + cei = Regex.Replace(cei, "[^\\d]", ""); + if (cei.Length != 12) + { + return false; + } + int num = 0; + for (int i = 1; i < 12; i++) + { + int num1 = Convert.ToInt32("74185216374".Substring(i - 1, 1)); + int num2 = Convert.ToInt32(cei.Substring(i - 1, 1)); + num = num + num1 * num2; + } + int num3 = num / 10; + int num4 = num - num / 10 * 10; + num = num3 + num4; + num4 = num - num / 10 * 10; + int num5 = 10 - num4; + return Convert.ToInt32(cei.Substring(11, 1)) == num5; + } + + public static bool ValidateChassi(this string chassiNumber) + { + string upper; + if (chassiNumber != null) + { + upper = chassiNumber.ToUpper(); + } + else + { + upper = null; + } + chassiNumber = upper; + if (string.IsNullOrEmpty(chassiNumber)) + { + return true; + } + if (chassiNumber.Length != 17 || Regex.IsMatch(chassiNumber, "^0| |^.{4,}([0-9A-Z])\\1{5,}|[iIoOqQ]")) + { + return false; + } + return Regex.IsMatch(chassiNumber, "[0-9]{4}$"); + } + + public static bool ValidateDate(this string birthday) + { + DateTime dateTime; + return DateTime.TryParse(birthday, out dateTime); + } + + public static bool ValidateDecimal(this string value) + { + decimal num; + return decimal.TryParse(value, out num); + } + + public static bool ValidateDocument(this string cpfCnpj) + { + int j; + int i; + int num; + if (string.IsNullOrEmpty(cpfCnpj)) + { + return false; + } + string str = cpfCnpj.Clear(); + int[] numArray = new int[14]; + int[] numArray1 = new int[2]; + if (str == string.Empty || new string(str[0], str.Length) == str) + { + return false; + } + if (str.Length == 11) + { + for (i = 0; i <= 10; i++) + { + numArray[i] = Convert.ToInt32(str.Substring(i, 1)); + } + for (i = 0; i <= 1; i++) + { + num = 0; + for (j = 0; j <= 8 + i; j++) + { + num = num + numArray[j] * (10 + i - j); + } + numArray1[i] = num * 10 % 11; + if (numArray1[i] == 10) + { + numArray1[i] = 0; + } + } + return numArray1[0] == numArray[9] & numArray1[1] == numArray[10]; + } + if (str.Length != 14) + { + return false; + } + for (i = 0; i <= 13; i++) + { + numArray[i] = Convert.ToInt32(str.Substring(i, 1)); + } + for (i = 0; i <= 1; i++) + { + num = 0; + for (j = 0; j <= 11 + i; j++) + { + num = num + numArray[j] * Convert.ToInt32("6543298765432".Substring(j + 1 - i, 1)); + } + numArray1[i] = num * 10 % 11; + if (numArray1[i] == 10) + { + numArray1[i] = 0; + } + } + return numArray1[0] == numArray[12] & numArray1[1] == numArray[13]; + } + + public static bool ValidateDouble(this string number) + { + double num; + return double.TryParse(number, out num); + } + + public static bool ValidateFipe(this string value) + { + if ((new Regex("^\\d{6}\\-\\d{1}$")).IsMatch(value)) + { + return true; + } + return false; + } + + public static bool ValidateFutureDate(this string birthday) + { + DateTime dateTime; + if (!DateTime.TryParse(birthday, out dateTime)) + { + return false; + } + return dateTime > Functions.GetNetworkTime().Date; + } + + public static bool ValidateInt(this string value) + { + int num; + return int.TryParse(value, out num); + } + + public static bool ValidateLong(this string value) + { + long num; + return long.TryParse(value, out num); + } + + public static bool ValidateMail(this string mail) + { + if (mail == null) + { + return false; + } + return (new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$")).IsMatch(mail); + } + + public static bool ValidateOrgao(this string orgao) + { + if (string.IsNullOrEmpty(orgao)) + { + return false; + } + return (new string[] { "SSP", "DETRAN", "ABNC", "CGPI", "DUREX", "DPF", "CGPI", "CGPMAF", "CNIG", "CNT", "COREN", "CORECON", "CRA", "CRAS", "CRB", "CRC", "CRE", "CREA", "CRECI", "CREFIT", "CRESS", "CRF", "CRM", "CRN", "CRO", "CRP", "CRPRE", "CRQ", "CRRC", "CRMV", "CSC", "CTPS", "DIC", "DIREX", "DPMAF", "DPT", "DST", "FGTS", "FIPE", "FLS", "GOVGO", "I CLA", "IFP", "IGP", "IICCECF/RO", "IIMG", "IML", "IPC", "IPF", "MAE", "MEX", "MMA", "OAB", "OMB", "PCMG", "PMMG", "POM", "SDS", "SNJ", "SECC", "SEJUSP", "SES", "EST", "SESP", "SJS", "SJTC", "SJTS", "SPTC", "DGPC", "" }).Contains(orgao.ToUpper()); + } + + public static bool ValidatePastDate(this string birthday) + { + DateTime dateTime; + if (!DateTime.TryParse(birthday, out dateTime)) + { + return false; + } + return dateTime < Functions.GetNetworkTime().Date; + } + + public static bool ValidatePhone(this string number) + { + if (number == null) + { + return false; + } + return Regex.Match(number, "^([2-9][0-9]{3,4})\\-([0-9]{4})$").Success; + } + + public static bool ValidatePlate(this string plateNumber) + { + string str; + if (plateNumber != null) + { + str = plateNumber.Alphanumeric(""); + } + else + { + str = null; + } + if (string.IsNullOrEmpty(str)) + { + return true; + } + return Regex.IsMatch(plateNumber, "^[a-zA-Z]{3}-?[0-9]{4}$"); + } + + public static bool ValidatePostCode(this string postCode) + { + if (postCode == null) + { + return false; + } + return Regex.Match(postCode, "^[0-9]{2}.?[0-9]{3}-[0-9]{3}$").Success; + } + + public static bool ValidatePrefix(this string prefix) + { + int num; + if (!int.TryParse(prefix, out num)) + { + return false; + } + if (num != 20 && num != 23 && num != 25 && num != 26 && num != 29 && num != 30 && num != 36 && num != 39 && num != 40 && num != 50 && num != 52 && num != 56 && num != 57 && num != 58 && num != 59 && num != 60 && num != 70 && num != 72 && num != 76 && num != 78 && num != 80 && num != 90 && num >= 11 && num <= 99) + { + return true; + } + return false; + } + + public static bool ValidateRne(this string rne) + { + if (string.IsNullOrEmpty(rne)) + { + return false; + } + return true; + } + + public static bool ValidateState(this string state) + { + if (string.IsNullOrEmpty(state)) + { + return false; + } + return (new string[] { "AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO" }).Contains(state.ToUpper()); + } + + public static bool ValidateValor(this string value) + { + string[] strArrays = value.Split(new char[] { '.' }); + if ((int)strArrays.Length < 2) + { + return true; + } + if ((int)strArrays.Length != 2) + { + return false; + } + return strArrays[1].Length <= 2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.csproj b/Codemerx/Gestor.Common/Gestor.Common.csproj new file mode 100644 index 0000000..c6a309d --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.csproj @@ -0,0 +1,490 @@ + + + + {AF38021A-3584-40B5-88EF-4742A4C443F5} + Debug + AnyCPU + Gestor.Common + Library + v4.8 + + + bin\Debug\ + true + DEBUG;TRACE + false + 4 + full + prompt + AnyCPU + + + bin\Release\ + false + TRACE + true + 4 + pdbonly + prompt + AnyCPU + + + + + + .\Gestor.CommonReferences\Gestor.Model.dll + + + + + + + + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + + \ No newline at end of file diff --git a/Codemerx/Gestor.Common/Gestor.Common.sln b/Codemerx/Gestor.Common/Gestor.Common.sln new file mode 100644 index 0000000..f22689d --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29728.190 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gestor.Common", "Gestor.Common.csproj", "{AF38021A-3584-40B5-88EF-4742A4C443F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AF38021A-3584-40B5-88EF-4742A4C443F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF38021A-3584-40B5-88EF-4742A4C443F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF38021A-3584-40B5-88EF-4742A4C443F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF38021A-3584-40B5-88EF-4742A4C443F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Codemerx/Gestor.Common/Gestor.CommonReferences/Gestor.Model.dll b/Codemerx/Gestor.Common/Gestor.CommonReferences/Gestor.Model.dll new file mode 100644 index 0000000..2b2b2d0 Binary files /dev/null and b/Codemerx/Gestor.Common/Gestor.CommonReferences/Gestor.Model.dll differ diff --git a/Codemerx/Gestor.Common/Properties/AssemblyInfo.cs b/Codemerx/Gestor.Common/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4107ae2 --- /dev/null +++ b/Codemerx/Gestor.Common/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +[assembly: AssemblyCompany("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyFileVersion("8.4.0.0")] +[assembly: AssemblyProduct("Gestor.Common")] +[assembly: AssemblyTitle("Gestor.Common")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("8.4.0.0")] +[assembly: CompilationRelaxations(8)] +[assembly: ComVisible(false)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: Guid("73d1cb17-a0c5-4e22-884f-171c125d27bc")] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows=true)] -- cgit v1.2.3