Exemple #1
0
        public override bool deleteFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            bool Result = base.deleteFuncionario(Funcionario);

            try
            {
                Connect();

                if (!(_rep.RemoverUsuario(Convert.ToInt64(Funcionario.Pis), out Result)))
                {
                    log.AddLog(Consts.ERRO_ENVIO_COMANDO);
                }
                else
                {
                    log.AddLog(Consts.OPERACAO_FINALIZADA);
                    log.AddLineBreak();
                    Result = true;
                }
            }
            catch (Exception ex)
            {
                log.AddLog(ex.Message);
                Result = false;
            }
            finally
            {
                _rep.Desconectar();
            }

            return(Result);
        }
Exemple #2
0
        public override bool deleteFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            base.deleteFuncionario(Funcionario);
            bool Result = false;

            try
            {
                if (Connect(0))
                {
                    short porta = (short)TerminalDados.Porta;

                    if (starRep.ExcluirFuncionario(TerminalDados.IP, porta, numeroTentativas, tempoEsperaMilissegundos, Funcionario.Pis))
                    {
                        log.AddLog("OK");
                        Result = true;
                    }
                    else
                    {
                        log.AddLog(AssepontoRep.Consts.ERRO_ENVIO_COMANDO);
                    }
                }

                return(Result);
            }
            catch (Exception ex)
            {
                log.AddLog(ex.Message.ToString());
            }
            finally
            {
                starRep.Fecha_Comunicacao();
            }
            return(Result);
        }
Exemple #3
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            bool Result      = base.sendFuncionario(Funcionario);
            byte privilegios = 0;

            try
            {
                Connect();

                if (!_rep.GravarUsuario(Convert.ToInt64(Funcionario.Pis), Funcionario.Nome, metodTeclado(Funcionario.Teclado), "",
                                        Funcionario.Barras + '\0', metodProximidade(Funcionario.Proximidade), privilegios, out Result))
                {
                    log.AddLog(Consts.ERRO_ENVIO_COMANDO);
                }
            }
            catch (Exception ex)
            {
                log.AddLog(ex.Message);
                Result = false;
            }
            finally
            {
                _rep.Desconectar();
            }

            return(Result);
        }
Exemple #4
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            base.sendFuncionario(Funcionario);

            bool Result = true;

            foreach (int Cracha in Funcionario.Crachas)
            {
                const string BIOMETRIAMODO_1N = "1";

                string cartao = Cracha.ToString().PadRight(15, '0');
                string pis    = Funcionario.Pis.PadRight(12, '0');
                string nome   = Funcionario.Nome.PadRight(52);

                string config = (TerminalDados.Barras ? "1" : "0") +
                                (TerminalDados.Proximidade ? "1" : "0") +
                                (TerminalDados.Biometria ? "1" : "0") +
                                (TerminalDados.Teclado ? "1" : "0") +
                                (Funcionario.TecladoPassword != "" ? "1" : "0") +
                                BIOMETRIAMODO_1N;

                string senha = Funcionario.TecladoPassword.PadRight(6);

                Comando cmd = new Comando(Protocolo.CMD_FUNCIONARIO, Protocolo.SET, String.Format("{0}{1}{2}{3}{4}", cartao, pis, config, senha, nome));

                if (!EnviaComandoTCP(cmd))
                {
                    Result = false;
                }
            }

            return(Result);
        }
Exemple #5
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            base.sendFuncionario(Funcionario);

            string Senha = "";

            foreach (int Cracha in Funcionario.Crachas)
            {
                _watchComm.AddEmployee(Funcionario.Pis, Funcionario.Nome, Senha);
                _watchComm.AddCredential(Cracha.ToString(), Funcionario.Pis, 0);
            }

            return(true);
        }
Exemple #6
0
        public override bool deleteFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            bool Ok = base.deleteFuncionario(Funcionario);

            //Connect(TerminalDados.Indice);

            /******************************************************************************************************************************
             * 'INCLUSÃO DE FUNCIONÁRIO                                                                                                      *
             * '******************************************************************************************************************************/
            /*Prepara o envio do cadastro do funcionário*/
            REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_Funcionario_Prepara(REPZPM_DLL.Handle, opExclusao, Funcionario.Pis, "", "", "", "", "", "", "", "");

            /*Comando executado*/
            if (REPZPM_DLL.Retorno == 1)
            {
                REPZPM_DLL.ID_Comando = REPZPM_DLL.DLLREP_Funcionario_Envia(REPZPM_DLL.Handle);

                /*Comando de cadastro de funcionário foi enviado com sucesso se for maior que 0*/
                if (REPZPM_DLL.ID_Comando > 0)
                {
                    if (REPZPM_DLL.Modo == 0)
                    {
                        /*Obtém o código de erro*/
                        REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemCodigoErro(REPZPM_DLL.Handle, 1);

                        /*Se Retorno for <> de 0, então houve erro na execução do comando de cadastro de funcionário*/
                        if (REPZPM_DLL.Retorno != 0)
                        {
                            REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1);
                            log.AddLog(Convert.ToString(MensagemErro), true);
                        }
                        else
                        {
                            log.AddLog(REPZPM_DLL.Trata_Retorno_REP(REPZPM_DLL.Retorno), true, true);
                            Ok = true;
                        }
                    }
                }
                else
                {
                    log.AddLog(Consts.ERRO_ENVIO_COMANDO, true);
                }
            }
            else
            {
                log.AddLog(Consts.ERRO_ENVIO_COMANDO, true);
            }

            return(Ok);
        }
