Ejemplo n.º 1
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_chamados ");

            /// USER [ execute ]

            T_Usuario usrConvey        = new T_Usuario(this);
            T_Usuario usrConveyCriador = new T_Usuario(this);

            if (input_st_operador.Length > 0)
            {
                if (!usrConvey.select_rows_login(input_st_operador, "000000"))
                {
                    PublishError("Usuário inexistente");
                    return(false);
                }

                if (!usrConvey.fetch())
                {
                    return(false);
                }
            }

            if (input_st_resp.Length > 0)
            {
                if (!usrConveyCriador.select_rows_login(input_st_resp, "000000"))
                {
                    PublishError("Usuário inexistente");
                    return(false);
                }

                if (!usrConveyCriador.fetch())
                {
                    return(false);
                }
            }

            T_Loja loj = new T_Loja(this);

            if (input_st_loja.Length > 0)
            {
                if (!loj.select_rows_loja(input_st_loja))
                {
                    PublishError("Código de loja inválido");
                    return(false);
                }

                if (!loj.fetch())
                {
                    return(false);
                }
            }

            T_Chamado cham = new T_Chamado(this);

            #region - busca pela data -

            if (input_dt_ini_ab.Length > 0 &&
                input_dt_fim_ab.Length > 0 &&
                input_dt_ini_fech.Length > 0 &&
                input_dt_fim_fech.Length > 0)
            {
                if (!cham.select_rows_abert_fech(input_dt_ini_ab,
                                                 input_dt_fim_ab,
                                                 input_dt_ini_fech,
                                                 input_dt_fim_fech))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length > 0 &&
                     input_dt_fim_ab.Length > 0 &&
                     input_dt_ini_fech.Length > 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_abert_fech(input_dt_ini_ab,
                                                 input_dt_fim_ab,
                                                 input_dt_ini_fech))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length > 0 &&
                     input_dt_fim_ab.Length > 0 &&
                     input_dt_ini_fech.Length == 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_abert_fech(input_dt_ini_ab,
                                                 input_dt_fim_ab))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length > 0 &&
                     input_dt_fim_ab.Length == 0 &&
                     input_dt_ini_fech.Length == 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_abert_fech(input_dt_ini_ab))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length > 0 &&
                     input_dt_fim_ab.Length == 0 &&
                     input_dt_ini_fech.Length > 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_abert_fech_ini(input_dt_ini_ab,
                                                     input_dt_ini_fech))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length == 0 &&
                     input_dt_fim_ab.Length == 0 &&
                     input_dt_ini_fech.Length > 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_fech(input_dt_ini_fech))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }

            #endregion

            StringBuilder sb = new StringBuilder();

            while (cham.fetch())
            {
                if (input_st_loja.Length > 0)
                {
                    if (cham.get_fk_loja() != loj.get_identity())
                    {
                        continue;
                    }
                }

                if (input_st_operador.Length > 0)
                {
                    if (cham.get_fk_operador() != usrConvey.get_identity())
                    {
                        continue;
                    }
                }
                else if (!usrConvey.selectIdentity(cham.get_fk_operador()))
                {
                    continue;
                }

                if (input_st_resp.Length > 0)
                {
                    if (cham.get_fk_oper_criador() != usrConveyCriador.get_identity())
                    {
                        continue;
                    }
                }
                else if (!usrConveyCriador.selectIdentity(cham.get_fk_oper_criador()))
                {
                    continue;
                }

                if (input_nu_prioridade != "-1")
                {
                    if (cham.get_nu_prioridade() != input_nu_prioridade)
                    {
                        continue;
                    }
                }

                if (input_nu_categ != "-1")
                {
                    if (cham.get_nu_categoria() != input_nu_categ)
                    {
                        continue;
                    }
                }

                if (cham.get_tg_fechado() != input_tg_closed)
                {
                    continue;
                }

                if (cham.get_tg_tecnico() != input_tg_tecnico)
                {
                    continue;
                }

                DadosChamado dc = new DadosChamado();

                dc.set_id_chamado(cham.get_identity());
                dc.set_st_oper(usrConvey.get_st_nome());
                dc.set_st_resp(usrConveyCriador.get_st_nome());
                dc.set_dt_ab(cham.get_dt_abertura());
                dc.set_st_motivo(cham.get_st_motivo());

                if (cham.get_tg_fechado() == Context.TRUE)
                {
                    dc.set_dt_fech(cham.get_dt_fechamento());
                }

                DataPortable tmp = dc as DataPortable;

                // ## indexa em memória

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

            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_block = MemorySave(ref dp);

            /// USER [ execute ] END

            Registry("execute done fetch_chamados ");

            return(true);
        }
