Ejemplo n.º 1
0
        public List <KeyValuePair <string, XElement> > Gerar_TSData_WhitelistRecord(TSData_WhitelistRecord tsData)
        {
            try
            {
                List <KeyValuePair <string, XElement> > retorno = new List <KeyValuePair <string, XElement> >();

                foreach (Whitelist_WhitelistRecord white in tsData.WhitelistRecord)
                {
                    XElement xml = new XElement(tsData.tSData);

                    xml.Add(new XElement(tsData.header,
                                         new XElement(tsData.Header.version, tsData.Header.Version),
                                         new XElement(tsData.Header.issuer, tsData.Header.Issuer),
                                         new XElement(tsData.Header.receiver, tsData.Header.Receiver),
                                         new XElement(tsData.Header.iD, tsData.Header.ID)));

                    xml.Add(new XElement(tsData.whitelistRecord, new XAttribute(tsData.Header.expire, white.Permission.To.AddMonths(1).ToString("s")),
                                         new XElement(white.action, white.Action),
                                         new XElement(white.utid, white.UTID),
                                         new XElement(white.coding, white.Coding),
                                         new XElement(white.permission, new XElement(white.Permission.upid, white.Permission.UPID),
                                                      new XElement(white.Permission.tsproperty, new XAttribute(white.Permission.type, white.Permission.Type_Event),
                                                                   new XElement(white.Permission.TSProperty.id, white.Permission.TSProperty.EventoID)),
                                                      new XElement(white.Permission.tsproperty, new XAttribute(white.Permission.type, white.Permission.Type_Area),
                                                                   new XElement(white.Permission.TSProperty.id, white.Permission.TSProperty.AreaID)),
                                                      new XElement(white.Permission.tsproperty, new XAttribute(white.Permission.type, white.Permission.Type_TicketType),
                                                                   new XElement(white.Permission.TSProperty.id, white.Permission.TSProperty.TicketTypeID)),
                                                      new XElement(white.Permission.tsproperty, new XAttribute(white.Permission.type, white.Permission.Type_SeasonTicket),
                                                                   new XElement(white.Permission.TSProperty.id, white.Permission.TSProperty.SeassonPassID)),
                                                      new XElement(white.Permission.tsproperty, string.Empty,
                                                                   new XAttribute(white.Permission.type, white.Permission.Type_Validity),
                                                                   new XAttribute(white.Permission.from, white.Permission.From.ToString("s")),
                                                                   new XAttribute(white.Permission.to, white.Permission.To.ToString("s"))))));

                    retorno.Add(new KeyValuePair <string, XElement>(white.UTID, xml));
                }

                return(retorno);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public List <KeyValuePair <string, XElement> > Buscar_TSData_WhitelistRecord()
        {
            BD bd = new BD();

            try
            {
                EventoIDsWhite = new List <int>();

                string SQL = string.Format(@"SELECT DISTINCT te.ID 
                FROM tEvento AS te (NOLOCK)
                INNER JOIN tApresentacao ta (NOLOCK) ON te.ID = ta.EventoID
                WHERE te.LocalID IN ({0}) AND ta.Horario >= '{1}%'", this.LocalID, DateTime.Now.AddDays(-1).ToString("yyyyMMdd"));

                bd.Consulta(SQL);

                while (bd.Consulta().Read())
                {
                    EventoIDsWhite.Add(bd.LerInt("ID"));
                }

                bd.FecharConsulta();

                if (EventoIDsWhite.Count > 0)
                {
                    TSData_WhitelistRecord tsData = new TSData_WhitelistRecord();

                    tsData.Header.Version  = Version;
                    tsData.Header.Issuer   = Issuer;
                    tsData.Header.Receiver = Receiver;
                    tsData.Header.ID       = ID;

                    for (int cont = 0; cont < EventoIDsWhite.Count; cont++)
                    {
                        SQL = string.Format(@"SELECT DISTINCT ticb.ID, ticb.CodigoBarra, SUBSTRING(ta.Horario,1,8) AS Horario, ta.Horario AS HorarioCompleto, 
                        tpt.ID AS PrecoTipoID, tash.HorarioInicial, tash.HorarioFinal, ticb.EventoID,
                        tgi.Horario as HoraGerenciada, ISNULL(tgi.PrecoTipoID, 0) AS GerencimanentoID
                        FROM tIngressoCodigoBarra ticb (NOLOCK) 
                        INNER JOIN tIngressoLog til (NOLOCK) ON til.CodigoBarra = ticb.CodigoBarra
                        INNER JOIN tIngresso ti (NOLOCK) ON ti.ID = til.IngressoID AND ti.EventoID = ticb.EventoID
                        INNER JOIN tApresentacao ta (NOLOCK) ON ta.ID = ti.ApresentacaoID AND ta.EventoID = ticb.EventoID
                        INNER JOIN tPreco tp (NOLOCK) ON tp.ID = til.PrecoID AND tp.ApresentacaoSetorID = ti.ApresentacaoSetorID
                        LEFT JOIN tPrecoTipo tpt (NOLOCK) ON tpt.ID = tp.PrecoTipoID
                        LEFT JOIN tGerenciamentoIngressos tgi (NOLOCK) ON tgi.ID = ti.GerenciamentoIngressosID
                        LEFT JOIN tAuxiliarSetoresHorario tash (NOLOCK) ON tash.SetorID = ti.SetorID
                        WHERE ticb.EventoID = {0} AND ta.Horario >= '{1}%' AND ticb.Sincronizado = 'F'", EventoIDsWhite[cont], DateTime.Now.AddDays(-1).ToString("yyyyMMdd"));

                        bd.Consulta(SQL);

                        while (bd.Consulta().Read())
                        {
                            DateTime Horarioinicial = new DateTime();
                            DateTime Horariofinal   = new DateTime();

                            switch (bd.LerInt("GerencimanentoID"))
                            {
                            case GerenciamentoIngressos.PRECOHORAMARCADA:
                                Horarioinicial = Utilitario.String2DateTime(DateTime.Now.ToString("yyyyMMdd") + bd.LerString("HoraGerenciada"));
                                Horariofinal   = Horarioinicial.AddHours(1);
                                break;

                            default:
                                string horarioinicial = bd.LerString("HorarioInicial");
                                string horariofinal   = bd.LerString("HorarioFinal");

                                if (string.IsNullOrEmpty(horarioinicial))
                                {
                                    Horarioinicial = Utilitario.String2DateTime(bd.LerString("HorarioCompleto"));
                                }
                                else
                                {
                                    Horarioinicial = Utilitario.String2DateTime(bd.LerString("Horario") + horarioinicial);
                                }

                                if (string.IsNullOrEmpty(horariofinal))
                                {
                                    Horariofinal = Horarioinicial.AddHours(7.5);
                                }
                                else
                                {
                                    Horariofinal = Utilitario.String2DateTime(bd.LerString("Horario") + horariofinal);
                                }
                                break;
                            }

                            tsData.WhitelistRecord.Add(new Whitelist_WhitelistRecord()
                            {
                                Action = "U",
                                Coding = this.Coding,
                                UTID   = bd.LerString("CodigoBarra"),

                                Permission = new Permission_WhitelistRecord()
                                {
                                    UPID = bd.LerInt("ID"),
                                    From = Horarioinicial,
                                    To   = Horariofinal,

                                    TSProperty = new TSProperty_WhitelistRecord()
                                    {
                                        AreaID           = this.AreaID,
                                        EventoID         = this.EventID == 0 ? bd.LerInt("EventoID").ToString() : this.EventID.ToString("00"),
                                        PersonCategoryID = this.PersonCategoryID,
                                        SeassonPassID    = this.SeassonPassID,
                                        TicketTypeID     = this.TicketTypeID == 0 ? bd.LerInt("PrecoTipoID").ToString("00") : this.TicketTypeID.ToString("00")
                                    }
                                }
                            });
                        }

                        bd.FecharConsulta();
                    }

                    return(this.Gerar_TSData_WhitelistRecord(tsData));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                bd.Fechar();
            }
        }