Ejemplo n.º 1
0
 public List <Usuario> ListarUsuariosPorData(DataEvento data)
 {
     using (var contexto = new ContextoDeDados())
     {
         return(contexto.Usuario.Where(u => u.DataEvento.Equals(data)).ToList());
     }
 }
Ejemplo n.º 2
0
 public List <Usuario> ListarUsuariosPorData(DataEvento data)
 {
     for (int i = 0; i < ListarUsuariosPorData(data).Count; i++)
     {
     }
     return(UserRepositorio.ListarUsuariosPorData(data));
 }
Ejemplo n.º 3
0
 public DataEvento Adicionar(DataEvento model)
 {
     if (model.Valid)
     {
         using (RepositorySession dalSession = new RepositorySession(Runtime.JWInstance))
         {
             IUnitOfWork unitOfWork = dalSession.UnitOfWork;
             unitOfWork.Begin();
             try
             {
                 if (_repository.PesquisarporDataeCongregacao(ref unitOfWork, model) != null)
                 {
                     model.AddNotification(nameof(model.Data), Errors.EventExists);
                     unitOfWork.Rollback();
                     return(model);
                 }
                 _repository.Inserir(ref unitOfWork, model);
                 unitOfWork.Commit();
             }
             catch
             {
                 unitOfWork.Rollback();
                 throw;
             }
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        public override int GetHashCode()
        {
            int hash = 13;

            hash += IDUsuario.GetHashCode();
            hash += DataEvento.GetHashCode();

            return(hash);
        }
Ejemplo n.º 5
0
        public void Salvar(string nome, string email, string telefone, string cidade, string cpf, int dataId)
        {
            UsuarioAplicativo    userAplicativo = new UsuarioAplicativo();
            DataEventoAplicativo dataAplicativo = new DataEventoAplicativo();

            DataEvento data = dataAplicativo.GetDataEventoPorId(dataId);

            Usuario usuario = new Usuario(nome, email, telefone, cidade, cpf, data);

            userAplicativo.Cadastar(usuario);
        }
Ejemplo n.º 6
0
        private DataEvento BuscarPorId(ref IUnitOfWork unitOfWork, int id)
        {
            var ret = _repository.FindById(ref unitOfWork, id);

            if (ret == null)
            {
                ret = new DataEvento();
                ret.AddNotification(nameof(ret.Codigo), string.Format(Errors.RegisterNotFound, id));
                unitOfWork.Rollback();
            }
            return(ret);
        }
Ejemplo n.º 7
0
 public void Inserir(ref IUnitOfWork unitOfWork, DataEvento model)
 {
     unitOfWork.Connection.Execute(@" INSERT INTO [dbo].[DataEvento]
                                      ([Data], [Descricao], [CongregacaoId], [Assembleia], [VisitaSuperintendente])
                                      VALUES
                                      (@Data, @Descricao, @CongregacaoId, @Assembleia, @VisitaSuperintendente) ",
                                   param: new
     {
         @Data                  = model.Data,
         @Descricao             = model.Descricao,
         @CongregacaoId         = model.CongregacaoId,
         @Assembleia            = model.Assembleia,
         @VisitaSuperintendente = model.VisitaSuperintendente
     },
                                   transaction: unitOfWork.Transaction);
 }
Ejemplo n.º 8
0
 public DataEvento PesquisarporDataeCongregacao(ref IUnitOfWork unitOfWork, DataEvento model, int?id = null)
 {
     return(unitOfWork.Connection.Query <DataEvento>(
                (id != null) ? @"SELECT DE.* FROM dbo.[DataEvento] DE 
                              WHERE Data = CAST(@Data As Date) and CongregacaoId = @CongregacaoId  and DE.Codigo <> @Codigo " :
                @" SELECT DE.* FROM 
                                 dbo.[DataEvento] DE 
                                 WHERE Data = CAST(@Data As Date) and CongregacaoId = @CongregacaoId ",
                param: new
     {
         @Data = model.Data,
         @CongregacaoId = model.CongregacaoId,
         @Codigo = (IntValues.IsNullorDefault(id)) ? (int?)null : id
     },
                transaction: unitOfWork.Transaction
                ).FirstOrDefault());
 }
Ejemplo n.º 9
0
        private bool InsereDetalheQuadro(ref IUnitOfWork unitOfWork, DateTime dataControle, Congregacao item, int codigoQuadro, TipoLista itemTipoLista)
        {
            var           cont           = 0;
            ControleLista proximoLista   = null;
            bool          liberouproximo = false;
            QuadroDetalhe quadrodetalhe  = null;
            DataEvento    evento         = _repositoryDataEvento.ListByDate(ref unitOfWork, item.Codigo, dataControle);
            var           ultimaReuniao  = _repositoryQuadroDetalhe.ObterUltimaReuniaoValida(ref unitOfWork, item.Codigo, dataControle);
            var           proximaReuniao = _repositoryQuadroDetalhe.ObterProximaReuniaoValida(ref unitOfWork, item.Codigo, dataControle);

            if (evento == null || (evento.VisitaSuperintendente && itemTipoLista.Codigo != Core.Domain.enums.eTipoLista.LeitorELC &&
                                   itemTipoLista.Codigo != Core.Domain.enums.eTipoLista.LeitorJW))
            {
                if (item.FolgaParticipacao && itemTipoLista.Codigo != Core.Domain.enums.eTipoLista.OracaoFinal &&
                    itemTipoLista.Codigo != Core.Domain.enums.eTipoLista.OracaoInicial &&
                    (itemTipoLista.Codigo != Core.Domain.enums.eTipoLista.AudioVideo))
                {
                    if (itemTipoLista.Codigo == Core.Domain.enums.eTipoLista.Indicador)
                    {
                        cont = 16;
                    }

                    while (proximoLista == null)
                    {
                        if (cont <= 15)
                        {
                            proximoLista = _repositoryControleLista.ObterProximoListaSemRepetirComFolga(ref unitOfWork,
                                                                                                        (int)itemTipoLista.Codigo, (ultimaReuniao == null) ? dataControle.AddDays(-1) : ultimaReuniao.Data, dataControle,
                                                                                                        (proximaReuniao == null) ? dataControle.AddDays(1) : proximaReuniao.Data, item.Codigo);
                        }
                        else if (cont > 15 && cont <= 30)
                        {
                            proximoLista = _repositoryControleLista.ObterProximoListaSemRepetirSemFolgaParaAudioSonoro(ref unitOfWork,
                                                                                                                       (int)itemTipoLista.Codigo, (ultimaReuniao == null) ? dataControle.AddDays(-1) : ultimaReuniao.Data, dataControle,
                                                                                                                       (proximaReuniao == null) ? dataControle.AddDays(1) : proximaReuniao.Data, item.Codigo);
                        }
                        else if (cont > 30 && cont <= 50)
                        {
                            proximoLista = _repositoryControleLista.ObterProximoListaSemRepetirSemFolga(ref unitOfWork,
                                                                                                        (int)itemTipoLista.Codigo, dataControle, (ultimaReuniao == null) ? dataControle.AddDays(-1) : ultimaReuniao.Data,
                                                                                                        (proximaReuniao == null) ? dataControle.AddDays(1) : proximaReuniao.Data, item.Codigo);
                        }
                        else
                        {
                            throw new Exception("Não foi possivel obter um irmão da lista ");
                        }


                        if (proximoLista == null)
                        {
                            _repositoryControleLista.LiberaProximoLista(ref unitOfWork, (int)itemTipoLista.Codigo, item.Codigo);
                            liberouproximo = true;
                        }
                        cont++;
                        Task.Delay(10).Wait();
                    }
                }
                else if (itemTipoLista.Codigo != Core.Domain.enums.eTipoLista.OracaoFinal && itemTipoLista.Codigo != Core.Domain.enums.eTipoLista.OracaoInicial &&
                         ((itemTipoLista.Codigo == Core.Domain.enums.eTipoLista.AudioVideo) || (!item.FolgaParticipacao)))
                {
                    while (proximoLista == null)
                    {
                        if (cont <= 25)
                        {
                            proximoLista = _repositoryControleLista.ObterProximoListaSemRepetirSemFolga(ref unitOfWork,
                                                                                                        (int)itemTipoLista.Codigo, dataControle, (ultimaReuniao == null) ? dataControle.AddDays(-1) : ultimaReuniao.Data,
                                                                                                        (proximaReuniao == null) ? dataControle.AddDays(1) : proximaReuniao.Data, item.Codigo);
                        }
                        else
                        {
                            proximoLista = _repositoryControleLista.ObterProximoListaSemRepetirSemFolgaParaAudioSonoro(ref unitOfWork,
                                                                                                                       (int)itemTipoLista.Codigo, (ultimaReuniao == null) ? dataControle.AddDays(-1) : ultimaReuniao.Data, dataControle,
                                                                                                                       (proximaReuniao == null) ? dataControle.AddDays(1) : proximaReuniao.Data, item.Codigo);
                        }

                        if (proximoLista == null)
                        {
                            _repositoryControleLista.LiberaProximoLista(ref unitOfWork, (int)itemTipoLista.Codigo, item.Codigo);
                            liberouproximo = true;
                        }

                        if (cont > 50)
                        {
                            throw new Exception("Não foi possivel obter um irmão da lista de audio e video");
                        }

                        cont++;
                    }
                }
                else
                {
                    while (proximoLista == null)
                    {
                        proximoLista = _repositoryControleLista.ObterProximoListaPodeRepetir(ref unitOfWork,
                                                                                             (int)itemTipoLista.Codigo, item.Codigo, dataControle);

                        if (proximoLista == null)
                        {
                            _repositoryControleLista.LiberaProximoLista(ref unitOfWork, (int)itemTipoLista.Codigo, item.Codigo);
                            liberouproximo = true;
                        }
                    }
                }

                quadrodetalhe = new QuadroDetalhe()
                {
                    Data = dataControle, IrmaoId = proximoLista.IrmaoId, QuadroId = codigoQuadro
                };
                _repositoryControleLista.AtualizaPartipacaoIrmaoLista(ref unitOfWork, (int)itemTipoLista.Codigo, proximoLista.IrmaoId, liberouproximo);
            }
            else
            {
                quadrodetalhe = new QuadroDetalhe()
                {
                    Data = dataControle, QuadroId = codigoQuadro, EventoId = evento.Codigo
                }
            };

            _repositoryQuadroDetalhe.InsereDataQuadro(ref unitOfWork, quadrodetalhe);

            return((evento != null && evento.Assembleia) ? true : false);
        }
    }
Ejemplo n.º 10
0
        public async Task <List <Detalle> > GetCreditor(List <ResultInstruction> list)
        {
            ServiceEvento            dataEvento = new ServiceEvento(TokenSii);
            DteInfoRef               infoLastF  = null;
            List <Detalle>           detalles   = new List <Detalle>();
            Dictionary <string, int> dic        = Properties.Settings.Default.DicReem;
            int   c = 0;
            float porcent;
            List <Task <List <Detalle> > > tareas = new List <Task <List <Detalle> > >();

            tareas = list.Select(async instruction =>
            {
                try
                {
                    // GET PARTICIPANT DEBTOR
                    instruction.ParticipantDebtor = await Participant.GetParticipantByIdAsync(instruction.Debtor);
                    //REEMPLAZOS
                    if (dic.ContainsKey(instruction.ParticipantDebtor.Id.ToString()))
                    {
                        instruction.ParticipantNew = await Participant.GetParticipantByIdAsync(dic[instruction.ParticipantDebtor.Id.ToString()]);
                    }
                    // ROOT CLASS.
                    Detalle detalle = new Detalle(instruction.ParticipantDebtor.Rut, instruction.ParticipantDebtor.VerificationCode, instruction.ParticipantDebtor.BusinessName, instruction.Amount, instruction, true);
                    // GET INFO OF INVOICES.
                    List <DteInfoRef> dteInfos    = await DteInfoRef.GetInfoRefAsync(instruction, Conn, "F");
                    List <DteInfoRef> dteInfoRefs = new List <DteInfoRef>();
                    if (dteInfos != null)
                    {
                        foreach (DteInfoRef item in dteInfos)
                        {
                            if (string.Compare(item.Glosa, instruction.PaymentMatrix.NaturalKey, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                dteInfoRefs.Add(item);
                            }
                        }
                        // ATTACH FILES.
                        detalle.DteInfoRefs = dteInfoRefs;
                        // ATTACH PRINCIPAL DOC.
                        if (detalle.DteInfoRefs.Count >= 1)
                        {
                            infoLastF = detalle.DteInfoRefs.First(); // SHOW THE LAST DOC.
                            if (dteInfoRefs.First().DteFiles != null)
                            {
                                switch (detalle.DteInfoRefs.First().DteFiles.Count)
                                {
                                case 1:
                                    if (infoLastF.DteFiles[0].TipoXML == null)
                                    {
                                        detalle.DTEDef  = HSerialize.DTE_To_Object(infoLastF.DteFiles[0].Archivo);
                                        detalle.DTEFile = infoLastF.DteFiles[0].Archivo;
                                    }
                                    break;

                                default:
                                    {
                                        detalle.DTEDef  = HSerialize.DTE_To_Object(infoLastF.DteFiles.FirstOrDefault(x => x.TipoXML == "D").Archivo);
                                        detalle.DTEFile = infoLastF.DteFiles.FirstOrDefault(x => x.TipoXML == "D").Archivo;
                                        break;
                                    }
                                }
                            }
                            detalle.DteInfoRefLast = infoLastF;
                            detalle.NroInt         = infoLastF.NroInt;
                            detalle.FechaEmision   = infoLastF.Fecha.ToString();
                            detalle.Folio          = infoLastF.Folio;
                            detalle.MntNeto        = infoLastF.NetoAfecto;
                            detalle.MntIva         = infoLastF.IVA;
                            detalle.MntTotal       = infoLastF.Total;
                            // GET INFO FROM SII
                            if (infoLastF.EnviadoSII == 1 && infoLastF.AceptadoCliente == 0) // 1 Enviado / 0 No enviado
                            {
                                detalle.FechaRecepcion = infoLastF.FechaEnvioSII.ToString("dd-MM-yyyy");
                                // EVENTS FROM SII
                                DataEvento evento = await dataEvento.GetStatusDteAsync("Creditor", TokenSii, "33", detalle, UserParticipant);
                                if (evento != null)
                                {
                                    detalle.DataEvento    = evento;
                                    detalle.StatusDetalle = GetStatus(detalle);
                                }
                            }
                            if (detalle.StatusDetalle == StatusDetalle.Pending && infoLastF.AceptadoCliente == 1)
                            {
                                detalle.FechaRecepcion = infoLastF.FechaEnvioSII.ToString("dd-MM-yyyy");
                                detalle.StatusDetalle  = StatusDetalle.Accepted;
                            }
                            else if (detalle.StatusDetalle == StatusDetalle.Accepted && infoLastF.AceptadoCliente == 0)
                            {
                                DteFiles.UpdateFiles(Conn, detalle); // UPDATE DTE_DocCab SET infoLastF.EnviadoCliente = 1
                            }
                        }
                        // SEND DTE TO CEN.
                        if (detalle.StatusDetalle == StatusDetalle.Accepted && detalle.Instruction != null && detalle.Instruction.StatusBilled == Instruction.StatusBilled.NoFacturado)
                        {
                            ResultDte resultDte = await Dte.SendDteCreditorAsync(detalle, TokenCen, detalle.DTEFile);
                            if (resultDte != null)
                            {
                                detalle.Instruction.Dte          = resultDte;
                                detalle.Instruction.StatusBilled = Instruction.StatusBilled.Facturado;
                            }
                        }
                        detalle.ValidatorFlag = new HFlagValidator(detalle, true);
                    }
                    else
                    {
                        detalle.ValidatorFlag = new HFlagValidator()
                        {
                            Flag = LetterFlag.Clear
                        };
                    }
                    detalles.Add(detalle);
                    c++;
                    porcent = (float)(100 * c) / list.Count;
                    await ReportProgress(porcent, $"Processing 'Pay Instructions' {instruction.Id}-{instruction.PaymentMatrix.PublishDate.ToString("dd-MM-yyyy")}, wait please.  ({c}/{list.Count})");
                    return(detalles);
                }
                catch (Exception)
                {
                    return(null);

                    throw;
                }
            }).ToList();
            await Task.WhenAll(tareas);

            return(detalles.OrderBy(x => x.Instruction.Id).ToList());
        }