Ejemplo n.º 2
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_alteraChamado ");

            /// USER [ execute ]

            T_Chamado   cham      = new T_Chamado(this);
            T_Usuario   usrConvey = new T_Usuario(this);
            LOG_Chamado l_c       = new LOG_Chamado(this);

            if (input_tg_fechado == Context.TRUE)
            {
                cham.ExclusiveAccess();
            }

            if (!cham.selectIdentity(input_id_chamado))
            {
                return(false);
            }

            if (cham.get_tg_fechado() == Context.TRUE)
            {
                PublishError("Chamado fechado não pode ser alterado");
                return(false);
            }

            if (!usrConvey.select_rows_login(input_st_operador, "000000"))
            {
                PublishError("Usuário inexistente");
                return(false);
            }

            if (!usrConvey.fetch())
            {
                return(false);
            }

            l_c.set_fk_chamado(cham.get_identity());
            l_c.set_fk_operador(user.get_identity());
            l_c.set_st_solucao(input_st_new_desc);
            l_c.set_dt_solucao(GetDataBaseTime());

            if (!l_c.create_LOG_Chamado())
            {
                return(false);
            }

            cham.set_tg_fechado(input_tg_fechado);
            cham.set_fk_operador(usrConvey.get_identity());

            if (input_tg_fechado == Context.TRUE)
            {
                cham.set_dt_fechamento(GetDataBaseTime());
            }

            if (!cham.synchronize_T_Chamado())
            {
                return(false);
            }

            if (input_tg_fechado == Context.TRUE)
            {
                l_c.set_st_solucao("## Chamado fechado");

                if (!l_c.create_LOG_Chamado())
                {
                    return(false);
                }
            }

            PublishNote("Chamado alterado com sucesso");

            /// USER [ execute ] END

            Registry("execute done exec_alteraChamado ");

            return(true);
        }
Ejemplo n.º 3
0
        public override bool execute( )
        {
            Registry("execute exec_login ");

            /// USER [ execute ]

            output_tg_trocaSenha = Context.FALSE;

            user = new T_Usuario(this);

            user.ExclusiveAccess();

            // ## Busca usuário com nome e cód de empresa

            if (loginLojista)
            {
                string st_loja = input_st_empresa.Replace("L", "");

                T_Loja loj = new T_Loja(this);

                if (!loj.select_rows_loja(st_loja))
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

                if (!loj.fetch())
                {
                    return(false);
                }

                T_Terminal term = new T_Terminal(this);

                if (!term.select_fk_loja(loj.get_identity()))
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

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

                LINK_UsuarioTerminal lut = new LINK_UsuarioTerminal(this);

                if (!lut.select_fk_term(term.get_identity()))
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

                bool found = false;

                T_Usuario usr_lojista = new T_Usuario(this);

                while (lut.fetch())
                {
                    if (!usr_lojista.selectIdentity(lut.get_fk_user()))
                    {
                        return(false);
                    }

                    Trace(usr_lojista.get_st_nome());

                    if (usr_lojista.get_st_nome() == input_st_nome)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

                if (!user.selectIdentity(usr_lojista.get_identity()))
                {
                    return(false);
                }

                input_st_empresa = st_loja;

                output_cont_header.set_nu_terminal(term.get_nu_terminal());
            }
            else
            {
                if (!user.select_rows_login(input_st_nome, input_st_empresa))
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

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

            // ## Confere bloqueio

            if (user.get_tg_bloqueio() != Context.FALSE)
            {
                PublishError("Usuário ou senha incorretos");
                return(false);
            }

            // ## Confere senha

            if (user.get_st_senha() != input_st_senha)
            {
                user.set_nu_senhaErrada(Convert.ToString(user.get_int_nu_senhaErrada() + 1));

                if (user.get_int_nu_senhaErrada() >= 3)
                {
                    // ## Na terceira senha errada, bloqueia cartão

                    //user.set_tg_bloqueio      ( Context.TRUE  );
                    //user.set_nu_senhaErrada   (  0            );
                }

                // ## Atualiza

                if (!user.synchronize_T_Usuario())
                {
                    return(false);
                }

                PublishError("Usuário ou senha incorretos");
                return(false);
            }
            else
            {
                // ## Zera senhas erradas

                ut_coverMark(1);

                user.set_nu_senhaErrada(0);
            }

            // ## Caso o ultimo logoff não foi executado, ou seja,
            // ## o usuário não fechou corretamente sua última instância

            if (user.get_tg_logoff() == Context.FALSE)
            {
                // ## Mais de cinco minutos se passaram...

                if (TimeSpanCtrl(user.get_dt_ultUso(),
                                 TSpan_Mode.MORE_THAN,
                                 5,
                                 TSpan_Range.Minutes) == true)
                {
                    PublishNote("Disconectando sessão ociosa por mais de cinco minutos");
                }
                else
                {
                    PublishError("Não são permitidas multiplas sessões");
                    return(false);
                }
            }

            // ## Seto que o logoff precisa ser feito

            user.set_tg_logoff(Context.FALSE);

            // ## Confere se senha expirou...

            if (TimeSpanCtrl(user.get_dt_trocaSenha(),
                             TSpan_Mode.MORE_THAN,
                             60,
                             TSpan_Range.Days) == true)
            {
                output_tg_trocaSenha = Context.TRUE;

                PublishNote("É necessário trocar sua senha");
            }

            // ## Confere se admin requisitou troca de senha

            if (user.get_tg_trocaSenha() == Context.TRUE)
            {
                output_tg_trocaSenha = Context.TRUE;

                PublishNote("É necessário trocar sua senha");
            }

            // ## Seto login feito agora

            user.set_dt_ultUso(GetDataBaseTime());

            // ## Atualizo usuário

            if (!user.synchronize_T_Usuario())
            {
                return(false);
            }

            output_cont_header.set_st_session(var_SessionKey);
            output_cont_header.set_st_empresa(input_st_empresa);
            output_cont_header.set_st_user_id(user.get_identity());
            output_cont_header.set_tg_user_type(user.get_tg_nivel());

            /// USER [ execute ] END

            Registry("execute done exec_login ");

            return(true);
        }