diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/Servicos/TarefaServico.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/Servicos/TarefaServico.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/Servicos/TarefaServico.cs | 795 |
1 files changed, 795 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Servicos/TarefaServico.cs b/Codemerx/Gestor.Application/Servicos/TarefaServico.cs new file mode 100644 index 0000000..792aea6 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/TarefaServico.cs @@ -0,0 +1,795 @@ +using Gestor.Application.Actions;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Threading;
+
+namespace Gestor.Application.Servicos
+{
+ public class TarefaServico : BaseServico
+ {
+ public TarefaServico()
+ {
+ }
+
+ public async Task<int[]> AtualizarNotasTarefas()
+ {
+ int num = 3;
+ int[] numArray1 = await Task.Run<int[]>(() => {
+ int[] numArray;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ numArray = read.get_TarefaRepository().ContarTarefas(Recursos.Usuario.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 100, num, Recursos.Usuario.get_Id(), true);
+ continue;
+ }
+ return numArray;
+ }
+ return new int[1];
+ });
+ return numArray1;
+ }
+
+ public async Task<List<Fase>> BuscarFases(long id)
+ {
+ int num = 3;
+ List<Fase> fases1 = await Task.Run<List<Fase>>(() => {
+ List<Fase> fases;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ fases = read.get_TarefaRepository().BuscarFases(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 102, num, id, true);
+ continue;
+ }
+ return fases;
+ }
+ return new List<Fase>();
+ });
+ return fases1;
+ }
+
+ public async Task<List<Tarefa>> BuscarNotas(long id)
+ {
+ int num = 3;
+ List<Tarefa> tarefas1 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefaPorUsuario(id, 1);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 98, num, id, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarNotasConcluidas(long id)
+ {
+ int num = 3;
+ List<Tarefa> tarefas1 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefaConcluidaPorUsuario(id, 1);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 99, num, id, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<Tarefa> BuscarTarefa(long id)
+ {
+ int num = 3;
+ Tarefa tarefa1 = await Task.Run<Tarefa>(() => {
+ Tarefa tarefa;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefa = read.get_TarefaRepository().BuscarTarefa(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 105, num, id, true);
+ continue;
+ }
+ return tarefa;
+ }
+ return new Tarefa();
+ });
+ return tarefa1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefas(TipoTarefa entidade, long id, bool? concluido)
+ {
+ int num = 3;
+ List<Tarefa> tarefas1 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefa(entidade, id, concluido);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 94, num, new { entidade = entidade, id = id, concluido = concluido }, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefas(long id, DateTime inicio, DateTime fim, bool? concluido)
+ {
+ int num = 3;
+ List<Tarefa> tarefas1 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefaPorUsuario(id, inicio, fim, concluido);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 95, num, new { id = id, inicio = inicio, fim = fim, concluido = concluido }, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefas(long id)
+ {
+ int num = 3;
+ List<Tarefa> tarefas1 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefaPorTrilha(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 101, num, id, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefasCliente(long id)
+ {
+ int num = 3;
+ List<Tarefa> tarefas1 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefaPorCliente(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 96, num, id, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefasPorTipo(TipoDeTarefa tipoTarefa)
+ {
+ int num = 3;
+ List<Tarefa> tarefas1 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefasPorTipo(tipoTarefa.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 309, num, new { tipoTarefa = tipoTarefa }, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Trilha>> BuscarTrilhas()
+ {
+ int num = 3;
+ List<Trilha> trilhas1 = await Task.Run<List<Trilha>>(() => {
+ List<Trilha> trilhas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ trilhas = read.get_TarefaRepository().BuscarTrilhas(true);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 104, num, null, true);
+ continue;
+ }
+ return trilhas;
+ }
+ return new List<Trilha>();
+ });
+ return trilhas1;
+ }
+
+ private static void CleanWebEditor(Tarefa tarefa)
+ {
+ if (tarefa.get_Descricao() != null)
+ {
+ tarefa.set_Descricao(TarefaServico.RemoveXml(tarefa.get_Descricao()));
+ }
+ if (tarefa.get_DescricaoInterna() != null)
+ {
+ tarefa.set_DescricaoInterna(TarefaServico.RemoveXml(tarefa.get_DescricaoInterna()));
+ }
+ }
+
+ public async Task<bool> Excluir(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_TarefaRepository().Excluir(id);
+ commited.Commit();
+ }
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_51 = TarefaServico.u003cu003ec.u003cu003e9__5_1;
+ if (u003cu003e9_51 == null)
+ {
+ u003cu003e9_51 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51;
+ }
+ dispatcher.Invoke(u003cu003e9_51);
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 268, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> ExcluirTarefasDocumento(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ List<Tarefa> tarefas = new List<Tarefa>();
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefa(0, id, new bool?(false));
+ }
+ foreach (Tarefa tarefa in tarefas)
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_TarefaRepository().Excluir(tarefa.get_Id());
+ commited.Commit();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(DateTime.Now);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa, jsonSerializerSetting));
+ registroLog.set_EntidadeId(tarefa.get_Id());
+ registroLog.set_Tela(4);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_192 = TarefaServico.u003cu003ec.u003cu003e9__19_2;
+ if (u003cu003e9_192 == null)
+ {
+ u003cu003e9_192 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__19_2 = u003cu003e9_192;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_192);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ }
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_191 = TarefaServico.u003cu003ec.u003cu003e9__19_1;
+ if (u003cu003e9_191 == null)
+ {
+ u003cu003e9_191 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__19_1 = u003cu003e9_191;
+ }
+ dispatcher.Invoke(u003cu003e9_191);
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 268, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public static string RemoveXml(string description)
+ {
+ try
+ {
+ List<string> strs = new List<string>();
+ string[] strArrays = description.Split(new char[] { '<' });
+ for (int i = 0; i < (int)strArrays.Length; i++)
+ {
+ string str = strArrays[i];
+ if (str.Contains("?xml") || str.Contains("o:p"))
+ {
+ strs.Add(string.Concat("<", str));
+ }
+ }
+ foreach (string str1 in strs)
+ {
+ description = description.Replace(str1, "");
+ }
+ }
+ catch (Exception exception)
+ {
+ throw exception;
+ }
+ return description;
+ }
+
+ public async Task<Tarefa> Salvar(Tarefa tarefa)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Tarefa tarefa2 = tarefa;
+ Tarefa tarefa3 = await Task.Run<Tarefa>(() => {
+ Tarefa tarefa4;
+ string str;
+ while (num > 0)
+ {
+ tarefa = tarefa2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TarefaServico.CleanWebEditor(tarefa);
+ if (tarefa.get_Entidade() == 1)
+ {
+ tarefa.set_Descricao((!string.IsNullOrWhiteSpace(tarefa.get_Anotacoes()) ? tarefa.get_Anotacoes() : tarefa.get_Descricao()));
+ }
+ tarefa = (tarefa.get_Id() == (long)0 ? commited.get_TarefaRepository().Salvar(tarefa) : commited.get_TarefaRepository().Atualizar(tarefa));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Tarefa tarefa1 = tarefa;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(tarefa.get_Id());
+ registroLog.set_Tela(38);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_12 = TarefaServico.u003cu003ec.u003cu003e9__1_2;
+ if (u003cu003e9_12 == null)
+ {
+ u003cu003e9_12 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__1_2 = u003cu003e9_12;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_12);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_11 = TarefaServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ dispatcher.Invoke(u003cu003e9_11);
+ tarefa4 = tarefa;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 265, num, tarefa, true);
+ continue;
+ }
+ return tarefa4;
+ }
+ return tarefa2;
+ });
+ return tarefa3;
+ }
+
+ public async Task<Trilha> Salvar(Trilha trilha)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Trilha trilha2 = trilha;
+ Trilha trilha3 = await Task.Run<Trilha>(() => {
+ Trilha trilha4;
+ string str;
+ while (num > 0)
+ {
+ trilha = trilha2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ trilha = (trilha.get_Id() == (long)0 ? commited.get_TarefaRepository().Salvar(trilha) : commited.get_TarefaRepository().Atualizar(trilha));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Trilha trilha1 = trilha;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(trilha1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(trilha.get_Id());
+ registroLog.set_Tela(4);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_42 = TarefaServico.u003cu003ec.u003cu003e9__4_2;
+ if (u003cu003e9_42 == null)
+ {
+ u003cu003e9_42 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__4_2 = u003cu003e9_42;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_42);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_41 = TarefaServico.u003cu003ec.u003cu003e9__4_1;
+ if (u003cu003e9_41 == null)
+ {
+ u003cu003e9_41 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
+ }
+ dispatcher.Invoke(u003cu003e9_41);
+ trilha4 = trilha;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 267, num, trilha, true);
+ continue;
+ }
+ return trilha4;
+ }
+ return trilha2;
+ });
+ return trilha3;
+ }
+
+ public async Task<List<Fase>> Salvar(List<Fase> fases)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<Fase> fases1 = fases;
+ List<Fase> fases2 = await Task.Run<List<Fase>>(() => {
+ List<Fase> fases3;
+ string str;
+ while (num > 0)
+ {
+ fases = fases1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ fases = commited.get_TarefaRepository().Salvar(fases);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (Fase fase in fases)
+ {
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(fase, jsonSerializerSetting));
+ registroLog.set_EntidadeId(fase.get_Id());
+ registroLog.set_Tela(4);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_142 = TarefaServico.u003cu003ec.u003cu003e9__14_2;
+ if (u003cu003e9_142 == null)
+ {
+ u003cu003e9_142 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__14_2 = u003cu003e9_142;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_142);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_141 = TarefaServico.u003cu003ec.u003cu003e9__14_1;
+ if (u003cu003e9_141 == null)
+ {
+ u003cu003e9_141 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141;
+ }
+ dispatcher.Invoke(u003cu003e9_141);
+ fases3 = fases;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 269, num, fases, true);
+ continue;
+ }
+ return fases3;
+ }
+ return fases1;
+ });
+ return fases2;
+ }
+
+ public async Task<List<Tarefa>> Salvar(List<Tarefa> tarefas)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<Tarefa> tarefas1 = tarefas;
+ List<Tarefa> tarefas2 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas3;
+ string str;
+ while (num > 0)
+ {
+ tarefas = tarefas1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ tarefas = commited.get_TarefaRepository().Salvar(tarefas);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (Tarefa tarefa in tarefas)
+ {
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa, jsonSerializerSetting));
+ registroLog.set_EntidadeId(tarefa.get_Id());
+ registroLog.set_Tela(4);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_152 = TarefaServico.u003cu003ec.u003cu003e9__15_2;
+ if (u003cu003e9_152 == null)
+ {
+ u003cu003e9_152 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__15_2 = u003cu003e9_152;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_152);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_151 = TarefaServico.u003cu003ec.u003cu003e9__15_1;
+ if (u003cu003e9_151 == null)
+ {
+ u003cu003e9_151 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__15_1 = u003cu003e9_151;
+ }
+ dispatcher.Invoke(u003cu003e9_151);
+ tarefas3 = tarefas;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 265, num, tarefas, true);
+ continue;
+ }
+ return tarefas3;
+ }
+ return tarefas1;
+ });
+ return tarefas2;
+ }
+
+ public async Task<List<long>> Validar(List<long> ids, long trilhaId)
+ {
+ int num = 3;
+ List<long> nums1 = await Task.Run<List<long>>(() => {
+ List<long> nums;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ nums = commited.get_TarefaRepository().Validar(ids, trilhaId);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 266, num, new { ids = ids, trilhaId = trilhaId }, true);
+ continue;
+ }
+ return nums;
+ }
+ return null;
+ });
+ return nums1;
+ }
+ }
+}
\ No newline at end of file |