示例#1
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute ins_terminal ");

            /// USER [ execute ]

            term.Reset();

            term.set_fk_loja(loj.get_identity());
            term.set_nu_terminal(my_term.ToString().PadLeft(8, '0'));
            term.set_st_localizacao(input_cont_dt.get_st_localizacao());

            if (!term.create_T_Terminal())
            {
                return(false);
            }

            PublishNote("Terminal criado com suceesso (" + my_term.ToString() + ")");

            /// USER [ execute ] END

            Registry("execute done ins_terminal ");

            return(true);
        }
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_consultaTransacao ");

            /// USER [ execute ]

            T_Terminal term = new T_Terminal(this);
            T_Cartao   cart = new T_Cartao(this);
            T_Loja     loj  = new T_Loja(this);

            StringBuilder sb = new StringBuilder();

            int  i_nu_parc  = 0;
            long i_vr_valor = 0;

            if (nu_parc.Length > 0)
            {
                i_nu_parc = Convert.ToInt32(nu_parc);
            }

            if (vr_valor.Length > 0)
            {
                i_vr_valor = Convert.ToInt64(vr_valor);
            }

            string nsu = input_cont_dct.get_st_nsu();

            Hashtable hshEmpresas = new Hashtable();

            #region - para o caso de administrador -

            if (user.get_tg_nivel() == TipoUsuario.Administrador)
            {
                T_Empresa emp_admin = new T_Empresa(this);

                if (emp_admin.select_rows_empresa(user.get_st_empresa()))
                {
                    if (!emp_admin.fetch())
                    {
                        return(false);
                    }

                    T_Empresa emp_tb = new T_Empresa(this);

                    // ## Para o caso de empresa administradora de empresas

                    if (emp_tb.select_fk_admin(emp_admin.get_identity()))
                    {
                        while (emp_tb.fetch())
                        {
                            hshEmpresas [emp_tb.get_identity()] = "*";
                        }
                    }
                }
            }

            #endregion

            // ## Busca as transações

            SQL_LOGGING_ENABLE = false;

            int max_trans = 200;

            if (input_cont_header.get_tg_user_type() == TipoUsuario.SuperUser)
            {
                max_trans = 1000;
            }

            while (l_tr.fetch())
            {
                // ## Filtro de empresas
                // ## somente de administradora ou de vinculadas

                if (hshEmpresas.Count > 0)
                {
                    if (hshEmpresas [l_tr.get_fk_empresa()] == null)
                    {
                        continue;
                    }
                }

                if (nsu.Length > 0)
                {
                    if (l_tr.get_nu_nsu() != nsu)
                    {
                        continue;
                    }
                }

                if (st_cart_id.Length > 0)
                {
                    if (l_tr.get_fk_cartao() != st_cart_id)
                    {
                        continue;
                    }
                }

                if (nu_parc.Length > 0)
                {
                    if (l_tr.get_int_nu_parcelas() < i_nu_parc)
                    {
                        continue;
                    }
                }

                if (vr_valor.Length > 0)
                {
                    if (l_tr.get_int_vr_total() < i_vr_valor)
                    {
                        continue;
                    }
                }

                if (en_oper.Length > 0)
                {
                    if (l_tr.get_en_operacao() != en_oper)
                    {
                        continue;
                    }
                }

                if (en_conf.Length > 0)
                {
                    if (l_tr.get_tg_confirmada() != en_conf)
                    {
                        continue;
                    }
                }

                if (fk_empresa.Length > 0)
                {
                    if (l_tr.get_fk_empresa() != fk_empresa)
                    {
                        continue;
                    }
                }

                if (fk_terminal.Length > 0)
                {
                    if (l_tr.get_fk_terminal() != fk_terminal)
                    {
                        continue;
                    }
                }

                term.Reset();
                loj.Reset();
                cart.Reset();

                // ## Busca terminal

                term.selectIdentity(l_tr.get_fk_terminal());

                if (fk_loja.Length > 0)
                {
                    if (term.get_fk_loja() != fk_loja)
                    {
                        continue;
                    }
                }

                loj.selectIdentity(l_tr.get_fk_loja());
                cart.selectIdentity(l_tr.get_fk_cartao());

                // ## Cria registro em memória

                if (--max_trans == 0)
                {
                    PublishNote("Limite máximo de registros excedido");
                    break;
                }

                DadosConsultaTransacao dt = new DadosConsultaTransacao();

                dt.set_en_oper(l_tr.get_en_operacao());
                dt.set_st_nsu(l_tr.get_nu_nsu());

                dt.set_st_cartao(cart.get_st_empresa() + "." +
                                 cart.get_st_matricula() + "." +
                                 cart.get_st_titularidade());

                dt.set_st_cnpj_loja(loj.get_st_nome());

                dt.set_st_terminal(term.get_nu_terminal());
                dt.set_vr_valor(l_tr.get_vr_total());
                dt.set_nu_parcelas(l_tr.get_nu_parcelas());
                dt.set_dt_transacao(l_tr.get_dt_transacao());
                dt.set_tg_status(l_tr.get_tg_confirmada());

                dt.set_st_msg_erro(l_tr.get_st_msg_transacao() +
                                   l_tr.get_st_doc());

                DataPortable tmp = dt as DataPortable;

                // ## indexa em memória

                sb.Append(MemorySave(ref tmp));
                sb.Append(",");
            }

            SQL_LOGGING_ENABLE = true;

            string list_ids = sb.ToString().TrimEnd(',');

            if (list_ids == "")
            {
                PublishNote("Nenhum resultado foi encontrado");
                return(true);
            }

            DataPortable dp = new DataPortable();

            dp.setValue("ids", list_ids);

            // ## cria indexador de bloco

            output_st_csv_id = MemorySave(ref dp);

            /// USER [ execute ] END

            Registry("execute done fetch_consultaTransacao ");

            return(true);
        }