Exemple #7
0
        public override bool deleteFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            base.deleteFuncionario(Funcionario);

            log.AddLog("EXCLUINDO FUNCIONÁRIO PIS: " + Funcionario.Pis);

            if (Rep.ExcluirEmpregado(TerminalDados.IP, TerminalDados.Porta, Convert.ToInt32(TerminalDados.SupervisorSenha), Funcionario.Pis))
            {
                log.AddLog("FUNCIONÁRIO EXCLUIDO COM SUCESSO");
                return(true);
            }
            else
            {
                LogErro();
                return(false);
            }
        }
Exemple #8
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            base.sendFuncionario(Funcionario);
            //Cracha = Cracha.PadLeft(CartaoDigitos, '0');

            log.AddLog("ENVIANDO FUNCIONÁRIO PIS: " + Funcionario.Pis + " CRACHÁ: " + Funcionario.Crachas[0]);

            if (Rep.CadastrarEmpregado(TerminalDados.IP, TerminalDados.Porta, Convert.ToInt32(TerminalDados.SupervisorSenha), Funcionario.Pis, Funcionario.Nome, Funcionario.Crachas[0].ToString(), false))
            {
                log.AddLog("FUNCIONÁRIO ENVIADO COM SUCESSO");
                return(true);
            }
            else
            {
                LogErro();
                return(false);
            }
        }
Exemple #9
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            base.sendFuncionario(Funcionario);
            bool Result = false;

            try
            {
                if (Connect(0))
                {
                    innerRep.InicializarListaEmpregados();
                    int resposta = innerRep.IncluirEmpregadosLista(Funcionario.Nome, Funcionario.Pis, crachas(Funcionario.Barras), crachas(Funcionario.Proximidade), crachas(Funcionario.Teclado), "", "1234", true);

                    if (resposta == 0)
                    {
                        resposta = innerRep.EnviarListaIndividualEmpregados();
                        resposta = innerRep.LerResultado(0);
                        if (resposta == 0)
                        {
                            Result = MensagemComandoFuncionario(Funcionario.Nome);
                            if (Result)
                            {
                                log.AddLog(string.Format(Consts.FUNCIONARIO_ENVIADO_COM_SUCESSO, Funcionario.Nome));
                            }
                        }
                        else
                        {
                            MensagemResultadoComunicacao(resposta);
                        }
                    }
                    else
                    {
                        MensagemCadastroFuncionario(resposta);
                    }
                }

                return(Result);
            }
            catch (Exception ex)
            {
                log.AddLog(ex.Message.ToString());
            }

            return(Result);
        }
Exemple #10
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            base.sendFuncionario(Funcionario);

            bool   Result = true;
            string Answer = "";

            foreach (int Cracha in Funcionario.Crachas)
            {
                Send(String.Format("01+EU+00+1+I[{0}[{1}[{2}[{3}[{4}", Funcionario.Pis, Funcionario.Nome, 1, 1, Cracha), out Answer);

                if (!ProcessAnswer(Answer))
                {
                    Result = false;
                }
            }

            return(Result);
        }
Exemple #11
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            base.sendFuncionario(Funcionario);
            bool Result = false;

            try
            {
                if (Connect(0))
                {
                    short porta = (short)TerminalDados.Porta;

                    short resposta = starRep.EnviarFuncionario(TerminalDados.IP, porta, numeroTentativas, tempoEsperaMilissegundos, Funcionario.Pis, Funcionario.Nome, Funcionario.Barras);

                    if (resposta == 1 || resposta == 2)
                    {
                        log.AddLog(string.Format(AssepontoRep.Consts.FUNCIONARIO_ENVIADO_COM_SUCESSO, Funcionario.Nome));
                        Result = true;
                    }
                    else
                    {
                        log.AddLog(AssepontoRep.Consts.ERRO_ENVIO_COMANDO);
                    }
                }

                return(Result);
            }
            catch (Exception ex)
            {
                log.AddLog(ex.Message.ToString());
            }
            finally
            {
                starRep.Fecha_Comunicacao();
            }
            return(Result);
        }
