using Gestor.Application.Drawers; using Gestor.Application.Helpers; using Gestor.Application.Servicos.Generic; using Gestor.Application.Servicos.Seguros; using Gestor.Application.Servicos.Seguros.Itens; using Gestor.Application.ViewModels.Generic; using Gestor.Application.Views.Ferramentas; using Gestor.Application.Views.Generic; using Gestor.Common.Validation; using Gestor.Model.Common; using Gestor.Model.Domain.Configuracoes; using Gestor.Model.Domain.Ferramentas; using Gestor.Model.Domain.Generic; using Gestor.Model.Domain.MalaDireta; using Gestor.Model.Domain.Seguros; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; namespace Gestor.Application.ViewModels.Seguros { public class SinistroViewModel : BaseSegurosViewModel { private readonly SinistroServico _servico; private readonly ItemServico _itemServico; private readonly Documento _documentoSelecionado; private readonly ClienteServico _clienteServico; private bool _editarObservacao = Recursos.Configuracoes.Any(new Func((ConfiguracaoSistema x) => x.get_Configuracao() == 49)); private bool _isAnotacoes = true; private List _tipoPerdaAuto = new List() { 1, 2, 4, 3, 8 }; private List _tipoPerdaVida = new List() { 5, 6, 7, 8 }; private Credencial _selectedCredencial = new Credencial(); private List _credenciais = new List(); private ObservableCollection _itens = new ObservableCollection(); private ObservableCollection _itensFiltrados = new ObservableCollection(); private ObservableCollection _parceiros = new ObservableCollection(SinistroViewModel.GerarParceiros()); private bool _habilitarImprimirHistorico; private bool _habilitarEnviarHistorico; private Visibility _isVisibleImprimirHistorico; private Visibility _isVisibleIncluir; private Visibility _isVisibleTerceiro = Visibility.Collapsed; private Visibility _visibilityAuto = Visibility.Collapsed; private Visibility _visibilityVida = Visibility.Collapsed; private Visibility _liquidacaoVisibility; private bool _isReadOnlyItem = true; private bool _tipoSinistroEnabled; private Item _selectedItem = new Item(); private bool _mostrarLista; private bool _isExpandedItem = true; private bool _isExpandedSinistro = true; private List _controles = new List(); private ObservableCollection _controlesFiltrados = new ObservableCollection(); private ControleSinistro _selectedControle = new ControleSinistro(); private Sinistro _selectedSinistro; private string _codigoSinistro; private string _anotacoes; private string _anotacoesInternas; private string _telefonesMecanica; private string _telefonesFunileiro; public new string Anotacoes { get { return this._anotacoes; } set { this._anotacoes = value; base.OnPropertyChanged("Anotacoes"); } } public string AnotacoesInternas { get { return this._anotacoesInternas; } set { this._anotacoesInternas = value; base.OnPropertyChanged("AnotacoesInternas"); } } private bool Carregando { get; set; } public string CodigoSinistro { get { return this._codigoSinistro; } set { this._codigoSinistro = value; base.OnPropertyChanged("CodigoSinistro"); } } public List Controles { get { return this._controles; } set { this._controles = value; base.EnableIncluir = (value == null ? true : value.Count == 0); base.OnPropertyChanged("Controles"); } } public ObservableCollection ControlesFiltrados { get { return this._controlesFiltrados; } set { this._controlesFiltrados = value; this.IsExpandedSinistro = (value != null ? value.Count > 0 : false); base.OnPropertyChanged("ControlesFiltrados"); } } public List Credenciais { get { return this._credenciais; } set { this._credenciais = value; base.OnPropertyChanged("Credenciais"); } } public bool EditarObservacao { get { return this._editarObservacao; } set { this._editarObservacao = value; base.OnPropertyChanged("EditarObservacao"); } } public int FiltroItens { get; set; } public bool HabilitarEnviarHistorico { get { return this._habilitarEnviarHistorico; } set { this._habilitarEnviarHistorico = value; base.OnPropertyChanged("HabilitarEnviarHistorico"); } } public bool HabilitarImprimirHistorico { get { return this._habilitarImprimirHistorico; } set { this._habilitarImprimirHistorico = value; base.OnPropertyChanged("HabilitarImprimirHistorico"); } } public bool IsAnotacoes { get { return this._isAnotacoes; } set { this._isAnotacoes = value; base.OnPropertyChanged("IsAnotacoes"); } } public bool IsExpandedItem { get { return this._isExpandedItem; } set { this._isExpandedItem = value; base.OnPropertyChanged("IsExpandedItem"); } } public bool IsExpandedSinistro { get { return this._isExpandedSinistro; } set { this._isExpandedSinistro = value; base.OnPropertyChanged("IsExpandedSinistro"); } } public bool IsReadOnlyItem { get { return this._isReadOnlyItem; } set { this._isReadOnlyItem = value; base.OnPropertyChanged("IsReadOnlyItem"); } } public Visibility IsVisibleImprimirHistorico { get { return this._isVisibleImprimirHistorico; } set { this._isVisibleImprimirHistorico = value; base.OnPropertyChanged("IsVisibleImprimirHistorico"); } } public Visibility IsVisibleIncluir { get { return this._isVisibleIncluir; } set { this._isVisibleIncluir = value; base.OnPropertyChanged("IsVisibleIncluir"); } } public Visibility IsVisibleTerceiro { get { return this._isVisibleTerceiro; } set { this._isVisibleTerceiro = value; base.OnPropertyChanged("IsVisibleTerceiro"); } } public Item ItemSelecionado { get; set; } public ObservableCollection Itens { get { return this._itens; } set { this._itens = value; base.OnPropertyChanged("Itens"); } } public ObservableCollection ItensFiltrados { get { return this._itensFiltrados; } set { this._itensFiltrados = value; this.IsExpandedItem = (value != null ? value.Count > 0 : false); base.OnPropertyChanged("ItensFiltrados"); } } public Visibility LiquidacaoVisibility { get { return this._liquidacaoVisibility; } set { this._liquidacaoVisibility = value; base.OnPropertyChanged("LiquidacaoVisibility"); } } public bool MostrarLista { get { return this._mostrarLista; } set { this._mostrarLista = value; base.OnPropertyChanged("MostrarLista"); } } public ObservableCollection Parceiros { get { return this._parceiros; } set { this._parceiros = value; base.OnPropertyChanged("Parceiros"); } } public ControleSinistro SelectedControle { get { return this._selectedControle; } set { bool count; this._selectedControle = value; if (value != null) { base.EnableButtons = value.get_Id() > (long)0; base.EnableIncluir = value.get_Id() > (long)0; this.IsVisibleTerceiro = (value.get_Sinistros() == null || value.get_Sinistros() != null && value.get_Sinistros().Count < 2 ? Visibility.Collapsed : Visibility.Visible); this.IsVisibleIncluir = (value.get_Sinistros() == null || !value.get_Sinistros().Any() ? Visibility.Visible : Visibility.Collapsed); if (this.MostrarLista) { count = true; } else { List controles = this.Controles; if (controles != null) { count = controles.Count > 1; } else { count = false; } } this.MostrarLista = count; } base.OnPropertyChanged("SelectedControle"); } } public Credencial SelectedCredencial { get { return this._selectedCredencial; } set { this._selectedCredencial = value; base.OnPropertyChanged("SelectedCredencial"); } } public Item SelectedItem { get { return this._selectedItem; } set { long? nullable; this._selectedItem = value; if (value != null) { nullable = new long?(value.get_Id()); } else { nullable = null; } base.VerificarEnables(nullable); base.OnPropertyChanged("SelectedItem"); } } public Sinistro SelectedSinistro { get { return this._selectedSinistro; } set { long? nullable; this._selectedSinistro = value; this.Anotacoes = string.Empty; this.AnotacoesInternas = string.Empty; this.HabilitarImprimirHistorico = value != null; this.HabilitarEnviarHistorico = value != null; this.CodigoSinistro = (this.SelectedSinistro == null || this.SelectedSinistro.get_Id() == 0 ? "" : string.Format("CÓDIGO SINISTRO {0}", this.SelectedSinistro.get_Id())); if (value != null && value.get_Id() != 0 && (this.LastAccessId != value.get_Id() || this.LastAccessTela != 7)) { base.RegistrarAcao(string.Format("ACESSOU SINISTRO DE ID \"{0}\"", value.get_Id()), value.get_Id(), new TipoTela?(7), string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}\nDESCRIÇÃO: \"{5}\"", new object[] { value.get_ControleSinistro().get_Item().get_Id(), value.get_ControleSinistro().get_Item().get_Documento().get_Id(), value.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Ramo().get_Nome(), value.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome(), value.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id(), value.get_Descricao() })); this.LastAccessId = value.get_Id(); this.LastAccessTela = 7; } if (value != null) { nullable = new long?(value.get_Id()); } else { nullable = null; } base.VerificarEnables(nullable); base.OnPropertyChanged("SelectedSinistro"); } } public string TelefonesFunileiro { get { return this._telefonesFunileiro; } set { this._telefonesFunileiro = value; base.OnPropertyChanged("TelefonesFunileiro"); } } public string TelefonesMecanica { get { return this._telefonesMecanica; } set { this._telefonesMecanica = value; base.OnPropertyChanged("TelefonesMecanica"); } } public List TipoPerdaAuto { get { return this._tipoPerdaAuto; } set { this._tipoPerdaAuto = value; base.OnPropertyChanged("TipoPerdaAuto"); } } public List TipoPerdaVida { get { return this._tipoPerdaVida; } set { this._tipoPerdaVida = value; base.OnPropertyChanged("TipoPerdaVida"); } } public bool TipoSinistroEnabled { get { return this._tipoSinistroEnabled; } set { this._tipoSinistroEnabled = value; base.OnPropertyChanged("TipoSinistroEnabled"); } } public Visibility VisibilityAuto { get { return this._visibilityAuto; } set { this._visibilityAuto = value; base.OnPropertyChanged("VisibilityAuto"); } } public Visibility VisibilityVida { get { return this._visibilityVida; } set { this._visibilityVida = value; base.OnPropertyChanged("VisibilityVida"); } } public SinistroViewModel(Item item, bool attached) { bool documento; bool vendedorPrincipal; this._servico = new SinistroServico(); this._itemServico = new ItemServico(); this._clienteServico = new ClienteServico(); this._documentoSelecionado = (attached ? ConsultaViewModel.DocumentoSelecionado : item.get_Documento()); this.FiltroItens = ConsultaViewModel.FiltrarItens; this.ItemSelecionado = ConsultaViewModel.ItemSelecionado; if (!attached) { this.FiltroItens = 4; this.ItemSelecionado = item; } if (item != null) { documento = item.get_Documento(); } else { documento = false; } if (documento) { Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado; if (documentoSelecionado != null) { vendedorPrincipal = documentoSelecionado.get_VendedorPrincipal(); } else { vendedorPrincipal = false; } if (vendedorPrincipal) { item.get_Documento().set_VendedorPrincipal(ConsultaViewModel.DocumentoSelecionado.get_VendedorPrincipal()); } } this.Seleciona(item); } public void AbrirInfo() { base.ShowDrawer(new InfoDrawer(this._documentoSelecionado, false), 0, false); } public async Task BuscarClienteSinistro() { Cliente cliente = await this._itemServico.BuscarCliente(this.SelectedItem.get_Id()); return cliente; } public async void CancelarAlteracao() { // // Current member / type: System.Void Gestor.Application.ViewModels.Seguros.SinistroViewModel::CancelarAlteracao() // File path: C:\AggerSeguros\Gestor.Application.exe // // Product version: 0.0.0.0 // Exception in: System.Void CancelarAlteracao() // // Object reference not set to an instance of an object. // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 515 // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459 // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378 // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331 // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104 // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100 // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72 // at Telerik.JustDecompiler.Decompiler.Extensions.DecompileStateMachine(MethodBody body, DecompilationContext enclosingContext, BaseStateMachineRemoverStep removeStateMachineStep, Func`2 stateMachineDataSelector, DecompilationContext& decompilationContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 112 // at Telerik.JustDecompiler.Decompiler.Extensions.DecompileAsyncStateMachine(MethodBody body, DecompilationContext enclosingContext, AsyncData& asyncData) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 150 // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.GetMoveNextStatements() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 161 // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.Match() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 76 // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 36 // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100 // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72 // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61 // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133 // // mailto: JustDecompilePublicFeedback@telerik.com } private async Task CarregarControles(Item item) { List controleSinistros = await this._servico.BuscarControles(item.get_Id()); SinistroViewModel list = this; List controleSinistros1 = controleSinistros; list.Controles = ( from x in controleSinistros1 orderby x.get_DataSinistro() descending select x).ToList(); this.ControlesFiltrados = new ObservableCollection(this.Controles); } public void CarregarParceiros() { List parceiros = new List(); Parceiro parceiro = new Parceiro(); parceiro.set_Nome("NENHUM"); parceiros.Add(parceiro); List parceiros1 = parceiros; parceiros1.AddRange( from x in Recursos.Parceiros orderby x.get_Nome() select x); this.Parceiros = new ObservableCollection(parceiros1); } public async void EnviarLogEmail() { int? nullable; string nome; string email; int? ordem; List credenciais = this.Credenciais; if (credenciais == null) { credenciais = await (new BaseServico()).BuscarCredenciais(); } this.Credenciais = credenciais; SinistroViewModel sinistroViewModel = this; List credencials = this.Credenciais; Credencial credencial = credencials.FirstOrDefault((Credencial x) => x.get_IdUsuario() == Recursos.Usuario.get_Id()); if (credencial == null) { credencial = this.Credenciais.FirstOrDefault(); } sinistroViewModel.SelectedCredencial = credencial; ObservableCollection observableCollection = await this._clienteServico.BuscarEmailsAsync(this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id()); if (observableCollection.Count != 0) { Documento documento = await (new ApoliceServico()).BuscarApoliceAsync(this._documentoSelecionado.get_Id(), false, false); SinistroViewModel sinistroViewModel1 = this; Vendedor vendedorPrincipal = documento.get_VendedorPrincipal(); if (vendedorPrincipal != null) { nome = vendedorPrincipal.get_Nome(); } else { nome = null; } string str = sinistroViewModel1.GerarHtmlSinistro(nome); string str1 = (new Regex(".*<\\/title>")).Replace(str, " ").Trim(); str1 = (new Regex("(<[^>]*>)|(p\\s?{[^}]*})|(\\r)|(\\n)")).Replace(str1, " ").Trim(); str1 = str1.Replace("@page{ size: A4;} body; -webkit-print-color-adjust: exact; }", " "); str1 = str1.Replace("NEW P { MARGIN-BOTTOM: 0; MARGIN-TOP: 0; }", " "); MalaDireta malaDiretum = new MalaDireta(); malaDiretum.set_Cliente(documento.get_Controle().get_Cliente()); malaDiretum.set_ArquivoDigital(null); malaDiretum.set_Sinistro(this.SelectedSinistro); malaDiretum.set_Item(this.SelectedItem); malaDiretum.set_Apolice(documento); malaDiretum.set_Tela(7); ClienteEmail clienteEmail = observableCollection.FirstOrDefault<ClienteEmail>(); if (clienteEmail != null) { email = clienteEmail.get_Email(); } else { email = null; } malaDiretum.set_Email(email); ClienteEmail clienteEmail1 = observableCollection.FirstOrDefault<ClienteEmail>(); if (clienteEmail1 != null) { ordem = clienteEmail1.get_Ordem(); } else { nullable = null; ordem = nullable; } nullable = ordem; malaDiretum.set_Ordem(nullable.GetValueOrDefault()); MalaDireta malaDiretum1 = malaDiretum; if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL")) { Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL"); } List<MalaDireta> malaDiretas = new List<MalaDireta>() { malaDiretum1 }; (new HosterWindow(new MalaDiretaView(malaDiretas, string.Concat("HISTÓRICO DO SINISTRO DO ITEM ", this.SelectedItem.get_Descricao()), str, null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).ShowDialog(); } else { await base.ShowMessage("O CLIENTE NÃO POSSUI NENHUM E-MAIL CADASTRADO", "OK", "", false); } observableCollection = null; } public async void Excluir() { Sinistro sinistro; int? nullable; bool valueOrDefault; bool flag; Sinistro sinistro1; int num; ControleSinistro controleSinistro; if (this.SelectedSinistro != null && this.SelectedSinistro.get_Id() != 0) { if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false)) { base.Loading(true); string str = string.Format("EXCLUIU SINISTRO DE ID \"{0}\"", this.SelectedSinistro.get_Id()); long id = this.SelectedSinistro.get_Id(); TipoTela? nullable1 = new TipoTela?(7); object[] objArray = new object[] { this.SelectedSinistro.get_ControleSinistro().get_Item().get_Id(), this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Id(), this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id(), this.SelectedSinistro.get_Id() }; base.RegistrarAcao(str, id, nullable1, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}\nDESCRIÇÃO: {5}", objArray)); if (this.SelectedControle.get_Sinistros().Count == 1) { List<ControleSinistro> controles = this.Controles; controles.Remove(this.SelectedControle); SinistroServico sinistroServico = this._servico; ControleSinistro selectedControle = this.SelectedControle; flag = (controles == null ? true : controles.Count == 0); if (await sinistroServico.DeleteControle(selectedControle, flag)) { int num1 = this.ControlesFiltrados.IndexOf(this.SelectedControle); this.Controles.Remove(this.SelectedControle); this.ControlesFiltrados.Remove(this.SelectedControle); this.ControlesFiltrados = new ObservableCollection<ControleSinistro>(this.ControlesFiltrados); if (this.ControlesFiltrados.Count <= 0) { this.SelectedControle = new ControleSinistro(); base.Alterar(false); base.EnableMenu = false; } else { SinistroViewModel sinistroViewModel = this; if (num1 < this.ControlesFiltrados.Count) { ObservableCollection<ControleSinistro> controlesFiltrados = this.ControlesFiltrados; num = (num1 == 0 ? 1 : num1); controleSinistro = controlesFiltrados.ElementAt<ControleSinistro>(num - 1); } else { controleSinistro = this.ControlesFiltrados.Last<ControleSinistro>(); } sinistroViewModel.SelectedControle = controleSinistro; } SinistroViewModel sinistroViewModel1 = this; ControleSinistro selectedControle1 = this.SelectedControle; if (selectedControle1 != null) { List<Sinistro> sinistros = selectedControle1.get_Sinistros(); if (sinistros != null) { sinistro1 = sinistros.FirstOrDefault<Sinistro>(); } else { sinistro1 = null; } } else { sinistro1 = null; } sinistroViewModel1.SelectedSinistro = sinistro1; } else { return; } } else if (await this._servico.Delete(this.SelectedSinistro)) { int num2 = this.SelectedControle.get_Sinistros().IndexOf(this.SelectedSinistro); this.SelectedControle.get_Sinistros().Remove(this.SelectedSinistro); long id1 = this.SelectedControle.get_Id(); this.SelectedControle = null; this.SelectedControle = this.ControlesFiltrados.First<ControleSinistro>((ControleSinistro x) => x.get_Id() == id1); SinistroViewModel sinistroViewModel2 = this; sinistro = (num2 < this.SelectedControle.get_Sinistros().Count ? this.SelectedControle.get_Sinistros().ElementAt<Sinistro>(num2) : this.SelectedControle.get_Sinistros().Last<Sinistro>()); sinistroViewModel2.SelectedSinistro = sinistro; } else { return; } if (this.Controles == null || this.Controles.Count == 0) { ItemServico itemServico = new ItemServico(); Item item = await itemServico.BuscarItemPorIdAsync(this.SelectedItem.get_Id()); item.set_Sinistrado(false); await itemServico.Save(item); itemServico = null; } if (this.ItensFiltrados.Count > 0 && this.ItensFiltrados != null) { Item item1 = this.ItensFiltrados.First<Item>((Item x) => x.get_Id() == this.SelectedItem.get_Id()); ControleSinistro controleSinistro1 = this.SelectedControle; if (controleSinistro1 != null) { List<Sinistro> sinistros1 = controleSinistro1.get_Sinistros(); if (sinistros1 != null) { nullable = new int?(sinistros1.Count); } else { nullable = null; } int? nullable2 = nullable; int num3 = 0; valueOrDefault = nullable2.GetValueOrDefault() > num3 & nullable2.HasValue; } else { valueOrDefault = false; } item1.set_Sinistrado(valueOrDefault); } this.ItensFiltrados = new ObservableCollection<Item>(this.ItensFiltrados); base.Loading(false); base.ToggleSnackBar("SINISTRO EXCLUÍDO COM SUCESSO", true); } } } public List<Item> FiltrarItem(string filter) { this.ItensFiltrados = (string.IsNullOrWhiteSpace(filter) ? this.Itens : new ObservableCollection<Item>( from x in this.Itens where ValidationHelper.RemoveDiacritics(x.get_Descricao().Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) orderby x.get_Ordem() select x)); return this.ItensFiltrados.ToList<Item>(); } public List<ControleSinistro> FiltrarSinistro(string filter) { ControleSinistro controleSinistro; this.ControlesFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<ControleSinistro>(this.Controles) : new ObservableCollection<ControleSinistro>(this.Controles.Where<ControleSinistro>((ControleSinistro x) => { if (ValidationHelper.RemoveDiacritics(x.get_DataSinistro().ToString().Trim()).Contains(filter)) { return true; } if (x.get_Sinistros() == null || x.get_Sinistros().Count <= 0) { return false; } return ValidationHelper.RemoveDiacritics(x.get_Sinistros()[0].get_Numero().Trim()).Contains(filter); }).OrderBy<ControleSinistro, DateTime?>((ControleSinistro x) => x.get_DataSinistro()))); if (this.ControlesFiltrados.Count > 0) { controleSinistro = this.ControlesFiltrados.First<ControleSinistro>(); } else { controleSinistro = null; } this.SelectedControle = controleSinistro; return this.ControlesFiltrados.ToList<ControleSinistro>(); } public string GerarHtmlSinistro(string vendedorPrincipal = "") { DateTime? vigencia2; bool? culpado; string shortDateString; string shortTimeString; string str; string str1; string str2; bool valueOrDefault; string shortDateString1; string str3 = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><meta http-equiv='Content-Language' content='pt-br'><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=yes'><link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'><style type='text/css' media='print'>@page{ size: A4;} body; -webkit-print-color-adjust: exact; }</style><title> HISTÓRICO DO SINISTRO
"; string str4 = ""; foreach (Sinistro sinistro in from x in this.SelectedControle.get_Sinistros() orderby x.get_TipoSinistro() select x) { str3 = string.Concat(str3, "

"); str4 = (string.IsNullOrEmpty(str4) ? "CLIENTE" : string.Concat("TERCEIRO Nº ", sinistro.get_Numero())); str3 = string.Concat(str3, str4, "

"); str3 = string.Concat(str3, "
"); int num = 0; if (str4 == "CLIENTE") { string[] nome = new string[] { str3, ""; str3 = string.Concat(nome); num = 1; string[] documento = new string[] { str3, ""; str3 = string.Concat(documento); num = 0; string[] apolice = new string[] { str3, ""; str3 = string.Concat(apolice); num = 1; string[] strArrays = new string[] { str3, ""; str3 = string.Concat(strArrays); num = 0; vigencia2 = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Vigencia2(); if (vigencia2.GetValueOrDefault().ToString(new CultureInfo("pt-BR")) != "01/01/0001 00:00:00") { vigencia2 = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Vigencia2(); if (vigencia2.HasValue) { shortDateString1 = vigencia2.GetValueOrDefault().ToShortDateString(); } else { shortDateString1 = null; } } else { shortDateString1 = "NÃO POSSUI"; } string str5 = shortDateString1; string[] strArrays1 = new string[] { str3, ""; str3 = string.Concat(strArrays1); num = 1; vendedorPrincipal = (sinistro.get_ControleSinistro().get_Item().get_Documento().get_VendedorPrincipal() == null ? vendedorPrincipal : sinistro.get_ControleSinistro().get_Item().get_Documento().get_VendedorPrincipal().get_Nome()); string[] strArrays2 = new string[] { str3, ""; str3 = string.Concat(strArrays2); num = 0; string[] nome1 = new string[] { str3, ""; str3 = string.Concat(nome1); } num = 1; string[] numero = new string[] { str3, ""; str3 = string.Concat(numero); num = 0; string[] strArrays3 = new string[] { str3, ""; str3 = string.Concat(strArrays3); num = 1; string[] strArrays4 = new string[] { str3, ""; str3 = string.Concat(strArrays4); num = 0; string[] strArrays5 = new string[] { str3, ""; str3 = string.Concat(strArrays5); num = 1; string[] str6 = new string[] { str3, ""; str3 = string.Concat(str6); num = 0; string[] itemSinistrado = new string[] { str3, ""; str3 = string.Concat(itemSinistrado); num = 1; string[] strArrays6 = new string[] { str3, ""; str3 = string.Concat(strArrays6); num = 0; string[] str7 = new string[] { str3, ""; str3 = string.Concat(str7); num = 1; string[] strArrays7 = new string[] { str3, ""; str3 = string.Concat(strArrays7); num = 0; string[] str8 = new string[] { str3, ""; str3 = string.Concat(str8); num = 1; string[] description = new string[] { str3, ""; str3 = string.Concat(description); str3 = string.Concat(str3, "
CLIENTE: "; nome[4] = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome(); nome[5] = "
DOCUMENTO DO SEGURADO: "; documento[4] = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Documento(); documento[5] = "
APÓLICE: "; apolice[4] = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Apolice(); apolice[5] = "
VIGÊNCIA INICIAL: "; DateTime vigencia1 = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Vigencia1(); strArrays[4] = vigencia1.ToShortDateString(); strArrays[5] = "
VIGÊNCIA FINAL: "; strArrays1[4] = str5; strArrays1[5] = "
VENDEDOR PRINCIPAL: "; strArrays2[4] = vendedorPrincipal; strArrays2[5] = "
SEGURADORA: "; nome1[4] = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Seguradora().get_Nome(); nome1[5] = "
NÚMERO SINISTRO: "; numero[4] = sinistro.get_Numero(); numero[5] = "
DATA DO SINISTRO: "; vigencia2 = sinistro.get_ControleSinistro().get_DataSinistro(); if (vigencia2.HasValue) { shortDateString = vigencia2.GetValueOrDefault().ToShortDateString(); } else { shortDateString = null; } strArrays3[4] = shortDateString; strArrays3[5] = "
HORA DO SINISTRO: "; vigencia2 = sinistro.get_ControleSinistro().get_HoraSinistro(); if (vigencia2.HasValue) { shortTimeString = vigencia2.GetValueOrDefault().ToShortTimeString(); } else { shortTimeString = null; } strArrays4[4] = shortTimeString; strArrays4[5] = "
DATA/HORA ABERTURA: "; vigencia2 = sinistro.get_DataReclamacao(); strArrays5[4] = vigencia2.ToString(); strArrays5[5] = "
DATA LIQUIDAÇÃO: "; vigencia2 = sinistro.get_DataLiquidacao(); str6[4] = vigencia2.ToString(); str6[5] = "
DESCRIÇÃO DO BEM SINISTRADO: "; itemSinistrado[4] = sinistro.get_ItemSinistrado(); itemSinistrado[5] = "
VALOR ORÇADO: "; decimal valorOrcado = sinistro.get_ValorOrcado(); strArrays6[4] = valorOrcado.ToString("C", new CultureInfo("pt-BR", false)); strArrays6[5] = "
VALOR LIBERADO: "; valorOrcado = sinistro.get_ValorLiberado(); str7[4] = valorOrcado.ToString("C", new CultureInfo("pt-BR", false)); str7[5] = "
VALOR PAGO: "; valorOrcado = sinistro.get_ValorPago(); strArrays7[4] = valorOrcado.ToString("C", new CultureInfo("pt-BR", false)); strArrays7[5] = "
VALOR FRANQUIA: "; valorOrcado = sinistro.get_ValorFranquia(); str8[4] = valorOrcado.ToString("C", new CultureInfo("pt-BR", false)); str8[5] = "
SITUAÇÃO: "; description[4] = ValidationHelper.GetDescription(sinistro.get_StatusSinistro()); description[5] = "
"); if (sinistro.get_SinistroAuto() != null) { str3 = string.Concat(str3, "
"); num = 0; string[] numeroBo = new string[] { str3, ""; str3 = string.Concat(numeroBo); num = 1; string[] description1 = new string[] { str3, ""; str3 = string.Concat(description1); num = 0; string str9 = str3; str1 = (num % 2 == 0 ? "WhiteSmoke" : "White"); culpado = sinistro.get_SinistroAuto().get_Culpado(); if (string.Concat(""; goto Label0; } Label1: str2 = "NÃO"; Label0: str3 = string.Concat(str9, str2); num = 1; string[] strArrays8 = new string[] { str3, ""; str3 = string.Concat(strArrays8); num = 0; string[] endereco = new string[] { str3, ""; str3 = string.Concat(endereco); num = 1; string[] envolvido = new string[] { str3, ""; str3 = string.Concat(envolvido); num = 0; string[] motorista = new string[] { str3, ""; str3 = string.Concat(motorista); num = 1; string[] ddd = new string[] { str3, ""; str3 = string.Concat(ddd); num = 0; string[] email = new string[] { str3, ""; str3 = string.Concat(email); str3 = string.Concat(str3, "
NÚMERO B.O.: "; numeroBo[4] = sinistro.get_SinistroAuto().get_NumeroBo(); numeroBo[5] = "
TIPO PERDA: "; description1[4] = ValidationHelper.GetDescription(sinistro.get_SinistroAuto().get_TipoPerda()); description1[5] = "
CONSIDERA-SE CULPADO? ", culpado.ToString()) != null) { SinistroAuto sinistroAuto = sinistro.get_SinistroAuto(); if (sinistroAuto != null) { culpado = sinistroAuto.get_Culpado(); bool flag = false; valueOrDefault = culpado.GetValueOrDefault() == flag & culpado.HasValue; } else { valueOrDefault = false; } if (valueOrDefault) { goto Label1; } str2 = "SIM
ÚLTIMO DOC. ENVIADO: "; strArrays8[4] = string.Format("{0:dd/MM/yyyy}", sinistro.get_SinistroAuto().get_UltimoDocEnviado()); strArrays8[5] = "
ENDEREÇO: "; endereco[4] = sinistro.get_SinistroAuto().get_Endereco(); endereco[5] = "
ENVOLVIDO/PROPRIETÁRIO: "; envolvido[4] = sinistro.get_SinistroAuto().get_Envolvido(); envolvido[5] = "
MOTORISTA: "; motorista[4] = sinistro.get_SinistroAuto().get_Motorista(); motorista[5] = "
TELEFONE: ("; ddd[4] = sinistro.get_SinistroAuto().get_Ddd(); ddd[5] = ") "; ddd[6] = sinistro.get_SinistroAuto().get_Telefone(); ddd[7] = "
E-MAIL: "; email[4] = sinistro.get_SinistroAuto().get_Email(); email[5] = "
"); str3 = string.Concat(str3, "
"); num = 1; string str10 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() != null ? sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Nome() : ""); string[] strArrays9 = new string[] { str3, ""; str3 = string.Concat(strArrays9); num = 0; string str11 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd1()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone1()) ? "" : string.Concat("(", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd1(), ") ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone1())); string str12 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd2()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone2()) ? "" : string.Concat(" / (", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd2(), ") ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone2())); string str13 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd3()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone3()) ? "" : string.Concat(" / (", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd3(), ") ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone3())); string[] strArrays10 = new string[] { str3, ""; str3 = string.Concat(strArrays10); num = 1; string str14 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null ? "" : sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Email()); string[] strArrays11 = new string[] { str3, ""; str3 = string.Concat(strArrays11); num = 0; string str15 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Endereco()) ? "" : sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Endereco() ?? ""); string str16 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Numero()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Numero())); string str17 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Complemento()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Complemento())); string str18 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Bairro()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Bairro())); string str19 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Cidade()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Cidade())); string str20 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Uf()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Uf())); string str21 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Cep()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Cep())); string[] strArrays12 = new string[] { str3, ""; str3 = string.Concat(strArrays12); str3 = string.Concat(str3, "
PARCEIRO MECÂNICA: "; strArrays9[4] = str10; strArrays9[5] = "
CONTATOS: "; strArrays10[4] = str11; strArrays10[5] = str12; strArrays10[6] = str13; strArrays10[7] = "
EMAIL: "; strArrays11[4] = str14; strArrays11[5] = "
ENDEREÇO: "; strArrays12[4] = str15; strArrays12[5] = str16; strArrays12[6] = str17; strArrays12[7] = str18; strArrays12[8] = str19; strArrays12[9] = str20; strArrays12[10] = str21; strArrays12[11] = "
"); str3 = string.Concat(str3, "
"); num = 1; str10 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() != null ? sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Nome() : ""); string[] strArrays13 = new string[] { str3, ""; str3 = string.Concat(strArrays13); num = 0; str11 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd1()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone1()) ? "" : string.Concat("(", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd1(), ") ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone1())); str12 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd2()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone2()) ? "" : string.Concat(" / (", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd2(), ") ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone2())); str13 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd3()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone3()) ? "" : string.Concat(" / (", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd3(), ") ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone3())); string[] strArrays14 = new string[] { str3, ""; str3 = string.Concat(strArrays14); num = 1; str14 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null ? "" : sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Email()); string[] strArrays15 = new string[] { str3, ""; str3 = string.Concat(strArrays15); num = 0; str15 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Endereco()) ? "" : sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Endereco() ?? ""); str16 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Numero()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Numero())); str17 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Complemento()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Complemento())); str18 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Bairro()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Bairro())); str19 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Cidade()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Cidade())); str20 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Uf()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Uf())); str21 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Cep()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Cep())); string[] strArrays16 = new string[] { str3, ""; str3 = string.Concat(strArrays16); str3 = string.Concat(str3, "
PARCEIRO FUNILARIA: "; strArrays13[4] = str10; strArrays13[5] = "
CONTATOS: "; strArrays14[4] = str11; strArrays14[5] = str12; strArrays14[6] = str13; strArrays14[7] = "
EMAIL: "; strArrays15[4] = str14; strArrays15[5] = "
ENDEREÇO: "; strArrays16[4] = str15; strArrays16[5] = str16; strArrays16[6] = str17; strArrays16[7] = str18; strArrays16[8] = str19; strArrays16[9] = str20; strArrays16[10] = str21; strArrays16[11] = "
"); } if (sinistro.get_SinistroVida() != null) { str3 = string.Concat(str3, "
"); num = 1; string[] description2 = new string[] { str3, ""; str3 = string.Concat(description2); num = 0; string[] strArrays17 = new string[] { str3, ""; str3 = string.Concat(strArrays17); num = 1; string[] description3 = new string[] { str3, ""; str3 = string.Concat(description3); num = 0; string[] certObito = new string[] { str3, ""; str3 = string.Concat(certObito); num = 1; string[] beneficiario = new string[] { str3, ""; str3 = string.Concat(beneficiario); str3 = string.Concat(str3, "
TIPO PERDA: "; description2[4] = ValidationHelper.GetDescription(sinistro.get_SinistroVida().get_TipoPerda()); description2[5] = "
AUXÍLIO FUNERAL: "; culpado = sinistro.get_SinistroVida().get_AuxFuneral(); if (culpado.HasValue) { culpado = sinistro.get_SinistroVida().get_AuxFuneral(); if (!culpado.Value) { goto Label3; } str = "SIM"; goto Label2; } Label3: str = "NÃO"; Label2: strArrays17[4] = str; strArrays17[5] = "
ESTADO CIVIL: "; description3[4] = ValidationHelper.GetDescription(sinistro.get_SinistroVida().get_EstadoCivil()); description3[5] = "
CERTIDÃO DE ÓBITO: "; certObito[4] = sinistro.get_SinistroVida().get_CertObito(); certObito[5] = "
BENEFICIÁRIO: "; beneficiario[4] = sinistro.get_SinistroVida().get_Beneficiario(); beneficiario[5] = "
"); } if (!string.IsNullOrWhiteSpace(sinistro.get_Descricao())) { str3 = string.Concat(str3, "
"); str3 = string.Concat(str3, "

DESCRIÇÃO

"); str3 = string.Concat(str3, "
"); str3 = string.Concat(str3, "
", sinistro.get_Descricao(), "
"); } if (string.IsNullOrWhiteSpace(sinistro.get_Observacao())) { continue; } str3 = string.Concat(str3, "
"); str3 = string.Concat(str3, "

HISTÓRICO

"); str3 = string.Concat(str3, "
"); str3 = string.Concat(str3, "
", sinistro.get_Observacao().Replace("", "").Replace("", ""), "
"); } str3 = string.Concat(str3, "
"); return str3; } private static List GerarParceiros() { List parceiros = new List(); Parceiro parceiro = new Parceiro(); parceiro.set_Nome("NENHUM"); parceiros.Add(parceiro); parceiros.AddRange( from x in Recursos.Parceiros orderby x.get_Nome() select x); return parceiros; } internal void ImprimirHistorico() { string nome; Vendedor vendedorPrincipal = this._documentoSelecionado.get_VendedorPrincipal(); if (vendedorPrincipal != null) { nome = vendedorPrincipal.get_Nome(); } else { nome = null; } string str = this.GerarHtmlSinistro(nome); string tempPath = Path.GetTempPath(); string str1 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (TipoTela)7, Funcoes.GetNetworkTime()); StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8); streamWriter.Write(str); streamWriter.Close(); Process.Start(str1); } public async void IncluirEnvolvido() { Sinistro sinistro = new Sinistro(); sinistro.set_ControleSinistro(this.SelectedControle); sinistro.set_TipoSinistro(new TipoSinistro?(1)); sinistro.set_Ativo(true); sinistro.set_StatusSinistro(new StatusSinistro?(1)); Sinistro sinistro1 = sinistro; long id = this._documentoSelecionado.get_Controle().get_Ramo().get_Id(); long num = id - (long)5; if (num <= (long)5) { switch ((uint)num) { case 0: { sinistro1.set_SinistroAuto(new SinistroAuto()); if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false)) { sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime())); } else { sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao()); sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao()); if (sinistro1.get_SinistroAuto() != null) { if (this.SelectedSinistro.get_SinistroAuto() == null) { this.SelectedSinistro.set_SinistroAuto(new SinistroAuto()); } sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco()); } } this.IsReadOnlyItem = false; this.SelectedSinistro = sinistro1; base.Alterar(true); sinistro1 = null; return; } case 1: case 2: case 4: case 5: { sinistro1.set_SinistroVida(new SinistroVida()); if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false)) { sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime())); } else { sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao()); sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao()); if (sinistro1.get_SinistroAuto() != null) { if (this.SelectedSinistro.get_SinistroAuto() == null) { this.SelectedSinistro.set_SinistroAuto(new SinistroAuto()); } sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco()); } } this.IsReadOnlyItem = false; this.SelectedSinistro = sinistro1; base.Alterar(true); sinistro1 = null; return; } case 3: { if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false)) { sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime())); } else { sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao()); sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao()); if (sinistro1.get_SinistroAuto() != null) { if (this.SelectedSinistro.get_SinistroAuto() == null) { this.SelectedSinistro.set_SinistroAuto(new SinistroAuto()); } sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco()); } } this.IsReadOnlyItem = false; this.SelectedSinistro = sinistro1; base.Alterar(true); sinistro1 = null; return; } } } else { } if (id != (long)37) { goto Label3; } sinistro1.set_SinistroAuto(new SinistroAuto()); if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false)) { sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime())); } else { sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao()); sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao()); if (sinistro1.get_SinistroAuto() != null) { if (this.SelectedSinistro.get_SinistroAuto() == null) { this.SelectedSinistro.set_SinistroAuto(new SinistroAuto()); } sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco()); } } this.IsReadOnlyItem = false; this.SelectedSinistro = sinistro1; base.Alterar(true); sinistro1 = null; return; sinistro1.set_SinistroVida(new SinistroVida()); if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false)) { sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime())); } else { sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao()); sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao()); if (sinistro1.get_SinistroAuto() != null) { if (this.SelectedSinistro.get_SinistroAuto() == null) { this.SelectedSinistro.set_SinistroAuto(new SinistroAuto()); } sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco()); } } this.IsReadOnlyItem = false; this.SelectedSinistro = sinistro1; base.Alterar(true); sinistro1 = null; return; Label3: if (id != (long)53) { if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false)) { sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime())); } else { sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao()); sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao()); if (sinistro1.get_SinistroAuto() != null) { if (this.SelectedSinistro.get_SinistroAuto() == null) { this.SelectedSinistro.set_SinistroAuto(new SinistroAuto()); } sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco()); } } this.IsReadOnlyItem = false; this.SelectedSinistro = sinistro1; base.Alterar(true); sinistro1 = null; return; } else { sinistro1.set_SinistroVida(new SinistroVida()); if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false)) { sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime())); } else { sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao()); sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao()); if (sinistro1.get_SinistroAuto() != null) { if (this.SelectedSinistro.get_SinistroAuto() == null) { this.SelectedSinistro.set_SinistroAuto(new SinistroAuto()); } sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco()); } } this.IsReadOnlyItem = false; this.SelectedSinistro = sinistro1; base.Alterar(true); sinistro1 = null; return; } if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false)) { sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime())); } else { sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao()); sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao()); if (sinistro1.get_SinistroAuto() != null) { if (this.SelectedSinistro.get_SinistroAuto() == null) { this.SelectedSinistro.set_SinistroAuto(new SinistroAuto()); } sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco()); } } this.IsReadOnlyItem = false; this.SelectedSinistro = sinistro1; base.Alterar(true); sinistro1 = null; } public async Task IncluirSinistro() { Sinistro sinistro; long id; decimal num; ControleSinistro controleSinistro; if (this.SelectedItem != null) { DateTime networkTime = Funcoes.GetNetworkTime(); ControleSinistro controleSinistro1 = new ControleSinistro(); controleSinistro1.set_DataSinistro(new DateTime?(networkTime)); controleSinistro1.set_Item(this.SelectedItem); controleSinistro = controleSinistro1; ObservableCollection observableCollection = await this._itemServico.BuscarCoberturasPorItemAsync(this.SelectedItem.get_Id()); Cobertura cobertura = observableCollection.FirstOrDefault((Cobertura x) => { if (x.get_CoberturaPadrao() == null) { return false; } return x.get_CoberturaPadrao().get_Id() == (long)1; }); Sinistro sinistro1 = new Sinistro(); sinistro1.set_ControleSinistro(controleSinistro); sinistro1.set_TipoSinistro(new TipoSinistro?(0)); sinistro1.set_Ativo(true); sinistro1.set_DataReclamacao(new DateTime?(networkTime)); sinistro1.set_StatusSinistro(new StatusSinistro?(1)); sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao()); num = (cobertura != null ? cobertura.get_Franquia() : decimal.Zero); sinistro1.set_ValorFranquia(num); sinistro = sinistro1; id = this._documentoSelecionado.get_Controle().get_Ramo().get_Id(); long num1 = id - (long)5; if (num1 <= (long)5) { switch ((uint)num1) { case 0: { goto Label0; } case 1: case 2: case 4: case 5: { goto Label1; } case 3: { goto Label2; } } } else { } if (id != (long)37) { goto Label3; } Label0: SinistroAuto sinistroAuto = new SinistroAuto(); sinistroAuto.set_Culpado(new bool?(false)); sinistro.set_SinistroAuto(sinistroAuto); Label2: this.IsReadOnlyItem = true; this.SelectedControle = controleSinistro; this.SelectedSinistro = sinistro; base.Alterar(true); } else { await base.ShowMessage("NECESSÁRIO INCLUIR O ITEM ANTES DE INCLUIR UM SINISTRO.", "OK", "", false); } controleSinistro = null; return; Label1: sinistro.set_SinistroVida(new SinistroVida()); goto Label2; Label3: if (id != (long)53) { goto Label2; } else { goto Label1; } goto Label2; } internal async Task> ItemFiltrar(string value) { List items = await Task.Run>(() => this.FiltrarItem(value)); return items; } public async Task>> Salvar() { List> keyValuePairs; string str; bool id; bool flag; string str1; List> keyValuePairs1 = this.SelectedSinistro.Validate(); if (keyValuePairs1.Count <= 0) { Sinistro selectedSinistro = this.SelectedSinistro; if (selectedSinistro.get_SinistroAuto() != null) { Parceiro parceiroFunilaria = selectedSinistro.get_SinistroAuto().get_ParceiroFunilaria(); if (parceiroFunilaria != null) { id = parceiroFunilaria.get_Id() == (long)0; } else { id = false; } if (id) { selectedSinistro.get_SinistroAuto().set_ParceiroFunilaria(null); } Parceiro parceiroMecanica = selectedSinistro.get_SinistroAuto().get_ParceiroMecanica(); if (parceiroMecanica != null) { flag = parceiroMecanica.get_Id() == (long)0; } else { flag = false; } if (flag) { selectedSinistro.get_SinistroAuto().set_ParceiroMecanica(null); } } DateTime networkTime = Funcoes.GetNetworkTime(); if (!string.IsNullOrWhiteSpace(this.Anotacoes) && !this.Anotacoes.IsEmpty()) { Sinistro sinistro = selectedSinistro; object[] nome = new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), networkTime, this.Anotacoes, selectedSinistro.get_Observacao() }; sinistro.set_Observacao(string.Format("

{0}, ID: {1}, {2:g}
{3}



{4}", nome)); } if (!string.IsNullOrWhiteSpace(this.AnotacoesInternas) && !this.AnotacoesInternas.IsEmpty()) { Sinistro sinistro1 = selectedSinistro; object[] objArray = new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), networkTime, this.AnotacoesInternas, selectedSinistro.get_ObservacaoInterna() }; sinistro1.set_ObservacaoInterna(string.Format("

{0}, ID: {1}, {2:g}
{3}



{4}", objArray)); } if (selectedSinistro.get_Id() != 0) { selectedSinistro.set_DataAlteracao(new DateTime?(DateTime.Now)); selectedSinistro.set_IdUsuarioAlteracao(Recursos.Usuario.get_Id()); } else { selectedSinistro.set_DataCriacao(new DateTime?(DateTime.Now)); selectedSinistro.set_IdUsuarioCriacao(Recursos.Usuario.get_Id()); } str = (selectedSinistro.get_Id() == 0 ? "INCLUIU" : "ALTEROU"); str1 = str; Sinistro sinistro2 = await this._servico.Save(selectedSinistro, this._documentoSelecionado.get_Controle().get_Ramo().get_Id()); selectedSinistro = sinistro2; if (this._servico.Sucesso) { await this.CarregarControles(selectedSinistro.get_ControleSinistro().get_Item()); this.SelectedControle = this.ControlesFiltrados.First((ControleSinistro x) => x.get_Id() == selectedSinistro.get_ControleSinistro().get_Id()); this.SelectedSinistro = this.SelectedControle.get_Sinistros().First((Sinistro x) => x.get_Id() == selectedSinistro.get_Id()); Recursos.Parceiros = this.Parceiros.ToList(); base.Alterar(false); base.ToggleSnackBar("SINISTRO SALVO COM SUCESSO", true); string str2 = string.Format("{0} SINISTRO DE ID \"{1}\"", str1, selectedSinistro.get_Id()); long num = selectedSinistro.get_Id(); TipoTela? nullable = new TipoTela?(7); object[] id1 = new object[] { selectedSinistro.get_ControleSinistro().get_Item().get_Id(), selectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Id(), selectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Ramo().get_Nome(), selectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome(), selectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id(), selectedSinistro.get_Descricao() }; base.RegistrarAcao(str2, num, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}\nDESCRIÇÃO: \"{5}\"", id1)); keyValuePairs = null; } else { keyValuePairs = null; } } else { keyValuePairs = keyValuePairs1; } str1 = null; return keyValuePairs; } public async void Seleciona(Item item) { Visibility visibility; Visibility visibility1; base.Loading(true); await base.PermissaoTela(7); this.SelectedItem = this.ItemSelecionado; SinistroViewModel sinistroViewModel = this; visibility = (this._documentoSelecionado.get_Controle().get_Ramo().get_Id() == (long)5 ? Visibility.Visible : Visibility.Collapsed); sinistroViewModel.VisibilityAuto = visibility; SinistroViewModel sinistroViewModel1 = this; visibility1 = (this._documentoSelecionado.get_Controle().get_Ramo().get_Id() == (long)6 ? Visibility.Visible : Visibility.Collapsed); sinistroViewModel1.VisibilityVida = visibility1; if (item != null) { await this.SelecionaControles(item); base.Loading(false); } else { base.Loading(false); } } public void SelecionaControle(ControleSinistro controle) { List list; bool sinistros; if (this.Carregando) { return; } this.SelectedControle = controle; ControleSinistro selectedControle = this.SelectedControle; ControleSinistro controleSinistro = this.SelectedControle; if (controleSinistro != null) { List sinistros1 = controleSinistro.get_Sinistros(); if (sinistros1 != null) { list = ( from x in sinistros1 orderby x.get_Id() select x).ToList(); } else { list = null; } } else { list = null; } selectedControle.set_Sinistros(list); if (this.Carregando) { return; } if (controle.get_Id() != this.SelectedControle.get_Id()) { this.SelectedControle = controle; } ControleSinistro selectedControle1 = this.SelectedControle; if (selectedControle1 != null) { sinistros = selectedControle1.get_Sinistros(); } else { sinistros = false; } if (sinistros) { this.TipoSinistroEnabled = (!this.SelectedControle.get_Sinistros().Any((Sinistro x) => { TipoSinistro? tipoSinistro = x.get_TipoSinistro(); return tipoSinistro.GetValueOrDefault() == 0 & tipoSinistro.HasValue; }) ? true : this.SelectedControle.get_Sinistros().Count <= 1); } } public async Task SelecionaControles(Item item) { Sinistro sinistro; base.Loading(true); await this.CarregarControles(item); if (this.ControlesFiltrados.Count <= 0) { this.SelectedControle = new ControleSinistro(); base.Alterar(false); } else { this.SelectedControle = this.ControlesFiltrados.FirstOrDefault(); } SinistroViewModel sinistroViewModel = this; ControleSinistro selectedControle = this.SelectedControle; if (selectedControle != null) { List sinistros = selectedControle.get_Sinistros(); if (sinistros != null) { sinistro = sinistros.FirstOrDefault(); } else { sinistro = null; } } else { sinistro = null; } sinistroViewModel.SelectedSinistro = sinistro; base.Loading(false); } public async void SelecionaItem(Item item) { if (!this.Carregando) { this.SelectedItem = item; if (this.SelectedItem != null) { if (!this.Carregando) { if (item.get_Id() != this.SelectedItem.get_Id()) { this.SelectedItem = this.ItensFiltrados.FirstOrDefault((Item x) => x.get_Id() == item.get_Id()); } await this.SelecionaControles(item); } } } } public async Task SelecionaItens(int type, Item item = null) { bool count; Item item1; base.Loading(true); this.Carregando = true; switch (type) { case 1: case 2: { this.Itens = await this._itemServico.BuscarItens(this._documentoSelecionado.get_Id(), 2); break; } case 3: { this.Itens = await this._itemServico.BuscarItens(this._documentoSelecionado.get_Controle().get_Id(), 1); break; } case 4: { this.Itens = await this._itemServico.BuscarItens(this._documentoSelecionado.get_Controle().get_Id(), 3); break; } default: { this.Itens = await this._itemServico.BuscarItens(this._documentoSelecionado.get_Controle().get_Id(), 0); break; } } this.ItensFiltrados = this.Itens; if (item != null && item.get_Id() > (long)0) { SinistroViewModel sinistroViewModel = this; if (this.ItensFiltrados == null || this.ItensFiltrados.Count <= 0) { item1 = null; } else { item1 = this.ItensFiltrados.FirstOrDefault((Item x) => x.get_Id() == item.get_Id()); } sinistroViewModel.SelectedItem = item1; } SinistroViewModel sinistroViewModel1 = this; if (this.MostrarLista) { count = true; } else { ObservableCollection itens = this.Itens; if (itens != null) { count = itens.Count > 1; } else { count = false; } } sinistroViewModel1.MostrarLista = count; this.Carregando = false; base.Loading(false); } internal async Task> SinistroFiltrar(string value) { List controleSinistros = await Task.Run>(() => this.FiltrarSinistro(value)); return controleSinistros; } } }