Exemplo n.º 1
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);
        }