Exemple #12
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            bool Result = base.sendFuncionario(Funcionario);

            //Connect(TerminalDados.Indice);

            int  Operacao;
            bool Ok      = false;
            bool Teclado = false;

            string Habilitar_Teclado   = Teclado ? "S" : "N";
            string tempFuncionarioNome = "";
            string tempCracha          = "";
            bool   tempTeclado         = false;
            string tempCodigoTeclado   = "";
            string tempCodigoBarras    = "";
            string tempCodigoMifare    = "";
            string tempCodigoTag       = "";

            string CodigoMifare = "";
            string CodigoTag    = "";

            getFuncionario(Funcionario.Pis, out tempFuncionarioNome, out tempCracha, out tempTeclado,
                           out tempCodigoTeclado, out tempCodigoBarras, out tempCodigoMifare, out tempCodigoTag);

            Operacao = tempFuncionarioNome != String.Empty ? opAlteracao : opInclusao;

            /*Prepara o envio do cadastro do funcionário*/

            if (Funcionario.Crachas.Count > 0)
            {
                foreach (long Cracha in Funcionario.Crachas)
                {
                    REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_Funcionario_Prepara(REPZPM_DLL.Handle, Operacao, Funcionario.Pis, Convert.ToString(Cracha), Funcionario.Nome, "", Habilitar_Teclado, Convert.ToString(Cracha), Convert.ToString(Cracha), CodigoMifare, CodigoTag);
                }
            }
            else
            {
                REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_Funcionario_Prepara(REPZPM_DLL.Handle, Operacao, Funcionario.Pis, "", Funcionario.Nome, "", Habilitar_Teclado, "", "", CodigoMifare, CodigoTag);
            }

            if (REPZPM_DLL.Retorno == 1)
            {
                REPZPM_DLL.ID_Comando = REPZPM_DLL.DLLREP_Funcionario_Envia(REPZPM_DLL.Handle);

                if (REPZPM_DLL.ID_Comando > 0)
                {
                    if (REPZPM_DLL.Modo == 0)
                    {
                        REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemCodigoErro(REPZPM_DLL.Handle, 1);

                        /*Se Retorno for <> de 0, então houve erro na execução do comando de cadastro de funcionário*/
                        if (REPZPM_DLL.Retorno != 0)
                        {
                            REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1);
                        }
                        else
                        {
                            Ok = true;
                        }
                    }
                }
            }
            else
            {
                log.AddLog(Consts.ERRO_ENVIO_COMANDO);
                return(false);
            }
            return(Ok);
        }
Exemple #13
0
        public override bool sendFuncionario(AssepontoRep.Types.Funcionario Funcionario)
        {
            bool Result = base.sendFuncionario(Funcionario);

            Connect(TerminalDados.IP, TerminalDados.Porta);

            int  Operacao;
            bool Ok      = false;
            bool Teclado = false;

            string Habilitar_Teclado   = Teclado ? "S" : "N";
            string tempFuncionarioNome = "";
            string tempCracha          = "";
            bool   tempTeclado         = false;
            string tempCodigoTeclado   = "";
            string tempCodigoBarras    = "";
            string tempCodigoMifare    = "";
            string tempCodigoTag       = "";

            string CodigoMifare = "";
            string CodigoTag    = "";

            getFuncionario(Funcionario.Pis, out tempFuncionarioNome, out tempCracha, out tempTeclado,
                           out tempCodigoTeclado, out tempCodigoBarras, out tempCodigoMifare, out tempCodigoTag);

            Operacao = tempFuncionarioNome != String.Empty ? opAlteracao : opInclusao;

            /******************************************************************************************************************************
             * 'INCLUSÃO DE FUNCIONÁRIO                                                                                                      *
             * '******************************************************************************************************************************/
            /*Prepara o envio do cadastro do funcionário*/

            if (Funcionario.Crachas.Count > 0)
            {
                foreach (long Cracha in Funcionario.Crachas)
                {
                    REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_Funcionario_Prepara(REPZPM_DLL.Handle, Operacao, Funcionario.Pis, Convert.ToString(Cracha), Funcionario.Nome, "", Habilitar_Teclado, Convert.ToString(Cracha), Convert.ToString(Cracha), CodigoMifare, CodigoTag);
                }
            }

            /*Comando executado*/
            if (REPZPM_DLL.Retorno == 1)
            {
                REPZPM_DLL.ID_Comando = REPZPM_DLL.DLLREP_Funcionario_Envia(REPZPM_DLL.Handle);

                /*Comando de cadastro de funcionário foi enviado com sucesso se for maior que 0*/
                if (REPZPM_DLL.ID_Comando > 0)
                {
                    if (REPZPM_DLL.Modo == 0)
                    {
                        /*Obtém o código de erro*/
                        REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemCodigoErro(REPZPM_DLL.Handle, 1);

                        /*Se Retorno for <> de 0, então houve erro na execução do comando de cadastro de funcionário*/
                        if (REPZPM_DLL.Retorno != 0)
                        {
                            REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1);
                            log.AddLog(REPZPM_DLL.Trata_Retorno_REP(REPZPM_DLL.Retorno), true);
                        }
                        else
                        {
                            log.AddLog(Consts.FUNCIONARIO_ENVIANDO);
                            Ok = true;
                        }
                    }
                }
                else
                {
                    log.AddLog(Consts.ERRO_ENVIO_COMANDO);
                }
            }
            else
            {
                log.AddLog(Consts.ERRO_ENVIO_COMANDO);
            }

            return(Ok);
        }